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

master
Sam 10 年前
父节点 8d8f32b081
当前提交 a58a3e90c8

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.8 KiB

@ -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

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

@ -1459,7 +1459,7 @@ void Game::setProtocolVersion(int version)
if(isOnline())
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));
m_features.reset();
@ -1587,7 +1587,7 @@ void Game::setClientVersion(int version)
if(isOnline())
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));
m_clientVersion = version;

正在加载...
取消
保存