1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 15:38:30 +02:00

Add and use scaling mode enum

This enum is to just make each mode be readable, instead of mysterious
0/1/2 values. It's not a strictly-typed enum because we still have to
serialize it as ints in the XML, but it's better than just leaving them
as ints.

This also adds a NUM_SCALING_MODES enum, so we don't have to hardcode
that 3 when cycling scaling modes anymore.
This commit is contained in:
Misa 2021-12-25 23:05:14 -08:00
parent f5166c437e
commit 550e76a6dc
4 changed files with 16 additions and 7 deletions

View File

@ -1922,7 +1922,7 @@ void editorinput(void)
game.my = (float) key.my; game.my = (float) key.my;
ed.tilex=(game.mx - (game.mx%8))/8; ed.tilex=(game.mx - (game.mx%8))/8;
ed.tiley=(game.my - (game.my%8))/8; ed.tiley=(game.my - (game.my%8))/8;
if (gameScreen.scalingMode == 1) { if (gameScreen.scalingMode == SCALING_STRETCH) {
// In this mode specifically, we have to fix the mouse coordinates // In this mode specifically, we have to fix the mouse coordinates
int winwidth, winheight; int winwidth, winheight;
gameScreen.GetWindowSize(&winwidth, &winheight); gameScreen.GetWindowSize(&winwidth, &winheight);

View File

@ -318,12 +318,13 @@ static void menurender(void)
switch (gameScreen.scalingMode) switch (gameScreen.scalingMode)
{ {
case 2: case SCALING_INTEGER:
graphics.Print( -1, 85, "Current mode: INTEGER", tr, tg, tb, true); graphics.Print( -1, 85, "Current mode: INTEGER", tr, tg, tb, true);
break; break;
case 1: case SCALING_STRETCH:
graphics.Print( -1, 85, "Current mode: STRETCH", tr, tg, tb, true); graphics.Print( -1, 85, "Current mode: STRETCH", tr, tg, tb, true);
break; break;
case SCALING_LETTERBOX:
default: default:
graphics.Print( -1, 85, "Current mode: LETTERBOX", tr, tg, tb, true); graphics.Print( -1, 85, "Current mode: LETTERBOX", tr, tg, tb, true);
break; break;

View File

@ -14,7 +14,7 @@ void ScreenSettings_default(struct ScreenSettings* _this)
_this->windowHeight = 240; _this->windowHeight = 240;
_this->fullscreen = false; _this->fullscreen = false;
_this->useVsync = true; // Now that uncapped is the default... _this->useVsync = true; // Now that uncapped is the default...
_this->scalingMode = 0; _this->scalingMode = SCALING_LETTERBOX;
_this->linearFilter = false; _this->linearFilter = false;
_this->badSignal = false; _this->badSignal = false;
} }
@ -163,7 +163,7 @@ void Screen::ResizeScreen(int x, int y)
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
} }
} }
if (scalingMode == 1) if (scalingMode == SCALING_STRETCH)
{ {
int winX, winY; int winX, winY;
GetWindowSize(&winX, &winY); GetWindowSize(&winX, &winY);
@ -183,7 +183,7 @@ void Screen::ResizeScreen(int x, int y)
else else
{ {
SDL_RenderSetLogicalSize(m_renderer, 320, 240); SDL_RenderSetLogicalSize(m_renderer, 320, 240);
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (scalingMode == 2)); int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (scalingMode == SCALING_INTEGER));
if (result != 0) if (result != 0)
{ {
vlog_error("Error: could not set scale: %s", SDL_GetError()); vlog_error("Error: could not set scale: %s", SDL_GetError());
@ -331,7 +331,7 @@ void Screen::toggleFullScreen(void)
void Screen::toggleScalingMode(void) void Screen::toggleScalingMode(void)
{ {
scalingMode = (scalingMode + 1) % 3; scalingMode = (scalingMode + 1) % NUM_SCALING_MODES;
ResizeScreen(-1, -1); ResizeScreen(-1, -1);
} }

View File

@ -1,6 +1,14 @@
#ifndef SCREENSETTINGS_H #ifndef SCREENSETTINGS_H
#define SCREENSETTINGS_H #define SCREENSETTINGS_H
enum
{
SCALING_LETTERBOX = 0,
SCALING_STRETCH = 1,
SCALING_INTEGER = 2,
NUM_SCALING_MODES
};
struct ScreenSettings struct ScreenSettings
{ {
int windowWidth; int windowWidth;