#include <chat.h>
Collaboration diagram for Chat:
Public Member Functions | |
Chat () | |
~Chat () | |
void | Show () |
void | ShowInput () |
int | CheckInput () |
void | Reset () |
void | NewMessage (const std::string &msg) |
void | HandleKey (const SDL_Event *event) |
Private Attributes | |
TextList * | chat |
Text * | input |
Text * | msg |
int | check_input |
uint | last_time |
Definition at line 36 of file chat.h.
Chat::Chat | ( | ) |
int Chat::CheckInput | ( | ) |
void Chat::HandleKey | ( | const SDL_Event * | event | ) |
Definition at line 82 of file chat.cpp.
00082 { 00083 SDL_KeyboardEvent kbd_event = event->key; 00084 SDL_keysym key = kbd_event.keysym; 00085 std::string txt = input->GetText(); 00086 00087 switch(key.sym){ 00088 00089 case SDLK_RETURN: 00090 check_input = 0; //Hide input widget 00091 if(txt != "" ) 00092 network.SendChatMessage(txt); //Send 'txt' to other players 00093 input->Set(""); 00094 break; 00095 00096 case SDLK_BACKSPACE: 00097 if(kbd_event.state == 1 && txt != "") 00098 txt = txt.substr(0, txt.size()-1); 00099 input->Set(txt); 00100 break; 00101 00102 default: 00103 if(kbd_event.state == 1){ 00104 if(key.unicode < 0x80 && key.unicode > 0) 00105 txt = txt + (char)key.unicode; 00106 input->Set(txt); 00107 } 00108 } 00109 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Chat::NewMessage | ( | const std::string & | msg | ) |
void Chat::Reset | ( | ) |
void Chat::Show | ( | ) |
Definition at line 44 of file chat.cpp.
00044 { 00045 uint now = Time::GetInstance()->ReadSec(); 00046 00047 if((now - last_time) >= MAXSECONDS){ 00048 chat->DeleteLine(); 00049 last_time = now; 00050 } 00051 00052 chat->Draw(XPOS, YPOS, HEIGHT); 00053 00054 if(check_input) 00055 ShowInput(); 00056 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Chat::ShowInput | ( | ) |
Definition at line 58 of file chat.cpp.
00058 { 00059 check_input = 1; 00060 if(input == NULL){ 00061 input = new Text("", c_white); 00062 msg = new Text(SAY, c_red); 00063 } 00064 input->DrawTopLeft(50,500); 00065 msg->DrawTopLeft(25,500); 00066 }
Here is the call graph for this function:
Here is the caller graph for this function:
TextList* Chat::chat [private] |
int Chat::check_input [private] |
Text* Chat::input [private] |
uint Chat::last_time [private] |