AdminCheckDialog.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/AdminCheckDialog.h>
00022 #include <dialogs/AdminDialog.h>
00023 #include <dialogs/AdminAuthDialog.h>
00024 #include <GLW/GLWWindowManager.h>
00025 #include <client/ClientChannelManager.h>
00026 #include <coms/ComsAdminMessage.h>
00027 #include <coms/ComsMessageSender.h>
00028 
00029 AdminCheckDialog *AdminCheckDialog::instance_ = 0;
00030 
00031 AdminCheckDialog *AdminCheckDialog::instance()
00032 {
00033         if (!instance_)
00034         {
00035                 instance_ = new AdminCheckDialog;
00036         }
00037         return instance_;
00038 }
00039 
00040 AdminCheckDialog::AdminCheckDialog() :
00041         GLWWindow("Admin", 10.0f, 10.0f, 300.0f, 70.0f, eSmallTitle, "Add/Remove players.")
00042 {
00043         ClientAdminResultHandler::instance()->addHandler(this);
00044         needCentered_ = true;
00045 }
00046 
00047 AdminCheckDialog::~AdminCheckDialog()
00048 {
00049 }
00050 
00051 void AdminCheckDialog::display()
00052 {
00053         GLWWindow::display();
00054 
00055         unsigned int sid = ClientAdminResultHandler::instance()->getSid();
00056         ComsAdminMessage message(sid, ComsAdminMessage::AdminLoginLocal, "", "");
00057         ComsMessageSender::sendToServer(message);
00058 
00059         GLWWindowManager::instance()->hideWindow(getId());
00060 }
00061 
00062 void AdminCheckDialog::adminResult(unsigned int sid, ComsAdminMessage::ComsAdminMessageType type)
00063 {
00064         GLWWindowManager::instance()->hideWindow(AdminDialog::instance()->getId());
00065         GLWWindowManager::instance()->hideWindow(AdminAuthDialog::instance()->getId());
00066         if (sid)
00067         {
00068                 ClientChannelManager::instance()->addChannel("general", "admin");
00069                 GLWWindowManager::instance()->showWindow(AdminDialog::instance()->getId());
00070         }
00071         else 
00072         {
00073                 ClientChannelManager::instance()->removeChannel("admin");
00074                 if (type == ComsAdminMessage::AdminLogin ||
00075                         type == ComsAdminMessage::AdminLoginLocal)
00076                 {
00077                         GLWWindowManager::instance()->showWindow(AdminAuthDialog::instance()->getId());
00078                 }
00079         }
00080 }

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