138 kTriforceGold = GetThemedColor(
"triforce_gold", kTriforceGoldFallback);
139 kHyruleGreen = GetThemedColor(
"hyrule_green", kHyruleGreenFallback);
140 kMasterSwordBlue = GetThemedColor(
"master_sword_blue", kMasterSwordBlueFallback);
141 kGanonPurple = GetThemedColor(
"ganon_purple", kGanonPurpleFallback);
142 kHeartRed = GetThemedColor(
"heart_red", kHeartRedFallback);
143 kSpiritOrange = GetThemedColor(
"spirit_orange", kSpiritOrangeFallback);
148 ImVec2 mouse_pos = ImGui::GetMousePos();
150 bool action_taken =
false;
153 ImGuiViewport* viewport = ImGui::GetMainViewport();
154 ImVec2 center = viewport->GetCenter();
155 ImVec2 viewport_size = viewport->Size;
157 float width = std::min(viewport_size.x * 0.8f, 1400.0f);
158 float height = std::min(viewport_size.y * 0.85f, 900.0f);
160 ImGui::SetNextWindowPos(center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
161 ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_Always);
163 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoCollapse |
164 ImGuiWindowFlags_NoResize |
165 ImGuiWindowFlags_NoMove;
167 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 20));
169 if (ImGui::Begin(
"##WelcomeScreen", p_open, window_flags)) {
170 ImDrawList* bg_draw_list = ImGui::GetWindowDrawList();
171 ImVec2 window_pos = ImGui::GetWindowPos();
172 ImVec2 window_size = ImGui::GetWindowSize();
175 struct TriforceConfig {
179 float repel_distance;
182 TriforceConfig triforce_configs[] = {
183 {0.08f, 0.12f, 36.0f, 0.025f, 50.0f},
184 {0.92f, 0.15f, 34.0f, 0.022f, 50.0f},
185 {0.06f, 0.88f, 32.0f, 0.020f, 45.0f},
186 {0.94f, 0.85f, 34.0f, 0.023f, 50.0f},
187 {0.50f, 0.08f, 38.0f, 0.028f, 55.0f},
188 {0.50f, 0.92f, 32.0f, 0.020f, 45.0f},
194 float x = window_pos.x + window_size.x * triforce_configs[i].x_pct;
195 float y = window_pos.y + window_size.y * triforce_configs[i].y_pct;
205 float base_x = window_pos.x + window_size.x * triforce_configs[i].x_pct;
206 float base_y = window_pos.y + window_size.y * triforce_configs[i].y_pct;
210 float time_offset = i * 1.2f;
217 float float_x = std::sin(
animation_time_ * float_speed_x + time_offset) * float_amount_x;
218 float float_y = std::cos(
animation_time_ * float_speed_y + time_offset * 1.2f) * float_amount_y;
223 float dist = std::sqrt(dx * dx + dy * dy);
227 float repel_radius = 200.0f;
230 target_pos.x += float_x;
231 target_pos.y += float_y;
236 float dir_x = dx / dist;
237 float dir_y = dy / dist;
240 float normalized_dist = dist / repel_radius;
241 float repel_strength = (1.0f - normalized_dist * normalized_dist) * triforce_configs[i].repel_distance;
243 target_pos.x += dir_x * repel_strength;
244 target_pos.y += dir_y * repel_strength;
257 adjusted_size, adjusted_alpha, 0.0f);
263 static float spawn_accumulator = 0.0f;
274 float angle = (rand() % 360) * (
M_PI / 180.0f);
275 float speed = 20.0f + (rand() % 40);
286 spawn_accumulator -= 1.0f;
290 float dt = ImGui::GetIO().DeltaTime;
309 ImU32 particle_color = ImGui::GetColorU32(ImVec4(1.0f, 0.843f, 0.0f, alpha));
321 ImDrawList* draw_list = ImGui::GetWindowDrawList();
322 ImVec2 separator_start = ImGui::GetCursorScreenPos();
323 ImVec2 separator_end(separator_start.x + ImGui::GetContentRegionAvail().x, separator_start.y + 1);
324 ImVec4 gold_faded = kTriforceGold;
326 ImVec4 blue_faded = kMasterSwordBlue;
328 draw_list->AddRectFilledMultiColor(
329 separator_start, separator_end,
330 ImGui::GetColorU32(gold_faded),
331 ImGui::GetColorU32(blue_faded),
332 ImGui::GetColorU32(blue_faded),
333 ImGui::GetColorU32(gold_faded));
335 ImGui::Dummy(ImVec2(0, 10));
337 ImGui::BeginChild(
"WelcomeContent", ImVec2(0, -60),
false);
340 ImGui::BeginChild(
"LeftPanel", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, 0),
true,
341 ImGuiWindowFlags_NoScrollbar);
346 ImVec2 sep_start = ImGui::GetCursorScreenPos();
349 ImVec2(sep_start.x + ImGui::GetContentRegionAvail().x, sep_start.y),
350 ImGui::GetColorU32(ImVec4(kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, 0.2f)),
353 ImGui::Dummy(ImVec2(0, 5));
360 ImGui::BeginChild(
"RightPanel", ImVec2(0, 0),
true);
365 sep_start = ImGui::GetCursorScreenPos();
368 ImVec2(sep_start.x + ImGui::GetContentRegionAvail().x, sep_start.y),
369 ImGui::GetColorU32(ImVec4(kMasterSwordBlue.x, kMasterSwordBlue.y, kMasterSwordBlue.z, 0.2f)),
372 ImGui::Dummy(ImVec2(0, 5));
379 ImVec2 footer_start = ImGui::GetCursorScreenPos();
380 ImVec2 footer_end(footer_start.x + ImGui::GetContentRegionAvail().x, footer_start.y + 1);
381 ImVec4 red_faded = kHeartRed;
383 ImVec4 green_faded = kHyruleGreen;
384 green_faded.w = 0.3f;
385 draw_list->AddRectFilledMultiColor(
386 footer_start, footer_end,
387 ImGui::GetColorU32(red_faded),
388 ImGui::GetColorU32(green_faded),
389 ImGui::GetColorU32(green_faded),
390 ImGui::GetColorU32(red_faded));
392 ImGui::Dummy(ImVec2(0, 5));
397 ImGui::PopStyleVar();
445 ImDrawList* draw_list = ImGui::GetWindowDrawList();
447 ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[2]);
451 auto windowWidth = ImGui::GetWindowSize().x;
452 auto textWidth = ImGui::CalcTextSize(title).x;
453 float xPos = (windowWidth - textWidth) * 0.5f;
455 ImGui::SetCursorPosX(xPos);
456 ImVec2 text_pos = ImGui::GetCursorScreenPos();
459 float glow_size = 30.0f;
460 ImU32 glow_color = ImGui::GetColorU32(ImVec4(kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, 0.15f));
461 draw_list->AddCircleFilled(
462 ImVec2(text_pos.x + textWidth / 2, text_pos.y + 15),
468 ImGui::TextColored(kTriforceGold,
"%s", title);
472 const char* subtitle =
"Yet Another Zelda3 Editor";
473 textWidth = ImGui::CalcTextSize(subtitle).x;
474 ImGui::SetCursorPosX((windowWidth - textWidth) * 0.5f);
476 ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"%s", subtitle);
480 ImVec2 left_tri_pos(xPos - 80, text_pos.y + 20);
481 ImVec2 right_tri_pos(xPos + textWidth + 50, text_pos.y + 20);
482 DrawTriforceBackground(draw_list, left_tri_pos, 20, 0.12f, 0.0f);
483 DrawTriforceBackground(draw_list, right_tri_pos, 20, 0.12f, 0.0f);
572 ImVec2 card_size(200, 95);
573 ImVec2 cursor_pos = ImGui::GetCursorScreenPos();
578 ImVec2 center(cursor_pos.x + card_size.x / 2, cursor_pos.y + card_size.y / 2);
579 cursor_pos.x = center.x - (card_size.x * scale) / 2;
580 cursor_pos.y = center.y - (card_size.y * scale) / 2;
581 card_size.x *= scale;
582 card_size.y *= scale;
586 ImDrawList* draw_list = ImGui::GetWindowDrawList();
589 ImU32 color_top = ImGui::GetColorU32(ImVec4(0.15f, 0.20f, 0.25f, 1.0f));
590 ImU32 color_bottom = ImGui::GetColorU32(ImVec4(0.10f, 0.15f, 0.20f, 1.0f));
591 draw_list->AddRectFilledMultiColor(
593 ImVec2(cursor_pos.x + card_size.x, cursor_pos.y + card_size.y),
594 color_top, color_top, color_bottom, color_bottom);
597 ImVec4 border_color_base = (index % 3 == 0) ? kHyruleGreen :
598 (index % 3 == 1) ? kMasterSwordBlue : kTriforceGold;
599 ImU32 border_color = ImGui::GetColorU32(
600 ImVec4(border_color_base.x, border_color_base.y, border_color_base.z, 0.5f));
602 draw_list->AddRect(cursor_pos,
603 ImVec2(cursor_pos.x + card_size.x, cursor_pos.y + card_size.y),
604 border_color, 6.0f, 0, 2.0f);
607 ImGui::SetCursorScreenPos(cursor_pos);
608 ImGui::InvisibleButton(absl::StrFormat(
"ProjectCard_%d", index).c_str(), card_size);
609 bool is_hovered = ImGui::IsItemHovered();
610 bool is_clicked = ImGui::IsItemClicked();
616 ImU32 hover_color = ImGui::GetColorU32(ImVec4(kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, 0.15f));
617 draw_list->AddRectFilled(cursor_pos,
618 ImVec2(cursor_pos.x + card_size.x, cursor_pos.y + card_size.y),
623 ImVec2 content_pos(cursor_pos.x + 8, cursor_pos.y + 8);
626 ImVec2 icon_center(content_pos.x + 13, content_pos.y + 13);
627 ImU32 icon_bg = ImGui::GetColorU32(border_color_base);
628 draw_list->AddCircleFilled(icon_center, 15, icon_bg, 24);
632 ImGui::SetCursorScreenPos(ImVec2(icon_center.x - icon_size.x / 2, icon_center.y - icon_size.y / 2));
633 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
635 ImGui::PopStyleColor();
638 ImGui::SetCursorScreenPos(ImVec2(content_pos.x + 32, content_pos.y + 8));
639 ImGui::PushTextWrapPos(cursor_pos.x + card_size.x - 8);
640 ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[0]);
641 std::string short_name = project.
name;
642 if (short_name.length() > 22) {
643 short_name = short_name.substr(0, 19) +
"...";
645 ImGui::TextColored(kTriforceGold,
"%s", short_name.c_str());
647 ImGui::PopTextWrapPos();
650 ImGui::SetCursorScreenPos(ImVec2(content_pos.x + 4, content_pos.y + 35));
651 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.65f, 0.65f, 0.65f, 1.0f));
653 ImGui::PopStyleColor();
656 ImGui::SetCursorScreenPos(ImVec2(content_pos.x + 4, content_pos.y + 58));
657 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.4f, 0.4f, 0.4f, 1.0f));
658 std::string short_path = project.
filepath;
659 if (short_path.length() > 26) {
660 short_path =
"..." + short_path.substr(short_path.length() - 23);
663 ImGui::PopStyleColor();
667 ImGui::BeginTooltip();
668 ImGui::TextColored(kMasterSwordBlue,
ICON_MD_INFO " Project Details");
670 ImGui::Text(
"Name: %s", project.
name.c_str());
671 ImGui::Text(
"ROM: %s", project.
rom_title.c_str());
672 ImGui::Text(
"Path: %s", project.
filepath.c_str());
688 float content_width = ImGui::GetContentRegionAvail().x;
690 ImGui::SameLine(content_width - 25);
694 if (ImGui::IsItemHovered()) {
702 ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.18f, 0.15f, 0.22f, 0.4f));
703 ImGui::BeginChild(
"VisualSettingsCompact", ImVec2(0, 115),
true, ImGuiWindowFlags_NoScrollbar);
709 ImGui::SetNextItemWidth(-1);
713 ImGui::SetNextItemWidth(-1);
730 ImGui::PopStyleColor();
742 Template templates[] = {
744 {
ICON_MD_MAP,
"ZSCustomOverworld v3", kMasterSwordBlue},
747 for (
int i = 0; i < 2; ++i) {
752 ImGui::PushStyleColor(ImGuiCol_Header,
753 ImVec4(templates[i].color.x * 0.6f, templates[i].color.y * 0.6f,
754 templates[i].color.z * 0.6f, 0.6f));
757 if (ImGui::Selectable(absl::StrFormat(
"%s %s", templates[i].icon, templates[i].name).c_str(),
763 ImGui::PopStyleColor();
766 if (ImGui::IsItemHovered()) {
767 ImGui::SetTooltip(
ICON_MD_STAR " Start with a %s template", templates[i].name);
772 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(kSpiritOrange.x * 0.6f, kSpiritOrange.y * 0.6f, kSpiritOrange.z * 0.6f, 0.8f));
773 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, kSpiritOrange);
774 ImGui::BeginDisabled(
true);
777 ImGui::EndDisabled();
778 ImGui::PopStyleColor(2);