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...
master
Eduardo Bart pirms 12 gadiem
vecāks 96358b317d
revīzija e03bf33f58

@ -1,7 +1,6 @@
Client = {}
function Client.init()
g_window.show()
g_window.setMinimumSize({ width = 600, height = 480 })
-- initialize in fullscreen mode on mobile devices
@ -27,6 +26,13 @@ function Client.init()
g_window.setTitle('OTClient')
g_window.setIcon(resolvepath('clienticon.png'))
-- show the only window after the first frame is rendered
addEvent(function()
addEvent(function()
g_window.show()
end)
end)
end
function Client.terminate()

@ -0,0 +1,23 @@
Module
name: client
description: Initialize the client and setups its main window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-priority: 100
load-later:
- client_topmenu
- client_background
- client_about
- client_options
- client_terminal
- client_modulemanager
- client_entergame
@onLoad: |
dofile 'client'
Client.init()
@onUnload: |
Client.terminate()

Pirms

Platums:  |  Augstums:  |  Izmērs: 518 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 518 B

@ -2,22 +2,33 @@ About = {}
-- private variables
local aboutButton
local aboutWindow
-- public functions
function About.init()
aboutButton = TopMenu.addRightButton('aboutButton', 'About', 'about.png', About.display)
end
function About.display()
displayUI('about.otui', { locked = true })
aboutButton = TopMenu.addRightButton('aboutButton', 'About', 'about.png', About.show)
aboutWindow = displayUI('about.otui')
aboutWindow:hide()
end
function About.terminate()
aboutButton:destroy()
aboutButton = nil
aboutWindow:destroy()
aboutWindow = nil
About = nil
end
function About.show()
aboutWindow:show()
aboutWindow:raise()
aboutWindow:focus()
end
function About.hide()
aboutWindow:hide()
end
function About.openWebpage()
displayErrorBox("Error", "Not implemented yet")
end

@ -3,16 +3,14 @@ Module
description: Create the about window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 160
unloadable: true
reloadable: true
dependencies:
- client_topmenu
onLoad: |
@onLoad: |
dofile 'about'
About.init()
onUnload: |
@onUnload: |
About.terminate()

@ -3,6 +3,9 @@ MainWindow
text: Info
size: 244 221
@onEnter: About.hide()
@onEscape: About.hide()
FlatPanel
size: 208 129
anchors.left: parent.left
@ -52,4 +55,4 @@ MainWindow
size: 46 24
anchors.right: parent.right
anchors.bottom: parent.bottom
@onClick: self:getParent():destroy()
@onClick: About.hide()

@ -7,11 +7,18 @@ local background
function Background.init()
background = displayUI('background.otui')
background:lower()
connect(g_game, { onGameStart = Background.hide })
connect(g_game, { onGameEnd = Background.show })
end
function Background.terminate()
disconnect(g_game, { onGameStart = Background.hide })
disconnect(g_game, { onGameEnd = Background.show })
background:destroy()
background = nil
Background = nil
end

@ -3,12 +3,14 @@ Module
description: Handles the background of the login screen
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 110
reloadable: true
onLoad: |
dependencies:
- client_topmenu
@onLoad: |
dofile 'background'
Background.init()
onUnload: |
@onUnload: |
Background.terminate()

@ -52,7 +52,27 @@ local function tryLogin(charInfo, tries)
Settings.set('lastUsedCharacter', charInfo.characterName)
end
function onGameLoginError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
errorBox.onOk = CharacterList.show
end
function onGameConnectionError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
errorBox.onOk = CharacterList.show
end
-- public functions
function CharacterList.init()
connect(g_game, { onLoginError = onGameLoginError })
connect(g_game, { onConnectionError = onGameConnectionError })
connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
connect(g_game, { onGameEnd = CharacterList.show })
end
function CharacterList.terminate()
characterList = nil
if charactersWindow then
@ -60,6 +80,7 @@ function CharacterList.terminate()
charactersWindow = nil
end
if loadBox then
g_game.cancelLogin()
loadBox:destroy()
loadBox = nil
end
@ -118,6 +139,7 @@ end
function CharacterList.show()
if not loadBox then
charactersWindow:show()
charactersWindow:raise()
charactersWindow:focus()
end
end

@ -59,11 +59,11 @@ end
-- public functions
function EnterGame.init()
enterGameButton = TopMenu.addButton('enterGameButton', 'Login (Ctrl + G)', '/core_styles/icons/login.png', EnterGame.openWindow)
Keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
motdButton = TopMenu.addButton('motdButton', 'Message of the day', '/core_styles/icons/motd.png', EnterGame.displayMotd)
motdButton:hide()
enterGame = displayUI('entergame.otui')
enterGameButton = TopMenu.addLeftButton('enterGameButton', 'Login (Ctrl + G)', 'login.png', EnterGame.openWindow)
motdButton = TopMenu.addLeftButton('motdButton', 'Message of the day', 'motd.png', EnterGame.displayMotd)
motdButton:hide()
Keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
local account = Settings.get('account')
local password = Settings.get('password')
@ -102,6 +102,7 @@ end
function EnterGame.show()
enterGame:show()
enterGame:raise()
enterGame:focus()
end

@ -3,14 +3,17 @@ Module
description: Manages enter game and character list windows
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 150
reloadable: true
onLoad: |
dependencies:
- client_topmenu
@onLoad: |
dofile 'entergame'
dofile 'characterlist'
EnterGame.init()
CharacterList.init()
onUnload: |
@onUnload: |
EnterGame.terminate()
CharacterList.terminate()

@ -5,7 +5,7 @@ MainWindow
@onEnter: EnterGame.doLogin()
@onEscape: EnterGame.hide()
LargerLabel
Label
text: Account name
anchors.left: parent.left
anchors.top: parent.top
@ -17,7 +17,7 @@ MainWindow
anchors.top: prev.bottom
margin-top: 2
LargerLabel
Label
text: Password
anchors.left: prev.left
anchors.top: prev.bottom
@ -30,7 +30,7 @@ MainWindow
anchors.top: prev.bottom
margin-top: 2
LargerLabel
Label
id: serverLabel
width: 140
text: Server
@ -46,7 +46,7 @@ MainWindow
anchors.top: serverLabel.bottom
margin-top: 2
LargerLabel
Label
id: portLabel
text: Port
width: 50

