sources/interface.h

changeset 72
1b9c53e0c846
parent 71
4f7c2c944637
child 73
07dda51a7a8e
equal deleted inserted replaced
71:4f7c2c944637 72:1b9c53e0c846
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #pragma once 31 #pragma once
32 #include "main.h" 32 #include "main.h"
33 #include "network/ipaddress.h"
34 #include "coloredline.h"
35 #include "network/rconsession.h"
33 36
34 namespace Interface 37 class Interface
35 { 38 {
36 FUNCTION initialize() -> void; 39 public:
37 FUNCTION handle_input() -> void; 40 enum InputState
38 FUNCTION render() -> void; 41 {
39 FUNCTION render_full() -> void; 42 INPUTSTATE_NORMAL,
40 FUNCTION set_title (const String& message) -> void; 43 INPUTSTATE_ADDRESS,
41 FUNCTION update_statusbar() -> void; 44 INPUTSTATE_PASSWORD,
42 FUNCTION connect (String address, String password) -> void; 45 INPUTSTATE_CONFIRM_DISCONNECTION,
43 FUNCTION set_player_names (const StringList& names) -> void; 46 };
44 FUNCTION need_refresh() -> void; 47
45 FUNCTION tab_complete (const String& part, String complete) -> void; 48 Interface();
49 void handle_input();
50 void render();
51 void render_full();
52 void set_title (const String& message);
53 void update_statusbar();
54 void connect (String address, String password);
55 void set_player_names (const StringList& names);
56 void need_refresh();
57 void tab_complete (const String& part, String complete);
58 RCONSession* get_session() { return &Session; }
59
60 template<typename... argtypes>
61 void print (const String& fmtstr, const argtypes&... args)
62 {
63 print_to_console (format (fmtstr, args...));
64 }
65
66 template<typename... argtypes>
67 void print_warning (const String& fmtstr, const argtypes&... args)
68 {
69 print_to_console (TEXTCOLOR_BrightYellow "-!- " + format (fmtstr, args...) + TEXTCOLOR_Reset);
70 }
71
72 template<typename... argtypes>
73 void print_error (const String& fmtstr, const argtypes&... args)
74 {
75 print_to_console (TEXTCOLOR_BrightRed "!!! " + format (fmtstr, args...) + TEXTCOLOR_Reset);
76 }
77
78 private:
79 StringList InputHistory;
80 int InputCursor = 0;
81 int CursorPosition = 0;
82 int InputPanning = 0;
83 bool NeedRefresh = false;
84 bool NeedStatusBarRender = false;
85 bool NeedInputRender = false;
86 bool NeedOutputRender = false;
87 bool NeedNicklistRender = false;
88 struct { char ch; int x; } CursorCharacter;
89 Vector<ColoredLine> OutputLines;
90 int OutputScroll = 0;
91 String Title;
92 InputState CurrentInputState = INPUTSTATE_NORMAL;
93 Function<void (void)> DisconnectConfirmFunction = nullptr;
94 IPAddress CurrentAddress;
95 String StatusBarText;
96 StringList PlayerNames;
97 String PasteBuffer;
98 RCONSession Session;
99
100 void render_titlebar();
101 void safe_disconnect (Function<void()> afterwards);
102 int render_colorline (int y, int x0, int width, const ColoredLine& line, bool allowWrap);
103 int nicklist_width();
104 void render_output();
105 void render_nicklist();
106 void render_input();
107 void render_statusbar();
108 void position_cursor();
109 int color_pair (Color fg, Color bg);
110 const String& current_input();
111 void detach_input();
112 String& mutable_current_input();
113 void move_input_cursor (int delta);
114 String prompt_string();
115 void set_input_state (InputState newstate);
116 void print_to_console (String a);
117 void yank (int a, int b);
118 int find_previous_word();
119 int find_next_word();
46 }; 120 };

mercurial