@ -1,3 +1,21 @@
SpelllistSettings = {
[ ' Default ' ] = {
iconFile = ' icons.png ' ,
iconSize = { width = 32 , height = 32 } ,
spellListWidth = 210 ,
spellWindowWidth = 550 ,
spellOrder = { ' Animate Dead ' , ' Annihilation ' , ' Avalanche ' , ' Berserk ' , ' Blood Rage ' , ' Brutal Strike ' , ' Cancel Invisibility ' , ' Challenge ' , ' Chameleon ' , ' Charge ' , ' Conjure Arrow ' , ' Conjure Bolt ' , ' Conjure Explosive Arrow ' , ' Conjure Piercing Bolt ' , ' Conjure Poisoned Arrow ' , ' Conjure Power Bolt ' , ' Conjure Sniper Arrow ' , ' Convince Creature ' , ' Creature Illusion ' , ' Cure Bleeding ' , ' Cure Burning ' , ' Cure Curse ' , ' Cure Electrification ' , ' Cure Poison ' , ' Cure Poison Rune ' , ' Curser ' , ' Death Strike ' , ' Desintegrate ' , ' Destroy Field ' , ' Divine Caldera ' , ' Divine Healing ' , ' Divine Missile ' , ' Electrify ' , ' Enchant Party ' , ' Enchant Spear ' , ' Enchant Staff ' , ' Energy Beam ' , ' Energy Field ' , ' Energy Strike ' , ' Energy Wall ' , ' Energy Wave ' , ' Energybomb ' , ' Envenom ' , ' Eternal Winter ' , ' Ethereal Spear ' , ' Explosion ' , ' Fierce Berserk ' , ' Find Person ' , ' Fire Field ' , ' Fire Wall ' , ' Fire Wave ' , ' Fireball ' , ' Firebomb ' , ' Flame Strike ' , ' Food ' , ' Front Sweep ' , ' Great Energy Beam ' , ' Great Fireball ' , ' Great Light ' , ' Groundshaker ' , ' Haste ' , ' Heal Friend ' , ' Heal Party ' , ' Heavy Magic Missile ' , ' Hells Core ' , ' Holy Flash ' , ' Holy Missile ' , ' Ice Strike ' , ' Ice Wave ' , ' Icicle ' , ' Ignite ' , ' Inflict Wound ' , ' Intense Healing ' , ' Intense Healing Rune ' , ' Intense Recovery ' , ' Intense Wound Cleansing ' , ' Invisibility ' , ' Levitate ' , ' Light ' , ' Light Healing ' , ' Light Magic Missile ' , ' Lightning ' , ' Magic Rope ' , ' Magic Shield ' , ' Magic Wall ' , ' Mass Healing ' , ' Paralyze ' , ' Physical Strike ' , ' Poison Bomb ' , ' Poison Field ' , ' Poison Wall ' , ' Protect Party ' , ' Protector ' , ' Rage of the Skies ' , ' Recovery ' , ' Salvation ' , ' Sharpshooter ' , ' Soulfire ' , ' Stalagmite ' , ' Stone Shower ' , ' Strong Energy Strike ' , ' Strong Ethereal Spear ' , ' Strong Flame Strike ' , ' Strong Haste ' , ' Strong Ice Strike ' , ' Strong Ice Wave ' , ' Strong Terra Strike ' , ' Sudden Death ' , ' Summon Creature ' , ' Swift Foot ' , ' Terra Strike ' , ' Terra Wave ' , ' Thunderstorm ' , ' Train Party ' , ' Ultimate Energy Strike ' , ' Ultimate Flame Strike ' , ' Ultimate Healing ' , ' Ultimate Healing Rune ' , ' Ultimate Ice Strike ' , ' Ultimate Light ' , ' Ultimate Terra Strike ' , ' Whirlwind Throw ' , ' Wild Growth ' , ' Wound Cleansing ' , ' Wrath of Nature ' }
} ,
[ ' Sample ' ] = {
iconFile = ' sample.png ' ,
iconSize = { width = 64 , height = 64 } ,
spellOrder = { ' Critical Strike ' , ' Firefly ' , ' Fire Breath ' , ' Moonglaives ' , ' Wind Walk ' }
}
}
local SpelllistProfile = ' Default '
spelllistWindow = nil
spelllistButton = nil
spellList = nil
@ -10,6 +28,7 @@ cooldownValueLabel = nil
levelValueLabel = nil
manaValueLabel = nil
premiumValueLabel = nil
descriptionValueLabel = nil
vocationBoxAny = nil
vocationBoxSorcerer = nil
@ -56,13 +75,23 @@ local filters = {
groupId = FILTER_GROUP_ANY
}
local spellDisplayOrder = { ' Animate Dead ' , ' Annihilation ' , ' Avalanche ' , ' Berserk ' , ' Blood Rage ' , ' Brutal Strike ' , ' Cancel Invisibility ' , ' Challenge ' , ' Chameleon ' , ' Charge ' , ' Conjure Arrow ' , ' Conjure Bolt ' , ' Conjure Explosive Arrow ' , ' Conjure Piercing Bolt ' , ' Conjure Poisoned Arrow ' , ' Conjure Power Bolt ' , ' Conjure Sniper Arrow ' , ' Convince Creature ' , ' Creature Illusion ' , ' Cure Bleeding ' , ' Cure Burning ' , ' Cure Curse ' , ' Cure Electrification ' , ' Cure Poison ' , ' Cure Poison Rune ' , ' Curser ' , ' Death Strike ' , ' Desintegrate ' , ' Destroy Field ' , ' Divine Caldera ' , ' Divine Healing ' , ' Divine Missile ' , ' Electrify ' , ' Enchant Party ' , ' Enchant Spear ' , ' Enchant Staff ' , ' Energy Beam ' , ' Energy Field ' , ' Energy Strike ' , ' Energy Wall ' , ' Energy Wave ' , ' Energybomb ' , ' Envenom ' , ' Eternal Winter ' , ' Ethereal Spear ' , ' Explosion ' , ' Fierce Berserk ' , ' Find Person ' , ' Fire Field ' , ' Fire Wall ' , ' Fire Wave ' , ' Fireball ' , ' Firebomb ' , ' Flame Strike ' , ' Food ' , ' Front Sweep ' , ' Great Energy Beam ' , ' Great Fireball ' , ' Great Light ' , ' Groundshaker ' , ' Haste ' , ' Heal Friend ' , ' Heal Party ' , ' Heavy Magic Missile ' , ' Hells Core ' , ' Holy Flash ' , ' Holy Missile ' , ' Ice Strike ' , ' Ice Wave ' , ' Icicle ' , ' Ignite ' , ' Inflict Wound ' , ' Intense Healing ' , ' Intense Healing Rune ' , ' Intense Recovery ' , ' Intense Wound Cleansing ' , ' Invisibility ' , ' Levitate ' , ' Light ' , ' Light Healing ' , ' Light Magic Missile ' , ' Lightning ' , ' Magic Rope ' , ' Magic Shield ' , ' Magic Wall ' , ' Mass Healing ' , ' Paralyze ' , ' Physical Strike ' , ' Poison Bomb ' , ' Poison Field ' , ' Poison Wall ' , ' Protect Party ' , ' Protector ' , ' Rage of the Skies ' , ' Recovery ' , ' Salvation ' , ' Sharpshooter ' , ' Soulfire ' , ' Stalagmite ' , ' Stone Shower ' , ' Strong Energy Strike ' , ' Strong Ethereal Spear ' , ' Strong Flame Strike ' , ' Strong Haste ' , ' Strong Ice Strike ' , ' Strong Ice Wave ' , ' Strong Terra Strike ' , ' Sudden Death ' , ' Summon Creature ' , ' Swift Foot ' , ' Terra Strike ' , ' Terra Wave ' , ' Thunderstorm ' , ' Train Party ' , ' Ultimate Energy Strike ' , ' Ultimate Flame Strike ' , ' Ultimate Healing ' , ' Ultimate Healing Rune ' , ' Ultimate Ice Strike ' , ' Ultimate Light ' , ' Ultimate Terra Strike ' , ' Whirlwind Throw ' , ' Wild Growth ' , ' Wound Cleansing ' , ' Wrath of Nature ' }
function setSpelllistProfile ( name )
if SpelllistProfile == name then return end
if SpelllistSettings [ name ] and SpellInfo [ name ] then
local oldProfile = SpelllistProfile
SpelllistProfile = name
changeSpelllistProfile ( oldProfile )
else
perror ( ' Spelllist profile \' ' .. name .. ' \' could not be set. ' )
end
end
function getIconImageClip ( id )
return ( ( ( id - 1 ) % 12 ) * 32 ) .. ' ' .. ( ( math.ceil ( id / 12 ) - 1 ) * 32 ) .. ' 32 32 '
return ( ( ( id - 1 ) % 12 ) * SpelllistSettings [ SpelllistProfile ] . iconSize.width ) .. ' ' .. ( ( math.ceil ( id / 12 ) - 1 ) * SpelllistSettings [ SpelllistProfile ] . iconSize.height ) .. ' ' .. SpelllistSettings [ SpelllistProfile ] . iconSize.width .. ' ' .. SpelllistSettings [ SpelllistProfile ] . iconSize.height
end
function setupOptions ( )
function set Options( )
if g_game.getClientVersion ( ) >= 950 then -- Vocation is only send in newer clients
spelllistWindow : getChildById ( ' buttonFilterVocation ' ) : setVisible ( true )
else
@ -71,7 +100,7 @@ function setupOptions()
end
function init ( )
connect ( g_game , { onGameStart = set up Options,
connect ( g_game , { onGameStart = set Options,
onGameEnd = resetWindow } )
spelllistWindow = g_ui.displayUI ( ' spelllist.otui ' , modules.game_interface . getRightPanel ( ) )
@ -89,6 +118,7 @@ function init()
levelValueLabel = spelllistWindow : getChildById ( ' labelLevelValue ' )
manaValueLabel = spelllistWindow : getChildById ( ' labelManaValue ' )
premiumValueLabel = spelllistWindow : getChildById ( ' labelPremiumValue ' )
descriptionValueLabel = spelllistWindow : getChildById ( ' labelDescriptionValue ' )
vocationBoxAny = spelllistWindow : getChildById ( ' vocationBoxAny ' )
vocationBoxSorcerer = spelllistWindow : getChildById ( ' vocationBoxSorcerer ' )
@ -136,33 +166,13 @@ function init()
g_keyboard.bindKeyPress ( ' Down ' , function ( ) spellList : focusNextChild ( KeyboardFocusReason ) end , spelllistWindow )
g_keyboard.bindKeyPress ( ' Up ' , function ( ) spellList : focusPreviousChild ( KeyboardFocusReason ) end , spelllistWindow )
for i = 1 , # spellDisplayOrder do
local spell = spellDisplayOrder [ i ]
local info = SpellInfo [ spell ]
local tmpLabel = g_ui.createWidget ( ' SpellListLabel ' , spellList )
tmpLabel : setId ( spell )
tmpLabel : setText ( spell .. ' \n \' ' .. info.words .. ' \' ' )
tmpLabel : setPhantom ( false )
if not ( SpellIcons [ info.icon ] ) then
perror ( ' Spell icon \' ' .. info.icon .. ' \' not found. ' )
else
tmpLabel : setImageClip ( getIconImageClip ( SpellIcons [ info.icon ] [ 1 ] ) )
end
tmpLabel.onClick = updateSpellInformation
end
connect ( spellList , { onChildFocusChange = function ( self , focusedChild )
if focusedChild == nil then return end
updateSpellInformation ( focusedChild )
end } )
setupOptions ( )
initialiseSpelllist ( )
setOptions ( )
resizeWindow ( )
end
function terminate ( )
disconnect ( g_game , { onGameStart = set up Options,
disconnect ( g_game , { onGameStart = setOptions ,
onGameEnd = resetWindow } )
disconnect ( spellList , { onChildFocusChange = function ( self , focusedChild )
@ -192,6 +202,7 @@ function terminate()
levelValueLabel = nil
manaValueLabel = nil
premiumValueLabel = nil
descriptionValueLabel = nil
vocationBoxAny = nil
vocationBoxSorcerer = nil
@ -209,13 +220,64 @@ function terminate()
premiumBoxYes = nil
end
function initialiseSpelllist ( )
for i = 1 , # SpelllistSettings [ SpelllistProfile ] . spellOrder do
local spell = SpelllistSettings [ SpelllistProfile ] . spellOrder [ i ]
local info = SpellInfo [ SpelllistProfile ] [ spell ]
local tmpLabel = g_ui.createWidget ( ' SpellListLabel ' , spellList )
tmpLabel : setId ( spell )
tmpLabel : setText ( spell .. ' \n \' ' .. info.words .. ' \' ' )
tmpLabel : setPhantom ( false )
local iconId = tonumber ( info.icon )
if not iconId and SpellIcons [ info.icon ] then
iconId = SpellIcons [ info.icon ] [ 1 ]
end
if not ( iconId ) then
perror ( ' Spell icon \' ' .. info.icon .. ' \' not found. ' )
end
tmpLabel : setHeight ( SpelllistSettings [ SpelllistProfile ] . iconSize.height + 4 )
tmpLabel : setTextOffset ( topoint ( ( SpelllistSettings [ SpelllistProfile ] . iconSize.width + 10 ) .. ' ' .. ( SpelllistSettings [ SpelllistProfile ] . iconSize.height - 32 ) / 2 + 3 ) )
tmpLabel : setImageSource ( ' /game_spelllist/icons/ ' .. SpelllistSettings [ SpelllistProfile ] . iconFile )
tmpLabel : setImageClip ( getIconImageClip ( iconId ) )
tmpLabel : setImageSize ( tosize ( SpelllistSettings [ SpelllistProfile ] . iconSize.width .. ' ' .. SpelllistSettings [ SpelllistProfile ] . iconSize.height ) )
tmpLabel.onClick = updateSpellInformation
end
connect ( spellList , { onChildFocusChange = function ( self , focusedChild )
if focusedChild == nil then return end
updateSpellInformation ( focusedChild )
end } )
end
function changeSpelllistProfile ( oldProfile )
-- Delete old labels
for i = 1 , # SpelllistSettings [ oldProfile ] . spellOrder do
local spell = SpelllistSettings [ oldProfile ] . spellOrder [ i ]
local tmpLabel = spellList : getChildById ( spell )
tmpLabel : destroy ( )
end
-- Create new spelllist and ajust window
initialiseSpelllist ( )
setOptions ( )
resizeWindow ( )
resetWindow ( )
end
function updateSpelllist ( )
for i = 1 , # spellDisplayOrder do
local spell = spellDisplayOrder [ i ]
local info = SpellInfo [ spell ]
for i = 1 , # Spellli stSettings[ S pel llistProfile] . s pel lOrder do
local spell = Spellli stSettings[ S pel llistProfile] . s pel lOrder[ i ]
local info = SpellInfo [ SpelllistProfile] [ spell]
local tmpLabel = spellList : getChildById ( spell )
local localPlayer = g_game.getLocalPlayer ( )
if not info.level then print ( spell ) end
if ( not ( filters.level ) or info.level <= localPlayer : getLevel ( ) ) and ( not ( filters.vocation ) or table.find ( info.vocations , localPlayer : getVocation ( ) ) ) and ( filters.vocationId == FILTER_VOCATION_ANY or table.find ( info.vocations , filters.vocationId ) or table.find ( info.vocations , filters.vocationId + 4 ) ) and ( filters.groupId == FILTER_GROUP_ANY or info.group [ filters.groupId ] ) and ( filters.premium == FILTER_PREMIUM_ANY or ( info.premium and filters.premium == FILTER_PREMIUM_YES ) or ( not ( info.premium ) and filters.premium == FILTER_PREMIUM_NO ) ) then
tmpLabel : setVisible ( true )
else
@ -236,9 +298,10 @@ function updateSpellInformation(widget)
local level = ' '
local mana = ' '
local premium = ' '
local description = ' '
if SpellInfo [ spell] then
local info = SpellInfo [ spell]
if SpellInfo [ SpelllistProfile] [ spell] then
local info = SpellInfo [ SpelllistProfile] [ spell]
name = spell
formula = info.words
@ -262,6 +325,7 @@ function updateSpellInformation(widget)
level = info.level
mana = info.mana .. ' / ' .. info.soul
premium = ( info.premium and ' yes ' or ' no ' )
description = info.description or ' - '
end
nameValueLabel : setText ( name )
@ -273,6 +337,7 @@ function updateSpellInformation(widget)
levelValueLabel : setText ( level )
manaValueLabel : setText ( mana )
premiumValueLabel : setText ( premium )
descriptionValueLabel : setText ( description )
end
function toggle ( )
@ -333,6 +398,11 @@ function toggleFilter(widget, selectedWidget)
updateSpelllist ( )
end
function resizeWindow ( )
spelllistWindow : setWidth ( SpelllistSettings [ ' Default ' ] . spellWindowWidth + SpelllistSettings [ SpelllistProfile ] . iconSize.width - 32 )
spellList : setWidth ( SpelllistSettings [ ' Default ' ] . spellListWidth + SpelllistSettings [ SpelllistProfile ] . iconSize.width - 32 )
end
function resetWindow ( )
spelllistWindow : hide ( )
spelllistButton : setOn ( false )