00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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