Implement purse slot (closes #208), add version 10.37 (could not find protocol changes)

master
Sam 10 years ago
parent 8d8f32b081
commit a58a3e90c8

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -14,6 +14,7 @@ InventorySlotStyles = {
inventoryWindow = nil inventoryWindow = nil
inventoryPanel = nil inventoryPanel = nil
inventoryButton = nil inventoryButton = nil
purseButton = nil
function init() function init()
connect(LocalPlayer, { onInventoryChange = onInventoryChange }) connect(LocalPlayer, { onInventoryChange = onInventoryChange })
@ -28,6 +29,16 @@ function init()
inventoryWindow:disableResize() inventoryWindow:disableResize()
inventoryPanel = inventoryWindow:getChildById('contentsPanel') 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() refresh()
inventoryWindow:setup() inventoryWindow:setup()
end end
@ -44,13 +55,15 @@ end
function refresh() function refresh()
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
for i=InventorySlotFirst,InventorySlotLast do for i = InventorySlotFirst, InventorySlotPurse do
if g_game.isOnline() then if g_game.isOnline() then
onInventoryChange(player, i, player:getInventoryItem(i)) onInventoryChange(player, i, player:getInventoryItem(i))
else else
onInventoryChange(player, i, nil) onInventoryChange(player, i, nil)
end end
end end
purseButton:setVisible(g_game.getFeature(GamePurseSlot))
end end
function toggle() function toggle()
@ -69,7 +82,15 @@ end
-- hooked events -- hooked events
function onInventoryChange(player, slot, item, oldItem) 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) local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if item then if item then
itemWidget:setStyle('Item') itemWidget:setStyle('Item')

@ -50,6 +50,14 @@ AmmoSlot < InventoryItem
image-source: /images/game/slots/ammo image-source: /images/game/slots/ammo
&position: {x=65535, y=10, z=0} &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 MiniWindow
id: inventoryWindow id: inventoryWindow
!text: tr('Inventory') !text: tr('Inventory')
@ -109,4 +117,9 @@ MiniWindow
AmmoSlot AmmoSlot
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3 margin-top: 3
PurseButton
margin-top: 3
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter

@ -54,7 +54,7 @@ function g_game.getSupportedClients()
940, 944, 953, 954, 960, 961, 963, 940, 944, 953, 954, 960, 961, 963,
970, 980, 981, 982, 983, 984, 985, 970, 980, 981, 982, 983, 984, 985,
986, 1001, 1002, 1010, 1020, 1021, 986, 1001, 1002, 1010, 1020, 1021,
1022, 1031, 1034, 1035, 1036 1022, 1031, 1034, 1035, 1036, 1037
} }
end end

@ -1459,7 +1459,7 @@ void Game::setProtocolVersion(int version)
if(isOnline()) if(isOnline())
stdext::throw_exception("Unable to change protocol version while online"); stdext::throw_exception("Unable to change protocol version while online");
if(version != 0 && (version < 760 || version > 1036)) if(version != 0 && (version < 760 || version > 1037))
stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
m_features.reset(); m_features.reset();
@ -1587,7 +1587,7 @@ void Game::setClientVersion(int version)
if(isOnline()) if(isOnline())
stdext::throw_exception("Unable to change client version while online"); stdext::throw_exception("Unable to change client version while online");
if(version != 0 && (version < 760 || version > 1036)) if(version != 0 && (version < 760 || version > 1037))
stdext::throw_exception(stdext::format("Client version %d not supported", version)); stdext::throw_exception(stdext::format("Client version %d not supported", version));
m_clientVersion = version; m_clientVersion = version;

Loading…
Cancel
Save