a lot of changes in modules

This commit is contained in:
Eduardo Bart
2012-02-06 17:19:47 -02:00
parent add8505a5b
commit 88301c329a
50 changed files with 488 additions and 322 deletions

View File

@@ -1,24 +0,0 @@
Module
name: client
description: Load all other otclient dependecies
author: OTClient team
website: https://github.com/edubart/otclient
canUnload: false
// NOTE: order does matter
dependencies:
- client_background
- client_topmenu
- client_tibiafiles
- client_about
- client_options
- client_entergame
- client_modulemanager
- game
onLoad: |
dofile 'client'
Client.init()
onUnload: |
Client.terminate()

View File

@@ -3,6 +3,12 @@ Module
description: Create the about window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 160
unloadable: true
dependencies:
- client_topmenu
onLoad: |
dofile 'about'

View File

@@ -3,6 +3,8 @@ Module
description: Handles the background of the login screen
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 110
onLoad: |
dofile 'background'

View File

@@ -42,11 +42,11 @@ local function tryLogin(charInfo, tries)
Game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
loadBox = displayCancelBox('Please wait', 'Connecting to game server...')
function loadBox.onCancel()
loadBox = nil
Game.cancelLogin()
CharacterList.show()
end
connect(loadBox, { onCancel = function()
loadBox = nil
Game.cancelLogin()
CharacterList.show()
end })
-- save last used character
Settings.set('lastUsedCharacter', charInfo.characterName)

View File

@@ -8,7 +8,6 @@ local motdMessage
local motdButton
local enterGameButton
-- private functions
local function clearAccountFields()
enterGame:getChildById('accountNameLineEdit'):clearText()
@@ -20,11 +19,13 @@ end
local function onError(protocol, message, connectionError)
loadBox:destroy()
loadBox = nil
if not connectionError then
clearAccountFields()
end
local errorBox = displayErrorBox('Login Error', message)
errorBox.onOk = EnterGame.show
connect(errorBox, { onOk = EnterGame.show })
end
local function onMotd(protocol, motd)
@@ -43,13 +44,15 @@ local function onCharacterList(protocol, characters, premDays)
end
loadBox:destroy()
loadBox = nil
CharacterList.create(characters, premDays)
local lastMotdNumber = Settings.getNumber("motd")
if motdNumber and motdNumber ~= lastMotdNumber then
Settings.set("motd", motdNumber)
local motdBox = displayInfoBox("Message of the day", motdMessage)
motdBox.onOk = CharacterList.show
connect(motdBox, { onOk = CharacterList.show })
CharacterList.hide()
end
end
@@ -76,8 +79,13 @@ function EnterGame.init()
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
enterGame:getChildById('accountNameLineEdit'):focus()
if #account > 0 and autologin then
addEvent(EnterGame.doLogin)
-- only open entergame when app starts
if not g_app.isRunning() then
if #account > 0 and autologin then
addEvent(EnterGame.doLogin)
end
else
enterGame:hide()
end
end
@@ -124,10 +132,11 @@ function EnterGame.doLogin()
protocolLogin.onCharacterList = onCharacterList
loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
loadBox.onCancel = function(msgbox)
protocolLogin:cancelLogin()
EnterGame.show()
end
connect(loadBox, { onCancel = function(msgbox)
loadBox = nil
protocolLogin:cancelLogin()
EnterGame.show()
end })
protocolLogin:login(EnterGame.host, EnterGame.port, EnterGame.account, EnterGame.password)
end

View File

@@ -3,6 +3,8 @@ Module
description: Manages enter game and character list windows
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 150
onLoad: |
dofile 'entergame'

View File

@@ -34,5 +34,4 @@ function Client.terminate()
Settings.set('window-size', g_window.getUnmaximizedSize())
Settings.set('window-pos', g_window.getUnmaximizedPos())
Settings.set('window-maximized', g_window.isMaximized())
g_window.hide()
end

