The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hotkey_handler_mp.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 
42  playmp_controller_.start_network();
43 }
44 
46  playmp_controller_.stop_network();
47 }
48 
50 {
51  hotkey::HOTKEY_COMMAND command = cmd.id;
52  bool res = true;
53  switch (command){
55  if (linger())
56  {
57  bool has_next_scenario = !gamestate().gamedata_.next_scenario().empty() &&
58  gamestate().gamedata_.next_scenario() != "null";
59  return playmp_controller_.is_host() || !has_next_scenario;
60  }
61  else
62  {
64  }
68  res = playmp_controller_.is_networked_mp();
69  break;
72  res = is_observer();
73  break;
74  default:
76  }
77  return res;
78 }
79 
hotkey_handler(playmp_controller &, saved_game &)
Stores all information related to functions that can be bound to hotkeys.
events::menu_handler menu_handler_
bool is_observer() const
GLuint res
Definition: glew.h:9258
An extension of playsingle_controller::hotkey_handler, which has support for MP wesnoth features like...
const std::string & next_scenario() const
Definition: game_data.hpp:89
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const
Check if a command can be executed.
GLuint index
Definition: glew.h:1782
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const
Check if a command can be executed.
game_data gamedata_
Definition: game_state.hpp:48
game_state & gamestate()
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...