Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 4897a60

Browse files
committed
Changes to resolution multiplier button in settings menu so everything works
1 parent a952724 commit 4897a60

File tree

2 files changed

+33
-56
lines changed

2 files changed

+33
-56
lines changed

Menus/MainMenuGUI.cpp

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ int MainMenuGUI::Create(Controller *pController)
234234
m_aSkirmishButton[P4TEAM] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonP4Team"));
235235
m_pCPUTeamLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("LabelCPUTeam"));
236236

237-
m_aOptionButton[FULLSCREEN] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonFullscreen"));
237+
m_aOptionButton[RESOLUTIONMULTIPLIER] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonFullscreen"));
238238
m_aOptionButton[P1NEXT] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonP1NextDevice"));
239239
m_aOptionButton[P2NEXT] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonP2NextDevice"));
240240
m_aOptionButton[P3NEXT] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("ButtonP3NextDevice"));
@@ -353,15 +353,13 @@ int MainMenuGUI::Create(Controller *pController)
353353
m_pResolutionCombo = dynamic_cast<GUIComboBox *>(m_pGUIController->GetControl("ComboResolution"));
354354
UpdateResolutionCombo();
355355

356-
// Set labels only when we know max resolution, as it defines whether we can switch to 2X windowed mode or not
357-
if (g_FrameMan.IsFullscreen())
358-
m_aOptionButton[FULLSCREEN]->SetText("Go 1X Window");
359-
else
360-
{
361-
if (g_FrameMan.NxWindowed() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 - 25 && g_FrameMan.GetResY() <= m_MaxResY / 2 - 25)
362-
m_aOptionButton[FULLSCREEN]->SetText("Go 2X Window");
363-
else
364-
m_aOptionButton[FULLSCREEN]->SetText("Go Fullscreen");
356+
// Set labels only when we know max resolution, as it defines whether we can switch to 2X windowed mode or not
357+
if (g_FrameMan.ResolutionMultiplier() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 && g_FrameMan.GetResY() <= m_MaxResY / 2) {
358+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Go 2X");
359+
} else if (g_FrameMan.ResolutionMultiplier() > 1) {
360+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Go 1X");
361+
} else {
362+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Unavailable");
365363
}
366364

367365
m_pResolutionNoticeLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("LabelResolutionNotice"));
@@ -1025,40 +1023,28 @@ void MainMenuGUI::Update()
10251023
g_GUISound.ExitMenuSound()->Play();
10261024
}
10271025

1028-
// Fullscreen toggle button pressed
1029-
if (anEvent.GetControl() == m_aOptionButton[FULLSCREEN])
1030-
{
1031-
g_GUISound.ButtonPressSound()->Play();
1026+
// Multiplier toggle button pressed
1027+
if (anEvent.GetControl() == m_aOptionButton[RESOLUTIONMULTIPLIER]) {
1028+
g_GUISound.ButtonPressSound()->Play();
10321029

1033-
// Was fullscreen, switch to 1x window
1034-
if (g_FrameMan.IsFullscreen())
1035-
{
1036-
// First set the multiplier back to 1 and then switch to fullscreen so we get the right multiplier
1037-
g_FrameMan.SwitchWindowMultiplier(1);
1038-
g_FrameMan.ToggleFullscreen();
1039-
}
1040-
// Was windowed
1041-
else
1042-
{
1043-
// Was at 1x, change to 2x, but only if resolution is reasonable
1044-
if (g_FrameMan.NxWindowed() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 - 25 && g_FrameMan.GetResY() <= m_MaxResY / 2 - 25)
1045-
g_FrameMan.SwitchWindowMultiplier(2);
1046-
// Was at 2x, change to fullscreen
1047-
else
1048-
g_FrameMan.ToggleFullscreen();
1049-
}
1030+
if (g_FrameMan.ResolutionMultiplier() > 1) {
1031+
g_FrameMan.SwitchResolutionMultiplier(1);
1032+
} else if (g_FrameMan.ResolutionMultiplier() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 && g_FrameMan.GetResY() <= m_MaxResY / 2) {
1033+
g_FrameMan.SwitchResolutionMultiplier(2);
1034+
}
1035+
}
10501036

1051-
// Update the label to whatever we ended up with
1052-
if (g_FrameMan.IsFullscreen())
1053-
m_aOptionButton[FULLSCREEN]->SetText("Go 1X Window");
1054-
else
1055-
{
1056-
if (g_FrameMan.NxWindowed() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 - 25 && g_FrameMan.GetResY() <= m_MaxResY / 2 - 25)
1057-
m_aOptionButton[FULLSCREEN]->SetText("Go 2X Window");
1058-
else
1059-
m_aOptionButton[FULLSCREEN]->SetText("Go Fullscreen");
1060-
}
1061-
}
1037+
// Update the label to whatever we ended up with
1038+
if (g_FrameMan.ResolutionMultiplier() == 1 && g_FrameMan.GetResX() <= m_MaxResX / 2 && g_FrameMan.GetResY() <= m_MaxResY / 2) {
1039+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetVisible(true);
1040+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Go 2X");
1041+
} else if (g_FrameMan.ResolutionMultiplier() > 1) {
1042+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetVisible(true);
1043+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Go 1X");
1044+
} else {
1045+
//m_aOptionButton[RESOLUTIONMULTIPLIER]->SetVisible(false);
1046+
m_aOptionButton[RESOLUTIONMULTIPLIER]->SetText("Unavailable");
1047+
}
10621048

10631049
// Return to main menu button pressed
10641050
if (anEvent.GetControl() == m_aMainMenuButton[BACKTOMAIN])
@@ -1595,19 +1581,10 @@ void MainMenuGUI::Update()
15951581
int newResY = g_FrameMan.GetResY();
15961582
sscanf(pResItem->m_Name.c_str(), "%4dx%4d", &newResX, &newResY);
15971583
// Sanity check the values and then set them as the new resolution to be switched to next time FrameMan is created
1598-
/*if (newResX >= 400 && newResX < 3000 && newResY >= 400 && newResY < 3000)*/
1599-
if (g_FrameMan.IsValidResolution(newResX, newResY))
1600-
{
1601-
// Force double virtual fullscreen res if the res is too high
1602-
if (newResX >= 1280)
1603-
g_FrameMan.SetNewNxFullscreen(2);
1604-
// Not oversized resolution
1605-
else
1606-
g_FrameMan.SetNewNxFullscreen(1);
1607-
1608-
g_FrameMan.SetNewResX(newResX /= g_FrameMan.GetNewNxFullscreen());
1609-
g_FrameMan.SetNewResY(newResY /= g_FrameMan.GetNewNxFullscreen());
1610-
}
1584+
if (g_FrameMan.IsValidResolution(newResX, newResY)) {
1585+
g_FrameMan.SetNewResX(newResX / g_FrameMan.ResolutionMultiplier());
1586+
g_FrameMan.SetNewResY(newResY / g_FrameMan.ResolutionMultiplier());
1587+
}
16111588
}
16121589

16131590
// Update the resolution restart notice

Menus/MainMenuGUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class MainMenuGUI {
509509

510510
enum OptionsButtons
511511
{
512-
FULLSCREEN = 0,
512+
RESOLUTIONMULTIPLIER = 0,
513513
P1NEXT,
514514
P2NEXT,
515515
P3NEXT,

0 commit comments

Comments
 (0)