summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/clui/Client.cpp11
-rw-r--r--src/client/clui/Client.hpp2
-rw-r--r--src/client/clui/clui.cpp89
-rw-r--r--src/client/clui/clui.hpp15
4 files changed, 104 insertions, 13 deletions
diff --git a/src/client/clui/Client.cpp b/src/client/clui/Client.cpp
index 9859794..9b697b6 100644
--- a/src/client/clui/Client.cpp
+++ b/src/client/clui/Client.cpp
@@ -71,9 +71,16 @@ void Client::HandleActions()
}
}
-void Client::AddMessage(const char *msg, int type)
+void Client::AddMessage(const char *msg, const char spec_char)
{
- chat->AddMessage(msg, type);
+ if(spec_char == USERS_CHAR)
+ players->SetPlayersList(msg);
+ else if(spec_char == GONLINE_CHAR)
+ tips->SetGeneralOnline(msg);
+ else if(spec_char == RONLINE_CHAR)
+ tips->SetRoomOnline(msg);
+ else
+ chat->AddMessage(msg, spec_char);
}
void Client::AddCharToBuffer(char ch)
diff --git a/src/client/clui/Client.hpp b/src/client/clui/Client.hpp
index 5dbcfd6..20599f4 100644
--- a/src/client/clui/Client.hpp
+++ b/src/client/clui/Client.hpp
@@ -24,7 +24,7 @@ public:
~Client();
virtual void HandleActions();
- virtual void AddMessage(const char *msg, int type);
+ virtual void AddMessage(const char *msg, const char spec_char);
private:
void AddCharToBuffer(char ch);
void RemoveCharFromBuffer();
diff --git a/src/client/clui/clui.cpp b/src/client/clui/clui.cpp
index 0010ff7..7b32478 100644
--- a/src/client/clui/clui.cpp
+++ b/src/client/clui/clui.cpp
@@ -13,7 +13,7 @@ WindowChat::~WindowChat()
}
}
-void WindowChat::AddMessage(const char *msg, int type)
+void WindowChat::AddMessage(const char *msg, const char spec_ch)
{
message *recent_msg = new message;
@@ -22,7 +22,7 @@ void WindowChat::AddMessage(const char *msg, int type)
strcpy(recent_msg->text, msg);
recent_msg->num_lines = lines;
- recent_msg->type = type;
+ recent_msg->spec_char = spec_ch;
recent_msg->prev = first;
first = recent_msg;
@@ -71,7 +71,7 @@ void WindowChat::PrintMessage(int line, message *m)
{
int need_print = m->num_lines;
while(need_print != 0) {
- if(m->type == system_msg) wattron(w, A_ITALIC);
+ if(m->spec_char == SYSTEM_CHAR) wattron(w, A_ITALIC);
else wattron(w, A_BOLD);
wmove(w, line-need_print+1, 1);
@@ -80,7 +80,7 @@ void WindowChat::PrintMessage(int line, message *m)
memcpy(tmp, m->text + str, oneline_len);
wprintw(w, tmp);
- if(m->type == system_msg) wattroff(w, A_ITALIC);
+ if(m->spec_char == SYSTEM_CHAR) wattroff(w, A_ITALIC);
else wattroff(w, A_BOLD);
delete[] tmp;
@@ -90,6 +90,87 @@ void WindowChat::PrintMessage(int line, message *m)
////////////////////////////////////////////////////////////////////////
+WindowPlayers::WindowPlayers(int num_y, int num_x, int by, int bx, char ch)
+ : WindowInterface(num_y, num_x, by, bx, ch)
+{
+ mvwprintw(w, num_y-2, 1, "<- /prev /next ->");
+ Update();
+}
+
+void WindowPlayers::SetPlayersList(const char *list)
+{
+ // clear line:
+ for(int j = 1; j < ny-2; j++) {
+ wmove(w, j, 1);
+ for(int i = 1; i < nx-1; i++)
+ waddch(w, ' ');
+ }
+
+ int len_list = strlen(list);
+ int p = 1;
+
+ int start = 0;
+ for(int i = 0; i < len_list; i++) {
+ if(list[i] == ';')
+ {
+ char *str = new char[max_name_len+1];
+ int size = i - start;
+ memcpy(str, list+start, size);
+ str[size] = '\0';
+
+ mvwprintw(w, p, 1, str);
+ start = i+1;
+ p++;
+ delete[] str;
+ }
+ }
+ Update();
+}
+
+////////////////////////////////////////////////////////////////////////
+
+WindowTips::WindowTips(int num_y, int num_x, int by, int bx, char ch)
+ : WindowInterface(num_y, num_x, by, bx, ch)
+{
+ mvwprintw(w, num_y-7, 1, " Tips");
+ mvwprintw(w, num_y-6, 1, "Online: ");
+ mvwprintw(w, num_y-5, 1, "Online room: ");
+ mvwprintw(w, num_y-4, 1, "");
+ mvwprintw(w, num_y-3, 1, "ESC - exit");
+ mvwprintw(w, num_y-2, 1, "ENTER - send msg");
+ Update();
+}
+
+void WindowTips::SetGeneralOnline(const char *online)
+{
+ // clear line:
+ wmove(w, ny-6, 1);
+ for(int i = 1; i < nx-1; i++)
+ waddch(w, ' ');
+
+ // print online
+ char *str = new char[nx];
+ sprintf(str, "Online: %s", online);
+ mvwprintw(w, ny-6, 1, str);
+ Update();
+ delete[] str;
+ Update();
+}
+
+void WindowTips::SetRoomOnline(const char *online)
+{
+ // clear line:
+ wmove(w, ny-5, 1);
+ for(int i = 1; i < nx-1; i++)
+ waddch(w, ' ');
+
+ // print online
+ char *str = new char[nx];
+ sprintf(str, "Online room: %s", online);
+ mvwprintw(w, ny-5, 1, str);
+ Update();
+ delete[] str;
+}
////////////////////////////////////////////////////////////////////////
diff --git a/src/client/clui/clui.hpp b/src/client/clui/clui.hpp
index 87445db..23f6c70 100644
--- a/src/client/clui/clui.hpp
+++ b/src/client/clui/clui.hpp
@@ -10,7 +10,7 @@ class WindowChat : public WindowInterface {
struct message {
char text[max_msg_len];
int num_lines; // number of lines
- int type;
+ char spec_char;
message *prev;
};
message *first;
@@ -19,7 +19,7 @@ public:
: WindowInterface(num_y, num_x, by, bx, ch), first(0) {}
~WindowChat();
- void AddMessage(const char *msg, int type);
+ void AddMessage(const char *msg, const char spec_ch);
private:
void ChatRedraw();
void PrintMessage(int line, message *m);
@@ -27,16 +27,19 @@ private:
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(int num_y, int num_x, int by, int bx, char ch);
~WindowPlayers() {}
+
+ void SetPlayersList(const char *list);
};
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(int num_y, int num_x, int by, int bx, char ch);
~WindowTips() {}
+
+ void SetGeneralOnline(const char *online);
+ void SetRoomOnline(const char *online);
};
class WindowInput : public WindowInterface {