Further Menu Improvements (#5129)

* Menu improvements

* Update calc for button offsets

* Fix enemy rando UI
This commit is contained in:
aMannus 2025-03-18 10:12:45 +01:00 committed by GitHub
parent 9e883ece96
commit ab5ea0e8ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 100 additions and 220 deletions

View file

@ -428,7 +428,6 @@ InputViewerSettingsWindow::~InputViewerSettingsWindow() {
} }
void InputViewerSettingsWindow::DrawElement() { void InputViewerSettingsWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
// gInputViewer.Scale // gInputViewer.Scale
CVarSliderFloat("Input Viewer Scale: %.2f", CVAR_INPUT_VIEWER("Scale"), CVarSliderFloat("Input Viewer Scale: %.2f", CVAR_INPUT_VIEWER("Scale"),
FloatSliderOptions().Color(THEME_COLOR).DefaultValue(1.0f).Min(0.1f).Max(5.0f).ShowButtons(true).Tooltip("Sets the on screen size of the input viewer")); FloatSliderOptions().Color(THEME_COLOR).DefaultValue(1.0f).Min(0.1f).Max(5.0f).ShowButtons(true).Tooltip("Sets the on screen size of the input viewer"));
@ -640,5 +639,4 @@ void InputViewerSettingsWindow::DrawElement() {
} }
} }
PopStyleHeader(); PopStyleHeader();
ImGui::PopFont();
} }

View file

