begin playertrade, questlog and textbooks modules

master
Eduardo Bart 12 years ago
parent 5b352ac999
commit 00740b56f3

@ -1,5 +1,6 @@
== CRASHS
modules recursivity makes client crash, it should generate a warning
anchors recursivity makes the client crash
== P1 BUGS (affects game play)
sometimes minimap desync Z pos
@ -7,7 +8,6 @@ follow and autowalk doesn't cancel when walking via hotkeys
== P2 BUGS
battle sometimes doesn't clear attacked/followed creatures when they go out of range
if you move a backpack to left panel, and resize it, client will go into a infinite loop resizing the backpack switching 4,5 columns
when looking from floor 5 in floor 7, sometimes a tile have 2 invisible grounds in floor 6 that should be ignored
== P3 BUGS

@ -23,6 +23,9 @@ Module
- game_minimap
- game_hotkeys
- game_npctrade
- game_textbooks
- game_playertrade
- game_questlog
@onLoad: |
importStyle 'styles/items.otui'

@ -0,0 +1,7 @@
PlayerTrade = {}
function PlayerTrade.init()
end
function PlayerTrade.terminate()
end

@ -0,0 +1,15 @@
Module
name: game_playertrade
description: Allow to trade items with players
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'playertrade'
PlayerTrade.init()
@onUnload: |
PlayerTrade.terminate()

@ -0,0 +1,30 @@
QuestLog = {}
-- g_game.requestQuestLog()
-- g_game.requestQuestLine(questId)
local function onGameQuestLog(questList)
for i,questEntry in pairs(questList) do
local id, name, done = unpack(questEntry)
print(id, name, done)
end
end
local function onGameQuestLine(questId, questMissions)
for i,questMission in pairs(questMissions) do
local name, description = unpack(questMission)
print(name, description)
end
end
function QuestLog.init()
importStyle 'questlogwindow.otui'
connect(g_game, { onQuestLog = onGameQuestLog })
connect(g_game, { onQuestLine= onGameQuestLine })
end
function QuestLog.terminate()
disconnect(g_game, { onQuestLog = onGameQuestLog })
disconnect(g_game, { onQuestLine= onGameQuestLine })
end

@ -0,0 +1,15 @@
Module
name: game_questlog
description: View game quests status
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'questlog'
QuestLog.init()
@onUnload: |
QuestLog.terminate()

@ -0,0 +1 @@
QuestLogWindow < MainWindow

@ -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

@ -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()

@ -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

@ -377,6 +377,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UITextEdit>("setValidCharacters", &UITextEdit::setValidCharacters);
g_lua.bindClassMemberFunction<UITextEdit>("setShiftNavigation", &UITextEdit::setShiftNavigation);
g_lua.bindClassMemberFunction<UITextEdit>("setMultiline", &UITextEdit::setMultiline);
g_lua.bindClassMemberFunction<UITextEdit>("setMaxLength", &UITextEdit::setMaxLength);
g_lua.bindClassMemberFunction<UITextEdit>("moveCursor", &UITextEdit::moveCursor);
g_lua.bindClassMemberFunction<UITextEdit>("appendText", &UITextEdit::appendText);
g_lua.bindClassMemberFunction<UITextEdit>("removeCharacter", &UITextEdit::removeCharacter);
@ -384,6 +385,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UITextEdit>("getTextPos", &UITextEdit::getTextPos);
g_lua.bindClassMemberFunction<UITextEdit>("getTextHorizontalMargin", &UITextEdit::getTextHorizontalMargin);
g_lua.bindClassMemberFunction<UITextEdit>("getCursorPos", &UITextEdit::getCursorPos);
g_lua.bindClassMemberFunction<UITextEdit>("getMaxLength", &UITextEdit::getMaxLength);
g_lua.bindClassMemberFunction<UITextEdit>("isCursorEnabled", &UITextEdit::isCursorEnabled);
g_lua.bindClassMemberFunction<UITextEdit>("isAlwaysActive", &UITextEdit::isAlwaysActive);
g_lua.bindClassMemberFunction<UITextEdit>("isTextHidden", &UITextEdit::isTextHidden);

@ -55,6 +55,7 @@ public:
int getTextPos(Point pos);
int getTextHorizontalMargin() { return m_textHorizontalMargin; }
int getCursorPos() { return m_cursorPos; }
uint getMaxLength() { return m_maxLength; }
bool isCursorEnabled() { return m_cursorPos != -1; }
bool isAlwaysActive() { return m_alwaysActive; }
bool isTextHidden() { return m_textHidden; }

@ -357,7 +357,7 @@ void Game::processTutorialHint(int id)
void Game::processAutomapFlag(const Position& pos, int icon, const std::string& message)
{
g_lua.callGlobalField("g_game", "onAutomapFlag", pos, icon, message);
}
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList)

Loading…
Cancel
Save