[Orxonox-commit 1723] r6441 - in code/branches/gamestate/src: libraries/core orxonox/overlays

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Jan 3 15:56:34 CET 2010


Author: rgrieder
Date: 2010-01-03 15:56:34 +0100 (Sun, 03 Jan 2010)
New Revision: 6441

Added:
   code/branches/gamestate/src/orxonox/overlays/GUISheet.cc
   code/branches/gamestate/src/orxonox/overlays/GUISheet.h
Modified:
   code/branches/gamestate/src/libraries/core/GUIManager.cc
   code/branches/gamestate/src/libraries/core/GUIManager.h
   code/branches/gamestate/src/orxonox/overlays/CMakeLists.txt
Log:
Added XML loadable wrapper class that can load GUI sheets.

Modified: code/branches/gamestate/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/gamestate/src/libraries/core/GUIManager.cc	2010-01-03 14:55:39 UTC (rev 6440)
+++ code/branches/gamestate/src/libraries/core/GUIManager.cc	2010-01-03 14:56:34 UTC (rev 6441)
@@ -207,6 +207,15 @@
         this->luaState_->doString(str, rootFileInfo_);
     }
 
+    /** Loads a GUI sheet by Lua script
+    @param name
+        The name of the GUI (like the script name, but without the extension)
+    */
+    void GUIManager::loadGUI(const std::string& name)
+    {
+        this->executeCode("loadGUI(\"" + name + "\")");
+    }
+
     /**
     @brief
         Displays specified GUI on screen

Modified: code/branches/gamestate/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/gamestate/src/libraries/core/GUIManager.h	2010-01-03 14:55:39 UTC (rev 6440)
+++ code/branches/gamestate/src/libraries/core/GUIManager.h	2010-01-03 14:56:34 UTC (rev 6441)
@@ -68,6 +68,7 @@
 
         void preUpdate(const Clock& time);
 
+        void loadGUI(const std::string& name);
         static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
         void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
         static void hideGUI(const std::string& name);

Modified: code/branches/gamestate/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/gamestate/src/orxonox/overlays/CMakeLists.txt	2010-01-03 14:55:39 UTC (rev 6440)
+++ code/branches/gamestate/src/orxonox/overlays/CMakeLists.txt	2010-01-03 14:56:34 UTC (rev 6441)
@@ -1,4 +1,5 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  GUISheet.cc
   OrxonoxOverlay.cc
   OverlayGroup.cc
 

Added: code/branches/gamestate/src/orxonox/overlays/GUISheet.cc
===================================================================
--- code/branches/gamestate/src/orxonox/overlays/GUISheet.cc	                        (rev 0)
+++ code/branches/gamestate/src/orxonox/overlays/GUISheet.cc	2010-01-03 14:56:34 UTC (rev 6441)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "GUISheet.h"
+
+#include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(GUISheet);
+
+    GUISheet::GUISheet(BaseObject* creator)
+        : BaseObject(creator)
+        , bShowOnLoad_(false)
+        , bShowCursor_(true)
+        , bHidePrevious_(false)
+    {
+        RegisterObject(GUISheet);
+
+        if (!GameMode::showsGraphics())
+            ThrowException(NoGraphics, "GUISheet construction failed: no graphics");
+    }
+
+    GUISheet::~GUISheet()
+    {
+    }
+
+    void GUISheet::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(GUISheet, XMLPort, xmlElement, mode);
+
+        XMLPortParam(GUISheet, "showOnLoad",   setShowOnLoad,       getShowOnLoad,       xmlElement, mode);
+        XMLPortParam(GUISheet, "showCursor",   setCursorVisibility, getCursorVisibility, xmlElement, mode);
+        XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding,   getPreviousHiding,   xmlElement, mode);
+        XMLPortParam(GUISheet, "script",       setScript,           getScript,           xmlElement, mode);
+    }
+
+    void GUISheet::show()
+    {
+        GUIManager::showGUI(this->script_, this->bHidePrevious_, this->bShowCursor_);
+    }
+
+    void GUISheet::hide()
+    {
+        GUIManager::hideGUI(this->script_);
+    }
+
+    void GUISheet::setScript(const std::string& filename)
+    {
+        this->script_ = filename;
+        GUIManager::getInstance().loadGUI(this->script_);
+        if (this->bShowOnLoad_)
+            this->show();
+    }
+
+    void GUISheet::setCursorVisibility(bool bShow)
+    {
+        this->bShowCursor_ = bShow;
+        // TODO: This call has no effect when already showing!
+    }
+
+    void GUISheet::setPreviousHiding(bool bHide)
+    {
+        this->bHidePrevious_ = bHide;
+        // TODO: This call has no effect when already showing!
+    }
+}


Property changes on: code/branches/gamestate/src/orxonox/overlays/GUISheet.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Added: code/branches/gamestate/src/orxonox/overlays/GUISheet.h
===================================================================
--- code/branches/gamestate/src/orxonox/overlays/GUISheet.h	                        (rev 0)
+++ code/branches/gamestate/src/orxonox/overlays/GUISheet.h	2010-01-03 14:56:34 UTC (rev 6441)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GUISheet_H__
+#define _GUISheet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    //! Simple XML loadable interface to the otherwise Lua coded GUI framework.
+    class _OrxonoxExport GUISheet : public BaseObject
+    {
+    public:
+        GUISheet(BaseObject* creator);
+        ~GUISheet();
+
+        void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void show();
+        void hide();
+
+        void setScript(const std::string& filename);
+        inline const std::string& getScript() const
+            { return this->script_; }
+
+        inline void setShowOnLoad(bool bShow)
+            { this->bShowOnLoad_ = bShow; }
+        inline bool getShowOnLoad() const
+            { return this->bShowOnLoad_; }
+
+        void setCursorVisibility(bool bShow);
+        inline bool getCursorVisibility() const
+            { return this->bShowCursor_; }
+
+        void setPreviousHiding(bool bHide);
+        inline bool getPreviousHiding() const
+            { return this->bHidePrevious_; }
+
+    private:
+        std::string script_;
+        bool bShowOnLoad_;
+        bool bShowCursor_;
+        bool bHidePrevious_;
+  };
+}
+
+#endif /* _GUISheet_H__ */


Property changes on: code/branches/gamestate/src/orxonox/overlays/GUISheet.h
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Orxonox-commit mailing list