[Orxonox-commit 2948] r7648 - in code/trunk: . data/gui/layouts data/gui/scripts data/levels src/libraries/core src/orxonox
dafrick at orxonox.net
dafrick at orxonox.net
Sat Nov 13 23:55:24 CET 2010
Author: dafrick
Date: 2010-11-13 23:55:23 +0100 (Sat, 13 Nov 2010)
New Revision: 7648
Added:
code/trunk/src/orxonox/LevelInfo.cc
code/trunk/src/orxonox/LevelInfo.h
Modified:
code/trunk/
code/trunk/data/gui/layouts/MultiplayerMenu.layout
code/trunk/data/gui/layouts/SingleplayerMenu.layout
code/trunk/data/gui/scripts/MultiplayerMenu.lua
code/trunk/data/gui/scripts/SingleplayerMenu.lua
code/trunk/data/levels/Fight in our Back.oxw
code/trunk/data/levels/Quest_PirateAttack.oxw
code/trunk/data/levels/The Time Machine.oxw
code/trunk/data/levels/empty_level.oxw
code/trunk/data/levels/events.oxw
code/trunk/data/levels/fps_test.oxw
code/trunk/data/levels/notifications.oxw
code/trunk/data/levels/pickups.oxw
code/trunk/data/levels/presentation.oxw
code/trunk/data/levels/presentation09.oxw
code/trunk/data/levels/presentation09b.oxw
code/trunk/data/levels/presentationFS10.oxw
code/trunk/data/levels/presentationHS09.oxw
code/trunk/data/levels/presentationHS09b.oxw
code/trunk/data/levels/presentation_FS10.oxw
code/trunk/data/levels/presentation_FS10_ed.oxw
code/trunk/data/levels/presentation_dm.oxw
code/trunk/data/levels/princessaeryn.oxw
code/trunk/data/levels/screenshot.oxw
code/trunk/data/levels/sound.oxw
code/trunk/data/levels/teambasematchlevel.oxw
code/trunk/data/levels/teamdeathmatch.oxw
code/trunk/data/levels/test_stars.oxw
code/trunk/data/levels/test_swallow.oxw
code/trunk/data/levels/tutorial.oxw
code/trunk/data/levels/waypoints.oxw
code/trunk/src/libraries/core/GUIManager.cc
code/trunk/src/libraries/core/GUIManager.h
code/trunk/src/libraries/core/Loader.cc
code/trunk/src/libraries/core/Loader.h
code/trunk/src/orxonox/CMakeLists.txt
code/trunk/src/orxonox/Level.cc
code/trunk/src/orxonox/LevelManager.cc
code/trunk/src/orxonox/LevelManager.h
code/trunk/src/orxonox/OrxonoxPrereqs.h
Log:
Merged releasetodo, containing a new way to describe and tag levels, back to trunk.
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Modified: code/trunk/data/gui/layouts/MultiplayerMenu.layout
===================================================================
--- code/trunk/data/gui/layouts/MultiplayerMenu.layout 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/gui/layouts/MultiplayerMenu.layout 2010-11-13 22:55:23 UTC (rev 7648)
@@ -14,7 +14,7 @@
<Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertFormatting" Value="TopAligned" />
- <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.7,0}}" />
<Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerListbox" >
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" />
@@ -22,32 +22,39 @@
<Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerJoinButton" >
<Property Name="Text" Value="Join" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.85,0},{0.3,0},{0.95,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.81,0},{0.3,0},{0.89,0}}" />
<Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerJoinButton_clicked"/>
</Window>
<Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerHostButton" >
<Property Name="Text" Value="Host" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.85,0},{0.6,0},{0.95,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.81,0},{0.6,0},{0.89,0}}" />
<Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerHostButton_clicked"/>
</Window>
<Window Type="MenuWidgets/RadioButton" Name="orxonox/MultiplayerDedicatedButton" >
<Property Name="Text" Value="Dedicated" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.85,0},{0.9,0},{0.95,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.81,0},{0.9,0},{0.89,0}}" />
<Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerDedicatedButton_clicked"/>
</Window>
+ <Window Type="MenuWidgets/Checkbox" Name="orxonox/MultiplayerShowAllCheckbox" >
+ <Property Name="Text" Value="show all" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.89,0},{0.8,0},{0.99,0}}" />
+ <Property Name="Disabled" Value="True" />
+ <Event Name="CheckStateChanged" Function="MultiplayerMenu.MultiplayerShowAll_clicked"/>
+ </Window>
</Window>
<Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerStartButton" >
<Property Name="Text" Value="Start" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.725,0},{0.4875,0},{0.775,0}}" />
<Event Name="Clicked" Function="MultiplayerMenu.MultiplayerStartButton_clicked"/>
</Window>
<Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.725,0},{0.7125,0},{0.775,0}}" />
<Event Name="Clicked" Function="MultiplayerMenu.MultiplayerBackButton_clicked"/>
</Window>
</Window>
Modified: code/trunk/data/gui/layouts/SingleplayerMenu.layout
===================================================================
--- code/trunk/data/gui/layouts/SingleplayerMenu.layout 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/gui/layouts/SingleplayerMenu.layout 2010-11-13 22:55:23 UTC (rev 7648)
@@ -14,22 +14,28 @@
<Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertFormatting" Value="TopAligned" />
- <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.7,0}}" />
<Window Type="MenuWidgets/Listbox" Name="orxonox/SingleplayerLevelListbox" >
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}" />
</Window>
+ <Window Type="MenuWidgets/Checkbox" Name="orxonox/SingleplayerShowAllCheckbox" >
+ <Property Name="Text" Value="show all" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.87,0},{0.8,0},{.97,0}}" />
+ <Event Name="CheckStateChanged" Function="SingleplayerMenu.SingleplayerShowAll_clicked"/>
+ </Window>
</Window>
<Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerStartButton" >
<Property Name="Text" Value="Start" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.725,0},{0.4875,0},{0.775,0}}" />
<Event Name="Clicked" Function="SingleplayerMenu.SingleplayerStartButton_clicked"/>
</Window>
<Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.725,0},{0.7125,0},{0.775,0}}" />
<Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
</Window>
</Window>
Modified: code/trunk/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MultiplayerMenu.lua 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/gui/scripts/MultiplayerMenu.lua 2010-11-13 22:55:23 UTC (rev 7648)
@@ -2,6 +2,10 @@
local P = createMenuSheet("MultiplayerMenu")
+P.levelList = {}
+P.itemList = {}
+P.showAll = false
+
function P.onLoad()
P.multiplayerMode = "startClient"
end
@@ -11,37 +15,58 @@
local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
local button = tolua.cast(window,"CEGUI::RadioButton")
button:setSelected(true)
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "True")
P.showServerList()
end
if P.multiplayerMode == "startServer" then
local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
local button = tolua.cast(window,"CEGUI::RadioButton")
button:setSelected(true)
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "False")
P.showLevelList()
end
if P.multiplayerMode == "startDedicated" then
local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
local button = tolua.cast(window,"CEGUI::RadioButton")
button:setSelected(true)
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "True")
P.showLevelList()
end
end
function P.MultiplayerJoinButton_clicked(e)
P.multiplayerMode = "startClient"
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "True")
P.showServerList()
end
function P.MultiplayerHostButton_clicked(e)
P.multiplayerMode = "startServer"
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "False")
P.showLevelList()
end
function P.MultiplayerDedicatedButton_clicked(e)
P.multiplayerMode = "startDedicated"
+ local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
+ checkbox:setProperty("Disabled", "True")
P.showLevelList()
end
+function P.MultiplayerShowAll_clicked(e)
+ local checkbox = tolua.cast(winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox"), "CEGUI::Checkbox")
+ local show = checkbox:isSelected()
+ if show ~= P.showAll then
+ P.showAll = show
+ P.createLevelList()
+ end
+end
+
function P.MultiplayerStartButton_clicked(e)
local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()
if P.multiplayerMode == "startClient" then
@@ -68,35 +93,42 @@
end
function P.showLevelList()
- local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
- CEGUI.toListbox(listbox):resetList()
+ P.createLevelList()
+end
+
+function P.createLevelList()
+ P.levelList = {}
+ P.itemList = {}
+ local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox"))
+ listbox:resetList()
+ orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
- orxonox.LevelManager:getInstance():compileAvailableLevelList()
- local levelList = {}
+ local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
local index = 0
- local level = ""
- while true do
+ local level = nil
+ while index < size do
level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
- if level == "" then
- break
+ if level ~= nil then
+ if P.showAll or not level:hasTag("test") then
+ table.insert(P.levelList, level)
+ end
end
- table.insert(levelList, level)
index = index + 1
end
- table.sort(levelList)
- index = 1
- for k,v in pairs(levelList) do
- local item = CEGUI.createListboxTextItem(v)
+ --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
+ --table.sort(levelList)
+ for k,v in pairs(P.levelList) do
+ local item = CEGUI.createListboxTextItem(v:getName())
item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
- item:setID(index)
- index = index + 1
- CEGUI.toListbox(listbox):addItem(item)
- if v .. ".oxw" == preselect then
+ listbox:addItem(item)
+ if v:getXMLFilename() == preselect then
listbox:setItemSelectState(item, true)
end
+ P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
+ orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
end
- end
-
+end
+
function P.showServerList()
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
Modified: code/trunk/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/SingleplayerMenu.lua 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/gui/scripts/SingleplayerMenu.lua 2010-11-13 22:55:23 UTC (rev 7648)
@@ -2,42 +2,73 @@
local P = createMenuSheet("SingleplayerMenu")
+P.levelList = {}
+P.itemList = {}
+P.showAll = false
+
function P.onLoad()
- listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
- preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
- orxonox.LevelManager:getInstance():compileAvailableLevelList()
- local levelList = {}
+ local window = winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox")
+ local button = tolua.cast(window,"CEGUI::Checkbox")
+ button:setSelected(false)
+ P.createLevelList()
+end
+
+function P.createLevelList()
+ P.levelList = {}
+ P.itemList = {}
+ local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
+ listbox:resetList()
+ orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
+ local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+ local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
local index = 0
- local level = ""
- while true do
- level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
- if level == "" then
- break
- end
- table.insert(levelList, level)
- index = index + 1
+ local level = nil
+ while index < size do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level ~= nil then
+ if P.showAll or not level:hasTag("test") then
+ table.insert(P.levelList, level)
+ end
+ end
+ index = index + 1
end
- table.sort(levelList)
- for k,v in pairs(levelList) do
- item = CEGUI.createListboxTextItem(v)
+ --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
+ --table.sort(levelList)
+ for k,v in pairs(P.levelList) do
+ local item = CEGUI.createListboxTextItem(v:getName())
item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
- CEGUI.toListbox(listbox):addItem(item)
- if v .. ".oxw" == preselect then
+ listbox:addItem(item)
+ if v:getXMLFilename() == preselect then
listbox:setItemSelectState(item, true)
end
+ P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
+ orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
end
-
end
function P.SingleplayerStartButton_clicked(e)
- local choice = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")):getFirstSelectedItem()
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- orxonox.execute("startGame")
- hideAllMenuSheets()
+ local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
+ local choice = listbox:getFirstSelectedItem()
+ if choice ~= nil then
+ local index = listbox:getItemIndex(choice)
+ local level = P.levelList[index+1]
+ if level ~= nil then
+ orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename())
+ orxonox.execute("startGame")
+ hideAllMenuSheets()
+ end
end
end
+function P.SingleplayerShowAll_clicked(e)
+ local checkbox = tolua.cast(winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox"), "CEGUI::Checkbox")
+ local show = checkbox:isSelected()
+ if show ~= P.showAll then
+ P.showAll = show
+ P.createLevelList()
+ end
+end
+
function P.SingleplayerBackButton_clicked(e)
hideMenuSheet(P.name)
end
Modified: code/trunk/data/levels/Fight in our Back.oxw
===================================================================
--- code/trunk/data/levels/Fight in our Back.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/Fight in our Back.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Fight in our Back"
+ description = "Our fleet is far ahead of us. We need to get rid of all the enemies in its back, because we do not want our enemies to attack from everywhere. So let us clear this Sector!"
+ tags = ""
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/Quest_PirateAttack.oxw
===================================================================
--- code/trunk/data/levels/Quest_PirateAttack.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/Quest_PirateAttack.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Pirate Attack"
+ description = "Dani's Testlevel"
+ tags = "test"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/The Time Machine.oxw
===================================================================
--- code/trunk/data/levels/The Time Machine.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/The Time Machine.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "The Time Machine"
+ description = "A simple level. The only goal is to defeat as much enemies as you can."
+ tags = ""
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/empty_level.oxw
===================================================================
--- code/trunk/data/levels/empty_level.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/empty_level.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Empty level"
+ description = "A level with absolutely nothing in it."
+ tags = "test"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/events.oxw
===================================================================
--- code/trunk/data/levels/events.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/events.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Events showcase"
+ description = "Level to test and showcase events."
+ tags = "test, showcase"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/fps_test.oxw
===================================================================
--- code/trunk/data/levels/fps_test.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/fps_test.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "FPS testlevel"
+ description = "Level to test First Person Shooter"
+ tags = "test"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/notifications.oxw
===================================================================
--- code/trunk/data/levels/notifications.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/notifications.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Notifications showcase"
+ description = "Level to test and showcase notifications."
+ tags = "test, showcase"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/pickups.oxw
===================================================================
--- code/trunk/data/levels/pickups.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/pickups.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Pickups showcase"
+ description = "Level to test and showcase pickups."
+ tags = "test, showcase"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/presentation.oxw
===================================================================
--- code/trunk/data/levels/presentation.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation"
+ description = "Presentation Level"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentation09.oxw
===================================================================
--- code/trunk/data/levels/presentation09.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation09.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation X"
+ description = "1st Presentation level for Orxonox Convention X"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentation09b.oxw
===================================================================
--- code/trunk/data/levels/presentation09b.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation09b.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation X2"
+ description = "2nd Presentation level for Orxonox Convention X"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentationFS10.oxw
===================================================================
--- code/trunk/data/levels/presentationFS10.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentationFS10.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation XI"
+ description = "1st Presentation level for Orxonox Convention XI"
+ tags = "presentation"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/presentationHS09.oxw
===================================================================
--- code/trunk/data/levels/presentationHS09.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentationHS09.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation X"
+ description = "1st Presentation level for Orxonox Convention X"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentationHS09b.oxw
===================================================================
--- code/trunk/data/levels/presentationHS09b.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentationHS09b.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation X"
+ description = "2nd Presentation level for Orxonox Convention X"
+ tags = "presentation"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/presentation_FS10.oxw
===================================================================
--- code/trunk/data/levels/presentation_FS10.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation_FS10.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation XI FPS"
+ description = "2nd Presentation level for Orxonox Convention XI, FPS"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentation_FS10_ed.oxw
===================================================================
--- code/trunk/data/levels/presentation_FS10_ed.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation_FS10_ed.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation XI FPS"
+ description = "3rd Presentation level for Orxonox Convention XI, FPS"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/presentation_dm.oxw
===================================================================
--- code/trunk/data/levels/presentation_dm.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/presentation_dm.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Presentation DM"
+ description = "Presentation Level"
+ tags = "presentation"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/princessaeryn.oxw
===================================================================
--- code/trunk/data/levels/princessaeryn.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/princessaeryn.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "The Tale of Princess Aeryn"
+ description = "The Tale of the elusive but beautiful Princess Aeryn"
+ tags = ""
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/screenshot.oxw
===================================================================
--- code/trunk/data/levels/screenshot.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/screenshot.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Screenshot"
+ description = "Level to make awesome screenshots in."
+ tags = "test"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/sound.oxw
===================================================================
--- code/trunk/data/levels/sound.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/sound.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Sound showcase"
+ description = "Level to test and showcase sound."
+ tags = "test"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/teambasematchlevel.oxw
===================================================================
--- code/trunk/data/levels/teambasematchlevel.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/teambasematchlevel.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Teambase Match"
+ description = "Fight for the bases."
+ tags = ""
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/teamdeathmatch.oxw
===================================================================
--- code/trunk/data/levels/teamdeathmatch.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/teamdeathmatch.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Team Deathmatch"
+ description = "Fight against each other in teams."
+ tags = ""
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/test_stars.oxw
===================================================================
--- code/trunk/data/levels/test_stars.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/test_stars.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Stars Testlevel"
+ description = "Level to test stars"
+ tags = "test"
+/>
+
<?lua
include("stats.oxo")
include("hudtemplates3.oxo")
Modified: code/trunk/data/levels/test_swallow.oxw
===================================================================
--- code/trunk/data/levels/test_swallow.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/test_swallow.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Swallow Testlevel"
+ description = "Level to test the swallow spaceship."
+ tags = "test"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/tutorial.oxw
===================================================================
--- code/trunk/data/levels/tutorial.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/tutorial.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Coding Tutorial"
+ description = "Level for the coding tutorial."
+ tags = "tutorial"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/data/levels/waypoints.oxw
===================================================================
--- code/trunk/data/levels/waypoints.oxw 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/data/levels/waypoints.oxw 2010-11-13 22:55:23 UTC (rev 7648)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Waypoints Testlevel"
+ description = "Testing waypoings for AI controlled spaceships."
+ tags = "test"
+/>
+
<?lua
include("hudtemplates3.oxo")
include("stats.oxo")
Modified: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/libraries/core/GUIManager.cc 2010-11-13 22:55:23 UTC (rev 7648)
@@ -42,6 +42,8 @@
#include <CEGUISystem.h>
#include <CEGUIWindow.h>
#include <CEGUIWindowManager.h>
+#include <elements/CEGUIListbox.h>
+#include <elements/CEGUIListboxItem.h>
#include <ogreceguirenderer/OgreCEGUIRenderer.h>
#include "SpecialConfig.h" // Configures the macro below
@@ -435,8 +437,46 @@
}
}
+ /**
+ @brief
+ Subscribe the input function to the input event for the input window.
+ This is a helper to be used in lua, because subscribeScriptedEvent() doesn't work in lua.
+ @param window
+ The window for which the event is subscribed.
+ @param event
+ The type of event to which we subscribe.
+ @param function
+ The function that is called when the event occurs.
+ */
void GUIManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function)
{
window->subscribeScriptedEvent(event, function);
}
+
+ /**
+ @brief
+ Set the input tooltip text for the input ListboxItem.
+ @param item
+ The ListboxItem for which the tooltip should be set.
+ @param tooltip
+ The tooltip text that should be set.
+ */
+ void GUIManager::setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& tooltip)
+ {
+ item->setTooltipText(tooltip);
+ }
+
+ /**
+ @brief
+ Set whether the tooltips for the input Listbox are enabled.
+ @param listbox
+ The Listbox for which to enable (or disable) tooltips.
+ @param enabled
+ Whether to enable or disabel the tooltips.
+ */
+ void GUIManager::setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled)
+ {
+ listbox->setItemTooltipsEnabled(enabled);
+ }
+
}
Modified: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/libraries/core/GUIManager.h 2010-11-13 22:55:23 UTC (rev 7648)
@@ -105,6 +105,8 @@
// TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
+ static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); //tolua_export
+ static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); //tolua_export
static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
Modified: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/libraries/core/Loader.cc 2010-11-13 22:55:23 UTC (rev 7648)
@@ -87,11 +87,21 @@
}
}
- bool Loader::load(const ClassTreeMask& mask)
+ /**
+ @brief
+ Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
+ @param mask
+ A ClassTreeMask, which defines which types of classes are loaded and which aren't.
+ @param verbose
+ Whether the loader is verbose (prints its progress in a low output level) or not.
+ @return
+ Returns true if successful.
+ */
+ bool Loader::load(const ClassTreeMask& mask, bool verbose)
{
bool success = true;
for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
- if (!Loader::load(it->first, it->second * mask))
+ if (!Loader::load(it->first, it->second * mask, verbose))
success = false;
return success;
@@ -108,13 +118,35 @@
}
}
- bool Loader::reload(const ClassTreeMask& mask)
+ /**
+ @brief
+ Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
+ @param mask
+ A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
+ @param verbose
+ Whether the loader is verbose (prints its progress in a low output level) or not.
+ @return
+ Returns true if successful.
+ */
+ bool Loader::reload(const ClassTreeMask& mask, bool verbose)
{
Loader::unload(mask);
- return Loader::load(mask);
+ return Loader::load(mask, verbose);
}
- bool Loader::load(const XMLFile* file, const ClassTreeMask& mask)
+ /**
+ @brief
+ Loads the input file, while conforming to the restrictions given by the input ClassTreeMask.
+ @param file
+ The file to be loaded.
+ @param mask
+ A ClassTreeMask, which defines which types of classes are loaded and which aren't.
+ @param verbose
+ Whether the loader is verbose (prints its progress in a low output level) or not.
+ @return
+ Returns true if successful.
+ */
+ bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
{
if (!file)
return false;
@@ -143,8 +175,16 @@
try
{
- COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
- COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
+ if(verbose)
+ {
+ COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
+ COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
+ }
+ else
+ {
+ COUT(4) << "Start loading " << file->getFilename() << "..." << std::endl;
+ COUT(4) << "Mask: " << Loader::currentMask_s << std::endl;
+ }
ticpp::Document xmlfile(file->getFilename());
xmlfile.Parse(xmlInput, true);
@@ -164,7 +204,10 @@
rootNamespace->setRoot(true);
rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
- COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
+ if(verbose)
+ COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
+ else
+ COUT(4) << "Finished loading " << file->getFilename() << '.' << std::endl;
COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl;
@@ -209,10 +252,22 @@
}
}
- bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask)
+ /**
+ @brief
+ Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.
+ @param file
+ The file to be reloaded.
+ @param mask
+ A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
+ @param verbose
+ Whether the loader is verbose (prints its progress in a low output level) or not.
+ @return
+ Returns true if successful.
+ */
+ bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
{
Loader::unload(file, mask);
- return Loader::load(file, mask);
+ return Loader::load(file, mask, verbose);
}
std::string Loader::replaceLuaTags(const std::string& text)
Modified: code/trunk/src/libraries/core/Loader.h
===================================================================
--- code/trunk/src/libraries/core/Loader.h 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/libraries/core/Loader.h 2010-11-13 22:55:23 UTC (rev 7648)
@@ -56,13 +56,13 @@
static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
static void remove(const XMLFile* file);
- static bool load(const ClassTreeMask& mask = ClassTreeMask());
+ static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
static void unload(const ClassTreeMask& mask = ClassTreeMask());
- static bool reload(const ClassTreeMask& mask = ClassTreeMask());
+ static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
- static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+ static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
- static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+ static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
static std::string replaceLuaTags(const std::string& text);
Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/orxonox/CMakeLists.txt 2010-11-13 22:55:23 UTC (rev 7648)
@@ -24,6 +24,7 @@
SET_SOURCE_FILES(ORXONOX_SRC_FILES
Level.cc
+ LevelInfo.cc
LevelManager.cc
Main.cc
MoodManager.cc
@@ -57,6 +58,7 @@
FIND_HEADER_FILES
TOLUA_FILES
ChatInputHandler.h
+ LevelInfo.h
LevelManager.h
MoodManager.h
controllers/HumanController.h
Modified: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/orxonox/Level.cc 2010-11-13 22:55:23 UTC (rev 7648)
@@ -75,7 +75,7 @@
XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
-}
+ }
void Level::registerVariables()
{
Copied: code/trunk/src/orxonox/LevelInfo.cc (from rev 7647, code/branches/releasetodo/src/orxonox/LevelInfo.cc)
===================================================================
--- code/trunk/src/orxonox/LevelInfo.cc (rev 0)
+++ code/trunk/src/orxonox/LevelInfo.cc 2010-11-13 22:55:23 UTC (rev 7648)
@@ -0,0 +1,210 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "LevelInfo.h"
+
+#include <sstream>
+#include <vector>
+
+#include "util/SubString.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "LevelManager.h"
+
+namespace orxonox
+{
+
+ // LevelInfoItem
+
+ //! The list of allowed tags.
+ /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>();
+
+ /**
+ @brief
+ Default constructor.
+ */
+ LevelInfoItem::LevelInfoItem()
+ {
+
+ }
+
+ /**
+ @brief
+ Constructor. Initializes the object.
+ @param name
+ The name of the Level.
+ @param filename
+ The XML-filename of the Level.
+ */
+ LevelInfoItem::LevelInfoItem(const std::string& name, const std::string filename)
+ {
+ this->setName(name);
+ this->setXMLFilename(filename);
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ LevelInfoItem::~LevelInfoItem()
+ {
+
+ }
+
+ /**
+ @brief
+ Initialize the set of allowed tags.
+ */
+ /*static*/ void LevelInfoItem::initializeTags(void)
+ {
+ if(!LevelInfoItem::initialized_s)
+ {
+ LevelInfoItem::possibleTags_s.insert("test");
+ LevelInfoItem::possibleTags_s.insert("singleplayer");
+ LevelInfoItem::possibleTags_s.insert("multiplayer");
+ LevelInfoItem::possibleTags_s.insert("showcase");
+ LevelInfoItem::possibleTags_s.insert("tutorial");
+ LevelInfoItem::possibleTags_s.insert("presentation");
+ }
+ }
+
+ /**
+ @brief
+ Set the tags the Level is tagged with.
+ @param tags
+ A comma-seperated string of all the tags to be set.
+ */
+ void LevelInfoItem::setTags(const std::string& tags)
+ {
+ SubString substr = SubString(tags, ",", " "); // Split the string into tags.
+ const std::vector<std::string>& strings = substr.getAllStrings();
+ for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
+ this->addTag(*it, false);
+
+ this->tagsUpdated();
+ }
+
+ /**
+ @brief
+ Add a tag to the set of tags the Level is tagged with.
+ @param tag
+ The tag to be added.
+ @param update
+ Whether the comma-seperated string of all tags should be updated. Default is true.
+ @return
+ Returns true if the tag was successfully added, if the tag was already present it returns false.
+ */
+ bool LevelInfoItem::addTag(const std::string& tag, bool update)
+ {
+ if(!this->validateTag(tag))
+ {
+ COUT(2) << "Bad LevelInfo tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << std::endl;
+ return false;
+ }
+ bool success = this->tags_.insert(*LevelInfoItem::possibleTags_s.find(tag)).second;
+ if(update && success)
+ this->tagsUpdated();
+ return success;
+ }
+
+ /**
+ @brief
+ Updates the comma-seperated string of all tags, if the set of tags has changed.
+ */
+ void LevelInfoItem::tagsUpdated(void)
+ {
+ std::stringstream stream;
+ std::set<std::string>::iterator temp;
+ for(std::set<std::string>::iterator it = this->tags_.begin(); it != this->tags_.end(); )
+ {
+ temp = it;
+ if(++it == this->tags_.end()) // If this is the last tag we don't add a comma.
+ stream << *temp;
+ else
+ stream << *temp << ", ";
+ }
+
+ this->tagsString_ = std::string(stream.str());
+ }
+
+ // LevelInfo
+
+ CreateFactory(LevelInfo);
+
+ /**
+ @brief
+
+ @param creator
+ The creator of this object.
+ */
+ LevelInfo::LevelInfo(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(LevelInfo);
+
+ this->xmlfilename_ = this->getFilename();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ LevelInfo::~LevelInfo()
+ {
+
+ }
+
+ /**
+ @brief
+ Creates a LevelInfo object through XML.
+ */
+ void LevelInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(LevelInfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
+ XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Copies the contents of this LevelInfo object to a new LevelInfoItem object.
+ This is needed, because a LeveInfo object is only created within the scope of the XML-file it is loaded with and is destroyed once that is unloaded.
+ @return
+ Returns a new LevelInfoItem with the same contents as the LevelInfo object.
+ */
+ LevelInfoItem* LevelInfo::copy(void)
+ {
+ LevelInfoItem* info = new LevelInfoItem(this->BaseObject::getName(), this->getXMLFilename());
+ info->setDescription(this->getDescription());
+ info->setTags(this->getTags());
+ return info;
+ }
+
+}
+
Copied: code/trunk/src/orxonox/LevelInfo.h (from rev 7647, code/branches/releasetodo/src/orxonox/LevelInfo.h)
===================================================================
--- code/trunk/src/orxonox/LevelInfo.h (rev 0)
+++ code/trunk/src/orxonox/LevelInfo.h 2010-11-13 22:55:23 UTC (rev 7648)
@@ -0,0 +1,201 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file LevelInfo.h
+ @brief Definition of the LevelInfo and LevelInfoItem class.
+ @ingroup Orxonox
+*/
+
+#ifndef _LevelInfo_H__
+#define _LevelInfo_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <set>
+#include <string>
+
+#include "core/BaseObject.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+ /**
+ @brief
+ The LevelInfoItem class stores information regarding a @ref orxonox::Level "Level" and makes that information it accessible trough the @ref orxonox::LevelManager "LevelManager".
+ A LevelInfoItem object is commonly created from a @ref orxonox::LevelInfo "LevelInfo" object, using its <code>copy()</code> method.
+
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport LevelInfoItem // tolua_export
+ : virtual public OrxonoxClass
+ { // tolua_export
+ public:
+ LevelInfoItem(); //!< Default constructor.
+ LevelInfoItem(const std::string& name, const std::string filename); //!< Constructor. Initializes the object.
+ virtual ~LevelInfoItem(); //!< Destructor.
+
+ /**
+ @brief Set the name of the Level.
+ @param name The name to be set.
+ */
+ inline void setName(const std::string& name)
+ { this->name_ = std::string(name); }
+ /**
+ @brief Get the name of the Level.
+ @return Returns the name of the Level.
+ */
+ inline const std::string& getName(void) { return this->name_; } // tolua_export
+
+ /**
+ @brief Set the description of the Level.
+ @param description The description to be set.
+ */
+ inline void setDescription(const std::string& description)
+ { this->description_ = std::string(description); }
+ /**
+ @brief Get the description of the Level.
+ @return Returns the description of the Level.
+ */
+ inline const std::string& getDescription() const { return this->description_; } // tolua_export
+
+ void setTags(const std::string& tags); //!< Set the tags the Level is tagged with.
+ bool addTag(const std::string& tag, bool update = true); //!< Add a tag to the set of tags the Level is tagged with.
+ /**
+ @brief Get the lis of the tags the Level is tagged with.
+ @return Returns a comma-seperated string of all the tags the Level is tagged with.
+ */
+ inline const std::string& getTags(void) const
+ { return this->tagsString_; }
+ /**
+ @brief Get whether the Level has a specific tag.
+ @param tag The tag for which is checked.
+ @return Returns true if the Level is tagged with the input tag.
+ */
+ inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
+
+ /**
+ @brief Get the XML-filename of the Level.
+ @return Returns the XML-filename (including *.oxw extension) of the Level.
+ */
+ inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export
+
+ protected:
+ /**
+ @brief Set the XML-filename of the Level.
+ @param filename The XML-filename to be set.
+ */
+ inline void setXMLFilename(const std::string& filename)
+ { this->xmlfilename_ = std::string(filename); }
+
+ std::string xmlfilename_; //!< The XML-filename of the Level.
+
+ private:
+ void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
+
+ static void initializeTags(void); //!< Initialize the set of allowed tags.
+ /**
+ @brief Check whether an input tag is allowed.
+ @param tag The tag to check.
+ @return Returns true if the input tag is allowed, false if not.
+ */
+ static bool validateTag(const std::string& tag)
+ { LevelInfoItem::initializeTags(); return LevelInfoItem::possibleTags_s.find(tag) != LevelInfoItem::possibleTags_s.end(); }
+
+ static std::set<std::string> possibleTags_s; //!< The set of allowed tags.
+ static const bool initialized_s = false; //!< Whether the set of allowed tags has been inizialized.
+
+ std::string name_; //!< The name of the Level.
+ std::string description_; //!< The description of the Level.
+ std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
+ std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
+ }; // tolua_export
+
+ /**
+ @brief
+ The LevelInfo class can be used to store information regarding a @ref orxonox::Level "Level" in its level file.
+ The following parameters can be specified:
+ - @b name The name of the level.
+ - @b description The description of the level.
+ - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>.
+
+ An example would be:
+ @code
+ <LevelInfo
+ name = "Levelname"
+ description = "This is just some awesome level."
+ tags = "test, awesome"
+ />
+ @endcode
+ The LevelInfo is best located at the top of the level file.
+
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport LevelInfo : public BaseObject, public LevelInfoItem
+ {
+ public:
+ LevelInfo(BaseObject* creator);
+ virtual ~LevelInfo();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
+
+ /**
+ @brief Set the description of the Level.
+ @param description The description to be set.
+ */
+ inline void setDescription(const std::string& description)
+ { this->LevelInfoItem::setDescription(description); }
+ /**
+ @brief Get the description of the Level.
+ @return Returns the description of the Level.
+ */
+ inline const std::string& getDescription() const
+ { return this->LevelInfoItem::getDescription(); }
+
+ /**
+ @brief Set the tags the Level is tagged with.
+ @param tags A comma-seperated string of all the tags to be set.
+ */
+ inline void setTags(const std::string& tags)
+ { this->LevelInfoItem::setTags(tags); }
+ /**
+ @brief Get the lis of the tags the Level is tagged with.
+ @return Returns a comma-seperated string of all the tags the Level is tagged with.
+ */
+ inline const std::string& getTags(void) const
+ { return this->LevelInfoItem::getTags(); }
+
+ LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
+
+ };
+} // tolua_export
+
+#endif /* _LevelInfo_H__ */
Modified: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/orxonox/LevelManager.cc 2010-11-13 22:55:23 UTC (rev 7648)
@@ -31,13 +31,16 @@
#include <map>
#include "util/ScopedSingletonManager.h"
+#include "core/ClassTreeMask.h"
#include "core/CommandLineParser.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/Loader.h"
#include "core/Resource.h"
+#include "core/XMLFile.h"
#include "PlayerManager.h"
#include "Level.h"
+#include "LevelInfo.h"
namespace orxonox
{
@@ -55,6 +58,8 @@
{
ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString());
}
+
+ this->compileAvailableLevelList();
}
LevelManager::~LevelManager()
@@ -124,25 +129,64 @@
return defaultLevelName_;
}
- const std::string& LevelManager::getAvailableLevelListItem(unsigned int index) const
+ unsigned int LevelManager::getNumberOfLevels()
{
- if (index >= availableLevels_.size())
- return BLANKSTRING;
+ this->updateAvailableLevelList();
+
+ return this->availableLevels_.size();
+ }
+
+ LevelInfoItem* LevelManager::getAvailableLevelListItem(unsigned int index) const
+ {
+ if (index >= this->availableLevels_.size())
+ return NULL;
else
- return availableLevels_[index];
+ {
+ std::map<std::string, LevelInfoItem*>::const_iterator it = this->infos_.find(this->availableLevels_[index]);
+ return it->second;
+ }
}
void LevelManager::compileAvailableLevelList()
{
- this->availableLevels_.clear();
Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
+ // Iterate over all *.oxw level files.
for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
{
+ //TODO: Replace with tag,
if (it->find("old/") != 0)
{
size_t pos = it->find(".oxw");
+
+ bool infoExists = false;
+ // Load the LevelInfo object from the level file.
+ XMLFile file = XMLFile(*it);
+ ClassTreeMask mask = ClassTreeMask();
+ mask.exclude(ClassIdentifier<BaseObject>::getIdentifier());
+ mask.include(ClassIdentifier<LevelInfo>::getIdentifier());
+ Loader::load(&file, mask, false);
+ for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
+ {
+ LevelInfoItem* info = item->copy();
+ if(info->getXMLFilename() == *it)
+ {
+ this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos),info));
+ infoExists = true;
+ }
+ }
+ Loader::unload(&file, mask);
+ if(!infoExists)
+ {
+ this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos), new LevelInfoItem(it->substr(0, pos), *it)));
+ }
+
this->availableLevels_.push_back(it->substr(0, pos));
}
}
}
+
+ void LevelManager::updateAvailableLevelList(void)
+ {
+ //TODO: Implement some kind of update?
+ }
}
Modified: code/trunk/src/orxonox/LevelManager.h
===================================================================
--- code/trunk/src/orxonox/LevelManager.h 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/orxonox/LevelManager.h 2010-11-13 22:55:23 UTC (rev 7648)
@@ -33,6 +33,7 @@
#include <cassert>
#include <list>
+#include <map>
#include <string>
#include "util/Singleton.h"
@@ -58,8 +59,8 @@
void setDefaultLevel(const std::string& levelName); //tolua_export
const std::string& getDefaultLevel() const; //tolua_export
- void compileAvailableLevelList(); //tolua_export
- const std::string& getAvailableLevelListItem(unsigned int index) const; //tolua_export
+ unsigned int getNumberOfLevels(void); //tolua_export
+ LevelInfoItem* getAvailableLevelListItem(unsigned int index) const; //tolua_export
static LevelManager& getInstance() { return Singleton<LevelManager>::getInstance(); } // tolua_export
@@ -68,8 +69,12 @@
void activateNextLevel();
+ void compileAvailableLevelList(void);
+ void updateAvailableLevelList(void);
+
std::list<Level*> levels_s;
std::vector<std::string> availableLevels_;
+ std::map<std::string, LevelInfoItem*> infos_;
// config values
std::string defaultLevelName_;
Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h 2010-11-13 22:30:06 UTC (rev 7647)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h 2010-11-13 22:55:23 UTC (rev 7648)
@@ -66,6 +66,8 @@
{
class CameraManager;
class Level;
+ class LevelInfo;
+ class LevelInfoItem;
class LevelManager;
class PawnManager;
class PlayerManager;
More information about the Orxonox-commit
mailing list