mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
reorganize modules
This commit is contained in:
67
modules/game_skills/skills.lua
Normal file
67
modules/game_skills/skills.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
Skills = {}
|
||||
|
||||
-- private variables
|
||||
local skillWindow = nil
|
||||
local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"}
|
||||
|
||||
-- public functions
|
||||
function Skills.create()
|
||||
skillWindow = UI.display('skills.otui', { parent = Game.gameRightPanel })
|
||||
|
||||
local skillPanel = skillWindow:getChildById('skillPanel')
|
||||
|
||||
-- create first widget cause of layout
|
||||
local widget = UIWidget.create()
|
||||
skillPanel:addChild(widget)
|
||||
widget:setStyle('SkillFirstWidget')
|
||||
|
||||
-- create skills
|
||||
for i=1,#skills,1 do
|
||||
local skillButton = UIButton.create()
|
||||
skillPanel:addChild(skillButton)
|
||||
skillButton:setStyle('SkillButton')
|
||||
|
||||
local nameLabel = UILabel.create()
|
||||
skillButton :addChild(nameLabel)
|
||||
nameLabel:setStyle('SkillNameLabel')
|
||||
nameLabel:setText(skills[i])
|
||||
nameLabel:resizeToText()
|
||||
|
||||
local levelLabel = UILabel.create()
|
||||
skillButton:addChild(levelLabel)
|
||||
levelLabel:setStyle('SkillLevelLabel')
|
||||
levelLabel:setId('skillLevelId' .. i)
|
||||
levelLabel:setText('0')
|
||||
|
||||
local percentBar = UIProgressBar.create()
|
||||
skillPanel:addChild(percentBar)
|
||||
percentBar:setStyle('SkillPercentPanel')
|
||||
percentBar:setId('skillPercentId' .. i)
|
||||
|
||||
skillButton.onClick = function(self)
|
||||
percentBar:setVisible(not percentBar:isVisible())
|
||||
self:updateParentLayout()
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Skills.destroy()
|
||||
skillWindow:destroy()
|
||||
skillWindow = nil
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onSkillUpdate(id, level, percent)
|
||||
local skillPanel = skillWindow:recursiveGetChildById('skillPanel')
|
||||
|
||||
local levelLabel = skillPanel:recursiveGetChildById('skillLevelId' .. (id + 1))
|
||||
levelLabel:setText(level)
|
||||
|
||||
local percentBar = skillPanel:getChildById('skillPercentId' .. (id + 1))
|
||||
percentBar:setPercent(percent)
|
||||
percentBar:setTooltip(percent .. "% to go")
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Skills.create,
|
||||
onLogout = Skills.destroy })
|
8
modules/game_skills/skills.otmod
Normal file
8
modules/game_skills/skills.otmod
Normal file
@@ -0,0 +1,8 @@
|
||||
Module
|
||||
name: game_skills
|
||||
description: Manage skills window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad: |
|
||||
require 'skills'
|
||||
return true
|
44
modules/game_skills/skills.otui
Normal file
44
modules/game_skills/skills.otui
Normal file
@@ -0,0 +1,44 @@
|
||||
SkillFirstWidget < UIWidget
|
||||
|
||||
SkillButton < UIButton
|
||||
height: 14
|
||||
margin-top: 4
|
||||
margin-left: 10
|
||||
margin-right: 10
|
||||
|
||||
SkillNameLabel < Label
|
||||
font: verdana-11px-monochrome
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
SkillLevelLabel < Label
|
||||
font: verdana-11px-monochrome
|
||||
text-align: right
|
||||
width: 32
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
SkillPercentPanel < UIProgressBar
|
||||
color: black
|
||||
background-color: green
|
||||
tooltip: test
|
||||
height: 5
|
||||
margin-top: 3
|
||||
margin-left: 10
|
||||
margin-right: 10
|
||||
|
||||
MiniWindow
|
||||
id: skillWindow
|
||||
title: Skills
|
||||
size: 200 220
|
||||
|
||||
Panel
|
||||
id: skillPanel
|
||||
anchors.fill: parent
|
||||
margin-top: 26
|
||||
margin-bottom: 3
|
||||
margin-left: 3
|
||||
margin-right: 3
|
||||
layout: verticalBox
|
Reference in New Issue
Block a user