HUDDialog.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <dialogs/HUDDialog.h>
00022 #include <graph/OptionsDisplay.h>
00023 #include <GLW/GLWTextButton.h>
00024 #include <GLW/GLWWindowManager.h>
00025 
00026 HUDDialog *HUDDialog::instance_ = 0;
00027 
00028 HUDDialog *HUDDialog::instance()
00029 {
00030         if (!instance_)
00031         {
00032                 instance_ = new HUDDialog;
00033         }
00034         return instance_;
00035 }
00036 
00037 HUDDialog::HUDDialog() :
00038         GLWWindow("HUD Settings", 10.0f, 10.0f, 300.0f, 70.0f, eSmallTitle,
00039                 "Allow the user to change hud settings")
00040 {
00041         needCentered_ = true;
00042 
00043         nameBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_NAME", "Show Name"));
00044         addWidget(nameBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00045         sightBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_SIGHT", "Show Sight"));
00046         addWidget(sightBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00047         oldSightBox_  = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("OLD_SIGHT", "Use Old Sight Position"));
00048         addWidget(oldSightBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00049         colorBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_COLOR", "Show Color"));
00050         addWidget(colorBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00051         healthBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_HEALTH", "Show Health"));
00052         addWidget(healthBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00053         iconBox_ = new GLWCheckBoxText(0.0f, 0.0f, LANG_RESOURCE("SHOW_ICON", "Show Icon"));
00054         addWidget(iconBox_, 0, SpaceLeft | SpaceRight | SpaceTop, 10.0f);
00055 
00056         GLWPanel *buttonPanel = new GLWPanel(0.0f, 0.0f, 0.0f, 0.0f, false, false);
00057         GLWButton *cancelButton = new GLWTextButton(LANG_RESOURCE("CANCEL", "Cancel"), 95, 10, 105, this, 
00058                 GLWButton::ButtonFlagCancel | GLWButton::ButtonFlagCenterX);
00059         cancelId_ = cancelButton->getId();
00060         buttonPanel->addWidget(cancelButton, 0, SpaceRight, 10.0f);
00061         GLWButton *okButton = new GLWTextButton(LANG_RESOURCE("OK", "Ok"), 235, 10, 55, this, 
00062                 GLWButton::ButtonFlagOk | GLWButton::ButtonFlagCenterX);
00063         okId_ = okButton->getId();
00064         buttonPanel->addWidget(okButton);
00065         buttonPanel->setLayout(GLWPanel::LayoutHorizontal);
00066         addWidget(buttonPanel, 0, SpaceAll, 10.0f);
00067 
00068         setLayout(GLWPanel::LayoutVerticle);
00069         layout();
00070 }
00071 
00072 HUDDialog::~HUDDialog()
00073 {
00074 }
00075 
00076 void HUDDialog::display()
00077 {
00078         GLWWindow::display();
00079 
00080         nameBox_->getCheckBox().setState(
00081                 OptionsDisplay::instance()->getDrawPlayerNames());
00082         sightBox_->getCheckBox().setState(
00083                 OptionsDisplay::instance()->getDrawPlayerSight());
00084         oldSightBox_->getCheckBox().setState(
00085                 OptionsDisplay::instance()->getOldSightPosition());
00086         colorBox_->getCheckBox().setState(
00087                 OptionsDisplay::instance()->getDrawPlayerColor());
00088         healthBox_->getCheckBox().setState(
00089                 OptionsDisplay::instance()->getDrawPlayerHealth());
00090         iconBox_->getCheckBox().setState(
00091                 OptionsDisplay::instance()->getDrawPlayerIcons());
00092 }
00093 
00094 void HUDDialog::buttonDown(unsigned int id)
00095 {
00096         if (id == okId_)
00097         {
00098                 OptionsDisplay::instance()->getDrawPlayerNamesEntry().setValue(
00099                         nameBox_->getCheckBox().getState());
00100                 OptionsDisplay::instance()->getDrawPlayerSightEntry().setValue(
00101                         sightBox_->getCheckBox().getState());
00102                 OptionsDisplay::instance()->getOldSightPositionEntry().setValue(
00103                         oldSightBox_->getCheckBox().getState());
00104                 OptionsDisplay::instance()->getDrawPlayerColorEntry().setValue(
00105                         colorBox_->getCheckBox().getState());
00106                 OptionsDisplay::instance()->getDrawPlayerHealthEntry().setValue(
00107                         healthBox_->getCheckBox().getState());
00108                 OptionsDisplay::instance()->getDrawPlayerIconsEntry().setValue(
00109                         iconBox_->getCheckBox().getState());
00110         }
00111         GLWWindowManager::instance()->hideWindow(getId());
00112 }

Generated on Mon Feb 16 15:14:37 2009 for Scorched3D by  doxygen 1.5.3