Skip to content

Commit

Permalink
Show how to play when going on play for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkwouter committed Nov 28, 2024
1 parent ddb83a8 commit 0ceedc4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/OptionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ void OptionManager::setFullscreen(bool value) {
write();
}

bool OptionManager::getHowToPlaySeen() {
return this->options.get("how_to_play_seen", false).asBool();
}

void OptionManager::setHowToPlaySeen(bool value) {
this->options["how_to_play_seen"] = value;
write();
}

int OptionManager::getScreenWidth() {
int result = this->options.get("screen_width", 0).asInt();
if (result == 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/OptionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class OptionManager {
bool getFullscreen();
int getScreenWidth();
int getScreenHeight();
bool getHowToPlaySeen();

int getShellSize();

Expand All @@ -56,6 +57,7 @@ class OptionManager {
void setRelaxedModeShells(std::vector<std::vector<ShellType>> value);
void setFullscreen(bool value);
void setScreenResolution(int width, int height);
void setHowToPlaySeen(bool value);

void resetChallengeMode();
void resetStandardMode();
Expand Down
4 changes: 4 additions & 0 deletions src/states/HowToScoreState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ void HowToScoreState::handleEvents(std::vector<Event> events) {
break;
case Event::MENU:
case Event::CONFIRM:
if (!this->options->getHowToPlaySeen()) {
this->next_state = State::PLAY;
this->options->setHowToPlaySeen(true);
}
this->done = true;
break;
case Event::WINDOW_RESIZE:
Expand Down
6 changes: 5 additions & 1 deletion src/states/MenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ void MenuState::handleEvents(std::vector<Event> events) {
}
break;
case Event::CONFIRM:
if (this->getNextState() == State::PLAY && !this->options->getHowToPlaySeen()) {
selection = (int) State::HOWTOCONTROLS - 1;
} else if (this->getNextState() == State::HOWTOCONTROLS) {
this->options->setHowToPlaySeen(true);
}
this->done = true;
break;
case Event::MENU:
case Event::QUIT:
this->selection = (int) State::EXIT - 1;
this->done = true;
Expand Down

0 comments on commit 0ceedc4

Please sign in to comment.