Skip to content

Commit

Permalink
Remove refresh rate from options
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkwouter committed Nov 28, 2024
1 parent b63a8b7 commit 85d98b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
7 changes: 1 addition & 6 deletions src/OptionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions src/OptionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class OptionManager {
bool getFullscreen();
int getScreenWidth();
int getScreenHeight();
int getScreenRefreshRate();

int getShellSize();
bool getShellSizeChanged();
Expand All @@ -56,7 +55,7 @@ class OptionManager {
void setRelaxedModeSeed(unsigned int value);
void setRelaxedModeShells(std::vector<std::vector<ShellType>> 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();
Expand Down
8 changes: 4 additions & 4 deletions src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/states/OptionsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 85d98b2

Please sign in to comment.