View File

@@ -0,0 +1,14 @@
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()

View File

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B

View File

@@ -54,25 +54,40 @@ function ModuleManager.refreshModules()
end
function ModuleManager.listModules()
if not moduleManagerWindow then return end
moduleList:destroyChildren()
local modules = g_modules.getModules()
for i,module in ipairs(modules) do
local label = createWidget('ModuleListLabel', moduleList)
label:setText(module:getName())
label:setOn(module:isLoaded())
end
moduleList:focusChild(moduleList:getFirstChild(), ActiveFocusReason)
end
function ModuleManager.refreshLoadedModules()
if not moduleManagerWindow then return end
for i,child in ipairs(moduleList:getChildren()) do
local module = g_modules.getModule(child:getText())
child:setOn(module:isLoaded())
end
end
function ModuleManager.updateModuleInfo(moduleName)
if not moduleManagerWindow then return end
local name = ''
local description = ''
local autoLoad = ''
local author = ''
local website = ''
local version = ''
local canLoad = false
local loaded = false
local canReload = false
local canUnload = false
local module = g_modules.getModule(moduleName)
@@ -82,8 +97,9 @@ function ModuleManager.updateModuleInfo(moduleName)
author = module:getAuthor()
website = module:getWebsite()
version = module:getVersion()
canUnload = module:isLoaded()
canLoad = not canUnload
loaded = module:isLoaded()
canUnload = module:canUnload()
canReload = not loaded or canUnload
end
moduleManagerWindow:recursiveGetChildById('moduleName'):setText(name)
@@ -93,17 +109,26 @@ function ModuleManager.updateModuleInfo(moduleName)
moduleManagerWindow:recursiveGetChildById('moduleWebsite'):setText(website)
moduleManagerWindow:recursiveGetChildById('moduleVersion'):setText(version)
moduleManagerWindow:recursiveGetChildById('moduleLoadButton'):setEnabled(canLoad)
moduleManagerWindow:recursiveGetChildById('moduleUnloadButton'):setEnabled(canUnload)
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
function ModuleManager.loadCurrentModule()
function ModuleManager.reloadCurrentModule()
local focusedChild = moduleList:getFocusedChild()
if focusedChild then
local module = g_modules.getModule(focusedChild:getText())
if module then
module:load()
module:reload()
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
ModuleManager.show()
end
end
end
@@ -115,7 +140,14 @@ function ModuleManager.unloadCurrentModule()
if module then
module:unload()
ModuleManager.updateModuleInfo(module:getName())
ModuleManager.refreshLoadedModules()
end
end
end
function ModuleManager.reloadAllModules()
g_modules.reloadModules()
ModuleManager.refreshLoadedModules()
ModuleManager.show()
end

View File

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

View File

