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

Commit 6036e50

Browse files
committed
Switch to using a single resolution multiplier property
1 parent 5402d63 commit 6036e50

File tree

5 files changed

+24
-60
lines changed

5 files changed

+24
-60
lines changed

GUI/AllegroInput.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ AllegroInput::AllegroInput(int whichPlayer, bool keyJoyMouseCursor):
3535

3636
#ifndef GUI_STANDALONE
3737
// Set the speed of the mouse
38-
float mouseDenominator = g_FrameMan.IsFullscreen() ? g_FrameMan.NxFullscreen() : g_FrameMan.NxWindowed();
38+
float mouseDenominator = g_FrameMan.ResolutionMultiplier();
3939
// If Nx fullscreen, adjust the mouse speed accordingly
40-
if (g_FrameMan.IsFullscreen() && g_FrameMan.NxFullscreen() > 1)
40+
if (g_FrameMan.IsFullscreen() && mouseDenominator > 1)
4141
set_mouse_speed(1, 1);
4242
else
4343
set_mouse_speed(2, 2);
@@ -283,7 +283,7 @@ void AllegroInput::Update(void)
283283
*/
284284
#ifndef GUI_STANDALONE
285285
// Get mouse cursor movement denominator based on window size multiplication
286-
float mouseDenominator = g_FrameMan.IsFullscreen() ? g_FrameMan.NxFullscreen() : g_FrameMan.NxWindowed();
286+
float mouseDenominator = g_FrameMan.ResolutionMultiplier();
287287

288288
// If joysticks and keyboard can control the mouse cursor too
289289
if (m_KeyJoyMouseCursor)

