summaryrefslogtreecommitdiffstats
path: root/src/client/clui/clui.hpp
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2020-12-10 16:02:46 +0000
committerJoursoir <chat@joursoir.net>2020-12-10 16:02:46 +0000
commit05750c44046f320109055aa5954ef0bbd977705f (patch)
treea39094e5eead788c48c9b4df0db379f4f45be26c /src/client/clui/clui.hpp
parent4131de177e36b19b20b8bbdb7bd43b18b6e22690 (diff)
downloadwant-chat-05750c44046f320109055aa5954ef0bbd977705f.tar.gz
want-chat-05750c44046f320109055aa5954ef0bbd977705f.tar.bz2
want-chat-05750c44046f320109055aa5954ef0bbd977705f.zip
refactor clui: delete class ChatRoom, create own class for chat, players, tips (new), input
Diffstat (limited to 'src/client/clui/clui.hpp')
-rw-r--r--src/client/clui/clui.hpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/client/clui/clui.hpp b/src/client/clui/clui.hpp
index e337aa9..87445db 100644
--- a/src/client/clui/clui.hpp
+++ b/src/client/clui/clui.hpp
@@ -3,59 +3,52 @@
#ifndef WC_CLUI_H
#define WC_CLUI_H
-#include <ncurses.h>
+#include "WindowInterface.hpp"
#include "../../const_vars.hpp"
-class Interface_wc {
- WINDOW *w;
- int ny, nx;
- int beg_y, beg_x;
- int ch_line;
-public:
- Interface_wc(int num_y, int num_x, int by, int bx, char ch);
-
- WINDOW *GetWindow() { return w; }
- void SetCursor(int y, int x) { wmove(w, y, x); }
- void Clear(bool full);
- void Update() { wrefresh(w); }
- void Delete() { delwin(w); }
-
- void Hide();
-};
-
-class ChatRoom {
- Interface_wc *chat;
- Interface_wc *players;
- Interface_wc *input;
- int i_nx, i_ny;
-
+class WindowChat : public WindowInterface {
struct message {
- char msg[max_msg_len];
+ char text[max_msg_len];
int num_lines; // number of lines
int type;
message *prev;
};
message *first;
public:
- ChatRoom();
- ~ChatRoom();
+ WindowChat(int num_y, int num_x, int by, int bx, char ch)
+ : WindowInterface(num_y, num_x, by, bx, ch), first(0) {}
+ ~WindowChat();
- // for chat:
void AddMessage(const char *msg, int type);
+private:
+ void ChatRedraw();
+ void PrintMessage(int line, message *m);
+};
- // for players:
- //void AddPlayer()
+class WindowPlayers : public WindowInterface {
+public:
+ WindowPlayers(int num_y, int num_x, int by, int bx, char ch)
+ : WindowInterface(num_y, num_x, by, bx, ch) {}
+ ~WindowPlayers() {}
+};
+
+class WindowTips : public WindowInterface {
+public:
+ WindowTips(int num_y, int num_x, int by, int bx, char ch)
+ : WindowInterface(num_y, num_x, by, bx, ch) {}
+ ~WindowTips() {}
+};
- // for input:
- int InputGetch() { return wgetch(input->GetWindow()); }
+class WindowInput : public WindowInterface {
+ int i_ny, i_nx;
+public:
+ WindowInput(int num_y, int num_x, int by, int bx, char ch);
+ ~WindowInput() {}
+
+ int GetChar();
bool AddCharToSendMsg(char ch);
bool RemoveCharFromMsg();
- void InputClear() { input->Clear(false); }
- void SetInputCursor(int y, int x);
-private:
- // for chat:
- void ChatRedraw();
- void PrintMessage(int line, message *m);
+ void SetPosCursor(int y, int x);
};
#endif \ No newline at end of file