This commit is contained in:
Eduardo Bart 2012-10-08 22:00:53 -03:00
commit ba407072a5
10 changed files with 214 additions and 129 deletions

View File

@ -0,0 +1,93 @@
cooldownPanel = nil
spellCooldownPanel = nil
function init()
connect(g_game, { onGameStart = show,
onGameEnd = hide,
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
cooldownPanel = g_ui.displayUI('cooldown.otui')
cooldownPanel:hide()
spellCooldownPanel = cooldownPanel:getChildById('spellCooldownPanel')
if g_game.isOnline() then
show()
end
end
function terminate()
disconnect(g_game, { onGameStart = show,
onGameEnd = hide,
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
spellCooldownPanel:destroy()
cooldownPanel:destroy()
end
function show()
if g_game.getFeature(GameSpellList) then
cooldownPanel:show()
end
end
function hide()
cooldownPanel:hide()
end
function updateProgressRect(progressRect, interval, init)
if init then
progressRect:setPercent(0)
else
progressRect:setPercent(progressRect:getPercent() + 4)
end
if progressRect:getPercent() < 100 then
removeEvent(progressRect.event)
progressRect.event = scheduleEvent(function() updateProgressRect(progressRect, interval) end, interval)
end
end
function onSpellCooldown(iconId, duration)
local spellName = SpelllistSettings[modules.game_spelllist.getSpelllistProfile()].spellIcons[iconId]
if not spellName then return end
local otcIconId = tonumber(SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon)
if not otcIconId and SpellIcons[SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon] then
otcIconId = SpellIcons[SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon][1]
end
if not otcIconId then return end
local icon = cooldownPanel:getChildById(spellName)
if not icon then
icon = g_ui.createWidget('SpellIcon', spellCooldownPanel)
icon:setId(spellName)
icon:setImageSource('/game_cooldown/icons/' .. SpelllistSettings[modules.game_spelllist.getSpelllistProfile()].iconFile)
icon:setTooltip(spellformula)
icon:setImageClip(modules.game_spelllist.getIconImageClip(otcIconId))
icon.event = scheduleEvent(function() icon:destroy() end, duration)
local progressRect = g_ui.createWidget('ProgressRect', icon)
updateProgressRect(progressRect, duration/25, true)
end
end
function onSpellGroupCooldown(groupId, duration)
if not SpellGroups[groupId] then return end
local icon = cooldownPanel:getChildById('groupIcon' .. SpellGroups[groupId])
local progressRect = cooldownPanel:getChildById('progressRect' .. SpellGroups[groupId])
if icon then
icon:setOn(true)
removeEvent(icon.event)
icon.event = scheduleEvent(function() icon:setOn(false) end, duration)
end
if progressRect then
removeEvent(progressRect.event)
updateProgressRect(progressRect, duration/25, true)
end
end

View File

@ -0,0 +1,9 @@
Module
name: game_cooldown
description: Spellcooldowns
author: OTClient team
website: www.otclient.info
sandboxed: true
scripts: [ cooldown.lua ]
@onLoad: init()
@onUnload: terminate()

View File

@ -0,0 +1,104 @@
SpellGroupIcon < UIWidget
size: 22 22
image-size: 22 22
image-source: /game_cooldown/icons/cooldownIcons.png
focusable: false
SpellIcon < UIWidget
size: 22 22
image-size: 22 22
margin-left: 2
anchors.top: prev.top
anchors.left: prev.right
focusable: false
$first:
margin-top: 3
anchors.top: parent.top
anchors.left: parent.left
ProgressRect < UIProgressRect
background: #585858AA
percent: 100
anchors.fill: parent
focusable: false
Panel
id: spellPanel
layout:
type: anchor
height: 28
width: 250
anchors.top: parent.top
anchors.left: parent.left
margin-top: 70
margin-left: 10
border-width: 1
border-color: #00000077
background-color: #ffffff11
focusable: false
SpellGroupIcon
id: groupIconAttack
image-clip: 0 0 20 20
anchors.top: parent.top
anchors.left: parent.left
margin-top: 3
margin-left: 3
$on:
image-clip: 0 20 20 20
ProgressRect
id: progressRectAttack
anchors.fill: groupIconAttack
!tooltip: tr('Attack')
SpellGroupIcon
id: groupIconHealing
image-clip: 20 0 20 20
anchors.top: parent.top
anchors.left: groupIconAttack.right
margin-top: 3
margin-left: 3
$on:
image-clip: 20 20 20 20
ProgressRect
id: progressRectHealing
anchors.fill: groupIconHealing
!tooltip: tr('Healing')
SpellGroupIcon
id: groupIconSupport
image-clip: 40 0 20 20
anchors.top: parent.top
anchors.left: groupIconHealing.right
margin-top: 3
margin-left: 3
$on:
image-clip: 40 20 20 20
ProgressRect
id: progressRectSupport
anchors.fill: groupIconSupport
!tooltip: tr('Support')
SpellGroupIcon
id: groupIconSpecial
image-clip: 60 0 20 20
anchors.top: parent.top
anchors.left: groupIconSupport.right
margin-top: 3
margin-left: 3
$on:
image-clip: 60 20 20 20
ProgressRect
id: progressRectSpecial
anchors.fill: groupIconSpecial
!tooltip: tr('Special')
Panel
id: spellCooldownPanel
anchors.fill: parent
margin-left: 102

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -10,7 +10,6 @@ mouseGrabberWidget = nil
countWindow = nil countWindow = nil
logoutWindow = nil logoutWindow = nil
exitWindow = nil exitWindow = nil
cooldownPanel = nil
function init() function init()
g_ui.importStyle('styles/countwindow.otui') g_ui.importStyle('styles/countwindow.otui')
@ -23,8 +22,6 @@ function init()
gameRootPanel:hide() gameRootPanel:hide()
gameRootPanel:lower() gameRootPanel:lower()
cooldownPanel = gameRootPanel:getChildById('spellPanel')
mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber') mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease
@ -82,8 +79,6 @@ function terminate()
onLoginAdvice = onLoginAdvice }) onLoginAdvice = onLoginAdvice })
disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange }) disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
cooldownPanel:destroy()
logoutButton:destroy() logoutButton:destroy()
gameRootPanel:destroy() gameRootPanel:destroy()
end end
@ -95,8 +90,6 @@ function show()
gameRootPanel:show() gameRootPanel:show()
gameRootPanel:focus() gameRootPanel:focus()
gameMapPanel:followCreature(g_game.getLocalPlayer()) gameMapPanel:followCreature(g_game.getLocalPlayer())
cooldownPanel:setVisible((g_game.getClientVersion() >= 870))
end end
function hide() function hide()
@ -551,31 +544,4 @@ function onLeftPanelVisibilityChange(leftPanel, visible)
children[i]:setParent(gameRightPanel) children[i]:setParent(gameRightPanel)
end end
end end
end end
function setGroupCooldown(groupId, duration)
if not SpellGroups[groupId] then return end
local icon = gameRootPanel:getChildById('groupIcon' .. SpellGroups[groupId])
if icon then
icon:setOn(true)
removeEvent(icon.event)
icon.event = scheduleEvent(function() icon:setOn(false) end, duration)
end
end
function setCooldown(iconFile, iconId, spellformula, duration)
local icon = cooldownPanel:getChildById(spellformula)
if icon then
removeEvent(icon.event)
icon.event = scheduleEvent(function() icon:destroy() end, duration)
else
icon = g_ui.createWidget('SpellIcon', cooldownPanel)
icon:setId(spellformula)
icon:setImageSource('/game_spelllist/icons/' .. iconFile)
icon:setTooltip(spellformula)
icon:setImageClip(modules.game_spelllist.getIconImageClip(iconId))
icon.event = scheduleEvent(function() icon:destroy() end, duration)
end
end

