Exemplo n.º 1
0
/**
 * \brief Constructor.
 * \param game the game
 */
GameCommands::GameCommands(Game& game):
  game(game),
  customizing(false),
  command_to_customize(NONE),
  customize_callback_ref(LUA_REFNIL) {

  // Load the commands from the savegame.
  for (int i = 0; i < NB_COMMANDS; i++) {

    Command command = Command(i);

    // Keyboard.
    InputEvent::KeyboardKey keyboard_key = get_saved_keyboard_binding(command);
    keyboard_mapping[keyboard_key] = command;

    // Joypad.
    const std::string& joypad_string = get_saved_joypad_binding(command);
    joypad_mapping[joypad_string] = command;
  }
}
Exemplo n.º 2
0
/**
 * \brief Constructor.
 * \param game the game
 */
GameCommands::GameCommands(Game& game):
  game(game),
  customizing(false),
  command_to_customize(GameCommand::NONE),
  customize_callback_ref() {

  // Load the commands from the savegame.
  for (const auto& kvp : command_names) {

    GameCommand command = kvp.first;
    if (command == GameCommand::NONE) {
      continue;
    }

    // Keyboard.
    InputEvent::KeyboardKey keyboard_key = get_saved_keyboard_binding(command);
    keyboard_mapping[keyboard_key] = command;

    // Joypad.
    const std::string& joypad_string = get_saved_joypad_binding(command);
    joypad_mapping[joypad_string] = command;
  }
}