00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <dialogs/MessageDialog.h>
00022 #include <client/ScorchedClient.h>
00023 #include <common/OptionsScorched.h>
00024 #include <console/Console.h>
00025 #include <GLEXT/GLViewPort.h>
00026 #include <GLW/GLWFont.h>
00027
00028 MessageDialog *MessageDialog::instance_ = 0;
00029
00030 MessageDialog *MessageDialog::instance()
00031 {
00032 if (!instance_) instance_ = new MessageDialog();
00033 return instance_;
00034 }
00035
00036 MessageDialog::MessageDialog() :
00037 showTime_(0.0f), GLWWindow("", 10.0f, 10.0f, 447.0f, 310.0f,
00038 GLWWindow::eTransparent | GLWWindow::eNoTitle,
00039 "")
00040 {
00041 disabled_ = true;
00042 windowLevel_ = 90000;
00043
00044 std::list<std::string> startupChannels;
00045 startupChannels.push_back("banner");
00046 ClientChannelManager::instance()->registerClient(this, startupChannels);
00047 }
00048
00049 MessageDialog::~MessageDialog()
00050 {
00051 }
00052
00053 void MessageDialog::channelText(ChannelText &text)
00054 {
00055 clear();
00056 texts_.push_back(text.getMessage());
00057 }
00058
00059 void MessageDialog::registeredForChannels(
00060 std::list<ChannelDefinition> ®isteredChannels,
00061 std::list<ChannelDefinition> &availableChannels)
00062 {
00063 }
00064
00065 void MessageDialog::simulate(float simTime)
00066 {
00067 showTime_ -= simTime;
00068 if (showTime_ <= 0.0f)
00069 {
00070 if (!texts_.empty())
00071 {
00072 currentText_ = texts_.front();
00073 texts_.pop_front();
00074 showTime_ = 5.0f;
00075 }
00076 }
00077 }
00078
00079 void MessageDialog::clear()
00080 {
00081 texts_.clear();
00082 showTime_ = 0.0f;
00083 }
00084
00085 void MessageDialog::draw()
00086 {
00087 if (showTime_ <= 0.0f) return;
00088
00089 GLState state(GLState::BLEND_ON | GLState::TEXTURE_OFF | GLState::DEPTH_OFF);
00090
00091 float wHeight = (float) GLViewPort::getHeight();
00092 float wWidth = (float) GLViewPort::getWidth();
00093 float textWidth = GLWFont::instance()->getGameFont()->getWidth(
00094 30, currentText_);
00095
00096 float x = (wWidth/2.0f) - (textWidth / 2) - 10.0f;
00097 float y = wHeight - 60.0f;
00098
00099 setW(textWidth + 20.0f);
00100 setH(40);
00101 setX(x);
00102 setY(y);
00103 GLWWindow::draw();
00104
00105 Vector white(0.9f, 0.9f, 1.0f);
00106 GLWFont::instance()->getGameFont()->draw(
00107 white, 30,
00108 x + 10.0f, y + 7.0f, 0.0f,
00109 currentText_);
00110 }