@@ -3,11 +3,21 @@ ModuleListLabel < Label
background-color: alpha
text-offset: 2 0
focusable: true
color: #cccccc
$focus:
background-color: #ffffff22
color: #ffffff
$on:
background-color: #006600
$!on:
background-color: #660000
$on focus:
background-color: #004400
$!on focus:
background-color: #440000
ModuleInfoLabel < Label
$!first:
margin-top: 5
@@ -19,10 +29,11 @@ ModuleValueLabel < UILabel
text-offset: 3 0
image-source: /core_styles/images/panel_flat.png
image-border: 1
height: 16
MainWindow
id: moduleManagerWindow
size: 450 450
size: 480 450
text: Module Manager
@onEscape: ModuleManager.hide()
@@ -38,21 +49,31 @@ MainWindow
margin-bottom: 30
Button
id: refreshModulesButton
anchors.top: moduleList.bottom
anchors.horizontalCenter: moduleList.horizontalCenter
anchors.left: moduleList.left
margin-top: 8
width: 80
text: Refresh
@onClick: ModuleManager.refreshModules()
Button
id: reloadAllModulesButton
anchors.top: moduleList.bottom
anchors.right: moduleList.right
margin-top: 8
width: 80
text: Reload All
@onClick: ModuleManager.reloadAllModules()
Panel
id: moduleInfo
anchors.left: moduleList.right
anchors.top: parent.top
anchors.right: parent.right
margin: 0 5 5 15
layout:
type: verticalBox
fit-children: true
layout: verticalBox
height: 265
ModuleInfoLabel
text: Module name
@@ -65,11 +86,6 @@ MainWindow
id: moduleDescription
height: 100
ModuleInfoLabel
text: Loaded
ModuleValueLabel
id: moduleLoaded
//ModuleInfoLabel
// text: Autoload
//ModuleValueLabel
@@ -97,13 +113,13 @@ MainWindow
id: moduleVersion
Button
id: moduleLoadButton
id: moduleReloadButton
anchors.top: moduleInfo.bottom
anchors.left: moduleInfo.left
margin-top: 8
text: Load
enabled: false
@onClick: ModuleManager.loadCurrentModule()
visible: false
@onClick: ModuleManager.reloadCurrentModule()
Button
id: moduleUnloadButton
@@ -112,6 +128,6 @@ MainWindow
margin-left: 10
margin-top: 8
text: Unload
enabled: false
visible: false
@onClick: ModuleManager.unloadCurrentModule()

View File

@@ -3,6 +3,11 @@ Module
description: Create the options window
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 130
dependencies:
- client_topmenu
onLoad: |
dofile 'options'

View File

@@ -45,14 +45,6 @@ function quit()
exit()
end
function reloadModule(name)
local module = g_modules.getModule(name)
if module then
module:unload()
module:load()
end
end
function autoReloadModule(name)
local function reloadEvent()
reloadModule(name)

View File

@@ -86,7 +86,10 @@ end
local function doCommand()
local currentCommand = commandLineEdit:getText()
Terminal.executeCommand(currentCommand)
commandLineEdit:clearText()
if commandLineEdit then
commandLineEdit:clearText()
end
return true
end

View File

@@ -1,11 +1,10 @@
Module
name: terminal
name: client_terminal
description: Terminal for executing lua functions
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
autoLoadAntecedence: 200
autoload: true
autoload-antecedence: 160
onLoad: |
dofile 'terminal'

View File

Before

Width:  |  Height:  |  Size: 459 B

After

Width:  |  Height:  |  Size: 459 B

View File

@@ -24,6 +24,9 @@ function TopMenu.init()
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
connect(Game, { onLogin = TopMenu.showGameButtons,
onLogout = TopMenu.hideGameButtons })
end
function TopMenu.terminate()
@@ -33,6 +36,9 @@ function TopMenu.terminate()
gameButtonsPanel = nil
topMenu:destroy()
topMenu = nil
disconnect(Game, { onLogin = TopMenu.showGameButtons,
onLogout = TopMenu.hideGameButtons })
end
function TopMenu.addButton(id, description, icon, callback, right)
@@ -82,6 +88,3 @@ end
function TopMenu.getButton(id)
return topMenu:recursiveGetChildById(id)
end
connect(Game, { onLogin = TopMenu.showGameButtons,
onLogout = TopMenu.hideGameButtons })

View File

@@ -3,6 +3,8 @@ Module
description: Create the top menu
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 120
onLoad: |
dofile 'topmenu'

View File

@@ -1,17 +0,0 @@
Module
name: core
description: Contains lua classes, functions and constants used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
// core must be loaded before other modules
autoLoad: true
autoLoadAntecedence: 10
// NOTE: order does matter
dependencies:
- core_lib
- core_fonts
- core_styles
- core_widgets

View File

@@ -3,7 +3,8 @@ Module
description: Contains fonts used by core
author: OTClient team
website: https://github.com/edubart/otclient
canUnload: false
autoload: true
autoload-antecedence: 30
onLoad: |
importFont 'verdana-11px-antialised'

