[Orxonox-commit 418] r2151 - in media: gui/layouts gui/scripts levels

danielh at orxonox.net danielh at orxonox.net
Wed May 20 20:55:23 CEST 2009


Author: danielh
Date: 2009-05-20 20:55:23 +0200 (Wed, 20 May 2009)
New Revision: 2151

Modified:
   media/gui/layouts/PickupInventory.layout
   media/gui/scripts/PickupInventory.lua
   media/levels/pickuptest.oxw
Log:
Moved most of the inventory logic to C++ (slight speedup, but still slow)

Modified: media/gui/layouts/PickupInventory.layout
===================================================================
--- media/gui/layouts/PickupInventory.layout	2009-05-20 16:47:33 UTC (rev 2150)
+++ media/gui/layouts/PickupInventory.layout	2009-05-20 18:55:23 UTC (rev 2151)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <GUILayout>
     <Window Type="TaharezLook/FrameWindow" Name="orxonox/Inventory">
-        <Property Name="UnifiedMinSize" Value="{{0.4,0},{0.3,0}}" />
-        <Property Name="UnifiedMaxSize" Value="{{0.8,0},{0.8,0}}" />
-        <Property Name="UnifiedPosition" Value="{{0.3,0},{0.35,0}}" />
-        <Property Name="UnifiedSize" Value="{{0.4,0},{0.3,0}}" />
+        <Property Name="UnifiedMinSize" Value="{{0.0,385},{0.0,200}}" />
+        <Property Name="UnifiedMaxSize" Value="{{0.0,385},{0.0,200}}" />
+        <Property Name="UnifiedPosition" Value="{{0.5,-100},{0.5,-85}}" />
+        <Property Name="UnifiedSize" Value="{{0.0,385},{0.0,200}}" />
         <Property Name="Text" Value="Inventory" />
         <Property Name="CloseButtonEnabled" Value="False" />
 
@@ -17,37 +17,13 @@
             
             <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabEquipment">
                 <Property Name="Text" Value="Equipment" />
-                <Property Name="UnifiedPosition" Value="{{0,0},{0,0}}"/>
-                <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
-                
-                <Window Type="TaharezLook/Button" Name="orxonox/Inventory/equipmentButton/1">
-                    <Property Name="UnifiedPosition" Value="{{0.0,6},{0.0,6}}"/>
-                    <Property Name="UnifiedSize" Value="{{0.2,-12},{0.2,-12}}"/>
-                    <Property Name="Text" Value="1"/>
-                </Window>
-                <Window Type="TaharezLook/Button" Name="orxonox/Inventory/equipmentButton/2">
-                    <Property Name="UnifiedPosition" Value="{{0.2,6},{0.0,6}}"/>
-                    <Property Name="UnifiedSize" Value="{{0.2,-12},{0.2,-12}}"/>
-                    <Property Name="Text" Value="2"/>
-                </Window>
-                <Window Type="TaharezLook/Button" Name="orxonox/Inventory/equipmentButton/3">
-                    <Property Name="UnifiedPosition" Value="{{0.4,6},{0.0,6}}"/>
-                    <Property Name="UnifiedSize" Value="{{0.2,-12},{0.2,-12}}"/>
-                    <Property Name="Text" Value="3"/>
-                </Window>
-                <Window Type="TaharezLook/Button" Name="orxonox/Inventory/equipmentButton/4">
-                    <Property Name="UnifiedPosition" Value="{{0.6,6},{0.0,6}}"/>
-                    <Property Name="UnifiedSize" Value="{{0.2,-12},{0.2,-12}}"/>
-                    <Property Name="Text" Value="4"/>
-                </Window>
-                <Window Type="TaharezLook/Button" Name="orxonox/Inventory/equipmentButton/5">
-                    <Property Name="UnifiedPosition" Value="{{0.8,6},{0.0,6}}"/>
-                    <Property Name="UnifiedSize" Value="{{0.2,-12},{0.2,-12}}"/>
-                    <Property Name="Text" Value="5"/>
-                </Window>
+                <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
+                <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
             </Window>
             <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabUsable">
                 <Property Name="Text" Value="Usable" />
+                <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
+                <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
             </Window>
             
             <Event Name="TabSelectionChanged" Function="tabChanged" />

Modified: media/gui/scripts/PickupInventory.lua
===================================================================
--- media/gui/scripts/PickupInventory.lua	2009-05-20 16:47:33 UTC (rev 2150)
+++ media/gui/scripts/PickupInventory.lua	2009-05-20 18:55:23 UTC (rev 2151)
@@ -1,14 +1,56 @@
 layoutPath = "PickupInventory.layout"
 
+-- variables
+local winMgr = CEGUI.WindowManager:getSingleton()
+local lastEquipmentCount_ = 0
+local lastUsableCount_ = 0
+
+local currentUsableID_ = -1
+local lastUsedEquipID_ = 0
+local lastUsedUsableID_ = 0
+
 -- events
 function tabChanged(e)
     local we = CEGUI.toWindowEventArgs(e)
     orxonox.PickupInventory:tabChanged(we.window)
 end
 function frmUpdate(e)
+    local equipCount = orxonox.PickupInventory:getEquipmentCount()
+    local usableCount = orxonox.PickupInventory:getUsableCount()
     
+    if equipCount ~= lastEquipmentCount_ or usableCount ~= lastUsableCount_ then
+        updateTabs()
+    end
 end
 
-function noButtonClicked(e)
-    orxonox.PickupInventory:toggleInventory()
+function itemClicked(e)
+    local w = CEGUI.toWindowEventArgs(e).window
+    local name = w:getName()
+    local t = name:sub(25, 27)
+    local i = name:sub(29)
+    
+    if t == "equ" then
+        
+    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")
+        end
+        orxonox.PickupInventory:selectUsable(tonumber(i))
+        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()
+    local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
+    local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
+    orxonox.PickupInventory:clearInventory(winMgr, lastEquipmentCount_, lastUsableCount_)
+    orxonox.PickupInventory:updateTabs(winMgr, eqWin, usWin)
+    
+    currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
+    lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
+    lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
+end

Modified: media/levels/pickuptest.oxw
===================================================================
--- media/levels/pickuptest.oxw	2009-05-20 16:47:33 UTC (rev 2150)
+++ media/levels/pickuptest.oxw	2009-05-20 18:55:23 UTC (rev 2151)
@@ -14,11 +14,11 @@
   >
     
     <Template name="jumpTest" baseclass="Jump">
-        <Jump velocity="0,0,500" jumpsAvailable="10" />
+        <Jump velocity="0,0,500" jumpsAvailable="1" guiImage="decal.jpg" guiText="TEST" />
     </Template>
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
 
-    <PickupSpawner item="jumpTest" triggerDistance="20" respawnTime="10" position="100, 0, 0">
+    <PickupSpawner item="jumpTest" triggerDistance="20" respawnTime="2" position="100, 0, 0">
         <attached>
             <Model mesh="sphere.mesh" scale="3.0" />
             <Billboard material="Examples/Flare" colour="0.5, 1.0, 0.3" scale="0.5" />




More information about the Orxonox-commit mailing list