mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Implement purse slot (closes #208), add version 10.37 (could not find protocol changes)
This commit is contained in:
@@ -14,6 +14,7 @@ InventorySlotStyles = {
|
||||
inventoryWindow = nil
|
||||
inventoryPanel = nil
|
||||
inventoryButton = nil
|
||||
purseButton = nil
|
||||
|
||||
function init()
|
||||
connect(LocalPlayer, { onInventoryChange = onInventoryChange })
|
||||
@@ -28,6 +29,16 @@ function init()
|
||||
inventoryWindow:disableResize()
|
||||
inventoryPanel = inventoryWindow:getChildById('contentsPanel')
|
||||
|
||||
purseButton = inventoryPanel:getChildById('purseButton')
|
||||
local function purseFunction()
|
||||
local purse = g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse)
|
||||
if purse then
|
||||
print(purse:getId())
|
||||
g_game.use(purse)
|
||||
end
|
||||
end
|
||||
purseButton.onClick = purseFunction
|
||||
|
||||
refresh()
|
||||
inventoryWindow:setup()
|
||||
end
|
||||
@@ -44,13 +55,15 @@ end
|
||||
|
||||
function refresh()
|
||||
local player = g_game.getLocalPlayer()
|
||||
for i=InventorySlotFirst,InventorySlotLast do
|
||||
for i = InventorySlotFirst, InventorySlotPurse do
|
||||
if g_game.isOnline() then
|
||||
onInventoryChange(player, i, player:getInventoryItem(i))
|
||||
else
|
||||
onInventoryChange(player, i, nil)
|
||||
end
|
||||
end
|
||||
|
||||
purseButton:setVisible(g_game.getFeature(GamePurseSlot))
|
||||
end
|
||||
|
||||
function toggle()
|
||||
@@ -69,7 +82,15 @@ end
|
||||
|
||||
-- hooked events
|
||||
function onInventoryChange(player, slot, item, oldItem)
|
||||
if slot >= InventorySlotPurse then return end
|
||||
if slot > InventorySlotPurse then return end
|
||||
|
||||
if slot == InventorySlotPurse then
|
||||
if g_game.getFeature(GamePurseSlot) then
|
||||
purseButton:setEnabled(item and true or false)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
|
||||
if item then
|
||||
itemWidget:setStyle('Item')
|
||||
|
||||
@@ -50,6 +50,14 @@ AmmoSlot < InventoryItem
|
||||
image-source: /images/game/slots/ammo
|
||||
&position: {x=65535, y=10, z=0}
|
||||
|
||||
PurseButton < Button
|
||||
id: purseButton
|
||||
size: 26 26
|
||||
!tooltip: tr('Open purse')
|
||||
icon-source: /images/game/slots/purse
|
||||
icon-size: 24 24
|
||||
icon-offset: 1 1
|
||||
|
||||
MiniWindow
|
||||
id: inventoryWindow
|
||||
!text: tr('Inventory')
|
||||
@@ -109,4 +117,9 @@ MiniWindow
|
||||
AmmoSlot
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 3
|
||||
margin-top: 3
|
||||
|
||||
PurseButton
|
||||
margin-top: 3
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
Reference in New Issue
Block a user