Skip to content

Commit

Permalink
Resize mod menu window
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Jul 5, 2024
1 parent c8ae1bf commit 0439a69
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/BMLMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,8 +1406,8 @@ void BMLMod::OnDrawMenu() {
ImGui::PushFont(m_Font);

const ImVec2 &vpSize = ImGui::GetMainViewport()->Size;
ImGui::SetNextWindowPos(ImVec2(vpSize.x * 0.3f, 0.0f), ImGuiCond_Appearing);
ImGui::SetNextWindowSize(ImVec2(vpSize.x * 0.7f, vpSize.y), ImGuiCond_Appearing);
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_Appearing);
ImGui::SetNextWindowSize(ImVec2(vpSize.x, vpSize.y), ImGuiCond_Appearing);

switch (m_CurrentMenu) {
case MENU_MOD_LIST:
Expand Down Expand Up @@ -1498,16 +1498,17 @@ void BMLMod::OnDrawModPage() {

ImGui::Dummy(Bui::CoordToScreenPos(ImVec2(0.375f, 0.1f)));

ImVec2 &vpSize = ImGui::GetMainViewport()->Size;
float menuWidth = vpSize.x * 0.4f;
const ImVec2 &vpSize = ImGui::GetMainViewport()->Size;
const float menuX = vpSize.x * 0.3f;
const float menuWidth = vpSize.x * 0.4f;

{
float oldScale = ImGui::GetFont()->Scale;
ImGui::GetFont()->Scale *= 1.2f;
ImGui::PushFont(ImGui::GetFont());

const float textWidth = ImGui::CalcTextSize(m_CurrentMod->GetName()).x;
ImGui::SetCursorPosX((menuWidth - textWidth) * 0.5f);
ImGui::SetCursorPosX(menuX + (menuWidth - textWidth) * 0.5f);
ImGui::TextUnformatted(m_CurrentMod->GetName());

ImGui::GetFont()->Scale = oldScale;
Expand All @@ -1521,10 +1522,11 @@ void BMLMod::OnDrawModPage() {
const float textWidth = ImGui::CalcTextSize(buf).x;
const float indent = (menuWidth - textWidth) * 0.5f;
if (indent > 0) {
ImGui::SetCursorPosX(indent);
ImGui::PushTextWrapPos(indent + textWidth);
ImGui::SetCursorPosX(menuX + indent);
ImGui::PushTextWrapPos(menuX + indent + textWidth);
} else {
ImGui::PushTextWrapPos(menuWidth);
ImGui::SetCursorPosX(menuX - indent);
ImGui::PushTextWrapPos(menuX + menuWidth);
}
ImGui::TextUnformatted(buf);
ImGui::PopTextWrapPos();
Expand All @@ -1533,7 +1535,7 @@ void BMLMod::OnDrawModPage() {
{
snprintf(buf, sizeof(buf), "v%s", m_CurrentMod->GetVersion());
const float textWidth = ImGui::CalcTextSize(buf).x;
ImGui::SetCursorPosX((menuWidth - textWidth) * 0.5f);
ImGui::SetCursorPosX(menuX + (menuWidth - textWidth) * 0.5f);
ImGui::TextUnformatted(buf);
}

Expand All @@ -1543,10 +1545,11 @@ void BMLMod::OnDrawModPage() {
const float textWidth = ImGui::CalcTextSize(m_CurrentMod->GetDescription()).x;
const float indent = (menuWidth - textWidth) * 0.5f;
if (indent > 0) {
ImGui::SetCursorPosX(indent);
ImGui::PushTextWrapPos(indent + textWidth);
ImGui::SetCursorPosX(menuX + indent);
ImGui::PushTextWrapPos(menuX + indent + textWidth);
} else {
ImGui::PushTextWrapPos(menuWidth);
ImGui::SetCursorPosX(menuX - indent);
ImGui::PushTextWrapPos(menuX + menuWidth);
}
ImGui::TextUnformatted(m_CurrentMod->GetDescription());
ImGui::PopTextWrapPos();
Expand Down

0 comments on commit 0439a69

Please sign in to comment.