mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
finally reloadable vip, skills, inventory, chat and minimap
This commit is contained in:
@@ -7,10 +7,9 @@ local inventoryButton
|
||||
|
||||
-- public functions
|
||||
function Inventory.init()
|
||||
connect(g_game, { onGameEnd = Inventory.clear,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
connect(LocalPlayer, { onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange })
|
||||
connect(g_game, { onGameEnd = Inventory.clear })
|
||||
|
||||
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||
|
||||
@@ -20,16 +19,13 @@ function Inventory.init()
|
||||
inventoryButton = TopMenu.addGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||
inventoryButton:setOn(true)
|
||||
|
||||
if g_game.isOnline() then
|
||||
Inventory.reload()
|
||||
end
|
||||
Inventory.refresh()
|
||||
end
|
||||
|
||||
function Inventory.terminate()
|
||||
connect(g_game, { onGameEnd = Inventory.clear,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
disconnect(LocalPlayer, { onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange })
|
||||
disconnect(g_game, { onGameEnd = Inventory.clear })
|
||||
|
||||
Keyboard.unbindKeyDown('Ctrl+I')
|
||||
|
||||
@@ -42,30 +38,29 @@ function Inventory.terminate()
|
||||
Inventory = nil
|
||||
end
|
||||
|
||||
function Inventory.refresh()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if not player then return end
|
||||
|
||||
for i=1,10 do
|
||||
Inventory.onInventoryChange(player, i, player:getInventoryItem(i))
|
||||
end
|
||||
end
|
||||
|
||||
function Inventory.toggle()
|
||||
local visible = not inventoryWindow:isExplicitlyVisible()
|
||||
inventoryWindow:setVisible(visible)
|
||||
inventoryButton:setOn(visible)
|
||||
end
|
||||
|
||||
function Inventory.clear()
|
||||
end
|
||||
|
||||
function Inventory.reload()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Inventory.onInventoryChange(slot, item)
|
||||
function Inventory.onInventoryChange(player, slot, item)
|
||||
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
|
||||
itemWidget:setItem(item)
|
||||
end
|
||||
|
||||
function Inventory.onFreeCapacityChange(freeCapacity)
|
||||
function Inventory.onFreeCapacityChange(player, freeCapacity)
|
||||
local widget = inventoryPanel:getChildById('capacity')
|
||||
widget:setText("Cap:\n" .. freeCapacity)
|
||||
end
|
||||
|
||||
function Inventory.onSoulChange(soul)
|
||||
local widget = inventoryPanel:getChildById('soul')
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
Reference in New Issue
Block a user