The Battle for Wesnoth  1.19.7+dev
hotkey_handler_mp.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
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 
20 #include "playmp_controller.hpp"
21 
24  , playmp_controller_(pc)
25 {}
26 
28 
31 }
32 
35 }
36 
38  playmp_controller_.start_network();
39 }
40 
42  playmp_controller_.stop_network();
43 }
44 
46 {
48  bool res = true;
49  switch (command){
51  if (linger())
52  {
53  return playmp_controller_.is_host() || !gamestate().has_next_scenario();
54  }
55  else
56  {
58  }
63  res = true;
64  break;
66  res = is_observer() && playmp_controller_.network_processing_stopped_;
67  break;
69  res = is_observer() && !playmp_controller_.network_processing_stopped_;
70  break;
71  default:
73  }
74  return res;
75 }
bool has_next_scenario() const
Checks whether this is not the last scenario (usually of a campaign)
Definition: game_state.cpp:393
events::menu_handler menu_handler_
bool is_observer() const
game_state & gamestate()
hotkey_handler(playmp_controller &, saved_game &)
virtual void start_network() override
virtual bool can_execute_command(const hotkey::ui_command &command) const override
Check if a command can be executed.
virtual void stop_network() override
virtual bool can_execute_command(const hotkey::ui_command &cmd) const override
Check if a command can be executed.
An extension of playsingle_controller::hotkey_handler, which has support for MP wesnoth features like...
@ HOTKEY_SPEAK_ALLY
@ HOTKEY_SPEAK_ALL
@ HOTKEY_STOP_NETWORK
@ HOTKEY_START_NETWORK
Used as the main paramneter for can_execute_command/do_execute_command These functions are used to ex...
hotkey::HOTKEY_COMMAND hotkey_command
The hotkey::HOTKEY_COMMAND associated with this action, HOTKEY_NULL for actions that don't allow hotk...