Managers/FrameMan.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ namespace RTE {
4444
m_NewResX = m_ResX;
4545
m_NewResY = m_ResY;
4646
m_Fullscreen = false;
47-
m_NxWindowed = 1;
48-
m_NxFullscreen = 1;
49-
m_NewNxFullscreen = 1;
47+
m_ResMultiplier = 1;
5048
m_HSplit = false;
5149
m_VSplit = false;
5250
m_HSplitOverride = false;
@@ -220,11 +218,8 @@ namespace RTE {
220218
m_NewResY = m_ResY;
221219
} else if (propName == "Fullscreen") {
222220
reader >> m_Fullscreen;
223-
} else if (propName == "NxWindowed") {
224-
reader >> m_NxWindowed;
225-
} else if (propName == "NxFullscreen") {
226-
reader >> m_NxFullscreen;
227-
m_NewNxFullscreen = m_NxFullscreen;
221+
} else if (propName == "ResolutionMultiplier") {
222+
reader >> m_ResMultiplier;
228223
} else if (propName == "HSplitScreen") {
229224
reader >> m_HSplitOverride;
230225
} else if (propName == "VSplitScreen") {
@@ -569,7 +564,7 @@ namespace RTE {
569564
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
570565

571566
void FrameMan::FlipFrameBuffers() {
572-
if ((!m_Fullscreen && m_NxWindowed != 1) || (m_Fullscreen && m_NxFullscreen != 1)) {
567+
if (m_ResMultiplier > 1) {
573568
stretch_blit(m_BackBuffer32, screen, 0, 0, m_BackBuffer32->w, m_BackBuffer32->h, 0, 0, SCREEN_W, SCREEN_H);
574569
} else {
575570
blit(m_BackBuffer32, screen, 0, 0, 0, 0, m_BackBuffer32->w, m_BackBuffer32->h);

Managers/FrameMan.h

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -194,35 +194,17 @@ namespace RTE {
194194
bool IsValidResolution(int width, int height) const;
195195

196196
/// <summary>
197-
/// Tells how many times the windowed screen resolution is being multiplied and the back-buffer stretched across for better readability.
197+
/// Tells how many times the screen resolution is being multiplied and the back-buffer stretched across for better readability.
198198
/// </summary>
199-
/// <returns>What multiple the windowed mode screen resolution is run in (1 normal).</returns>
200-
int NxWindowed() const { return m_NxWindowed; }
199+
/// <returns>What multiple the screen resolution is run in (1 normal).</returns>
200+
int ResolutionMultiplier() const { return m_ResMultiplier; }
201201

202202
/// <summary>
203203
/// Sets and switches to a new windowed mode multiplier.
204204
/// </summary>
205205
/// <param name="multiplier">The multiplier to switch to.</param>
206206
/// <returns>Error code, anything other than 0 is error.</returns>
207207
int SwitchWindowMultiplier(int multiplier = 1);
208-
209-
/// <summary>
210-
/// Tells how many times the fullscreen resolution is being multiplied and the back-buffer stretched across for better readability.
211-
/// </summary>
212-
/// <returns>What multiple the fullscreen mode screen resolution is run in (1 normal).</returns>
213-
int NxFullscreen() const { return m_NxFullscreen; }
214-
215-
/// <summary>
216-
/// Gets how many times the fullscreen resolution will be multiplied ON NEXT RESTART and the back-buffer stretched.
217-
/// </summary>
218-
/// <returns>What multiple the fullscreen mode screen resolution will be run in on next restart of game.</returns>
219-
int GetNewNxFullscreen() const { return m_NewNxFullscreen; }
220-
221-
/// <summary>
222-
/// Sets how many times the fullscreen resolution will be multiplied ON NEXT RESTART and the back-buffer stretched.
223-
/// </summary>
224-
/// <param name="newMultiple">What multiple the fullscreen mode screen resolution will be run in on next restart of game.</param>
225-
void SetNewNxFullscreen(int newMultiple) { m_NewNxFullscreen = newMultiple; }
226208
#pragma endregion
227209

228210
#pragma region Split-Screen Handling
@@ -592,13 +574,8 @@ namespace RTE {
592574

593575
bool m_Fullscreen; //!< Whether in fullscreen mode or not.
594576

595-
/// <summary>
596-
/// The number of times the fullscreen mode resolution should be multiplied and stretched across for better visibility.
597-
/// The internal virtual resolution (m_ResX, m_ResY) is 1/n of the actual fullscreen resolution that the graphics card outputs.
598-
/// </summary>
599-
int m_NxFullscreen;
600-
int m_NewNxFullscreen; //!< This is the new fullscreen multiple that will take effect next time the FrameMan is started.
601-
int m_NxWindowed; //!< The number of times the windowed mode resolution should be multiplied and stretched across for better visibility.
577+
unsigned char m_ResMultiplier; //!< The number of times the game window and image should be multiplied and stretched across for better visibility.
578+
unsigned char m_NewResMultiplier; //!< This is the new multiple that will take effect next time the FrameMan is started.
602579

603580
bool m_HSplit; //!< Whether the screen is split horizontally across the screen, ie as two splitscreens one above the other.
604581
bool m_VSplit; //!< Whether the screen is split vertically across the screen, ie as two splitscreens side by side.

Managers/SettingsMan.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,12 @@ int SettingsMan::ReadProperty(std::string propName, Reader &reader)
136136
g_FrameMan.ReadProperty(propName, reader);
137137
else if (propName == "ResolutionY")
138138
g_FrameMan.ReadProperty(propName, reader);
139+
else if (propName == "ResolutionMultiplier")
140+
g_FrameMan.ReadProperty(propName, reader);
139141
else if (propName == "PaletteFile")
140142
g_FrameMan.ReadProperty(propName, reader);
141143
else if (propName == "Fullscreen")
142144
g_FrameMan.ReadProperty(propName, reader);
143-
else if (propName == "NxWindowed")
144-
g_FrameMan.ReadProperty(propName, reader);
145-
else if (propName == "NxFullscreen")
146-
g_FrameMan.ReadProperty(propName, reader);
147145
else if (propName == "PixelsPerMeter")
148146
g_FrameMan.ReadProperty(propName, reader);
149147
else if (propName == "PlayIntro")
@@ -328,14 +326,12 @@ int SettingsMan::Save(Writer &writer) const
328326
writer << g_FrameMan.GetNewResX();
329327
writer.NewProperty("ResolutionY");
330328
writer << g_FrameMan.GetNewResY();
329+
writer.NewProperty("ResolutionMultiplier");
330+
writer << g_FrameMan.ResolutionMultiplier();
331331
writer.NewProperty("PaletteFile");
332332
writer << g_FrameMan.GetPaletteFile();
333333
writer.NewProperty("Fullscreen");
334334
writer << g_FrameMan.IsFullscreen();
335-
writer.NewProperty("NxWindowed");
336-
writer << g_FrameMan.NxWindowed();
337-
writer.NewProperty("NxFullscreen");
338-
writer << g_FrameMan.GetNewNxFullscreen();
339335
writer.NewProperty("PixelsPerMeter");
340336
writer << g_FrameMan.GetPPM();
341337
writer.NewProperty("PlayIntro");
@@ -518,15 +514,13 @@ int SettingsMan::SaveDefaults(Writer &writer) const
518514
writer << 960;
519515
writer.NewProperty("ResolutionY");
520516
writer << 540;
517+
writer.NewProperty("ResolutionMultiplier");
518+
writer << 1;
521519
writer.NewProperty("PaletteFile");
522520
ContentFile paletteFile("Base.rte/palette.bmp");
523521
writer << paletteFile;
524522
writer.NewProperty("Fullscreen");
525523
writer << 0;
526-
writer.NewProperty("NxWindowed");
527-
writer << 1;
528-
writer.NewProperty("NxFullscreen");
529-
writer << 2;
530524
writer.NewProperty("PixelsPerMeter");
531525
writer << 20;
532526
writer.NewProperty("PlayIntro");

Managers/UInputMan.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,11 +2027,10 @@ void UInputMan::ForceMouseWithinBox(int x, int y, int width, int height, int whi
20272027
// Only mess with the mouse if the original mouse position is not above the screen and may be grabbing the title bar of the game window
20282028
if (!m_DisableMouseMoving && !m_TrapMousePos && (whichPlayer == -1 || m_aControlScheme[whichPlayer].GetDevice() == DEVICE_MOUSE_KEYB))
20292029
{
2030-
float windowResMultiplier = g_FrameMan.IsFullscreen() ? g_FrameMan.NxFullscreen() : g_FrameMan.NxWindowed();
2031-
int mouseX = MAX(x, mouse_x);
2032-
int mouseY = MAX(y, mouse_y);
2033-
mouseX = MIN(mouseX, x + width * windowResMultiplier);
2034-
mouseY = MIN(mouseY, y + height * windowResMultiplier);
2030+
int mouseX = std::max(x, static_cast<int>(mouse_x));
2031+
int mouseY = std::max(y, static_cast<int>(mouse_y));
2032+
mouseX = std::min(mouseX, x + width * g_FrameMan.ResolutionMultiplier());
2033+
mouseY = std::min(mouseY, y + height * g_FrameMan.ResolutionMultiplier());
20352034

20362035
position_mouse(mouseX, mouseY);
20372036
}
@@ -2556,9 +2555,8 @@ int UInputMan::Update()
25562555

25572556
// Enable the mouse cursor positioning again after having been disabled. Only do this when the mouse is within the drawing area so it
25582557
// won't cause the whole window to move if the user clicks the title bar and unintentionally drags it due to programmatic positioning.
2559-
float mouseDenominator = g_FrameMan.IsFullscreen() ? g_FrameMan.NxFullscreen() : g_FrameMan.NxWindowed();
2560-
int mX = (float)mouse_x / mouseDenominator;
2561-
int mY = (float)mouse_y / mouseDenominator;
2558+
int mX = mouse_x / g_FrameMan.ResolutionMultiplier();
2559+
int mY = mouse_y / g_FrameMan.ResolutionMultiplier();
25622560
if (m_DisableMouseMoving && m_PrepareToEnableMouseMoving && (mX >= 0 && mX < g_FrameMan.GetResX() && mY >= 0 && mY < g_FrameMan.GetResY()))
25632561
m_DisableMouseMoving = m_PrepareToEnableMouseMoving = false;
25642562
}

0 commit comments

Comments
 (0)