Improved rando settings (#3980)

* Initial implementation

* center icons (#5)

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
This commit is contained in:
Pepe20129 2024-07-17 05:25:28 +02:00 committed by GitHub
parent 8eb6304999
commit f2958aea1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 146 additions and 91 deletions

View File

@ -639,20 +639,14 @@ void InitEntranceTrackingData() {
SortEntranceListByType(destListSortedByType, 1); SortEntranceListByType(destListSortedByType, 1);
} }
void EntranceTrackerWindow::DrawElement() { void EntranceTrackerSettingsWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Entrance Tracker", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { if (!ImGui::Begin("Entrance Tracker Settings", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End(); ImGui::End();
return; return;
} }
// Begin tracker settings
ImGui::SetNextItemOpen(false, ImGuiCond_Once);
if (ImGui::TreeNode("Tracker Settings")) {
// Reduce indentation from the tree node for the table
ImGui::SetCursorPosX((ImGui::GetCursorPosX() / 2) + 4.0f);
if (ImGui::BeginTable("entranceTrackerSettings", 1, ImGuiTableFlags_BordersInnerH)) { if (ImGui::BeginTable("entranceTrackerSettings", 1, ImGuiTableFlags_BordersInnerH)) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
@ -725,9 +719,15 @@ void EntranceTrackerWindow::DrawElement() {
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::TreePop(); ImGui::End();
} else { }
UIWidgets::PaddedSeparator();
void EntranceTrackerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Entrance Tracker", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
} }
static ImGuiTextFilter locationSearch; static ImGuiTextFilter locationSearch;

View File

