Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11710 for code/trunk


Ignore:
Timestamp:
Jan 7, 2018, 12:50:29 AM (7 years ago)
Author:
landauf
Message:

fixed two bugs in PickupInventory.lua:

  • the update function had a messed up logic regarding the use-button in the detail window (condition was partially inverted)
  • updating the event subscription of the use-button in the detail-window doesn't seem to work - probably CEGUI doesn't like updating/changing/overriding an event while begin IN a mouse-click-event already. moving the logic to the Use/Unuse-function instead seems to work.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/gui/scripts/PickupInventory.lua

    r9348 r11710  
    5151                else
    5252                    useButton:setEnabled(true)
    53                     if pickup.inUse == true then
    54                         useButton:setText("unuse")
    55                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
     53                    if pickup.inUse == false then
     54                        useButton:setText("use")
    5655                        if pickup.usable == false then
    5756                            useButton:setEnabled(false)
    5857                        end
    5958                    else
    60                         useButton:setText("use")
    61                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
     59                        useButton:setText("unuse")
    6260                        if pickup.unusable == false then
    6361                            useButton:setEnabled(false)
     
    135133    if pickup.inUse == false then
    136134        useButton:setText("use")
    137         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    138135        if pickup.usable == false then
    139136            useButton:setEnabled(false)
     
    141138    else
    142139        useButton:setText("unuse")
    143         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
    144140        if pickup.unusable == false then
    145141            useButton:setEnabled(false)
    146142        end
    147143    end
     144    orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseUnuseButton_clicked")
    148145    item:addChildWindow(useButton)
    149146
     
    240237    if pickup.inUse == false then
    241238        useButton:setText("use")
    242         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    243239        if pickup.usable == false then
    244240            useButton:setEnabled(false)
     
    246242    else
    247243        useButton:setText("unuse")
    248         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    249244        if pickup.unusable == false then
    250245            useButton:setEnabled(false)
    251246        end
    252247    end
     248    orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseUnuseDetailButton_clicked")
    253249    wrapper:addChildWindow(useButton)
    254250   
     
    275271end
    276272
    277 function P.InventoryUseButton_clicked(e)
     273function P.InventoryUseUnuseButton_clicked(e)
    278274    local pickupIndex = P.windowToPickupHelper(e)
    279275    local pickup = P.pickupsList[pickupIndex]
    280     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    281 end
    282 
    283 function P.InventoryUnuseButton_clicked(e)
    284     local pickupIndex = P.windowToPickupHelper(e)
    285     local pickup = P.pickupsList[pickupIndex]
    286     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
     276    if pickup.inUse == false then
     277        orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
     278    else
     279        orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
     280    end
    287281end
    288282
     
    298292end
    299293
    300 function P.InventoryUseDetailButton_clicked(e)
     294function P.InventoryUseUnuseDetailButton_clicked(e)
    301295    local pickupIndex = P.windowToPickupHelper(e)
    302296    local pickup = P.detailPickups[pickupIndex]
    303     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    304 end
    305 
    306 function P.InventoryUnuseDetailButton_clicked(e)
    307     local pickupIndex = P.windowToPickupHelper(e)
    308     local pickup = P.detailPickups[pickupIndex]
    309     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
     297    if pickup.inUse == false then
     298        orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
     299    else
     300        orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
     301    end
    310302end
    311303
Note: See TracChangeset for help on using the changeset viewer.