Planeshift

pawsbuddy.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Craig
00003  *
00004  * Copyright (C) 2004 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef PAWS_BUDDY_HEADER
00020 #define PAWS_BUDDY_HEADER
00021 
00022 #include "paws/pawswidget.h"
00023 #include "net/subscriber.h"
00024 
00025 #include "paws/pawsstringpromptwindow.h"
00026 #include "gui/pawscontrolwindow.h"
00027 #include "gui/chatwindow.h"
00028 
00029 class pawsListBox;
00030 
00031 
00036 #define ALIASES_FILE_PREFIX       "/planeshift/userdata/aliases_"
00037 
00038 
00042 class pawsBuddyWindow : public pawsControlledWindow, public psClientNetSubscriber, public iOnStringEnteredAction
00043 {
00044 public:
00045     pawsBuddyWindow();
00046 
00047     bool PostSetup();
00048     
00052     void HandleMessage( MsgEntry* me );
00053 
00054     bool OnButtonReleased( int mouseButton, int keyModifier, pawsWidget* widget );
00055     void OnListAction( pawsListBox* widget, int status );
00056     void OnStringEntered(const char *name,int param,const char *value);
00057 
00058     virtual void Show();
00059 
00060     virtual void OnResize();
00061 
00062 private:
00064     pawsListBox* buddyList;  
00065 
00067     csString currentBuddy;
00068     
00070     pawsChatWindow* chatWindow;
00071 
00073     csString editBuddy;
00074 
00076     csStringArray onlineBuddies;
00078     csStringArray offlineBuddies;
00079 
00081     csHash<csString, csString> aliases;
00082 
00088     csString GetAlias(const csString & name) const;
00089 
00095     csString GetRealName(const csString & alias) const;
00096 
00101     void LoadAliases(const csString & charName);
00102 
00107     void SaveAliases(const csString & charName) const;
00108 
00115     void ChangeAlias(const csString & name, const csString & oldAlias, const csString & newAlias);
00116 
00123     void FillBuddyList();
00124 
00131     bool IsUniqueAlias(const csString & alias) const;
00132 
00133 };
00134 
00135 
00136 CREATE_PAWS_FACTORY( pawsBuddyWindow );
00137 #endif