[Orxonox-commit 526] r2184 - in media/gui: layouts scripts

bknecht at orxonox.net bknecht at orxonox.net
Mon May 25 22:08:48 CEST 2009


Author: bknecht
Date: 2009-05-25 22:08:48 +0200 (Mon, 25 May 2009)
New Revision: 2184

Modified:
   media/gui/layouts/PickupInventory.layout
   media/gui/scripts/PickupInventory.lua
   media/gui/scripts/gui.lua
   media/gui/scripts/mainmenu_2.lua
Log:
some fixes for pickupinventory and whole gui implementation

Modified: media/gui/layouts/PickupInventory.layout
===================================================================
--- media/gui/layouts/PickupInventory.layout	2009-05-25 16:40:14 UTC (rev 2183)
+++ media/gui/layouts/PickupInventory.layout	2009-05-25 20:08:48 UTC (rev 2184)
@@ -26,7 +26,7 @@
                 <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
             </Window>
         </Window>
-        
-        <Event Name="WindowUpdate" Function="frmUpdate" />
+
+        <Event Name="WindowUpdate" Function="PickupInventory.update" />
     </Window>
 </GUILayout>

Modified: media/gui/scripts/PickupInventory.lua
===================================================================
--- media/gui/scripts/PickupInventory.lua	2009-05-25 16:40:14 UTC (rev 2183)
+++ media/gui/scripts/PickupInventory.lua	2009-05-25 20:08:48 UTC (rev 2184)
@@ -1,23 +1,34 @@
-layoutPath = "PickupInventory.layout"
+gui = require("gui")
+local P = gui:new() --inherit everything from the gui package
+
+PickupInventory = P
+
+P.filename = "PickupInventory"
+P.layoutString = "PickupInventory.layout"
 
--- variables
-local winMgr = CEGUI.WindowManager:getSingleton()
+P.lastEquipmentCount_ = 0
+P.lastUsableCount_ = 0
+P.currentUsableID_ = 0
 
-local lastEquipmentCount_ = 0
-local lastUsableCount_ = 0
-local currentUsableID_ = 0
-
 -- events
-function frmUpdate(e)
+function P:frmUpdate(e)
     local equipCount = orxonox.PickupInventory:getEquipmentCount()
     local usableCount = orxonox.PickupInventory:getUsableCount()
     
-    if equipCount ~= lastEquipmentCount_ or usableCount ~= lastUsableCount_ then
-        updateTabs()
+    if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
+        self:updateTabs()
     end
+end
+
+function P.update(e)
+    loadedGUIs["PickupInventory"]:frmUpdate(e)
+end
+
+function P.itemClicked(e)
+    loadedGUIs["PickupInventory"]:mItemClicked(e)
 end
 
-function itemClicked(e)
+function P:mItemClicked(e)
     local w = CEGUI.toWindowEventArgs(e).window
     local name = w:getName()
     local t = name:sub(25, 27)
@@ -28,23 +39,25 @@
     end
     
     if t == "use" then
-        if currentUsableID_ >= 0 then
-            winMgr:getWindow("orxonox/Inventory/Title/use/" .. currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
+        if self.currentUsableID_ >= 0 then
+            winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
         end
         orxonox.PickupInventory:selectUsable(tonumber(i))
-        currentUsableID_ = tonumber(i)
+        self.currentUsableID_ = tonumber(i)
         winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
     end
 end
 
 -- methods
-function updateTabs()
+function P:updateTabs()
     local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
     local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
     orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
     orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
     
-    currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
-    lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
-    lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
-end
+    self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
+    self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
+    self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
+end
+
+return PickupInventory

Modified: media/gui/scripts/gui.lua
===================================================================
--- media/gui/scripts/gui.lua	2009-05-25 16:40:14 UTC (rev 2183)
+++ media/gui/scripts/gui.lua	2009-05-25 20:08:48 UTC (rev 2184)
@@ -14,7 +14,6 @@
     local newElement = { window = gui, filename = fname, visible = false } or {}
     setmetatable(newElement, self) -- connects new element with class
     self.__index = self
-    self:init()
     return newElement
 end
 
@@ -35,7 +34,9 @@
 end
 
 function P:load ()
-    return self:new(winMgr:loadWindowLayout(self.layoutString), self.filename)
+    self.window = winMgr:loadWindowLayout(self.layoutString)
+    self:init()
+    return self
 end
 
 return gui or _G[_REQUIREDNAME]

Modified: media/gui/scripts/mainmenu_2.lua
===================================================================
--- media/gui/scripts/mainmenu_2.lua	2009-05-25 16:40:14 UTC (rev 2183)
+++ media/gui/scripts/mainmenu_2.lua	2009-05-25 20:08:48 UTC (rev 2184)
@@ -11,6 +11,7 @@
     listbox = winMgr:getWindow("orxonox/LevelListbox")
     preselect = orxonox.Game:getInstance():getLevel()
     orxonox.GUIManager:getInstance():getLevelList() --levellist variable ist set now
+    table.sort(levellist)
     for k,v in pairs(levellist) do
         item = CEGUI.createListboxTextItem(v)        
         item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")




More information about the Orxonox-commit mailing list