Pirms

Platums:  |  Augstums:  |  Izmērs: 696 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 696 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 331 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 331 B

@ -1,14 +0,0 @@
Module
name: client_main
description: Initialize the client and setups its main window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 100
onLoad: |
dofile 'client'
Client.init()
onUnload: |
Client.terminate()

@ -16,8 +16,9 @@ function ModuleManager.init()
Keyboard.bindKeyPress('Up', function() moduleList:focusPreviousChild(KeyboardFocusReason) end, moduleManagerWindow)
Keyboard.bindKeyPress('Down', function() moduleList:focusNextChild(KeyboardFocusReason) end, moduleManagerWindow)
moduleManagerButton = TopMenu.addButton('moduleManagerButton', 'Module manager', 'modulemanager.png', ModuleManager.toggle)
moduleManagerButton = TopMenu.addLeftButton('moduleManagerButton', 'Module manager', 'modulemanager.png', ModuleManager.toggle)
-- refresh modules only after all modules are loaded
addEvent(ModuleManager.listModules)
end
@ -36,8 +37,8 @@ end
function ModuleManager.show()
moduleManagerWindow:show()
moduleManagerWindow:focus()
moduleManagerWindow:raise()
moduleManagerWindow:focus()
end
function ModuleManager.toggle()
@ -98,8 +99,8 @@ function ModuleManager.updateModuleInfo(moduleName)
website = module:getWebsite()
version = module:getVersion()
loaded = module:isLoaded()
canReload = module:canReload()
canUnload = module:canUnload()
canReload = not loaded or canUnload
end
moduleManagerWindow:recursiveGetChildById('moduleName'):setText(name)
@ -111,12 +112,10 @@ function ModuleManager.updateModuleInfo(moduleName)
local reloadButton = moduleManagerWindow:recursiveGetChildById('moduleReloadButton')
reloadButton:setEnabled(canReload)
reloadButton:setVisible(true)
if loaded then reloadButton:setText('Reload')
else reloadButton:setText('Load') end
local unloadButton = moduleManagerWindow:recursiveGetChildById('moduleUnloadButton')
unloadButton:setVisible(true)
unloadButton:setEnabled(canUnload)
end
@ -126,6 +125,7 @@ function ModuleManager.reloadCurrentModule()
local module = g_modules.getModule(focusedChild:getText())
if module then
module:reload()
if ModuleManager == nil then return end
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
ModuleManager.show()
@ -139,6 +139,7 @@ function ModuleManager.unloadCurrentModule()
local module = g_modules.getModule(focusedChild:getText())
if module then
module:unload()
if ModuleManager == nil then return end
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
end

@ -3,15 +3,16 @@ Module
description: Manage other modules
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
autoload: true
autoload-antecedence: 140
autoload-priority: 140
dependencies:
- client_topmenu
onLoad: |
@onLoad: |
dofile 'modulemanager'
ModuleManager.init()
onUnload: |
@onUnload: |
ModuleManager.terminate()

@ -27,7 +27,7 @@ ModuleValueLabel < UILabel
font: verdana-11px-antialised
color: #aaaaaa
text-offset: 3 0
image-source: /core_styles/images/panel_flat.png
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
height: 16
@ -92,9 +92,9 @@ MainWindow
// id: moduleAutoload
//ModuleInfoLabel
// text: Autoload antecedence
// text: Autoload priority
//ModuleValueLabel
// id: moduleLoadAntecedence
// id: moduleLoadPriority
// text: 1000
ModuleInfoLabel
@ -118,7 +118,7 @@ MainWindow
anchors.left: moduleInfo.left
margin-top: 8
text: Load
visible: false
enabled: false
@onClick: ModuleManager.reloadCurrentModule()
Button
@ -128,6 +128,14 @@ MainWindow
margin-left: 10
margin-top: 8
text: Unload
visible: false
enabled: false
@onClick: ModuleManager.unloadCurrentModule()
Button
id: closeButton
anchors.bottom: parent.bottom
anchors.right: parent.right
text: Close
width: 60
@onClick: ModuleManager.hide()

@ -2,29 +2,29 @@ Options = {}
local optionsWindow
local optionsButton
local options = { vsync = true,
showfps = true,
fullscreen = false,
classicControl = false,
showStatusMessagesInConsole = true,
showEventMessagesInConsole = true,
showInfoMessagesInConsole = true,
showTimestampsInConsole = true,
showLevelsInConsole = true,
showPrivateMessagesInConsole = true }
function Options.init()
-- load settings
local booleanOptions = { vsync = true,
showfps = true,
fullscreen = false,
classicControl = false,
showStatusMessagesInConsole = true,
showEventMessagesInConsole = true,
showInfoMessagesInConsole = true,
showTimestampsInConsole = true,
showLevelsInConsole = true,
showPrivateMessagesInConsole = true,
}
for k,v in pairs(booleanOptions) do
Settings.setDefault(k, v)
Options.changeOption(k, Settings.getBoolean(k))
-- load options
for k,v in pairs(options) do
if type(v) == 'boolean' then
Settings.setDefault(k, v)
Options.setOption(k, Settings.getBoolean(k))
end
end
optionsWindow = displayUI('options.otui')
optionsWindow:setVisible(false)
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
optionsWindow:hide()
optionsButton = TopMenu.addLeftButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
Keyboard.bindKeyDown('Ctrl+O', Options.toggle)
end
@ -47,11 +47,11 @@ end
function Options.show()
optionsWindow:show()
optionsWindow:lock()
optionsWindow:raise()
optionsWindow:focus()
end
function Options.hide()
optionsWindow:unlock()
optionsWindow:hide()
end
@ -59,20 +59,24 @@ function Options.openWebpage()
displayErrorBox("Error", "Not implemented yet")
end
-- private functions
function Options.changeOption(key, status)
function Options.setOption(key, value)
if key == 'vsync' then
g_window.setVerticalSync(status)
g_window.setVerticalSync(value)
elseif key == 'showfps' then
addEvent(function()
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
if frameCounter then frameCounter:setVisible(status) end
if frameCounter then frameCounter:setVisible(value) end
end)
elseif key == 'fullscreen' then
addEvent(function()
g_window.setFullscreen(status)
g_window.setFullscreen(value)
end)
end
Settings.set(key, status)
Options[key] = status
Settings.set(key, value)
options[key] = value
end
function Options.getOption(key)
return options[key]
end

