mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
BEAWARE all game functionality is disabled with this commit for a while
* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
Inventory = {}
|
||||
|
||||
-- private variables
|
||||
local inventoryWindow
|
||||
local inventoryButton
|
||||
|
||||
-- public functions
|
||||
function Inventory.create()
|
||||
inventoryWindow = displayUI('inventory.otui', { parent = g_game.gameRightPanel })
|
||||
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||
inventoryButton:setOn(true)
|
||||
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||
end
|
||||
|
||||
function Inventory.destroy()
|
||||
Keyboard.unbindKeyDown('Ctrl+I')
|
||||
inventoryWindow:destroy()
|
||||
inventoryWindow = nil
|
||||
inventoryButton:destroy()
|
||||
inventoryButton = nil
|
||||
end
|
||||
|
||||
function Inventory.toggle()
|
||||
local visible = not inventoryWindow:isExplicitlyVisible()
|
||||
inventoryWindow:setVisible(visible)
|
||||
inventoryButton:setOn(visible)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Inventory.onInventoryChange(slot, item)
|
||||
local itemWidget = inventoryWindow:getChildById('slot' .. slot)
|
||||
itemWidget:setItem(item)
|
||||
end
|
||||
|
||||
function Inventory.onFreeCapacityChange(freeCapacity)
|
||||
local widget = inventoryWindow:getChildById('capacity')
|
||||
widget:setText("Cap:\n" .. freeCapacity)
|
||||
end
|
||||
|
||||
function Inventory.onSoulChange(soul)
|
||||
local widget = inventoryWindow:getChildById('soul')
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = Inventory.create,
|
||||
onGameEnd = Inventory.destroy,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
|
Reference in New Issue
Block a user