[Orxonox-commit 198] r2869 - in branches/gui/src/orxonox: gamestates gui
bknecht at orxonox.net
bknecht at orxonox.net
Mon Mar 30 23:34:51 CEST 2009
Author: bknecht
Date: 2009-03-30 21:34:51 +0000 (Mon, 30 Mar 2009)
New Revision: 2869
Modified:
branches/gui/src/orxonox/gamestates/GSGraphics.cc
branches/gui/src/orxonox/gamestates/GSGraphics.h
branches/gui/src/orxonox/gamestates/GSLevel.cc
branches/gui/src/orxonox/gamestates/GSLevel.h
branches/gui/src/orxonox/gamestates/GSMainMenu.cc
branches/gui/src/orxonox/gamestates/GSStandalone.cc
branches/gui/src/orxonox/gamestates/GSStandalone.h
branches/gui/src/orxonox/gui/GUIManager.cc
Log:
Including some features to use only mouse or keys in a GUI, also cleaning up the calls to GUIManager, also trying to show and hide a GUI just by tabbing a key. Anyways, more features to come soonsvn status
Modified: branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSGraphics.cc 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSGraphics.cc 2009-03-30 21:34:51 UTC (rev 2869)
@@ -35,6 +35,7 @@
#include "util/Debug.h"
#include "core/ConfigValueIncludes.h"
#include "core/Clock.h"
+#include "core/ConsoleCommand.h"
#include "core/Core.h"
#include "core/CoreIncludes.h"
#include "core/Game.h"
@@ -109,11 +110,24 @@
guiManager_ = new GUIManager();
guiManager_->initialise(renderWindow);
+ FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI);
+ functor->setObject(this);
+ this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
+ CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
+
+
InputManager::getInstance().requestEnterState("master");
}
void GSGraphics::deactivate()
{
+
+ if (this->ccToggleGUI_)
+ {
+ delete this->ccToggleGUI_;
+ this->ccToggleGUI_ = 0;
+ }
+
masterInputState_->setHandler(0);
InputManager::getInstance().requestDestroyState("master");
delete this->masterKeyBinder_;
@@ -132,6 +146,11 @@
GameMode::setShowsGraphics(false);
}
+ void GSGraphics::toggleGUI()
+ {
+ GUIManager::getInstance().executeCode("toggleGUI()");
+ }
+
/**
@note
A note about the Ogre::FrameListener: Even though we don't use them,
Modified: branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- branches/gui/src/orxonox/gamestates/GSGraphics.h 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSGraphics.h 2009-03-30 21:34:51 UTC (rev 2869)
@@ -46,6 +46,8 @@
void deactivate();
void update(const Clock& time);
+ void toggleGUI();
+
private:
// Window events from WindowEventListener
void windowResized(unsigned int newWidth, unsigned int newHeight);
@@ -60,6 +62,7 @@
KeyBinder* masterKeyBinder_;
SimpleInputState* masterInputState_;
XMLFile* debugOverlay_;
+ ConsoleCommand* ccToggleGUI_;
};
}
Modified: branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSLevel.cc 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSLevel.cc 2009-03-30 21:34:51 UTC (rev 2869)
@@ -55,11 +55,14 @@
AddGameState(GSLevel, "level");
SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
+ SetConsoleCommand(GSLevel, showIngameGUI, true).keybindMode(KeybindMode::OnPress).keybindMode(KeybindMode::OnRelease);
GSLevel::GSLevel(const std::string& name)
: GameState(name)
, keyBinder_(0)
- , inputState_(0)
+ , gameInputState_(0)
+ , guiMouseOnlyInputState_(0)
+ , guiKeysOnlyInputState_(0)
, radar_(0)
, startFile_(0)
, cameraManager_(0)
@@ -86,18 +89,17 @@
if (GameMode::showsGraphics())
{
- {
- FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::toggleGUI);
- functor->setObject(this);
- this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
- CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
- }
-
- inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
+ gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
keyBinder_ = new KeyBinder();
keyBinder_->loadBindings("keybindings.ini");
- inputState_->setHandler(keyBinder_);
+ gameInputState_->setHandler(keyBinder_);
+ guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
+ guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
+
+ guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
+ guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
+
// create the global CameraManager
this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
@@ -137,6 +139,21 @@
}
}
+ void GSLevel::showIngameGUI(bool show)
+ {
+ COUT(0) << "*** Call works with \"" << (show ? "true" : "false") << "\" as param" << std::endl;
+ if (show)
+ {
+ GUIManager::getInstancePtr()->showGUI("inGameTest");
+ InputManager::getInstance().requestEnterState("guiMouseOnly");
+ }
+ else
+ {
+ GUIManager::getInstancePtr()->executeCode("hideGUI(inGameTest)");
+ InputManager::getInstance().requestLeaveState("guiMouseOnly");
+ }
+ }
+
void GSLevel::deactivate()
{
// destroy console commands
@@ -150,11 +167,6 @@
delete this->ccTkeybind_;
this->ccTkeybind_ = 0;
}
- if (this->ccToggleGUI_)
- {
- delete this->ccToggleGUI_;
- this->ccToggleGUI_ = 0;
- }
// this call will delete every BaseObject!
@@ -195,7 +207,9 @@
if (GameMode::showsGraphics())
{
- inputState_->setHandler(0);
+ gameInputState_->setHandler(0);
+ guiMouseOnlyInputState_->setHandler(0);
+ guiKeysOnlyInputState_->setHandler(0);
InputManager::getInstance().requestDestroyState("game");
if (this->keyBinder_)
{
@@ -234,14 +248,6 @@
delete this->startFile_;
}
- void GSLevel::toggleGUI()
- {
- if (GameMode::showsGraphics())
- {
- GUIManager::getInstance().executeCode("toggleGUI()");
- }
- }
-
void GSLevel::keybind(const std::string &command)
{
this->keybindInternal(command, false);
Modified: branches/gui/src/orxonox/gamestates/GSLevel.h
===================================================================
--- branches/gui/src/orxonox/gamestates/GSLevel.h 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSLevel.h 2009-03-30 21:34:51 UTC (rev 2869)
@@ -46,7 +46,7 @@
void deactivate();
void update(const Clock& time);
- void toggleGUI();
+ static void showIngameGUI(bool show);
protected:
void loadLevel();
@@ -57,10 +57,12 @@
void tkeybind(const std::string& command);
void keybindInternal(const std::string& command, bool bTemporary);
- KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings
- SimpleInputState* inputState_;
- Radar* radar_; //!< represents the Radar (not the HUD part)
- XMLFile* startFile_; //!< current hard coded default level
+ KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings
+ SimpleInputState* gameInputState_; //!< input state for normal ingame playing
+ SimpleInputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI
+ SimpleInputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI
+ Radar* radar_; //!< represents the Radar (not the HUD part)
+ XMLFile* startFile_; //!< current hard coded default level
CameraManager* cameraManager_;
LevelManager* levelManager_;
PlayerManager* playerManager_;
@@ -71,7 +73,6 @@
// console commands
ConsoleCommand* ccKeybind_;
ConsoleCommand* ccTkeybind_;
- ConsoleCommand* ccToggleGUI_;
};
}
Modified: branches/gui/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSMainMenu.cc 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSMainMenu.cc 2009-03-30 21:34:51 UTC (rev 2869)
@@ -82,16 +82,14 @@
void GSMainMenu::deactivate()
{
- InputManager::getInstance().requestLeaveState("game");
- InputManager::getInstance().requestDestroyState("game");
+ InputManager::getInstance().requestLeaveState("mainMenu");
+ InputManager::getInstance().requestDestroyState("mainMenu");
if (this->ccStartGame_)
{
delete this->ccStartGame_;
this->ccStartGame_ = 0;
}
-
- GUIManager::getInstance().executeCode("hideGUI()");
}
void GSMainMenu::update(const Clock& time)
Modified: branches/gui/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSStandalone.cc 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSStandalone.cc 2009-03-30 21:34:51 UTC (rev 2869)
@@ -54,10 +54,6 @@
void GSStandalone::activate()
{
GameMode::setIsStandalone(true);
-
- guiManager_ = GUIManager::getInstancePtr();
- // not sure if necessary
- // guiManager_->loadScene("IngameMenu");
}
void GSStandalone::deactivate()
@@ -67,13 +63,5 @@
void GSStandalone::update(const Clock& time)
{
- //Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
- //COUT(0) << "** " << viewport->getCamera()->getSceneManager() << std::endl;
- //guiManager_->testFct();
- //Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
- //guiManager_->showGUI("IngameMenu", viewport->getCamera()->getSceneManager());
-
- // tick CEGUI
- guiManager_->update(time);
}
}
Modified: branches/gui/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- branches/gui/src/orxonox/gamestates/GSStandalone.h 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gamestates/GSStandalone.h 2009-03-30 21:34:51 UTC (rev 2869)
@@ -45,7 +45,6 @@
void update(const Clock& time);
private:
- GUIManager* guiManager_;
};
}
Modified: branches/gui/src/orxonox/gui/GUIManager.cc
===================================================================
--- branches/gui/src/orxonox/gui/GUIManager.cc 2009-03-30 21:26:14 UTC (rev 2868)
+++ branches/gui/src/orxonox/gui/GUIManager.cc 2009-03-30 21:34:51 UTC (rev 2869)
@@ -22,7 +22,7 @@
* Author:
* Reto Grieder
* Co-authors:
- * ...
+ * Benjamin Knecht
*
*/
@@ -194,7 +194,7 @@
{
if (state_ != Uninitialised)
{
- COUT(3) << "Loading GUI " << name << std::endl;
+ //COUT(3) << "Loading GUI " << name << std::endl;
try
{
this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")");
More information about the Orxonox-commit
mailing list