@ -3,15 +3,14 @@ Module
description: Create the options window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 130
reloadable: true
dependencies:
- client_topmenu
onLoad: |
@onLoad: |
dofile 'options'
Options.init()
onUnload: |
@onUnload: |
Options.terminate()

@ -1,6 +1,6 @@
OptionCheckBox < CheckBox
@onCheckChange: Options.changeOption(self:getId(), self:isChecked())
@onSetup: self:setChecked(Options[self:getId()])
@onCheckChange: Options.setOption(self:getId(), self:isChecked())
@onSetup: self:setChecked(Options.getOption(self:getId()))
$first:
anchors.left: parent.left
@ -67,4 +67,4 @@ MainWindow
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
@onClick: Options.hide()
@onClick: Options.hide()

@ -41,10 +41,6 @@ function debugContainersItems()
end
end
function quit()
exit()
end
function autoReloadModule(name)
local function reloadEvent()
reloadModule(name)

@ -110,26 +110,27 @@ function Terminal.init()
terminalWidget = displayUI('terminal.otui')
terminalWidget:setVisible(false)
terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
terminalButton = TopMenu.addLeftButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
Keyboard.bindKeyDown('Ctrl+T', Terminal.toggle)
commandHistory = Settings.getList('terminal-history')
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
Keyboard.bindKeyDown('Up', function() navigateCommand(1) end, commandLineEdit)
Keyboard.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
Keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandLineEdit)
Keyboard.bindKeyPress('Down', function() navigateCommand(-1) end, commandLineEdit)
Keyboard.bindKeyDown('Tab', completeCommand, commandLineEdit)
Keyboard.bindKeyDown('Enter', doCommand, commandLineEdit)
Keyboard.bindKeyDown('Escape', Terminal.hide, terminalWidget)
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
Logger.setOnLog(onLog)
Logger.fireOldMessages()
g_logger.setOnLog(onLog)
g_logger.fireOldMessages()
end
function Terminal.terminate()
Settings.setList('terminal-history', commandHistory)
Keyboard.unbindKeyDown('Ctrl+T')
Logger.setOnLog(nil)
g_logger.setOnLog(nil)
terminalButton:destroy()
terminalButton = nil
commandLineEdit = nil
@ -150,11 +151,11 @@ end
function Terminal.show()
terminalWidget:show()
terminalWidget:lock()
terminalWidget:raise()
terminalWidget:focus()
end
function Terminal.hide()
terminalWidget:unlock()
terminalWidget:hide()
end
@ -178,7 +179,7 @@ function Terminal.executeCommand(command)
if command == nil or #command == 0 then return end
logLocked = true
Logger.log(LogInfo, '>> ' .. command)
g_logger.log(LogInfo, '>> ' .. command)
logLocked = false
-- detect and convert commands with simple syntax
@ -210,7 +211,7 @@ function Terminal.executeCommand(command)
-- check for syntax errors
if not func then
Logger.log(LogError, 'incorrect lua syntax: ' .. err:sub(5))
g_logger.log(LogError, 'incorrect lua syntax: ' .. err:sub(5))
return
end
@ -223,6 +224,6 @@ function Terminal.executeCommand(command)
-- if the command returned a value, print it
if ret then print(ret) end
else
Logger.log(LogError, 'command failed: ' .. ret)
g_logger.log(LogError, 'command failed: ' .. ret)
end
end

@ -3,13 +3,12 @@ Module
description: Terminal for executing lua functions
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 160
reloadable: true
onLoad: |
@onLoad: |
dofile 'terminal'
dofile 'commands'
Terminal.init()
onUnload: |
@onUnload: |
Terminal.terminate()

@ -1,14 +0,0 @@
Module
name: client_tibiafiles
description: Contains tibia spr and dat
unloadable: false
autoload: true
autoload-antecedence: 170
onLoad: |
if not g_thingsType.load('/client_tibiafiles/Tibia.dat') then
fatal("Unable to load dat file, please place a valid Tibia dat in modules/client_tibiafiles/Tibia.dat")
end
if not g_sprites.load('/client_tibiafiles/Tibia.spr') then
fatal("Unable to load spr file, please place a valid Tibia spr in modules/client_tibiafiles/Tibia.spr")
end

Pirms

Platums:  |  Augstums:  |  Izmērs: 470 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 470 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 426 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 426 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 4.3 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 4.3 KiB

