Changeset 6711
- Timestamp:
- Apr 13, 2010, 10:16:10 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/pickup4 (added) merged: 6632,6669,6675,6679,6700-6701,6707
- Property svn:mergeinfo changed
-
code/trunk/data/gui/layouts/PickupInventory.layout
r6417 r6711 1 <?xml version="1.0" encoding="UTF-8" ?> 2 <GUILayout> 3 <Window Type="TaharezLook/FrameWindow" Name="orxonox/Inventory"> 4 <Property Name="UnifiedMinSize" Value="{{0.0,385},{0.0,200}}" /> 5 <Property Name="UnifiedMaxSize" Value="{{0.0,385},{0.0,200}}" /> 6 <Property Name="UnifiedPosition" Value="{{0.5,-100},{0.5,-85}}" /> 7 <Property Name="UnifiedSize" Value="{{0.0,385},{0.0,200}}" /> 8 <Property Name="Text" Value="Inventory" /> 9 <Property Name="CloseButtonEnabled" Value="False" /> 1 <?xml version="1.0" encoding="UTF-8"?> 10 2 11 <Window Type="TaharezLook/TabControl" Name="orxonox/Inventory/TabControl" > 12 <Property Name="Tooltip" Value="Inventory" /> 13 <Property Name="TabHeight" Value="{0,-1}" /> 3 <GUILayout > 4 <Window Type="DefaultWindow" Name="orxonox/PickupInventory/Background" > 5 <Property Name="InheritsAlpha" Value="False" /> 6 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 7 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" /> 8 <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/PickupInventory" > 9 <Property Name="Text" Value="Pickup Inventory" /> 10 <Property Name="Alpha" Value="0.8" /> 11 <Property Name="InheritsAlpha" Value="False" /> 12 <Property Name="HorzFormatting" Value="HorzCentred" /> 14 13 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 15 <Property Name="TabPanePosition" Value="Bottom" /> 16 <Property Name="UnifiedAreaRect" Value="{{0,10},{0,30},{1,-10},{1,-10}}" /> 17 18 <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabEquipment"> 19 <Property Name="Text" Value="Equipment" /> 20 <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/> 21 <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/> 22 </Window> 23 <Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabUsable"> 24 <Property Name="Text" Value="Usable" /> 25 <Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/> 26 <Property Name="UnifiedSize" Value="{{1.0,-6},{1.0,-6}}"/> 14 <Property Name="VertFormatting" Value="TopAligned" /> 15 <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.15,0},{0.85,0},{0.8,0}}" /> 16 <Window Type="TaharezLook/StaticText" Name="orxonox/PickupInventory/Wrapper" > 17 <Property Name="TextColours" Value="FF4444FF" /> 18 <Property Name="InheritsAlpha" Value="False" /> 19 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 20 <Property Name="HorzFormatting" Value="HorzCentred" /> 21 <Property Name="VertFormatting" Value="TopAligned" /> 22 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" /> 23 <Window Type="TaharezLook/ScrollablePane" Name="orxonox/PickupInventory/Inventory" > 24 <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" /> 25 <Property Name="HorzStepSize" Value="0.005" /> 26 <Property Name="VertStepSize" Value="0.005" /> 27 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 28 <Property Name="HorzOverlapSize" Value="0.01" /> 29 <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" /> 30 <Property Name="VertOverlapSize" Value="0.01" /> 31 <Property Name="HorzScrollPosition" Value="0" /> 32 <Property Name="VertScrollPosition" Value="0" /> 33 </Window> 27 34 </Window> 28 35 </Window> 29 30 <Event Name="WindowUpdate" Function="PickupInventory.update" /> 36 <Window Type="TaharezLook/Button" Name="orxonox/PickupInventory/InventoryBackButton" > 37 <Property Name="Text" Value="Back" /> 38 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 39 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8350,0},{0.6,0},{0.8800,0}}" /> 40 <Event Name="Clicked" Function="PickupInventory.InventoryBackButton_clicked"/> 41 </Window> 31 42 </Window> 32 43 </GUILayout> -
code/trunk/data/gui/schemes/OrxonoxGUIScheme.scheme
r5951 r6711 2 2 <GUIScheme Name="OrxonoxGUI"> 3 3 <Imageset Name="MainMenuBackground" Filename="MainMenuBackground.imageset"/> 4 <Imageset Name="PickupInventory" Filename="PickupInventory.imageset"/> 4 5 </GUIScheme> -
code/trunk/data/gui/scripts/InitialiseGUI.lua
r6417 r6711 223 223 end 224 224 225 --TODO: Needed? 225 226 function test(e) 226 227 debug(0, "Blubb") -
code/trunk/data/gui/scripts/PickupInventory.lua
r6417 r6711 3 3 BasicGUI = require("BasicGUI") 4 4 local P = BasicGUI:new() --inherit everything from the gui package 5 5 6 if _REQUIREDNAME == nil then 6 7 PickupInventory = P … … 12 13 P.layoutString = "PickupInventory.layout" 13 14 14 P.lastEquipmentCount_ = 0 15 P.lastUsableCount_ = 0 16 P.currentUsableID_ = 0 17 18 -- events 19 function P:frmUpdate(e) 20 local equipCount = orxonox.PickupInventory:getEquipmentCount() 21 local usableCount = orxonox.PickupInventory:getUsableCount() 22 23 if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then 24 self:updateTabs() 25 end 26 end 27 28 function P.update(e) 29 loadedGUIs["PickupInventory"]:frmUpdate(e) 30 end 31 32 function P.itemClicked(e) 33 loadedGUIs["PickupInventory"]:mItemClicked(e) 34 end 35 36 function P:mItemClicked(e) 37 local w = CEGUI.toWindowEventArgs(e).window 38 local name = w:getName() 39 local t = name:sub(25, 27) 40 local i = name:sub(29) 41 42 if t == "equ" then 43 44 end 45 46 if t == "use" then 47 if self.currentUsableID_ >= 0 then 48 winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF") 15 P.carrierList = {} 16 P.wrapper = nil 17 P.detailsWindows = {} 18 19 function P.init() 20 carrierList = {} 21 end 22 23 function P.show() 24 P.window:show() -- TODO: Do this through parent... 25 P.visible = true 26 27 P.createInventory() 28 29 end 30 31 function P.hide() 32 P.cleanup() 33 34 end 35 36 function P.update() 37 P.cleanup() 38 39 P.createInventory() 40 end 41 42 function P.createInventory() 43 local pickupManager = orxonox.PickupManager:getInstance() 44 local carrier = pickupManager:getPawn() 45 46 local root = winMgr:getWindow("orxonox/PickupInventory/Inventory") 47 P.wrapper = winMgr:createWindow("TaharezLook/ScrollablePane", "orxonox/PickupInventory/Inventory/Wrapper") 48 P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) 49 root:addChildWindow(P.wrapper) 50 51 P.carrierList = {} 52 53 --Design parameters: 54 local space = 15 55 56 P.getCarrierList(carrier) 57 local offset = 0 58 for k,v in pairs(P.carrierList) do 59 local window = P.createCarrierBox(v,k) 60 window:setYPosition(CEGUI.UDim(0,offset)) 61 offset = offset + window:getHeight():asAbsolute(1) + space 62 P.wrapper:addChildWindow(window) 63 end 64 end 65 66 function P.getCarrierList(carrier) 67 68 -- TODO: Test for nil or 0? 69 if carrier == nil then 70 return 71 end 72 73 table.insert(P.carrierList, carrier) 74 75 local numCarriers = orxonox.PickupManager:getInstance():getNumCarrierChildren(carrier) 76 if numCarriers == 0 then 77 return 78 end 79 80 for i=0,numCarriers-1,1 do 81 local child = orxonox.PickupManager:getInstance():getCarrierChild(i, carrier) 82 if child ~= nil then 83 P.getCarrierList(child) 49 84 end 50 orxonox.PickupInventory:selectUsable(tonumber(i)) 51 self.currentUsableID_ = tonumber(i) 52 winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444") 53 end 54 end 55 56 -- methods 57 function P:updateTabs() 58 local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment") 59 local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable") 60 orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin) 61 orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin) 62 63 self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex() 64 self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount() 65 self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount() 85 end 86 end 87 88 function P.createCarrierBox(carrier, index) 89 90 local name = "orxonox/PickupInventory/Carrier" .. index 91 92 --Design parameters: 93 local imageHeight = 50 94 local textHeight = 30 95 local horizontalOffset = 20 96 local buttonWidth = 85 97 98 local offset = 0 99 100 local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Box") 101 box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0))) 102 box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0))) 103 104 offset = offset+textHeight 105 local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title") 106 title:setText(carrier:getCarrierName()) 107 title:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, offset))) 108 title:setProperty("FrameEnabled", "set:False") 109 box:addChildWindow(title) 110 111 local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier) 112 for i=0,numPickups-1,1 do 113 local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier) 114 115 local item = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i) 116 item:setSize(CEGUI.UVector2(CEGUI.UDim(1, -horizontalOffset), CEGUI.UDim(0, imageHeight))) 117 item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, offset))) 118 box:addChildWindow(item) 119 offset = offset + imageHeight+5 120 121 local image = winMgr:createWindow("TaharezLook/StaticImage", name .. "/Box/Pickup" .. i .. "/Image") 122 image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation()) 123 image:setProperty("BackgroundEnabled", "set:False") 124 image:setProperty("FrameEnabled", "set:True") 125 image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageHeight), CEGUI.UDim(0, imageHeight))) 126 item:addChildWindow(image) 127 128 local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i .. "/Title") 129 title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageHeight+5), CEGUI.UDim(0, (imageHeight-textHeight)/2))) 130 title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, textHeight))) 131 title:setText(pickup:getPickupName()) 132 title:setProperty("FrameEnabled", "set:False") 133 item:addChildWindow(title) 134 135 local useButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/UseButton") 136 useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+10),CEGUI.UDim(0, (imageHeight-textHeight)/2))) 137 useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight))) 138 useButton:setText("use") 139 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.filename .. ".InventoryUseButton_clicked") 140 item:addChildWindow(useButton) 141 142 local dropButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/DropButton") 143 dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+15+buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2))) 144 dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight))) 145 dropButton:setText("drop") 146 orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.filename .. ".InventoryDropButton_clicked") 147 item:addChildWindow(dropButton) 148 149 local detailsButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/DetailsButton") 150 detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+20+2*buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2))) 151 detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight))) 152 detailsButton:setText("details") 153 orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.filename .. ".InventoryDetailsButton_clicked") 154 item:addChildWindow(detailsButton) 155 end 156 157 box:setHeight(CEGUI.UDim(0,offset)) 158 159 return box 160 end 161 162 function P.cleanup() 163 if P.wrapper ~= nil then 164 winMgr:destroyWindow(P.wrapper) 165 end 166 167 --Destroy details windows. 168 for k,v in pairs(P.detailsWindows) do 169 if v ~= nil then 170 winMgr:destroyWindow(v) 171 end 172 end 173 end 174 175 function P.windowToCarrierHelper(e) 176 local we = CEGUI.toWindowEventArgs(e) 177 local name = we.window:getName() 178 179 local match = string.gmatch(name, "%d+") 180 local carrierNr = tonumber(match()) 181 local pickupNr = tonumber(match()) 182 183 local arguments = {} 184 arguments[1] = carrierNr 185 arguments[2] = pickupNr 186 return arguments 187 end 188 189 function P.createDetailsWindow(pickupIndex, carrierIndex) 190 local carrier = P.carrierList[carrierIndex] 191 local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(pickupIndex, carrier) 192 193 local headerOffset = 35 194 --Design parameters 195 local titleHeight = 30 196 local imageSize = 100 197 local buttonWidth = 85 198 199 local name = "orxonox/PickupInventory/Carrier" .. carrierIndex .. "/Pickup" .. pickupIndex .. "/Details" .. P.getNewDetailNumber() 200 201 local window = winMgr:createWindow("TaharezLook/FrameWindow", name) 202 window:setSize(CEGUI.UVector2(CEGUI.UDim(0.5,0),CEGUI.UDim(0.4,0))) 203 orxonox.GUIManager:subscribeEventHelper(window, "CloseClicked", P.filename .. ".closeDetailWindow") 204 205 local root = winMgr:getWindow("orxonox/PickupInventory/Background") 206 root:addChildWindow(window) 207 208 local wrapper = winMgr:createWindow("DefaultWindow", name .. "/Wrapper") 209 wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1, -20),CEGUI.UDim(1, -50))) 210 wrapper:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10),CEGUI.UDim(0, 40))) 211 window:addChildWindow(wrapper) 212 213 local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title") 214 title:setText(pickup:getPickupName()) 215 title:setHeight(CEGUI.UDim(0, titleHeight)) 216 title:setProperty("FrameEnabled", "set:False") 217 title:setProperty("BackgroundEnabled", "set:False") 218 wrapper:addChildWindow(title) 219 220 local image = winMgr:createWindow("TaharezLook/StaticImage", name .. "/Image") 221 image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation()) 222 image:setProperty("BackgroundEnabled", "set:False") 223 image:setProperty("FrameEnabled", "set:True") 224 image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageSize), CEGUI.UDim(0, imageSize))) 225 image:setYPosition(CEGUI.UDim(0, titleHeight + 5)) 226 wrapper:addChildWindow(image) 227 228 local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Description") 229 box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(imageSize + 10)),CEGUI.UDim(1, -(titleHeight + 5 + titleHeight + 20)))) 230 box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize + 10),CEGUI.UDim(0, titleHeight + 5))) 231 local description = winMgr:createWindow("TaharezLook/StaticText", name .. "/Description/Text") 232 description:setText(pickup:getPickupDescription()) 233 description:setProperty("HorzFormatting", "WordWrapLeftAligned") 234 description:setProperty("VertFormatting", "TopAligned") 235 box:addChildWindow(description) 236 wrapper:addChildWindow(box) 237 238 local useButton = winMgr:createWindow("TaharezLook/Button", name .. "/UseButton") 239 useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10),CEGUI.UDim(1, -40))) 240 useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight))) 241 useButton:setText("use") 242 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.filename .. ".InventoryUseButton_clicked") 243 wrapper:addChildWindow(useButton) 244 245 local dropButton = winMgr:createWindow("TaharezLook/Button", name .. "/DropButton") 246 dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10+buttonWidth+10),CEGUI.UDim(1, -40))) 247 dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight))) 248 dropButton:setText("drop") 249 orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.filename .. ".InventoryDropButton_clicked") 250 wrapper:addChildWindow(dropButton) 251 252 table.insert(P.detailsWindows, window) 253 254 end 255 256 function P.getNewDetailNumber() 257 local number = table.getn(P.detailsWindows) 258 for k,v in pairs(P.detailsWindows) do 259 if v == nil then 260 number = k-1 261 end 262 end 263 return number 264 end 265 266 function P.InventoryUseButton_clicked(e) 267 local arguments = P.windowToCarrierHelper(e) 268 orxonox.PickupManager:getInstance():usePickup(arguments[2], P.carrierList[arguments[1]], true) 269 end 270 271 function P.InventoryDropButton_clicked(e) 272 local arguments = P.windowToCarrierHelper(e) 273 orxonox.PickupManager:getInstance():dropPickup(arguments[2], P.carrierList[arguments[1]]) 274 end 275 276 function P.InventoryDetailsButton_clicked(e) 277 local arguments = P.windowToCarrierHelper(e) 278 P.createDetailsWindow(arguments[2], arguments[1]) 279 end 280 281 function P.closeDetailWindow(e) 282 --Get some numbers from the window 283 local we = CEGUI.toWindowEventArgs(e) 284 local name = we.window:getName() 285 local match = string.gmatch(name, "%d+") 286 local carrierNr = tonumber(match()) 287 local pickupNr = tonumber(match()) 288 local detailNr = tonumber(match()) 289 290 local window = P.detailsWindows[detailNr+1] 291 winMgr:destroyWindow(window) 292 P.detailsWindows[detailNr+1] = nil 293 end 294 295 function P.InventoryBackButton_clicked(e) 296 hideGUI("PickupInventory") 66 297 end 67 298 -
code/trunk/data/gui/scripts/QuestGUI.lua
r6417 r6711 11 11 12 12 function P:show() 13 self.window:show() -- T DO: Do this through parent...13 self.window:show() -- TODO: Do this through parent... 14 14 self.visible = true 15 15 -
code/trunk/data/levels/includes/pickups.oxi
r6524 r6711 1 1 <PickupRepresentation 2 name = "Small Health Boost" 3 description = "Adds a small amout of health to the ship." 2 pickupName = "Small Health Boost" 3 pickupDescription = "Adds a small amout of health to the ship." 4 inventoryRepresentation = "SmallHealth" 4 5 spawnerTemplate = "smallhealthpickupRepresentation" 5 6 > … … 10 11 11 12 <PickupRepresentation 12 name = "Medium Health Boost"13 description = "Adds a medium amout of health to the ship."13 pickupName = "Medium Health Boost" 14 pickupDescription = "Adds a medium amout of health to the ship." 14 15 spawnerTemplate = "mediumhealthpickupRepresentation" 16 inventoryRepresentation = "MediumHealth" 15 17 > 16 18 <pickup> … … 20 22 21 23 <PickupRepresentation 22 name = "Huge Health Boost"23 description = "Adds a huge amout of health to the ship."24 pickupName = "Huge Health Boost" 25 pickupDescription = "Adds a huge amout of health to the ship." 24 26 spawnerTemplate = "hugehealthpickupRepresentation" 27 inventoryRepresentation = "HugeHealth" 25 28 > 26 29 <pickup> … … 30 33 31 34 <PickupRepresentation 32 name = "Crazy Madness Health Boost"33 description = "Adds a crazy amout of health to the ship."35 pickupName = "Crazy Madness Health Boost" 36 pickupDescription = "Adds a crazy amout of health to the ship." 34 37 spawnerTemplate = "crazyhealthpickupRepresentation" 38 inventoryRepresentation = "CrazyMadnessHealth" 35 39 > 36 40 <pickup> … … 40 44 41 45 <PickupRepresentation 42 name = "Double Pickup"43 description = "Does stuff."46 pickupName = "Double Pickup" 47 pickupDescription = "Does stuff." 44 48 spawnerTemplate = "crazyhealthpickupRepresentation" 45 49 > … … 48 52 </pickup> 49 53 </PickupRepresentation> 54 55 <PickupRepresentation 56 pickupName = "Use Pickup" 57 pickupDescription = "Uses all pickups you have." 58 spawnerTemplate = "usepickupRepresentation" 59 inventoryRepresentation = "usePickup" 60 > 61 <pickup> 62 <MetaPickup metaType="use" /> 63 </pickup> 64 </PickupRepresentation> 65 66 <PickupRepresentation 67 pickupName = "Drop Pickup" 68 pickupDescription = "Drops all pickups you have." 69 spawnerTemplate = "droppickupRepresentation" 70 inventoryRepresentation = "dropPickup" 71 > 72 <pickup> 73 <MetaPickup metaType="drop" /> 74 </pickup> 75 </PickupRepresentation> 76 77 <PickupRepresentation 78 pickupName = "Huge Health Boost" 79 pickupDescription = "Adds a huge amout of health to the ship." 80 spawnerTemplate = "hugehealthpickupRepresentation" 81 inventoryRepresentation = "HugeHealth" 82 > 83 <pickup> 84 <HealthPickup 85 health = 100 86 healthType = "limited" 87 activationType = "onUse" 88 durationType = "once" 89 /> 90 </pickup> 91 </PickupRepresentation> -
code/trunk/data/levels/pickup.oxw
r6524 r6711 37 37 <PickupSpawner position="-50,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10"> 38 38 <pickup> 39 <HealthPickup health=50 healthRate=5 durationType=continuous activationType= immediate healthType=permanent />39 <HealthPickup health=50 healthRate=5 durationType=continuous activationType=onUse healthType=permanent /> 40 40 </pickup> 41 41 </PickupSpawner> … … 71 71 </PickupSpawner> 72 72 73 < !--PickupSpawner position="100,100,100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">73 <PickupSpawner position="100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10"> 74 74 <pickup> 75 <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=limited /> 75 <HealthPickup 76 health = 100 77 healthType = "limited" 78 activationType = "onUse" 79 durationType = "once" 80 /> 76 81 </pickup> 77 </PickupSpawner -->82 </PickupSpawner> 78 83 79 84 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> -
code/trunk/data/levels/templates/pickup_representation_templates.oxt
r6524 r6711 107 107 </PickupCollection> 108 108 </Template> 109 110 <Template name=usepickupRepresentation> 111 <PickupRepresentation> 112 <spawner-representation> 113 <StaticEntity> 114 <attached> 115 <Billboard position="0,0,0" colour="0.60,0.97,0.23" material="Sphere2" scale=0.1> 116 <attached> 117 <Billboard position="0,0,0" colour="0.40,0.81,0.10" material="Arrow" scale=0.65 /> 118 </attached> 119 </Billboard> 120 </attached> 121 </StaticEntity> 122 </spawner-representation> 123 </PickupRepresentation> 124 </Template> 125 126 <Template name=droppickupRepresentation> 127 <PickupRepresentation> 128 <spawner-representation> 129 <StaticEntity> 130 <attached> 131 <Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1> 132 <attached> 133 <Billboard position="0,0,0" colour="0.95,0.20,0.10" material="Arrow" scale=0.65 /> 134 </attached> 135 </Billboard> 136 </attached> 137 </StaticEntity> 138 </spawner-representation> 139 </PickupRepresentation> 140 </Template> 109 141 -
code/trunk/data/overlays/hudtemplates3.oxo
r5980 r6711 101 101 visible = "false" 102 102 /> 103 104 <GUIOverlay 105 name = "PickupInventory" 106 guiname = "PickupInventory" 107 visible = "false" 108 /> 103 109 104 110 </OverlayGroup> -
code/trunk/src/modules/pickup/CMakeLists.txt
r6524 r6711 15 15 FIND_HEADER_FILES 16 16 TOLUA_FILES 17 PickupManager.h 18 PickupRepresentation.h 17 19 DEFINE_SYMBOL 18 20 "PICKUP_SHARED_BUILD" -
code/trunk/src/modules/pickup/PickupManager.cc
r6540 r6711 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/LuaState.h" 38 #include "core/GUIManager.h" 37 39 #include "core/ScopedSingletonManager.h" 38 40 #include "core/Identifier.h" 39 41 #include "interfaces/PickupCarrier.h" 42 #include "infos/PlayerInfo.h" 40 43 #include "worldentities/pawns/Pawn.h" 41 44 #include "PickupRepresentation.h" 42 45 46 #include "ToluaBindPickup.h" 47 43 48 namespace orxonox 44 49 { 45 50 // Register tolua_open function when loading the library 51 DeclareToluaInterface(Pickup); 52 46 53 ManageScopedSingleton(PickupManager, ScopeID::Root, false); 54 55 /*static*/ const std::string PickupManager::guiName_s = "PickupInventory"; 47 56 48 57 /** … … 110 119 } 111 120 121 PickupCarrier* PickupManager::getPawn(void) 122 { 123 Pawn* pawn = dynamic_cast<Pawn*>(GUIManager::getInstancePtr()->getPlayer(PickupManager::guiName_s)->getControllableEntity()); 124 if(pawn == NULL) 125 return NULL; 126 return dynamic_cast<PickupCarrier*>(pawn); 127 } 128 129 int PickupManager::getNumCarrierChildren(PickupCarrier* carrier) 130 { 131 if(carrier == NULL) 132 return 0; 133 return carrier->getNumCarrierChildren(); 134 } 135 136 PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier) 137 { 138 if(carrier == NULL) 139 return NULL; 140 return carrier->getCarrierChild(index); 141 } 142 143 const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier) 144 { 145 if(carrier == NULL) 146 return BLANKSTRING; 147 return carrier->getCarrierName(); 148 } 149 150 PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier) 151 { 152 Pickupable* pickup = carrier->getPickup(index); 153 if(pickup == NULL) 154 return NULL; 155 156 return this->getRepresentation(pickup->getPickupIdentifier()); 157 } 158 159 int PickupManager::getNumPickups(PickupCarrier* carrier) 160 { 161 if(carrier == NULL) 162 return 0; 163 return carrier->getNumPickups(); 164 } 165 166 void PickupManager::dropPickup(int index, PickupCarrier* carrier) 167 { 168 Pickupable* pickup = carrier->getPickup(index); 169 carrier->drop(pickup); 170 } 171 172 void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use) 173 { 174 Pickupable* pickup = carrier->getPickup(index); 175 pickup->setUsed(use); 176 } 177 112 178 } -
code/trunk/src/modules/pickup/PickupManager.h
r6540 r6711 44 44 #include "core/OrxonoxClass.h" 45 45 46 namespace orxonox 47 { 46 namespace orxonox // tolua_export 47 { // tolua_export 48 48 49 49 /** 50 50 @brief 51 51 Manages Pickupables. 52 In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the Pickup GUI.52 In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the PickupInventory. 53 53 //TODO: Manage Pickup GUI. 54 54 @author 55 55 Damian 'Mozork' Frick 56 56 */ 57 class _PickupExport PickupManager : public Singleton<PickupManager>, public OrxonoxClass 58 { 57 class _PickupExport PickupManager // tolua_export 58 : public Singleton<PickupManager>, public OrxonoxClass 59 { // tolua_export 59 60 friend class Singleton<PickupManager>; 60 61 … … 63 64 virtual ~PickupManager(); 64 65 65 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } 66 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export 66 67 67 68 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 68 69 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 69 70 71 // tolua_begin 72 orxonox::PickupCarrier* getPawn(void); 73 74 int getNumCarrierChildren(orxonox::PickupCarrier* carrier); 75 orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier); 76 77 const std::string& getCarrierName(orxonox::PickupCarrier* carrier); 78 79 int getNumPickups(orxonox::PickupCarrier* carrier); 80 PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier); 81 void dropPickup(int index, orxonox::PickupCarrier* carrier); 82 void usePickup(int index, orxonox::PickupCarrier* carrier, bool use); 83 // tolua_end 84 70 85 private: 71 86 static PickupManager* singletonPtr_s; 87 static const std::string guiName_s; 72 88 73 89 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 74 90 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 75 91 76 }; 92 }; // tolua_export 77 93 78 } 94 } // tolua_export 79 95 80 96 #endif // _PickupManager_H__ -
code/trunk/src/modules/pickup/PickupPrereqs.h
r6710 r6711 65 65 namespace orxonox 66 66 { 67 67 68 68 class DroppedPickup; 69 69 class Pickup; -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r6676 r6711 86 86 this->name_ = "Pickup"; 87 87 this->spawnerTemplate_ = ""; 88 this->inventoryRepresentation_ = "Default"; 88 89 this->pickup_ = NULL; 89 90 } … … 97 98 SUPER(PickupRepresentation, XMLPort, xmlelement, mode); 98 99 99 XMLPortParam(PickupRepresentation, " name", setName, getName, xmlelement, mode);100 XMLPortParam(PickupRepresentation, " description", setDescription, getDescription, xmlelement, mode);100 XMLPortParam(PickupRepresentation, "pickupName", setPickupName, getPickupName, xmlelement, mode); 101 XMLPortParam(PickupRepresentation, "pickupDescription", setPickupDescription, getPickupDescription, xmlelement, mode); 101 102 XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode); 103 XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode); 102 104 XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode); 103 105 XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode); -
code/trunk/src/modules/pickup/PickupRepresentation.h
r6540 r6711 45 45 #include "core/BaseObject.h" 46 46 47 namespace orxonox 48 { 47 namespace orxonox // tolua_export 48 { // tolua_export 49 49 50 50 /** … … 53 53 They are created through XML and are registered with the PickupManager. 54 54 */ 55 class _PickupExport PickupRepresentation : public BaseObject 56 { 55 class _PickupExport PickupRepresentation // tolua_export 56 : public BaseObject 57 { // tolua_export 57 58 58 59 public: … … 67 68 @param name The name. 68 69 */ 69 inline void set Name(const std::string& name)70 inline void setPickupName(const std::string& name) 70 71 { this->name_ = name; } 71 72 /** … … 73 74 @param description The Description. 74 75 */ 75 inline void set Description(const std::string& description)76 inline void setPickupDescription(const std::string& description) 76 77 { this->description_ = description; } 77 78 /** … … 90 91 { this->spawnerRepresentation_ = representation; } 91 92 /** 93 @brief Set the image representing the pickup in the PickupInventory. 94 @param image A string with the name of the image representing the pickup. 95 */ 96 inline void setInventoryRepresentation(const std::string& image) 97 { this->inventoryRepresentation_ = image; } 98 /** 92 99 @brief Set the Pickupable that is represented by this PickupRepresentation. 93 100 @param pickup A pointer to the Pickupable. … … 100 107 @return Returns the name. 101 108 */ 102 inline const std::string& getName(void) 103 { return this->name_; } 109 inline const std::string& getPickupName(void) { return this->name_; } // tolua_export 104 110 /** 105 111 @brief Get the description of the Pickupable represented by this PickupRepresentation. 106 112 @return Returns the description. 107 113 */ 108 inline const std::string& getDescription(void) 109 { return this->description_; } 114 inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export 110 115 /** 111 116 @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation. … … 121 126 inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) 122 127 { if(index == 0) return this->spawnerRepresentation_; return NULL; } 128 /** 129 @brief Get the name of the image representing the pickup in the PickupInventory. 130 @return Returns the name of the image as a string. 131 */ 132 inline const std::string& getInventoryRepresentation(void) { return this->inventoryRepresentation_; } // tolua_export 123 133 /** 124 134 @brief Get the Pickupable represented by this PickupRepresentation. … … 139 149 std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. 140 150 StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. 151 std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image? 141 152 142 153 Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. 143 154 144 }; 155 }; // tolua_export 145 156 146 } 157 } // tolua_export 147 158 148 159 #endif // _PickupRepresentation_H__ -
code/trunk/src/modules/pickup/PickupSpawner.cc
r6563 r6711 180 180 { 181 181 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 182 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 182 183 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance. 183 if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))184 if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_)) 184 185 { 185 186 this->trigger(*it); -
code/trunk/src/orxonox/CMakeLists.txt
r6524 r6711 58 58 MoodManager.h 59 59 controllers/HumanController.h 60 interfaces/PickupCarrier.h 60 61 sound/SoundManager.h 61 62 DEFINE_SYMBOL -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r6534 r6711 60 60 RegisterRootObject(PickupCarrier); 61 61 62 this->setCarrierName("PickupCarrier"); 62 63 } 63 64 -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r6710 r6711 45 45 #include "core/OrxonoxClass.h" 46 46 47 namespace orxonox 48 { 47 namespace orxonox // tolua_export 48 { // tolua_export 49 49 50 50 //! Forward-declarations. 51 class PickupManager; 51 52 class Pickup; 52 53 class HealthPickup; … … 61 62 Damian 'Mozork' Frick 62 63 */ 63 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass 64 { 64 class _OrxonoxExport PickupCarrier // tolua_export 65 : virtual public OrxonoxClass 66 { // tolua_export 65 67 //! So that the different Pickupables have full access to their PickupCarrier. 68 friend class Pickupable; 69 friend class PickupManager; 66 70 //! Friends. 67 friend class Pickupable;68 71 friend class Pickup; 69 72 friend class HealthPickup; … … 120 123 121 124 //! Go recursively through all children to check whether they are a target. 122 std:: list<PickupCarrier*>* children = this->getCarrierChildren();123 for(std:: list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)125 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 126 for(std::vector<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++) 124 127 { 125 128 if((*it)->isTarget(pickup)) … … 147 150 148 151 //! Go recursively through all children to check whether they are the target. 149 std:: list<PickupCarrier*>* children = this->getCarrierChildren();150 for(std:: list<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)152 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 153 for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++) 151 154 { 152 155 if(pickup->isTarget(*it)) … … 166 169 */ 167 170 virtual const Vector3& getCarrierPosition(void) = 0; 168 169 protected: 171 172 /** 173 @brief Get the name of this PickupCarrier. 174 @return Returns the name as a string. 175 */ 176 const std::string& getCarrierName(void) { return this->carrierName_; } // tolua_export 177 178 protected: 170 179 /** 171 180 @brief Get all direct children of this PickupSpawner. … … 174 183 @return Returns a pointer to a list of all direct children. 175 184 */ 176 virtual std:: list<PickupCarrier*>* getCarrierChildren(void) = 0;185 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) = 0; 177 186 /** 178 187 @brief Get the parent of this PickupSpawner … … 188 197 std::set<Pickupable*>& getPickups(void) 189 198 { return this->pickups_; } 190 199 200 /** 201 @brief Set the name of this PickupCarrier. 202 The name needs to be set in the constructor of every class inheriting from PickupCarrier, by calling setCarrierName(). 203 @param name The name to be set. 204 */ 205 void setCarrierName(const std::string& name) 206 { this->carrierName_ = name; } 207 191 208 private: 192 209 std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier. 193 194 }; 195 } 210 std::string carrierName_; //!< The name of the PickupCarrier, as displayed in the PickupInventory. 211 212 /** 213 @brief Get the number of carrier children this PickupCarrier has. 214 @return Returns the number of carrier children. 215 */ 216 unsigned int getNumCarrierChildren(void) 217 { 218 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 219 unsigned int size = list->size(); 220 delete list; 221 return size; 222 } 223 224 /** 225 @brief Get the index-th child of this PickupCarrier. 226 @param index The index of the child to return. 227 @return Returns the index-th child. 228 */ 229 PickupCarrier* getCarrierChild(unsigned int index) 230 { 231 std::vector<PickupCarrier*>* list = this->getCarrierChildren(); 232 if(list->size() < index) 233 return NULL; 234 PickupCarrier* carrier = (*list)[index]; 235 delete list; 236 return carrier; 237 } 238 239 /** 240 @brief Get the number of Pickupables this PickupCarrier carries. 241 @return returns the number of pickups. 242 */ 243 unsigned int getNumPickups(void) 244 { return this->pickups_.size(); } 245 246 /** 247 @brief Get the index-th Pickupable of this PickupCarrier. 248 @param index The index of the Pickupable to return. 249 @return Returns the index-th pickup. 250 */ 251 Pickupable* getPickup(unsigned int index) 252 { 253 std::set<Pickupable*>::iterator it; 254 for(it = this->pickups_.begin(); index != 0 && it != this->pickups_.end(); it++) 255 index--; 256 if(it == this->pickups_.end()) 257 return NULL; 258 return *it; 259 } 260 261 }; // tolua_export 262 } // tolua_export 196 263 197 264 #endif /* _PickupCarrier_H__ */ -
code/trunk/src/orxonox/items/Engine.cc
r6709 r6711 64 64 this->boostBlur_ = 0; 65 65 66 this->setCarrierName("Engine"); 66 67 this->speedAdd_ = 0.0; 67 68 this->speedMultiply_ = 1.0; -
code/trunk/src/orxonox/items/Engine.h
r6709 r6711 122 122 123 123 protected: 124 virtual std:: list<PickupCarrier*>* getCarrierChildren(void)125 { return new std:: list<PickupCarrier*>(); }124 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) 125 { return new std::vector<PickupCarrier*>(); } 126 126 virtual PickupCarrier* getCarrierParent(void); 127 127 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r6502 r6711 327 327 { 328 328 OrxonoxOverlay* overlay= it->second; 329 COUT(1) << "MUP" << std::endl; 329 330 if(overlay->isVisible()) 331 { 330 332 overlay->hide(); 333 COUT(1) << "HIDE " << name << std::endl; 334 } 331 335 else 336 { 332 337 overlay->show(); 338 COUT(1) << "SHOW " << name << std::endl; 339 } 333 340 } 334 341 } -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r6540 r6711 78 78 else 79 79 this->weaponSystem_ = 0; 80 81 this->setCarrierName("Pawn"); 80 82 81 83 this->setRadarObjectColour(ColourValue::Red); -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r6540 r6711 37 37 #include "worldentities/ControllableEntity.h" 38 38 39 namespace orxonox 40 { 41 class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable, public PickupCarrier 42 { 39 namespace orxonox // tolua_export 40 { // tolua_export 41 class _OrxonoxExport Pawn // tolua_export 42 : public ControllableEntity, public RadarViewable, public PickupCarrier 43 { // tolua_export 43 44 friend class WeaponSystem; 44 45 … … 132 133 bool bAlive_; 133 134 134 virtual std:: list<PickupCarrier*>* getCarrierChildren(void)135 { return new std:: list<PickupCarrier*>(); }135 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) 136 { return new std::vector<PickupCarrier*>(); } 136 137 virtual PickupCarrier* getCarrierParent(void) 137 138 { return NULL; } … … 155 156 156 157 Vector3 aimPosition_; 157 }; 158 } 158 }; // tolua_export 159 } // tolua_export 159 160 160 161 #endif /* _Pawn_H__ */ -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r6709 r6711 221 221 } 222 222 223 std:: list<PickupCarrier*>* SpaceShip::getCarrierChildren(void)224 { 225 std:: list<PickupCarrier*>* list = new std::list<PickupCarrier*>();226 list->push_ front(this->engine_);223 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) 224 { 225 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>(); 226 list->push_back(this->engine_); 227 227 return list; 228 228 } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
r6709 r6711 86 86 87 87 protected: 88 virtual std:: list<PickupCarrier*>* getCarrierChildren(void);88 virtual std::vector<PickupCarrier*>* getCarrierChildren(void); 89 89 bool bInvertYAxis_; 90 90
Note: See TracChangeset
for help on using the changeset viewer.