00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }