2
// C++ Implementation: Quit
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2005
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
28
// #include "../EmberOgre.h"
29
#include "main/Application.h"
30
#include <elements/CEGUIPushButton.h>
32
#include "framework/ConsoleBackend.h"
33
#include "../GUIManager.h"
34
#include "services/input/Input.h"
39
Quit::Quit() : SoftQuit("softquit", this, "Display a quit confirmation window.")
48
void Quit::buildWidget()
51
loadMainSheet("Quit.layout", "Quit/");
53
Ember::Application::getSingleton().EventRequestQuit.connect(sigc::mem_fun(*this, &Quit::EmberOgre_RequestQuit));
55
CEGUI::PushButton* yesButton = static_cast<CEGUI::PushButton*>(getWindow("YesButton"));
56
CEGUI::PushButton* noButton = static_cast<CEGUI::PushButton*>(getWindow("NoButton"));
59
BIND_CEGUI_EVENT(noButton, CEGUI::PushButton::EventClicked, Quit::No_Click );
62
BIND_CEGUI_EVENT(yesButton, CEGUI::PushButton::EventClicked, Quit::Yes_Click );
65
registerConsoleVisibilityToggleCommand("quit");
68
mMainWindow->setVisible(false);
71
bool Quit::Yes_Click(const CEGUI::EventArgs& args)
73
Ember::Application::getSingleton().quit();
77
bool Quit::No_Click(const CEGUI::EventArgs& args)
79
mMainWindow->setVisible(false);
84
void Quit::EmberOgre_RequestQuit(bool& handled)
87
//if the window system twice requests a quit, do it
88
if (mMainWindow->isVisible()) {
89
Ember::Application::getSingleton().quit();
97
mMainWindow->activate();
98
mMainWindow->moveToFront();
99
mMainWindow->setVisible(true);
101
Ember::Input::getSingleton().setInputMode(Ember::Input::IM_GUI);
102
//mMainWindow->setModalState(true);
107
//mMainWindow->setModalState(false);
111
void Quit::runCommand(const std::string &command, const std::string &args)
113
if(SoftQuit == command)
117
Widget::runCommand(command, args);