begin playertrade, questlog and textbooks modules

This commit is contained in:
Eduardo Bart
2012-04-30 21:20:27 -03:00
parent 5b352ac999
commit 00740b56f3
13 changed files with 193 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
TextBooks = {}
local function onGameEditText(id, itemId, maxLength, text, writter, time)
local textWindow = createWidget('TextWindow', rootWidget)
local writeable = maxLength ~= #text
local textItem = textWindow:getChildById('textItem')
local description = textWindow:getChildById('description')
local textEdit = textWindow:getChildById('text')
local okButton = textWindow:getChildById('okButton')
local cancelButton = textWindow:getChildById('cancelButton')
textItem:setItemId(itemId)
textEdit:setMaxLength(maxLength)
textEdit:setText(text)
textEdit:setEnabled(writeable)
local desc = tr('You read the following')
if #writter > 0 then
desc = desc .. tr(', written by \n%s\n', writter)
if #time > 0 then
desc = desc .. tr('on %s.\n', time)
end
elseif #time > 0 then
desc = desc .. tr(', written on %s.\n', time)
end
if #text == 0 and not writeable then
desc = tr("It is empty.\n")
elseif writeable then
desc = desc .. tr('You can enter new text.')
end
description:setText(desc)
okButton.onClick = function()
g_game.editText(id, textEdit:getText())
textWindow:destroy()
end
end
local function onGameEditList(listId, id, text)
end
function TextBooks.init()
importStyle 'textwindow.otui'
connect(g_game, { onEditText = onGameEditText })
connect(g_game, { onEditList = onGameEditList })
end
function TextBooks.terminate()
disconnect(g_game, { onEditText = onGameEditText })
disconnect(g_game, { onEditList = onGameEditList })
end

View File

@@ -0,0 +1,15 @@
Module
name: game_textbooks
description: Allow to edit text books and lists
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'textbooks'
TextBooks.init()
@onUnload: |
TextBooks.terminate()

View File

@@ -0,0 +1,47 @@
TextWindow < MainWindow
id: textWindow
!text: tr('Edit Text')
size: 280 280
@onEscape: self:destroy()
UIItem
id: textItem
virtual: true
item-id: 2816
size: 32 32
anchors.top: parent.top
anchors.left: parent.left
Label
id: description
anchors.top: parent.top
anchors.left: textItem.right
anchors.right: parent.right
anchors.bottom: text.top
text-align: left
margin-left: 8
margin-bottom: 10
MultilineTextEdit
id: text
anchors.fill: parent
anchors.top: textItem.bottom
margin-top: 30
margin-bottom: 30
Button
id: cancelButton
!text: tr('Cancel')
anchors.top: next.top
anchors.right: next.left
margin-right: 8
width: 60
@onClick: self:getParent():destroy()
Button
id: okButton
!text: tr('Ok')
anchors.top: text.bottom
anchors.right: text.right
margin-top: 10
width: 60