about summary refs log tree commit diff stats
path: root/data/maps/the_bearer/rooms/Blue Vegetable (View).txtpb
blob: cf1ffd3cffef9c8f7687f6c464714882d888f89a (plain) (blame)
1
2
3
4
5
6
7
8
name: "Blue Vegetable (View)"
panels {
  name: "THORN"
  path: "Panels/Blue/panel_1"
  clue: "thorn"
  answer: "corn"
  symbols: ZERO
}
.Integer.Long */
#include "menu_system.h"
#include "game.h"

void MenuSystem::tick(double dt) {
  pauseAnimation_.tick(dt);

  if (openState_ == OpenState::Animating && pauseAnimation_.isComplete()) {
    if (pauseAnimation_.getProgress() == 0.0) {
      openState_ = OpenState::Closed;

      game_.unpauseGameplay();
    } else if (pauseAnimation_.getProgress() == 1.0) {
      openState_ = OpenState::Open;
    }
  } else if (openState_ == OpenState::Open) {
    cursorBobTimer_.accumulate(dt);
    while (cursorBobTimer_.step()) {
      if (cursorBobDown_) {
        cursorBob_++;

        if (cursorBob_ >= 4) {
          cursorBobDown_ = false;
        }
      } else {
        cursorBob_--;

        if (cursorBob_ <= 0) {
          cursorBobDown_ = true;
        }
      }
    }
  }
}

void MenuSystem::openPauseMenu() {
  pauseAnimation_.start(125, 1.0);
  openState_ = OpenState::Animating;

  game_.pauseGameplay();

  menu_ = CreateMenu({
    MenuBuilder().Command("Settings"),
    MenuBuilder().Command("Return to Main Menu"),
    MenuBuilder().Command("Resume Game")
  });
}

void MenuSystem::closePauseMenu() {
  pauseAnimation_.start(125, 0.0);
  openState_ = OpenState::Animating;
}

void MenuSystem::pressedUp() {
  if (cursor_ > 0) {
    cursor_--;
    cursorBob_ = 0;
    cursorBobDown_ = true;

    game_.getMixer().playSound("../res/sfx/vertical_menu.wav");
  }
}

void MenuSystem::pressedDown() {
  if (cursor_ < menu_.size() - 1) {
    cursor_++;
    cursorBob_ = 0;
    cursorBobDown_ = true;

    game_.getMixer().playSound("../res/sfx/vertical_menu.wav");
  }
}