mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
De-C++-ify struct ScreenSettings
This includes: - Removing the constructor in favor of actually being able to see that there's an actual function called being made initializing the struct - Removing the use of a reference in Screen::init() in favor of using a pointer - Adding the struct qualifier everywhere (it's not much typing), although technically you could typedef it in C, but I'd rather much not typedef just to remove a tag qualifier
This commit is contained in:
parent
d0ffafe117
commit
1e157f3cc9
6 changed files with 37 additions and 36 deletions
|
@ -4021,7 +4021,7 @@ void Game::unlocknum( int t )
|
|||
#endif
|
||||
}
|
||||
|
||||
void Game::loadstats(ScreenSettings* screen_settings)
|
||||
void Game::loadstats(struct ScreenSettings* screen_settings)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLHandle hDoc(&doc);
|
||||
|
@ -4100,7 +4100,7 @@ void Game::loadstats(ScreenSettings* screen_settings)
|
|||
deserializesettings(dataNode, screen_settings);
|
||||
}
|
||||
|
||||
void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings)
|
||||
void Game::deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSettings* screen_settings)
|
||||
{
|
||||
// Don't duplicate controller buttons!
|
||||
controllerButton_flip.clear();
|
||||
|
@ -4327,13 +4327,13 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
|||
|
||||
bool Game::savestats(bool sync /*= true*/)
|
||||
{
|
||||
ScreenSettings screen_settings;
|
||||
struct ScreenSettings screen_settings;
|
||||
gameScreen.GetSettings(&screen_settings);
|
||||
|
||||
return savestats(&screen_settings, sync);
|
||||
}
|
||||
|
||||
bool Game::savestats(const ScreenSettings* screen_settings, bool sync /*= true*/)
|
||||
bool Game::savestats(const struct ScreenSettings* screen_settings, bool sync /*= true*/)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc);
|
||||
|
@ -4436,7 +4436,7 @@ void Game::savestatsandsettings_menu(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSettings* screen_settings)
|
||||
void Game::serializesettings(tinyxml2::XMLElement* dataNode, const struct ScreenSettings* screen_settings)
|
||||
{
|
||||
tinyxml2::XMLDocument& doc = xml::get_document(dataNode);
|
||||
|
||||
|
@ -4563,7 +4563,7 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSetting
|
|||
xml::update_tag(dataNode, "controllerSensitivity", key.sensitivity);
|
||||
}
|
||||
|
||||
void Game::loadsettings(ScreenSettings* screen_settings)
|
||||
void Game::loadsettings(struct ScreenSettings* screen_settings)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLHandle hDoc(&doc);
|
||||
|
@ -4592,13 +4592,13 @@ void Game::loadsettings(ScreenSettings* screen_settings)
|
|||
|
||||
bool Game::savesettings(void)
|
||||
{
|
||||
ScreenSettings screen_settings;
|
||||
struct ScreenSettings screen_settings;
|
||||
gameScreen.GetSettings(&screen_settings);
|
||||
|
||||
return savesettings(&screen_settings);
|
||||
}
|
||||
|
||||
bool Game::savesettings(const ScreenSettings* screen_settings)
|
||||
bool Game::savesettings(const struct ScreenSettings* screen_settings)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/settings.vvv", doc);
|
||||
|
|
|
@ -165,20 +165,20 @@ public:
|
|||
|
||||
void unlocknum(int t);
|
||||
|
||||
void loadstats(ScreenSettings* screen_settings);
|
||||
void loadstats(struct ScreenSettings* screen_settings);
|
||||
|
||||
bool savestats(const ScreenSettings* screen_settings, bool sync = true);
|
||||
bool savestats(const struct ScreenSettings* screen_settings, bool sync = true);
|
||||
bool savestats(bool sync = true);
|
||||
|
||||
void deletestats(void);
|
||||
|
||||
void deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* screen_settings);
|
||||
void deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSettings* screen_settings);
|
||||
|
||||
void serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSettings* screen_settings);
|
||||
void serializesettings(tinyxml2::XMLElement* dataNode, const struct ScreenSettings* screen_settings);
|
||||
|
||||
void loadsettings(ScreenSettings* screen_settings);
|
||||
void loadsettings(struct ScreenSettings* screen_settings);
|
||||
|
||||
bool savesettings(const ScreenSettings* screen_settings);
|
||||
bool savesettings(const struct ScreenSettings* screen_settings);
|
||||
bool savesettings(void);
|
||||
|
||||
bool savestatsandsettings(void);
|
||||
|
|
|
@ -20,27 +20,27 @@ extern "C"
|
|||
);
|
||||
}
|
||||
|
||||
ScreenSettings::ScreenSettings(void)
|
||||
void ScreenSettings_default(struct ScreenSettings* _this)
|
||||
{
|
||||
windowWidth = 320;
|
||||
windowHeight = 240;
|
||||
fullscreen = false;
|
||||
useVsync = true; // Now that uncapped is the default...
|
||||
scalingMode = 0;
|
||||
linearFilter = false;
|
||||
badSignal = false;
|
||||
_this->windowWidth = 320;
|
||||
_this->windowHeight = 240;
|
||||
_this->fullscreen = false;
|
||||
_this->useVsync = true; // Now that uncapped is the default...
|
||||
_this->scalingMode = 0;
|
||||
_this->linearFilter = false;
|
||||
_this->badSignal = false;
|
||||
}
|
||||
|
||||
void Screen::init(const ScreenSettings& settings)
|
||||
void Screen::init(const struct ScreenSettings* settings)
|
||||
{
|
||||
m_window = NULL;
|
||||
m_renderer = NULL;
|
||||
m_screenTexture = NULL;
|
||||
m_screen = NULL;
|
||||
isWindowed = !settings.fullscreen;
|
||||
scalingMode = settings.scalingMode;
|
||||
isFiltered = settings.linearFilter;
|
||||
vsync = settings.useVsync;
|
||||
isWindowed = !settings->fullscreen;
|
||||
scalingMode = settings->scalingMode;
|
||||
isFiltered = settings->linearFilter;
|
||||
vsync = settings->useVsync;
|
||||
|
||||
SDL_SetHintWithPriority(
|
||||
SDL_HINT_RENDER_SCALE_QUALITY,
|
||||
|
@ -85,9 +85,9 @@ void Screen::init(const ScreenSettings& settings)
|
|||
240
|
||||
);
|
||||
|
||||
badSignalEffect = settings.badSignal;
|
||||
badSignalEffect = settings->badSignal;
|
||||
|
||||
ResizeScreen(settings.windowWidth, settings.windowHeight);
|
||||
ResizeScreen(settings->windowWidth, settings->windowHeight);
|
||||
}
|
||||
|
||||
void Screen::destroy(void)
|
||||
|
@ -105,7 +105,7 @@ void Screen::destroy(void)
|
|||
#undef X
|
||||
}
|
||||
|
||||
void Screen::GetSettings(ScreenSettings* settings)
|
||||
void Screen::GetSettings(struct ScreenSettings* settings)
|
||||
{
|
||||
int width, height;
|
||||
GetWindowSize(&width, &height);
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
class Screen
|
||||
{
|
||||
public:
|
||||
void init(const ScreenSettings& settings);
|
||||
void init(const struct ScreenSettings* settings);
|
||||
void destroy(void);
|
||||
|
||||
void GetSettings(ScreenSettings* settings);
|
||||
void GetSettings(struct ScreenSettings* settings);
|
||||
|
||||
void LoadIcon(void);
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
struct ScreenSettings
|
||||
{
|
||||
ScreenSettings(void);
|
||||
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
bool fullscreen;
|
||||
|
@ -14,4 +12,6 @@ struct ScreenSettings
|
|||
bool badSignal;
|
||||
};
|
||||
|
||||
void ScreenSettings_default(struct ScreenSettings* _this);
|
||||
|
||||
#endif /* SCREENSETTINGS_H */
|
||||
|
|
|
@ -571,10 +571,11 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
// Prioritize unlock.vvv first (2.2 and below),
|
||||
// but settings have been migrated to settings.vvv (2.3 and up)
|
||||
ScreenSettings screen_settings;
|
||||
struct ScreenSettings screen_settings;
|
||||
ScreenSettings_default(&screen_settings);
|
||||
game.loadstats(&screen_settings);
|
||||
game.loadsettings(&screen_settings);
|
||||
gameScreen.init(screen_settings);
|
||||
gameScreen.init(&screen_settings);
|
||||
}
|
||||
|
||||
graphics.create_buffers(gameScreen.GetFormat());
|
||||
|
|
Loading…
Reference in a new issue