ChannelTextParser.h

Go to the documentation of this file.
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_ChannelTextParserh_INCLUDE__)
00022 #define __INCLUDE_ChannelTextParserh_INCLUDE__
00023 
00024 #include <lang/LangString.h>
00025 #include <common/Vector.h>
00026 #include <vector>
00027 
00028 class ScorchedContext;
00029 class ChannelTextParser
00030 {
00031 public:
00032         enum ChannelTextEntryType
00033         {
00034                 ePlayerEntry,
00035                 eWeaponEntry,
00036                 eChannelEntry,
00037                 eAdminEntry,
00038                 eTipEntry
00039         };
00040         struct ChannelTextEntry
00041         {
00042                 ChannelTextEntryType type;
00043                 unsigned int data;
00044                 LangString text;
00045                 LangString part;
00046                 Vector color;
00047         };
00048 
00049         ChannelTextParser();
00050         virtual ~ChannelTextParser();
00051 
00052         void parseText(ScorchedContext &context, const LangString &text);
00053         void subset(ChannelTextParser &other, int start, int len);
00054 
00055         const LangString &getString() { return text_; }
00056 
00057         ChannelTextEntry *getEntry(int position);
00058     
00059 protected:
00060         LangString text_;
00061         std::vector<unsigned int> entryIndex_;
00062         std::vector<ChannelTextEntry> entries_;
00063 
00064         bool parseUrl(ScorchedContext &context, 
00065                 const LangString &url, ChannelTextEntry &entry);
00066         bool createPlayerEntry(ScorchedContext &context,
00067                 const LangString &part, ChannelTextEntry &entry);
00068         bool createWeaponEntry(ScorchedContext &context, 
00069                 const LangString &partt, ChannelTextEntry &entry);
00070         bool createChannelEntry(ScorchedContext &context, 
00071                 const LangString &part, ChannelTextEntry &entry);
00072         bool createTipEntry(ScorchedContext &context, 
00073                 const LangString &part, ChannelTextEntry &entry);
00074         bool createAdminEntry(ScorchedContext &context, 
00075                 const LangString &part, ChannelTextEntry &entry);
00076         void addIndex(int number, unsigned char index);
00077 };
00078 
00079 #endif

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3