Chat Class Reference

#include <chat.h>

Collaboration diagram for Chat:

Collaboration graph
[legend]
List of all members.

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

TextListchat
Textinput
Textmsg
int check_input
uint last_time

Detailed Description

Definition at line 36 of file chat.h.


Constructor & Destructor Documentation

Chat::Chat (  ) 

Definition at line 32 of file chat.cpp.

00032           {
00033   chat = NULL;
00034   input = NULL;
00035   msg = NULL;
00036   check_input = 0;
00037 }

Chat::~Chat (  ) 

Definition at line 28 of file chat.cpp.

00028            {
00029   delete chat;
00030 }


Member Function Documentation

int Chat::CheckInput (  ) 

Definition at line 68 of file chat.cpp.

00068                     {
00069   return check_input;
00070 }

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  ) 

Definition at line 72 of file chat.cpp.

00072                                          {
00073   if(!(chat->Size())){
00074     uint now = Time::GetInstance()->ReadSec();
00075     last_time = now;
00076   }
00077 
00078   chat->AddText(msg, MAXLINES);
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Chat::Reset (  ) 

Definition at line 39 of file chat.cpp.

00039                 {
00040   if(chat == NULL)
00041     chat = new TextList();
00042 }

Here is the caller graph for this function:

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:


Member Data Documentation

TextList* Chat::chat [private]

Definition at line 39 of file chat.h.

int Chat::check_input [private]

Definition at line 43 of file chat.h.

Text* Chat::input [private]

Definition at line 40 of file chat.h.

uint Chat::last_time [private]

Definition at line 44 of file chat.h.

Text* Chat::msg [private]

Definition at line 41 of file chat.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 13:41:43 2007 for Wormux by  doxygen 1.4.7