tibia-client/modules/skills/skills.lua

57 lines
1.6 KiB
Lua
Raw Normal View History

Skills = {}
2011-09-13 23:54:23 +02:00
-- private variables
local skillWindow = nil
local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"}
2011-09-13 23:54:23 +02:00
-- public functions
function Skills.create()
skillWindow = loadUI("/skills/skills.otui", Game.gameRightPanel)
2011-09-13 23:54:23 +02:00
local skillPanel = skillWindow:getChildById('skillPanel')
2011-09-13 23:54:23 +02:00
-- create first widget cause of layout
local widget = UIWidget.create()
skillPanel:addChild(widget)
widget:setStyle('SkillFirstWidget')
2011-09-13 23:54:23 +02:00
-- create skills
for i=1,#skills,1 do
local nameLabel = UILabel.create()
skillPanel:addChild(nameLabel)
nameLabel:setStyle('SkillNameLabel')
nameLabel:setText(skills[i])
local levelLabel = UILabel.create()
skillPanel:addChild(levelLabel)
levelLabel:setStyle('SkillLevelLabel')
levelLabel:setId('skillLevelId' .. i)
2011-11-03 23:14:56 +01:00
levelLabel:setText('0')
2011-11-14 03:40:18 +01:00
local percentBar = UIProgressBar.create()
skillPanel:addChild(percentBar)
percentBar:setStyle('SkillPercentPanel')
percentBar:setId('skillPercentId' .. i)
2011-09-13 23:54:23 +02:00
end
end
function Skills.destroy()
skillWindow:destroy()
skillWindow = nil
end
-- hooked events
2011-11-04 00:34:32 +01:00
function Game.onSkillUpdate(id, level, percent)
2011-09-13 23:54:23 +02:00
local skillPanel = skillWindow:getChildById('skillPanel')
2011-11-03 23:14:56 +01:00
local levelLabel = skillPanel:getChildById('skillLevelId' .. (id + 1))
levelLabel:setText(level)
2011-11-14 03:40:18 +01:00
local percentBar = skillPanel:getChildById('skillPercentId' .. (id + 1))
percentBar:setPercent(percent)
percentBar:setTooltip(percent .. "% to go")
end
connect(Game, { onLogin = Skills.create,
2011-11-03 23:14:56 +01:00
onLogout = Skills.destroy })