Accessory sorting due to price.
[scorched3d.git] / src / client / dialogs / LogDialog.cpp
blobfb13d08127dcced2fac65f4c6951d4f5e76e9669
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 <dialogs/LogDialog.h>
22 #include <dialogs/QuitDialog.h>
23 #include <GLW/GLWTextButton.h>
24 #include <GLW/GLWWindowManager.h>
25 #include <GLEXT/GLViewPort.h>
26 #include <graph/OptionsDisplay.h>
27 #include <common/Logger.h>
29 LogDialog *LogDialog::instance_ = 0;
31 LogDialog *LogDialog::instance()
33 if (!instance_)
35 instance_ = new LogDialog;
37 return instance_;
40 LogDialog::LogDialog() :
41 GLWWindow("Log", 10.0f, 10.0f, 300.0f, 240.0f, 0,
42 "Log Window")
44 needCentered_ = true;
45 quit_ = (GLWTextButton *)
46 addWidget(new GLWTextButton(LANG_RESOURCE("QUIT", "Quit"), 205, 10, 85, this,
47 GLWButton::ButtonFlagCenterX));
48 listView_ = (GLWListView *) addWidget(new GLWListView(10, 40, 280, 140, 100));
49 serverName_ = (GLWLabel *) addWidget(new GLWLabel(5, 195, LANG_RESOURCE("LOCAL", "Local")));
51 // Add this class as a log handler
52 Logger::addLogger(this);
55 LogDialog::~LogDialog()
59 void LogDialog::logMessage(LoggerInfo &info)
61 listView_->addLine(info.getMessage());
62 listView_->endPosition();
65 void LogDialog::draw()
67 float wWidth = (float) GLViewPort::getWidth();
68 float width = wWidth - 40.0f;
69 if (width < 320) width = 320;
70 if (width > 640) width = 640;
71 setW(width - 20);
72 listView_->setW(width - 40);
73 quit_->setX(width - 115);
75 float wHeight = (float) GLViewPort::getHeight();
76 float height = wHeight - 40.0f;
77 if (height < 200) height = 200;
78 if (height > 300) height = 300;
79 serverName_->setY(height - 50);
80 listView_->setH(height - 90);
81 setH(height - 20);
83 GLWWindow::draw();
86 void LogDialog::buttonDown(unsigned int id)
88 if (id == quit_->getId())
90 GLWWindowManager::instance()->
91 showWindow(QuitDialog::instance()->getId());