View File

@ -1,19 +1,4 @@
SpellGroupIcon < UIWidget
size: 22 22
image-size: 22 22
image-source: /game_spelllist/icons/cooldownIcons.png
focusable: false
SpellIcon < UIWidget
size: 22 22
image-size: 22 22
margin-right: 3
margin-top: 6
margin-left: 3
focusable: false
$first:
margin-left: 100
GameSidePanel < UIMiniWindowContainer GameSidePanel < UIMiniWindowContainer
image-source: /images/sidepanel.png image-source: /images/sidepanel.png
image-border: 4 image-border: 4
@ -71,67 +56,6 @@ UIWidget
focusable: false focusable: false
on: true on: true
Panel
id: spellPanel
layout:
type: horizontalBox
height: 32
width: 250
anchors.left: gameLeftPanel.right
anchors.bottom: parent.bottom
relative-margin: bottom
margin-bottom: 187
margin-left: 10
border-width: 1
border-color: #00000077
background-color: #ffffff11
focusable: false
SpellGroupIcon
id: groupIconAttack
parent: spellPanel
image-clip: 0 32 32 32
anchors.top: spellPanel.top
anchors.left: spellPanel.left
!tooltip: tr('Attack')
margin-top: 3
margin-left: 3
$on:
image-clip: 0 0 32 32
SpellGroupIcon
id: groupIconHealing
image-clip: 32 32 32 32
anchors.top: spellPanel.top
anchors.left: groupIconAttack.right
!tooltip: tr('Healing')
margin-top: 3
margin-left: 3
$on:
image-clip: 32 0 32 32
SpellGroupIcon
id: groupIconSupport
image-clip: 64 32 32 32
anchors.top: spellPanel.top
anchors.left: groupIconHealing.right
!tooltip: tr('Support')
margin-top: 3
margin-left: 3
$on:
image-clip: 64 0 32 32
SpellGroupIcon
id: groupIconSpecial
image-clip: 96 32 32 32
anchors.top: spellPanel.top
anchors.left: groupIconSupport.right
!tooltip: tr('Special')
margin-top: 3
margin-left: 3
$on:
image-clip: 96 0 32 32
Splitter Splitter
id: bottomSplitter id: bottomSplitter
anchors.left: gameLeftPanel.right anchors.left: gameLeftPanel.right
@ -140,9 +64,9 @@ UIWidget
relative-margin: bottom relative-margin: bottom
margin-bottom: 172 margin-bottom: 172
@canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end
@onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) self:getParent():getChildById('spellPanel'):setMarginBottom(15 + math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end
UIWidget UIWidget
id: mouseGrabber id: mouseGrabber
focusable: false focusable: false
visible: false visible: false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -59,6 +59,10 @@ local filters = {
groupId = FILTER_GROUP_ANY groupId = FILTER_GROUP_ANY
} }
function getSpelllistProfile()
return SpelllistProfile
end
function setSpelllistProfile(name) function setSpelllistProfile(name)
if SpelllistProfile == name then return end if SpelllistProfile == name then return end
@ -83,24 +87,9 @@ function setOptions()
end end
end end
function onSpellCooldown(iconId, duration)
local spellName = SpelllistSettings[SpelllistProfile].spellIcons[iconId]
if not spellName then return end
local otcIconId = tonumber(SpellInfo[SpelllistProfile][spellName].icon)
if not otcIconId and SpellIcons[SpellInfo[SpelllistProfile][spellName].icon] then
otcIconId = SpellIcons[SpellInfo[SpelllistProfile][spellName].icon][1]
end
if not otcIconId then return end
modules.game_interface.setCooldown(SpelllistSettings[SpelllistProfile].iconFile, otcIconId, spellName, duration)
end
function init() function init()
connect(g_game, { onGameStart = setOptions, connect(g_game, { onGameStart = setOptions,
onGameEnd = resetWindow, onGameEnd = resetWindow })
onSpellGroupCooldown = modules.game_interface.setGroupCooldown,
onSpellCooldown = onSpellCooldown })
spelllistWindow = g_ui.displayUI('spelllist.otui', modules.game_interface.getRightPanel()) spelllistWindow = g_ui.displayUI('spelllist.otui', modules.game_interface.getRightPanel())
spelllistWindow:hide() spelllistWindow:hide()