Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6711 for code/trunk/data/gui


Ignore:
Timestamp:
Apr 13, 2010, 10:16:10 AM (15 years ago)
Author:
dafrick
Message:

Merged pickup4 branch back to trunk.

Location:
code/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/gui/layouts/PickupInventory.layout

    r6417 r6711  
    1 <?xml version="1.0" encoding="UTF-8" ?>
    2 <GUILayout>
    3     <Window Type="TaharezLook/FrameWindow" Name="orxonox/Inventory">
    4         <Property Name="UnifiedMinSize" Value="{{0.0,385},{0.0,200}}" />
    5         <Property Name="UnifiedMaxSize" Value="{{0.0,385},{0.0,200}}" />
    6         <Property Name="UnifiedPosition" Value="{{0.5,-100},{0.5,-85}}" />
    7         <Property Name="UnifiedSize" Value="{{0.0,385},{0.0,200}}" />
    8         <Property Name="Text" Value="Inventory" />
    9         <Property Name="CloseButtonEnabled" Value="False" />
     1<?xml version="1.0" encoding="UTF-8"?>
    102
    11         <Window Type="TaharezLook/TabControl" Name="orxonox/Inventory/TabControl" >
    12             <Property Name="Tooltip" Value="Inventory" />
    13             <Property Name="TabHeight" Value="{0,-1}" />
     3<GUILayout >
     4    <Window Type="DefaultWindow" Name="orxonox/PickupInventory/Background" >
     5        <Property Name="InheritsAlpha" Value="False" />
     6        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     7        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
     8        <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/PickupInventory" >
     9            <Property Name="Text" Value="Pickup Inventory" />
     10            <Property Name="Alpha" Value="0.8" />
     11            <Property Name="InheritsAlpha" Value="False" />
     12            <Property Name="HorzFormatting" Value="HorzCentred" />
    1413            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    15             <Property Name="TabPanePosition" Value="Bottom" />
    16             <Property Name="UnifiedAreaRect" Value="{{0,10},{0,30},{1,-10},{1,-10}}" />
    17 
    18             <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabEquipment">
    19                 <Property Name="Text" Value="Equipment" />
    20                 <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
    21                 <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
    22             </Window>
    23             <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabUsable">
    24                 <Property Name="Text" Value="Usable" />
    25                 <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
    26                 <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/>
     14            <Property Name="VertFormatting" Value="TopAligned" />
     15            <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.15,0},{0.85,0},{0.8,0}}" />
     16            <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/Wrapper" >
     17                <Property Name="TextColours" Value="FF4444FF" />
     18                <Property Name="InheritsAlpha" Value="False" />
     19                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     20                <Property Name="HorzFormatting" Value="HorzCentred" />
     21                <Property Name="VertFormatting" Value="TopAligned" />
     22                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
     23                <Window Type="TaharezLook/ScrollablePane" Name="orxonox/PickupInventory/Inventory" >
     24                    <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
     25                    <Property Name="HorzStepSize" Value="0.005" />
     26                    <Property Name="VertStepSize" Value="0.005" />
     27                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     28                    <Property Name="HorzOverlapSize" Value="0.01" />
     29                    <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" />
     30                    <Property Name="VertOverlapSize" Value="0.01" />
     31                    <Property Name="HorzScrollPosition" Value="0" />
     32                    <Property Name="VertScrollPosition" Value="0" />
     33                </Window>
    2734            </Window>
    2835        </Window>
    29 
    30         <Event Name="WindowUpdate" Function="PickupInventory.update" />
     36        <Window Type="TaharezLook/Button" Name="orxonox/PickupInventory/InventoryBackButton" >
     37            <Property Name="Text" Value="Back" />
     38            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     39            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8350,0},{0.6,0},{0.8800,0}}" />
     40            <Event Name="Clicked" Function="PickupInventory.InventoryBackButton_clicked"/>
     41        </Window>
    3142    </Window>
    3243</GUILayout>
  • code/trunk/data/gui/schemes/OrxonoxGUIScheme.scheme

    r5951 r6711  
    22<GUIScheme Name="OrxonoxGUI">
    33    <Imageset Name="MainMenuBackground" Filename="MainMenuBackground.imageset"/>
     4    <Imageset Name="PickupInventory" Filename="PickupInventory.imageset"/>
    45</GUIScheme>
  • code/trunk/data/gui/scripts/InitialiseGUI.lua

    r6417 r6711  
    223223end
    224224
     225--TODO: Needed?
    225226function test(e)
    226227    debug(0, "Blubb")
  • code/trunk/data/gui/scripts/PickupInventory.lua

    r6417 r6711  
    33BasicGUI = require("BasicGUI")
    44local P = BasicGUI:new() --inherit everything from the gui package
     5
    56if _REQUIREDNAME == nil then
    67    PickupInventory = P
     
    1213P.layoutString = "PickupInventory.layout"
    1314
    14 P.lastEquipmentCount_ = 0
    15 P.lastUsableCount_ = 0
    16 P.currentUsableID_ = 0
    17 
    18 -- events
    19 function P:frmUpdate(e)
    20     local equipCount = orxonox.PickupInventory:getEquipmentCount()
    21     local usableCount = orxonox.PickupInventory:getUsableCount()
    22 
    23     if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
    24         self:updateTabs()
    25     end
    26 end
    27 
    28 function P.update(e)
    29     loadedGUIs["PickupInventory"]:frmUpdate(e)
    30 end
    31 
    32 function P.itemClicked(e)
    33     loadedGUIs["PickupInventory"]:mItemClicked(e)
    34 end
    35 
    36 function P:mItemClicked(e)
    37     local w = CEGUI.toWindowEventArgs(e).window
    38     local name = w:getName()
    39     local t = name:sub(25, 27)
    40     local i = name:sub(29)
    41 
    42     if t == "equ" then
    43 
    44     end
    45 
    46     if t == "use" then
    47         if self.currentUsableID_ >= 0 then
    48             winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
     15P.carrierList = {}
     16P.wrapper = nil
     17P.detailsWindows = {}
     18
     19function P.init()
     20    carrierList = {}
     21end
     22
     23function P.show()
     24    P.window:show() -- TODO: Do this through parent...
     25    P.visible = true
     26   
     27    P.createInventory()
     28
     29end
     30
     31function P.hide()
     32    P.cleanup()
     33   
     34end
     35
     36function P.update()
     37    P.cleanup()
     38   
     39    P.createInventory()
     40end
     41
     42function P.createInventory()
     43    local pickupManager = orxonox.PickupManager:getInstance()
     44    local carrier = pickupManager:getPawn()
     45   
     46    local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
     47    P.wrapper = winMgr:createWindow("TaharezLook/ScrollablePane", "orxonox/PickupInventory/Inventory/Wrapper")
     48    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
     49    root:addChildWindow(P.wrapper)
     50   
     51    P.carrierList = {}
     52   
     53    --Design parameters:
     54    local space = 15
     55   
     56    P.getCarrierList(carrier)
     57    local offset = 0
     58    for k,v in pairs(P.carrierList) do
     59        local window = P.createCarrierBox(v,k)
     60        window:setYPosition(CEGUI.UDim(0,offset))
     61        offset = offset + window:getHeight():asAbsolute(1) + space
     62        P.wrapper:addChildWindow(window)
     63    end
     64end
     65
     66function P.getCarrierList(carrier)
     67
     68    -- TODO: Test for nil or 0?
     69    if carrier == nil then
     70        return
     71    end
     72   
     73    table.insert(P.carrierList, carrier)
     74   
     75    local numCarriers = orxonox.PickupManager:getInstance():getNumCarrierChildren(carrier)
     76    if numCarriers == 0 then
     77        return
     78    end
     79   
     80    for i=0,numCarriers-1,1 do
     81        local child = orxonox.PickupManager:getInstance():getCarrierChild(i, carrier)
     82        if child ~= nil then
     83            P.getCarrierList(child)
    4984        end
    50         orxonox.PickupInventory:selectUsable(tonumber(i))
    51         self.currentUsableID_ = tonumber(i)
    52         winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
    53     end
    54 end
    55 
    56 -- methods
    57 function P:updateTabs()
    58     local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
    59     local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
    60     orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
    61     orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
    62 
    63     self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
    64     self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
    65     self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
     85    end
     86end
     87
     88function P.createCarrierBox(carrier, index)
     89
     90    local name = "orxonox/PickupInventory/Carrier" .. index
     91       
     92    --Design parameters:
     93    local imageHeight = 50
     94    local textHeight = 30
     95    local horizontalOffset = 20
     96    local buttonWidth = 85
     97   
     98    local offset = 0
     99
     100    local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Box")
     101    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0)))
     102    box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0)))
     103   
     104    offset = offset+textHeight
     105    local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title")
     106    title:setText(carrier:getCarrierName())
     107    title:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, offset)))
     108    title:setProperty("FrameEnabled", "set:False")
     109    box:addChildWindow(title)
     110   
     111    local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
     112    for i=0,numPickups-1,1 do
     113        local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier)
     114       
     115        local item = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i)
     116        item:setSize(CEGUI.UVector2(CEGUI.UDim(1, -horizontalOffset), CEGUI.UDim(0, imageHeight)))
     117        item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, offset)))
     118        box:addChildWindow(item)
     119        offset = offset + imageHeight+5
     120       
     121        local image = winMgr:createWindow("TaharezLook/StaticImage", name .. "/Box/Pickup" .. i .. "/Image")
     122        image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
     123        image:setProperty("BackgroundEnabled", "set:False")
     124        image:setProperty("FrameEnabled", "set:True")
     125        image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageHeight), CEGUI.UDim(0, imageHeight)))
     126        item:addChildWindow(image)
     127       
     128        local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i .. "/Title")
     129        title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageHeight+5), CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     130        title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, textHeight)))
     131        title:setText(pickup:getPickupName())
     132        title:setProperty("FrameEnabled", "set:False")
     133        item:addChildWindow(title)
     134       
     135        local useButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/UseButton")
     136        useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+10),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     137        useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
     138        useButton:setText("use")
     139        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.filename .. ".InventoryUseButton_clicked")
     140        item:addChildWindow(useButton)
     141       
     142        local dropButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/DropButton")
     143        dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+15+buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     144        dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
     145        dropButton:setText("drop")
     146        orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.filename .. ".InventoryDropButton_clicked")
     147        item:addChildWindow(dropButton)
     148       
     149        local detailsButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/DetailsButton")
     150        detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+20+2*buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     151        detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
     152        detailsButton:setText("details")
     153        orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.filename .. ".InventoryDetailsButton_clicked")
     154        item:addChildWindow(detailsButton)
     155    end
     156   
     157    box:setHeight(CEGUI.UDim(0,offset))
     158   
     159    return box
     160end
     161
     162function P.cleanup()
     163    if P.wrapper ~= nil then
     164        winMgr:destroyWindow(P.wrapper)
     165    end
     166   
     167    --Destroy details windows.
     168    for k,v in pairs(P.detailsWindows) do
     169        if v ~= nil then
     170            winMgr:destroyWindow(v)
     171        end
     172    end
     173end
     174
     175function P.windowToCarrierHelper(e)
     176    local we = CEGUI.toWindowEventArgs(e)
     177    local name = we.window:getName()
     178
     179    local match = string.gmatch(name, "%d+")
     180    local carrierNr = tonumber(match())
     181    local pickupNr = tonumber(match())
     182
     183    local arguments = {}
     184    arguments[1] = carrierNr
     185    arguments[2] = pickupNr
     186    return arguments
     187end
     188
     189function P.createDetailsWindow(pickupIndex, carrierIndex)
     190    local carrier = P.carrierList[carrierIndex]
     191    local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(pickupIndex, carrier)
     192   
     193    local headerOffset = 35
     194    --Design parameters
     195    local titleHeight = 30
     196    local imageSize = 100
     197    local buttonWidth = 85
     198   
     199    local name = "orxonox/PickupInventory/Carrier" .. carrierIndex .. "/Pickup" .. pickupIndex .. "/Details" .. P.getNewDetailNumber()
     200   
     201    local window = winMgr:createWindow("TaharezLook/FrameWindow", name)
     202    window:setSize(CEGUI.UVector2(CEGUI.UDim(0.5,0),CEGUI.UDim(0.4,0)))
     203    orxonox.GUIManager:subscribeEventHelper(window, "CloseClicked", P.filename .. ".closeDetailWindow")
     204   
     205    local root = winMgr:getWindow("orxonox/PickupInventory/Background")
     206    root:addChildWindow(window)
     207   
     208    local wrapper = winMgr:createWindow("DefaultWindow", name .. "/Wrapper")
     209    wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1, -20),CEGUI.UDim(1, -50)))
     210    wrapper:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10),CEGUI.UDim(0, 40)))
     211    window:addChildWindow(wrapper)
     212   
     213    local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title")
     214    title:setText(pickup:getPickupName())
     215    title:setHeight(CEGUI.UDim(0, titleHeight))
     216    title:setProperty("FrameEnabled", "set:False")
     217    title:setProperty("BackgroundEnabled", "set:False")
     218    wrapper:addChildWindow(title)
     219   
     220    local image = winMgr:createWindow("TaharezLook/StaticImage", name .. "/Image")
     221    image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
     222    image:setProperty("BackgroundEnabled", "set:False")
     223    image:setProperty("FrameEnabled", "set:True")
     224    image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageSize), CEGUI.UDim(0, imageSize)))
     225    image:setYPosition(CEGUI.UDim(0, titleHeight + 5))
     226    wrapper:addChildWindow(image)
     227   
     228    local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Description")
     229    box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(imageSize + 10)),CEGUI.UDim(1, -(titleHeight + 5 + titleHeight + 20))))
     230    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize + 10),CEGUI.UDim(0, titleHeight + 5)))
     231    local description = winMgr:createWindow("TaharezLook/StaticText", name .. "/Description/Text")
     232    description:setText(pickup:getPickupDescription())
     233    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
     234    description:setProperty("VertFormatting", "TopAligned")
     235    box:addChildWindow(description)
     236    wrapper:addChildWindow(box)
     237   
     238    local useButton = winMgr:createWindow("TaharezLook/Button", name .. "/UseButton")
     239    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10),CEGUI.UDim(1, -40)))
     240    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
     241    useButton:setText("use")
     242    orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.filename .. ".InventoryUseButton_clicked")
     243    wrapper:addChildWindow(useButton)
     244   
     245    local dropButton = winMgr:createWindow("TaharezLook/Button", name .. "/DropButton")
     246    dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10+buttonWidth+10),CEGUI.UDim(1, -40)))
     247    dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
     248    dropButton:setText("drop")
     249    orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.filename .. ".InventoryDropButton_clicked")
     250    wrapper:addChildWindow(dropButton)
     251   
     252    table.insert(P.detailsWindows, window)
     253   
     254end
     255
     256function P.getNewDetailNumber()
     257    local number = table.getn(P.detailsWindows)
     258    for k,v in pairs(P.detailsWindows) do
     259        if v == nil then
     260            number = k-1
     261        end
     262    end
     263    return number
     264end
     265
     266function P.InventoryUseButton_clicked(e)
     267    local arguments = P.windowToCarrierHelper(e)
     268    orxonox.PickupManager:getInstance():usePickup(arguments[2], P.carrierList[arguments[1]], true)
     269end
     270
     271function P.InventoryDropButton_clicked(e)
     272    local arguments = P.windowToCarrierHelper(e)
     273    orxonox.PickupManager:getInstance():dropPickup(arguments[2], P.carrierList[arguments[1]])
     274end
     275
     276function P.InventoryDetailsButton_clicked(e)
     277    local arguments = P.windowToCarrierHelper(e)
     278    P.createDetailsWindow(arguments[2], arguments[1])
     279end
     280
     281function P.closeDetailWindow(e)
     282    --Get some numbers from the window
     283    local we = CEGUI.toWindowEventArgs(e)
     284    local name = we.window:getName()
     285    local match = string.gmatch(name, "%d+")
     286    local carrierNr = tonumber(match())
     287    local pickupNr = tonumber(match())
     288    local detailNr = tonumber(match())
     289   
     290    local window = P.detailsWindows[detailNr+1]
     291    winMgr:destroyWindow(window)
     292    P.detailsWindows[detailNr+1] = nil
     293end
     294
     295function P.InventoryBackButton_clicked(e)
     296    hideGUI("PickupInventory")
    66297end
    67298
  • code/trunk/data/gui/scripts/QuestGUI.lua

    r6417 r6711  
    1111
    1212function P:show()
    13     self.window:show() -- TDO: Do this through parent...
     13    self.window:show() -- TODO: Do this through parent...
    1414    self.visible = true
    1515
Note: See TracChangeset for help on using the changeset viewer.