some cleanup in modules, fixes in tooltip, uiwidget warnings, disable map saving for a while

This commit is contained in:
Eduardo Bart
2012-02-05 20:42:35 -02:00
parent 0471785d30
commit a55e138002
27 changed files with 180 additions and 114 deletions

View File

@@ -1,2 +0,0 @@
-- place any code for testing purposes here
--scheduleEvent(function() dumpWidgets() end, 100)

View File

@@ -1,7 +0,0 @@
Module
name: playground
autoLoad: true
autoLoadAntecedence: 1000
onLoad: |
require 'playground'

View File

@@ -15,9 +15,9 @@ function Client.init()
-- window position, default is the screen center
local displaySize = g_window.getDisplaySize()
local pos = { x = (displaySize.width - size.width)/2,
y = (displaySize.height - size.height)/2 }
pos = Settings.getPoint('window-pos', pos)
local defaultPos = { x = (displaySize.width - size.width)/2,
y = (displaySize.height - size.height)/2 }
local pos = Settings.getPoint('window-pos', defaultPos)
g_window.move(pos)
-- window maximized?

View File

@@ -9,7 +9,7 @@ function About.init()
end
function About.display()
aboutWindow = displayUI('about.otui', { locked = true })
displayUI('about.otui', { locked = true })
end
function About.terminate()

View File

@@ -8,5 +8,5 @@ Module
require 'about'
About.init()
onUnload:
onUnload: |
About.terminate()

View File

@@ -6,6 +6,7 @@ local background
-- public functions
function Background.init()
background = displayUI('background.otui')
background:lower()
end
function Background.terminate()

View File

@@ -8,6 +8,6 @@ Module
require 'background'
Background.init()
onUnload:
onUnload: |
Background.terminate()

View File

@@ -54,6 +54,18 @@ local function tryLogin(charInfo, tries)
end
-- public functions
function CharacterList.terminate()
characterList = nil
if charactersWindow then
charactersWindow:destroy()
charactersWindow = nil
end
if loadBox then
loadBox:destroy()
loadBox = nil
end
end
function CharacterList.create(characters, premDays)
if charactersWindow then
charactersWindow:destroy()
@@ -77,7 +89,7 @@ function CharacterList.create(characters, premDays)
label.characterName = characterName
label.worldHost = worldHost
label.worldPort = worldIp
connect(label, { onDoubleClick = function () CharacterList.doLogin() return true end } )
if i == 1 or Settings.get('lastUsedCharacter') == characterName then

View File

@@ -9,7 +9,8 @@ Module
require 'characterlist'
EnterGame.init()
onUnload:
onUnload: |
EnterGame.terminate()
CharacterList.terminate()

View File

@@ -40,7 +40,7 @@ MainWindow
LineEdit
id: serverHostLineEdit
tooltip: Only protocol 8.62 is supported
tooltip: Only protocol 8.6 is supported
anchors.left: serverLabel.left
anchors.right: serverLabel.right
anchors.top: serverLabel.bottom

View File

@@ -30,6 +30,7 @@ function TopMenu.terminate()
Hotkeys.unbindKeyDown('Ctrl+Q')
leftButtonsPanel = nil
rightButtonsPanel = nil
gameButtonsPanel = nil
topMenu:destroy()
topMenu = nil
end

View File

@@ -20,3 +20,6 @@ Module
require 'settings'
require 'hotkeys'
require 'cursor'
onUnload: |
rootWidget = nil

View File

@@ -1,11 +1,12 @@
ToolTip = {}
-- private variables
local currentToolTip
local toolTipLabel
local currentHoveredWidget
-- private functions
local function moveToolTip(tooltip)
local pos = g_window.getMousePos()
local pos = g_window.getMousePosition()
pos.y = pos.y + 1
local xdif = g_window.getSize().width - (pos.x + tooltip:getWidth())
if xdif < 2 then
@@ -18,34 +19,37 @@ end
-- public functions
function ToolTip.display(text)
if text then
ToolTip.hide()
currentToolTip = displayUI('tooltip.otui')
currentToolTip.onMouseMove = moveToolTip
local label = currentToolTip:getChildById('toolTipText')
label:setText(text)
label:resizeToText()
local size = label:getSize()
size.width = size.width + 4
size.height = size.height + 4
currentToolTip:setSize(size)
moveToolTip(currentToolTip)
end
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 currentToolTip then
currentToolTip:destroy()
currentToolTip = nil
if toolTipLabel then
toolTipLabel:destroy()
toolTipLabel = nil
end
end
-- UIWidget hooks
local function onWidgetHoverChange(widget, hovered)
if hovered then
ToolTip.display(widget.tooltip)
if widget.tooltip then
ToolTip.display(widget.tooltip)
currentHoveredWidget = widget
end
else
ToolTip:hide()
if widget == currentHoveredWidget then
ToolTip:hide()
currentHoveredWidget = nil
end
end
end

View File

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