ST_engine  0.3-ALPHA
console.hpp
1 /* This file is part of the "ST" project.
2  * You may use, distribute or modify this code under the terms
3  * of the GNU General Public License version 2.
4  * See LICENCE.txt in the root directory of the project.
5  *
6  * Author: Maxim Atanasov
7  * E-mail: maxim.atanasov@protonmail.com
8  */
9 
10 #ifndef DEVCONSOLE_DEF
11 #define DEVCONSOLE_DEF
12 
13 #include <message_bus.hpp>
14 #include "../src/main/console_log.hpp"
15 
17 class console {
18  friend class drawing_manager;
19 
20  friend class console_test;
21 
22 private:
23  void scroll(int32_t scroll_y);
24 
25  void toggle();
26 
27  void show();
28 
29  void hide();
30 
31  void write(const std::string &arg, ST::log_type type);
32 
33  void handle_messages();
34 
35  void backspaceAction();
36 
37  void leftKeyAction();
38 
39  void rightKeyAction();
40 
41  void downKeyAction();
42 
43  void upKeyAction();
44 
45  void enterKeyAction();
46 
47  void deleteKeyAction();
48 
49  uint8_t log_level = 0x00;
50 
51  SDL_Color color{};
52  SDL_Color color_text{};
53  SDL_Color color_info{};
54  SDL_Color color_error{};
55  SDL_Color color_success{};
56 
57 
58  subscriber msg_sub{};
59  bool shown = false;
60  std::vector<ST::console_log> entries;
61  std::vector<std::string> command_entries;
62  const uint8_t font_size = 40;
63  int32_t scroll_offset = 0;
64 
65  //things to do with inputting text commands
66  uint16_t cursor_position = 0;
67  uint64_t cursor_timer = 0;
68  int16_t entries_history_index = -1;
69  std::string composition;
70  std::string composition_history_temp;
71  uint16_t hold_counter = 0;
72 
73 
74  message_bus &gMessage_bus;
75 public:
76  explicit console(message_bus &gMessageBus);
77 
78  ~console();
79 
80  void set_log_level(ST::log_type arg);
81 
82  [[nodiscard]] bool is_open() const;
83 
84  void update();
85 
86  void post_init() const;
87 };
88 
89 #endif
Tests fixture for the console.
This object represents the console window.
Definition: console.hpp:17
~console()
Definition: console.cpp:248
void update()
Definition: console.cpp:346
void set_log_level(ST::log_type arg)
Definition: console.cpp:190
bool is_open() const
Definition: console.cpp:227
console(message_bus &gMessageBus)
Definition: console.cpp:19
This object is responsible for issuing drawing commands and drawing the current level.
The central messaging system of the engine. All subsystem make extensive use of it.
Definition: message_bus.hpp:29
This class handles a small queue for messages.
Definition: subscriber.hpp:20