[Orxonox-commit 1496] r6214 - in code/branches/presentation2: data/gui/scripts src/libraries/core src/libraries/core/input

scheusso at orxonox.net scheusso at orxonox.net
Wed Dec 2 20:41:44 CET 2009


Author: scheusso
Date: 2009-12-02 20:41:44 +0100 (Wed, 02 Dec 2009)
New Revision: 6214

Modified:
   code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua
   code/branches/presentation2/src/libraries/core/CMakeLists.txt
   code/branches/presentation2/src/libraries/core/GUIManager.cc
   code/branches/presentation2/src/libraries/core/Game.cc
   code/branches/presentation2/src/libraries/core/Game.h
   code/branches/presentation2/src/libraries/core/IOConsole.cc
   code/branches/presentation2/src/libraries/core/input/KeyBinder.cc
   code/branches/presentation2/src/libraries/core/input/KeyBinder.h
   code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h
Log:
a small fix in IOConsole
some changes in GUI-system and preparation for keybindings menu
fix in menu handling


Modified: code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua	2009-12-02 19:41:44 UTC (rev 6214)
@@ -54,7 +54,11 @@
 -- be sure to set the global variable "filename" before calling this function
 function showGUI(filename, hidePrevious, bCursorVisible)
     if bCursorVisible == nil then
-        bCursorVisible = true
+        if nrOfActiveSheets > 0 then
+            bCursorVisible = cursorVisibility[nrOfActiveSheets]
+        else
+            bCursorVisible = true
+        end
     end
 
     if root == nil then
@@ -169,7 +173,9 @@
 end
 
 function keyESC()
-    if nrOfActiveSheets > 0 then
+    if nrOfActiveSheets == 1 and activeSheets[1] == "MainMenu" then
+        orxonox.CommandExecutor:execute("exit")
+    elseif nrOfActiveSheets > 0 then
         orxonox.CommandExecutor:execute("hideGUI "..activeSheets[nrOfActiveSheets])
     else
         showGUI("InGameMenu")

Modified: code/branches/presentation2/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/presentation2/src/libraries/core/CMakeLists.txt	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/CMakeLists.txt	2009-12-02 19:41:44 UTC (rev 6214)
@@ -90,6 +90,8 @@
     Loader.h
     LuaState.h
     input/InputManager.h
+    input/KeyBinder.h
+    input/KeyBinderManager.h
   DEFINE_SYMBOL
     "CORE_SHARED_BUILD"
   PCH_FILE

Modified: code/branches/presentation2/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/GUIManager.cc	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/GUIManager.cc	2009-12-02 19:41:44 UTC (rev 6214)
@@ -61,6 +61,10 @@
 
 namespace orxonox
 {
+    static void key_esc()
+        { GUIManager::getInstance().keyESC(); }
+    SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
+    
     class CEGUILogger : public CEGUI::DefaultLogger
     {
     public:

Modified: code/branches/presentation2/src/libraries/core/Game.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/Game.cc	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/Game.cc	2009-12-02 19:41:44 UTC (rev 6214)
@@ -57,9 +57,6 @@
     static void stop_game()
         { Game::getInstance().stop(); }
     SetConsoleCommandShortcutExternAlias(stop_game, "exit");
-    static void key_esc()
-        { Game::getInstance().keyESC(); }
-    SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
     static void printFPS()
         { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
     SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");
@@ -330,14 +327,6 @@
             excessSleepTime_ = 50000;
     }
 
-    void Game::keyESC()
-    {
-        if( this->getState("mainMenu") && this->getState("mainMenu")->getActivity().active==true )
-            this->stop();
-        else
-            GUIManager::getInstance().keyESC();
-    }
-
     void Game::stop()
     {
         this->bAbort_ = true;

Modified: code/branches/presentation2/src/libraries/core/Game.h
===================================================================
--- code/branches/presentation2/src/libraries/core/Game.h	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/Game.h	2009-12-02 19:41:44 UTC (rev 6214)
@@ -99,7 +99,6 @@
 
         void run();
         void stop();
-        void keyESC();
 
         static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
 

Modified: code/branches/presentation2/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/IOConsole.cc	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/IOConsole.cc	2009-12-02 19:41:44 UTC (rev 6214)
@@ -259,6 +259,7 @@
         this->cout_.flush();
 
         // Process output written to std::cout
+        std::cout.flush();
         if (!this->origCout_.str().empty())
         {
             this->shell_->addOutputLine(this->origCout_.str(), Shell::None);

Modified: code/branches/presentation2/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinder.cc	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinder.cc	2009-12-02 19:41:44 UTC (rev 6214)
@@ -253,7 +253,10 @@
 
         // Parse bindings and create the ConfigValueContainers if necessary
         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+        {
             it->second->readConfigValue(this->configFile_);
+            this->allCommands_[it->second->bindingString_] = it->second->groupName_ + " " + it->second->name_;
+        }
 
         COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
     }
@@ -268,6 +271,7 @@
             else
                 it->second->configContainer_->set(binding);
             it->second->configContainer_->getValue(&(it->second->bindingString_), it->second);
+            this->allCommands_[it->second->bindingString_] = it->second->groupName_ + " " + it->second->name_;
             return true;
         }
         else
@@ -276,6 +280,25 @@
             return false;
         }
     }
