The Battle for Wesnoth  1.15.2+dev
plugin_executor.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "gui/core/timer.hpp"
17 #include "gui/widgets/window.hpp"
20 #include "game_config.hpp"
21 #include <memory>
22 
23 namespace gui2
24 {
25 namespace dialogs
26 {
27 
29 {
30  std::size_t timer_id;
31 
32  void play_slice() {
33  if(plugins_context_) {
34  plugins_context_->play_slice();
35  }
36  }
37 protected:
38  std::unique_ptr<plugins_context> plugins_context_;
39 
40 protected:
42  : timer_id(0u)
43  {
44  if(plugins_manager::get()) {
45  timer_id = add_timer(game_config::lobby_network_timer, std::bind(&plugin_executor::play_slice, this), true);
46  }
47  }
48 
50  {
51  if(plugins_manager::get()) {
52  remove_timer(timer_id);
53  }
54  }
55 };
56 
57 } // namespace dialogs
58 } // namespace gui2
This file contains the window object, this object is a top level container which has the event manage...
Generic file dialog.
Definition: field-fwd.hpp:22
std::unique_ptr< plugins_context > plugins_context_
unsigned lobby_network_timer
Definition: game_config.cpp:87
Various uncategorised dialogs.
Contains the gui2 timer routines.
std::size_t add_timer(const uint32_t interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
Definition: timer.cpp:126
static plugins_manager * get()
Definition: manager.cpp:58
bool remove_timer(const std::size_t id)
Removes a timer.
Definition: timer.cpp:167