@ -7,12 +7,25 @@ local rightButtonsPanel
local gameButtonsPanel
-- private functions
local function onLogout()
if g_game.isOnline() then
g_game.safeLogout()
local function addButton(id, description, icon, callback, panel, toggle)
local class
if toggle then
class = 'TopToggleButton'
else
class = 'TopButton'
end
local button = createWidget(class, panel)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 3))
if toggle then
button.onCheckChange = callback
else
exit()
button.onClick = callback
end
return button
end
-- public functions
@ -22,15 +35,11 @@ function TopMenu.init()
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
connect(g_game, { onGameStart = TopMenu.showGameButtons,
onGameEnd = TopMenu.hideGameButtons })
onGameEnd = TopMenu.hideGameButtons })
end
function TopMenu.terminate()
Keyboard.unbindKeyDown('Ctrl+Q')
leftButtonsPanel = nil
rightButtonsPanel = nil
gameButtonsPanel = nil
@ -38,45 +47,33 @@ function TopMenu.terminate()
topMenu = nil
disconnect(g_game, { onGameStart = TopMenu.showGameButtons,
onGameEnd = TopMenu.hideGameButtons })
onGameEnd = TopMenu.hideGameButtons })
TopMenu = nil
end
function TopMenu.addButton(id, description, icon, callback, right)
local panel
local class
if right then
panel = rightButtonsPanel
class = 'TopRightButton'
else
panel = leftButtonsPanel
class = 'TopLeftButton'
end
function TopMenu.addLeftButton(id, description, icon, callback)
return addButton(id, description, icon, callback, leftButtonsPanel, false)
end
local button = createWidget(class, panel)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 2))
button.onClick = callback
return button
function TopMenu.addLeftToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, leftButtonsPanel, true)
end
function TopMenu.addGameButton(id, description, icon, callback)
local button = createWidget('GameTopButton', gameButtonsPanel)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 2))
button.onClick = callback
return button
function TopMenu.addRightButton(id, description, icon, callback)
return addButton(id, description, icon, callback, rightButtonsPanel, false)
end
function TopMenu.addLeftButton(id, description, icon, callback)
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, false)
function TopMenu.addRightToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, rightButtonsPanel, true)
end
function TopMenu.addRightButton(id, description, icon, callback)
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
function TopMenu.addGameButton(id, description, icon, callback)
return addButton(id, description, icon, callback, gameButtonsPanel, false)
end
function TopMenu.addGameToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, gameButtonsPanel, true)
end
function TopMenu.hideGameButtons()
@ -90,3 +87,5 @@ end
function TopMenu.getButton(id)
return topMenu:recursiveGetChildById(id)
end

@ -3,12 +3,11 @@ Module
description: Create the top menu
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 120
reloadable: true
onLoad: |
@onLoad: |
dofile 'topmenu'
TopMenu.init()
onUnload: |
@onUnload: |
TopMenu.terminate()

@ -1,6 +1,6 @@
TopButton < UIButton
size: 26 26
image-source: /core_styles/images/top_button.png
image-source: images/top_button.png
image-clip: 0 0 26 26
image-border: 3
image-color: #ffffffff
@ -17,66 +17,61 @@ TopButton < UIButton
image-color: #ffffff44
icon-color: #ffffff44
GameTopButton < UIButton
TopToggleButton < UICheckBox
size: 26 26
image-source: /core_styles/images/top_button2.png
image-source: images/top_game_button.png
image-clip: 26 0 26 26
image-color: #ffffff22
icon-color: #ffffffff
image-border: 3
icon-color: #ffffffff
$on:
$checked:
image-clip: 0 0 26 26
image-color: #ffffffff
icon-color: #ffffffff
TopLeftButton < TopButton
TopRightButton < TopButton
TopMenuButtonsPanel < Panel
layout:
type: horizontalBox
spacing: 4
fit-children: true
padding: 6 4
TopPanel < Panel
height: 36
image-source: images/top_panel.png
image-repeated: true
focusable: false
TopPanel
id: topMenu
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
focusable: false
Panel
TopMenuButtonsPanel
id: leftButtonsPanel
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
layout:
type: horizontalBox
spacing: 4
fit-children: true
padding: 6 4
Panel
TopMenuButtonsPanel
id: gameButtonsPanel
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: prev.right
anchors.right: next.left
layout:
type: horizontalBox
spacing: 4
padding: 6 4
visible: false
Panel
TopMenuButtonsPanel
id: rightButtonsPanel
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
layout:
type: horizontalBox
spacing: 4
fit-children: true
padding: 6 4
FrameCounter
id: frameCounter
anchors.top: parent.top
anchors.right: prev.left
margin-top: 8
margin-right: 5
margin-right: 5

@ -1,15 +0,0 @@
Module
name: core_fonts
description: Contains fonts used by core
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 30
onLoad: |
importFont 'verdana-11px-antialised'
importFont 'verdana-11px-monochrome'
importFont 'verdana-11px-rounded'
importFont 'terminus-14px-bold'
setDefaultFont 'verdana-11px-antialised'

@ -4,9 +4,9 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 10
autoload-priority: 10
onLoad: |
@onLoad: |
dofile 'ext/table'
dofile 'ext/string'
dofile 'ext/os'
@ -17,9 +17,26 @@ Module
dofile 'const'
dofile 'util'
dofile 'globals'
dofile 'dispatcher'
dofile 'effects'
dofile 'settings'
dofile 'keyboard'
dofile 'mouse'
dofile 'ui/effects'
dofile 'ui/radiogroup'
dofile 'ui/tooltip'
dofile 'widgets/uiwidget'
dofile 'widgets/uibutton'
dofile 'widgets/uilabel'
dofile 'widgets/uicheckbox'
dofile 'widgets/uicombobox'
dofile 'widgets/uispinbox'
dofile 'widgets/uiprogressbar'
dofile 'widgets/uitabbar'
dofile 'widgets/uipopupmenu'
dofile 'widgets/uiwindow'
--dofile 'widgets/uiminiwindow'
--dofile 'widgets/uiminiwindowcontainer'
dofile 'widgets/uimessagebox'

@ -1,20 +0,0 @@
function scheduleEvent(callback, delay)
local event = g_dispatcher.scheduleEvent(callback, delay)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function addEvent(callback, front)
local event = g_dispatcher.addEvent(callback, front)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function removeEvent(event)
if event then
event:cancel()
end
end

