mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
finally reloadable vip, skills, inventory, chat and minimap
This commit is contained in:
@@ -113,7 +113,7 @@ end
|
||||
local function onOpenPrivateChannel(receiver)
|
||||
local privateTab = Console.getTab(receiver)
|
||||
if privateTab == nil then
|
||||
Console.addTab(receiver)
|
||||
Console.addTab(receiver, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -7,10 +7,9 @@ local inventoryButton
|
||||
|
||||
-- public functions
|
||||
function Inventory.init()
|
||||
connect(g_game, { onGameEnd = Inventory.clear,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
connect(LocalPlayer, { onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange })
|
||||
connect(g_game, { onGameEnd = Inventory.clear })
|
||||
|
||||
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||
|
||||
@@ -20,16 +19,13 @@ function Inventory.init()
|
||||
inventoryButton = TopMenu.addGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||
inventoryButton:setOn(true)
|
||||
|
||||
if g_game.isOnline() then
|
||||
Inventory.reload()
|
||||
end
|
||||
Inventory.refresh()
|
||||
end
|
||||
|
||||
function Inventory.terminate()
|
||||
connect(g_game, { onGameEnd = Inventory.clear,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
disconnect(LocalPlayer, { onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange })
|
||||
disconnect(g_game, { onGameEnd = Inventory.clear })
|
||||
|
||||
Keyboard.unbindKeyDown('Ctrl+I')
|
||||
|
||||
@@ -42,30 +38,29 @@ function Inventory.terminate()
|
||||
Inventory = nil
|
||||
end
|
||||
|
||||
function Inventory.refresh()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if not player then return end
|
||||
|
||||
for i=1,10 do
|
||||
Inventory.onInventoryChange(player, i, player:getInventoryItem(i))
|
||||
end
|
||||
end
|
||||
|
||||
function Inventory.toggle()
|
||||
local visible = not inventoryWindow:isExplicitlyVisible()
|
||||
inventoryWindow:setVisible(visible)
|
||||
inventoryButton:setOn(visible)
|
||||
end
|
||||
|
||||
function Inventory.clear()
|
||||
end
|
||||
|
||||
function Inventory.reload()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Inventory.onInventoryChange(slot, item)
|
||||
function Inventory.onInventoryChange(player, slot, item)
|
||||
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
|
||||
itemWidget:setItem(item)
|
||||
end
|
||||
|
||||
function Inventory.onFreeCapacityChange(freeCapacity)
|
||||
function Inventory.onFreeCapacityChange(player, freeCapacity)
|
||||
local widget = inventoryPanel:getChildById('capacity')
|
||||
widget:setText("Cap:\n" .. freeCapacity)
|
||||
end
|
||||
|
||||
function Inventory.onSoulChange(soul)
|
||||
local widget = inventoryPanel:getChildById('soul')
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
@@ -3,6 +3,7 @@ Minimap = {}
|
||||
-- private variables
|
||||
local minimapWidget
|
||||
local minimapButton
|
||||
local DEFAULT_ZOOM = 45
|
||||
|
||||
-- private functions
|
||||
function onMinimapMouseRelease(self, mousePosition, mouseButton)
|
||||
@@ -40,6 +41,8 @@ function Minimap.init()
|
||||
minimapWidget.onMouseRelease = onMinimapMouseRelease
|
||||
minimapWidget.onMouseWheel = onMinimapMouseWheel
|
||||
minimapWidget:hide()
|
||||
|
||||
Minimap.reset()
|
||||
end
|
||||
|
||||
function Minimap.terminate()
|
||||
@@ -61,7 +64,9 @@ function Minimap.toggle()
|
||||
end
|
||||
|
||||
function Minimap.reset()
|
||||
minimapWidget:followCreature(g_game.getLocalPlayer())
|
||||
for i=1,10 do minimapWidget:zoomOut() end
|
||||
local player = g_game.getLocalPlayer()
|
||||
if not player then return end
|
||||
minimapWidget:followCreature(player)
|
||||
minimapWidget:setZoom(DEFAULT_ZOOM)
|
||||
end
|
||||
|
||||
|
@@ -39,6 +39,8 @@ function Skills.init()
|
||||
skillsButton = TopMenu.addGameToggleButton('skillsButton', tr('Skills') .. ' (Ctrl+S)', 'skills.png', Skills.toggle)
|
||||
skillsButton:setOn(true)
|
||||
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
|
||||
|
||||
Skills.refresh()
|
||||
end
|
||||
|
||||
function Skills.terminate()
|
||||
@@ -63,6 +65,24 @@ function Skills.terminate()
|
||||
Skills = nil
|
||||
end
|
||||
|
||||
function Skills.refresh()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if not player then return end
|
||||
|
||||
Skills.onExperienceChange(player, player:getExperience())
|
||||
Skills.onLevelChange(player, player:getLevel(), player:getLevelPercent())
|
||||
Skills.onHealthChange(player, player:getHealth(), player:getMaxHealth())
|
||||
Skills.onManaChange(player, player:getMana(), player:getMaxMana())
|
||||
Skills.onSoulChange(player, player:getSoul())
|
||||
Skills.onFreeCapacityChange(player, player:getFreeCapacity())
|
||||
Skills.onStaminaChange(player, player:getStamina())
|
||||
Skills.onMagicLevelChange(player, player:getMagicLevel(), player:getMagicLevelPercent())
|
||||
|
||||
for i=0,6 do
|
||||
Skills.onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i))
|
||||
end
|
||||
end
|
||||
|
||||
function Skills.toggle()
|
||||
local visible = not skillsWindow:isExplicitlyVisible()
|
||||
skillsWindow:setVisible(visible)
|
||||
|
@@ -15,6 +15,8 @@ function VipList.init()
|
||||
vipWindow = displayUI('viplist.otui', GameInterface.getLeftPanel())
|
||||
vipButton = TopMenu.addGameToggleButton('vipListButton', tr('VIP list'), 'viplist.png', VipList.toggle)
|
||||
vipButton:setOn(true)
|
||||
|
||||
VipList.refresh()
|
||||
end
|
||||
|
||||
function VipList.terminate()
|
||||
@@ -30,6 +32,13 @@ function VipList.terminate()
|
||||
VipList = nil
|
||||
end
|
||||
|
||||
function VipList.refresh()
|
||||
VipList.clear()
|
||||
for id,vip in pairs(g_game.getVips()) do
|
||||
VipList.onAddVip(id, unpack(vip))
|
||||
end
|
||||
end
|
||||
|
||||
function VipList.clear()
|
||||
local vipList = vipWindow:getChildById('contentsPanel')
|
||||
vipList:destroyChildren()
|
||||
|
Reference in New Issue
Block a user