Browse Source

questlog module complete

Eduardo Bart 8 years ago
parent
commit
2f0a151fed

+ 0
- 2
TODO View File

@@ -3,8 +3,6 @@ game_shaders (with shader manager)
3 3
 game_map (with save/load/options)
4 4
 game_minimap (with all tibia functionality)
5 5
 game_playertrade
6
-game_textbooks
7
-game_questlog
8 6
 game_ruleviolations
9 7
 
10 8
 == NOTABLE FEATURES

+ 12
- 0
modules/core_styles/styles/labels.otui View File

@@ -5,6 +5,18 @@ Label < UILabel
5 5
   $disabled:
6 6
     color: #bbbbbb88
7 7
 
8
+FlatLabel < UILabel
9
+  font: verdana-11px-antialised
10
+  color: #aaaaaa
11
+  size: 86 20
12
+  text-offset: 3 3
13
+  text-margin: 3
14
+  image-source: /core_styles/styles/images/panel_flat.png
15
+  image-border: 1
16
+
17
+  $disabled:
18
+    color: #aaaaaa88
19
+
8 20
 GameLabel < UILabel
9 21
   font: verdana-11px-antialised
10 22
   color: #bbbbbb

+ 1
- 15
modules/game_inventory/inventory.otui View File

@@ -88,25 +88,11 @@ MiniWindow
88 88
       margin-top: 5
89 89
       &position: {x=65535, y=10, z=0}
90 90
 
91
-    GameLabel
92
-      id: soul
93
-      anchors.top: slot9.bottom
94
-      anchors.bottom: slot8.bottom
95
-      anchors.left: slot9.left
96
-      anchors.right: slot9.right
97
-      margin-top: 5
98
-      text-align: center
99
-      image-source: /core_styles/styles/images/panel_flat.png
100
-      image-border: 1
101
-
102 91
     GameLabel
103 92
       id: capacity
93
+      height: 30
104 94
       anchors.top: slot10.bottom
105
-      anchors.bottom: slot8.bottom
106 95
       anchors.left: slot10.left
107
-      anchors.right: slot10.right
108 96
       margin-top: 5
109 97
       text-align: center
110
-      image-source: /core_styles/styles/images/panel_flat.png
111
-      image-border: 1
112 98
 

+ 52
- 0
modules/game_questlog/questlinewindow.otui View File

@@ -0,0 +1,52 @@
1
+MissionLabel < Label
2
+  font: verdana-11px-monochrome
3
+  background-color: alpha
4
+  text-offset: 2 0
5
+  focusable: true
6
+
7
+  $focus:
8
+    background-color: #ffffff22
9
+    color: #ffffff
10
+
11
+QuestLineWindow < MainWindow
12
+  id: questLineWindow
13
+  !text: tr('Quest Log')
14
+  size: 500 400
15
+  @onEscape: self:destroy()
16
+
17
+  TextList
18
+    id: missionList
19
+    anchors.fill: parent
20
+    anchors.bottom: none
21
+    width: 200
22
+    height: 200
23
+    padding: 1
24
+    focusable: false
25
+    margin-right: 20
26
+    vertical-scrollbar: missionListScrollBar
27
+
28
+  VerticalScrollBar
29
+    id: missionListScrollBar
30
+    anchors.top: missionList.top
31
+    anchors.bottom: missionList.bottom
32
+    anchors.left: missionList.right
33
+    step: 14
34
+    pixels-scroll: true
35
+
36
+  FlatLabel
37
+    id: missionDescription
38
+    anchors.top: missionList.bottom
39
+    anchors.left: parent.left
40
+    anchors.right: missionListScrollBar.right
41
+    anchors.bottom: parent.bottom
42
+    margin-bottom: 30
43
+    margin-top: 10
44
+    text-wrap: true
45
+
46
+  Button
47
+    id: closeButton
48
+    anchors.bottom: parent.bottom
49
+    anchors.right: parent.right
50
+    !text: tr('Close')
51
+    width: 90
52
+    @onClick: self:getParent():destroy()

+ 62
- 5
modules/game_questlog/questlog.lua View File

@@ -1,30 +1,87 @@
1 1
 QuestLog = {}
2 2
 
3
+local questLogButton
4
+local questLogWindow
5
+local questLineWindow
6
+
3 7
 -- g_game.requestQuestLog()
4 8
 -- g_game.requestQuestLine(questId)
5 9
 
6
-local function onGameQuestLog(questList)
7
-  for i,questEntry in pairs(questList) do
8
-    local id, name, done = unpack(questEntry)
9
-    print(id, name, done)
10
+local function onGameQuestLog(quests)
11
+  QuestLog.destroyWindows()
12
+
13
+  questLogWindow = createWidget('QuestLogWindow', rootWidget)
14
+  local questList = questLogWindow:getChildById('questList')
15
+
16
+  for i,questEntry in pairs(quests) do
17
+    local id, name, completed = unpack(questEntry)
18
+
19
+    local questLabel = createWidget('QuestLabel', questList)
20
+    questLabel:setOn(completed)
21
+    questLabel:setText(name)
22
+    questLabel.onDoubleClick = function()
23
+      questLogWindow:hide()
24
+      g_game.requestQuestLine(id)
25
+    end
26
+  end
27
+
28
+  questLogWindow.onDestroy = function()
29
+    questLogWindow = nil
10 30
   end