@ -1,57 +1,13 @@
rootWidget = g_ui.getRootWidget()
function importStyle(otui)
g_ui.importStyle(resolvepath(otui, 2))
end
function importFont(otfont)
g_fonts.importFont(resolvepath(otfont, 2))
end
importStyle = g_ui.importStyle
importFont = g_fonts.importFont
setDefaultFont = g_fonts.setDefaultFont
function setDefaultFont(font)
g_fonts.setDefaultFont(font)
end
loadUI = g_ui.loadUI
function displayUI(arg1, options)
local widget
local parent
if options then parent = options.parent end
function displayUI(otui, parent)
parent = parent or rootWidget
-- display otui files
if type(arg1) == 'string' then
local otuiFilePath = resolvepath(arg1, 2)
widget = g_ui.loadUI(otuiFilePath, parent)
-- display already loaded widgets
else
widget = arg1
if parent:hasChild(widget) then
widget:focus()
widget:show()
else
parent:addChild(widget)
widget:show()
end
end
-- apply display options
if widget and options then
for option,value in pairs(options) do
if option == 'locked' and value then
widget:lock()
elseif option == 'visible' then
widget:setVisible(value)
elseif option == 'x' then
widget:setX(value)
elseif option == 'y' then
widget:setY(value)
end
end
end
return widget
end
function loadUI(otui, parent)
local otuiFilePath = resolvepath(otui, 2)
return g_ui.loadUI(otuiFilePath, parent)
end
@ -65,7 +21,7 @@ function createWidget(style, parent)
local class = _G[className]
if not class then
error('could not find widget class ' .. class)
error('could not find widget class ' .. className)
return
end
@ -80,6 +36,28 @@ function createWidget(style, parent)
return widget
end
function scheduleEvent(callback, delay)
local event = g_dispatcher.scheduleEvent(callback, delay)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function addEvent(callback, front)
local event = g_dispatcher.addEvent(callback, front)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function removeEvent(event)
if event then
event:cancel()
event._callback = nil
end
end
function reloadModule(name)
local module = g_modules.getModule(name)
if module then

@ -7,3 +7,4 @@ end
function Mouse.restoreCursor()
g_window.restoreMouseCursor()
end

@ -32,7 +32,6 @@ function Settings.set(key, value)
g_configs.set(key, convertSettingValue(value))
end
function Settings.setDefault(key, value)
if Settings.exists(key) then return false end
Settings.set(key, value)

@ -41,13 +41,15 @@ end
-- public functions
function ToolTip.init()
toolTipLabel = createWidget('Label', rootWidget)
toolTipLabel:setId('toolTip')
toolTipLabel:setBackgroundColor('#111111bb')
toolTipLabel.onMouseMove = moveToolTip
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
onHoverChange = onWidgetHoverChange})
addEvent(function()
toolTipLabel = createWidget('Label', rootWidget)
toolTipLabel:setId('toolTip')
toolTipLabel:setBackgroundColor('#111111bb')
toolTipLabel.onMouseMove = moveToolTip
end)
end
function ToolTip.terminate()
@ -63,6 +65,8 @@ end
function ToolTip.display(text)
if text == nil then return end
if not toolTipLabel then return end
toolTipLabel:setText(text)
toolTipLabel:resizeToText()
toolTipLabel:resize(toolTipLabel:getWidth() + 4, toolTipLabel:getHeight() + 4)
@ -73,6 +77,7 @@ function ToolTip.display(text)
end
function ToolTip.hide()
toolTipLabel:hide()
end
@ -85,3 +90,5 @@ function UIWidget:getTooltip()
return self.tooltip
end
ToolTip.init()
connect(g_app, { onTerminate = ToolTip.terminate })

@ -3,20 +3,15 @@ function print(...)
for i,v in ipairs(arg) do
msg = msg .. tostring(v) .. "\t"
end
Logger.log(LogInfo, msg)
g_logger.log(LogInfo, msg)
end
function fatal(msg)
Logger.log(LogFatal, msg)
g_logger.log(LogFatal, msg)
end
function setonclose(func)
g_app.onClose = func
end
function exit()
g_app.exit()
end
exit = g_app.exit
quit = g_app.exit
function connect(object, signalsAndSlots, pushFront)
for signal,slot in pairs(signalsAndSlots) do

@ -21,7 +21,8 @@ function UIPopupMenu:display(pos)
currentMenu:destroy()
end
displayUI(self, {x = pos.x, y = pos.y})
rootWidget:addChild(self)
self:setPosition(pos)
self:grabMouse()
self:grabKeyboard()
currentMenu = self

@ -7,7 +7,7 @@ function UIWindow.create()
return window
end
function UIWindow:onKeyPress(keyCode, keyboardModifiers)
function UIWindow:onKeyDown(keyCode, keyboardModifiers)
if keyboardModifiers == KeyboardNoModifier then
if keyCode == KeyEnter then
signalcall(self.onEnter, self)
@ -17,9 +17,8 @@ function UIWindow:onKeyPress(keyCode, keyboardModifiers)
end
end
function UIWindow:onMousePress(mousePos, mouseButton)
self:raise()
return true
function UIWindow:onFocusChange(focused)
if focused then self:raise() end
end
function UIWindow:onDragEnter(mousePos)

@ -3,11 +3,16 @@ Module
description: Contains ui styles used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
autoload: true
autoload-antecedence: 20
autoload-priority: 20
@onLoad: |
importFont 'fonts/verdana-11px-antialised'
importFont 'fonts/verdana-11px-monochrome'
importFont 'fonts/verdana-11px-rounded'
importFont 'fonts/terminus-14px-bold'
setDefaultFont 'verdana-11px-antialised'
onLoad: |
importStyle 'styles/buttons.otui'
importStyle 'styles/labels.otui'
importStyle 'styles/panels.otui'

Pirms

Platums:  |  Augstums:  |  Izmērs: 266 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 266 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 3.7 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 3.7 KiB

Pirms

Platums:  |  Augstums:  |  Izmērs: 9.8 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 9.8 KiB

Pirms

Platums:  |  Augstums:  |  Izmērs: 3.6 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 3.6 KiB

Pirms

Platums:  |  Augstums:  |  Izmērs: 5.8 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 5.8 KiB

@ -4,15 +4,15 @@ Button < UIButton
size: 106 24
text-offset: 0 0
image-color: white
image-source: /core_styles/images/button.png
image-source: /core_styles/styles/images/button.png
image-border: 5
$hover !disabled:
image-source: /core_styles/images/button_hover.png
image-source: /core_styles/styles/images/button_hover.png
$pressed:
text-offset: 1 1
image-source: /core_styles/images/button_down.png
image-source: /core_styles/styles/images/button_down.png
$disabled:
color: #f0ad4d88
@ -20,7 +20,7 @@ Button < UIButton
ConsoleButton < UIButton
size: 20 20
image-source: /core_styles/images/tabbutton.png
image-source: /core_styles/styles/images/tabbutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2

