mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-31 22:19:44 +01:00
Allow Game::savestats() to accept a pointer to ScreenSettings
Another step to fix the bug #556 is to allow Game::savestats() to accept a pointer to an existing ScreenSettings struct. This entails refactoring Game::savesettings() and Game::serializesettings() to accept the function as well, along with adding Screen::GetSettings() so the settings of the current Screen can be easily grabbed.
This commit is contained in:
parent
b62908f0f4
commit
55163e90d5
4 changed files with 46 additions and 30 deletions
|
@ -4737,6 +4737,14 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::savestats()
|
bool Game::savestats()
|
||||||
|
{
|
||||||
|
ScreenSettings screen_settings;
|
||||||
|
graphics.screenbuffer->GetSettings(&screen_settings);
|
||||||
|
|
||||||
|
return savestats(&screen_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::savestats(const ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc);
|
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc);
|
||||||
|
@ -4810,7 +4818,7 @@ bool Game::savestats()
|
||||||
|
|
||||||
xml::update_tag(dataNode, "swnrecord", swnrecord);
|
xml::update_tag(dataNode, "swnrecord", swnrecord);
|
||||||
|
|
||||||
serializesettings(dataNode);
|
serializesettings(dataNode, screen_settings);
|
||||||
|
|
||||||
return FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc);
|
return FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc);
|
||||||
}
|
}
|
||||||
|
@ -4834,29 +4842,19 @@ void Game::savestatsandsettings_menu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument& doc = xml::get_document(dataNode);
|
tinyxml2::XMLDocument& doc = xml::get_document(dataNode);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "fullscreen", !graphics.screenbuffer->isWindowed);
|
xml::update_tag(dataNode, "fullscreen", (int) screen_settings->fullscreen);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "stretch", graphics.screenbuffer->stretchMode);
|
xml::update_tag(dataNode, "stretch", screen_settings->stretch);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "useLinearFilter", graphics.screenbuffer->isFiltered);
|
xml::update_tag(dataNode, "useLinearFilter", (int) screen_settings->linearFilter);
|
||||||
|
|
||||||
int width, height;
|
xml::update_tag(dataNode, "window_width", screen_settings->windowWidth);
|
||||||
if (graphics.screenbuffer != NULL)
|
|
||||||
{
|
|
||||||
graphics.screenbuffer->GetWindowSize(&width, &height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
width = 320;
|
|
||||||
height = 240;
|
|
||||||
}
|
|
||||||
xml::update_tag(dataNode, "window_width", width);
|
|
||||||
|
|
||||||
xml::update_tag(dataNode, "window_height", height);
|
xml::update_tag(dataNode, "window_height", screen_settings->windowHeight);
|
||||||
|
|
||||||
xml::update_tag(dataNode, "noflashingmode", noflashingmode);
|
xml::update_tag(dataNode, "noflashingmode", noflashingmode);
|
||||||
|
|
||||||
|
@ -4869,7 +4867,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", graphics.screenbuffer->badSignalEffect);
|
xml::update_tag(dataNode, "advanced_smoothing", (int) screen_settings->badSignal);
|
||||||
|
|
||||||
|
|
||||||
xml::update_tag(dataNode, "usingmmmmmm", music.usingmmmmmm);
|
xml::update_tag(dataNode, "usingmmmmmm", music.usingmmmmmm);
|
||||||
|
@ -4890,16 +4888,7 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
||||||
|
|
||||||
xml::update_tag(dataNode, "glitchrunnermode", (int) glitchrunnermode);
|
xml::update_tag(dataNode, "glitchrunnermode", (int) glitchrunnermode);
|
||||||
|
|
||||||
int vsyncOption;
|
xml::update_tag(dataNode, "vsync", (int) screen_settings->useVsync);
|
||||||
if (graphics.screenbuffer != NULL)
|
|
||||||
{
|
|
||||||
vsyncOption = (int) graphics.screenbuffer->vsync;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vsyncOption = 0;
|
|
||||||
}
|
|
||||||
xml::update_tag(dataNode, "vsync", vsyncOption);
|
|
||||||
|
|
||||||
// Delete all controller buttons we had previously.
|
// Delete all controller buttons we had previously.
|
||||||
// dataNode->FirstChildElement() shouldn't be NULL at this point...
|
// dataNode->FirstChildElement() shouldn't be NULL at this point...
|
||||||
|
@ -4990,6 +4979,14 @@ void Game::loadsettings(ScreenSettings* screen_settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::savesettings()
|
bool Game::savesettings()
|
||||||
|
{
|
||||||
|
ScreenSettings screen_settings;
|
||||||
|
graphics.screenbuffer->GetSettings(&screen_settings);
|
||||||
|
|
||||||
|
return savesettings(&screen_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::savesettings(const ScreenSettings* screen_settings)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc);
|
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc);
|
||||||
|
@ -5006,7 +5003,7 @@ bool Game::savesettings()
|
||||||
|
|
||||||
tinyxml2::XMLElement* dataNode = xml::update_element(root, "Data");
|
tinyxml2::XMLElement* dataNode = xml::update_element(root, "Data");
|
||||||
|
|
||||||
serializesettings(dataNode);
|
serializesettings(dataNode, screen_settings);
|
||||||
|
|
||||||
return FILESYSTEM_saveTiXml2Document("saves/settings.vvv", doc);
|
return FILESYSTEM_saveTiXml2Document("saves/settings.vvv", doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,16 +133,18 @@ public:
|
||||||
|
|
||||||
void loadstats(ScreenSettings* screen_settings);
|
void loadstats(ScreenSettings* screen_settings);
|
||||||
|
|
||||||
|
bool savestats(const ScreenSettings* screen_settings);
|
||||||
bool savestats();
|
bool savestats();
|
||||||
|
|
||||||
void deletestats();
|
void deletestats();
|
||||||
|
|
||||||
void deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings);
|
void deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings);
|
||||||
|
|
||||||
void serializesettings(tinyxml2::XMLElement* dataNode);
|
void serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSettings* screen_settings);
|
||||||
|
|
||||||
void loadsettings(ScreenSettings* screen_settings);
|
void loadsettings(ScreenSettings* screen_settings);
|
||||||
|
|
||||||
|
bool savesettings(const ScreenSettings* screen_settings);
|
||||||
bool savesettings();
|
bool savesettings();
|
||||||
|
|
||||||
bool savestatsandsettings();
|
bool savestatsandsettings();
|
||||||
|
|
|
@ -93,6 +93,21 @@ void Screen::init(const ScreenSettings& settings)
|
||||||
ResizeScreen(settings.windowWidth, settings.windowHeight);
|
ResizeScreen(settings.windowWidth, settings.windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen::GetSettings(ScreenSettings* settings)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
GetWindowSize(&width, &height);
|
||||||
|
|
||||||
|
settings->windowWidth = width;
|
||||||
|
settings->windowHeight = height;
|
||||||
|
|
||||||
|
settings->fullscreen = !isWindowed;
|
||||||
|
settings->useVsync = vsync;
|
||||||
|
settings->stretch = stretchMode;
|
||||||
|
settings->linearFilter = isFiltered;
|
||||||
|
settings->badSignal = badSignalEffect;
|
||||||
|
}
|
||||||
|
|
||||||
void Screen::LoadIcon()
|
void Screen::LoadIcon()
|
||||||
{
|
{
|
||||||
unsigned char *fileIn = NULL;
|
unsigned char *fileIn = NULL;
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Screen
|
||||||
public:
|
public:
|
||||||
void init(const ScreenSettings& settings);
|
void init(const ScreenSettings& settings);
|
||||||
|
|
||||||
|
void GetSettings(ScreenSettings* settings);
|
||||||
|
|
||||||
void LoadIcon();
|
void LoadIcon();
|
||||||
|
|
||||||
void ResizeScreen(int x, int y);
|
void ResizeScreen(int x, int y);
|
||||||
|
|
Loading…
Reference in a new issue