Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui window rework #4307

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions soh/soh/Enhancements/audio/AudioEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,6 @@ void AudioEditor::InitElement() {
void AudioEditor::DrawElement() {
AudioCollection::Instance->InitializeShufflePool();

ImGui::SetNextWindowSize(ImVec2(820, 630), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Audio Editor", &mIsVisible)) {
ImGui::End();
return;
}

float buttonSegments = ImGui::GetContentRegionAvail().x / 4;
if (ImGui::Button("Randomize All Groups", ImVec2(buttonSegments, 30.0f))) {
AudioEditor_RandomizeAll();
Expand Down Expand Up @@ -700,7 +694,6 @@ void AudioEditor::DrawElement() {

ImGui::EndTabBar();
}
ImGui::End();
}

std::vector<SeqType> allTypes = { SEQ_BGM_WORLD, SEQ_BGM_EVENT, SEQ_BGM_BATTLE, SEQ_OCARINA, SEQ_FANFARE, SEQ_INSTRUMENT, SEQ_SFX, SEQ_VOICE };
Expand Down
656 changes: 330 additions & 326 deletions soh/soh/Enhancements/controls/InputViewer.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions soh/soh/Enhancements/controls/InputViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class InputViewer : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;

void Draw() override;
void InitElement() override {};
void DrawElement() override;
void UpdateElement() override {};
Expand Down
7 changes: 0 additions & 7 deletions soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,12 +1687,6 @@ static const char* colorSchemes[2] = {
};

void CosmeticsEditorWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(550, 520), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Cosmetics Editor", &mIsVisible)) {
ImGui::End();
return;
}

ImGui::Text("Color Scheme");
ImGui::SameLine();
UIWidgets::EnhancementCombobox(CVAR_COSMETIC("DefaultColorScheme"), colorSchemes, COLORSCHEME_N64);
Expand Down Expand Up @@ -1811,7 +1805,6 @@ void CosmeticsEditorWindow::DrawElement() {
}
ImGui::EndTabBar();
}
ImGui::End();
}

void RegisterOnLoadGameHook() {
Expand Down
6 changes: 0 additions & 6 deletions soh/soh/Enhancements/debugger/MessageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ void MessageViewer::InitElement() {
}

void MessageViewer::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Custom Message Debugger", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}
ImGui::Text("Table ID");
ImGui::SameLine();
ImGui::InputText("##TableID", mTableIdBuf, MAX_STRING_SIZE, ImGuiInputTextFlags_CallbackCharFilter, UIWidgets::TextFilters::FilterAlphaNum);
Expand Down Expand Up @@ -74,7 +69,6 @@ void MessageViewer::DrawElement() {
if (ImGui::Button("Display Message##CustomMessage")) {
mDisplayCustomMessageClicked = true;
}
ImGui::End();
// ReSharper restore CppDFAUnreachableCode
}

Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/debugger/actorViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,6 @@ void ActorViewer_AddTagForAllActors() {
}

void ActorViewerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Actor Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

static Actor* display;
static Actor empty{};
static Actor* fetch = NULL;
Expand Down Expand Up @@ -1235,8 +1229,6 @@ void ActorViewerWindow::DrawElement() {
actors.clear();
}
}

ImGui::End();
}

void ActorViewerWindow::InitElement() {
Expand Down
7 changes: 0 additions & 7 deletions soh/soh/Enhancements/debugger/colViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ static std::vector<Vtx> sphereVtx;

// Draws the ImGui window for the collision viewer
void ColViewerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Collision Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}
UIWidgets::EnhancementCheckbox("Enabled", CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"));

UIWidgets::LabeledRightAlignedEnhancementCombobox("Scene", CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), ColRenderSettingNames, COLVIEW_DISABLED);
Expand Down Expand Up @@ -95,8 +90,6 @@ void ColViewerWindow::DrawElement() {
} else {
UIWidgets::InsertHelpHoverText(colorHelpText);
}

ImGui::End();
}

// Calculates the normal for a triangle at the 3 specified points
Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/debugger/debugSaveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,12 +1747,6 @@ void DrawPlayerTab() {
}

void SaveEditorWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Save Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

if (ImGui::BeginTabBar("SaveContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) {
if (ImGui::BeginTabItem("Info")) {
DrawInfoTab();
Expand Down Expand Up @@ -1786,8 +1780,6 @@ void SaveEditorWindow::DrawElement() {

ImGui::EndTabBar();
}

ImGui::End();
}

void SaveEditorWindow::InitElement() {
Expand Down
11 changes: 0 additions & 11 deletions soh/soh/Enhancements/debugger/dlViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ void PerformDisplayListSearch() {
}

void DLViewerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Display List Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

// Debounce the search field as listing otr files is expensive
if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) {
doSearch = true;
Expand All @@ -122,7 +116,6 @@ void DLViewerWindow::DrawElement() {
}

if (activeDisplayList == "") {
ImGui::End();
return;
}

Expand All @@ -131,7 +124,6 @@ void DLViewerWindow::DrawElement() {

if (res->GetInitData()->Type != static_cast<uint32_t>(LUS::ResourceType::DisplayList)) {
ImGui::Text("Resource type is not a Display List. Please choose another.");
ImGui::End();
return;
}

Expand Down Expand Up @@ -325,11 +317,8 @@ void DLViewerWindow::DrawElement() {
}
} catch (const std::exception& e) {
ImGui::Text("Error displaying DL instructions.");
ImGui::End();
return;
}

ImGui::End();
}

void DLViewerWindow::InitElement() {
Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/debugger/valueViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ extern "C" void ValueViewer_Draw(GfxPrint* printer) {
}

void ValueViewerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Value Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

UIWidgets::PaddedEnhancementCheckbox("Enable Printing", CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting"));

ImGui::BeginGroup();
Expand Down Expand Up @@ -212,8 +206,6 @@ void ValueViewerWindow::DrawElement() {
}
ImGui::EndGroup();
}

ImGui::End();
}

void ValueViewerWindow::InitElement() {
Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/gameplaystats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,6 @@ void DrawGameplayStatsOptionsTab() {
}

void GameplayStatsWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(480, 550), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Gameplay Stats", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

DrawGameplayStatsHeader();

if (ImGui::BeginTabBar("Stats", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) {
Expand All @@ -648,8 +642,6 @@ void GameplayStatsWindow::DrawElement() {
}

ImGui::Text("Note: Gameplay stats are saved to the current file and will be\nlost if you quit without saving.");

ImGui::End();
}
void InitStats(bool isDebug) {
gSaveContext.sohStats.heartPieces = isDebug ? 8 : 0;
Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3137,13 +3137,6 @@ void RandomizerSettingsWindow::DrawElement() {

static int maxKeyringCount;
static bool disableGFKeyring = false;

ImGui::SetNextWindowSize(ImVec2(920, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Randomizer Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

bool disableEditingRandoSettings = CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
if (disableEditingRandoSettings) {
UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
Expand Down Expand Up @@ -5284,7 +5277,6 @@ void RandomizerSettingsWindow::DrawElement() {
if (disableEditingRandoSettings) {
UIWidgets::ReEnableComponent("");
}
ImGui::End();
}

CustomMessage Randomizer::GetWarpSongMessage(u16 textId, bool mysterious) {
Expand Down
26 changes: 14 additions & 12 deletions soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,16 @@ void UpdateCheck(uint32_t check, RandomizerCheckTrackerData data) {
UpdateOrdering(area);
}

void CheckTrackerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);
void CheckTrackerWindow::Draw() {
if (!IsVisible()) {
return;
}
DrawElement();
// Sync up the IsVisible flag if it was changed by ImGui
SyncVisibilityConsoleVariable();
}

void CheckTrackerWindow::DrawElement() {
if (CVarGetInteger(CVAR_TRACKER_CHECK("WindowType"), TRACKER_WINDOW_WINDOW) == TRACKER_WINDOW_FLOATING) {
if (CVarGetInteger(CVAR_TRACKER_CHECK("ShowOnlyPaused"), 0) && (gPlayState == nullptr || gPlayState->pauseCtx.state == 0)) {
return;
Expand All @@ -880,14 +887,16 @@ void CheckTrackerWindow::DrawElement() {
int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton2"), TRACKER_COMBO_BUTTON_R)];
OSContPad* trackerButtonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads();
bool comboButtonsHeld = trackerButtonsPressed != nullptr &&
trackerButtonsPressed[0].button & comboButton1Mask &&
trackerButtonsPressed[0].button & comboButton2Mask;
trackerButtonsPressed[0].button & comboButton1Mask &&
trackerButtonsPressed[0].button & comboButton2Mask;
if (!comboButtonsHeld) {
return;
}
}
}

ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);

BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar);

if (!GameInteractor::IsSaveLoaded() || !initialized) {
Expand Down Expand Up @@ -1601,14 +1610,8 @@ static const char* windowType[] = { "Floating", "Window" };
static const char* displayType[] = { "Always", "Combo Button Hold" };
static const char* buttonStrings[] = { "A Button", "B Button", "C-Up", "C-Down", "C-Left", "C-Right", "L Button",
"Z Button", "R Button", "Start", "D-Up", "D-Down", "D-Left", "D-Right" };
void CheckTrackerSettingsWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver);

if (!ImGui::Begin("Check Tracker Settings", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

void CheckTrackerSettingsWindow::DrawElement() {
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });
ImGui::BeginTable("CheckTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV);
ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f);
Expand Down Expand Up @@ -1668,7 +1671,6 @@ void CheckTrackerSettingsWindow::DrawElement() {

ImGui::PopStyleVar(1);
ImGui::EndTable();
ImGui::End();
}

void CheckTrackerWindow::InitElement() {
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizer_check_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CheckTrackerSettingsWindow : public Ship::GuiWindow {
class CheckTrackerWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
void Draw() override;
~CheckTrackerWindow() {};

protected:
Expand Down
11 changes: 10 additions & 1 deletion soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,24 @@ void InitEntranceTrackingData() {
SortEntranceListByType(destListSortedByType, 1);
}

void EntranceTrackerWindow::Draw() {
if (!IsVisible()) {
return;
}
DrawElement();
// Sync up the IsVisible flag if it was changed by ImGui
SyncVisibilityConsoleVariable();
}

void EntranceTrackerWindow::DrawElement() {
// Begin tracker settings
ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver);

if (!ImGui::Begin("Entrance Tracker", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

// Begin tracker settings
ImGui::SetNextItemOpen(false, ImGuiCond_Once);
if (ImGui::TreeNode("Tracker Settings")) {
// Reduce indentation from the tree node for the table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class EntranceTrackerWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;

void Draw() override;
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
Expand Down
18 changes: 9 additions & 9 deletions soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,15 @@ void ItemTrackerLoadFile() {
}
}

void ItemTrackerWindow::Draw() {
if (!IsVisible()) {
return;
}
DrawElement();
// Sync up the IsVisible flag if it was changed by ImGui
SyncVisibilityConsoleVariable();
}

void ItemTrackerWindow::DrawElement() {
UpdateVectors();

Expand Down Expand Up @@ -1122,13 +1131,6 @@ static const char* displayTypes[3] = { "Hidden", "Main Window", "Separate" };
static const char* extendedDisplayTypes[4] = { "Hidden", "Main Window", "Misc Window", "Separate" };

void ItemTrackerSettingsWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(733, 472), ImGuiCond_FirstUseEver);

if (!ImGui::Begin("Item Tracker Settings", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
}

ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });
ImGui::BeginTable("itemTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV);
ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f);
Expand Down Expand Up @@ -1255,8 +1257,6 @@ void ItemTrackerSettingsWindow::DrawElement() {

ImGui::PopStyleVar(1);
ImGui::EndTable();

ImGui::End();
}

void ItemTrackerWindow::InitElement() {
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizer_item_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ItemTrackerSettingsWindow : public Ship::GuiWindow {
class ItemTrackerWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
void Draw() override;

protected:
void InitElement() override;
Expand Down
Loading
Loading