View File

@@ -3,6 +3,8 @@ Module
description: Contains core lua classes, functions and constants used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 10
onLoad: |
dofile 'ext/table'
@@ -21,5 +23,3 @@ Module
dofile 'keyboard'
dofile 'mouse'
onUnload: |
rootWidget = nil

View File

@@ -1,34 +1,20 @@
local eventId = 0
local eventList = {}
function scheduleEvent(func, delay)
if not func then return end
eventId = eventId + 1
local id = eventId
local function proxyFunc()
if eventList[id] then
if eventList[id].active then
func()
end
eventList[id] = nil
end
end
eventList[id] = { func = proxyFunc, active = true }
if delay and delay > 0 then
g_dispatcher.scheduleEvent(proxyFunc, delay)
else
g_dispatcher.addEvent(proxyFunc, false)
end
return id
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(func)
return scheduleEvent(func, 0)
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(id)
if id and eventList[id] then
eventList[id].active = false
return true
function removeEvent(event)
if event then
event:cancel()
end
end

View File

@@ -74,3 +74,16 @@ function createWidget(style, parent)
widget:setStyle(style)
return widget
end
function reloadModule(name)
local module = g_modules.getModule(name)
if module then
module:reload()
end
end
function reloadModules()
g_modules.reloadModules()
end

View File

@@ -35,6 +35,28 @@ function connect(object, signalsAndSlots, pushFront)
end
end
function disconnect(object, signalsAndSlots)
for signal,slot in pairs(signalsAndSlots) do
if not object[signal] then
elseif type(object[signal]) == 'function' then
if object[signal] == slot then
object[signal] = nil
end
elseif type(object[signal]) == 'table' then
for k,func in pairs(object[signal]) do
if func == slot then
table.remove(object[signal], k)
if #object[signal] == 1 then
object[signal] = object[signal][1]
end
break
end
end
end
end
end
function extends(base)
local derived = {}
function derived.internalCreate()

View File

@@ -3,6 +3,9 @@ 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
onLoad: |
importStyle 'styles/buttons.otui'
@@ -20,3 +23,4 @@ Module
importStyle 'styles/popupmenus.otui'
importStyle 'styles/comboboxes.otui'
importStyle 'styles/spinboxes.otui'
importStyle 'styles/messagebox.otui'

View File

@@ -0,0 +1,19 @@
MessageBoxWindow < MainWindow
id: messageBoxWindow
anchors.centerIn: parent
height: 60
width: 80
padding-bottom: 10
padding-right: 10
MessageBoxLabel < Label
id: messageBoxLabel
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
MessageBoxRightButton < Button
id: messageBoxRightButton
anchors.bottom: parent.bottom
anchors.right: parent.right
width: 64
visible: true

View File

@@ -1,20 +1,4 @@
Window < UIWindow
font: verdana-11px-antialised
size: 200 200
opacity: 1
color: white
text-offset: 0 2
text-align: top
move-policy: free
stackable: true
image-source: /core_styles/images/window.png
image-border: 4
image-border-top: 20
$disabled:
color: #aaaaaa88
Window2 < UIWindow
font: verdana-11px-antialised
size: 200 200
opacity: 1
@@ -31,7 +15,7 @@ Window2 < UIWindow
$disabled:
color: #aaaaaa88
MainWindow < Window2
MainWindow < Window
anchors.centerIn: parent
MiniWindow < UIWindow

View File

@@ -3,6 +3,10 @@ Module
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'
@@ -16,6 +20,12 @@ Module
dofile 'uipopupmenu'
dofile 'uiwindow'
dofile 'uiitem'
dofile 'tooltip/tooltip'
dofile 'messagebox/messagebox'
dofile 'uimessagebox'
dofile 'tooltip'
--dofile 'messagebox/messagebox'
ToolTip.init()
onUnload: |
ToolTip.terminate()

