AnnConsole.hpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "systemMacro.h"
11 
12 #include <iostream>
13 #include <string>
14 #include <array>
15 #include <algorithm>
16 
17 #include "AnnSubsystem.hpp"
18 #include "AnnTypes.h"
19 #include "AnnKeyCode.h"
20 
21 #include <GL/glew.h>
22 
23 #include <Overlay/OgreFont.h>
24 
25 namespace Annwvyn
26 {
29  {
30  public:
31  static constexpr auto CONSOLE_BUFFER = 17;
32  static constexpr auto MAX_CONSOLE_LOG_WIDTH = 72;
33  static constexpr auto BASE = 256;
34  static constexpr auto MARGIN = 4;
35  static constexpr auto CONSOLE_HISTORY = 64;
36 
38  AnnConsole();
39 
41  ~AnnConsole();
42 
45  void append(const std::string& string);
46 
48  void setVisible(bool visibility = true);
49 
51  void toggle();
52 
54  bool needUpdate() override;
55 
58  void update() override;
59 
61  void syncConsolePosition() const;
62 
64  void bufferClear();
65 
67  std::array<const char*, 2> forbidden = { { "var", "auto" } };
68 
70  static void WriteToTexture(const Ogre::String& str, Ogre::TexturePtr destTexture, Ogre::Image::Box destRectangle, Ogre::Font* font, const Ogre::ColourValue& color, char justify = 'l', bool wordwrap = false);
71 
73  bool setFromPointedHistory();
74 
76  void notifyNavigationKey(KeyCode::code code);
77 
78  private:
80  void runInput(std::string& input);
81 
83  void addToHistory(const std::string& input);
84 
86  bool runSpecialInput(const std::string& input);
87 
89  bool isForbdiden(const std::string& keyword);
90 
92  bool modified;
93 
96 
99 
101  std::string buffer[CONSOLE_BUFFER];
102 
104  Ogre::ManualObject* displaySurface;
105 
107  Ogre::SceneNode* consoleNode;
108 
110  Ogre::TexturePtr texture;
111 
114 
116  Ogre::TexturePtr background;
117 
119  GLuint backgroundID, textureID;
120 
122  Ogre::FontPtr font;
123 
126 
128  double lastUpdate;
129 
131  const double refreshRate;
132 
135 
138 
141  };
142 
144 }
const double refreshRate
Delay in seconds to re-refresh the console.
Definition: AnnConsole.hpp:131
file for defining macros used for symbol export regarding the way the OS does things.
Ogre::SceneNode * consoleNode
Node where the console is attached.
Definition: AnnConsole.hpp:107
AnnVect3 offset
Position of the plane using the camera as reference.
Definition: AnnConsole.hpp:113
Ogre::FontPtr font
The font object used, should be Vera Mono in true type format from the Gnome project, included in CORE resources.
Definition: AnnConsole.hpp:122
In engine - On screen floating console.
Definition: AnnConsole.hpp:28
std::array< AnnVect3, 4 > points
Array of 3D points to construct the render plane.
Definition: AnnConsole.hpp:95
Ogre::TexturePtr texture
The actual texture of the display.
Definition: AnnConsole.hpp:110
std::array< AnnVect2, 4 > textCoord
Array of UV coordinates to constructed the render plane.
Definition: AnnConsole.hpp:98
A 3D Vector.
Definition: AnnVect3.hpp:16
int historyStatus
Status of the history.
Definition: AnnConsole.hpp:137
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
Translation of OIS keys code to Annwvyn KeyCode.
int cursorPos
Position of the text cursor, indexed from the end of the string.
Definition: AnnConsole.hpp:140
Ogre::TexturePtr background
Background texture, should be a random PNG file from the CORE resources.
Definition: AnnConsole.hpp:116
bool modified
True if content of the buffer has been modified.
Definition: AnnConsole.hpp:92
double lastUpdate
Timestamp in seconds since the start of the game the last console refresh was performed.
Definition: AnnConsole.hpp:128
Parent class of all Annwvyn SubSystem.
std::array< std::string, CONSOLE_HISTORY > commandHistory
Buffer of strings containing past run commands.
Definition: AnnConsole.hpp:134
Data types definition for Annwvyn.
#define AnnDllExport
Definition: systemMacro.h:24
bool visibility
If false, the console is not visible.
Definition: AnnConsole.hpp:125
Ogre::ManualObject * displaySurface
The surface used to display (aka the render plane)
Definition: AnnConsole.hpp:104