From 85d98b2620ca6eb8c77ed27d3ce417de849fdc29 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Thu, 28 Nov 2024 11:48:47 +0100 Subject: [PATCH] Remove refresh rate from options --- src/OptionManager.cpp | 7 +------ src/OptionManager.hpp | 3 +-- src/Window.cpp | 8 ++++---- src/states/OptionsState.cpp | 4 ++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/OptionManager.cpp b/src/OptionManager.cpp index 4d940b6..5df7af4 100644 --- a/src/OptionManager.cpp +++ b/src/OptionManager.cpp @@ -241,11 +241,7 @@ int OptionManager::getScreenHeight() { return result; } -int OptionManager::getScreenRefreshRate() { - return this->options.get("screen_refresh_rate", 0).asInt(); -} - -void OptionManager::setScreenResolution(int width, int height, int refresh_rate) { +void OptionManager::setScreenResolution(int width, int height) { int new_shell_size = DEFAULT_SHELL_SIZE; while (width < (new_shell_size * DEFAULT_BOARD_WIDTH) || height < (new_shell_size * (DEFAULT_BOARD_HEIGHT +1))) { new_shell_size = new_shell_size/2; @@ -262,7 +258,6 @@ void OptionManager::setScreenResolution(int width, int height, int refresh_rate) this->options["screen_width"] = width; this->options["screen_height"] = height; - this->options["screen_refresh_rate"] = refresh_rate; write(); } diff --git a/src/OptionManager.hpp b/src/OptionManager.hpp index 4ffae96..b6f4660 100644 --- a/src/OptionManager.hpp +++ b/src/OptionManager.hpp @@ -40,7 +40,6 @@ class OptionManager { bool getFullscreen(); int getScreenWidth(); int getScreenHeight(); - int getScreenRefreshRate(); int getShellSize(); bool getShellSizeChanged(); @@ -56,7 +55,7 @@ class OptionManager { void setRelaxedModeSeed(unsigned int value); void setRelaxedModeShells(std::vector> value); void setFullscreen(bool value); - void setScreenResolution(int width, int height, int refresh_rate); + void setScreenResolution(int width, int height); void setChallengeModeSeed(int seed); void resetChallengeMode(); diff --git a/src/Window.cpp b/src/Window.cpp index c074268..6860b9f 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -23,9 +23,9 @@ Window::Window(const std::string &title, OptionManager * options) : options(opti } // Set default screen resolution and refresh rate if they haven't been set yet - if (this->options->getScreenRefreshRate() == 0) { + if (this->options->getScreenWidth() == 0 || this->options->getScreenHeight() == 0 ) { SDL_DisplayMode mode = getStandardDisplayMode(); - this->options->setScreenResolution(mode.w, mode.h, mode.refresh_rate); + this->options->setScreenResolution(mode.w, mode.h); } Uint32 window_flags = SDL_WINDOW_RESIZABLE; @@ -40,7 +40,7 @@ Window::Window(const std::string &title, OptionManager * options) : options(opti // Set the refresh rate if (this->options->getFullscreen()) { for(SDL_DisplayMode mode : getDisplayModes()) { - if (mode.w == options->getScreenWidth() && mode.h == options->getScreenHeight() && mode.refresh_rate == options->getScreenRefreshRate()) { + if (mode.w == options->getScreenWidth() && mode.h == options->getScreenHeight()) { SDL_SetWindowDisplayMode(window, &mode); break; } @@ -82,7 +82,7 @@ void Window::updateSize() { if (height < MIN_SCREEN_HEIGHT) { height = MIN_SCREEN_HEIGHT; } - this->options->setScreenResolution(width, height, this->options->getScreenRefreshRate()); + this->options->setScreenResolution(width, height); } Window::~Window() { diff --git a/src/states/OptionsState.cpp b/src/states/OptionsState.cpp index 29ed01e..e4be482 100644 --- a/src/states/OptionsState.cpp +++ b/src/states/OptionsState.cpp @@ -288,13 +288,13 @@ void OptionsState::applyFullscreen() { this->options->setFullscreen(this->fullscreen); if (this->fullscreen) { - this->options->setScreenResolution(standard_mode.w, standard_mode.h, standard_mode.refresh_rate); + this->options->setScreenResolution(standard_mode.w, standard_mode.h); SDL_SetWindowSize(window, this->options->getScreenWidth(), this->options->getScreenHeight()); SDL_SetWindowDisplayMode(this->window, &standard_mode); SDL_SetWindowFullscreen(this->window, SDL_WINDOW_FULLSCREEN); } else { SDL_SetWindowFullscreen(this->window, 0); - this->options->setScreenResolution(standard_mode.w/2, standard_mode.h/2, standard_mode.refresh_rate); + this->options->setScreenResolution(standard_mode.w/2, standard_mode.h/2); SDL_RestoreWindow(this->window); SDL_SetWindowSize(this->window, this->options->getScreenWidth(), this->options->getScreenHeight()); SDL_SetWindowPosition(this->window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);