The Battle for Wesnoth
1.21.0-dev
Loading...
Searching...
No Matches
gui
dialogs
multiplayer
plugin_executor.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2017 - 2025
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
15
#pragma once
16
17
#include "
gui/core/timer.hpp
"
18
#include "
gui/widgets/window.hpp
"
19
#include "
scripting/plugins/context.hpp
"
20
#include "
scripting/plugins/manager.hpp
"
21
#include "
game_config.hpp
"
22
#include <memory>
23
24
namespace
gui2::dialogs
25
{
26
27
class
plugin_executor
28
{
29
std::size_t
timer_id
;
30
31
void
play_slice
() {
32
if
(
plugins_context_
) {
33
plugins_context_
->play_slice();
34
}
35
}
36
protected
:
37
std::unique_ptr<plugins_context>
plugins_context_
;
38
39
protected
:
40
plugin_executor
()
41
:
timer_id
(0u)
42
{
43
if
(
plugins_manager::get
()) {
44
timer_id
=
add_timer
(
game_config::lobby_network_timer
, std::bind(&
plugin_executor::play_slice
,
this
),
true
);
45
}
46
}
47
48
~plugin_executor
()
49
{
50
if
(
plugins_manager::get
()) {
51
remove_timer
(
timer_id
);
52
}
53
}
54
};
55
56
}
// namespace dialogs
gui2::dialogs::plugin_executor
Definition
plugin_executor.hpp:28
gui2::dialogs::plugin_executor::plugin_executor
plugin_executor()
Definition
plugin_executor.hpp:40
gui2::dialogs::plugin_executor::timer_id
std::size_t timer_id
Definition
plugin_executor.hpp:29
gui2::dialogs::plugin_executor::play_slice
void play_slice()
Definition
plugin_executor.hpp:31
gui2::dialogs::plugin_executor::~plugin_executor
~plugin_executor()
Definition
plugin_executor.hpp:48
gui2::dialogs::plugin_executor::plugins_context_
std::unique_ptr< plugins_context > plugins_context_
Definition
plugin_executor.hpp:37
plugins_manager::get
static plugins_manager * get()
Definition
manager.cpp:58
context.hpp
game_config.hpp
window.hpp
This file contains the window object, this object is a top level container which has the event manage...
game_config::lobby_network_timer
std::chrono::milliseconds lobby_network_timer
Definition
game_config.cpp:71
gui2::dialogs
Definition
achievements_dialog.cpp:35
gui2::add_timer
std::size_t add_timer(const std::chrono::milliseconds &interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
Definition
timer.cpp:123
gui2::remove_timer
bool remove_timer(const std::size_t id)
Removes a timer.
Definition
timer.cpp:164
manager.hpp
timer.hpp
Contains the gui2 timer routines.
Generated by
1.9.8