Merge pull request #30 from BeniS/otclient
|
@ -1,5 +1,19 @@
|
||||||
-- @docclass Player
|
-- @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()
|
function Player:isPartyLeader()
|
||||||
local shield = self:getShield()
|
local shield = self:getShield()
|
||||||
return (shield == ShieldWhiteYellow or
|
return (shield == ShieldWhiteYellow or
|
||||||
|
|
|
@ -118,18 +118,13 @@ local function onOpenChannel(channelId, channelName)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onOpenPrivateChannel(receiver)
|
local function onOpenPrivateChannel(receiver)
|
||||||
local privateTab = Console.getTab(receiver)
|
Console.addPrivateChannel(receiver)
|
||||||
if privateTab == nil then
|
|
||||||
channels[receiver] = receiver
|
|
||||||
Console.addTab(receiver, true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onOpenOwnPrivateChannel(channelId, channelName)
|
local function onOpenOwnPrivateChannel(channelId, channelName)
|
||||||
local privateTab = Console.getTab(channelName)
|
local privateTab = Console.getTab(channelName)
|
||||||
if privateTab == nil then
|
if privateTab == nil then
|
||||||
--channels[channelId] = channelName (this should be tested)
|
Console.addChannel(channelName, channelId)
|
||||||
Console.addChannel(channelName, channelId, true)
|
|
||||||
end
|
end
|
||||||
ownPrivateName = channelName
|
ownPrivateName = channelName
|
||||||
end
|
end
|
||||||
|
@ -302,7 +297,12 @@ function Console.openHelp()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.addTab(name, focus)
|
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
|
if focus then
|
||||||
consoleTabBar:selectTab(tab)
|
consoleTabBar:selectTab(tab)
|
||||||
elseif name ~= tr('Server Log') then
|
elseif name ~= tr('Server Log') then
|
||||||
|
@ -348,6 +348,11 @@ function Console.addChannel(name, id)
|
||||||
return tab
|
return tab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Console.addPrivateChannel(receiver)
|
||||||
|
channels[receiver] = receiver
|
||||||
|
return Console.addTab(receiver, true)
|
||||||
|
end
|
||||||
|
|
||||||
function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatureName)
|
function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatureName)
|
||||||
local focus = false
|
local focus = false
|
||||||
if speaktype.speakType == SpeakPrivateNpcToPlayer then
|
if speaktype.speakType == SpeakPrivateNpcToPlayer then
|
||||||
|
|
|
@ -75,6 +75,7 @@ Panel
|
||||||
|
|
||||||
TabButton
|
TabButton
|
||||||
id: clearChannelButton
|
id: clearChannelButton
|
||||||
|
!tooltip: tr('Clear current message window')
|
||||||
icon: icons/clearchannel.png
|
icon: icons/clearchannel.png
|
||||||
anchors.right: next.left
|
anchors.right: next.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
|
@ -35,10 +35,13 @@ local hotkeyColors = {
|
||||||
-- public functions
|
-- public functions
|
||||||
function HotkeysManager.init()
|
function HotkeysManager.init()
|
||||||
hotkeysWindow = g_ui.displayUI('hotkeys_manager.otui')
|
hotkeysWindow = g_ui.displayUI('hotkeys_manager.otui')
|
||||||
|
local hotkeyListPanel = hotkeysWindow:getChildById('currentHotkeys')
|
||||||
|
|
||||||
hotkeysWindow:setVisible(false)
|
hotkeysWindow:setVisible(false)
|
||||||
hotkeysButton = TopMenu.addGameButton('hotkeysButton', tr('Hotkeys') .. ' (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
|
hotkeysButton = TopMenu.addGameButton('hotkeysButton', tr('Hotkeys') .. ' (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
|
||||||
g_keyboard.bindKeyDown('Ctrl+K', 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')
|
currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
|
||||||
currentItemPreview = hotkeysWindow:getChildById('itemPreview')
|
currentItemPreview = hotkeysWindow:getChildById('itemPreview')
|
||||||
|
@ -102,6 +105,7 @@ function HotkeysManager.terminate()
|
||||||
hotkeysManagerLoaded = false
|
hotkeysManagerLoaded = false
|
||||||
|
|
||||||
g_keyboard.unbindKeyDown('Ctrl+K')
|
g_keyboard.unbindKeyDown('Ctrl+K')
|
||||||
|
|
||||||
HotkeysManager.save()
|
HotkeysManager.save()
|
||||||
|
|
||||||
currentHotkeysList = nil
|
currentHotkeysList = nil
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
Inventory = {}
|
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
|
-- private variables
|
||||||
local inventoryWindow
|
local inventoryWindow
|
||||||
local inventoryPanel
|
local inventoryPanel
|
||||||
|
@ -39,7 +53,7 @@ end
|
||||||
|
|
||||||
function Inventory.refresh()
|
function Inventory.refresh()
|
||||||
local player = g_game.getLocalPlayer()
|
local player = g_game.getLocalPlayer()
|
||||||
for i=1,10 do
|
for i=InventorySlotFirst,InventorySlotLast do
|
||||||
if player then
|
if player then
|
||||||
Inventory.onInventoryChange(player, i, player:getInventoryItem(i))
|
Inventory.onInventoryChange(player, i, player:getInventoryItem(i))
|
||||||
else
|
else
|
||||||
|
@ -63,9 +77,15 @@ function Inventory.onMiniWindowClose()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hooked events
|
-- hooked events
|
||||||
function Inventory.onInventoryChange(player, slot, item)
|
function Inventory.onInventoryChange(player, slot, item, oldItem)
|
||||||
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
|
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
|
||||||
|
if(item) then
|
||||||
|
itemWidget:setStyle('Item')
|
||||||
itemWidget:setItem(item)
|
itemWidget:setItem(item)
|
||||||
|
else
|
||||||
|
itemWidget:setStyle(InventorySlotStyles[slot])
|
||||||
|
itemWidget:setItem(nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Inventory.onFreeCapacityChange(player, freeCapacity)
|
function Inventory.onFreeCapacityChange(player, freeCapacity)
|
||||||
|
|
|
@ -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
|
MiniWindow
|
||||||
id: inventoryWindow
|
id: inventoryWindow
|
||||||
!text: tr('Inventory')
|
!text: tr('Inventory')
|
||||||
|
@ -7,83 +47,73 @@ MiniWindow
|
||||||
&save: true
|
&save: true
|
||||||
|
|
||||||
MiniWindowContents
|
MiniWindowContents
|
||||||
Item
|
HeadSlot
|
||||||
// head
|
// head
|
||||||
id: slot1
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
margin-top: 4
|
margin-top: 4
|
||||||
&position: {x=65535, y=1, z=0}
|
&position: {x=65535, y=1, z=0}
|
||||||
|
|
||||||
Item
|
BodySlot
|
||||||
// armor
|
// body
|
||||||
id: slot4
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=4, z=0}
|
&position: {x=65535, y=4, z=0}
|
||||||
|
|
||||||
Item
|
LegSlot
|
||||||
// legs
|
// legs
|
||||||
id: slot7
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=7, z=0}
|
&position: {x=65535, y=7, z=0}
|
||||||
|
|
||||||
Item
|
FeetSlot
|
||||||
// feet
|
// feet
|
||||||
id: slot8
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=8, z=0}
|
&position: {x=65535, y=8, z=0}
|
||||||
|
|
||||||
Item
|
NeckSlot
|
||||||
// necklace
|
// neck
|
||||||
id: slot2
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: slot1.left
|
anchors.right: slot1.left
|
||||||
margin-top: 10
|
margin-top: 10
|
||||||
margin-right: 5
|
margin-right: 5
|
||||||
&position: {x=65535, y=2, z=0}
|
&position: {x=65535, y=2, z=0}
|
||||||
|
|
||||||
Item
|
LeftSlot
|
||||||
// left
|
// left hand
|
||||||
id: slot6
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=6, z=0}
|
&position: {x=65535, y=6, z=0}
|
||||||
|
|
||||||
Item
|
FingerSlot
|
||||||
// ring
|
// finger
|
||||||
id: slot9
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=9, z=0}
|
&position: {x=65535, y=9, z=0}
|
||||||
|
|
||||||
Item
|
BackSlot
|
||||||
// backpack
|
// back
|
||||||
id: slot3
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: slot1.right
|
anchors.left: slot1.right
|
||||||
margin-top: 10
|
margin-top: 10
|
||||||
margin-left: 5
|
margin-left: 5
|
||||||
&position: {x=65535, y=3, z=0}
|
&position: {x=65535, y=3, z=0}
|
||||||
|
|
||||||
Item
|
RightSlot
|
||||||
// right
|
// right hand
|
||||||
id: slot5
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
&position: {x=65535, y=5, z=0}
|
&position: {x=65535, y=5, z=0}
|
||||||
|
|
||||||
Item
|
AmmoSlot
|
||||||
// ammo
|
// ammo
|
||||||
id: slot10
|
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: prev.horizontalCenter
|
anchors.horizontalCenter: prev.horizontalCenter
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
|
@ -98,3 +128,12 @@ MiniWindow
|
||||||
text-align: center
|
text-align: center
|
||||||
text-auto-resize: true
|
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
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.8 KiB |
|
@ -38,7 +38,7 @@ end
|
||||||
-- public functions
|
-- public functions
|
||||||
function Minimap.init()
|
function Minimap.init()
|
||||||
connect(g_game, { onGameStart = Minimap.reset,
|
connect(g_game, { onGameStart = Minimap.reset,
|
||||||
onForceWalk = Minimap.center } )
|
onForceWalk = Minimap.center })
|
||||||
|
|
||||||
g_keyboard.bindKeyDown('Ctrl+M', Minimap.toggle)
|
g_keyboard.bindKeyDown('Ctrl+M', Minimap.toggle)
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ end
|
||||||
|
|
||||||
function Minimap.terminate()
|
function Minimap.terminate()
|
||||||
disconnect(g_game, { onGameStart = Minimap.reset,
|
disconnect(g_game, { onGameStart = Minimap.reset,
|
||||||
onForceWalk = Minimap.center } )
|
onForceWalk = Minimap.center })
|
||||||
|
|
||||||
g_keyboard.unbindKeyDown('Ctrl+M')
|
g_keyboard.unbindKeyDown('Ctrl+M')
|
||||||
|
|
||||||
|
@ -104,19 +104,6 @@ function Minimap.onMiniWindowClose()
|
||||||
minimapButton:setOn(false)
|
minimapButton:setOn(false)
|
||||||
end
|
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)
|
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)
|
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y)
|
||||||
end
|
end
|
||||||
|
@ -160,3 +147,17 @@ function Minimap.onButtonClick(id)
|
||||||
minimapWidget:setCameraPosition(pos)
|
minimapWidget:setCameraPosition(pos)
|
||||||
end
|
end
|
||||||
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
|