2011-11-03 13:17:10 +01:00
|
|
|
Skills = {}
|
2011-09-13 23:54:23 +02:00
|
|
|
|
2011-11-03 13:17:10 +01:00
|
|
|
-- private variables
|
|
|
|
local skillWindow = nil
|
2011-11-03 10:59:11 +01:00
|
|
|
local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"}
|
2011-09-13 23:54:23 +02:00
|
|
|
|
2011-11-03 13:17:10 +01:00
|
|
|
-- public functions
|
|
|
|
function Skills.create()
|
|
|
|
skillWindow = loadUI("/skills/skills.otui", Game.gameRightPanel)
|
2011-11-03 10:59:11 +01:00
|
|
|
|
2011-09-13 23:54:23 +02:00
|
|
|
local skillPanel = skillWindow:getChildById('skillPanel')
|
2011-11-03 10:59:11 +01:00
|
|
|
|
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-11-03 10:59:11 +01:00
|
|
|
|
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-03 10:59:11 +01:00
|
|
|
|
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
|
|
|
|
|
2011-11-03 13:17:10 +01:00
|
|
|
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")
|
2011-11-03 21:54:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
connect(Game, { onLogin = Skills.create,
|
2011-11-03 23:14:56 +01:00
|
|
|
onLogout = Skills.destroy })
|