+    
+    /**
+    @brief
+        Return the key name for a specific command
+    */
+    std::string KeyBinder::getBinding(std::string commandName)
+    {
+        COUT(0)<< commandName << endl;
+        if( this->allCommands_.find(commandName) != this->allCommands_.end())
+        {
+            std::string keyname = this->allCommands_[commandName];
+//             while(keyname.find(".")!=keyname.npos)
+//                 keyname.replace(1, keyname.find("."), " ");
+            COUT(0) << keyname << endl;
+            return keyname;
+        }
+        else
+            return "";
+    }
 
     /**
     @brief

Modified: code/branches/presentation2/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinder.h	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinder.h	2009-12-02 19:41:44 UTC (rev 6214)
@@ -42,8 +42,10 @@
 #include "InputCommands.h"
 #include "JoyStickQuantityListener.h"
 
+// tolua_begin
 namespace orxonox
 {
+    // tolua_end
     /**
     @brief
         Maps mouse, keyboard and joy stick input to command strings and executes them.
@@ -53,14 +55,16 @@
         You cannot change the filename because the KeyBinderManager maps these filenames to the
         KeyBinders. If you need to load other bindings, just create a new one.
     */
-    class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener
-    {
+    class _CoreExport KeyBinder // tolua_export
+        : public InputHandler, public JoyStickQuantityListener
+    { // tolua_export
     public:
         KeyBinder (const std::string& filename);
         virtual ~KeyBinder();
 
         void clearBindings();
         bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
+        std::string getBinding(std::string commandName); //tolua_export
         const std::string& getBindingsFilename()
             { return this->filename_; }
         void setConfigValues();
@@ -129,6 +133,8 @@
         std::map<std::string, Button*> allButtons_;
         //! Pointer list with all half axes
         std::vector<HalfAxis*> allHalfAxes_;
+        //! Maps input commands to all Button names, including half axes
+        std::map<std::string, std::string> allCommands_;
 
         /**
         @brief
@@ -173,7 +179,7 @@
         //##### Constant config variables #####
         // Use some value at about 1000. This can be configured with mouseSensitivity_ anyway.
         static const int mouseClippingSize_ = 1024;
-    };
+    };// tolua_export
 
 
     inline void KeyBinder::buttonPressed (const KeyEvent& evt)
@@ -218,6 +224,6 @@
         for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
             mouseAxes_[i].relVal_ = 0.0f;
     }
-}
+}// tolua_export
 
 #endif /* _KeyBinder_H__ */

Modified: code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h	2009-12-02 19:00:19 UTC (rev 6213)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h	2009-12-02 19:41:44 UTC (rev 6214)
@@ -36,8 +36,8 @@
 #include "util/Singleton.h"
 #include "core/OrxonoxClass.h"
 
-namespace orxonox
-{
+namespace orxonox //tolua_export
+{ //tolua_export
     /**
     @brief
         Handles the KeyBinders and supplies them throughout the game.
@@ -50,17 +50,18 @@
         You are not forced to use the KeyBinder imposed by getCurrent(). But be aware that "keybind"
         will not work as expected!
     */
-    class _CoreExport KeyBinderManager : public Singleton<KeyBinderManager>, public OrxonoxClass
-    {
+    class _CoreExport KeyBinderManager //tolua_export
+        : public Singleton<KeyBinderManager>, public OrxonoxClass
+    { //tolua_export
         friend class Singleton<KeyBinderManager>;
     public:
         KeyBinderManager();
         ~KeyBinderManager();
         void setConfigValues();
 
+        static KeyBinderManager& getInstance() { return Singleton<KeyBinderManager>::getInstance(); } //tolua_export
         //! Returns the currently selected KeyBinder
-        KeyBinder* getCurrent()
-            { return this->currentBinder_; }
+        KeyBinder* getCurrent() { return this->currentBinder_; } //tolua_export
         //! Like getCurrent(), but returns it as InputHandler* (so you don't have to include KeyBinder.h)
         InputHandler* getCurrentAsHandler();
         //! Selects the current KeyBinder and creates it if not yet loaded.
@@ -114,7 +115,7 @@
         std::string command_;                        //! Stores the command received by (t)keybind
 
         static KeyBinderManager* singletonPtr_s;
-    };
-}
+    }; //tolua_export
+} //tolua_export
 
 #endif /* _KeyBinderManager_H__ */




More information about the Orxonox-commit mailing list