move UIWindow to lua

This commit is contained in:
Eduardo Bart
2012-01-10 21:13:38 -02:00
parent a1374baee1
commit 8ad88c4070
23 changed files with 57 additions and 254 deletions

View File

@@ -1,6 +1,6 @@
MainWindow
id: about
title: Info
text: Info
size: 244 221
FlatPanel

View File

@@ -10,8 +10,10 @@ local function onCharactersWindowKeyPress(self, keyCode, keyText, keyboardModifi
if keyboardModifiers == KeyboardNoModifier then
if keyCode == KeyUp or keyCode == KeyTab then
characterList:focusPreviousChild(ActiveFocusReason)
return true
elseif keyCode == KeyDown then
characterList:focusNextChild(ActiveFocusReason)
return true
end
end
return false
@@ -59,7 +61,7 @@ function CharacterList.create(characters, premDays)
charactersWindow = displayUI('characterlist.otui')
characterList = charactersWindow:getChildById('characterList')
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
charactersWindow.onKeyPress = onCharactersWindowKeyPress
connect(charactersWindow, {onKeyPress = onCharactersWindowKeyPress })
local focusLabel
for i,characterInfo in ipairs(characters) do

View File

@@ -10,7 +10,7 @@ CharacterListLabel < Label
MainWindow
id: charactersWindow
title: Character List
text: Character List
size: 250 248
@onEnter: CharacterList.doLogin()
@onEscape: CharacterList.destroy()
@@ -23,6 +23,8 @@ MainWindow
margin-bottom: 5
margin-left: 16
margin-right: 16
padding: 1
focusable: false
Label
id: accountStatusLabel

View File

@@ -1,6 +1,6 @@
MainWindow
id: enterGame
title: Enter Game
text: Enter Game
size: 236 240
@onEnter: EnterGame.doLogin()
@onEscape: EnterGame.hide()

View File

@@ -18,7 +18,7 @@ OptionCheckBox < CheckBox
MainWindow
id: optionsWindow
title: Options
text: Options
size: 286 280
@onEnter: Options.hide()
@onEscape: Options.hide()

View File

@@ -99,6 +99,21 @@ function tonumber(v)
return oldtonumber(v)
end
function signalcall(param, ...)
if type(param) == 'function' then
return param(...)
elseif type(param) == 'table' then
for k,v in pairs(param) do
if param(...) then
return true
end
end
elseif func ~= nil then
error('attempt to call a non function value')
end
return false
end
function runscript(file)
g_lua.runScript(resolvepath(file, 2))
end

View File

@@ -3,16 +3,16 @@ Window < UIWindow
size: 200 200
opacity: 1
color: white
head-height: 20
head-text-align: center
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
$pressed:
opacity: 0.75
//$pressed:
// opacity: 0.75
$disabled:
color: #aaaaaa88
@@ -20,8 +20,8 @@ Window < UIWindow
MiniWindow < UIWindow
font: verdana-11px-antialised
size: 192 200
head-height: 25
head-text-align: center
text-offset: 0 5
text-align: top
margin-top: 10
margin-left: 6
margin-right: 6

View File

@@ -12,5 +12,6 @@ Module
require 'uicombobox'
require 'uiprogressbar'
require 'uipopupmenu'
require 'uiwindow'
require 'tooltip/tooltip'
require 'messagebox/messagebox'

View File

@@ -10,8 +10,9 @@ function MessageBox.create(title, text, flags)
setmetatable(box, MessageBox)
-- create messagebox window
local window = displayUI('messagebox.otui', { locked = true })
window:setTitle(title)
local window = displayUI('messagebox.otui')
window:lock()
window:setText(title)
local label = window:getChildById('messageBoxLabel')
label:setText(text)

View File

@@ -0,0 +1,17 @@
UIWindow = extends(UIWidget)
function UIWindow.create()
local window = UIWindow.internalCreate()
window:setTextAlign(AlignTopCenter)
return window
end
function UIWindow:onKeyPress(keyCode, keyText, keyboardModifiers)
if keyboardModifiers == KeyboardNoModifier then
if keyCode == KeyReturn or keyCode == KeyEnter then
signalcall(self.onEnter, self)
elseif keyCode == KeyEscape then
signalcall(self.onEscape, self)
end
end
end

View File

@@ -3,7 +3,7 @@ Color < ColorBox
anchors.left: head.right
Window
title: Select Outfit
text: Select Outfit
size: 550 280
anchors.horizontalCenter: parent.horizontalCenter

View File

@@ -34,7 +34,7 @@ SkillPercentPanel < ProgressBar
MiniWindow
id: skillWindow
title: Skills
text: Skills
size: 200 310
Panel

View File

@@ -1,6 +1,6 @@
MainWindow
size: 256 128
title: Add to VIP list
text: Add to VIP list
@onEnter: VipList.addVip()
@onEscape: VipList.destroyAddWindow()

View File

@@ -6,7 +6,7 @@ VipListLabel < GameLabel
MiniWindow
id: vipWindow
title: VIP List
text: VIP List
UIWidget
id: vipList