mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Remove duplicate screen configuration variables
There were some duplicate Screen configuration variables that were on Game, when there didn't need to be. - game.fullScreenEffect_badSignal is a duplicate of graphics.screenbuffer->badSignalEffect - game.fullscreen is a duplicate of !graphics.screenbuffer->isWindowed - game.stretchMode is a duplicate of graphics.screenbuffer->stretchMode - game.useLinearFilter is a duplicate of graphics.screenbuffer->isFiltered These duplicate variables have been removed now. I put indentation when handling the ScreenSettings struct in main() so the local doesn't live for the entirety of main() (which is the entirety of the program).
This commit is contained in:
parent
af11f6936a
commit
40b7ddda05
6 changed files with 55 additions and 67 deletions
|
@ -167,17 +167,12 @@ void Game::init(void)
|
||||||
oldcreditposition = 0;
|
oldcreditposition = 0;
|
||||||
bestgamedeaths = -1;
|
bestgamedeaths = -1;
|
||||||
|
|
||||||
fullScreenEffect_badSignal = false;
|
|
||||||
|
|
||||||
//Accessibility Options
|
//Accessibility Options
|
||||||
colourblindmode = false;
|
colourblindmode = false;
|
||||||
noflashingmode = false;
|
noflashingmode = false;
|
||||||
slowdown = 30;
|
slowdown = 30;
|
||||||
gameframerate=34;
|
gameframerate=34;
|
||||||
|
|
||||||
fullscreen = false;// true; //Assumed true at first unless overwritten at some point!
|
|
||||||
stretchMode = 0;
|
|
||||||
useLinearFilter = false;
|
|
||||||
// 0..5
|
// 0..5
|
||||||
controllerSensitivity = 2;
|
controllerSensitivity = 2;
|
||||||
|
|
||||||
|
@ -4473,7 +4468,7 @@ void Game::unlocknum( int t )
|
||||||
|
|
||||||
#define LOAD_ARRAY(ARRAY_NAME) LOAD_ARRAY_RENAME(ARRAY_NAME, ARRAY_NAME)
|
#define LOAD_ARRAY(ARRAY_NAME) LOAD_ARRAY_RENAME(ARRAY_NAME, ARRAY_NAME)
|
||||||
|
|
||||||
void Game::loadstats(int *width, int *height, bool *vsync)
|
void Game::loadstats(ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
if (!FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc))
|
if (!FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc))
|
||||||
|
@ -4549,10 +4544,10 @@ void Game::loadstats(int *width, int *height, bool *vsync)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializesettings(dataNode, width, height, vsync);
|
deserializesettings(dataNode, screen_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::deserializesettings(tinyxml2::XMLElement* dataNode, int* width, int* height, bool* vsync)
|
void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
// Don't duplicate controller buttons!
|
// Don't duplicate controller buttons!
|
||||||
controllerButton_flip.clear();
|
controllerButton_flip.clear();
|
||||||
|
@ -4569,26 +4564,26 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, int* width, int*
|
||||||
|
|
||||||
if (pKey == "fullscreen")
|
if (pKey == "fullscreen")
|
||||||
{
|
{
|
||||||
fullscreen = help.Int(pText);
|
screen_settings->fullscreen = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "stretch")
|
if (pKey == "stretch")
|
||||||
{
|
{
|
||||||
stretchMode = help.Int(pText);
|
screen_settings->stretch = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "useLinearFilter")
|
if (pKey == "useLinearFilter")
|
||||||
{
|
{
|
||||||
useLinearFilter = help.Int(pText);
|
screen_settings->linearFilter = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "window_width")
|
if (pKey == "window_width")
|
||||||
{
|
{
|
||||||
*width = help.Int(pText);
|
screen_settings->windowWidth = help.Int(pText);
|
||||||
}
|
}
|
||||||
if (pKey == "window_height")
|
if (pKey == "window_height")
|
||||||
{
|
{
|
||||||
*height = help.Int(pText);
|
screen_settings->windowHeight = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4638,7 +4633,7 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, int* width, int*
|
||||||
|
|
||||||
if (pKey == "advanced_smoothing")
|
if (pKey == "advanced_smoothing")
|
||||||
{
|
{
|
||||||
fullScreenEffect_badSignal = help.Int(pText);
|
screen_settings->badSignal = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "usingmmmmmm")
|
if (pKey == "usingmmmmmm")
|
||||||
|
@ -4677,7 +4672,7 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, int* width, int*
|
||||||
|
|
||||||
if (pKey == "vsync")
|
if (pKey == "vsync")
|
||||||
{
|
{
|
||||||
*vsync = help.Int(pText);
|
screen_settings->useVsync = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "notextoutline")
|
if (pKey == "notextoutline")
|
||||||
|
@ -4853,11 +4848,11 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument& doc = xml::get_document(dataNode);
|
tinyxml2::XMLDocument& doc = xml::get_document(dataNode);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "fullscreen", fullscreen);
|
xml::update_tag(dataNode, "fullscreen", !graphics.screenbuffer->isWindowed);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "stretch", stretchMode);
|
xml::update_tag(dataNode, "stretch", graphics.screenbuffer->stretchMode);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "useLinearFilter", useLinearFilter);
|
xml::update_tag(dataNode, "useLinearFilter", graphics.screenbuffer->isFiltered);
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
if (graphics.screenbuffer != NULL)
|
if (graphics.screenbuffer != NULL)
|
||||||
|
@ -4884,7 +4879,7 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
||||||
xml::update_tag(dataNode, "slowdown", slowdown);
|
xml::update_tag(dataNode, "slowdown", slowdown);
|
||||||
|
|
||||||
|
|
||||||
xml::update_tag(dataNode, "advanced_smoothing", fullScreenEffect_badSignal);
|
xml::update_tag(dataNode, "advanced_smoothing", graphics.screenbuffer->badSignalEffect);
|
||||||
|
|
||||||
|
|
||||||
xml::update_tag(dataNode, "usingmmmmmm", usingmmmmmm);
|
xml::update_tag(dataNode, "usingmmmmmm", usingmmmmmm);
|
||||||
|
@ -4974,7 +4969,7 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
||||||
xml::update_tag(dataNode, "controllerSensitivity", controllerSensitivity);
|
xml::update_tag(dataNode, "controllerSensitivity", controllerSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::loadsettings(int* width, int* height, bool* vsync)
|
void Game::loadsettings(ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
if (!FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc))
|
if (!FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc))
|
||||||
|
@ -5001,7 +4996,7 @@ void Game::loadsettings(int* width, int* height, bool* vsync)
|
||||||
|
|
||||||
tinyxml2::XMLElement* dataNode = hRoot.FirstChildElement("Data").FirstChild().ToElement();
|
tinyxml2::XMLElement* dataNode = hRoot.FirstChildElement("Data").FirstChild().ToElement();
|
||||||
|
|
||||||
deserializesettings(dataNode, width, height, vsync);
|
deserializesettings(dataNode, screen_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::savesettings()
|
void Game::savesettings()
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ScreenSettings.h"
|
||||||
|
|
||||||
// Forward decl without including all of <tinyxml2.h>
|
// Forward decl without including all of <tinyxml2.h>
|
||||||
namespace tinyxml2
|
namespace tinyxml2
|
||||||
{
|
{
|
||||||
|
@ -128,17 +130,17 @@ public:
|
||||||
|
|
||||||
void unlocknum(int t);
|
void unlocknum(int t);
|
||||||
|
|
||||||
void loadstats(int *width, int *height, bool *vsync);
|
void loadstats(ScreenSettings* screen_settings);
|
||||||
|
|
||||||
void savestats(const bool stats_only = false);
|
void savestats(const bool stats_only = false);
|
||||||
|
|
||||||
void deletestats();
|
void deletestats();
|
||||||
|
|
||||||
void deserializesettings(tinyxml2::XMLElement* dataNode, int* width, int* height, bool* vsync);
|
void deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings);
|
||||||
|
|
||||||
void serializesettings(tinyxml2::XMLElement* dataNode);
|
void serializesettings(tinyxml2::XMLElement* dataNode);
|
||||||
|
|
||||||
void loadsettings(int* width, int* height, bool* vsync);
|
void loadsettings(ScreenSettings* screen_settings);
|
||||||
|
|
||||||
void savesettings();
|
void savesettings();
|
||||||
|
|
||||||
|
@ -308,7 +310,6 @@ public:
|
||||||
bool unlocknotify[numunlock];
|
bool unlocknotify[numunlock];
|
||||||
bool anything_unlocked();
|
bool anything_unlocked();
|
||||||
int stat_trinkets;
|
int stat_trinkets;
|
||||||
bool fullscreen;
|
|
||||||
int bestgamedeaths;
|
int bestgamedeaths;
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,9 +369,6 @@ public:
|
||||||
bool savemystats;
|
bool savemystats;
|
||||||
|
|
||||||
|
|
||||||
bool fullScreenEffect_badSignal;
|
|
||||||
bool useLinearFilter;
|
|
||||||
int stretchMode;
|
|
||||||
int controllerSensitivity;
|
int controllerSensitivity;
|
||||||
|
|
||||||
bool quickrestartkludge;
|
bool quickrestartkludge;
|
||||||
|
|
|
@ -385,7 +385,6 @@ void menuactionpress()
|
||||||
case 0:
|
case 0:
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
graphics.screenbuffer->toggleFullScreen();
|
graphics.screenbuffer->toggleFullScreen();
|
||||||
game.fullscreen = !game.fullscreen;
|
|
||||||
game.savestats();
|
game.savestats();
|
||||||
|
|
||||||
// Recreate menu to update "resize to nearest"
|
// Recreate menu to update "resize to nearest"
|
||||||
|
@ -395,7 +394,6 @@ void menuactionpress()
|
||||||
case 1:
|
case 1:
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
graphics.screenbuffer->toggleStretchMode();
|
graphics.screenbuffer->toggleStretchMode();
|
||||||
game.stretchMode = (game.stretchMode + 1) % 3;
|
|
||||||
game.savestats();
|
game.savestats();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -414,13 +412,11 @@ void menuactionpress()
|
||||||
case 3:
|
case 3:
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
graphics.screenbuffer->toggleLinearFilter();
|
graphics.screenbuffer->toggleLinearFilter();
|
||||||
game.useLinearFilter = !game.useLinearFilter;
|
|
||||||
game.savestats();
|
game.savestats();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//change smoothing
|
//change smoothing
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.fullScreenEffect_badSignal = !game.fullScreenEffect_badSignal;
|
|
||||||
graphics.screenbuffer->badSignalEffect= !graphics.screenbuffer->badSignalEffect;
|
graphics.screenbuffer->badSignalEffect= !graphics.screenbuffer->badSignalEffect;
|
||||||
game.savestats();
|
game.savestats();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -173,23 +173,31 @@ void menurender()
|
||||||
graphics.bigprint( -1, 30, "Toggle Fullscreen", tr, tg, tb, true);
|
graphics.bigprint( -1, 30, "Toggle Fullscreen", tr, tg, tb, true);
|
||||||
graphics.Print( -1, 65, "Change to fullscreen/windowed mode.", tr, tg, tb, true);
|
graphics.Print( -1, 65, "Change to fullscreen/windowed mode.", tr, tg, tb, true);
|
||||||
|
|
||||||
if(game.fullscreen){
|
if (graphics.screenbuffer->isWindowed)
|
||||||
graphics.Print( -1, 85, "Current mode: FULLSCREEN", tr, tg, tb, true);
|
{
|
||||||
}else{
|
|
||||||
graphics.Print( -1, 85, "Current mode: WINDOWED", tr, tg, tb, true);
|
graphics.Print( -1, 85, "Current mode: WINDOWED", tr, tg, tb, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphics.Print( -1, 85, "Current mode: FULLSCREEN", tr, tg, tb, true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
graphics.bigprint( -1, 30, "Scaling Mode", tr, tg, tb, true);
|
graphics.bigprint( -1, 30, "Scaling Mode", tr, tg, tb, true);
|
||||||
graphics.Print( -1, 65, "Choose letterbox/stretch/integer mode.", tr, tg, tb, true);
|
graphics.Print( -1, 65, "Choose letterbox/stretch/integer mode.", tr, tg, tb, true);
|
||||||
|
|
||||||
if(game.stretchMode == 2){
|
switch (graphics.screenbuffer->stretchMode)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
graphics.Print( -1, 85, "Current mode: INTEGER", tr, tg, tb, true);
|
graphics.Print( -1, 85, "Current mode: INTEGER", tr, tg, tb, true);
|
||||||
}else if (game.stretchMode == 1){
|
break;
|
||||||
|
case 1:
|
||||||
graphics.Print( -1, 85, "Current mode: STRETCH", tr, tg, tb, true);
|
graphics.Print( -1, 85, "Current mode: STRETCH", tr, tg, tb, true);
|
||||||
}else{
|
break;
|
||||||
|
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;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -206,9 +214,12 @@ void menurender()
|
||||||
graphics.bigprint( -1, 30, "Toggle Filter", tr, tg, tb, true);
|
graphics.bigprint( -1, 30, "Toggle Filter", tr, tg, tb, true);
|
||||||
graphics.Print( -1, 65, "Change to nearest/linear filter.", tr, tg, tb, true);
|
graphics.Print( -1, 65, "Change to nearest/linear filter.", tr, tg, tb, true);
|
||||||
|
|
||||||
if(game.useLinearFilter){
|
if (graphics.screenbuffer->isFiltered)
|
||||||
|
{
|
||||||
graphics.Print( -1, 85, "Current mode: LINEAR", tr, tg, tb, true);
|
graphics.Print( -1, 85, "Current mode: LINEAR", tr, tg, tb, true);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
graphics.Print( -1, 85, "Current mode: NEAREST", tr, tg, tb, true);
|
graphics.Print( -1, 85, "Current mode: NEAREST", tr, tg, tb, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3906,7 +3906,7 @@ void editorinput()
|
||||||
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 (game.stretchMode == 1) {
|
if (graphics.screenbuffer->stretchMode == 1) {
|
||||||
// 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;
|
||||||
graphics.screenbuffer->GetWindowSize(&winwidth, &winheight);
|
graphics.screenbuffer->GetWindowSize(&winwidth, &winheight);
|
||||||
|
|
|
@ -213,25 +213,14 @@ int main(int argc, char *argv[])
|
||||||
graphics.towerbg.bypos = map.ypos / 2;
|
graphics.towerbg.bypos = map.ypos / 2;
|
||||||
graphics.titlebg.bypos = map.ypos / 2;
|
graphics.titlebg.bypos = map.ypos / 2;
|
||||||
|
|
||||||
//Moved screensetting init here from main menu V2.1
|
{
|
||||||
int width = 320;
|
|
||||||
int height = 240;
|
|
||||||
bool vsync = false;
|
|
||||||
|
|
||||||
// Prioritize unlock.vvv first (2.2 and below),
|
// Prioritize unlock.vvv first (2.2 and below),
|
||||||
// but settings have been migrated to settings.vvv (2.3 and up)
|
// but settings have been migrated to settings.vvv (2.3 and up)
|
||||||
game.loadstats(&width, &height, &vsync);
|
ScreenSettings screen_settings;
|
||||||
game.loadsettings(&width, &height, &vsync);
|
game.loadstats(&screen_settings);
|
||||||
|
game.loadsettings(&screen_settings);
|
||||||
gameScreen.init(
|
gameScreen.init(screen_settings);
|
||||||
width,
|
}
|
||||||
height,
|
|
||||||
game.fullscreen,
|
|
||||||
vsync,
|
|
||||||
game.stretchMode,
|
|
||||||
game.useLinearFilter,
|
|
||||||
game.fullScreenEffect_badSignal
|
|
||||||
);
|
|
||||||
graphics.screenbuffer = &gameScreen;
|
graphics.screenbuffer = &gameScreen;
|
||||||
|
|
||||||
const SDL_PixelFormat* fmt = gameScreen.GetFormat();
|
const SDL_PixelFormat* fmt = gameScreen.GetFormat();
|
||||||
|
@ -490,7 +479,6 @@ void inline fixedloop()
|
||||||
if(key.toggleFullscreen)
|
if(key.toggleFullscreen)
|
||||||
{
|
{
|
||||||
gameScreen.toggleFullScreen();
|
gameScreen.toggleFullScreen();
|
||||||
game.fullscreen = !game.fullscreen;
|
|
||||||
key.toggleFullscreen = false;
|
key.toggleFullscreen = false;
|
||||||
|
|
||||||
key.keymap.clear(); //we lost the input due to a new window.
|
key.keymap.clear(); //we lost the input due to a new window.
|
||||||
|
|
Loading…
Reference in a new issue