Planeshift

chatbubbles.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Robberts
00003  *
00004  * Copyright (C) 2003 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 
00020 #ifndef CHAT_BUBBLES_HEADER
00021 #define CHAT_BUBBLES_HEADER
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <cstypes.h>
00026 #include <csutil/ref.h>
00027 #include <csutil/array.h>
00028 
00029 //=============================================================================
00030 // Project Includes
00031 //=============================================================================
00032 #include "net/subscriber.h"
00033 
00034 #include "effects/pseffectobjtextable.h"
00035 
00036 //=============================================================================
00037 // Local Includes
00038 //=============================================================================
00039 
00040 //these are special cases used to manage /me /my configurations in chat bubbles
00041 #define CHATBUBBLE_ME -2
00042 #define CHATBUBBLE_MY -3
00043 
00044 struct BubbleChatType
00045 {
00046     int                 chatType;           // the chat type this settings will apply to
00047     psEffectTextRow     textSettings;       // the settings
00048     char                effectPrefix[64];   // the prefix of the effect name to apply, effects of name <prefix>longphrase, <prefix>normal, and <prefix>shortphrase should exist
00049         bool                            enabled;
00050 };
00051 
00052 
00053 class psChatBubbles : public iNetSubscriber
00054 {
00055 private:
00056     psEngine *      psengine;
00057 
00058     csArray<BubbleChatType> chatTypes;
00059 
00060     size_t bubbleMaxLineLen;            // maximum number of characters per line
00061     size_t bubbleShortPhraseCharCount;  // messages with fewer than this many characters get small bubble
00062     size_t bubbleLongPhraseLineCount;   // messages with more than this many lines get large bubble
00063 
00064         bool bubblesEnabled;                                            // enable all chat bubbles
00065         bool mixActionColours;
00066         BubbleChatType* GetTemplate(int iChatType);
00067 
00068 public:
00069     psChatBubbles();
00070     virtual ~psChatBubbles();
00071 
00072     bool Initialize(psEngine * engine);
00073 
00083     bool Load(const char * filename, bool saveUserData = false);
00084         
00085         csArray<BubbleChatType> GetBubbleChatTypes() { return chatTypes; }
00086         void SetBubbleChatTypes(csArray<BubbleChatType> chatTypes) { this->chatTypes = chatTypes; }
00087         
00088         bool isEnabled() { return bubblesEnabled; }
00089         bool isMixingActionColours() { return mixActionColours; }
00090         void setEnabled(bool enable) { bubblesEnabled = enable; }
00091 
00092     size_t GetBubbleMaxLineLen() { return bubbleMaxLineLen; }
00093     size_t GetBubbleShortPhraseCharCount() { return bubbleShortPhraseCharCount; }
00094     size_t GetBubbleLongPhraseLineCount() { return bubbleLongPhraseLineCount; }
00095         
00096     // implemented iNetSubscriber messages
00097     virtual bool Verify(MsgEntry * msg, unsigned int flags, Client *& client);
00098     virtual void HandleMessage(MsgEntry * msg, Client * client);
00099 
00100 };
00101 
00102 #endif // CHAT_BUBBLES_HEADER