@@ -321,53 +321,40 @@ namespace RTE {
321
321
322
322
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
323
323
324
- int FrameMan::SwitchWindowMultiplier ( int multiplier) {
325
- if (multiplier <= 0 || multiplier > 4 || multiplier == m_NxWindowed ) {
324
+ int FrameMan::SwitchResolutionMultiplier ( unsigned char multiplier) {
325
+ if (multiplier <= 0 || multiplier > 4 || multiplier == m_ResMultiplier ) {
326
326
return -1 ;
327
327
}
328
- if (m_Fullscreen) {
329
- m_NxWindowed = multiplier;
330
- return 0 ;
328
+ if (m_ResX > m_ScreenResX / multiplier) {
329
+ return -1 ;
331
330
}
332
331
333
- // Refuse windowed multiplier if the resolution is too high
334
- if (m_ResX > 1024 ) { m_NxWindowed = 1 ; }
335
-
336
332
// Save the palette so we can re-set it after the switch.
337
333
PALETTE pal;
338
334
get_palette (pal);
335
+
339
336
// Need to save these first for recovery attempts to work (screen might be 0)
340
337
int resX = m_ResX;
341
338
int resY = m_ResY;
342
339
343
- // Switch to new windowed mode
344
- if (set_gfx_mode (GFX_AUTODETECT_WINDOWED, resX * multiplier, resY * multiplier, 0 , 0 ) != 0 ) {
340
+ // Set the GFX_TEXT driver to hack around Allegro's window resizing limitations (specifically reducing window size) when switching from 2X mode to 1X mode.
341
+ // This will force a state where this is no actual game window, and the next set_gfx_mode call will recreate it correctly.
342
+ set_gfx_mode (GFX_TEXT, 0 , 0 , 0 , 0 );
343
+
344
+ if (set_gfx_mode (m_GfxDriver, resX * multiplier, resY * multiplier, 0 , 0 ) != 0 ) {
345
345
// Oops, failed to set windowed mode, so go back to previous multiplier
346
- if (set_gfx_mode (GFX_AUTODETECT_WINDOWED, resX * m_NxWindowed, resY * m_NxWindowed, 0 , 0 ) != 0 ) {
347
- // Can't go back to previous mode either! total fail
346
+ if (set_gfx_mode (m_GfxDriver, resX * m_ResMultiplier, resY * m_ResMultiplier, 0 , 0 ) != 0 ) {
348
347
set_gfx_mode (GFX_TEXT, 0 , 0 , 0 , 0 );
349
348
allegro_message (" Unable to set back to previous windowed mode multiplier because: %s!" , allegro_error);
350
349
return 1 ;
351
350
}
352
- // Successfully reverted back to previous setting
353
351
g_ConsoleMan.PrintString (" ERROR: Failed to switch to new windowed mode multiplier, reverted back to previous setting!" );
354
- // Reset the palette.
355
352
set_palette (pal);
356
- // Make sure everything gets caught up after the switch
357
- rest (2000 );
358
353
return 1 ;
359
354
}
360
- // Make sure everything gets caught up after the switch
361
- rest (2000 );
362
- g_ConsoleMan.PrintString (" SYSTEM: Switched to different windowed mode multiplier" );
363
-
364
- // Save the new multiplier
365
- m_NxWindowed = multiplier;
366
- m_Fullscreen = false ;
367
-
368
- // Reset the palette.
355
+ g_ConsoleMan.PrintString (" SYSTEM: Switched to different windowed mode multiplier." );
356
+ m_ResMultiplier = multiplier;
369
357
set_palette (pal);
370
-
371
358
return 0 ;
372
359
}
373
360
0 commit comments