mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
add onGameStart/onGameEnd/onLogin/onLogout events
This commit is contained in:
@@ -25,8 +25,8 @@ function TopMenu.init()
|
||||
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
|
||||
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
|
||||
|
||||
connect(Game, { onLogin = TopMenu.showGameButtons,
|
||||
onLogout = TopMenu.hideGameButtons })
|
||||
connect(Game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
end
|
||||
|
||||
function TopMenu.terminate()
|
||||
@@ -37,8 +37,8 @@ function TopMenu.terminate()
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
|
||||
disconnect(Game, { onLogin = TopMenu.showGameButtons,
|
||||
onLogout = TopMenu.hideGameButtons })
|
||||
disconnect(Game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
|
||||
TopMenu = nil
|
||||
end
|
||||
|
@@ -108,5 +108,5 @@ local function onApplicationClose()
|
||||
end
|
||||
|
||||
setonclose(onApplicationClose)
|
||||
connect(Game, { onLogin = Game.createInterface }, true)
|
||||
connect(Game, { onLogout = Game.destroyInterface })
|
||||
connect(Game, { onGameStart = Game.createInterface }, true)
|
||||
connect(Game, { onGameEnd = Game.destroyInterface })
|
||||
|
@@ -66,8 +66,8 @@ function CombatControls.init()
|
||||
connect(fightModeRadioGroup, { onSelectionChange = onFightModeChange })
|
||||
connect(chaseModeButton, { onCheckChange = onChaseModeChange })
|
||||
connect(safeFightButton, { onCheckChange = onSafeFightChange })
|
||||
connect(Game, { onLogin = CombatControls.online })
|
||||
connect(Game, { onLogout = CombatControls.offline })
|
||||
connect(Game, { onGameStart = CombatControls.online })
|
||||
connect(Game, { onGameEnd = CombatControls.offline })
|
||||
|
||||
if Game.isOnline() then
|
||||
CombatControls.online()
|
||||
@@ -94,8 +94,8 @@ function CombatControls.terminate()
|
||||
combatControlsWindow:destroy()
|
||||
combatControlsWindow = nil
|
||||
|
||||
disconnect(Game, { onLogin = CombatControls.online })
|
||||
disconnect(Game, { onLogout = CombatControls.offline })
|
||||
disconnect(Game, { onGameStart = CombatControls.online })
|
||||
disconnect(Game, { onGameEnd = CombatControls.offline })
|
||||
|
||||
CombatControls = nil
|
||||
end
|
||||
|
@@ -365,8 +365,8 @@ local function onChannelList(channelList)
|
||||
end
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Console.create,
|
||||
onLogout = Console.destroy,
|
||||
connect(Game, { onGameStart = Console.create,
|
||||
onGameEnd = Console.destroy,
|
||||
onCreatureSpeak = onCreatureSpeak,
|
||||
onChannelList = onChannelList,
|
||||
onOpenChannel = onOpenChannel,
|
||||
|
@@ -43,7 +43,7 @@ function Containers.onContainerOpen(containerId, itemId, name, capacity, hasPare
|
||||
itemWidget:setStyle('Item')
|
||||
container:addChild(itemWidget)
|
||||
itemWidget.position = {x=65535, y=containerId+64, z=i-1}
|
||||
|
||||
|
||||
if i <= #items then
|
||||
local item = items[i]
|
||||
item:setPosition(itemWidget.position)
|
||||
@@ -70,7 +70,7 @@ function Containers.onContainerAddItem(containerId, item)
|
||||
while i >= 1 do
|
||||
local itemWidget = container:getChildByIndex(i)
|
||||
if not itemWidget then return end
|
||||
|
||||
|
||||
local nextItemWidget = container:getChildByIndex(i+1)
|
||||
if not nextItemWidget then return end
|
||||
|
||||
@@ -79,7 +79,7 @@ function Containers.onContainerAddItem(containerId, item)
|
||||
swapItem:setPosition(nextItemWidget.position)
|
||||
nextItemWidget:setItem(swapItem)
|
||||
end
|
||||
|
||||
|
||||
i = i - 1
|
||||
end
|
||||
|
||||
@@ -94,7 +94,7 @@ end
|
||||
function Containers.onContainerUpdateItem(containerId, slot, item)
|
||||
local container = m_containers[containerId]
|
||||
if not container then return end
|
||||
|
||||
|
||||
local itemWidget = container:getChildByIndex(slot + 1)
|
||||
if not itemWidget then return end
|
||||
itemWidget:setItem(item)
|
||||
@@ -104,35 +104,35 @@ end
|
||||
function Containers.onContainerRemoveItem(containerId, slot)
|
||||
local container = m_containers[containerId]
|
||||
if not container then return end
|
||||
|
||||
|
||||
local itemWidget = container:getChildByIndex(slot+1)
|
||||
if not itemWidget then return end
|
||||
itemWidget:setItem(nil)
|
||||
|
||||
|
||||
for i=slot,container.itemCount-2 do
|
||||
local itemWidget = container:getChildByIndex(i+1)
|
||||
if not itemWidget then return end
|
||||
|
||||
|
||||
local nextItemWidget = container:getChildByIndex(i+2)
|
||||
if not nextItemWidget then return end
|
||||
|
||||
|
||||
local item = nextItemWidget:getItem()
|
||||
local pos = item:getPosition()
|
||||
pos.z = pos.z - 1
|
||||
item:setPosition(pos)
|
||||
|
||||
|
||||
itemWidget:setItem(item)
|
||||
nextItemWidget:setItem(nil)
|
||||
end
|
||||
|
||||
|
||||
container.itemCount = container.itemCount - 1
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Containers.clean,
|
||||
onLogout = Containers.clean,
|
||||
connect(Game, { onGameStart = Containers.clean,
|
||||
onGameEnd = Containers.clean,
|
||||
onContainerOpen = Containers.onContainerOpen,
|
||||
onContainerClose = Containers.onContainerClose,
|
||||
onContainerAddItem = Containers.onContainerAddItem,
|
||||
onContainerUpdateItem = Containers.onContainerUpdateItem,
|
||||
onContainerRemoveItem = Containers.onContainerRemoveItem })
|
||||
|
||||
|
||||
|
@@ -53,7 +53,7 @@ function HealthBar.onManaChange(mana, maxMana)
|
||||
manaBar:setPercent(percent)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = HealthBar.create,
|
||||
onLogout = HealthBar.destroy,
|
||||
connect(Game, { onGameStart = HealthBar.create,
|
||||
onGameEnd = HealthBar.destroy,
|
||||
onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
|
@@ -42,8 +42,8 @@ function Inventory.onSoulChange(soul)
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Inventory.create,
|
||||
onLogout = Inventory.destroy,
|
||||
connect(Game, { onGameStart = Inventory.create,
|
||||
onGameEnd = Inventory.destroy,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
|
@@ -199,4 +199,4 @@ end
|
||||
|
||||
-- hooked events
|
||||
connect(Game, { onOpenOutfitWindow = Outfit.create,
|
||||
onLogout = Outfit.destroy })
|
||||
onGameEnd = Outfit.destroy })
|
||||
|
@@ -122,8 +122,8 @@ function Skills.onSkillChange(id, level, percent)
|
||||
setSkillPercent('skillId' .. id, percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Skills.create,
|
||||
onLogout = Skills.destroy,
|
||||
connect(Game, { onGameStart = Skills.create,
|
||||
onGameEnd = Skills.destroy,
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
|
@@ -111,7 +111,7 @@ local function onGameTextMessage(msgtypedesc, msg)
|
||||
TextMessage.display(msgtypedesc, msg)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = TextMessage.create,
|
||||
onLogout = TextMessage.destroy,
|
||||
connect(Game, { onGameStart = TextMessage.create,
|
||||
onGameEnd = TextMessage.destroy,
|
||||
onDeath = onGameDeath,
|
||||
onTextMessage = onGameTextMessage })
|
||||
|
@@ -57,7 +57,7 @@ function VipList.onAddVip(id, name, online)
|
||||
|
||||
label:setPhantom(false)
|
||||
connect(label, { onDoubleClick = function () Game.openPrivateChannel(label:getText()) return true end } )
|
||||
|
||||
|
||||
local nameLower = name:lower()
|
||||
local childrenCount = vipList:getChildCount()
|
||||
|
||||
@@ -123,7 +123,7 @@ function VipList.onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||
end
|
||||
|
||||
|
||||
connect(Game, { onLogin = VipList.create,
|
||||
onLogout = VipList.destroy,
|
||||
connect(Game, { onGameStart = VipList.create,
|
||||
onGameEnd = VipList.destroy,
|
||||
onAddVip = VipList.onAddVip,
|
||||
onVipStateChange = VipList.onVipStateChange })
|
||||
|
Reference in New Issue
Block a user