Antkeeper  0.0.1
window-controls.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code 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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "game/controls.hpp"
21 #include "game/graphics.hpp"
22 
24 {
25  // Toggle fullscreen
26  ctx.event_subscriptions.emplace_back
27  (
29  (
30  [&ctx](const auto& event)
31  {
32  ctx.window->set_fullscreen(!ctx.window->is_fullscreen());
33  }
34  )
35  );
36 
37  // Take screenshot
38  ctx.event_subscriptions.emplace_back
39  (
41  (
42  [&ctx](const auto& event)
43  {
44  ::graphics::save_screenshot(ctx);
45  }
46  )
47  );
48 }
49 
51 {
53 }
54 
56 {
60 }
Definition: game.hpp:121
input::action_map window_action_map
Definition: game.hpp:200
std::vector< std::shared_ptr<::event::subscription > > event_subscriptions
Definition: game.hpp:265
input::action fullscreen_action
Definition: game.hpp:201
input::action screenshot_action
Definition: game.hpp:202
void disable()
Disables the mapping of input events to actions.
Definition: action-map.cpp:41
void enable()
Enables the mapping of input events to actions.
Definition: action-map.cpp:28
void reset() noexcept
Resets the activation state of the action without publishing any events.
Definition: action.cpp:75
::event::channel< action_activated_event > & get_activated_channel() noexcept
Returns the channel through which action activated events are published.
Definition: action.hpp:91
Publish-subscribe messaging.
Definition: channel.hpp:32
void enable_window_controls(::game &ctx)
void setup_window_controls(::game &ctx)
void disable_window_controls(::game &ctx)