Update archipelago menu styling
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
#include "soh/SohGui/UIWidgets.hpp"
|
||||
#include "soh/SohGui/SohGui.hpp"
|
||||
#include "soh/OTRGlobals.h"
|
||||
|
||||
ImVector<char*> 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");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -199,10 +199,10 @@ void SetupGuiElements() {
|
||||
std::make_shared<PlandomizerWindow>(CVAR_WINDOW("PlandomizerEditor"), "Plandomizer Editor", ImVec2(850, 760));
|
||||
gui->AddGuiWindow(mPlandomizerWindow);
|
||||
mArchipelagoSettingsWindow = std::make_shared<ArchipelagoSettingsWindow>(CVAR_WINDOW("ArchipelagoSettingsWindow"),
|
||||
"Archipelago Settings", ImVec2(850, 760));
|
||||
"Archipelago Settings", ImVec2(600, 450));
|
||||
gui->AddGuiWindow(mArchipelagoSettingsWindow);
|
||||
mArchipelagoConsoleWindow = std::make_shared<ArchipelagoConsoleWindow>(CVAR_WINDOW("ArchipelagoConsoleWindow"),
|
||||
"Archipelago Console", ImVec2(850, 760));
|
||||
"Archipelago Console", ImVec2(600, 550));
|
||||
gui->AddGuiWindow(mArchipelagoConsoleWindow);
|
||||
mModalWindow = std::make_shared<SohModalWindow>(CVAR_WINDOW("ModalWindow"), "Modal Window");
|
||||
gui->AddGuiWindow(mModalWindow);
|
||||
|
||||
@@ -33,6 +33,7 @@ void SohMenu::AddMenuNetwork() {
|
||||
|
||||
// Sail
|
||||
path.sidebarName = "Sail";
|
||||
path.column = SECTION_COLUMN_1;
|
||||
AddSidebarEntry("Network", path.sidebarName, 3);
|
||||
|
||||
AddWidget(path,
|
||||
|
||||
Reference in New Issue
Block a user