7#include "absl/strings/str_format.h"
11#include "imgui/imgui.h"
19struct TemplateDescriptor {
24 const char* what_changes;
33 "Edit rooms, sprites, or graphics without custom code.",
34 "Creates a project on top of the ROM. The ROM itself is only modified "
35 "when you save edits inside the editors.",
38 "Resize overworld areas and add custom map features.",
39 "Applies the ZSO3 patch: expanded overworld tables, extended palette "
40 "and GFX storage, and custom entrances/exits.",
42 {
"ZSCustomOverworld v2",
ICON_MD_MAP,
"ZSCustomOverworld v2",
43 "Port an older hack that already uses ZSO v2.",
44 "Applies the legacy ZSO2 patch. Smaller feature set than v3.", 2},
46 "Build a ROM that has to work with ALTTPR or similar.",
47 "Keeps edits inside the surface randomizers patch over. Skips ASM "
48 "hooks and overworld remapping.",
57 if (name == kTemplates[i].
id)
92 constexpr const char* kPopupId =
"##new_project_dialog";
94 ImGui::OpenPopup(kPopupId);
98 ImGui::SetNextWindowSize(ImVec2(560, 0), ImGuiCond_Appearing);
99 if (!ImGui::BeginPopupModal(kPopupId,
nullptr,
100 ImGuiWindowFlags_AlwaysAutoResize |
101 ImGuiWindowFlags_NoSavedSettings)) {
111 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
113 "Pick a template, point at the ROM it should build on, and give the "
114 "project a name. The project file will be saved in your configured "
121 ImGui::TextUnformatted(
"Template");
123 ImGui::SetNextItemWidth(-1);
124 if (ImGui::BeginCombo(
"##template_combo", combo_preview)) {
127 const std::string label =
128 absl::StrFormat(
"%s %s", kTemplates[i].icon, kTemplates[i].name);
129 if (ImGui::Selectable(label.c_str(), selected)) {
133 ImGui::SetItemDefaultFocus();
142 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
144 ImGui::TextWrapped(
"%s Effect: %s",
ICON_MD_EDIT, tmpl.what_changes);
145 const char* skill_tag = tmpl.skill_level == 1 ?
"Beginner"
146 : tmpl.skill_level == 2 ?
"Intermediate"
148 ImGui::TextWrapped(
"%s Skill: %s",
ICON_MD_INFO, skill_tag);
154 ImGui::TextUnformatted(
"Source ROM");
155 const float browse_width = ImGui::CalcTextSize(
" Browse…").x +
157 ImGui::GetStyle().FramePadding.x * 2.0f + 8.0f;
158 ImGui::SetNextItemWidth(-browse_width - ImGui::GetStyle().ItemSpacing.x);
164 if (!picked.empty()) {
174 ImGui::TextUnformatted(
"Project name");
175 ImGui::SetNextItemWidth(-1);
179 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
181 "Used as the project display name and to derive the project filename. "
182 "Spaces are replaced with underscores.");
192 const bool rom_valid = !rom_path.empty() && std::filesystem::exists(rom_path);
193 const bool name_valid = !project_name.empty();
194 const bool can_create = rom_valid && name_valid;
197 ImGui::BeginDisabled();
203 ImGui::CloseCurrentPopup();
209 ImGui::EndDisabled();
212 if (ImGui::Button(
ICON_MD_CLOSE " Cancel", ImVec2(100, 0)) ||
213 ImGui::IsKeyPressed(ImGuiKey_Escape,
false)) {
214 ImGui::CloseCurrentPopup();
225 gui::StyleColorGuard warn_guard(ImGuiCol_Text, warn);
226 if (!rom_valid && rom_path.empty()) {
228 }
else if (!rom_valid) {
230 }
else if (!name_valid) {
void Open(const std::string &initial_template="")
std::string status_message_
char rom_path_buffer_[1024]
CreateCallback create_callback_
char project_name_buffer_[128]
void ApplyTemplateSelection(const std::string &name)
static ThemeManager & Get()
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
#define ICON_MD_ROCKET_LAUNCH
#define ICON_MD_FOLDER_OPEN
#define ICON_MD_LIGHTBULB
constexpr TemplateDescriptor kTemplates[]
constexpr int kTemplateCount
int FindTemplateIndex(const std::string &name)
ImVec4 ConvertColorToImVec4(const Color &color)
ImVec4 GetTextSecondaryVec4()