The Battle for Wesnoth  1.17.0-dev
hotkey_handler_mp.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2021
3  by Chris Beck <render787@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
17 
19 #include "hotkey/hotkey_item.hpp"
21 #include "playmp_controller.hpp"
22 
25  , playmp_controller_(pc)
26 {}
27 
29 
32 }
33 
36 }
37 
40 }
41 
44 }
45 
47 {
48  hotkey::HOTKEY_COMMAND command = cmd.id;
49  bool res = true;
50  switch (command){
52  if (linger())
53  {
54  bool has_next_scenario = !gamestate().gamedata_.next_scenario().empty() &&
55  gamestate().gamedata_.next_scenario() != "null";
56  return playmp_controller_.is_host() || !has_next_scenario;
57  }
58  else
59  {
61  }
66  res = true;
67  break;
70  break;
73  break;
74  default:
76  }
77  return res;
78 }
hotkey_handler(playmp_controller &, saved_game &)
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const override
Check if a command can be executed.
HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
virtual void start_network() override
Stores all information related to functions that can be bound to hotkeys.
virtual void stop_network() override
events::menu_handler & menu_handler_
An extension of playsingle_controller::hotkey_handler, which has support for MP wesnoth features like...
game_data gamedata_
Definition: game_state.hpp:46
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72
const std::string & next_scenario() const
Definition: game_data.hpp:96
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const override
Check if a command can be executed.