From 3eedc9cb6d73a19bff083206b84c45eebe5a1f01 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 19 Sep 2013 21:18:26 -0400 Subject: [PATCH 1/2] Eliminate some magic numbers, and make several functions more consistent with each other. --- Windows/WndMainWindow.cpp | 61 +++++++++++++++++++++------------------ Windows/WndMainWindow.h | 12 ++++++++ 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index b22680bf48..e031d818f3 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -232,11 +232,10 @@ namespace MainWindow } void SetInternalResolution(int res = -1) { - const int MAX_ZOOM = 10; - if (res >= 0 && res <= MAX_ZOOM) + if (res >= 0 && res <= RESOLUTION_MAX) g_Config.iInternalResolution = res; else { - if (++g_Config.iInternalResolution > MAX_ZOOM) + if (++g_Config.iInternalResolution > RESOLUTION_MAX) g_Config.iInternalResolution = 0; } @@ -570,8 +569,13 @@ namespace MainWindow if(gpu) gpu->ClearCacheNextFrame(); } - void setRenderingMode(int mode) { - g_Config.iRenderingMode = mode; + void setRenderingMode(int mode = -1) { + if (mode >= FB_NON_BUFFERED_MODE) + g_Config.iRenderingMode = mode; + else { + if (++g_Config.iRenderingMode > FB_READFBOMEMORY_GPU) + g_Config.iRenderingMode = FB_NON_BUFFERED_MODE; + } I18NCategory *g = GetI18NCategory("Graphics"); @@ -600,8 +604,13 @@ namespace MainWindow g_Config.iFpsLimit = fps; } - void setFrameSkipping(int framesToSkip) { - g_Config.iFrameSkip = framesToSkip; + void setFrameSkipping(int framesToSkip = -1) { + if (framesToSkip >= FRAMESKIP_OFF) + g_Config.iFrameSkip = framesToSkip; + else { + if (++g_Config.iFrameSkip > FRAMESKIP_MAX) + g_Config.iFrameSkip = FRAMESKIP_OFF; + } I18NCategory *g = GetI18NCategory("Graphics"); const char *frameskipStr = g->T("Frame Skipping"); @@ -1128,17 +1137,17 @@ namespace MainWindow SaveState::SaveSlot(g_Config.iCurrentStateSlot, SaveStateActionFinished); break; - case ID_OPTIONS_SCREENAUTO: SetInternalResolution(0); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN1X: SetInternalResolution(1); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN2X: SetInternalResolution(2); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN3X: SetInternalResolution(3); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN4X: SetInternalResolution(4); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN5X: SetInternalResolution(5); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN6X: SetInternalResolution(6); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN7X: SetInternalResolution(7); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN8X: SetInternalResolution(8); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN9X: SetInternalResolution(9); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN10X: SetInternalResolution(10); ResizeDisplay(true); break; + case ID_OPTIONS_SCREENAUTO: SetInternalResolution(RESOLUTION_AUTO); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN1X: SetInternalResolution(RESOLUTION_NATIVE); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN2X: SetInternalResolution(RESOLUTION_2X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN3X: SetInternalResolution(RESOLUTION_3X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN4X: SetInternalResolution(RESOLUTION_4X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN5X: SetInternalResolution(RESOLUTION_5X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN6X: SetInternalResolution(RESOLUTION_6X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN7X: SetInternalResolution(RESOLUTION_7X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN8X: SetInternalResolution(RESOLUTION_8X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN9X: SetInternalResolution(RESOLUTION_9X); ResizeDisplay(true); break; + case ID_OPTIONS_SCREEN10X: SetInternalResolution(RESOLUTION_MAX); ResizeDisplay(true); break; case ID_OPTIONS_WINDOW1X: SetWindowSize(1); break; case ID_OPTIONS_WINDOW2X: SetWindowSize(2); break; @@ -1180,9 +1189,7 @@ namespace MainWindow // Dummy option to let the buffered rendering hotkey cycle through all the options. case ID_OPTIONS_BUFFEREDRENDERINGDUMMY: - g_Config.iRenderingMode = ++g_Config.iRenderingMode > FB_READFBOMEMORY_GPU ? FB_NON_BUFFERED_MODE : g_Config.iRenderingMode; - - setRenderingMode(g_Config.iRenderingMode); + setRenderingMode(); break; case ID_DEBUG_SHOWDEBUGSTATISTICS: @@ -1212,9 +1219,7 @@ namespace MainWindow case ID_OPTIONS_FRAMESKIP_8: setFrameSkipping(FRAMESKIP_MAX); break; case ID_OPTIONS_FRAMESKIPDUMMY: - g_Config.iFrameSkip = ++g_Config.iFrameSkip > FRAMESKIP_MAX ? FRAMESKIP_OFF : g_Config.iFrameSkip; - - setFrameSkipping(g_Config.iFrameSkip); + setFrameSkipping(); break; case ID_FILE_EXIT: @@ -1559,11 +1564,11 @@ namespace MainWindow ID_OPTIONS_SCREEN9X, ID_OPTIONS_SCREEN10X, }; - if (g_Config.iInternalResolution < 0) - g_Config.iInternalResolution = 0; + if (g_Config.iInternalResolution < RESOLUTION_AUTO) + g_Config.iInternalResolution = RESOLUTION_AUTO; - else if(g_Config.iInternalResolution > 10) - g_Config.iInternalResolution = 5; + else if (g_Config.iInternalResolution > RESOLUTION_MAX) + g_Config.iInternalResolution = RESOLUTION_MAX; for (int i = 0; i < ARRAY_SIZE(zoomitems); i++) { CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iInternalResolution) ? MF_CHECKED : MF_UNCHECKED)); diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index a6b5082471..2a784a9f5a 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -28,6 +28,18 @@ namespace MainWindow FRAMESKIP_8 = 9, FRAMESKIP_MAX = FRAMESKIP_8, + RESOLUTION_AUTO = 0, + RESOLUTION_NATIVE = 1, + RESOLUTION_2X = 2, + RESOLUTION_3X = 3, + RESOLUTION_4X = 4, + RESOLUTION_5X = 5, + RESOLUTION_6X = 6, + RESOLUTION_7X = 7, + RESOLUTION_8X = 8, + RESOLUTION_9X = 9, + RESOLUTION_MAX = 10, + TEXSCALING_OFF = 1, TEXSCALING_2X = 2, TEXSCALING_3X = 3, From 3c1c7aade8b67ec231d6bd1af64a9a1d49a0594d Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 19 Sep 2013 23:27:25 -0400 Subject: [PATCH 2/2] Just call ResizeDisplay(true) inside SetInternalResolution. --- Windows/WndMainWindow.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index e031d818f3..180d6a5eb8 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -239,6 +239,7 @@ namespace MainWindow g_Config.iInternalResolution = 0; } + ResizeDisplay(true); } void CorrectCursor() { @@ -1137,17 +1138,17 @@ namespace MainWindow SaveState::SaveSlot(g_Config.iCurrentStateSlot, SaveStateActionFinished); break; - case ID_OPTIONS_SCREENAUTO: SetInternalResolution(RESOLUTION_AUTO); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN1X: SetInternalResolution(RESOLUTION_NATIVE); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN2X: SetInternalResolution(RESOLUTION_2X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN3X: SetInternalResolution(RESOLUTION_3X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN4X: SetInternalResolution(RESOLUTION_4X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN5X: SetInternalResolution(RESOLUTION_5X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN6X: SetInternalResolution(RESOLUTION_6X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN7X: SetInternalResolution(RESOLUTION_7X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN8X: SetInternalResolution(RESOLUTION_8X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN9X: SetInternalResolution(RESOLUTION_9X); ResizeDisplay(true); break; - case ID_OPTIONS_SCREEN10X: SetInternalResolution(RESOLUTION_MAX); ResizeDisplay(true); break; + case ID_OPTIONS_SCREENAUTO: SetInternalResolution(RESOLUTION_AUTO); break; + case ID_OPTIONS_SCREEN1X: SetInternalResolution(RESOLUTION_NATIVE); break; + case ID_OPTIONS_SCREEN2X: SetInternalResolution(RESOLUTION_2X); break; + case ID_OPTIONS_SCREEN3X: SetInternalResolution(RESOLUTION_3X); break; + case ID_OPTIONS_SCREEN4X: SetInternalResolution(RESOLUTION_4X); break; + case ID_OPTIONS_SCREEN5X: SetInternalResolution(RESOLUTION_5X); break; + case ID_OPTIONS_SCREEN6X: SetInternalResolution(RESOLUTION_6X); break; + case ID_OPTIONS_SCREEN7X: SetInternalResolution(RESOLUTION_7X); break; + case ID_OPTIONS_SCREEN8X: SetInternalResolution(RESOLUTION_8X); break; + case ID_OPTIONS_SCREEN9X: SetInternalResolution(RESOLUTION_9X); break; + case ID_OPTIONS_SCREEN10X: SetInternalResolution(RESOLUTION_MAX); break; case ID_OPTIONS_WINDOW1X: SetWindowSize(1); break; case ID_OPTIONS_WINDOW2X: SetWindowSize(2); break; @@ -1157,7 +1158,6 @@ namespace MainWindow case ID_OPTIONS_RESOLUTIONDUMMY: { SetInternalResolution(); - ResizeDisplay(true); break; }