Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2017, 3:36:57 PM (7 years ago)
Author:
rrogge
Message:

Dialogfenster geht auf :D

Location:
code/branches/Dialogue_FS17/data
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua

    r11401 r11406  
    3535-- Dialogue.lua
    3636
    37 local P = createMenuSheet("PickupInventory")
     37local P = createMenuSheet("Dialogue")
    3838
    3939P.wrapper = nil
     
    7575
    7676    -- Update opened detail windows.
    77     for k,v in pairs(P.detailsWindows) do
    78         if v ~= nil then
    79             local pickup = P.detailPickups[k]
    80             if pickup ~= nil and pickup ~= 0 then
    81                 local useButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/UseButton")
    82                 local dropButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/DropButton")
    83                 if orxonox.PickupManager:getInstance():isValidPickup(pickup.pickup) == false then
    84                     useButton:setEnabled(false)
    85                     dropButton:setEnabled(false)
    86                     P.detailPickups[k] = nil
    87                 else
    88                     useButton:setEnabled(true)
    89                     if pickup.inUse == true then
    90                         useButton:setText("unuse")
    91                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    92                         if pickup.usable == false then
    93                             useButton:setEnabled(false)
    94                         end
    95                     else
    96                         useButton:setText("use")
    97                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    98                         if pickup.unusable == false then
    99                             useButton:setEnabled(false)
    100                         end
    101                     end
    102 
    103                     if pickup.pickedUp == false then
    104                         useButton:setEnabled(false)
    105                         dropButton:setEnabled(false)
    106                         P.detailPickups[k] = nil
    107                     end
    108                 end
    109             end
    110         end
    111     end
     77   
    11278
    11379    -- Update main inventory.
     
    11985
    12086function P.createInventory()
    121     local pickupManager = orxonox.PickupManager:getInstance()
     87    local pickupManager = orxonox.DialogueManager:getInstance()
    12288   
    123     local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
    124     P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/PickupInventory/Inventory/Wrapper")
     89    local root = winMgr:getWindow("orxonox/Dialogue/Inventory")
     90    local question = orxonox.DialogueManager:getInstance():getquestion()
     91    root:setText(question)
     92    P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
    12593    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
    12694    root:addChildWindow(P.wrapper)
    12795   
    128     P.pickupsList = {}
    129 
    130     local numPickups = pickupManager:getNumPickups()
    131     local counter = 1
    132     local offset = 0
    133     while counter <= numPickups do
    134         local pickup = pickupManager:popPickup()
    135         table.insert(P.pickupsList, pickup)
    136         local window = P.createPickupEntry(counter, pickup)
    137         window:setYPosition(CEGUI.UDim(0,offset))
    138         offset = offset + window:getHeight():asAbsolute(1)
    139         P.wrapper:addChildWindow(window)
    140         counter = counter + 1
    141     end
     96   
    14297
    14398end
    14499
    145 function P.createPickupEntry(index, pickup)
    146     local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName)
    147100
    148     local name = "orxonox/PickupInventory/Box/Pickup" .. index
    149 
    150     local item = winMgr:createWindow("MenuWidgets/StaticText", name)
    151     item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
    152     item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
    153 
    154     local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    155     image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    156     image:setProperty("BackgroundEnabled", "set:False")
    157     image:setProperty("FrameEnabled", "set:True")
    158     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight), CEGUI.UDim(0, P.imageHeight)))
    159     item:addChildWindow(image)
    160 
    161     local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    162     title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight+5), CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    163     title:setSize(CEGUI.UVector2(CEGUI.UDim(0.3, 0), CEGUI.UDim(0, P.textHeight)))
    164     title:setText(representation:getPickupName())
    165     title:setProperty("FrameEnabled", "set:False")
    166     item:addChildWindow(title)
    167 
    168     local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    169     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+10),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    170     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    171     if pickup.inUse == false then
    172         useButton:setText("use")
    173         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    174         if pickup.usable == false then
    175             useButton:setEnabled(false)
    176         end
    177     else
    178         useButton:setText("unuse")
    179         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
    180         if pickup.unusable == false then
    181             useButton:setEnabled(false)
    182         end
    183     end
    184     item:addChildWindow(useButton)
    185 
    186     local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    187     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+15+P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    188     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    189     dropButton:setText("drop")
    190     orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
    191     item:addChildWindow(dropButton)
    192 
    193     local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DetailsButton")
    194     detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+20+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    195     detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    196     detailsButton:setText("details")
    197     orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
    198     item:addChildWindow(detailsButton)
    199 
    200     return item
    201 end
    202101
    203102function P.cleanup(destroyDetails)
     
    217116end
    218117
    219 function P.windowToPickupHelper(e)
    220     local we = CEGUI.toWindowEventArgs(e)
    221     local name = we.window:getName()
    222118
    223     local match = string.gmatch(name, "%d+")
    224     local pickupIndex = tonumber(match())
    225 
    226     return pickupIndex
    227 end
    228 
    229 function P.createDetailsWindow(pickupIndex)
    230     local pickup = P.pickupsList[pickupIndex]
    231     local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName)
    232 
    233     local index = P.getNewDetailNumber()
    234     local name = "orxonox/PickupInventory/Details" .. index
    235    
    236     local window = winMgr:createWindow("MenuWidgets/FrameWindow", name)
    237     window:setSize(CEGUI.UVector2(CEGUI.UDim(0.5,0),CEGUI.UDim(0.4,0)))
    238     orxonox.GUIManager:subscribeEventHelper(window, "CloseClicked", P.name .. ".closeDetailWindow")
    239    
    240     local root = winMgr:getWindow("orxonox/PickupInventory/Background")
    241     root:addChildWindow(window)
    242    
    243     local wrapper = winMgr:createWindow("DefaultWindow", name .. "/Wrapper")
    244     wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1, -20),CEGUI.UDim(1, -50)))
    245     wrapper:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10),CEGUI.UDim(0, 40)))
    246     window:addChildWindow(wrapper)
    247    
    248     local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    249     title:setText(representation:getPickupName())
    250     title:setHeight(CEGUI.UDim(0, P.textHeight))
    251     title:setProperty("FrameEnabled", "set:False")
    252     title:setProperty("BackgroundEnabled", "set:False")
    253     wrapper:addChildWindow(title)
    254    
    255     local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    256     image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    257     image:setProperty("BackgroundEnabled", "set:False")
    258     image:setProperty("FrameEnabled", "set:True")
    259     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize), CEGUI.UDim(0, P.detailImageSize)))
    260     image:setYPosition(CEGUI.UDim(0, P.textHeight + 5))
    261     wrapper:addChildWindow(image)
    262    
    263     local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Description")
    264     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(P.detailImageSize + 10)),CEGUI.UDim(1, -(P.textHeight + 5 + P.textHeight + 20))))
    265     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize + 10),CEGUI.UDim(0, P.textHeight + 5)))
    266     local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Text")
    267     description:setText(representation:getPickupDescription())
    268     description:setProperty("HorzFormatting", "WordWrapLeftAligned")
    269     description:setProperty("VertFormatting", "TopAligned")
    270     box:addChildWindow(description)
    271     wrapper:addChildWindow(box)
    272 
    273     local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    274     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10),CEGUI.UDim(1, -40)))
    275     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    276     if pickup.inUse == false then
    277         useButton:setText("use")
    278         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    279         if pickup.usable == false then
    280             useButton:setEnabled(false)
    281         end
    282     else
    283         useButton:setText("unuse")
    284         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    285         if pickup.unusable == false then
    286             useButton:setEnabled(false)
    287         end
    288     end
    289     wrapper:addChildWindow(useButton)
    290    
    291     local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    292     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10+P.buttonWidth+10),CEGUI.UDim(1, -40)))
    293     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    294     dropButton:setText("drop")
    295     orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropDetailButton_clicked")
    296     wrapper:addChildWindow(dropButton)
    297 
    298     P.detailsWindows[index] = window
    299     P.detailPickups[index] = pickup
    300    
    301 end
    302 
    303 function P.getNewDetailNumber()
    304     local number = table.getn(P.detailsWindows)
    305     for k,v in pairs(P.detailsWindows) do
    306         if v == nil then
    307             number = k-1
    308         end
    309     end
    310     return number+1
    311 end
    312 
    313 function P.InventoryUseButton_clicked(e)
    314     local pickupIndex = P.windowToPickupHelper(e)
    315     local pickup = P.pickupsList[pickupIndex]
    316     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    317 end
    318 
    319 function P.InventoryUnuseButton_clicked(e)
    320     local pickupIndex = P.windowToPickupHelper(e)
    321     local pickup = P.pickupsList[pickupIndex]
    322     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    323 end
    324 
    325 function P.InventoryDropButton_clicked(e)
    326     local pickupIndex = P.windowToPickupHelper(e)
    327     local pickup = P.pickupsList[pickupIndex]
    328     orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    329 end
    330 
    331 function P.InventoryDetailsButton_clicked(e)
    332     local pickupIndex = P.windowToPickupHelper(e)
    333     P.createDetailsWindow(pickupIndex)
    334 end
    335 
    336 function P.InventoryUseDetailButton_clicked(e)
    337     local pickupIndex = P.windowToPickupHelper(e)
    338     local pickup = P.detailPickups[pickupIndex]
    339     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    340 end
    341 
    342 function P.InventoryUnuseDetailButton_clicked(e)
    343     local pickupIndex = P.windowToPickupHelper(e)
    344     local pickup = P.detailPickups[pickupIndex]
    345     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    346 end
    347 
    348 function P.InventoryDropDetailButton_clicked(e)
    349     local pickupIndex = P.windowToPickupHelper(e)
    350     local pickup = P.detailPickups[pickupIndex]
    351     orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    352 end
    353 
    354 function P.closeDetailWindow(e)
    355     --Get some numbers from the window
    356     local we = CEGUI.toWindowEventArgs(e)
    357     local name = we.window:getName()
    358     local match = string.gmatch(name, "%d+")
    359     local detailNr = tonumber(match())
    360    
    361     P.destroyDetailWindow(detailNr)
    362 end
    363 
    364 function P.destroyDetailWindow(detailNr)
    365     local window = P.detailsWindows[detailNr]
    366     winMgr:destroyWindow(window)
    367     P.detailsWindows[detailNr] = nil
    368     P.detailPickups[detailNr] = nil
    369 end
    370119
    371120function P.InventoryBackButton_clicked(e)
    372     orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility PickupInventory")
     121    orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
    373122end
    374123
Note: See TracChangeset for help on using the changeset viewer.