00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #if !defined(__INCLUDE_ClientChannelManagerh_INCLUDE__) 00022 #define __INCLUDE_ClientChannelManagerh_INCLUDE__ 00023 00024 #include <coms/ComsMessageHandler.h> 00025 #include <client/ClientChannelManagerI.h> 00026 #include <console/ConsoleRule.h> 00027 #include <set> 00028 00029 class ClientChannelManager : 00030 public ComsMessageHandlerI 00031 { 00032 public: 00033 static ClientChannelManager *instance(); 00034 00035 void showText(const ChannelText &text); 00036 void sendText(const ChannelText &text); 00037 00038 std::set<unsigned int> &getMutedPlayers() { return mutedPlayers_; } 00039 00040 bool registerClient(ClientChannelManagerI *reciever, 00041 std::list<std::string> &channels); 00042 bool deregisterClient(ClientChannelManagerI *reciever); 00043 bool changeRegistration(ClientChannelManagerI *reciever, 00044 std::list<std::string> &channels); 00045 00046 void addChannel(const char *lookfor, const char *channel); 00047 void removeChannel(const char *channel); 00048 00049 // Inherited from ComsMessageHandlerI 00050 virtual bool processMessage( 00051 NetMessage &message, 00052 const char *messageType, 00053 NetBufferReader &reader); 00054 00055 protected: 00056 static ClientChannelManager *instance_; 00057 static unsigned int nextRecieverId_; 00058 00059 class ChannelEntry 00060 { 00061 public: 00062 ChannelEntry(ClientChannelManagerI *user); 00063 00064 ClientChannelManagerI *getUser() { return user_; } 00065 void setChannels(std::list<ChannelDefinition> &channels); 00066 std::set<std::string> &getChannels() { return channels_; } 00067 00068 bool hasChannel(const std::string &channel); 00069 00070 protected: 00071 ClientChannelManagerI *user_; 00072 std::set<std::string> channels_; 00073 }; 00074 00075 std::set<unsigned int> mutedPlayers_; 00076 std::map<unsigned int, ChannelEntry *> recievers_; 00077 unsigned int getChannelEntry(ClientChannelManagerI *reciever); 00078 void say(std::vector<ConsoleRuleValue> &values); 00079 00080 private: 00081 ClientChannelManager(); 00082 virtual ~ClientChannelManager(); 00083 00084 }; 00085 00086 #endif
1.5.3