about summary refs log tree commit diff stats
path: root/data/maps/the_stormy/metadata.txtpb
blob: 42b181432d4de6424eeb4800f9a4f3b053f65893 (plain) (blame)
1
display_name: "The Stormy"
ight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include "menu_system.h"
#include "game.h"
#include "script_system.h"

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

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

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

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

          if (cursorBob_ <= 0) {
            cursorBobDown_ = true;
          }
        }
      }
    } else if (menuChangeAnimation_.isComplete()) {
      isMenuChanging_ = false;

      if (menuChangeAnimation_.getProgress() == 0.0) {
        menus_.pop_back();
      }
    }
  }
}

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

  game_.pauseGameplay();

  std::vector<MenuBuilder> builders = {
    MenuBuilder().Command("Settings")
                 .ActivationFunction([this] (Game&) {
                   openSubmenu(Menu({
                     MenuBuilder().Slider("Music Volume: ")
                                  .InitialValue(10)
                                  .MaxValue(10),
                     MenuBuilder().Slider("Sound Volume: ")
                                  .InitialValue(10)
                                  .MaxValue(10),
                     MenuBuilder().Command("Back")
                                  .ActivationFunction([this] (Game& game) {
                                    closePauseMenu();
                                  })
                                  .SkipSoundEffect()
                   }));
                 }),
    MenuBuilder().Command("Resume Game")
                 .ActivationFunction([] (Game& game) {
                   game.getSystem<MenuSystem>().closePauseMenu();
                 })
                 .SkipSoundEffect(),
    MenuBuilder().Command("Quit")
                 .ActivationFunction([] (Game& game) {
                   game.quit();
                 })
  };

  if (game_.getMap().hasExitArea()) {
    builders.push_back(MenuBuilder().Command("Exit Area")
                                    .ActivationFunction([] (Game& game) {
                                      game.getSystem<MenuSystem>().closePauseMenu(false);
                                      game.getSystem<ScriptSystem>().runScript(game.getMap().getName(), "exit_area");
                                    }));
  }

  menus_.emplace_back(builders);

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

void MenuSystem::closePauseMenu(bool playSfx) {
  if (menus_.size() > 1) {
    isMenuChanging_ = true;
    menuChangeAnimation_.start(250, 0.0);

    if (playSfx) {
      game_.getMixer().playSound("../res/sfx/menu_deselect.wav");
    }
  } else {
    pauseAnimation_.start(125, 0.0);
    openState_ = OpenState::Animating;

    if (playSfx) {
      game_.getMixer().playSound("../res/sfx/menu_close.wav");
    }
  }
}

void MenuSystem::pressedUp() {
  menus_.back().moveCursorUp();

  cursorBob_ = 0;
  cursorBobDown_ = true;

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

void MenuSystem::pressedDown() {
  menus_.back().moveCursorDown();

  cursorBob_ = 0;
  cursorBobDown_ = true;

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

void MenuSystem::pressedLeft() {
  Menu& curMenu = menus_.back();
  MenuItem& menuItem = curMenu.getItems()[curMenu.getCursorPosition()];

  if (menuItem.type == MenuType::Slider && menuItem.value > 0) {
    menuItem.value--;

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

void MenuSystem::pressedRight() {
  Menu& curMenu = menus_.back();
  MenuItem& menuItem = curMenu.getItems()[curMenu.getCursorPosition()];

  if (menuItem.type == MenuType::Slider && menuItem.value < menuItem.maxValue) {
    menuItem.value++;

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

void MenuSystem::activateOption() {
  Menu& curMenu = menus_.back();
  const MenuItem& menuItem = curMenu.getItems()[curMenu.getCursorPosition()];

  if (menuItem.type == MenuType::Command) {
    if (menuItem.playSfx) {
      game_.getMixer().playSound("../res/sfx/menu_activate.wav");
    }

    if (menuItem.activationFunction) {
      menuItem.activationFunction(game_);
    }
  }
}

void MenuSystem::openSubmenu(Menu submenu) {
  menus_.push_back(std::move(submenu));
  isMenuChanging_ = true;
  menuChangeAnimation_.start(250, 1.0);
}