git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / src / client / GLW / GLWChannelViewTextRenderer.cpp
blob35da8fdfade8d2af0f7e611e81fd19ca13552e4f
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <GLW/GLWChannelViewTextRenderer.h>
22 #include <GLW/GLWChannelView.h>
23 #include <GLW/GLWTranslate.h>
24 #include <tank/TankContainer.h>
25 #include <tankgraph/TargetRendererImplTank.h>
26 #include <client/ScorchedClient.h>
27 #include <lang/LangResource.h>
29 GLWChannelViewTextRenderer::GLWChannelViewTextRenderer(GLWChannelView *channelView) :
30 channelView_(channelView)
34 GLWChannelViewTextRenderer::~GLWChannelViewTextRenderer()
38 void GLWChannelViewTextRenderer::drawCharacter(
39 int charPosition, Vector &position,
40 GLFont2dStorage::CharEntry &charEntry, Vector4 &color)
42 ChannelTextEntry *textEntry = getEntry(charPosition);
43 if (!textEntry) return;
45 // Set the appropriate tool tip
46 if (GLWToolTip::instance()->addToolTip(
47 &toolTip_,
48 GLWTranslate::getPosX() + position[0],
49 GLWTranslate::getPosY() + position[1],
50 12.0f, 18.0f))
52 switch (textEntry->type)
54 case ePlayerEntry:
56 TargetRendererImplTank *renderer = 0;
57 Tank *tank = ScorchedClient::instance()->getTankContainer().getTankById(
58 textEntry->data);
59 if (tank) renderer = (TargetRendererImplTank *) tank->getRenderer();
60 if (renderer)
62 GLWToolTip::instance()->addToolTip(
63 &renderer->getTips()->tankTip,
64 GLWTranslate::getPosX() + position[0],
65 GLWTranslate::getPosY() + position[1],
66 12.0f, 18.0f);
68 else
70 toolTip_.setText(ToolTip::ToolTipInfo,
71 LANG_RESOURCE("PLAYER_DISCONECTED", "Player disconnected"),
72 textEntry->part);
75 break;
76 case eChannelEntry:
77 toolTip_.setText(ToolTip::ToolTipHelp,
78 LANG_RESOURCE("CHANNEL", "Channel"),
79 textEntry->part);
80 break;
81 case eWeaponEntry:
82 toolTip_.setText(ToolTip::ToolTipHelp,
83 LANG_RESOURCE("WEAPON", "Weapon"),
84 textEntry->part);
85 break;
86 case eAdminEntry:
87 toolTip_.setText(ToolTip::ToolTipHelp,
88 LANG_RESOURCE("ADMIN", "Admin"),
89 textEntry->part);
90 break;
94 // Set the appropriate text colours etc.
95 switch (textEntry->type)
97 case eChannelEntry:
98 break;
99 default:
100 color[0] = textEntry->color[0];
101 color[1] = textEntry->color[1];
102 color[2] = textEntry->color[2];
103 break;