diff --git a/BUGS b/BUGS index fe26ed7d..6e243c81 100644 --- a/BUGS +++ b/BUGS @@ -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 diff --git a/modules/game/game.otmod b/modules/game/game.otmod index e46bae4b..fa636f32 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -23,6 +23,9 @@ Module - game_minimap - game_hotkeys - game_npctrade + - game_textbooks + - game_playertrade + - game_questlog @onLoad: | importStyle 'styles/items.otui' diff --git a/modules/game_playertrade/playertrade.lua b/modules/game_playertrade/playertrade.lua new file mode 100644 index 00000000..221603ee --- /dev/null +++ b/modules/game_playertrade/playertrade.lua @@ -0,0 +1,7 @@ +PlayerTrade = {} + +function PlayerTrade.init() +end + +function PlayerTrade.terminate() +end diff --git a/modules/game_playertrade/playertrade.otmod b/modules/game_playertrade/playertrade.otmod new file mode 100644 index 00000000..d82d2fd2 --- /dev/null +++ b/modules/game_playertrade/playertrade.otmod @@ -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() diff --git a/modules/game_questlog/questlog.lua b/modules/game_questlog/questlog.lua new file mode 100644 index 00000000..2cbf50f1 --- /dev/null +++ b/modules/game_questlog/questlog.lua @@ -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 diff --git a/modules/game_questlog/questlog.otmod b/modules/game_questlog/questlog.otmod new file mode 100644 index 00000000..9191c09c --- /dev/null +++ b/modules/game_questlog/questlog.otmod @@ -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() diff --git a/modules/game_questlog/questlogwindow.otui b/modules/game_questlog/questlogwindow.otui new file mode 100644 index 00000000..b2a2df52 --- /dev/null +++ b/modules/game_questlog/questlogwindow.otui @@ -0,0 +1 @@ +QuestLogWindow < MainWindow \ No newline at end of file diff --git a/modules/game_textbooks/textbooks.lua b/modules/game_textbooks/textbooks.lua new file mode 100644 index 00000000..21cd6d88 --- /dev/null +++ b/modules/game_textbooks/textbooks.lua @@ -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 diff --git a/modules/game_textbooks/textbooks.otmod b/modules/game_textbooks/textbooks.otmod new file mode 100644 index 00000000..0c6129fa --- /dev/null +++ b/modules/game_textbooks/textbooks.otmod @@ -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() diff --git a/modules/game_textbooks/textwindow.otui b/modules/game_textbooks/textwindow.otui new file mode 100644 index 00000000..11fd8f81 --- /dev/null +++ b/modules/game_textbooks/textwindow.otui @@ -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 diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 7d07c1bb..2af0e3e1 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -377,6 +377,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("setValidCharacters", &UITextEdit::setValidCharacters); g_lua.bindClassMemberFunction("setShiftNavigation", &UITextEdit::setShiftNavigation); g_lua.bindClassMemberFunction("setMultiline", &UITextEdit::setMultiline); + g_lua.bindClassMemberFunction("setMaxLength", &UITextEdit::setMaxLength); g_lua.bindClassMemberFunction("moveCursor", &UITextEdit::moveCursor); g_lua.bindClassMemberFunction("appendText", &UITextEdit::appendText); g_lua.bindClassMemberFunction("removeCharacter", &UITextEdit::removeCharacter); @@ -384,6 +385,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("getTextPos", &UITextEdit::getTextPos); g_lua.bindClassMemberFunction("getTextHorizontalMargin", &UITextEdit::getTextHorizontalMargin); g_lua.bindClassMemberFunction("getCursorPos", &UITextEdit::getCursorPos); + g_lua.bindClassMemberFunction("getMaxLength", &UITextEdit::getMaxLength); g_lua.bindClassMemberFunction("isCursorEnabled", &UITextEdit::isCursorEnabled); g_lua.bindClassMemberFunction("isAlwaysActive", &UITextEdit::isAlwaysActive); g_lua.bindClassMemberFunction("isTextHidden", &UITextEdit::isTextHidden); diff --git a/src/framework/ui/uitextedit.h b/src/framework/ui/uitextedit.h index 04676ddf..e6ca15fb 100644 --- a/src/framework/ui/uitextedit.h +++ b/src/framework/ui/uitextedit.h @@ -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; } diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 664e364e..b69453f9 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -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>& outfitList)