This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

source: ps/trunk/source/gui/ObjectTypes/CHotkeyPicker.h

Last change on this file was 27965, checked in by Vladislav Belov, 13 months ago

Revert non-ASCII characters from source and configuration files introduced in rP27786.

Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185

  • Property svn:eol-style set to native
File size: 2.3 KB
RevLine 
[25392]1/* Copyright (C) 2021 Wildfire Games.
[27965]2 * This file is part of 0 A.D.
[24215]3 *
[27965]4 * 0 A.D. is free software: you can redistribute it and/or modify
[24215]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 *
[27965]9 * 0 A.D. is distributed in the hope that it will be useful,
[24215]10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
[27965]15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
[24215]16 */
17
18#ifndef INCLUDED_CHOTKEYPICKER
19#define INCLUDED_CHOTKEYPICKER
20
[24222]21#include "gui/CGUI.h"
[24352]22#include "gui/ObjectBases/IGUIObject.h"
[24215]23#include "lib/external_libraries/libsdl.h"
24#include "ps/CStr.h"
25
[24222]26#include <vector>
27
[24215]28/**
29 * When in focus, returns all currently pressed keys.
30 * After a set time without changes, it will trigger a "combination" event.
31 *
32 * Used to create new hotkey combinations in-game. Mostly custom.
33 * This object does not draw anything.
34 */
35class CHotkeyPicker : public IGUIObject
36{
37 GUI_OBJECT(CHotkeyPicker)
38
39public:
40 CHotkeyPicker(CGUI& pGUI);
41 virtual ~CHotkeyPicker();
42
43 // Do nothing.
[25588]44 virtual void Draw(CCanvas2D& UNUSED(canvas)) {};
[24215]45
46 // Checks if the timer has passed and we need to fire a "combination" event.
47 virtual void Tick();
48
49 // React to blur/focus.
50 virtual void HandleMessage(SGUIMessage& Message);
51
52 // Pre-empt events: this is our sole purpose.
53 virtual InReaction PreemptEvent(const SDL_Event_* ev);
[25428]54
55 struct Key
56 {
57 // The scancode is used for fast comparisons.
58 SDL_Scancode code;
59 // This is the name ultimately stored in the config file.
60 CStr scancodeName;
61 };
[24215]62protected:
63 // Fire an event with m_KeysPressed as argument.
64 void FireEvent(const CStr& event);
65
66 // Time without changes until a "combination" event is sent.
[25392]67 CGUISimpleSetting<float> m_TimeToCombination;
[24215]68 // Time of the last registered key change.
69 double m_LastKeyChange;
70
71 // Keep track of which keys we are pressing, and precompute their name for JS code.
72 std::vector<Key> m_KeysPressed;
73
74 static const CStr EventNameCombination;
75 static const CStr EventNameKeyChange;
76};
77
78#endif // INCLUDED_CHOTKEYPICKER
Note: See TracBrowser for help on using the repository browser.