Skip to content

Commit

Permalink
Modern Menu GUI Scaling Hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterdish committed Nov 15, 2024
1 parent f51b428 commit 5cadb59
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions mm/2s2h/BenGui/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ void BenMenu::DrawElement() {
ImVec2 pos = window->DC.CursorPos;
float centerX = pos.x + windowWidth / 2 - (style.ItemSpacing.x * (sectionCount + 1));
std::vector<ImVec2> headerSizes;
#ifdef __ANDROID__
float headerWidth = 600.0f + style.ItemSpacing.x;
#else
float headerWidth = 200.0f + style.ItemSpacing.x;
#endif
for (int i = 0; i < sectionCount; i++) {
ImVec2 size = ImGui::CalcTextSize(menuEntries.at(i).label.c_str());
headerSizes.push_back(size);
Expand All @@ -217,7 +221,11 @@ void BenMenu::DrawElement() {
headerWidth += style.ItemSpacing.x;
}
}
ImVec2 menuSize = { std::fminf(1280, windowWidth), std::fminf(800, windowHeight) };
#ifdef __ANDROID__
ImVec2 menuSize = {windowWidth,windowHeight};
#else
ImVec2 menuSize = {std::fminf(1280, windowWidth), std::fminf(800, windowHeight) };
#endif
pos += window->WorkRect.GetSize() / 2 - menuSize / 2;
ImGui::SetNextWindowPos(pos);
ImGui::BeginChild("Menu Block", menuSize,
Expand Down Expand Up @@ -287,7 +295,11 @@ void BenMenu::DrawElement() {
menuSearchText = menuSearch.InputBuf;
menuSearchText.erase(std::remove(menuSearchText.begin(), menuSearchText.end(), ' '), menuSearchText.end());
if (menuSearchText.length() < 1) {
#ifdef __ANDROID__
ImGui::SameLine(headerWidth - 600.0f + style.ItemSpacing.x);
#else
ImGui::SameLine(headerWidth - 200.0f + style.ItemSpacing.x);
#endif
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "Search...");
}
ImGui::PopStyleColor();
Expand All @@ -299,7 +311,7 @@ void BenMenu::DrawElement() {
.tooltip = "Reset"
#ifdef __APPLE__
" (Command-R)"
#elif !defined(__SWITCH__) && !defined(__WIIU__)
#elif !defined(__SWITCH__) && !defined(__WIIU__) && !defined(__ANDROID__)
" (Ctrl+R)"
#else
""
Expand Down Expand Up @@ -328,7 +340,11 @@ void BenMenu::DrawElement() {
float sectionHeight = menuSize.y - headerHeight - 4 - style.ItemSpacing.y * 2;
float columnHeight = sectionHeight - style.ItemSpacing.y * 4;
ImGui::SetNextWindowPos(pos + style.ItemSpacing * 2);
#ifdef __ANDROID__
float sidebarWidth = 600 - style.ItemSpacing.x;
#else
float sidebarWidth = 200 - style.ItemSpacing.x;
#endif

const char* sidebarCvar = menuEntries.at(headerIndex).sidebarCvar;

Expand Down Expand Up @@ -380,6 +396,9 @@ void BenMenu::DrawElement() {
if (windowWidth < 800) {
columns = 1;
}
#ifdef __ANDROID__
columns=1;
#endif
float columnWidth = (sectionWidth - style.ItemSpacing.x * columns) / columns;
bool useColumns = columns > 1;
if (!useColumns || (headerSearch && menuSearchText.length() > 0)) {
Expand Down

0 comments on commit 5cadb59

Please sign in to comment.