V-Gears 0
Free Final Fantasy VII engine.
Console.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreColourValue.h>
19#include <OgreLog.h>
20#include <OgreSingleton.h>
21#include <OgreStringVector.h>
22#include <OIS/OIS.h>
23#include <list>
24#include <vector>
25#include "Event.h"
26
30class Console : public Ogre::Singleton<Console>, public Ogre::LogListener{
31
32 public:
33
37 Console();
38
42 ~Console();
43
49 void Input(const VGears::Event& event);
50
54 void Update();
55
59 void UpdateDraw();
60
64 void UpdateNotification();
65
69 void OnResize();
70
74 void SetToVisible();
75
79 void SetToHide();
80
86 bool IsVisible() const;
87
94 void AddTextToOutput(
95 const Ogre::String& text, const Ogre::ColourValue& colour = Ogre::ColourValue::White
96 );
97
103 void ExecuteCommand(const Ogre::String& command);
104
108 void ExecuteScript();
109
113 void CompleteInput();
114
118 void ResetAutoCompletion();
119
123 void AddInputToHistory();
124
129
140 virtual void messageLogged(
141 const Ogre::String& message, Ogre::LogMessageLevel lml,
142 bool maskDebug, const Ogre::String &logName, bool& skipThisMessage
143 );
144
145 private:
146
150 void LoadHistory();
151
155 void SaveHistory();
156
160 void AddToHistory(const Ogre::String& history);
161
167 char TranslateNumpad(const VGears::Event& event);
168
173
178
182 unsigned int line_width_;
183
188
193
198
202 float height_;
203
208
213
217 Ogre::ColourValue colour;
218
222 float time;
223 };
224
228 std::list<OutputLine> output_line_;
229
233 unsigned int max_output_line_;
234
238 unsigned int display_line_;
239
244
248 unsigned int cursor_position_;
249
254
258 std::list<Ogre::String> history_;
259
264
268 unsigned int max_history_size_;
269
273 Ogre::StringVector auto_completition_;
274
279};
280
The game console.
Definition: Console.h:30
void ExecuteCommand(const Ogre::String &command)
Executes a command in the console.
Definition: Console.cpp:446
void AddTextToOutput(const Ogre::String &text, const Ogre::ColourValue &colour=Ogre::ColourValue::White)
Writes text to the console.
Definition: Console.cpp:403
char TranslateNumpad(const VGears::Event &event)
Translates numpad key events to regular number events.
Definition: Console.cpp:263
std::list< OutputLine > output_line_
Listof lines in the console.
Definition: Console.h:228
void SetInputLineFromHistory()
Sets a line from the history as the current input.
Definition: Console.cpp:591
void SetToVisible()
Shows the console.
Definition: Console.cpp:394
~Console()
Destructor.
Definition: Console.cpp:71
unsigned int max_output_line_
Max number of lines in output list.
Definition: Console.h:233
int history_line_cycle_index_
Currently selected line of the input history.
Definition: Console.h:263
int console_height_
The console height.
Definition: Console.h:177
unsigned int max_history_size_
Maximum number of inputs to save to the history.
Definition: Console.h:268
void AddInputToHistory()
Adds a console input to the console history.
Definition: Console.cpp:589
void Update()
Updates the console.
Definition: Console.cpp:284
float height_
Line height of the console.
Definition: Console.h:202
Ogre::StringVector auto_completition_
List of strings available for autocompletion.
Definition: Console.h:273
void ExecuteScript()
Definition: Console.cpp:475
void Input(const VGears::Event &event)
Processes an input event.
Definition: Console.cpp:100
unsigned int auto_completition_line_
Index of the currently displayed autocompletion option.
Definition: Console.h:278
unsigned int display_line_
The bottom line of the console, the active one.
Definition: Console.h:238
void SetToHide()
Hides the console.
Definition: Console.cpp:399
void LoadHistory()
Loads the console input history.
Definition: Console.cpp:77
unsigned int cursor_position_
Position of the cursor in the active line.
Definition: Console.h:248
unsigned int line_width_
The width of each line in the console.
Definition: Console.h:182
virtual void messageLogged(const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skipThisMessage)
Logs a message to the console.
Definition: Console.cpp:603
void UpdateNotification()
Notifies the console to update itself.
Definition: Console.cpp:359
void OnResize()
Processes a console resizing event.
Definition: Console.cpp:380
void CompleteInput()
Autocompletes the current input.
Definition: Console.cpp:477
bool IsVisible() const
Checks if the console is currently visible.
Definition: Console.cpp:401
Console()
Constructor.
Definition: Console.cpp:39
int letter_width_
The width of each letter in the console.
Definition: Console.h:187
void ResetAutoCompletion()
Clears the autocompletion list.
Definition: Console.cpp:584
bool visible_
Indicates if the console is currently visible.
Definition: Console.h:197
bool to_visible_
Indicates if the console is being made visible.
Definition: Console.h:192
float cursor_blink_time_
Cursor blink frequency, in seconds.
Definition: Console.h:253
void UpdateDraw()
Redraws the console.
Definition: Console.cpp:302
int console_width_
The console width.
Definition: Console.h:172
std::list< Ogre::String > history_
The console input history.
Definition: Console.h:258
void SaveHistory()
Saves the console input history.
Definition: Console.cpp:85
void AddToHistory(const Ogre::String &history)
Adds a string to the console input history.
Definition: Console.cpp:94
Ogre::String input_line_
Currently typed text.
Definition: Console.h:243
Ogre::String String
Definition: TypeDefine.h:37
An ouptut line of the console.
Definition: Console.h:207
float time
Time at which it was printed.
Definition: Console.h:222
Ogre::ColourValue colour
Color for the text in the line.
Definition: Console.h:217
Ogre::String text
Text in the line.
Definition: Console.h:212
An input event.
Definition: Event.h:84