Accessory sorting due to price.
[scorched3d.git] / src / client / dialogs / HUDDialog.cpp
blobe2ab9248873e798ca49f67be437fa9aca3e93b7f
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/HUDDialog.h>
22 #include <graph/OptionsDisplay.h>
23 #include <GLW/GLWTextButton.h>
24 #include <GLW/GLWWindowManager.h>
26 HUDDialog *HUDDialog::instance_ = 0;
28 HUDDialog *HUDDialog::instance()
30 if (!instance_)
32 instance_ = new HUDDialog;
34 return instance_;
37 HUDDialog::HUDDialog() :
38 GLWWindow("HUD Settings", 10.0f, 10.0f, 300.0f, 70.0f, eSmallTitle,
39 "Allow the user to change hud settings")
41 needCentered_ = true;
43 nameBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_NAME", "Show Name"));
44 addWidget(nameBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
45 sightBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_SIGHT", "Show Sight"));
46 addWidget(sightBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
47 oldSightBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("OLD_SIGHT", "Use Old Sight Position"));
48 addWidget(oldSightBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
49 colorBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_COLOR", "Show Color"));
50 addWidget(colorBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
51 healthBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_HEALTH", "Show Health"));
52 addWidget(healthBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
53 iconBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_ICON", "Show Icon"));
54 addWidget(iconBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
56 GLWPanel *buttonPanel = new GLWPanel(0.0f, 0.0f, 0.0f, 0.0f, false, false);
57 GLWButton *cancelButton = new GLWTextButton(LANG_RESOURCE("CANCEL", "Cancel"), 95, 10, 105, this,
58 GLWButton::ButtonFlagCancel | GLWButton::ButtonFlagCenterX);
59 cancelId_ = cancelButton->getId();
60 buttonPanel->addWidget(cancelButton, 0, SpaceRight, 10.0f);
61 GLWButton *okButton = new GLWTextButton(LANG_RESOURCE("OK", "Ok"), 235, 10, 55, this,
62 GLWButton::ButtonFlagOk | GLWButton::ButtonFlagCenterX);
63 okId_ = okButton->getId();
64 buttonPanel->addWidget(okButton);
65 buttonPanel->setLayout(GLWPanel::LayoutHorizontal);
66 addWidget(buttonPanel, 0, SpaceAll, 10.0f);
68 setLayout(GLWPanel::LayoutVerticle);
69 layout();
72 HUDDialog::~HUDDialog()
76 void HUDDialog::display()
78 GLWWindow::display();
80 nameBox_->getCheckBox().setState(
81 OptionsDisplay::instance()->getDrawPlayerNames());
82 sightBox_->getCheckBox().setState(
83 OptionsDisplay::instance()->getDrawPlayerSight());
84 oldSightBox_->getCheckBox().setState(
85 OptionsDisplay::instance()->getOldSightPosition());
86 colorBox_->getCheckBox().setState(
87 OptionsDisplay::instance()->getDrawPlayerColor());
88 healthBox_->getCheckBox().setState(
89 OptionsDisplay::instance()->getDrawPlayerHealth());
90 iconBox_->getCheckBox().setState(
91 OptionsDisplay::instance()->getDrawPlayerIcons());
94 void HUDDialog::buttonDown(unsigned int id)
96 if (id == okId_)
98 OptionsDisplay::instance()->getDrawPlayerNamesEntry().setValue(
99 nameBox_->getCheckBox().getState());
100 OptionsDisplay::instance()->getDrawPlayerSightEntry().setValue(
101 sightBox_->getCheckBox().getState());
102 OptionsDisplay::instance()->getOldSightPositionEntry().setValue(
103 oldSightBox_->getCheckBox().getState());
104 OptionsDisplay::instance()->getDrawPlayerColorEntry().setValue(
105 colorBox_->getCheckBox().getState());
106 OptionsDisplay::instance()->getDrawPlayerHealthEntry().setValue(
107 healthBox_->getCheckBox().getState());
108 OptionsDisplay::instance()->getDrawPlayerIconsEntry().setValue(
109 iconBox_->getCheckBox().getState());
111 GLWWindowManager::instance()->hideWindow(getId());