@ -6,7 +6,7 @@ CheckBox < UICheckBox
image-color: #ffffffff
image-rect: 0 0 12 12
image-offset: 0 2
image-source: /core_styles/images/checkbox.png
image-source: /core_styles/styles/images/checkbox.png
$hover !disabled:
color: #cccccc
@ -30,7 +30,7 @@ CheckBox < UICheckBox
ColorBox < UICheckBox
size: 16 16
image-color: #ffffffff
image-source: /core_styles/images/colorbox.png
image-source: /core_styles/styles/images/colorbox.png
$checked:
image-clip: 16 0 16 16
@ -44,16 +44,16 @@ ButtonBox < UICheckBox
size: 106 24
text-offset: 0 0
text-align: center
image-source: /core_styles/images/button.png
image-source: /core_styles/styles/images/button.png
image-color: white
image-border: 5
$hover !disabled:
image-source: /core_styles/images/button_hover.png
image-source: /core_styles/styles/images/button_hover.png
$checked:
text-offset: 1 1
image-source: /core_styles/images/button_down.png
image-source: /core_styles/styles/images/button_down.png
$disabled:
color: #f0ad4d88

@ -14,14 +14,14 @@ ComboBoxPopupMenuButton < UIButton
color: #555555
ComboBoxPopupMenuSeparator < UIWidget
image-source: /core_styles/images/combobox.png
image-source: /core_styles/styles/images/combobox.png
image-repeated: true
image-clip: 1 59 89 1
height: 1
phantom: true
ComboBoxPopupMenu < UIPopupMenu
image-source: /core_styles/images/combobox.png
image-source: /core_styles/styles/images/combobox.png
image-clip: 0 60 89 20
image-border: 1
image-border-top: 0
@ -33,7 +33,7 @@ ComboBox < UIComboBox
size: 86 20
text-offset: 3 0
text-align: left
image-source: /core_styles/images/combobox.png
image-source: /core_styles/styles/images/combobox.png
image-border: 1
image-border-right: 17
image-clip: 0 0 89 20

@ -1,8 +1,5 @@
Creature < UICreature
size: 80 80
padding: 1
image-source: /core_styles/images/panel_flat.png
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
UIWidget
id: lala

Pirms

Platums:  |  Augstums:  |  Izmērs: 825 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 825 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 833 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 833 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 859 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 859 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 548 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 548 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 262 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 262 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 457 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 457 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 34 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 34 KiB

Pirms

Platums:  |  Augstums:  |  Izmērs: 1.1 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 1.1 KiB

Pirms

Platums:  |  Augstums:  |  Izmērs: 262 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 262 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 241 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 241 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 179 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 179 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 400 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 400 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 415 B

Pēc

Platums:  |  Augstums:  |  Izmērs: 415 B

Pirms

Platums:  |  Augstums:  |  Izmērs: 35 KiB

Pēc

Platums:  |  Augstums:  |  Izmērs: 35 KiB

@ -1,5 +1,5 @@
Item < UIItem
size: 34 34
image-source: /core_styles/images/item.png
image-source: /core_styles/styles/images/item.png
font: verdana-11px-rounded
border-color: white

@ -5,8 +5,6 @@ Label < UILabel
$disabled:
color: #aaaaaa88
LargerLabel < Label
GameLabel < UILabel
font: verdana-11px-antialised
color: #aaaaaa

@ -3,7 +3,7 @@ LineEdit < UILineEdit
color: #aaaaaa
size: 86 20
text-margin: 3
image-source: /core_styles/images/panel_flat.png
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
$disabled:

@ -2,4 +2,4 @@ TextList < UIWidget
layout: verticalBox
border-width: 1
border-color: #1d222b
background-color: #222833
background-color: #222833

@ -2,23 +2,5 @@ Panel < UIWidget
phantom: true
FlatPanel < Panel
image-source: /core_styles/images/panel_flat.png
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
TopPanel < Panel
height: 36
image-source: /core_styles/images/top_panel.png
image-repeated: true
InterfacePanel < UIMiniWindowContainer
image-source: /core_styles/images/interface_panel.png
image-border: 4
InterfacePanel2 < Panel
image-source: /core_styles/images/interface_panel2.png
image-border: 4
Map < UIMap
padding: 4
image-source: /core_styles/images/map_panel.png
image-border: 4

@ -17,7 +17,7 @@ PopupMenuButton < UIButton
PopupMenuSeparator < UIWidget
margin-left: 2
margin-right: 2
image-source: /core_styles/images/menubox.png
image-source: /core_styles/styles/images/menubox.png
image-border-left: 1
image-border-right: 1
image-clip: 0 0 32 2
@ -26,7 +26,7 @@ PopupMenuSeparator < UIWidget
PopupMenu < UIPopupMenu
width: 50
image-source: /core_styles/images/menubox.png
image-source: /core_styles/styles/images/menubox.png
image-border: 3
padding-top: 3
padding-bottom: 3

@ -2,6 +2,6 @@ ProgressBar < UIProgressBar
height: 16
background-color: red
border: 1 black
image: /core_styles/images/progressbar.png
image: /core_styles/styles/images/progressbar.png
image-border: 1

@ -1,5 +1,5 @@
HorizontalSeparator < UIWidget
image-source: /core_styles/images/horizontal_separator.png
image-source: /core_styles/styles/images/horizontal_separator.png
image-border-top: 2
height: 2
phantom: true

@ -3,7 +3,7 @@ SpinBox < UISpinBox
color: #aaaaaa
size: 86 20
text-margin: 3
image-source: /core_styles/images/panel_flat.png
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
$disabled:

@ -2,7 +2,7 @@ TabBar < UITabBar
TabBarPanel < Panel
TabBarButton < UIButton
size: 20 20
image-source: /core_styles/images/tabbutton.png
image-source: /core_styles/styles/images/tabbutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2

