From a58a3e90c8a2b14994eb8b961eff5cdd1a3dc746 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Mar 2014 15:46:35 +0100 Subject: [PATCH] Implement purse slot (closes #208), add version 10.37 (could not find protocol changes) --- data/images/game/slots/purse.png | Bin 0 -> 1811 bytes modules/game_inventory/inventory.lua | 25 +++++++++++++++++++++++-- modules/game_inventory/inventory.otui | 15 ++++++++++++++- modules/gamelib/game.lua | 2 +- src/client/game.cpp | 4 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 data/images/game/slots/purse.png diff --git a/data/images/game/slots/purse.png b/data/images/game/slots/purse.png new file mode 100644 index 0000000000000000000000000000000000000000..229e9ed4e067a71f91581b3f1c001caef796e201 GIT binary patch literal 1811 zcmV+u2kiKXP)DJp5xhBj5D5;bi}BBhVessa*1LsDoP z6iA~sB+8=#wm~9)h&U)>!J$GhqKaA~N@7j)O&lh{n%$fiHp7X!wo)I)@(L`L8 z|LZ;<>48Bp^% zyL|SZJ2-RvSX0_5XP{UtR`k)Z1kprX{r;OvxH2%n=%@!iG;AS&`<5-iaU2f3bb=QK z^-B6{>7bUC!7a-|2!UZ3)g_1~;%eXK9^N{3j<%@h`}m3k1j|<3$@#PAv5FR&q1P6a zXsqcnLBlXGP1Dmr+1b{WP|x?>#j&Grqw5;u<6udfWh;6BID7gm0FL7@UJUZ)FCOJH zoAxMRS|;jQErPzO3?0|Saa{oJUE0IpLnlcjbgZI9GUFpXQeb1>Dk3d@9+>F@ikFGk z&Hc5=iOCt*x4DP0bedR42LR9Sdz;t{g)n?LjzfCHWZn8+<}aKFz*uISpKaUArxr!) z0zC7k*^oqqfDnSjoGt~BmtF>zcNl287yH9!z5>ARoiCCcy~>8Z&tsZ-4j(vJx5+d^ zLNrotTUSE8x_vDGzy8T@0od~6O=Pa7X$?o%`rThLZ=OL%NBcCTm(4Wu7=}@oL_-2X z2%?F&dSIrDLc?_=Pi_4=Kl&BEjp<(z+jmYI&OM+F0TEkX6*+L=jcShTUFB0{afb@p3hG8J3 zO(5W{RToXP;>nF^bwXoir^4^|k5`Q~7 z2tZ5Fi%a;zh|)Sg$YuaIc+%qWdpbFl&DPey;<>Zbb6;xZ?#FVdqK(Sfy!2N;10xQ* zb{-%W3nHbYyE{rp`$T&GeE2f2|D&Y(%f-@G8V4OP1V{x717KZ4gbQl)6-Nn<{KsMS zO(7C-4|FnkGF7Y&=q}xhYJl7PK(caSm%3VX>FU&QN4!0K@l*>7u7kfk*ul!5Cb|9N zEH~d2Boc{CBOo*0F8kdM@73#`blAI1ujmP2 z35nKfaq*!5Pduvl_d5k{ydg-TFnx7@+U4U9hXj5hSofsE8z(#sxGvmvn_D{rD;IXD zL$CM&3wKEI?uiyUZXE|B$jzstXl*&rCU(QH(&_)#7)n8Vn?`EP1$0&|_wElmI@kGJ z2*60PG))HtN8ZvovQ!5$fHpy3Og5foDA*{sOhD(uoM8K!7y#eipCQsjLpz%F;Mz)> z7)YmuPYA)<#a(L8CY%0OY;0GsWskw*Yh1W20SSaq(gsaKq%0uJvkyn<{hA3v(Epx~ z{TIA6=QU4!@c@_rrl*awQYV{EPCI*iU%atPeSbrc>+km*BNsIK9)q9%Cdb`NCk-nF z1vm_SsC{8EJ6oytg$zx}^B>jsgPE zG6)zn0_@BB^#BT^LVX%5-b$54)iZfDYFr5~4zl`R_ zJ0`ySN?b1vrv$*FS?%hUu%8uo7(B9Bq8s28UAAtq>A&E`oXiV87)lC&*`-5fvX#MW zmZ0Pm^#+pu!K9d%h^t$!K2F8T(3yc;KoZJqX!M zE2)e*75INLajmbJawe{yH8IK9wx^d%!~Z{l{{o;oY&3ga<002ovPDHLkV1jik BTgU(a literal 0 HcmV?d00001 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;