@ -1523,7 +1523,7 @@ void Draw_Placements(){
CVarSetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Changed"), 1); CVarSetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Changed"), 1);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 24); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::CalcTextSize("g").y * 2));
if (UIWidgets::Button("Reset##EnemyHealthBarWidth", if (UIWidgets::Button("Reset##EnemyHealthBarWidth",
UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) { UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) {
CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Value")); CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Value"));
@ -1537,7 +1537,7 @@ void Draw_Placements(){
void Reset_Option_Single(const char* Button_Title, const char* name) { void Reset_Option_Single(const char* Button_Title, const char* name) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 24); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::CalcTextSize("g").y * 2));
if (UIWidgets::Button(Button_Title, if (UIWidgets::Button(Button_Title,
UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) { UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) {
CVarClear(name); CVarClear(name);
@ -1546,7 +1546,7 @@ void Reset_Option_Single(const char* Button_Title, const char* name) {
void Reset_Option_Double(const char* Button_Title, const char* name) { void Reset_Option_Double(const char* Button_Title, const char* name) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 24); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::CalcTextSize("g").y * 2));
if (UIWidgets::Button(Button_Title, if (UIWidgets::Button(Button_Title,
UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) { UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) {
CVarClear((std::string(name) + ".Value").c_str()); CVarClear((std::string(name) + ".Value").c_str());
@ -1578,7 +1578,7 @@ void DrawSillyTab() {
CVarSetInteger(CVAR_COSMETIC("Link.BodySize.Changed"), 1); CVarSetInteger(CVAR_COSMETIC("Link.BodySize.Changed"), 1);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 24); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::CalcTextSize("g").y * 2));
if (UIWidgets::Button("Reset##Link_BodySize", if (UIWidgets::Button("Reset##Link_BodySize",
UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) { UIWidgets::ButtonOptions().Size(ImVec2(80, 36)).Padding(ImVec2(5.0f, 0.0f)))) {
CVarClear(CVAR_COSMETIC("Link.BodySize.Value")); CVarClear(CVAR_COSMETIC("Link.BodySize.Value"));
@ -2194,7 +2194,7 @@ void CosmeticsEditorWindow::DrawElement() {
CVarSetInteger(CVAR_COSMETIC("Trails.Duration.Changed"), 1); CVarSetInteger(CVAR_COSMETIC("Trails.Duration.Changed"), 1);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 24); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::CalcTextSize("g").y * 2));
if (UIWidgets::Button("Reset##Trails_Duration", UIWidgets::ButtonOptions() if (UIWidgets::Button("Reset##Trails_Duration", UIWidgets::ButtonOptions()
.Size(ImVec2(80, 36)) .Size(ImVec2(80, 36))
.Padding(ImVec2(5.0f, 0.0f)))) { .Padding(ImVec2(5.0f, 0.0f)))) {

View file

@ -26,7 +26,6 @@ void MessageViewer::InitElement() {
} }
void MessageViewer::DrawElement() { void MessageViewer::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
ImGui::Text("Table ID"); ImGui::Text("Table ID");
ImGui::SameLine(); ImGui::SameLine();
PushStyleInput(THEME_COLOR); PushStyleInput(THEME_COLOR);
@ -86,7 +85,6 @@ void MessageViewer::DrawElement() {
mDisplayCustomMessageClicked = true; mDisplayCustomMessageClicked = true;
} }
PopStyleButton(); PopStyleButton();
ImGui::PopFont();
} }
void MessageViewer::UpdateElement() { void MessageViewer::UpdateElement() {

View file

@ -934,8 +934,6 @@ void ActorViewerWindow::DrawElement() {
static s16 currentSelectedInDropdown; static s16 currentSelectedInDropdown;
static std::vector<u16> actors; static std::vector<u16> actors;
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
if (gPlayState != nullptr) { if (gPlayState != nullptr) {
needs_reset = lastSceneId != gPlayState->sceneNum; needs_reset = lastSceneId != gPlayState->sceneNum;
if (needs_reset) { if (needs_reset) {
@ -1234,7 +1232,6 @@ void ActorViewerWindow::DrawElement() {
actors.clear(); actors.clear();
} }
} }
ImGui::PopFont();
} }
void ActorViewerWindow::InitElement() { void ActorViewerWindow::InitElement() {

View file

@ -91,7 +91,6 @@ void PerformDisplayListSearch() {
} }
void DLViewerWindow::DrawElement() { void DLViewerWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
// Debounce the search field as listing otr files is expensive // Debounce the search field as listing otr files is expensive
UIWidgets::PushStyleInput(THEME_COLOR); UIWidgets::PushStyleInput(THEME_COLOR);
if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) { if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) {
@ -122,7 +121,6 @@ void DLViewerWindow::DrawElement() {
UIWidgets::PopStyleCombobox(); UIWidgets::PopStyleCombobox();
if (activeDisplayList == "") { if (activeDisplayList == "") {
ImGui::PopFont();
return; return;
} }
@ -131,7 +129,6 @@ void DLViewerWindow::DrawElement() {
if (res->GetInitData()->Type != static_cast<uint32_t>(Fast::ResourceType::DisplayList)) { if (res->GetInitData()->Type != static_cast<uint32_t>(Fast::ResourceType::DisplayList)) {
ImGui::Text("Resource type is not a Display List. Please choose another."); ImGui::Text("Resource type is not a Display List. Please choose another.");
ImGui::PopFont();
return; return;
} }
@ -329,10 +326,8 @@ void DLViewerWindow::DrawElement() {
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
ImGui::Text("Error displaying DL instructions."); ImGui::Text("Error displaying DL instructions.");
ImGui::PopFont();
return; return;
} }
ImGui::PopFont();
} }
void DLViewerWindow::InitElement() { void DLViewerWindow::InitElement() {

View file

@ -143,7 +143,6 @@ void RegisterValueViewerHooks() {
RegisterShipInitFunc initFunc(RegisterValueViewerHooks, { CVAR_NAME }); RegisterShipInitFunc initFunc(RegisterValueViewerHooks, { CVAR_NAME });
void ValueViewerWindow::DrawElement() { void ValueViewerWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
UIWidgets::CVarCheckbox("Enable Printing", CVAR_NAME, UIWidgets::CheckboxOptions().Color(THEME_COLOR)); UIWidgets::CVarCheckbox("Enable Printing", CVAR_NAME, UIWidgets::CheckboxOptions().Color(THEME_COLOR));
ImGui::BeginGroup(); ImGui::BeginGroup();
@ -264,7 +263,6 @@ void ValueViewerWindow::DrawElement() {
} }
ImGui::EndGroup(); ImGui::EndGroup();
} }
ImGui::PopFont();
} }
void ValueViewerWindow::InitElement() { void ValueViewerWindow::InitElement() {

View file

@ -286,7 +286,7 @@ void GetSelectedEnemies() {
for (int i = 0; i < 49; i++) { for (int i = 0; i < 49; i++) {
if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemyList.All"), 0)) { if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemyList.All"), 0)) {
selectedEnemyList.push_back(randomizedEnemySpawnTable[i]); selectedEnemyList.push_back(randomizedEnemySpawnTable[i]);
} else if (CVarGetInteger(enemyCVarList[i], 0)) { } else if (CVarGetInteger(enemyCVarList[i], 1)) {
selectedEnemyList.push_back(randomizedEnemySpawnTable[i]); selectedEnemyList.push_back(randomizedEnemySpawnTable[i]);
} }
} }

View file

@ -1141,14 +1141,12 @@ void BeginFloatWindows(std::string UniqueName, bool& open, ImGuiWindowFlags flag
Color_Background.b / 255.0f, Color_Background.a / 255.0f)); Color_Background.b / 255.0f, Color_Background.a / 255.0f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f);
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
ImGui::Begin(UniqueName.c_str(), &open, windowFlags); ImGui::Begin(UniqueName.c_str(), &open, windowFlags);
} }
void EndFloatWindows() { void EndFloatWindows() {
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopFont();
ImGui::End(); ImGui::End();
} }
@ -1760,7 +1758,6 @@ static std::unordered_map<int32_t, const char*> buttonStrings = {
{ TRACKER_COMBO_BUTTON_D_LEFT, "D-Left" }, { TRACKER_COMBO_BUTTON_D_RIGHT, "D-Right" }}; { TRACKER_COMBO_BUTTON_D_LEFT, "D-Left" }, { TRACKER_COMBO_BUTTON_D_RIGHT, "D-Right" }};
void CheckTrackerSettingsWindow::DrawElement() { void CheckTrackerSettingsWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });
if (ImGui::BeginTable("CheckTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) { if (ImGui::BeginTable("CheckTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) {
ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f); ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f);
@ -1827,7 +1824,6 @@ void CheckTrackerSettingsWindow::DrawElement() {
ImGui::PopStyleVar(1); ImGui::PopStyleVar(1);
} }
ImGui::EndTable(); ImGui::EndTable();
ImGui::PopFont();
} }
void CheckTrackerWindow::InitElement() { void CheckTrackerWindow::InitElement() {

View file

@ -660,7 +660,6 @@ void InitEntranceTrackingData() {
void EntranceTrackerSettingsWindow::DrawElement() { void EntranceTrackerSettingsWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
ImGui::TextWrapped("The entrance tracker will only track shuffled entrances"); ImGui::TextWrapped("The entrance tracker will only track shuffled entrances");
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
@ -722,7 +721,6 @@ void EntranceTrackerSettingsWindow::DrawElement() {
ImGui::TextColored(ImColor(COLOR_GRAY), "Undiscovered Entrances"); ImGui::TextColored(ImColor(COLOR_GRAY), "Undiscovered Entrances");
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::PopFont();
} }
void EntranceTrackerWindow::Draw() { void EntranceTrackerWindow::Draw() {
@ -735,12 +733,10 @@ void EntranceTrackerWindow::Draw() {
} }
void EntranceTrackerWindow::DrawElement() { void EntranceTrackerWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
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", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End(); ImGui::End();
ImGui::PopFont();
return; return;
} }
@ -938,7 +934,6 @@ void EntranceTrackerWindow::DrawElement() {
} }
ImGui::EndChild(); ImGui::EndChild();
ImGui::End(); ImGui::End();
ImGui::PopFont();
} }
void EntranceTrackerWindow::InitElement() { void EntranceTrackerWindow::InitElement() {

View file

@ -469,6 +469,7 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) {
if (!GameInteractor::IsSaveLoaded()) { if (!GameInteractor::IsSaveLoaded()) {
return; return;
} }
ImGui::PushFont(OTRGlobals::Instance->fontMono);
int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36);
int textSize = CVarGetInteger(CVAR_TRACKER_ITEM("TextSize"), 13); int textSize = CVarGetInteger(CVAR_TRACKER_ITEM("TextSize"), 13);
ItemTrackerNumbers currentAndMax = GetItemCurrentAndMax(item); ItemTrackerNumbers currentAndMax = GetItemCurrentAndMax(item);
@ -611,6 +612,7 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) {
ImGui::SetCursorScreenPos(ImVec2(p.x, p.y - 14)); ImGui::SetCursorScreenPos(ImVec2(p.x, p.y - 14));
ImGui::Text(""); ImGui::Text("");
} }
ImGui::PopFont();
} }
void DrawEquip(ItemTrackerItem item) { void DrawEquip(ItemTrackerItem item) {
@ -952,14 +954,12 @@ void BeginFloatingWindows(std::string UniqueName, ImGuiWindowFlags flags = 0) {
ImGui::PushStyleColor(ImGuiCol_WindowBg, VecFromRGBA8(CVarGetColor(CVAR_TRACKER_ITEM("BgColor.Value"), {0, 0, 0, 0}))); ImGui::PushStyleColor(ImGuiCol_WindowBg, VecFromRGBA8(CVarGetColor(CVAR_TRACKER_ITEM("BgColor.Value"), {0, 0, 0, 0})));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f);
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
ImGui::Begin(UniqueName.c_str(), nullptr, windowFlags); ImGui::Begin(UniqueName.c_str(), nullptr, windowFlags);
} }
void EndFloatingWindows() { void EndFloatingWindows() {
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopFont();
ImGui::End(); ImGui::End();
} }
@ -1375,7 +1375,6 @@ static std::unordered_map<int32_t, const char*> extendedDisplayTypes = {{ SECTIO
static std::unordered_map<int32_t, const char*> minimalDisplayTypes = {{ SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" }, { SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" }}; static std::unordered_map<int32_t, const char*> minimalDisplayTypes = {{ SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" }, { SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" }};
void ItemTrackerSettingsWindow::DrawElement() { void ItemTrackerSettingsWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontStandardLarger);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });
ImGui::BeginTable("itemTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV); ImGui::BeginTable("itemTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV);
ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f); ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f);
@ -1541,7 +1540,6 @@ void ItemTrackerSettingsWindow::DrawElement() {
ImGui::PopStyleVar(1); ImGui::PopStyleVar(1);
ImGui::EndTable(); ImGui::EndTable();
ImGui::PopFont();
} }
void ItemTrackerWindow::InitElement() { void ItemTrackerWindow::InitElement() {

View file

@ -941,7 +941,6 @@ static bool initialized = false;
void TimeSplitWindow::DrawElement() { void TimeSplitWindow::DrawElement() {
ImGui::SetWindowFontScale(timeSplitsWindowSize); ImGui::SetWindowFontScale(timeSplitsWindowSize);
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
PushStyleTabs(THEME_COLOR); PushStyleTabs(THEME_COLOR);
if (ImGui::BeginTabBar("Split Tabs")) { if (ImGui::BeginTabBar("Split Tabs")) {
@ -960,7 +959,6 @@ void TimeSplitWindow::DrawElement() {
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
PopStyleTabs(); PopStyleTabs();
ImGui::PopFont();
} }
void TimeSplitWindow::InitElement() { void TimeSplitWindow::InitElement() {

View file

@ -407,7 +407,7 @@ OTRGlobals::OTRGlobals() {
fontStandard = CreateFontWithSize(16.0f, "fonts/Montserrat-Regular.ttf"); fontStandard = CreateFontWithSize(16.0f, "fonts/Montserrat-Regular.ttf");
fontStandardLarger = CreateFontWithSize(20.0f, "fonts/Montserrat-Regular.ttf"); fontStandardLarger = CreateFontWithSize(20.0f, "fonts/Montserrat-Regular.ttf");
fontStandardLargest = CreateFontWithSize(24.0f, "fonts/Montserrat-Regular.ttf"); fontStandardLargest = CreateFontWithSize(24.0f, "fonts/Montserrat-Regular.ttf");
ImGui::GetIO().FontDefault = fontMono; ImGui::GetIO().FontDefault = fontStandardLarger;
ScaleImGui(); ScaleImGui();
// Move the camera strings from read only memory onto the heap (writable memory) // Move the camera strings from read only memory onto the heap (writable memory)

View file

@ -530,13 +530,13 @@ void Menu::DrawElement() {
ImGui::End(); ImGui::End();
return; return;
} }
ImGui::PushFont(OTRGlobals::Instance->fontStandardLargest);
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
ImGuiStyle& style = ImGui::GetStyle(); ImGuiStyle& style = ImGui::GetStyle();
windowHeight = window->WorkRect.GetHeight(); windowHeight = window->WorkRect.GetHeight();
windowWidth = window->WorkRect.GetWidth(); windowWidth = window->WorkRect.GetWidth();
ImGui::PushFont(OTRGlobals::Instance->fontStandardLargest);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f));
const char* headerCvar = CVAR_SETTING("Menu.ActiveHeader"); const char* headerCvar = CVAR_SETTING("Menu.ActiveHeader");
std::string headerIndex = CVarGetString(headerCvar, "Settings"); std::string headerIndex = CVarGetString(headerCvar, "Settings");
@ -559,12 +559,13 @@ void Menu::DrawElement() {
// Full screen menu with widths below 1280, heights below 800. // Full screen menu with widths below 1280, heights below 800.
// 5% of screen width/height padding on both sides above those resolutions. // 5% of screen width/height padding on both sides above those resolutions.
ImVec2 menuSize = { std::fminf(1280, windowWidth), std::fminf(800, windowHeight) }; // Menu width will never exceed a 16:9 aspect ratio.
ImVec2 menuSize = { windowWidth, windowHeight };
if (windowWidth > 1280) { if (windowWidth > 1280) {
menuSize.x = floor(windowWidth * 0.9); menuSize.x = std::fminf(windowWidth * 0.9f, (windowHeight * 1.77f));
} }
if (windowHeight > 800) { if (windowHeight > 800) {
menuSize.y = floor(windowHeight * 0.9); menuSize.y = windowHeight * 0.9f;
} }
pos += window->WorkRect.GetSize() / 2 - menuSize / 2; pos += window->WorkRect.GetSize() / 2 - menuSize / 2;
@ -696,7 +697,12 @@ void Menu::DrawElement() {
float sectionHeight = menuSize.y - headerHeight - 4 - style.ItemSpacing.y * 2; float sectionHeight = menuSize.y - headerHeight - 4 - style.ItemSpacing.y * 2;
float columnHeight = sectionHeight - style.ItemSpacing.y * 4; float columnHeight = sectionHeight - style.ItemSpacing.y * 4;
ImGui::SetNextWindowPos(pos + style.ItemSpacing * 2); ImGui::SetNextWindowPos(pos + style.ItemSpacing * 2);
// Increase sidebar width on larger screens to accomodate people scaling their menus.
float sidebarWidth = 200 - style.ItemSpacing.x; float sidebarWidth = 200 - style.ItemSpacing.x;
if (menuSize.x > 1600) {
sidebarWidth = menuSize.x * 0.15f;
}
const char* sidebarCvar = menuEntries.at(headerIndex).sidebarCvar; const char* sidebarCvar = menuEntries.at(headerIndex).sidebarCvar;
@ -732,8 +738,8 @@ void Menu::DrawElement() {
} }
} }
ImGui::EndChild(); ImGui::EndChild();
ImGui::PopFont();
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
pos = ImVec2{ sectionCenterX + (sidebarWidth / 2), topY } + style.ItemSpacing * 2; pos = ImVec2{ sectionCenterX + (sidebarWidth / 2), topY } + style.ItemSpacing * 2;
window->DrawList->AddRectFilled(pos, pos + ImVec2{ 4, sectionHeight - style.FramePadding.y * 2 }, window->DrawList->AddRectFilled(pos, pos + ImVec2{ 4, sectionHeight - style.FramePadding.y * 2 },
ImGui::GetColorU32({ 255, 255, 255, 255 }), true, style.WindowRounding); ImGui::GetColorU32({ 255, 255, 255, 255 }), true, style.WindowRounding);
@ -802,8 +808,6 @@ void Menu::DrawElement() {
if (!useColumns || menuSearchText.length() > 0) { if (!useColumns || menuSearchText.length() > 0) {
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::PopFont();
ImGui::PopFont();
if (!popout) { if (!popout) {
ImGui::PopStyleVar(); ImGui::PopStyleVar();

View file

@ -34,7 +34,8 @@ void SohMenu::AddMenuEnhancements() {
if (iter->first != 0) comboboxTooltip += "\n\n"; if (iter->first != 0) comboboxTooltip += "\n\n";
comboboxTooltip += std::string(iter->second.label) + " - " + std::string(iter->second.description); comboboxTooltip += std::string(iter->second.label) + " - " + std::string(iter->second.description);
} }
AddWidget(path, "Enhancement Presets", WIDGET_COMBOBOX) AddWidget(path, "Enhancement Presets", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Select Preset", WIDGET_COMBOBOX)
.ValuePointer(&enhancementPresetSelected) .ValuePointer(&enhancementPresetSelected)
.Callback([](WidgetInfo& info) { .Callback([](WidgetInfo& info) {
const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_ENHANCEMENTS); const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_ENHANCEMENTS);
@ -46,6 +47,7 @@ void SohMenu::AddMenuEnhancements() {
.Tooltip(comboboxTooltip.c_str()) .Tooltip(comboboxTooltip.c_str())
); );
AddWidget(path, "Apply Preset##Enhancemnts", WIDGET_BUTTON) AddWidget(path, "Apply Preset##Enhancemnts", WIDGET_BUTTON)
.Options(ButtonOptions().Size(UIWidgets::Sizes::Inline))
.Callback([](WidgetInfo& info) { .Callback([](WidgetInfo& info) {
const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_ENHANCEMENTS); const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_ENHANCEMENTS);
const PresetTypeDefinition presetTypeDef = presetTypes.at(PRESET_TYPE_ENHANCEMENTS); const PresetTypeDefinition presetTypeDef = presetTypes.at(PRESET_TYPE_ENHANCEMENTS);
@ -1051,7 +1053,7 @@ void SohMenu::AddMenuEnhancements() {
)); ));
path.sidebarName = "Items"; path.sidebarName = "Items";
AddSidebarEntry("Enhancements", path.sidebarName, 2); AddSidebarEntry("Enhancements", path.sidebarName, 3);
path.column = SECTION_COLUMN_1; path.column = SECTION_COLUMN_1;
AddWidget(path, "Controls", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Controls", WIDGET_SEPARATOR_TEXT);
@ -1678,7 +1680,7 @@ void SohMenu::AddMenuEnhancements() {
); );
path.sidebarName = "Extra Modes"; path.sidebarName = "Extra Modes";
AddSidebarEntry("Enhancements", path.sidebarName, 2); AddSidebarEntry("Enhancements", path.sidebarName, 3);
path.column = SECTION_COLUMN_1; path.column = SECTION_COLUMN_1;
AddWidget(path, "Mirrored World", WIDGET_CVAR_COMBOBOX) AddWidget(path, "Mirrored World", WIDGET_CVAR_COMBOBOX)
@ -1703,19 +1705,6 @@ void SohMenu::AddMenuEnhancements() {
" - Dungeons Random (Seeded): Dungeons are mirrored based on the current randomizer seed/file\n" " - Dungeons Random (Seeded): Dungeons are mirrored based on the current randomizer seed/file\n"
) )
); );
AddWidget(path, "Randomized Enemy Sizes", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("RandomizedEnemySizes"))
.Options(CheckboxOptions().Tooltip(
"Enemies and Bosses spawn with random sizes."
));
AddWidget(path, "Scale Health with Size", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("EnemySizeScalesHealth"))
.PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemySizes"), 0) == 0;
})
.Options(CheckboxOptions().Tooltip(
"Scales normal enemies Health with their randomized size. *This will NOT affect bosses*"
));
AddWidget(path, "Ivan the Fairy (Coop Mode)", WIDGET_CVAR_CHECKBOX) AddWidget(path, "Ivan the Fairy (Coop Mode)", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("IvanCoopModeEnabled")) .CVar(CVAR_ENHANCEMENT("IvanCoopModeEnabled"))
.Options(CheckboxOptions().Tooltip( .Options(CheckboxOptions().Tooltip(
@ -1827,6 +1816,7 @@ void SohMenu::AddMenuEnhancements() {
.PreFunc([](WidgetInfo& info) { .PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("ExtraTraps.Enabled"), 0) == 0; info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("ExtraTraps.Enabled"), 0) == 0;
}); });
path.column = SECTION_COLUMN_2; path.column = SECTION_COLUMN_2;
AddWidget(path, "Enemy Randomizer", WIDGET_CVAR_COMBOBOX) AddWidget(path, "Enemy Randomizer", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_ENHANCEMENT("RandomizedEnemies")) .CVar(CVAR_ENHANCEMENT("RandomizedEnemies"))
@ -1843,22 +1833,34 @@ void SohMenu::AddMenuEnhancements() {
"- Random (Seeded): Enemies are randomized based on the current randomizer seed/file\n" "- Random (Seeded): Enemies are randomized based on the current randomizer seed/file\n"
) )
); );
AddWidget(path, "Randomized Enemy Sizes", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("RandomizedEnemySizes"))
.Options(CheckboxOptions().Tooltip("Enemies and Bosses spawn with random sizes."));
AddWidget(path, "Scale Health with Size", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("EnemySizeScalesHealth"))
.PreFunc(
[](WidgetInfo& info) { info.options->disabled = !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemySizes"), 0); })
.Options(CheckboxOptions().Tooltip(
"Scales normal enemies Health with their randomized size. *This will NOT affect bosses*"));
AddWidget(path, "Enemy List", WIDGET_SEPARATOR_TEXT) AddWidget(path, "Enemy List", WIDGET_SEPARATOR_TEXT)
.PreFunc([](WidgetInfo& info) { .PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) != ENEMY_RANDOMIZER_RANDOM; info.isHidden = !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0);
}); });
AddWidget(path, "Select All Enemies", WIDGET_CVAR_CHECKBOX) AddWidget(path, "Select All Enemies", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_ENHANCEMENT("RandomizedEnemyList.All")) .CVar(CVAR_ENHANCEMENT("RandomizedEnemyList.All"))
.PreFunc([](WidgetInfo& info) { .PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) != ENEMY_RANDOMIZER_RANDOM; info.isHidden = !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0);
}); });
AddWidget(path, "Enemy List", WIDGET_SEPARATOR); AddWidget(path, "Enemy List", WIDGET_SEPARATOR).PreFunc([](WidgetInfo& info) {
info.isHidden = !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0);
});
for (int i = 0; i < RANDOMIZED_ENEMY_SPAWN_TABLE_SIZE; i++) { for (int i = 0; i < RANDOMIZED_ENEMY_SPAWN_TABLE_SIZE; i++) {
AddWidget(path, enemyNameList[i], WIDGET_CVAR_CHECKBOX) AddWidget(path, enemyNameList[i], WIDGET_CVAR_CHECKBOX)
.CVar(enemyCVarList[i]) .CVar(enemyCVarList[i])
.Options(CheckboxOptions().DefaultValue(true))
.PreFunc([](WidgetInfo& info) { .PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) != ENEMY_RANDOMIZER_RANDOM; info.isHidden = !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0);
info.options->disabled = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemyList.All"), 0) == 1; info.options->disabled = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemyList.All"), 0);
info.options->disabledTooltip = "These options are disabled because \"Select All Enemies\" is enabled."; info.options->disabledTooltip = "These options are disabled because \"Select All Enemies\" is enabled.";
}) })
.Callback([](WidgetInfo& info) { .Callback([](WidgetInfo& info) {
@ -1871,6 +1873,14 @@ void SohMenu::AddMenuEnhancements() {
AddSidebarEntry("Enhancements", path.sidebarName, 3); AddSidebarEntry("Enhancements", path.sidebarName, 3);
path.column = SECTION_COLUMN_1; path.column = SECTION_COLUMN_1;
AddWidget(path, "Infinite...", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Money", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteMoney"));
AddWidget(path, "Health", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteHealth"));
AddWidget(path, "Ammo", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteAmmo"));
AddWidget(path, "Magic", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteMagic"));
AddWidget(path, "Nayru's Love", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteNayru"));
AddWidget(path, "Epona Boost", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteEponaBoost"));
AddWidget(path, "Inventory", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Inventory", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Super Tunic", WIDGET_CVAR_CHECKBOX) AddWidget(path, "Super Tunic", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("SuperTunic")) .CVar(CVAR_CHEAT("SuperTunic"))
@ -1909,73 +1919,8 @@ void SohMenu::AddMenuEnhancements() {
.Options(CheckboxOptions().Tooltip( .Options(CheckboxOptions().Tooltip(
"This allows you to put up for shield with any two-handed weapon in hand except for Deku Sticks." "This allows you to put up for shield with any two-handed weapon in hand except for Deku Sticks."
)); ));
AddWidget(path, "Deku Sticks:", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_CHEAT("DekuStick"))
.Options(ComboboxOptions().ComboMap(
dekuStickCheat
).DefaultIndex(DEKU_STICK_NORMAL));
AddWidget(path, "Bomb Timer Multiplier: %.2fx", WIDGET_CVAR_SLIDER_FLOAT)
.CVar(CVAR_CHEAT("BombTimerMultiplier"))
.Options(FloatSliderOptions()
.Format("%.2f")
.Min(0.1f)
.Max(5.0f)
.DefaultValue(1.0f));
AddWidget(path, "Hookshot Everything", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("HookshotEverything"))
.Options(CheckboxOptions().Tooltip(
"Makes every surface in the game hookshot-able."
));
AddWidget(path, "Hookshot Reach Multiplier: %.2fx", WIDGET_CVAR_SLIDER_FLOAT)
.CVar(CVAR_CHEAT("HookshotReachMultiplier"))
.Options(FloatSliderOptions()
.Format("%.2f")
.Min(1.0f)
.Max(5.0f));
AddWidget(path, "Change Age", WIDGET_BUTTON)
.Options(ButtonOptions().Tooltip("Switches Link's age and reloads the area."))
.Callback([](WidgetInfo& info){
SwitchAge();
});
AddWidget(path, "Clear Cutscene Pointer", WIDGET_BUTTON)
.Callback([](WidgetInfo& info) {
GameInteractor::RawAction::ClearCutscenePointer();
})
.Options(ButtonOptions().Tooltip(
"Clears the cutscene pointer to a value safe for wrong warps."
));
path.column = SECTION_COLUMN_2; path.column = SECTION_COLUMN_2;
AddWidget(path, "Infinite...", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Money", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteMoney"));
AddWidget(path, "Health", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteHealth"));
AddWidget(path, "Ammo", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteAmmo"));
AddWidget(path, "Magic", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteMagic"));
AddWidget(path, "Nayru's Love", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteNayru"));
AddWidget(path, "Epona Boost", WIDGET_CVAR_CHECKBOX).CVar(CVAR_CHEAT("InfiniteEponaBoost"));
AddWidget(path, "Save States", WIDGET_SEPARATOR_TEXT);
AddWidget(path, ICON_FA_EXCLAMATION_TRIANGLE " WARNING!!!! " ICON_FA_EXCLAMATION_TRIANGLE, WIDGET_TEXT)
.Options(WidgetOptions().Color(Colors::Orange));
AddWidget(path,
"These are NOT like emulator states. They do not save your game progress "
"and they WILL break across transitions and load zones (like doors). "
"Support for related issues will not be provided.", WIDGET_TEXT
);
AddWidget(path, "I promise I have read the warning", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("SaveStatePromise"))
.Callback([](WidgetInfo& info) {
CVarSetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
});
AddWidget(path, "I understand, enable save states", WIDGET_CVAR_CHECKBOX)
.PreFunc([](WidgetInfo& info) {
info.isHidden = CVarGetInteger(CVAR_CHEAT("SaveStatePromise"), 0) == 0;
})
.CVar(CVAR_CHEAT("SaveStatesEnabled"))
.Options(CheckboxOptions().Tooltip(
"F5 to save, F6 to change slots, F7 to load"
));
AddWidget(path, "Behavior", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Behavior", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "No Clip", WIDGET_CVAR_CHECKBOX) AddWidget(path, "No Clip", WIDGET_CVAR_CHECKBOX)
@ -2024,7 +1969,46 @@ void SohMenu::AddMenuEnhancements() {
"Keese and Guay no longer target you and simply ignore you as if you were wearing the " "Keese and Guay no longer target you and simply ignore you as if you were wearing the "
"Skull Mask." "Skull Mask."
)); ));
AddWidget(path, "Deku Sticks:", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_CHEAT("DekuStick"))
.Options(ComboboxOptions().ComboMap(dekuStickCheat).DefaultIndex(DEKU_STICK_NORMAL));
AddWidget(path, "Bomb Timer Multiplier: %.2fx", WIDGET_CVAR_SLIDER_FLOAT)
.CVar(CVAR_CHEAT("BombTimerMultiplier"))
.Options(FloatSliderOptions().Format("%.2f").Min(0.1f).Max(5.0f).DefaultValue(1.0f));
AddWidget(path, "Hookshot Everything", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("HookshotEverything"))
.Options(CheckboxOptions().Tooltip("Makes every surface in the game hookshot-able."));
AddWidget(path, "Hookshot Reach Multiplier: %.2fx", WIDGET_CVAR_SLIDER_FLOAT)
.CVar(CVAR_CHEAT("HookshotReachMultiplier"))
.Options(FloatSliderOptions().Format("%.2f").Min(1.0f).Max(5.0f));
AddWidget(path, "Change Age", WIDGET_BUTTON)
.Options(ButtonOptions().Tooltip("Switches Link's age and reloads the area."))
.Callback([](WidgetInfo& info) { SwitchAge(); });
AddWidget(path, "Clear Cutscene Pointer", WIDGET_BUTTON)
.Callback([](WidgetInfo& info) { GameInteractor::RawAction::ClearCutscenePointer(); })
.Options(ButtonOptions().Tooltip("Clears the cutscene pointer to a value safe for wrong warps."));
path.column = SECTION_COLUMN_3; path.column = SECTION_COLUMN_3;
AddWidget(path, "Save States", WIDGET_SEPARATOR_TEXT);
AddWidget(path, ICON_FA_EXCLAMATION_TRIANGLE " WARNING!!!! " ICON_FA_EXCLAMATION_TRIANGLE, WIDGET_TEXT)
.Options(WidgetOptions().Color(Colors::Orange));
AddWidget(path,
"These are NOT like emulator states. They do not save your game progress "
"and they WILL break across transitions and load zones (like doors). "
"Support for related issues will not be provided.",
WIDGET_TEXT);
AddWidget(path, "I promise I have read the warning", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("SaveStatePromise"))
.Callback([](WidgetInfo& info) {
CVarSetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
});
AddWidget(path, "I understand, enable save states", WIDGET_CVAR_CHECKBOX)
.PreFunc([](WidgetInfo& info) { info.isHidden = CVarGetInteger(CVAR_CHEAT("SaveStatePromise"), 0) == 0; })
.CVar(CVAR_CHEAT("SaveStatesEnabled"))
.Options(CheckboxOptions().Tooltip("F5 to save, F6 to change slots, F7 to load"));
AddWidget(path, "Beta Quest", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Beta Quest", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Enable Beta Quest", WIDGET_CVAR_CHECKBOX) AddWidget(path, "Enable Beta Quest", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_CHEAT("EnableBetaQuest")) .CVar(CVAR_CHEAT("EnableBetaQuest"))
@ -2100,7 +2084,7 @@ void SohMenu::AddMenuEnhancements() {
// Timers // Timers
path.sidebarName = "Timers"; path.sidebarName = "Timers";
AddSidebarEntry("Enhancements", path.sidebarName, 1); AddSidebarEntry("Enhancements", path.sidebarName, 3);
AddWidget(path, "Toggle Timers Window", WIDGET_WINDOW_BUTTON) AddWidget(path, "Toggle Timers Window", WIDGET_WINDOW_BUTTON)
.CVar(CVAR_WINDOW("TimeDisplayEnabled")) .CVar(CVAR_WINDOW("TimeDisplayEnabled"))
.WindowName("Additional Timers") .WindowName("Additional Timers")

View file

@ -55,6 +55,7 @@ void SohMenu::AddMenuSettings() {
WidgetPath path = { "Settings", "General", SECTION_COLUMN_1 }; WidgetPath path = { "Settings", "General", SECTION_COLUMN_1 };
// General - Settings // General - Settings
AddWidget(path, "General Settings", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Menu Theme", WIDGET_CVAR_COMBOBOX) AddWidget(path, "Menu Theme", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_SETTING("Menu.Theme")) .CVar(CVAR_SETTING("Menu.Theme"))
.Options(ComboboxOptions() .Options(ComboboxOptions()
@ -207,6 +208,7 @@ void SohMenu::AddMenuSettings() {
"FPS than your monitor's refresh rate will waste resources, and might give a worse result."; "FPS than your monitor's refresh rate will waste resources, and might give a worse result.";
path.sidebarName = "Graphics"; path.sidebarName = "Graphics";
AddSidebarEntry("Settings", "Graphics", 3); AddSidebarEntry("Settings", "Graphics", 3);
AddWidget(path, "Graphics Options", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Toggle Fullscreen", WIDGET_CVAR_CHECKBOX) AddWidget(path, "Toggle Fullscreen", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_SETTING("Fullscreen")) .CVar(CVAR_SETTING("Fullscreen"))
.Callback([](WidgetInfo& info) { Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); }) .Callback([](WidgetInfo& info) { Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); })
@ -292,9 +294,12 @@ void SohMenu::AddMenuSettings() {
.CVar(CVAR_TEXTURE_FILTER) .CVar(CVAR_TEXTURE_FILTER)
.Options(ComboboxOptions().Tooltip("Sets the applied Texture Filtering.").ComboMap(textureFilteringMap)); .Options(ComboboxOptions().Tooltip("Sets the applied Texture Filtering.").ComboMap(textureFilteringMap));
path.column = SECTION_COLUMN_2;
AddWidget(path, "Advanced Graphics Options", WIDGET_SEPARATOR_TEXT);
// Controls // Controls
path.sidebarName = "Controls"; path.sidebarName = "Controls";
path.column = SECTION_COLUMN_1;
AddSidebarEntry("Settings", "Controls", 2); AddSidebarEntry("Settings", "Controls", 2);
AddWidget(path, "Controller Bindings", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Controller Bindings", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Popout Bindings Window", WIDGET_WINDOW_BUTTON) AddWidget(path, "Popout Bindings Window", WIDGET_WINDOW_BUTTON)
@ -302,7 +307,9 @@ void SohMenu::AddMenuSettings() {
.WindowName("Configure Controller") .WindowName("Configure Controller")
.Options(WindowButtonOptions().Tooltip("Enables the separate Bindings Window.")); .Options(WindowButtonOptions().Tooltip("Enables the separate Bindings Window."));
path.column = SECTION_COLUMN_2; // Input Viewer
path.sidebarName = "Input Viewer";
AddSidebarEntry("Settings", path.sidebarName, 3);
AddWidget(path, "Input Viewer", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Input Viewer", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Toggle Input Viewer", WIDGET_WINDOW_BUTTON) AddWidget(path, "Toggle Input Viewer", WIDGET_WINDOW_BUTTON)
.CVar(CVAR_WINDOW("InputViewer")) .CVar(CVAR_WINDOW("InputViewer"))
@ -318,7 +325,7 @@ void SohMenu::AddMenuSettings() {
// Notifications // Notifications
path.sidebarName = "Notifications"; path.sidebarName = "Notifications";
path.column = SECTION_COLUMN_1; path.column = SECTION_COLUMN_1;
AddSidebarEntry("Settings", "Notifications", 3); AddSidebarEntry("Settings", path.sidebarName, 3);
AddWidget(path, "Position", WIDGET_CVAR_COMBOBOX) AddWidget(path, "Position", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_SETTING("Notifications.Position")) .CVar(CVAR_SETTING("Notifications.Position"))
.Options(ComboboxOptions() .Options(ComboboxOptions()

View file

@ -30,7 +30,6 @@ void SohModalWindow::Draw() {
} }
void SohModalWindow::DrawElement() { void SohModalWindow::DrawElement() {
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
if (modals.size() > 0) { if (modals.size() > 0) {
SohModal curModal = modals.at(0); SohModal curModal = modals.at(0);
if (!ImGui::IsPopupOpen(curModal.title_.c_str())) { if (!ImGui::IsPopupOpen(curModal.title_.c_str())) {
@ -62,7 +61,6 @@ void SohModalWindow::DrawElement() {
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
ImGui::PopFont();
} }
void SohModalWindow::RegisterPopup(std::string title, std::string message, std::string button1, std::string button2, std::function<void()> button1callback, std::function<void()> button2callback) { void SohModalWindow::RegisterPopup(std::string title, std::string message, std::string button1, std::string button2, std::function<void()> button1callback, std::function<void()> button2callback) {

View file

@ -515,92 +515,6 @@ namespace UIWidgets {
void Separator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, void Separator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f,
float extraVerticalBottomPadding = 0.0f); float extraVerticalBottomPadding = 0.0f);
/*using ComboVariant = std::variant<const std::unordered_map<int32_t, const char*>&, const std::vector<const char*>&>;
bool Combobox(const char* label, int32_t* value, ComboVariant comboSource, const ComboboxOptions& options = {}) {
bool dirty = false;
float startX = ImGui::GetCursorPosX();
std::string invisibleLabelStr = "##" + std::string(label);
const char* invisibleLabel = invisibleLabelStr.c_str();
ImGui::PushID(label);
ImGui::BeginGroup();
ImGui::BeginDisabled(options.disabled);
PushStyleCombobox(options.color);
if (options.alignment == ComponentAlignment::Left) {
if (options.labelPosition == LabelPosition::Above) {
ImGui::Text("%s", label);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
} else if (options.labelPosition == LabelPosition::Near) {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().ItemSpacing.x * 2);
} else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) {
ImGui::SetNextItemWidth(ImGui::CalcTextSize(comboMap.at(*value)).x + ImGui::GetStyle().FramePadding.x * 4 + ImGui::GetStyle().ItemSpacing.x);
}
} else if (options.alignment == ComponentAlignment::Right) {
if (options.labelPosition == LabelPosition::Above) {
ImGui::NewLine();
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x);
ImGui::Text("%s", label);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
} else if (options.labelPosition == LabelPosition::Near) {
ImGui::SameLine(ImGui::CalcTextSize(label).x + ImGui::GetStyle().ItemSpacing.x * 2);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
} else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) {
float width = ImGui::CalcTextSize(comboMap.at(*value)).x + ImGui::GetStyle().FramePadding.x * 4;
ImGui::SameLine(ImGui::GetContentRegionAvail().x - width);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
}
}
if (ImGui::BeginCombo(invisibleLabel, comboMap.at(*value), options.flags)) {
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 10.0f));
for (const auto& pair : comboMap) {
if (strlen(pair.second) > 1) {
if (ImGui::Selectable(pair.second, pair.first == *value)) {
*value = pair.first;
dirty = true;
}
}
}
ImGui::PopStyleVar();
ImGui::EndCombo();
}
if (options.alignment == ComponentAlignment::Left) {
if (options.labelPosition == LabelPosition::Near) {
ImGui::SameLine();
ImGui::Text("%s", label);
} else if (options.labelPosition == LabelPosition::Far) {
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x);
ImGui::Text("%s", label);
}
} else if (options.alignment == ComponentAlignment::Right) {
if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far) {
ImGui::SameLine(startX);
ImGui::Text("%s", label);
}
}
PopStyleCombobox();
ImGui::EndDisabled();
ImGui::EndGroup();
if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && !Ship_IsCStringEmpty(options.disabledTooltip)) {
ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip).c_str());
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && !Ship_IsCStringEmpty(options.tooltip)) {
ImGui::SetTooltip("%s", WrappedText(options.tooltip).c_str());
}
ImGui::PopID();
return dirty;
}
bool CVarCombobox(const char* label, const char* cvarName, ComboVariant comboSource, const ComboboxOptions& options = {}) {
bool dirty = false;
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);
if (Combobox(label, &value, comboSource, options)) {
CVarSetInteger(cvarName, value);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
ShipInit::Init(cvarName);
dirty = true;
}
return dirty;
}*/
float CalcComboWidth(const char* preview_value, ImGuiComboFlags flags); float CalcComboWidth(const char* preview_value, ImGuiComboFlags flags);
template <typename T> template <typename T>