@ -5,7 +5,7 @@ Window < UIWindow
color: white
text-offset: 0 2
text-align: top
image-source: /core_styles/images/window.png
image-source: /core_styles/styles/images/window.png
image-border: 4
image-border-top: 20
opacity: 1
@ -35,7 +35,7 @@ MiniWindow < UIMiniWindow
margin-left: 6
margin-right: 6
move-policy: free updated
image-source: /core_styles/images/mini_window.png
image-source: /core_styles/styles/images/mini_window.png
image-border: 4
image-border-top: 23
padding: 25 8 2 8

@ -1,33 +0,0 @@
Module
name: core_widgets
description: Contains widgets used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
unloadble: false
autoload: true
autoload-antecedence: 40
onLoad: |
dofile 'uiwidget'
dofile 'uibutton'
dofile 'uilabel'
dofile 'uicheckbox'
dofile 'uicombobox'
dofile 'uispinbox'
dofile 'uiprogressbar'
dofile 'uitabbar'
dofile 'uipopupmenu'
dofile 'uiwindow'
dofile 'uiminiwindow'
dofile 'uiminiwindowcontainer'
dofile 'uiitem'
dofile 'uimessagebox'
dofile 'tooltip'
dofile 'radiogroup'
ToolTip.init()
onUnload: |
ToolTip.terminate()

@ -46,19 +46,6 @@ function g_game.startUseWith(thing)
end
function g_game.createInterface()
Background.hide()
CharacterList.destroyLoadBox()
g_game.gameUi = displayUI('game.otui')
--Keyboard.bindKeyPress('Up', function() g_game.walk(North) end)
--Keyboard.bindKeyPress('Down', function() g_game.walk(South) end)
--Keyboard.bindKeyPress('Left', function() g_game.walk(West) end)
--Keyboard.bindKeyPress('Right', function() g_game.walk(East) end)
Keyboard.bindKeyPress('Ctrl+Shift+Up', function() g_game.forceWalk(North) end)
Keyboard.bindKeyPress('Ctrl+Shift+Down', function() g_game.forceWalk(South) end)
Keyboard.bindKeyPress('Ctrl+Shift+Left', function() g_game.forceWalk(West) end)
Keyboard.bindKeyPress('Ctrl+Shift+Right', function() g_game.forceWalk(East) end)
rootWidget:moveChildToIndex(g_game.gameUi, 1)
g_game.gameMapPanel = g_game.gameUi:getChildById('gameMapPanel')
@ -89,17 +76,6 @@ function g_game.hide()
end
-- hooked events
function g_game.onLoginError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
connect(errorBox, { onOk = CharacterList.show })
end
function g_game.onConnectionError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
connect(errorBox, { onOk = CharacterList.show })
end
local function onApplicationClose()
if g_game.isOnline() then

@ -3,19 +3,11 @@ Module
description: Create the game interface, where the ingame stuff starts
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- game_healthbar
- game_inventory
- game_skills
- game_textmessage
- game_viplist
- game_console
- game_outfit
- game_containers
- game_combatcontrols
- game_hotkeys
- game_battle
- game_tibiafiles
//- game_shaders
onLoad: |
dofile 'game'

@ -0,0 +1,11 @@
Module
name: game_tibiafiles
description: Contains tibia spr and dat
@onLoad: |
if not g_thingsType.load('/game_tibiafiles/Tibia.dat') then
fatal("Unable to load dat file, please place a valid Tibia dat in modules/game_tibiafiles/Tibia.dat")
end
if not g_sprites.load('/game_tibiafiles/Tibia.spr') then
fatal("Unable to load spr file, please place a valid Tibia spr in modules/game_tibiafiles/Tibia.spr")
end

