diff --git a/modules/game/player.lua b/modules/game/player.lua index 8043d336..39e84389 100644 --- a/modules/game/player.lua +++ b/modules/game/player.lua @@ -1,5 +1,19 @@ -- @docclass Player +InventorySlotHead = 1 +InventorySlotNeck = 2 +InventorySlotBack = 3 +InventorySlotBody = 4 +InventorySlotRight = 5 +InventorySlotLeft = 6 +InventorySlotLeg = 7 +InventorySlotFeet = 8 +InventorySlotFinger = 9 +InventorySlotAmmo = 10 + +InventorySlotFirst = 1 +InventorySlotLast = 10 + function Player:isPartyLeader() local shield = self:getShield() return (shield == ShieldWhiteYellow or @@ -37,4 +51,4 @@ function Player:hasVip(creatureName) if (vip[1] == creatureName) then return true end end return false -end +end \ No newline at end of file diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index f4acfb75..8604503c 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -118,18 +118,13 @@ local function onOpenChannel(channelId, channelName) end local function onOpenPrivateChannel(receiver) - local privateTab = Console.getTab(receiver) - if privateTab == nil then - channels[receiver] = receiver - Console.addTab(receiver, true) - end + Console.addPrivateChannel(receiver) end local function onOpenOwnPrivateChannel(channelId, channelName) local privateTab = Console.getTab(channelName) if privateTab == nil then - --channels[channelId] = channelName (this should be tested) - Console.addChannel(channelName, channelId, true) + Console.addChannel(channelName, channelId) end ownPrivateName = channelName end @@ -302,7 +297,12 @@ function Console.openHelp() end function Console.addTab(name, focus) - local tab = consoleTabBar:addTab(name) + local tab = Console.getTab(name) + if(tab) then -- is channel already open + if(not focus) then focus = true end + else + tab = consoleTabBar:addTab(name) + end if focus then consoleTabBar:selectTab(tab) elseif name ~= tr('Server Log') then @@ -348,6 +348,11 @@ function Console.addChannel(name, id) return tab end +function Console.addPrivateChannel(receiver) + channels[receiver] = receiver + return Console.addTab(receiver, true) +end + function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatureName) local focus = false if speaktype.speakType == SpeakPrivateNpcToPlayer then diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 54a34523..4ff5a597 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -75,6 +75,7 @@ Panel TabButton id: clearChannelButton + !tooltip: tr('Clear current message window') icon: icons/clearchannel.png anchors.right: next.left anchors.top: parent.top diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index b7ee6ead..ec0a7bed 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -35,10 +35,13 @@ local hotkeyColors = { -- public functions function HotkeysManager.init() hotkeysWindow = g_ui.displayUI('hotkeys_manager.otui') + local hotkeyListPanel = hotkeysWindow:getChildById('currentHotkeys') hotkeysWindow:setVisible(false) hotkeysButton = TopMenu.addGameButton('hotkeysButton', tr('Hotkeys') .. ' (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle) g_keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle) + g_keyboard.bindKeyPress('Down', function() hotkeyListPanel:focusNextChild(KeyboardFocusReason) end, hotkeysWindow) + g_keyboard.bindKeyPress('Up', function() hotkeyListPanel:focusPreviousChild(KeyboardFocusReason) end, hotkeysWindow) currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys') currentItemPreview = hotkeysWindow:getChildById('itemPreview') @@ -102,6 +105,9 @@ function HotkeysManager.terminate() hotkeysManagerLoaded = false g_keyboard.unbindKeyDown('Ctrl+K') + g_keyboard.unbindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow) + g_keyboard.unbindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow) + HotkeysManager.save() currentHotkeysList = nil diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index b5259524..434ed6f7 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -1,5 +1,19 @@ Inventory = {} +-- public variables +InventorySlotStyles = { + [InventorySlotHead] = "HeadSlot", + [InventorySlotNeck] = "NeckSlot", + [InventorySlotBack] = "BackSlot", + [InventorySlotBody] = "BodySlot", + [InventorySlotRight] = "RightSlot", + [InventorySlotLeft] = "LeftSlot", + [InventorySlotLeg] = "LegSlot", + [InventorySlotFeet] = "FeetSlot", + [InventorySlotFinger] = "FingerSlot", + [InventorySlotAmmo] = "AmmoSlot" +} + -- private variables local inventoryWindow local inventoryPanel @@ -39,7 +53,7 @@ end function Inventory.refresh() local player = g_game.getLocalPlayer() - for i=1,10 do + for i=InventorySlotFirst,InventorySlotLast do if player then Inventory.onInventoryChange(player, i, player:getInventoryItem(i)) else @@ -63,9 +77,15 @@ function Inventory.onMiniWindowClose() end -- hooked events -function Inventory.onInventoryChange(player, slot, item) +function Inventory.onInventoryChange(player, slot, item, oldItem) local itemWidget = inventoryPanel:getChildById('slot' .. slot) - itemWidget:setItem(item) + if(item) then + itemWidget:setStyle('Item') + itemWidget:setItem(item) + else + itemWidget:setStyle(InventorySlotStyles[slot]) + itemWidget:setItem(nil) + end end function Inventory.onFreeCapacityChange(player, freeCapacity) diff --git a/modules/game_inventory/inventory.otui b/modules/game_inventory/inventory.otui index 05398711..42019a6f 100644 --- a/modules/game_inventory/inventory.otui +++ b/modules/game_inventory/inventory.otui @@ -1,3 +1,43 @@ +HeadSlot < Item + id: slot1 + image-source: /game_inventory/slots/head.png + +BodySlot < Item + id: slot4 + image-source: /game_inventory/slots/body.png + +LegSlot < Item + id: slot7 + image-source: /game_inventory/slots/legs.png + +FeetSlot < Item + id: slot8 + image-source: /game_inventory/slots/feet.png + +NeckSlot < Item + id: slot2 + image-source: /game_inventory/slots/neck.png + +LeftSlot < Item + id: slot6 + image-source: /game_inventory/slots/left-hand.png + +FingerSlot < Item + id: slot9 + image-source: /game_inventory/slots/finger.png + +BackSlot < Item + id: slot3 + image-source: /game_inventory/slots/back.png + +RightSlot < Item + id: slot5 + image-source: /game_inventory/slots/right-hand.png + +AmmoSlot < Item + id: slot10 + image-source: /game_inventory/slots/ammo.png + MiniWindow id: inventoryWindow !text: tr('Inventory') @@ -6,84 +46,74 @@ MiniWindow @onClose: Inventory.onMiniWindowClose() &save: true - MiniWindowContents - Item + MiniWindowContents + HeadSlot // head - id: slot1 anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter margin-top: 4 &position: {x=65535, y=1, z=0} - Item - // armor - id: slot4 + BodySlot + // body anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=4, z=0} - Item + LegSlot // legs - id: slot7 anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=7, z=0} - Item + FeetSlot // feet - id: slot8 anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=8, z=0} - Item - // necklace - id: slot2 + NeckSlot + // neck anchors.top: parent.top anchors.right: slot1.left margin-top: 10 margin-right: 5 &position: {x=65535, y=2, z=0} - Item - // left - id: slot6 + LeftSlot + // left hand anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=6, z=0} - Item - // ring - id: slot9 + FingerSlot + // finger anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=9, z=0} - Item - // backpack - id: slot3 + BackSlot + // back anchors.top: parent.top anchors.left: slot1.right margin-top: 10 margin-left: 5 &position: {x=65535, y=3, z=0} - Item - // right - id: slot5 + RightSlot + // right hand anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 &position: {x=65535, y=5, z=0} - Item + AmmoSlot // ammo - id: slot10 anchors.top: prev.bottom anchors.horizontalCenter: prev.horizontalCenter margin-top: 5 @@ -97,4 +127,13 @@ MiniWindow margin-top: 5 text-align: center text-auto-resize: true + + GameLabel + id: soul + height: 30 + anchors.top: slot9.bottom + anchors.left: slot9.left + margin-top: 5 + text-align: center + text-auto-resize: true diff --git a/modules/game_inventory/slots/ammo.png b/modules/game_inventory/slots/ammo.png new file mode 100644 index 00000000..345415f5 Binary files /dev/null and b/modules/game_inventory/slots/ammo.png differ diff --git a/modules/game_inventory/slots/back.png b/modules/game_inventory/slots/back.png new file mode 100644 index 00000000..dc874a73 Binary files /dev/null and b/modules/game_inventory/slots/back.png differ diff --git a/modules/game_inventory/slots/body.png b/modules/game_inventory/slots/body.png new file mode 100644 index 00000000..78dcbe26 Binary files /dev/null and b/modules/game_inventory/slots/body.png differ diff --git a/modules/game_inventory/slots/feet.png b/modules/game_inventory/slots/feet.png new file mode 100644 index 00000000..4bdfd5fd Binary files /dev/null and b/modules/game_inventory/slots/feet.png differ diff --git a/modules/game_inventory/slots/finger.png b/modules/game_inventory/slots/finger.png new file mode 100644 index 00000000..61dec1e6 Binary files /dev/null and b/modules/game_inventory/slots/finger.png differ diff --git a/modules/game_inventory/slots/head.png b/modules/game_inventory/slots/head.png new file mode 100644 index 00000000..f2f3782b Binary files /dev/null and b/modules/game_inventory/slots/head.png differ diff --git a/modules/game_inventory/slots/left-hand.png b/modules/game_inventory/slots/left-hand.png new file mode 100644 index 00000000..7ca84cf9 Binary files /dev/null and b/modules/game_inventory/slots/left-hand.png differ diff --git a/modules/game_inventory/slots/legs.png b/modules/game_inventory/slots/legs.png new file mode 100644 index 00000000..145121a4 Binary files /dev/null and b/modules/game_inventory/slots/legs.png differ diff --git a/modules/game_inventory/slots/neck.png b/modules/game_inventory/slots/neck.png new file mode 100644 index 00000000..94a4e55e Binary files /dev/null and b/modules/game_inventory/slots/neck.png differ diff --git a/modules/game_inventory/slots/right-hand.png b/modules/game_inventory/slots/right-hand.png new file mode 100644 index 00000000..0aa355b3 Binary files /dev/null and b/modules/game_inventory/slots/right-hand.png differ diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index ea04fa29..3ad4abeb 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -38,7 +38,7 @@ end -- public functions function Minimap.init() connect(g_game, { onGameStart = Minimap.reset, - onForceWalk = Minimap.center } ) + onForceWalk = Minimap.center }) g_keyboard.bindKeyDown('Ctrl+M', Minimap.toggle) @@ -78,7 +78,7 @@ end function Minimap.terminate() disconnect(g_game, { onGameStart = Minimap.reset, - onForceWalk = Minimap.center } ) + onForceWalk = Minimap.center }) g_keyboard.unbindKeyDown('Ctrl+M') @@ -104,19 +104,6 @@ function Minimap.onMiniWindowClose() minimapButton:setOn(false) end -function Minimap.reset() - local player = g_game.getLocalPlayer() - if not player then return end - minimapWidget:followCreature(player) - minimapWidget:setZoom(DEFAULT_ZOOM) -end - -function Minimap.center() - local player = g_game.getLocalPlayer() - if not player then return end - minimapWidget:followCreature(player) -end - function Minimap.isClickInRange(position, fromPosition, toPosition) return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y) end @@ -159,4 +146,18 @@ function Minimap.onButtonClick(id) pos.z = pos.z + 1 minimapWidget:setCameraPosition(pos) end +end + +-- hooked events +function Minimap.reset() + local player = g_game.getLocalPlayer() + if not player then return end + minimapWidget:followCreature(player) + minimapWidget:setZoom(DEFAULT_ZOOM) +end + +function Minimap.center() + local player = g_game.getLocalPlayer() + if not player then return end + minimapWidget:followCreature(player) end \ No newline at end of file