@ -85,6 +85,16 @@ s16 GetLastEntranceOverride();
s16 GetCurrentGrottoId(); s16 GetCurrentGrottoId();
const EntranceData* GetEntranceData(s16); const EntranceData* GetEntranceData(s16);
class EntranceTrackerSettingsWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
protected:
void InitElement() override {};
void DrawElement() override;
void UpdateElement() override {};
};
class EntranceTrackerWindow : public Ship::GuiWindow { class EntranceTrackerWindow : public Ship::GuiWindow {
public: public:
using GuiWindow::GuiWindow; using GuiWindow::GuiWindow;

View File

@ -129,6 +129,7 @@ namespace SohGui {
std::shared_ptr<GameplayStatsWindow> mGameplayStatsWindow; std::shared_ptr<GameplayStatsWindow> mGameplayStatsWindow;
std::shared_ptr<CheckTracker::CheckTrackerSettingsWindow> mCheckTrackerSettingsWindow; std::shared_ptr<CheckTracker::CheckTrackerSettingsWindow> mCheckTrackerSettingsWindow;
std::shared_ptr<CheckTracker::CheckTrackerWindow> mCheckTrackerWindow; std::shared_ptr<CheckTracker::CheckTrackerWindow> mCheckTrackerWindow;
std::shared_ptr<EntranceTrackerSettingsWindow> mEntranceTrackerSettingsWindow;
std::shared_ptr<EntranceTrackerWindow> mEntranceTrackerWindow; std::shared_ptr<EntranceTrackerWindow> mEntranceTrackerWindow;
std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow; std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow;
std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow; std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow;
@ -193,6 +194,8 @@ namespace SohGui {
gui->AddGuiWindow(mCheckTrackerSettingsWindow); gui->AddGuiWindow(mCheckTrackerSettingsWindow);
mEntranceTrackerWindow = std::make_shared<EntranceTrackerWindow>(CVAR_WINDOW("EntranceTracker"), "Entrance Tracker"); mEntranceTrackerWindow = std::make_shared<EntranceTrackerWindow>(CVAR_WINDOW("EntranceTracker"), "Entrance Tracker");
gui->AddGuiWindow(mEntranceTrackerWindow); gui->AddGuiWindow(mEntranceTrackerWindow);
mEntranceTrackerSettingsWindow = std::make_shared<EntranceTrackerSettingsWindow>(CVAR_WINDOW("EntranceTrackerSettings"), "Entrance Tracker Settings");
gui->AddGuiWindow(mEntranceTrackerSettingsWindow);
mItemTrackerWindow = std::make_shared<ItemTrackerWindow>(CVAR_WINDOW("ItemTracker"), "Item Tracker"); mItemTrackerWindow = std::make_shared<ItemTrackerWindow>(CVAR_WINDOW("ItemTracker"), "Item Tracker");
gui->AddGuiWindow(mItemTrackerWindow); gui->AddGuiWindow(mItemTrackerWindow);
mItemTrackerSettingsWindow = std::make_shared<ItemTrackerSettingsWindow>(CVAR_WINDOW("ItemTrackerSettings"), "Item Tracker Settings"); mItemTrackerSettingsWindow = std::make_shared<ItemTrackerSettingsWindow>(CVAR_WINDOW("ItemTrackerSettings"), "Item Tracker Settings");
@ -213,6 +216,7 @@ namespace SohGui {
mItemTrackerWindow = nullptr; mItemTrackerWindow = nullptr;
mItemTrackerSettingsWindow = nullptr; mItemTrackerSettingsWindow = nullptr;
mEntranceTrackerWindow = nullptr; mEntranceTrackerWindow = nullptr;
mEntranceTrackerSettingsWindow = nullptr;
mCheckTrackerWindow = nullptr; mCheckTrackerWindow = nullptr;
mCheckTrackerSettingsWindow = nullptr; mCheckTrackerSettingsWindow = nullptr;
mGameplayStatsWindow = nullptr; mGameplayStatsWindow = nullptr;

View File

@ -38,6 +38,10 @@
#include "Enhancements/randomizer/randomizer_settings_window.h" #include "Enhancements/randomizer/randomizer_settings_window.h"
#include "Enhancements/resolution-editor/ResolutionEditor.h" #include "Enhancements/resolution-editor/ResolutionEditor.h"
// FA icons are kind of wonky, if they worked how I expected them to the "+ 2.0f" wouldn't be needed, but
// they don't work how I expect them to so I added that because it looked good when I eyeballed it
#define FA_ICON_BUTTON_FRAME_PADDING_X(icon) (((optionsButtonSize.x - ImGui::CalcTextSize(icon).x) / 2) + 2.0f)
extern bool ToggleAltAssetsAtEndOfFrame; extern bool ToggleAltAssetsAtEndOfFrame;
extern bool isBetaQuestEnabled; extern bool isBetaQuestEnabled;
@ -1963,6 +1967,7 @@ extern std::shared_ptr<RandomizerSettingsWindow> mRandomizerSettingsWindow;
extern std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow; extern std::shared_ptr<ItemTrackerWindow> mItemTrackerWindow;
extern std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow; extern std::shared_ptr<ItemTrackerSettingsWindow> mItemTrackerSettingsWindow;
extern std::shared_ptr<EntranceTrackerWindow> mEntranceTrackerWindow; extern std::shared_ptr<EntranceTrackerWindow> mEntranceTrackerWindow;
extern std::shared_ptr<EntranceTrackerSettingsWindow> mEntranceTrackerSettingsWindow;
extern std::shared_ptr<CheckTracker::CheckTrackerWindow> mCheckTrackerWindow; extern std::shared_ptr<CheckTracker::CheckTrackerWindow> mCheckTrackerWindow;
extern std::shared_ptr<CheckTracker::CheckTrackerSettingsWindow> mCheckTrackerSettingsWindow; extern std::shared_ptr<CheckTracker::CheckTrackerSettingsWindow> mCheckTrackerSettingsWindow;
extern "C" u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); extern "C" u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
@ -1981,11 +1986,19 @@ void DrawRandomizerMenu() {
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f));
#ifdef __WIIU__ #ifdef __WIIU__
static ImVec2 buttonSize(200.0f * 2.0f, 0.0f); static ImVec2 buttonSize(200.0f * 2.0f, 0.0f);
static ImVec2 buttonWithOptionsSize(170.0f * 2.0f, 0.0f);
static ImVec2 optionsButtonSize(25.0f * 2.0f, 0.0f);
static float separationToOptionsButton = 5.0f * 2.0f;
#else #else
static ImVec2 buttonSize(200.0f, 0.0f); static ImVec2 buttonSize(200.0f, 0.0f);
static ImVec2 buttonWithOptionsSize(170.0f, 0.0f);
static ImVec2 optionsButtonSize(25.0f, 0.0f);
static float separationToOptionsButton = 5.0f;
#endif #endif
if (mRandomizerSettingsWindow) { if (mRandomizerSettingsWindow) {
if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVarGetInteger(CVAR_WINDOW("RandomizerSettings"), 0)).c_str(), buttonSize)) { if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVarGetInteger(CVAR_WINDOW("RandomizerSettings"), 0)).c_str(), buttonSize)) {
mRandomizerSettingsWindow->ToggleVisibility(); mRandomizerSettingsWindow->ToggleVisibility();
@ -1993,36 +2006,64 @@ void DrawRandomizerMenu() {
} }
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
if (mItemTrackerWindow) { if (mItemTrackerWindow) {
if (ImGui::Button(GetWindowButtonText("Item Tracker", CVarGetInteger(CVAR_WINDOW("ItemTracker"), 0)).c_str(), buttonSize)) { if (ImGui::Button(GetWindowButtonText("Item Tracker", CVarGetInteger(CVAR_WINDOW("ItemTracker"), 0)).c_str(), buttonWithOptionsSize)) {
mItemTrackerWindow->ToggleVisibility(); mItemTrackerWindow->ToggleVisibility();
} }
} }
UIWidgets::Spacer(0); ImGui::SameLine(0, 0);
ImVec2 cursor = ImGui::GetCursorPos();
ImGui::SetCursorPos(ImVec2(cursor.x + separationToOptionsButton, cursor.y));
if (mItemTrackerSettingsWindow) { if (mItemTrackerSettingsWindow) {
if (ImGui::Button(GetWindowButtonText("Item Tracker Settings", CVarGetInteger(CVAR_WINDOW("ItemTrackerSettings"), 0)).c_str(), buttonSize)) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(FA_ICON_BUTTON_FRAME_PADDING_X(ICON_FA_COG), 6.0f));
if (ImGui::Button(ICON_FA_COG "##ItemTrackerSettings", optionsButtonSize)) {
mItemTrackerSettingsWindow->ToggleVisibility(); mItemTrackerSettingsWindow->ToggleVisibility();
} }
ImGui::PopStyleVar();
} }
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
if (mEntranceTrackerWindow) { if (mEntranceTrackerWindow) {
if (ImGui::Button(GetWindowButtonText("Entrance Tracker", CVarGetInteger(CVAR_WINDOW("EntranceTracker"), 0)).c_str(), buttonSize)) { if (ImGui::Button(GetWindowButtonText("Entrance Tracker", CVarGetInteger(CVAR_WINDOW("EntranceTracker"), 0)).c_str(), buttonWithOptionsSize)) {
mEntranceTrackerWindow->ToggleVisibility(); mEntranceTrackerWindow->ToggleVisibility();
} }
} }
ImGui::SameLine(0, 0);
cursor = ImGui::GetCursorPos();
ImGui::SetCursorPos(ImVec2(cursor.x + separationToOptionsButton, cursor.y));
if (mEntranceTrackerSettingsWindow) {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(FA_ICON_BUTTON_FRAME_PADDING_X(ICON_FA_COG), 6.0f));
if (ImGui::Button(ICON_FA_COG "##EntranceTrackerSettings", optionsButtonSize)) {
mEntranceTrackerSettingsWindow->ToggleVisibility();
}
ImGui::PopStyleVar();
}
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
if (mCheckTrackerWindow) { if (mCheckTrackerWindow) {
if (ImGui::Button(GetWindowButtonText("Check Tracker", CVarGetInteger(CVAR_WINDOW("CheckTracker"), 0)).c_str(), buttonSize)) { if (ImGui::Button(GetWindowButtonText("Check Tracker", CVarGetInteger(CVAR_WINDOW("CheckTracker"), 0)).c_str(), buttonWithOptionsSize)) {
mCheckTrackerWindow->ToggleVisibility(); mCheckTrackerWindow->ToggleVisibility();
} }
} }
UIWidgets::Spacer(0);
ImGui::SameLine(0, 0);
cursor = ImGui::GetCursorPos();
ImGui::SetCursorPos(ImVec2(cursor.x + separationToOptionsButton, cursor.y));
if (mCheckTrackerSettingsWindow) { if (mCheckTrackerSettingsWindow) {
if (ImGui::Button(GetWindowButtonText("Check Tracker Settings", CVarGetInteger(CVAR_WINDOW("CheckTrackerSettings"), 0)).c_str(), buttonSize)) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(FA_ICON_BUTTON_FRAME_PADDING_X(ICON_FA_COG), 6.0f));
if (ImGui::Button(ICON_FA_COG "##CheckTrackerSettings", optionsButtonSize)) {
mCheckTrackerSettingsWindow->ToggleVisibility(); mCheckTrackerSettingsWindow->ToggleVisibility();
} }
ImGui::PopStyleVar();
} }
ImGui::PopStyleVar(3); ImGui::PopStyleVar(3);
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);