From 9e3e11692fbecfc90861dccc6dab5922f860bbe4 Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 19 May 2025 12:31:12 +0200 Subject: [PATCH] Update archipelago menu styling --- .../Archipelago/ArchipelagoConsoleWindow.cpp | 48 ++++++++++--------- .../Archipelago/ArchipelagoSettingsWindow.cpp | 32 +++++++++---- soh/soh/SohGui/SohGui.cpp | 4 +- soh/soh/SohGui/SohMenuNetwork.cpp | 1 + 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp index 7fb8b8d07..c5fddfb3a 100644 --- a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp +++ b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp @@ -2,10 +2,12 @@ #include "soh/SohGui/UIWidgets.hpp" #include "soh/SohGui/SohGui.hpp" +#include "soh/OTRGlobals.h" ImVector Items; bool autoScroll = true; -bool scrollToBottom = false; + +using namespace UIWidgets; void ArchipelagoConsole_SendMessage(const char* fmt, ...) IM_FMTARGS(2) { char buf[1024]; @@ -18,22 +20,17 @@ void ArchipelagoConsole_SendMessage(const char* fmt, ...) IM_FMTARGS(2) { } void ArchipelagoConsoleWindow::DrawElement() { - if (ImGui::Button("Add line to log")) { - ArchipelagoConsole_SendMessage("[LOG] Hello World"); - ArchipelagoConsole_SendMessage("[ERROR] Hello World"); - ArchipelagoConsole_SendMessage("Hello World"); - } + ImGui::SeparatorText("Archipelago Log"); - if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), false, + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.15f, 0.15f, 0.15f, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 8.0f); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(15.0f, 12.0f)); + + if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), ImGuiChildFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_HorizontalScrollbar)) { - - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing for (int i = 0; i < Items.Size; i++) { const char* item = Items[i]; - - // Normally you would store more information in your item than just a string. - // (e.g. make Items[] an array of structure, store color/type etc.) ImVec4 color; bool hasColor = false; if (strstr(item, "[ERROR]")) { @@ -42,25 +39,32 @@ void ArchipelagoConsoleWindow::DrawElement() { } else if (strstr(item, "[LOG]")) { color = ImVec4(0.7f, 0.7f, 1.0f, 1.0f); hasColor = true; - } else if (strncmp(item, "# ", 2) == 0) { - color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f); - hasColor = true; } - if (hasColor) + if (hasColor) { ImGui::PushStyleColor(ImGuiCol_Text, color); + } + ImGui::TextUnformatted(item); - if (hasColor) + + if (hasColor) { ImGui::PopStyleColor(); + } } // Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame. // Using a scrollbar or mouse-wheel will take away from the bottom edge. - if (scrollToBottom || (autoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())) { + if (autoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) { ImGui::SetScrollHereY(1.0f); - } - scrollToBottom = false; - - ImGui::PopStyleVar(); + } } ImGui::EndChild(); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(2); + + if (UIWidgets::Button("Add dummy lines to log", + UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { + ArchipelagoConsole_SendMessage("[LOG] Hello World"); + ArchipelagoConsole_SendMessage("[ERROR] Hello World"); + ArchipelagoConsole_SendMessage("Hello World"); + } }; diff --git a/soh/soh/Network/Archipelago/ArchipelagoSettingsWindow.cpp b/soh/soh/Network/Archipelago/ArchipelagoSettingsWindow.cpp index 15eaa6072..fe22a45f4 100644 --- a/soh/soh/Network/Archipelago/ArchipelagoSettingsWindow.cpp +++ b/soh/soh/Network/Archipelago/ArchipelagoSettingsWindow.cpp @@ -7,13 +7,24 @@ void ArchipelagoSettingsWindow::DrawElement() { ArchipelagoClient& AP_client = ArchipelagoClient::GetInstance(); + ImGui::SeparatorText("Connection info"); - ImGui::InputText("Server Address", AP_client.GetServerAddressBuffer(), AP_Client_consts::MAX_ADDRESS_LENGTH); - ImGui::InputText("Slot Name", AP_client.GetSlotNameBuffer(), AP_Client_consts::MAX_PLAYER_NAME_LENGHT); - ImGui::InputText("Password (leave blank for no password)", AP_client.GetPasswordBuffer(), + + UIWidgets::PushStyleCombobox(THEME_COLOR); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::ColorValues.at(THEME_COLOR)); + + ImGui::Text("Server Address"); + ImGui::InputText("##serveraddress", AP_client.GetServerAddressBuffer(), AP_Client_consts::MAX_ADDRESS_LENGTH); + ImGui::Text("Slot Name"); + ImGui::InputText("##slotname", AP_client.GetSlotNameBuffer(), AP_Client_consts::MAX_PLAYER_NAME_LENGHT); + ImGui::Text("Password (leave blank for no password)"); + ImGui::InputText("##password", AP_client.GetPasswordBuffer(), AP_Client_consts::MAX_PASSWORD_LENGTH, ImGuiInputTextFlags_Password); - if (ImGui::Button("Connect")) { + ImGui::PopStyleColor(); + UIWidgets::PopStyleCombobox(); + + if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { bool success = AP_client.StartClient(); ArchipelagoConsole_SendMessage("[LOG] Trying to connect..."); } @@ -21,17 +32,18 @@ void ArchipelagoSettingsWindow::DrawElement() { ImGui::SameLine(); ImGui::Text(ArchipelagoClient::GetInstance().GetConnectionStatus()); - if (ImGui::Button("Scout")) { + // Temporary developer helpers + ImGui::SeparatorText("Developer Tools"); + if (UIWidgets::Button("Scout", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { AP_client.StartLocationScouts(); } ImGui::SameLine(); - if (ImGui::Button("Link up")) { + if (UIWidgets::Button("Link up", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { CVarSetInteger("ArchipelagoConnected", 1); } - - UIWidgets::PaddedSeparator(); - - if(ImGui::Button("Give Blue Rupee")) { + ImGui::SameLine(); + if (UIWidgets::Button("Give Blue Rupee", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { ArchipelagoClient::GetInstance().OnItemReceived(66077, true); } + }; \ No newline at end of file diff --git a/soh/soh/SohGui/SohGui.cpp b/soh/soh/SohGui/SohGui.cpp index ca258596b..b7dd20cc4 100644 --- a/soh/soh/SohGui/SohGui.cpp +++ b/soh/soh/SohGui/SohGui.cpp @@ -199,10 +199,10 @@ void SetupGuiElements() { std::make_shared(CVAR_WINDOW("PlandomizerEditor"), "Plandomizer Editor", ImVec2(850, 760)); gui->AddGuiWindow(mPlandomizerWindow); mArchipelagoSettingsWindow = std::make_shared(CVAR_WINDOW("ArchipelagoSettingsWindow"), - "Archipelago Settings", ImVec2(850, 760)); + "Archipelago Settings", ImVec2(600, 450)); gui->AddGuiWindow(mArchipelagoSettingsWindow); mArchipelagoConsoleWindow = std::make_shared(CVAR_WINDOW("ArchipelagoConsoleWindow"), - "Archipelago Console", ImVec2(850, 760)); + "Archipelago Console", ImVec2(600, 550)); gui->AddGuiWindow(mArchipelagoConsoleWindow); mModalWindow = std::make_shared(CVAR_WINDOW("ModalWindow"), "Modal Window"); gui->AddGuiWindow(mModalWindow); diff --git a/soh/soh/SohGui/SohMenuNetwork.cpp b/soh/soh/SohGui/SohMenuNetwork.cpp index cc3b0c1a4..f4a45e75b 100644 --- a/soh/soh/SohGui/SohMenuNetwork.cpp +++ b/soh/soh/SohGui/SohMenuNetwork.cpp @@ -33,6 +33,7 @@ void SohMenu::AddMenuNetwork() { // Sail path.sidebarName = "Sail"; + path.column = SECTION_COLUMN_1; AddSidebarEntry("Network", path.sidebarName, 3); AddWidget(path,