Fix some issues in text window

This commit is contained in:
Eduardo Bart 2012-09-05 21:37:52 -03:00
parent c2bbff5113
commit f491bf288f
1 changed files with 37 additions and 6 deletions

View File

@ -40,39 +40,44 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
local desc = '' local desc = ''
if #writter > 0 then if #writter > 0 then
desc = tr('You read the following, written by \n%s\n', writter) desc = tr('You read the following, written by \n%s\n', writter)
if #time > 0 then if #time > 0 then
desc = desc .. tr('on %s.\n', time) desc = desc .. tr('on %s.\n', time)
end end
elseif #time > 0 then elseif #time > 0 then
desc = tr('You read the following, written on %s.\n', time) desc = tr('You read the following, written on \n%s.\n', time)
end end
if #text == 0 and not writeable then if #text == 0 and not writeable then
desc = tr("It is empty.\n") desc = tr("It is empty.")
elseif writeable then elseif writeable then
desc = desc .. tr('You can enter new text.') desc = desc .. tr('You can enter new text.')
end end
local lines = #{string.find(desc, '\n')}
if lines < 2 then desc = desc .. '\n' end
description:setText(desc) description:setText(desc)
if not writeable then if not writeable then
textWindow:setText(tr('Show Text')) textWindow:setText(tr('Show Text'))
--textEdit:wrapText()
cancelButton:hide() cancelButton:hide()
cancelButton:setWidth(0)
okButton:setMarginRight(0)
else else
textWindow:setText(tr('Edit Text')) textWindow:setText(tr('Edit Text'))
end end
doneFunc = function() local doneFunc = function()
if writeable then if writeable then
g_game.editText(id, textEdit:getText()) g_game.editText(id, textEdit:getText())
end end
textEdit = nil
destroy() destroy()
end end
okButton.onClick = doneFunc okButton.onClick = doneFunc
textWindow.onEnter = doneFunc cancelButton.onClick = destroy
--textWindow.onEnter = doneFunc -- this should be '\n'
textWindow.onEscape = destroy textWindow.onEscape = destroy
end end
@ -100,3 +105,29 @@ function onGameEditList(id, doorId, text)
textWindow.onEnter = doneFunc textWindow.onEnter = doneFunc
textWindow.onEscape = destroy textWindow.onEscape = destroy
end end
function onGameEditList(id, doorId, text)
if textWindow then return end
textWindow = g_ui.createWidget('TextWindow', rootWidget)
local textEdit = textWindow:getChildById('text')
local description = textWindow:getChildById('description')
local okButton = textWindow:getChildById('okButton')
local cancelButton = textWindow:getChildById('cancelButton')
textEdit:setMaxLength(8192)
textEdit:setText(text)
textEdit:setEnabled(true)
description:setText(tr('Enter one name per line.'))
textWindow:setText(tr('Edit List'))
doneFunc = function()
g_game.editList(id, doorId, textEdit:getText())
destroy()
end
okButton.onClick = doneFunc
textWindow.onEnter = doneFunc
textWindow.onEscape = destroy
end