GLWChannelViewTextRenderer.cpp

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 #include <GLW/GLWChannelViewTextRenderer.h>
00022 #include <GLW/GLWChannelView.h>
00023 #include <GLW/GLWTranslate.h>
00024 #include <tank/TankContainer.h>
00025 #include <tankgraph/TargetRendererImplTank.h>
00026 #include <client/ScorchedClient.h>
00027 #include <lang/LangResource.h>
00028 
00029 GLWChannelViewTextRenderer::GLWChannelViewTextRenderer(GLWChannelView *channelView) :
00030         channelView_(channelView)
00031 {
00032 }
00033 
00034 GLWChannelViewTextRenderer::~GLWChannelViewTextRenderer()
00035 {
00036 }
00037 
00038 void GLWChannelViewTextRenderer::drawCharacter(
00039         int charPosition, Vector &position, 
00040         GLFont2dStorage::CharEntry &charEntry, Vector4 &color)
00041 {
00042         ChannelTextEntry *textEntry = getEntry(charPosition);
00043         if (!textEntry) return;
00044 
00045         // Set the appropriate tool tip
00046         if (GLWToolTip::instance()->addToolTip(
00047                 &toolTip_,
00048                 GLWTranslate::getPosX() + position[0], 
00049                 GLWTranslate::getPosY() + position[1],
00050                 12.0f, 18.0f))
00051         {
00052                 switch (textEntry->type)
00053                 {
00054                 case ePlayerEntry:
00055                         {
00056                                 TargetRendererImplTank *renderer = 0;
00057                                 Tank *tank = ScorchedClient::instance()->getTankContainer().getTankById(
00058                                         textEntry->data);
00059                                 if (tank) renderer = (TargetRendererImplTank *) tank->getRenderer();
00060                                 if (renderer)
00061                                 {
00062                                         GLWToolTip::instance()->addToolTip(
00063                                                         &renderer->getTips()->tankTip,
00064                                                         GLWTranslate::getPosX() + position[0], 
00065                                                         GLWTranslate::getPosY() + position[1],
00066                                                         12.0f, 18.0f);
00067                                 }
00068                                 else
00069                                 {
00070                                         toolTip_.setText(ToolTip::ToolTipInfo, 
00071                                                 LANG_RESOURCE("PLAYER_DISCONECTED", "Player disconnected"),
00072                                                 textEntry->part);
00073                                 }
00074                         }
00075                         break;
00076                 case eChannelEntry:
00077                         toolTip_.setText(ToolTip::ToolTipHelp, 
00078                                 LANG_RESOURCE("CHANNEL", "Channel"),
00079                                 textEntry->part);               
00080                         break;
00081                 case eWeaponEntry:
00082                         toolTip_.setText(ToolTip::ToolTipHelp, 
00083                                 LANG_RESOURCE("WEAPON", "Weapon"),
00084                                 textEntry->part);       
00085                         break;
00086                 case eAdminEntry:
00087                         toolTip_.setText(ToolTip::ToolTipHelp, 
00088                                 LANG_RESOURCE("ADMIN", "Admin"),
00089                                 textEntry->part);       
00090                         break;
00091                 }
00092         }
00093 
00094         // Set the appropriate text colours etc.
00095         switch (textEntry->type)
00096         {
00097         case eChannelEntry:
00098                 break;
00099         default:
00100                 color[0] = textEntry->color[0];
00101                 color[1] = textEntry->color[1];
00102                 color[2] = textEntry->color[2];
00103                 break;
00104         }
00105 }

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