@ -36,29 +36,29 @@ table.insert(lifeBarColors, {percentAbove = -1, color = '#4F0000' } )
-- public functions
function Battle.create()
battleWindow = displayUI('battle.otui', { parent = g_game.gameRightPanel })
battleWindow = displayUI('battle.otui', g_game.gameRightPanel)
battleWindow:hide()
battleButton = TopMenu.addGameButton('battleButton', 'Battle (Ctrl+B)', '/game_battle/battle.png', Battle.toggle)
Keyboard.bindKeyDown('Ctrl+B', Battle.toggle)
battlePannel = battleWindow:getChildById('battlePanel')
hidePlayersButton = battleWindow:getChildById('hidePlayers')
hideNPCsButton = battleWindow:getChildById('hideNPCs')
hideMonstersButton = battleWindow:getChildById('hideMonsters')
hideSkullsButton = battleWindow:getChildById('hideSkulls')
hidePartyButton = battleWindow:getChildById('hideParty')
mouseWidget = createWidget('UIButton')
mouseWidget:setVisible(false)
mouseWidget:setFocusable(false)
mouseWidget:setFocusable(false)
connect(Creature, { onSkullChange = Battle.checkCreatureSkull,
onEmblemChange = Battle.checkCreatureEmblem } )
onEmblemChange = Battle.checkCreatureEmblem } )
connect(g_game, { onAttackingCreatureChange = Battle.onAttack,
onFollowingCreatureChange = Battle.onFollow } )
addEvent(Battle.addAllCreatures)
checkCreaturesEvent = scheduleEvent(Battle.checkCreatures, 200)
end
@ -80,10 +80,10 @@ function Battle.destroy()
battleButton = nil
battleWindow:destroy()
battleWindow = nil
disconnect(Creature, { onSkullChange = Battle.checkCreatureSkull,
onEmblemChange = Battle.checkCreatureEmblem } )
onEmblemChange = Battle.checkCreatureEmblem } )
disconnect(g_game, { onAttackingCreatureChange = Battle.onAttack } )
end
@ -94,7 +94,7 @@ function Battle.toggle()
end
function Battle.addAllCreatures()
local spectators = {}
local spectators = {}
local player = g_game.getLocalPlayer()
if player then
creatures = g_map.getSpectators(player:getPosition(), false)
@ -104,7 +104,7 @@ function Battle.addAllCreatures()
end
end
end
for i, v in pairs(spectators) do
Battle.addCreature(v)
end
@ -116,7 +116,7 @@ function Battle.doCreatureFitFilters(creature)
local hideMonsters = hideMonstersButton:isChecked()
local hideSkulls = hideSkullsButton:isChecked()
local hideParty = hidePartyButton:isChecked()
if hidePlayers and not creature:asMonster() and not creature:asNpc() then
return false
elseif hideNPCs and creature:asNpc() then
@ -128,35 +128,35 @@ function Battle.doCreatureFitFilters(creature)
elseif hideParty and creature:getShield() > ShieldWhiteBlue then
return false
end
return true
end
function Battle.checkCreatures()
local player = g_game.getLocalPlayer()
if player then
if player then
local spectators = {}
-- reloading list of spectators
local creaturesAppeared = {}
local creaturesAppeared = {}
creatures = g_map.getSpectators(player:getPosition(), false)
for i, creature in ipairs(creatures) do
if creature ~= player and Battle.doCreatureFitFilters(creature) then
-- searching for creatures that appeared on battle list
local battleButton = battleButtonsByCreaturesList[creature:getId()]
if battleButton == nil then
table.insert(creaturesAppeared, creature)
table.insert(creaturesAppeared, creature)
else
Battle.setLifeBarPercent(battleButton, creature:getHealthPercent())
end
spectators[creature:getId()] = creature
end
end
for i, v in pairs(creaturesAppeared) do
Battle.addCreature(v)
end
-- searching for creatures that disappeared from battle list
local creaturesDisappeared = {}
for i, creature in pairs(battleButtonsByCreaturesList) do
@ -164,7 +164,7 @@ function Battle.checkCreatures()
table.insert(creaturesDisappeared, creature.creature)
end
end
for i, v in pairs(creaturesDisappeared) do
Battle.removeCreature(v)
end
@ -174,28 +174,28 @@ end
function Battle.addCreature(creature)
local creatureId = creature:getId()
if battleButtonsByCreaturesList[creatureId] == nil then
local battleButton = displayUI('battleButton.otui', { parent = battlePannel })
local battleButton = displayUI('battleButton.otui', battlePanne)
local creatureWidget = battleButton:getChildById('creature')
local labelWidget = battleButton:getChildById('label')
local lifeBarWidget = battleButton:getChildById('lifeBar')
battleButton:setId('BattleButton_' .. creature:getName():gsub('%s','_'))
battleButton.creatureId = creatureId
battleButton.creature = creature
battleButton.isHovered = false
battleButton.isTarget = false
battleButton.isFollowed = false
labelWidget:setText(creature:getName())
creatureWidget:setCreature(creature)
creatureWidget:setCreature(creature)
Battle.setLifeBarPercent(battleButton, creature:getHealthPercent())
battleButtonsByCreaturesList[creatureId] = battleButton
Battle.checkCreatureSkull(battleButton.creature)
Battle.checkCreatureEmblem(battleButton.creature)
Battle.checkCreatureEmblem(battleButton.creature)
end
end
@ -205,7 +205,7 @@ function Battle.checkCreatureSkull(creature, skullId)
local skullWidget = battleButton:getChildById('skull')
local labelWidget = battleButton:getChildById('label')
local creature = battleButton.creature
if creature:getSkull() ~= SkullNone then
skullWidget:setWidth(skullWidget:getHeight())
local imagePath = getSkullImagePath(creature:getSkull())
@ -265,12 +265,12 @@ end
function Battle.removeCreature(creature)
local creatureId = creature:getId()
if battleButtonsByCreaturesList[creatureId] ~= nil then
if lastBattleButtonSwitched == battleButtonsByCreaturesList[creatureId] then
lastBattleButtonSwitched = nil
end
battleButtonsByCreaturesList[creatureId].creature:hideStaticSquare()
battleButtonsByCreaturesList[creatureId]:destroy()
battleButtonsByCreaturesList[creatureId] = nil
@ -280,7 +280,7 @@ end
function Battle.setLifeBarPercent(battleButton, percent)
local lifeBarWidget = battleButton:getChildById('lifeBar')
lifeBarWidget:setPercent(percent)
local color
for i, v in pairs(lifeBarColors) do
if percent > v.percentAbove then
@ -288,31 +288,31 @@ function Battle.setLifeBarPercent(battleButton, percent)
break
end
end
lifeBarWidget:setBackgroundColor(color)
end
function Battle.onbattlePannelHoverChange(widget, hovered)
if widget.isBattleButton then
if widget.isBattleButton then
widget.isHovered = hovered
Battle.checkBattleButton(widget)
end
end
function Battle.onAttack(creature)
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
function Battle.onAttack(creature)
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
if battleButton then
battleButton.isTarget = creature and true or false
Battle.checkBattleButton(battleButton)
end
end
function Battle.onFollow(creature)
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
function Battle.onFollow(creature)
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
if battleButton then
battleButton.isFollowed = creature and true or false
Battle.checkBattleButton(battleButton)
end
end
end
function Battle.checkBattleButton(battleButton)
@ -322,20 +322,20 @@ function Battle.checkBattleButton(battleButton)
elseif battleButton.isFollowed then
color = battleButtonColors.onFollowed
end
color = battleButton.isHovered and color.hovered or color.notHovered
if battleButton.isHovered or battleButton.isTarget or battleButton.isFollowed then
battleButton.creature:showStaticSquare(color)
battleButton:getChildById('creature'):setBorderWidth(1)
battleButton:getChildById('creature'):setBorderColor(color)
battleButton:getChildById('label'):setColor(color)
else
battleButton:getChildById('label'):setColor(color)
else
battleButton.creature:hideStaticSquare()
battleButton:getChildById('creature'):setBorderWidth(0)
battleButton:getChildById('label'):setColor(color)
battleButton:getChildById('label'):setColor(color)
end
if battleButton.isTarget or battleButton.isFollowed then
if lastBattleButtonSwitched and lastBattleButtonSwitched ~= battleButton then
lastBattleButtonSwitched.isTarget = false

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels Rādīt vairāk

Notiek ielāde…
Atcelt
Saglabāt