The Battle for Wesnoth  1.15.2+dev
hotkey_handler_mp.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Chris Beck <render787@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
16 
18 #include "hotkey/hotkey_item.hpp"
20 #include "playmp_controller.hpp"
21 
24  , playmp_controller_(pc)
25 {}
26 
28 
31 }
32 
35 }
36 
39 }
40 
43 }
44 
46 {
47  hotkey::HOTKEY_COMMAND command = cmd.id;
48  bool res = true;
49  switch (command){
51  if (linger())
52  {
53  bool has_next_scenario = !gamestate().gamedata_.next_scenario().empty() &&
54  gamestate().gamedata_.next_scenario() != "null";
55  return playmp_controller_.is_host() || !has_next_scenario;
56  }
57  else
58  {
60  }
65  res = true;
66  break;
69  break;
72  break;
73  default:
75  }
76  return res;
77 }
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:45
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:71
const std::string & next_scenario() const
Definition: game_data.hpp:93
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const override
Check if a command can be executed.