AdminAuthDialog.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/AdminAuthDialog.h>
00022 #include <dialogs/AdminDialog.h>
00023 #include <GLW/GLWTextButton.h>
00024 #include <GLW/GLWWindowManager.h>
00025 #include <client/ClientAdminResultHandler.h>
00026 #include <coms/ComsAdminMessage.h>
00027 #include <coms/ComsMessageSender.h>
00028 
00029 AdminAuthDialog *AdminAuthDialog::instance_ = 0;
00030 
00031 AdminAuthDialog *AdminAuthDialog::instance()
00032 {
00033         if (!instance_)
00034         {
00035                 instance_ = new AdminAuthDialog;
00036         }
00037         return instance_;
00038 }
00039 
00040 AdminAuthDialog::AdminAuthDialog() :
00041         GLWWindow("", 10.0f, 10.0f, 300.0f, 70.0f, eSmallTitle, "")
00042 {
00043         needCentered_ = true;
00044 }
00045 
00046 AdminAuthDialog::~AdminAuthDialog()
00047 {
00048 }
00049 
00050 void AdminAuthDialog::display()
00051 {
00052         GLWWindow::display();
00053 
00054         clear();
00055 
00056         addWidget(
00057                 new GLWLabel(0.0f, 0.0f, LANG_RESOURCE("ADMINAUTH_LINE", "Admin authentication.")), 
00058                 0, SpaceAll, 10.0f);
00059 
00060         GLWPanel *inputPanel = new GLWPanel(0.0f, 0.0f, 0.0f, 0.0f, false, false);
00061 
00062         username_ = 0;
00063         {
00064                 username_ = new GLWTextBox(0.0f, 0.0f, 200.0f);
00065                 inputPanel->addWidget(new GLWLabel(0.0f, 0.0f, LANG_RESOURCE("USER_NAME_LABEL", "User Name :")));
00066                 inputPanel->addWidget(username_, 0, SpaceLeft | SpaceTop, 10.0f);
00067         }
00068         password_ = 0;
00069         {
00070                 password_ = new GLWTextBox(0.0f, 0.0f, 200.0f, LangString(), GLWTextBox::eFlagPassword);
00071                 inputPanel->addWidget(new GLWLabel(0.0f, 0.0f, LANG_RESOURCE("PASSWORD_LABEL", "Password :")));
00072                 inputPanel->addWidget(password_, 0, SpaceLeft | SpaceTop, 10.0f);
00073         }
00074         inputPanel->setGridWidth(2);
00075         inputPanel->setLayout(GLWPanel::LayoutGrid);
00076         addWidget(inputPanel, 0, SpaceAll, 10.0f);
00077 
00078         username_->setCurrent();
00079 
00080         GLWPanel *buttonPanel = new GLWPanel(0.0f, 0.0f, 0.0f, 0.0f, false, false);
00081         GLWButton *cancelButton = new GLWTextButton(LANG_RESOURCE("CANCEL", "Cancel"), 95, 10, 105, this, 
00082                 GLWButton::ButtonFlagCancel | GLWButton::ButtonFlagCenterX);
00083         cancelId_ = cancelButton->getId();
00084         buttonPanel->addWidget(cancelButton, 0, SpaceRight, 10.0f);
00085         GLWButton *okButton = new GLWTextButton(LANG_RESOURCE("OK", "Ok"), 235, 10, 55, this, 
00086                 GLWButton::ButtonFlagOk | GLWButton::ButtonFlagCenterX);
00087         okId_ = okButton->getId();
00088         buttonPanel->addWidget(okButton);
00089         buttonPanel->setLayout(GLWPanel::LayoutHorizontal);
00090         addWidget(buttonPanel, 0, SpaceAll, 10.0f);
00091 
00092         setLayout(GLWPanel::LayoutVerticle);
00093         layout();
00094 }
00095 
00096 void AdminAuthDialog::buttonDown(unsigned int id)
00097 {
00098         GLWWindowManager::instance()->hideWindow(getId());
00099         if (id == okId_)
00100         {
00101                 unsigned int sid = ClientAdminResultHandler::instance()->getSid();
00102                 ComsAdminMessage message(sid, ComsAdminMessage::AdminLogin, 
00103                         username_->getText().c_str(), 
00104                         password_->getText().c_str());
00105                 ComsMessageSender::sendToServer(message);
00106         }
00107 }

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