[Orxonox-commit 2927] r7627 - in code/branches/releasetodo: data/gui/scripts src/libraries/core

dafrick at orxonox.net dafrick at orxonox.net
Tue Nov 9 21:53:34 CET 2010


Author: dafrick
Date: 2010-11-09 21:53:34 +0100 (Tue, 09 Nov 2010)
New Revision: 7627

Modified:
   code/branches/releasetodo/data/gui/scripts/MultiplayerMenu.lua
   code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua
   code/branches/releasetodo/src/libraries/core/GUIManager.cc
   code/branches/releasetodo/src/libraries/core/GUIManager.h
Log:
Now we have the level description as tooltip. Unforunately for this to work i had to write two additional wrappers for CEGUI lua functions, so I guess it's time to start investigating why some CEGUI functions work in lua and some don't.


Modified: code/branches/releasetodo/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/branches/releasetodo/data/gui/scripts/MultiplayerMenu.lua	2010-11-06 20:52:48 UTC (rev 7626)
+++ code/branches/releasetodo/data/gui/scripts/MultiplayerMenu.lua	2010-11-09 20:53:34 UTC (rev 7627)
@@ -80,6 +80,7 @@
     P.itemList = {}
     local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox"))
     listbox:resetList()
+    orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
     local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
     local index = 0
@@ -104,8 +105,9 @@
         end
         P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
         --TODO: The description as tooltip would be nice.
-        --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k])
+        --local lItem = P.itemList[k]
         --lItem:setTooltipText(v:getDescription())
+        orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
     end
 end
 

Modified: code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua	2010-11-06 20:52:48 UTC (rev 7626)
+++ code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua	2010-11-09 20:53:34 UTC (rev 7627)
@@ -18,6 +18,7 @@
     P.itemList = {}
     local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
     listbox:resetList()
+    orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
     local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
     local index = 0
@@ -44,6 +45,7 @@
         --TODO: The description as tooltip would be nice.
         --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k])
         --lItem:setTooltipText(v:getDescription())
+        orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
     end
 end
 

Modified: code/branches/releasetodo/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/releasetodo/src/libraries/core/GUIManager.cc	2010-11-06 20:52:48 UTC (rev 7626)
+++ code/branches/releasetodo/src/libraries/core/GUIManager.cc	2010-11-09 20:53:34 UTC (rev 7627)
@@ -42,6 +42,8 @@
 #include <CEGUISystem.h>
 #include <CEGUIWindow.h>
 #include <CEGUIWindowManager.h>
+#include <CEGUI/elements/CEGUIListbox.h>
+#include <CEGUI/elements/CEGUIListboxItem.h>
 #include <ogreceguirenderer/OgreCEGUIRenderer.h>
 
 #include "SpecialConfig.h" // Configures the macro below
@@ -439,4 +441,16 @@
     {
         window->subscribeScriptedEvent(event, function);
     }
+
+    void GUIManager::setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& tooltip)
+    {
+        item->setTooltipText(tooltip);
+    }
+
+    void GUIManager::setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled)
+    {
+        listbox->setItemTooltipsEnabled(enabled);
+    }
+
+    
 }

Modified: code/branches/releasetodo/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/releasetodo/src/libraries/core/GUIManager.h	2010-11-06 20:52:48 UTC (rev 7626)
+++ code/branches/releasetodo/src/libraries/core/GUIManager.h	2010-11-09 20:53:34 UTC (rev 7627)
@@ -105,6 +105,8 @@
 
         // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
         static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
+        static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); //tolua_export
+        static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); //tolua_export
 
         static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
 




More information about the Orxonox-commit mailing list