GLWChannelView.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_GLWChannelViewh_INCLUDE__)
00022 #define __INCLUDE_GLWChannelViewh_INCLUDE__
00023 
00024 #include <GLW/GLWidget.h>
00025 #include <GLW/GLWIconButton.h>
00026 #include <GLW/GLWChannelViewTextRenderer.h>
00027 #include <client/ClientChannelManagerI.h>
00028 #include <common/KeyboardKey.h>
00029 #include <common/Vector.h>
00030 #include <list>
00031 
00032 class GLWChannelViewI
00033 {
00034 public:
00035         virtual ~GLWChannelViewI();
00036 
00037         virtual void channelsChanged(unsigned int id) = 0;
00038 };
00039 
00040 class GLWChannelView : 
00041         public GLWidget,
00042         public ClientChannelManagerI,
00043         public GLWButtonI
00044 {
00045 public:
00046         class BaseChannelEntry
00047         {
00048         public:
00049                 std::string channel;
00050                 unsigned int type;
00051         };
00052         class CurrentChannelEntry : public BaseChannelEntry
00053         {
00054         public:
00055                 Vector color;
00056                 unsigned int id;
00057         };
00058 
00059         GLWChannelView();
00060         virtual ~GLWChannelView();
00061 
00062         bool getParentSized() { return parentSized_; }
00063         bool initFromXMLInternal(XMLNode *node);
00064 
00065         unsigned int getLastWhisperSrc() { return lastWhisperSrc_; }
00066 
00067         std::list<CurrentChannelEntry> &getCurrentChannels() { return currentChannels_; }
00068         std::list<BaseChannelEntry> &getAvailableChannels() { return availableChannels_; }
00069         CurrentChannelEntry *getChannel(const std::string &channelName);
00070 
00071         void joinChannel(const std::string &channelName);
00072         void leaveChannel(const std::string &channelName);
00073 
00074         void setHandler(GLWChannelViewI *handler) { handler_ = handler; };
00075 
00076         // GLWidget
00077         virtual void draw();
00078         virtual void simulate(float frameTime);
00079         virtual bool initFromXML(XMLNode *node);
00080         virtual void mouseDown(int button, float x, float y, bool &skipRest);
00081         virtual void mouseUp(int button, float x, float y, bool &skipRest);
00082         virtual void mouseDrag(int button, float mx, float my, float x, float y, bool &skipRest);
00083         virtual void keyDown(char *buffer, unsigned int keyState, 
00084                 KeyboardHistory::HistoryElement *history, int hisCount, 
00085                 bool &skipRest);
00086         virtual void setX(float x);
00087         virtual void setY(float y);
00088 
00089         // ClientChannelManagerI
00090         virtual void channelText(ChannelText &text);
00091         virtual void registeredForChannels(
00092                 std::list<ChannelDefinition> &registeredChannels,
00093                 std::list<ChannelDefinition> &availableChannels);
00094 
00095         // ButtonI
00096         virtual void buttonDown(unsigned int id);
00097 
00098         REGISTER_CLASS_HEADER(GLWChannelView);
00099 
00100 protected:
00101         class GLWChannelViewEntry
00102         {
00103         public:
00104                 Vector color;
00105                 GLWChannelViewTextRenderer text;
00106                 float timeRemaining;
00107         };
00108 
00109         GLWChannelViewI *handler_;
00110         GLWIconButton upButton_;
00111         GLWIconButton downButton_;
00112         GLWIconButton resetButton_;
00113         bool createdTexture_;
00114         GLTexture upTexture_;
00115         GLTexture downTexture_;
00116         GLTexture resetTexture_;
00117 
00118         unsigned int lastChannelId_;
00119         unsigned int lastWhisperSrc_;
00120         bool init_;
00121         bool alignTop_, parentSized_;
00122         bool splitLargeLines_, allowScroll_;
00123         bool showChannelName_, showChannelNumber_;
00124         int lineDepth_;
00125         int scrollPosition_;
00126         float displayTime_;
00127         float fontSize_, outlineFontSize_;
00128         int visibleLines_, totalLines_;
00129         int currentVisible_;
00130         std::list<GLWChannelViewEntry> textLines_;
00131         KeyboardKey *scrollUpKey_;
00132         KeyboardKey *scrollDownKey_;
00133         KeyboardKey *scrollResetKey_;
00134         std::map<std::string, Vector> channelColors_;
00135         std::list<std::string> startupChannels_;
00136         std::list<CurrentChannelEntry> currentChannels_;
00137         std::list<BaseChannelEntry> availableChannels_;
00138         std::string textSound_;
00139 
00140         void addInfo(Vector &color, GLWChannelViewTextRenderer &text);
00141         void formCurrentChannelList(std::list<std::string> &result);
00142         int splitLine(const LangString &message);
00143 };
00144 
00145 #endif // __INCLUDE_GLWChannelViewh_INCLUDE__

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