diff --git a/TODO b/TODO index d517ed7e..10c0e3c2 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,6 @@ game_shaders (with shader manager) game_map (with save/load/options) game_minimap (with all tibia functionality) game_playertrade -game_textbooks -game_questlog game_ruleviolations == NOTABLE FEATURES diff --git a/modules/core_styles/styles/labels.otui b/modules/core_styles/styles/labels.otui index 0c5a8f9f..9dc62cd0 100644 --- a/modules/core_styles/styles/labels.otui +++ b/modules/core_styles/styles/labels.otui @@ -5,6 +5,18 @@ Label < UILabel $disabled: color: #bbbbbb88 +FlatLabel < UILabel + font: verdana-11px-antialised + color: #aaaaaa + size: 86 20 + text-offset: 3 3 + text-margin: 3 + image-source: /core_styles/styles/images/panel_flat.png + image-border: 1 + + $disabled: + color: #aaaaaa88 + GameLabel < UILabel font: verdana-11px-antialised color: #bbbbbb diff --git a/modules/game_inventory/inventory.otui b/modules/game_inventory/inventory.otui index df006978..be589fc0 100644 --- a/modules/game_inventory/inventory.otui +++ b/modules/game_inventory/inventory.otui @@ -88,25 +88,11 @@ MiniWindow margin-top: 5 &position: {x=65535, y=10, z=0} - GameLabel - id: soul - anchors.top: slot9.bottom - anchors.bottom: slot8.bottom - anchors.left: slot9.left - anchors.right: slot9.right - margin-top: 5 - text-align: center - image-source: /core_styles/styles/images/panel_flat.png - image-border: 1 - GameLabel id: capacity + height: 30 anchors.top: slot10.bottom - anchors.bottom: slot8.bottom anchors.left: slot10.left - anchors.right: slot10.right margin-top: 5 text-align: center - image-source: /core_styles/styles/images/panel_flat.png - image-border: 1 diff --git a/modules/game_questlog/questlinewindow.otui b/modules/game_questlog/questlinewindow.otui new file mode 100644 index 00000000..0d05ced6 --- /dev/null +++ b/modules/game_questlog/questlinewindow.otui @@ -0,0 +1,52 @@ +MissionLabel < Label + font: verdana-11px-monochrome + background-color: alpha + text-offset: 2 0 + focusable: true + + $focus: + background-color: #ffffff22 + color: #ffffff + +QuestLineWindow < MainWindow + id: questLineWindow + !text: tr('Quest Log') + size: 500 400 + @onEscape: self:destroy() + + TextList + id: missionList + anchors.fill: parent + anchors.bottom: none + width: 200 + height: 200 + padding: 1 + focusable: false + margin-right: 20 + vertical-scrollbar: missionListScrollBar + + VerticalScrollBar + id: missionListScrollBar + anchors.top: missionList.top + anchors.bottom: missionList.bottom + anchors.left: missionList.right + step: 14 + pixels-scroll: true + + FlatLabel + id: missionDescription + anchors.top: missionList.bottom + anchors.left: parent.left + anchors.right: missionListScrollBar.right + anchors.bottom: parent.bottom + margin-bottom: 30 + margin-top: 10 + text-wrap: true + + Button + id: closeButton + anchors.bottom: parent.bottom + anchors.right: parent.right + !text: tr('Close') + width: 90 + @onClick: self:getParent():destroy() diff --git a/modules/game_questlog/questlog.lua b/modules/game_questlog/questlog.lua index 2cbf50f1..477b1ecf 100644 --- a/modules/game_questlog/questlog.lua +++ b/modules/game_questlog/questlog.lua @@ -1,30 +1,87 @@ QuestLog = {} +local questLogButton +local questLogWindow +local questLineWindow + -- 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) +local function onGameQuestLog(quests) + QuestLog.destroyWindows() + + questLogWindow = createWidget('QuestLogWindow', rootWidget) + local questList = questLogWindow:getChildById('questList') + + for i,questEntry in pairs(quests) do + local id, name, completed = unpack(questEntry) + + local questLabel = createWidget('QuestLabel', questList) + questLabel:setOn(completed) + questLabel:setText(name) + questLabel.onDoubleClick = function() + questLogWindow:hide() + g_game.requestQuestLine(id) + end + end + + questLogWindow.onDestroy = function() + questLogWindow = nil end end local function onGameQuestLine(questId, questMissions) + if questLogWindow then questLogWindow:hide() end + if questLineWindow then questLineWindow:destroy() end + + questLineWindow = createWidget('QuestLineWindow', rootWidget) + local missionList = questLineWindow:getChildById('missionList') + local missionDescription = questLineWindow:getChildById('missionDescription') + + missionList.onChildFocusChange = function(self, focusedChild) + if focusedChild == nil then return end + missionDescription:setText(focusedChild.description) + end + for i,questMission in pairs(questMissions) do local name, description = unpack(questMission) - print(name, description) + + local missionLabel = createWidget('MissionLabel', missionList) + missionLabel:setText(name) + missionLabel.description = description + end + + questLineWindow.onDestroy = function() + if questLogWindow then questLogWindow:show() end + questLineWindow = nil end end function QuestLog.init() importStyle 'questlogwindow.otui' + importStyle 'questlinewindow.otui' + + questLogButton = TopMenu.addGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end) connect(g_game, { onQuestLog = onGameQuestLog }) connect(g_game, { onQuestLine= onGameQuestLine }) end +function QuestLog.destroyWindows() + if questLogWindow then + questLogWindow:destroy() + questLogWindow = nil + end + + if questLineWindow then + questLineWindow:destroy() + questLineWindow = nil + end +end + function QuestLog.terminate() disconnect(g_game, { onQuestLog = onGameQuestLog }) disconnect(g_game, { onQuestLine= onGameQuestLine }) + + QuestLog.destroyWindows() end diff --git a/modules/game_questlog/questlogwindow.otui b/modules/game_questlog/questlogwindow.otui index b2a2df52..0f7225fa 100644 --- a/modules/game_questlog/questlogwindow.otui +++ b/modules/game_questlog/questlogwindow.otui @@ -1 +1,51 @@ -QuestLogWindow < MainWindow \ No newline at end of file +QuestLabel < Label + font: verdana-11px-monochrome + background-color: alpha + text-offset: 2 0 + focusable: true + color: #cccccc + + $focus: + color: #ffffff + + $on: + background-color: #006600 + $!on: + background-color: #660000 + + $on focus: + background-color: #004400 + $!on focus: + background-color: #440000 + +QuestLogWindow < MainWindow + id: questLogWindow + !text: tr('Quest Log') + size: 500 400 + @onEscape: self:destroy() + + TextList + id: questList + anchors.fill: parent + width: 190 + padding: 1 + focusable: false + margin-bottom: 30 + margin-right: 20 + vertical-scrollbar: questListScrollBar + + VerticalScrollBar + id: questListScrollBar + anchors.top: questList.top + anchors.bottom: questList.bottom + anchors.left: questList.right + step: 14 + pixels-scroll: true + + Button + id: closeButton + anchors.bottom: parent.bottom + anchors.right: parent.right + !text: tr('Close') + width: 90 + @onClick: self:getParent():destroy() diff --git a/modules/game_textbooks/textbooks.lua b/modules/game_textbooks/textbooks.lua index a04e6e94..1affe45d 100644 --- a/modules/game_textbooks/textbooks.lua +++ b/modules/game_textbooks/textbooks.lua @@ -60,7 +60,7 @@ local function onGameEditList(id, doorId, text) textEdit:setMaxLength(8192) textEdit:setText(text) textEdit:setEnabled(true) - description:setText(tr('Enter one text per line.')) + description:setText(tr('Enter one name per line.')) textWindow:setText(tr('Edit List')) okButton.onClick = function() diff --git a/src/framework/graphics/texturemanager.h b/src/framework/graphics/texturemanager.h index e2eb08fc..71898d13 100644 --- a/src/framework/graphics/texturemanager.h +++ b/src/framework/graphics/texturemanager.h @@ -33,7 +33,7 @@ public: static TexturePtr loadPNG(std::stringstream& file); private: - std::map m_textures; + std::unordered_map m_textures; }; extern TextureManager g_textures; diff --git a/src/framework/ui/uimanager.h b/src/framework/ui/uimanager.h index 65e37e18..9c6d1950 100644 --- a/src/framework/ui/uimanager.h +++ b/src/framework/ui/uimanager.h @@ -82,7 +82,7 @@ private: Boolean m_hoverUpdateScheduled; bool m_isOnInputEvent; Boolean m_drawDebugBoxes; - std::map m_styles; + std::unordered_map m_styles; }; extern UIManager g_ui;