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-09-13 23:54:23 +02:00
|
|
|
local percentPanel = UIWidget.create()
|
|
|
|
skillPanel:addChild(percentPanel)
|
|
|
|
percentPanel:setStyle('SkillPercentPanel')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-03 13:17:10 +01:00
|
|
|
function Skills.destroy()
|
|
|
|
skillWindow:destroy()
|
|
|
|
skillWindow = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
-- hooked events
|
2011-09-13 23:54:23 +02:00
|
|
|
function Game.setSkill(id, level, percent)
|
|
|
|
local skillPanel = skillWindow:getChildById('skillPanel')
|
2011-11-03 23:14:56 +01:00
|
|
|
|
|
|
|
local levelLabel = skillPanel:getChildById('skillLevelId' .. (id + 1))
|
|
|
|
levelLabel:setText(level)
|
|
|
|
|
|
|
|
--local percentLabel = skillPanel:getChildById('skillLevelId' .. id)
|
|
|
|
--levelLabel:setText(percent)
|
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 })
|