1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
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 <dialogs/MessageDialog.h>
22 #include <client/ScorchedClient.h>
23 #include <common/OptionsScorched.h>
24 #include <console/Console.h>
25 #include <GLEXT/GLViewPort.h>
26 #include <GLW/GLWFont.h>
28 MessageDialog
*MessageDialog::instance_
= 0;
30 MessageDialog
*MessageDialog::instance()
32 if (!instance_
) instance_
= new MessageDialog();
36 MessageDialog::MessageDialog() :
37 showTime_(0.0f
), GLWWindow("", 10.0f
, 10.0f
, 447.0f
, 310.0f
,
38 GLWWindow::eTransparent
| GLWWindow::eNoTitle
,
44 std::list
<std::string
> startupChannels
;
45 startupChannels
.push_back("banner");
46 ClientChannelManager::instance()->registerClient(this, startupChannels
);
49 MessageDialog::~MessageDialog()
53 void MessageDialog::channelText(ChannelText
&text
)
56 texts_
.push_back(text
.getMessage());
59 void MessageDialog::registeredForChannels(
60 std::list
<ChannelDefinition
> ®isteredChannels
,
61 std::list
<ChannelDefinition
> &availableChannels
)
65 void MessageDialog::simulate(float simTime
)
68 if (showTime_
<= 0.0f
)
72 currentText_
= texts_
.front();
79 void MessageDialog::clear()
85 void MessageDialog::draw()
87 if (showTime_
<= 0.0f
) return;
89 GLState
state(GLState::BLEND_ON
| GLState::TEXTURE_OFF
| GLState::DEPTH_OFF
);
91 float wHeight
= (float) GLViewPort::getHeight();
92 float wWidth
= (float) GLViewPort::getWidth();
93 float textWidth
= GLWFont::instance()->getGameFont()->getWidth(
96 float x
= (wWidth
/2.0f
) - (textWidth
/ 2) - 10.0f
;
97 float y
= wHeight
- 60.0f
;
99 setW(textWidth
+ 20.0f
);
105 Vector
white(0.9f
, 0.9f
, 1.0f
);
106 GLWFont::instance()->getGameFont()->draw(
108 x
+ 10.0f
, y
+ 7.0f
, 0.0f
,