diff --git a/data/images/game/slots/purse.png b/data/images/game/slots/purse.png new file mode 100644 index 00000000..229e9ed4 Binary files /dev/null and b/data/images/game/slots/purse.png differ diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index 4e2c87a2..ae1a81d8 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -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') diff --git a/modules/game_inventory/inventory.otui b/modules/game_inventory/inventory.otui index e9147a31..4089118e 100644 --- a/modules/game_inventory/inventory.otui +++ b/modules/game_inventory/inventory.otui @@ -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 \ No newline at end of file + margin-top: 3 + + PurseButton + margin-top: 3 + anchors.top: prev.bottom + anchors.horizontalCenter: prev.horizontalCenter \ No newline at end of file diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index ca8ca5b4..f05c36c7 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -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 diff --git a/src/client/game.cpp b/src/client/game.cpp index dd07e6fa..122b83e0 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -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;