Changeset 7830 for code/branches/tutoriallevel/data
- Timestamp:
- Jan 16, 2011, 2:15:39 PM (14 years ago)
- Location:
- code/branches/tutoriallevel/data
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel/data/gui/layouts/QuestGUI.layout
r6746 r7830 1 1 <?xml version="1.0" ?> 2 2 <GUILayout> 3 <Window Type="MenuWidgets/StaticImage" Name="orxonox/QuestGUI/Background"> 4 <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/> 5 <Property Name="Image" Value="set:MainMenuBackground image:Background"/> 6 <Property Name="FrameEnabled" Value="set:true"/> 7 <Property Name="BackgroundEnabled" Value="set:false"/> 8 <Property Name="InheritsAlpha" Value="False" /> 3 <Window Type="DefaultWindow" Name="orxonox/QuestGUI/Background"> 4 <Property Name="InheritsAlpha" Value="False" /> 5 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" /> 9 6 10 <Window Type="MenuWidgets/Titlebar" Name="orxonox/QuestGUI/Title"> 11 <Property Name="UnifiedPosition" Value="{{0.05,0},{0.05,0}}"/> 12 <Property Name="UnifiedSize" Value="{{0.9,0},{0.05,0}}"/> 13 <Property Name="Text" Value="Your Quests"/> 7 <Window Type="DefaultWindow" Name="orxonox/QuestGUI/MainWindow"> 8 <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.1,0},{0.9,0},{0.9,0}}" /> 9 10 <Window Type="MenuWidgets/Titlebar" Name="orxonox/QuestGUI/Title"> 11 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{0,30}}" /> 12 <Property Name="Text" Value="Your Quests"/> 13 </Window> 14 15 <Window Type="MenuWidgets/StaticText" Name="orxonox/QuestGUI/MainWindow/LeftPanel"> 16 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,30},{0.5,0},{1,0}}" /> 17 18 <Window Type="MenuWidgets/TabButton" Name="orxonox/QuestGUI/ActiveQuestsButton"> 19 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0.5,0},{0,30}}" /> 20 <Property Name="Text" Value="active quests"/> 21 <Event Name="Clicked" Function="QuestGUI.showActiveQuestsButton_clicked"/> 22 </Window> 23 <Window Type="MenuWidgets/TabButton" Name="orxonox/QuestGUI/FinishedQuestsButton"> 24 <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0,0},{1,0},{0,30}}" /> 25 <Property Name="Text" Value="finished quests"/> 26 <Event Name="Clicked" Function="QuestGUI.showFinishedQuestsButton_clicked"/> 27 </Window> 28 29 <Window Type="MenuWidgets/Listbox" Name="orxonox/QuestGUI/QuestsList"> 30 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,30},{1,0},{1,0}}" /> 31 <Event Name="ItemSelectionChanged" Function="QuestGUI.changeQuest_clicked"/> 32 </Window> 33 </Window> 34 35 <Window Type="MenuWidgets/StaticText" Name="orxonox/QuestGUI/MainWindow/RightPanel"> 36 <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0,30},{1,0},{1,0}}" /> 37 38 <Window Type="MenuWidgets/StaticText" Name="orxonox/QuestGUI/Quest/Title"> 39 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{0,30}}" /> 40 <Property Name="Text" Value="Quest Title"/> 41 </Window> 42 43 <Window Type="MenuWidgets/ScrollablePane" Name="orxonox/QuestGUI/Quest/Wrapper"> 44 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,30},{1,0},{1,0}}" /> 45 46 <Window Type="MenuWidgets/StaticText" Name="orxonox/QuestGUI/Quest/Description"> 47 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{0,0}}" /> 48 <Property Name="HorzFormatting" Value="WordWrapLeftAligned" /> 49 <Property Name="VertFormatting" Value="TopAligned" /> 50 <Property Name="FrameEnabled" Value="false" /> 51 <Property Name="Text" Value="Quest Description"/> 52 </Window> 53 54 <Window Type="MenuWidgets/Listbox" Name="orxonox/QuestGUI/Quest/SubquestsList"> 55 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" /> 56 <Event Name="ItemSelectionChanged" Function="QuestGUI.changeToSubquest_clicked"/> 57 </Window> 58 59 <Window Type="MenuWidgets/StaticText" Name="orxonox/QuestGUI/Quest/Hints"> 60 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{0,0}}" /> 61 <Property Name="VertFormatting" Value="TopAligned" /> 62 <Property Name="FrameEnabled" Value="false" /> 63 <Property Name="Text" Value="Hints:" /> 64 </Window> 65 </Window> 66 </Window> 14 67 </Window> 15 16 <Window Type="MenuWidgets/Listbox" Name="orxonox/QuestGUI/QuestsList">17 <Property Name="UnifiedPosition" Value="{{0.07,0},{0.18,0}}" />18 <Property Name="UnifiedSize" Value="{{0.86,0},{0.8,0}}" />19 <Property Name="Alpha" Value="0.8" />20 </Window>21 22 68 </Window> 23 69 </GUILayout> -
code/branches/tutoriallevel/data/gui/scripts/QuestGUI.lua
r7732 r7830 3 3 local P = createMenuSheet("QuestGUI") 4 4 5 P.questManager = nil -- The QuestManager. 6 P.showActive = true -- Whether the active or finished quest list is displayed. 7 P.currentQuest = nil -- The quest that is currently displayed. 8 P.player = nil -- The player the quests are displayed for. 9 P.quests = {} 10 P.subquests = {} 11 12 -- design parameters 13 P.scrollbarWidth = 13 14 P.frameHeigth = 18 15 P.borderSize = 5 16 P.titleHeight = 26 17 18 -- old: 5 19 P.rootWindow = nil 6 20 P.detailsWindows = {} … … 11 25 -- design parameters 12 26 P.indentWidth = 20 13 P.scrollbarWidth = 1314 27 P.buttonHeight = 30 15 P.titleHeight = 2616 28 P.borderWidth = 5 17 29 30 --TODO: 31 -- Highlight whether we are currently looking at active or finished quests 32 -- Distinguish completet from failed quests 33 -- Add hints 34 35 function P.onLoad() 36 P.questManager = orxonox.QuestManager:getInstance() 37 end 38 18 39 function P.onShow() 19 20 local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList") 21 40 -- Get the player. 22 41 P.player = orxonox.GUIManager:getInstance():getPlayer(P.name) 23 P.rootWindow = P.createQuestGUI() 24 25 questsList:addChildWindow(P.rootWindow)42 43 -- Load the list of quests to be displayed. 44 P.loadQuestsList(P.currentQuest) 26 45 end 27 46 28 47 function P.onHide() 29 P.cleanup() 30 end 31 48 --P.cleanup() 49 end 50 51 function P.loadQuestsList(selectQuest) 52 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList")) 53 P.clearQuestList() 54 55 local selectQuestId = nil 56 if selectQuest ~= nil then 57 selectQuestId = P.questManager:getId(selectQuest) 58 end 59 60 -- Iterate through all root-quests. 61 local numRootQuests = P.questManager:getNumRootQuests(P.player) 62 if numRootQuests > 0 then 63 local i = 0 64 while i <= numRootQuests-1 do 65 local quest = P.questManager:getRootQuest(P.player, i) 66 local item = P.insertQuest(list, quest) 67 if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(quest) then 68 list:setItemSelectState(item, true) 69 end 70 P.insertSubQuests(list, quest, selectQuestId) 71 i = i+1 72 end 73 if list:getItemCount() > 0 then 74 if selectQuestId == nil then 75 list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first quest. 76 end 77 else 78 P.loadQuest() 79 end 80 end 81 end 82 83 function P.insertSubQuests(list, quest, selectQuestId) 84 -- Iterate through all sub-quests. 85 local numQuests = P.questManager:getNumSubQuests(quest, P.player) 86 if numQuests > 0 then 87 local i = 0 88 while i <= numQuests-1 do 89 local subquest = P.questManager:getSubQuest(quest, P.player, i) 90 local item = P.insertQuest(list, subquest) 91 if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(subquest) then 92 list:setItemSelectState(item, true) 93 end 94 i = i+1 95 end 96 end 97 end 98 99 function P.insertQuest(list, quest) 100 if P.showActive == quest:isActive(P.player) then 101 local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle()) 102 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 103 list:addItem(item) 104 table.insert(P.quests, quest) 105 return item 106 end 107 return nil 108 end 109 110 function P.loadQuest(quest) 111 112 P.clearQuest() 113 if quest == nil then 114 return 115 else 116 local offset = 0 117 118 -- Load title and description 119 local description = P.questManager:getDescription(quest) 120 local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title") 121 titleWindow:setText(description:getTitle()) 122 local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description") 123 descriptionWindow:setText(description:getDescription()) 124 descriptionWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(1, 0))) 125 descriptionWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, P.borderSize))) 126 local height = getStaticTextWindowHeight(descriptionWindow) 127 descriptionWindow:setHeight(CEGUI.UDim(0, height)) 128 offset = offset + height 129 130 -- Load subquests 131 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList")) 132 local numQuests = P.questManager:getNumSubQuests(quest, P.player) 133 local i = 0 134 while i <= numQuests-1 do 135 local quest = P.questManager:getSubQuest(quest, P.player, i) 136 --if P.showActive == quest:isActive(P.player) then 137 local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle()) 138 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 139 list:addItem(item) 140 table.insert(P.subquests, quest) 141 --end 142 i = i+1 143 end 144 height = list:getTotalItemsHeight() 145 if height > 0 then 146 height = height+P.frameHeigth 147 end 148 list:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(0, height))) 149 list:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset))) 150 offset = offset + height 151 152 -- Load hints 153 local hintsWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints") 154 hintsWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset))) 155 hintsWindow:setWidth(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize)) 156 height = P.titleHeight 157 local numHints = P.questManager:getNumHints(quest, P.player) 158 local i = 0 159 while i <= numHints-1 do 160 local hint = P.questManager:getHints(quest, P.player, i) 161 height = height + P.insertHint(hintsWindow, hint, i, height) 162 i = i+1 163 end 164 hintsWindow:setHeight(CEGUI.UDim(0, height)) 165 end 166 167 P.currentQuest = quest 168 end 169 170 function P.clearQuest() 171 -- clear title 172 local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title") 173 titleWindow:setText("no Quests") 174 175 -- clear description 176 local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description") 177 descriptionWindow:setText("There is currently no quest that can be displayed.") 178 179 -- clear list fo subquests 180 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList")) 181 list:resetList() 182 list:setHeight(CEGUI.UDim(0, 0)) 183 P.subquests = {} 184 185 -- clear hints 186 local hints = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints") 187 local numChildren = hints:getChildCount()-2 -- TODO: HACK 188 local i = 0 189 while i < numChildren do 190 local hint = hints:getChild("orxonox/QuestGUI/Quest/Hints/" .. i) 191 if hint ~= nil then 192 hints:removeChildWindow(hint) 193 winMgr:destroyWindow(hint) 194 end 195 i = i+1 196 end 197 hints:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(0, 0))) 198 199 P.currentQuest = nil 200 end 201 202 function P.clearQuestList() 203 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList")) 204 list:resetList() 205 P.quests = {} 206 end 207 208 function P.selectQuest(list, quest) 209 if quest == nil then 210 cout(1, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.") 211 list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first 212 return 213 end 214 215 local questId = P.questManager:getId(quest) 216 local found = false 217 local index = 0 218 for k,v in pairs(P.quests) do 219 if P.questManager:getId(v) == questId then 220 found = true 221 index = k-1 222 end 223 end 224 cout(0, questId .. " " .. index) 225 if found then 226 list:setItemSelectState(list:getListboxItemFromIndex(index), true) 227 else 228 cout(1, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.") 229 list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first 230 end 231 end 232 233 function P.insertHint(hintsWindow, hint, index, offset) 234 local window = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/QuestGUI/Quest/Hints/" .. index) 235 window:setProperty("HorzFormatting", "WordWrapLeftAligned") 236 window:setProperty("VertFormatting", "TopAligned") 237 window:setProperty("FrameEnabled", "false") 238 window:setID(index) 239 hintsWindow:addChildWindow(window) 240 local description = P.questManager:getDescription(hint) 241 window:setText(description:getDescription()) 242 window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(1, 0))) 243 local height = getStaticTextWindowHeight(window) 244 window:setHeight(CEGUI.UDim(0, height)) 245 window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset))) 246 return height+P.borderSize 247 end 248 249 function P.showActiveQuestsButton_clicked(e) 250 if P.showActive == false then 251 P.showActive = true 252 P.loadQuestsList() 253 end 254 end 255 256 function P.showFinishedQuestsButton_clicked(e) 257 if P.showActive == true then 258 P.showActive = false 259 P.loadQuestsList() 260 end 261 end 262 263 function P.changeQuest_clicked(e) 264 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList")) 265 local choice = list:getFirstSelectedItem() 266 if choice ~= nil then 267 local index = list:getItemIndex(choice) 268 local quest = P.quests[index+1] 269 if quest ~= nil then 270 P.loadQuest(quest) 271 end 272 end 273 end 274 275 function P.changeToSubquest_clicked(e) 276 local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList")) 277 local questsList = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList")) 278 local choice = list:getFirstSelectedItem() 279 if choice ~= nil then 280 local index = list:getItemIndex(choice) 281 local quest = P.subquests[index+1] 282 if quest ~= nil then 283 if quest:isActive(P.player) == P.showActive then 284 P.selectQuest(questsList, quest) 285 else 286 P.showActive = quest:isActive(P.player) 287 P.loadQuestsList(quest) 288 end 289 else 290 cout(1, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...") 291 end 292 end 293 end 294 295 -- old: 296 --[[ 32 297 function P.createQuestGUI() 33 298 local questManager = orxonox.QuestManager:getInstance() … … 283 548 winMgr:destroyWindow(P.detailsWindows[detailsNr]) 284 549 P.detailsWindows[detailsNr] = nil 285 end 550 end --]] 286 551 287 552 return P -
code/branches/tutoriallevel/data/gui/scripts/SingleplayerMenu.lua
r7689 r7830 47 47 index = index + 1 48 48 end 49 --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename. 50 --table.sort(levelList) 49 51 50 for k,v in pairs(P.levelList) do 52 51 local item = CEGUI.createListboxTextItem(v:getName())
Note: See TracChangeset
for help on using the changeset viewer.