View File

@@ -1,81 +0,0 @@
MessageBox = {}
MessageBox.__index = MessageBox
-- messagebox flags
MessageBoxOk = 1
MessageBoxCancel = 2
function MessageBox.create(title, text, flags)
local box = {}
setmetatable(box, MessageBox)
-- create messagebox window
local window = displayUI('messagebox.otui')
window:lock()
window:setText(title)
local label = window:getChildById('messageBoxLabel')
label:setText(text)
label:resizeToText()
-- set window size based on label size
window:setWidth(math.max(label:getWidth() + 48, 120))
window:setHeight(label:getHeight() + 64)
-- setup messagebox first button
local buttonRight = window:getChildById('messageBoxRightButton')
if flags == MessageBoxOk then
buttonRight:setText("Ok")
box.onOk = function() end
buttonRight.onClick = function()
box.onOk()
box:destroy()
end
window.onEnter = buttonRight.onClick
window.onEscape = buttonRight.onClick
elseif flags == MessageBoxCancel then
buttonRight:setText("Cancel")
box.onCancel = function() end
buttonRight.onClick = function()
box.onCancel()
box:destroy()
end
window.onEnter = buttonRight.onClick
window.onEscape = buttonRight.onClick
end
box.window = window
return box
end
function MessageBox:destroy()
if self.onDestroy then
self.onDestroy()
self.onDestroy = nil
end
if self.window then
self.window:destroy()
self.window = nil
end
self.onOk = nil
self.onCancel = nil
end
-- shortcuts for creating message boxes
function displayMessageBox(title, text, flags)
return MessageBox.create(title, text, flags)
end
function displayErrorBox(title, text)
return MessageBox.create(title, text, MessageBoxOk)
end
function displayInfoBox(title, text)
return MessageBox.create(title, text, MessageBoxOk)
end
function displayCancelBox(title, text)
return MessageBox.create(title, text, MessageBoxCancel)
end

View File

@@ -1,21 +0,0 @@
Window
id: messageBoxWindow
anchors.centerIn: parent
height: 80
width: 120
Label
id: messageBoxLabel
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
margin-top: 27
margin-bottom : 27
Button
id: messageBoxRightButton
anchors.bottom: parent.bottom
anchors.right: parent.right
margin-right: 10
margin-bottom: 10
width: 64
visible: true

View File

@@ -6,6 +6,8 @@ local currentHoveredWidget
-- private functions
local function moveToolTip(tooltip)
if not tooltip:isVisible() then return end
local pos = g_window.getMousePosition()
pos.y = pos.y + 1
local xdif = g_window.getSize().width - (pos.x + tooltip:getWidth())
@@ -17,28 +19,6 @@ local function moveToolTip(tooltip)
tooltip:setPosition(pos)
end
-- public functions
function ToolTip.display(text)
if text == nil then return end
ToolTip.hide()
toolTipLabel = createWidget('Label', rootWidget)
toolTipLabel:setId('toolTip')
toolTipLabel:setBackgroundColor('#111111bb')
toolTipLabel:setText(text)
toolTipLabel:resizeToText()
toolTipLabel:resize(toolTipLabel:getWidth() + 4, toolTipLabel:getHeight() + 4)
toolTipLabel.onMouseMove = moveToolTip
moveToolTip(toolTipLabel)
end
function ToolTip.hide()
if toolTipLabel then
toolTipLabel:destroy()
toolTipLabel = nil
end
end
-- UIWidget hooks
local function onWidgetHoverChange(widget, hovered)
if hovered then
if widget.tooltip then
@@ -59,8 +39,39 @@ local function onWidgetStyleApply(widget, styleName, styleNode)
end
end
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
onHoverChange = onWidgetHoverChange})
-- public functions
function ToolTip.init()
toolTipLabel = createWidget('Label', rootWidget)
toolTipLabel:setId('toolTip')
toolTipLabel:setBackgroundColor('#111111bb')
connect(toolTipLabel, { onMouseMove = moveToolTip })
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
onHoverChange = onWidgetHoverChange})
end
function ToolTip.terminate()
disconnect(UIWidget, { onStyleApply = onWidgetStyleApply,
onHoverChange = onWidgetHoverChange })
currentHoveredWidget = nil
toolTipLabel:destroy()
toolTipLabel = nil
end
function ToolTip.display(text)
if text == nil then return end
toolTipLabel:setText(text)
toolTipLabel:resizeToText()
toolTipLabel:resize(toolTipLabel:getWidth() + 4, toolTipLabel:getHeight() + 4)
toolTipLabel:show()
toolTipLabel:raise()
moveToolTip(toolTipLabel)
end
function ToolTip.hide()
toolTipLabel:hide()
end
-- UIWidget extensions
function UIWidget:setTooltip(text)

