Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
GUIConsole.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_GUI_CONSOLE_H_
34#define DVD_GUI_CONSOLE_H_
35
36constexpr size_t CEGUI_MAX_INPUT_HISTORY = 5;
37
39
40namespace CEGUI {
41 class FormattedListboxTextItem;
42 class EventArgs;
43};
44
45namespace Divide {
46
47class GUI;
48class ResourceCache;
49class PlatformContext;
50class GUIConsoleCommandParser;
53 public:
55 ~GUIConsole() override;
56
58 void setVisible(bool visible);
60 bool isVisible() const;
61
62 void update(U64 deltaTimeUS);
63
66
67 protected:
68 void RegisterHandlers();
69 bool Handle_TextSubmitted(const CEGUI::EventArgs& e);
70 bool Handle_TextInput(const CEGUI::EventArgs& e);
71
72 protected:
73 friend class GUI;
74 void createCEGUIWindow();
75 // Post the message to the ChatHistory listbox with a white colour default
76 void OutputText(const Console::OutputEntry& text) const;
77
78 protected:
81 bool _init;
84 CEGUI::String _lastMsg;
86 CEGUI::Editbox* _editBox;
89 CEGUI::Listbox* _outputWindow;
91 std::unique_ptr<GUIConsoleCommandParser> _cmdParser;
93 CEGUI::Window* _consoleWindow;
96 CEGUI::String _inputBuffer;
98 std::deque<CEGUI::String> _inputHistory;
101
102 moodycamel::ConcurrentQueue<Console::OutputEntry> _outputBuffer;
103
105};
106
107}; // namespace Divide
108
109#endif //DVD_GUI_CONSOLE_H_
constexpr size_t CEGUI_MAX_INPUT_HISTORY
Definition: GUIConsole.h:36
GUIConsole implementation, CEGUI based, as in the practical tutorial series.
Definition: GUIConsole.h:52
std::unique_ptr< GUIConsoleCommandParser > _cmdParser
pointer to the command parser instance used
Definition: GUIConsole.h:91
void RegisterHandlers()
Register our handler functions.
Definition: GUIConsole.cpp:85
bool Handle_TextSubmitted(const CEGUI::EventArgs &e)
Handle when we press Enter after typing.
Definition: GUIConsole.cpp:123
bool isVisible() const
Return true if console is visible, false if is hidden.
Definition: GUIConsole.cpp:176
CEGUI::Editbox * _editBox
pointer to the editBox to reduce typing and casting
Definition: GUIConsole.h:86
size_t _consoleCallbackIndex
Definition: GUIConsole.h:104
I16 _inputHistoryIndex
Used to cycle through history.
Definition: GUIConsole.h:100
void printText(const Console::OutputEntry &entry)
Add text to the console Window. Uses a text buffer if the console isn't ready for display yet.
Definition: GUIConsole.cpp:183
void createCEGUIWindow()
The function which will load in the CEGUI Window and register event handlers.
Definition: GUIConsole.cpp:57
CEGUI::String _lastMsg
Definition: GUIConsole.h:84
bool Handle_TextInput(const CEGUI::EventArgs &e)
A key is pressed in the console input editbox.
Definition: GUIConsole.cpp:98
moodycamel::ConcurrentQueue< Console::OutputEntry > _outputBuffer
Definition: GUIConsole.h:102
Console::EntryType _lastMsgType
Definition: GUIConsole.h:83
~GUIConsole() override
Definition: GUIConsole.cpp:40
void setVisible(bool visible)
Hide or show the console.
Definition: GUIConsole.cpp:145
CEGUI::Listbox * _outputWindow
Definition: GUIConsole.h:89
std::deque< CEGUI::String > _inputHistory
Used to manage the input history.
Definition: GUIConsole.h:98
void update(U64 deltaTimeUS)
Definition: GUIConsole.cpp:219
CEGUI::Window * _consoleWindow
This will be a pointer to the ConsoleRoot Window.
Definition: GUIConsole.h:93
CEGUI::String _inputBuffer
Definition: GUIConsole.h:96
bool _init
used to check if the console is ready
Definition: GUIConsole.h:81
void OutputText(const Console::OutputEntry &text) const
Definition: GUIConsole.cpp:199
Graphical User Interface.
Definition: GUI.h:81
PlatformContext & context() noexcept
constexpr Optick::Category::Type GUI
Definition: Profiler.h:64
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int16_t I16
Project & parent
Definition: DefaultScene.h:41
Project const SceneEntry & entry
Definition: DefaultScene.h:41
uint64_t U64
Definition: Console.h:119