11 31
 end
12 32
 
13 33
 local function onGameQuestLine(questId, questMissions)
34
+  if questLogWindow then questLogWindow:hide() end
35
+  if questLineWindow then questLineWindow:destroy() end
36
+
37
+  questLineWindow = createWidget('QuestLineWindow', rootWidget)
38
+  local missionList = questLineWindow:getChildById('missionList')
39
+  local missionDescription = questLineWindow:getChildById('missionDescription')
40
+
41
+  missionList.onChildFocusChange = function(self, focusedChild)
42
+    if focusedChild == nil then return end
43
+    missionDescription:setText(focusedChild.description)
44
+  end
45
+
14 46
   for i,questMission in pairs(questMissions) do
15 47
     local name, description = unpack(questMission)
16
-    print(name, description)
48
+
49
+    local missionLabel = createWidget('MissionLabel', missionList)
50
+    missionLabel:setText(name)
51
+    missionLabel.description = description
52
+  end
53
+
54
+  questLineWindow.onDestroy = function()
55
+    if questLogWindow then questLogWindow:show() end
56
+    questLineWindow = nil
17 57
   end
18 58
 end
19 59
 
20 60
 function QuestLog.init()
21 61
   importStyle 'questlogwindow.otui'
62
+  importStyle 'questlinewindow.otui'
63
+
64
+  questLogButton = TopMenu.addGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end)
22 65
 
23 66
   connect(g_game, { onQuestLog = onGameQuestLog })
24 67
   connect(g_game, { onQuestLine= onGameQuestLine })
25 68
 end
26 69
 
70
+function QuestLog.destroyWindows()
71
+  if questLogWindow then
72
+    questLogWindow:destroy()
73
+    questLogWindow = nil
74
+  end
75
+
76
+  if questLineWindow then
77
+    questLineWindow:destroy()
78
+    questLineWindow = nil
79
+  end
80
+end
81
+
27 82
 function QuestLog.terminate()
28 83
   disconnect(g_game, { onQuestLog = onGameQuestLog })
29 84
   disconnect(g_game, { onQuestLine= onGameQuestLine })
85
+
86
+  QuestLog.destroyWindows()
30 87
 end

+ 51
- 1
modules/game_questlog/questlogwindow.otui View File

@@ -1 +1,51 @@
1
-QuestLogWindow < MainWindow
1
+QuestLabel < Label
2
+  font: verdana-11px-monochrome
3
+  background-color: alpha
4
+  text-offset: 2 0
5
+  focusable: true
6
+  color: #cccccc
7
+
8
+  $focus:
9
+    color: #ffffff
10
+
11
+  $on:
12
+    background-color: #006600
13
+  $!on:
14
+    background-color: #660000
15
+
16
+  $on focus:
17
+    background-color: #004400
18
+  $!on focus:
19
+    background-color: #440000
20
+
21
+QuestLogWindow < MainWindow
22
+  id: questLogWindow
23
+  !text: tr('Quest Log')
24
+  size: 500 400
25
+  @onEscape: self:destroy()
26
+
27
+  TextList
28
+    id: questList
29
+    anchors.fill: parent
30
+    width: 190
31
+    padding: 1
32
+    focusable: false
33
+    margin-bottom: 30
34
+    margin-right: 20
35
+    vertical-scrollbar: questListScrollBar
36
+
37
+  VerticalScrollBar
38
+    id: questListScrollBar
39
+    anchors.top: questList.top
40
+    anchors.bottom: questList.bottom
41
+    anchors.left: questList.right
42
+    step: 14
43
+    pixels-scroll: true
44
+
45
+  Button
46
+    id: closeButton
47
+    anchors.bottom: parent.bottom
48
+    anchors.right: parent.right
49
+    !text: tr('Close')
50
+    width: 90
51
+    @onClick: self:getParent():destroy()

+ 1
- 1
modules/game_textbooks/textbooks.lua View File

@@ -60,7 +60,7 @@ local function onGameEditList(id, doorId, text)
60 60
   textEdit:setMaxLength(8192)
61 61
   textEdit:setText(text)
62 62
   textEdit:setEnabled(true)
63
-  description:setText(tr('Enter one text per line.'))
63
+  description:setText(tr('Enter one name per line.'))
64 64
   textWindow:setText(tr('Edit List'))
65 65
 
66 66
   okButton.onClick = function()

+ 1
- 1
src/framework/graphics/texturemanager.h View File

@@ -33,7 +33,7 @@ public:
33 33
     static TexturePtr loadPNG(std::stringstream& file);
34 34
 
35 35
 private:
36
-    std::map<std::string, TextureWeakPtr> m_textures;
36
+    std::unordered_map<std::string, TextureWeakPtr> m_textures;
37 37
 };
38 38
 
39 39
 extern TextureManager g_textures;

+ 1
- 1
src/framework/ui/uimanager.h View File

@@ -82,7 +82,7 @@ private:
82 82
     Boolean<false> m_hoverUpdateScheduled;
83 83
     bool m_isOnInputEvent;
84 84
     Boolean<false> m_drawDebugBoxes;
85
-    std::map<std::string, OTMLNodePtr> m_styles;
85
+    std::unordered_map<std::string, OTMLNodePtr> m_styles;
86 86
 };
87 87
 
88 88
 extern UIManager g_ui;

Loading…
Cancel
Save