View File

@@ -1,7 +0,0 @@
Label
id: toolTipText
background-color: #111111bb
size: 200 200
id: toolTip
focusable: false
anchors.centerIn: parent

View File

@@ -1,23 +1,64 @@
--[[
UIMessageBox = extends(UIWindow)
function UIMessageBox.create(title, message)
MessageBoxOk = 1
MessageBoxCancel = 2
-- messagebox cannot be created from otui files
UIMessageBox.create = nil
function UIMessageBox.display(title, message, flags)
local messagebox = UIMessageBox.internalCreate()
rootWidget:addChild(messagebox)
messagebox:setStyle('MessageBoxWindow')
messagebox:setText(title)
local messageLabel = self:getChildById('messageLabel')
label:setText(message)
label:resizeToText()
window:setWidth(math.max(label:getWidth() + self:getPaddingLeft() + self:getPaddingRight(), self:getWidth()))
window:setHeight(label:getHeight() + self:getPaddingTop() + self:getPaddingBottom())
local messageLabel = createWidget('MessageBoxLabel', messagebox)
messageLabel:setText(message)
messageLabel:resizeToText()
messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getWidth()))
messagebox:setHeight(math.max(messageLabel:getHeight() + 64, messagebox:getHeight()))
-- setup messagebox first button
local buttonRight = createWidget('MessageBoxRightButton', messagebox)
if flags == MessageBoxOk then
buttonRight:setText('Ok')
connect(buttonRight, { onClick = function(self) self:getParent():ok() end })
elseif flags == MessageBoxCancel then
buttonRight:setText('Cancel')
connect(buttonRight, { onClick = function(self) self:getParent():cancel() end })
end
connect(messagebox, { onEnter = function(self) self:destroy() end })
connect(messagebox, { onEscape = function(self) self:destroy() end })
messagebox:lock()
return messagebox
end
function UIMessageBox:setTitle(title)
function displayInfoBox(title, message)
return UIMessageBox.display(title, message, MessageBoxOk)
end
function UIMessageBox:setMessage(message)
function displayErrorBox(title, message)
return UIMessageBox.display(title, message, MessageBoxOk)
end
function displayCancelBox(title, message)
return UIMessageBox.display(title, message, MessageBoxCancel)
end
function UIMessageBox:ok()
signalcall(self.onOk, self)
self.onOk = nil
self:destroy()
end
function UIMessageBox:cancel()
signalcall(self.onCancel, self)
self.onCancel = nil
self:destroy()
end
]]--

View File

@@ -90,13 +90,13 @@ end
function Game.onLoginError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
errorBox.onOk = CharacterList.show
connect(errorBox, { onOk = CharacterList.show })
end
function Game.onConnectionError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
errorBox.onOk = CharacterList.show
connect(errorBox, { onOk = CharacterList.show })
end
local function onApplicationClose()

View File

@@ -30,5 +30,4 @@ UIGame
id: mouseGrabber
focusable: false
visible: false
phantom: true