mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
BEAWARE all game functionality is disabled with this commit for a while
* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
This commit is contained in:
@@ -1,137 +0,0 @@
|
||||
Skills = {}
|
||||
|
||||
-- private variables
|
||||
local skillsWindow
|
||||
local skillsButton
|
||||
|
||||
-- private functions
|
||||
local function getNumberString(number)
|
||||
local out = ''
|
||||
number = tostring(number):reverse()
|
||||
for i=1,#number do
|
||||
out = out .. number:sub(i, i)
|
||||
if i % 3 == 0 and i ~= #number then
|
||||
out = out .. ','
|
||||
end
|
||||
end
|
||||
out = out:reverse()
|
||||
return out
|
||||
end
|
||||
|
||||
local function setSkillValue(id, value)
|
||||
local skill = skillsWindow:recursiveGetChildById(id)
|
||||
|
||||
if skill then
|
||||
local widget = skill:getChildById('value')
|
||||
widget:setText(value)
|
||||
end
|
||||
end
|
||||
|
||||
local function setSkillPercent(id, percent, tooltip)
|
||||
local skill = skillsWindow:recursiveGetChildById(id)
|
||||
|
||||
if skill then
|
||||
local widget = skill:getChildById('percent')
|
||||
widget:setPercent(percent)
|
||||
|
||||
if tooltip then
|
||||
widget:setTooltip(tooltip)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Skills.create()
|
||||
skillsWindow = displayUI('skills.otui', { parent = g_game.gameRightPanel })
|
||||
skillsWindow:hide()
|
||||
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
|
||||
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
|
||||
end
|
||||
|
||||
function Skills.destroy()
|
||||
Keyboard.unbindKeyDown('Ctrl+S')
|
||||
skillsButton:destroy()
|
||||
skillsButton = nil
|
||||
skillsWindow:destroy()
|
||||
skillsWindow = nil
|
||||
end
|
||||
|
||||
function Skills.toggle()
|
||||
local visible = not skillsWindow:isExplicitlyVisible()
|
||||
skillsWindow:setVisible(visible)
|
||||
skillsButton:setOn(visible)
|
||||
end
|
||||
|
||||
function Skills.onSkillButtonClick(button)
|
||||
local percentBar = button:getChildById('percent')
|
||||
if percentBar then
|
||||
percentBar:setVisible(not percentBar:isVisible())
|
||||
if percentBar:isVisible() then
|
||||
button:setHeight(21)
|
||||
else
|
||||
button:setHeight(21 - 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Skills.onExperienceChange(localPlayer, value)
|
||||
setSkillValue('experience', getNumberString(value))
|
||||
end
|
||||
|
||||
function Skills.onLevelChange(localPlayer, value, percent)
|
||||
setSkillValue('level', getNumberString(value))
|
||||
setSkillPercent('level', percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
function Skills.onHealthChange(localPlayer, health, maxHealth)
|
||||
setSkillValue('health', getNumberString(health))
|
||||
end
|
||||
|
||||
function Skills.onManaChange(localPlayer, mana, maxMana)
|
||||
setSkillValue('mana', getNumberString(mana))
|
||||
end
|
||||
|
||||
function Skills.onSoulChange(localPlayer, soul)
|
||||
setSkillValue('soul', soul)
|
||||
end
|
||||
|
||||
function Skills.onFreeCapacityChange(localPlayer, freeCapacity)
|
||||
setSkillValue('capacity', freeCapacity)
|
||||
end
|
||||
|
||||
function Skills.onStaminaChange(localPlayer, stamina)
|
||||
local hours = math.floor(stamina / 60)
|
||||
local minutes = stamina % 60
|
||||
if minutes < 10 then
|
||||
minutes = '0' .. minutes
|
||||
end
|
||||
local percent = 100 * stamina / (42 * 60) -- max is 42 hours
|
||||
|
||||
setSkillValue('stamina', hours .. ":" .. minutes)
|
||||
setSkillPercent('stamina', percent, 'You have ' .. percent .. ' percent')
|
||||
end
|
||||
|
||||
function Skills.onMagicLevelChange(localPlayer, value, percent)
|
||||
setSkillValue('magiclevel', value)
|
||||
setSkillPercent('magiclevel', percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
function Skills.onSkillChange(localPlayer, id, level, percent)
|
||||
setSkillValue('skillId' .. id, level)
|
||||
setSkillPercent('skillId' .. id, percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = Skills.create,
|
||||
onGameEnd = Skills.destroy })
|
||||
|
||||
connect(LocalPlayer, {
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
onManaChange = Skills.onManaChange,
|
||||
onSoulChange = Skills.onSoulChange,
|
||||
onFreeCapacityChange = Skills.onFreeCapacityChange,
|
||||
onStaminaChange = Skills.onStaminaChange,
|
||||
onMagicLevelChange = Skills.onMagicLevelChange,
|
||||
onSkillChange = Skills.onSkillChange })
|
@@ -1,7 +0,0 @@
|
||||
Module
|
||||
name: game_skills
|
||||
description: Manage skills window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad: |
|
||||
dofile 'skills'
|
@@ -1,150 +0,0 @@
|
||||
SkillFirstWidget < UIWidget
|
||||
|
||||
SkillButton < UIButton
|
||||
height: 21
|
||||
margin-bottom: 2
|
||||
&onClick: Skills.onSkillButtonClick
|
||||
|
||||
SkillNameLabel < GameLabel
|
||||
font: verdana-11px-monochrome
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
SkillValueLabel < GameLabel
|
||||
id: value
|
||||
font: verdana-11px-monochrome
|
||||
text-align: topright
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: prev.left
|
||||
|
||||
SkillPercentPanel < ProgressBar
|
||||
id: percent
|
||||
background-color: green
|
||||
height: 5
|
||||
margin-top: 15
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
tooltip: 0
|
||||
|
||||
MiniWindow
|
||||
id: skillWindow
|
||||
text: Skills
|
||||
height: 350
|
||||
|
||||
Panel
|
||||
id: skillPanel
|
||||
anchors.fill: parent
|
||||
layout: verticalBox
|
||||
|
||||
SkillButton
|
||||
id: experience
|
||||
height: 15
|
||||
SkillNameLabel
|
||||
text: Experience
|
||||
SkillValueLabel
|
||||
|
||||
SkillButton
|
||||
id: level
|
||||
SkillNameLabel
|
||||
text: Level
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
background-color: red
|
||||
|
||||
SkillButton
|
||||
id: health
|
||||
height: 15
|
||||
SkillNameLabel
|
||||
text: Hit Points
|
||||
SkillValueLabel
|
||||
|
||||
SkillButton
|
||||
id: mana
|
||||
height: 15
|
||||
SkillNameLabel
|
||||
text: Mana
|
||||
SkillValueLabel
|
||||
|
||||
SkillButton
|
||||
id: soul
|
||||
height: 15
|
||||
SkillNameLabel
|
||||
text: Soul Points
|
||||
SkillValueLabel
|
||||
|
||||
SkillButton
|
||||
id: capacity
|
||||
height: 15
|
||||
SkillNameLabel
|
||||
text: Capacity
|
||||
SkillValueLabel
|
||||
|
||||
SkillButton
|
||||
id: stamina
|
||||
SkillNameLabel
|
||||
text: Stamina
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: magiclevel
|
||||
SkillNameLabel
|
||||
text: Magic Level
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
background-color: red
|
||||
|
||||
SkillButton
|
||||
id: skillId0
|
||||
SkillNameLabel
|
||||
text: Fist Fighting
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId1
|
||||
SkillNameLabel
|
||||
text: Club Fighting
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId2
|
||||
|
||||
SkillNameLabel
|
||||
text: Sword Fighting
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId3
|
||||
SkillNameLabel
|
||||
text: Axe Fighting
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId4
|
||||
SkillNameLabel
|
||||
text: Distance Fighting
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId5
|
||||
SkillNameLabel
|
||||
text: Shielding
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
SkillButton
|
||||
id: skillId6
|
||||
SkillNameLabel
|
||||
text: Fishing
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
Reference in New Issue
Block a user