[Orxonox-commit 4374] r9045 - in code/branches/shipSelection: data/gui/layouts data/gui/scripts src/orxonox
huttemat at orxonox.net
huttemat at orxonox.net
Fri Mar 16 16:54:46 CET 2012
Author: huttemat
Date: 2012-03-16 16:54:46 +0100 (Fri, 16 Mar 2012)
New Revision: 9045
Added:
code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
Modified:
code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout
code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua
code/branches/shipSelection/src/orxonox/LevelInfo.cc
Log:
added wip ship selection menu
Modified: code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout
===================================================================
--- code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout 2012-03-16 15:09:29 UTC (rev 9044)
+++ code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout 2012-03-16 15:54:46 UTC (rev 9045)
@@ -1,57 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<GUILayout >
- <Window Type="MenuWidgets/StaticImage" Name="orxonox/SingleplayerBackground" >
+
+ <Window Type="MenuWidgets/StaticImage" Name="orxonox/ShipSelectionBackground" >
<Property Name="FrameEnabled" Value="False" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
<Property Name="BackgroundEnabled" Value="False" />
- <Window Type="MenuWidgets/StaticText" Name="orxonox/SingleplayerWindow" >
- <Property Name="Text" Value="Singleplayer" />
+ <!-- -->
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/ShipSelectionWindow" >
+ <Property Name="Text" Value="ShipSelection" />
<Property Name="Alpha" Value="0.8" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.15,0},{0.8,0},{0.7,0}}" />
- <Window Type="MenuWidgets/TabControl" Name="orxonox/SingleplayerTabControl" >
+ <!--
+ <Window Type="MenuWidgets/TabControl" Name="orxonox/ShipSelectionTabControl" >
<Property Name="TabHeight" Value="{0,26.4388}" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="TabPanePosition" Value="Top" />
<Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.925,0}}" />
</Window>
- <Window Type="MenuWidgets/StaticImage" Name="orxonox/SingleplayerLevelImage" >
+ -->
+ <Window Type="MenuWidgets/StaticImage" Name="orxonox/ShipSelectionLevelImage" >
<Property Name="AlwaysOnTop" Value="True" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.25,0},{0.9,0},{0.675,0}}" />
</Window>
- <Window Type="MenuWidgets/StaticText" Name="orxonox/SingleplayerLevelDescription" >
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/ShipSelectionLevelDescription" >
<Property Name="AlwaysOnTop" Value="True" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertScrollbar" Value="True" />
<Property Name="HorzScrollbar" Value="True" />
<Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.725,0},{0.9,0},{0.875,0}}" />
</Window>
+
</Window>
- <Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerStartButton" >
+ <!-- -->
+ <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionStartButton" >
<Property Name="Text" Value="Start" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.725,0},{0.4,0},{0.775,0}}" />
- <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerStartButton_clicked"/>
+ <Event Name="Clicked" Function="ShipSelectionMenu.ShipSelectionStartButton_clicked"/>
</Window>
- <Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerConfigButton" >
+ <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionConfigButton" >
<Property Name="Text" Value="Configure" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.425,0},{0.725,0},{0.575,0},{0.775,0}}" />
<Property Name="Disabled" Value="True" />
- <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerConfigButton_clicked"/>
+ <Event Name="Clicked" Function="ShipSelectionMenu.ShipSelectionConfigButton_clicked"/>
</Window>
- <Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerBackButton" >
+ <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.725,0},{0.75,0},{0.775,0}}" />
- <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
+ <Event Name="Clicked" Function="ShipSelectionMenu.ShipSelectionBackButton_clicked"/>
</Window>
</Window>
</GUILayout>
Added: code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua (rev 0)
+++ code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua 2012-03-16 15:54:46 UTC (rev 9045)
@@ -0,0 +1,171 @@
+-- ShipSelectionMenu.lua
+
+local P = createMenuSheet("ShipSelectionMenu")
+P.levelList = {}
+P.activeTabIndexes = {}
+P.scrollbarWidth = 13
+
+function P.onLoad()
+--[[ P.createLevelList()
+
+ -- create tabs with desired tab as argument (nil for all)
+ P.createFilterTab("Gametypes", "gametype")
+ P.createFilterTab("Missions", "mission")
+ P.createFilterTab("Minigames", "minigame")
+ P.createFilterTab("Showcases", "showcase")
+ P.createFilterTab("Presentations", "presentation")
+ P.createFilterTab("Tests", "test")
+ P.createFilterTab("Show All", nil)
+
+ -- update description and screenshot boxes
+ P.ShipSelectionSelectionChanged()
+
+ --buttons are arranged in a 1x3 matrix
+ P:setButton(1, 1, {
+ ["button"] = winMgr:getWindow("orxonox/ShipSelectionStartButton"),
+ ["callback"] = P.ShipSelectionStartButton_clicked
+ })
+
+ P:setButton(1, 2, {
+ ["button"] = winMgr:getWindow("orxonox/ShipSelectionConfigButton"),
+ ["callback"] = P.ShipSelectionConfigButton_clicked
+ })
+
+ P:setButton(1, 3, {
+ ["button"] = winMgr:getWindow("orxonox/ShipSelectionBackButton"),
+ ["callback"] = P.ShipSelectionBackButton_clicked
+ })--]]
+end
+--[[
+function P.createLevelList()
+ P.levelList = {}
+ local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
+ local index = 0
+ local level = nil
+ while index < size do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level ~= nil then
+ local levelXMLFilename = level:getXMLFilename()
+ -- create an imageset for each screenshot
+ local imageName = level:getScreenshot()
+ if imageName ~= "" then
+ CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, imageName)
+ else
+ CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, "noscreenshot.png")
+ end
+ table.insert(P.levelList, level)
+ end
+ index = index + 1
+ end
+end
+
+function P.createFilterTab(name, tag)
+ -- create unique tab window name
+ local tabName = "orxonox/ShipSelectionLevelTab"
+ if tag ~= nil then
+ tabName = tabName..tag
+ end
+ -- create new tab window with desired name
+ local listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName))
+ listbox:setText(name)
+ listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
+ listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.675,0}}")
+ -- fill listbox with items
+ listbox:resetList()
+ orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
+ local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+ local tabIndexes = {}
+ for k,v in pairs(P.levelList) do
+ -- only add level if it has desired tag
+ if tag == nil or v:hasTag(tag) then
+ local item = CEGUI.createListboxTextItem(v:getName())
+ item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+ listbox:addItem(item)
+ table.insert(tabIndexes, k)
+ if v:getXMLFilename() == preselect then
+ listbox:setItemSelectState(item, true)
+ end
+ orxonox.GUIManager:setTooltipTextHelper(item, v:getDescription())
+ end
+ end
+ table.insert(P.activeTabIndexes, tabIndexes)
+ -- listen to selection changes
+ orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".ShipSelectionSelectionChanged")
+ local tabControl = winMgr:getWindow("orxonox/ShipSelectionTabControl")
+ orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".ShipSelectionSelectionChanged")
+ if listbox:getItemCount() > 0 then
+ tabControl:addChildWindow(tabName)
+ end
+end
+
+function P.ShipSelectionGetSelectedLevel()
+ -- choose the active listbox
+ local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/ShipSelectionTabControl"))
+ local listbox = CEGUI.toListbox(tabControl:getTabContentsAtIndex(tabControl:getSelectedTabIndex()))
+ local choice = listbox:getFirstSelectedItem()
+ if choice ~= nil then
+ -- get the right tab and the right index
+ local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
+ local index = tabIndexes[listbox:getItemIndex(choice)+1]
+ return P.levelList[index]
+ else
+ return nil
+ end
+end
+
+function P.ShipSelectionSelectionChanged(e)
+ local levelImage = winMgr:getWindow("orxonox/ShipSelectionLevelImage")
+ local levelDescription = winMgr:getWindow("orxonox/ShipSelectionLevelDescription")
+ local configButton = winMgr:getWindow("orxonox/ShipSelectionConfigButton")
+ local level = P.ShipSelectionGetSelectedLevel()
+ if level ~= nil then
+ local levelXMLFilename = level:getXMLFilename()
+ local imageName = level:getScreenshot()
+ -- set the screenshot and the description for the selected level
+ levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
+ levelDescription:setText(level:getDescription())
+ -- only enable config button for "gametype" levels
+ if level:hasTag("gametype") then
+ configButton:setProperty("Disabled", "False")
+ else
+ configButton:setProperty("Disabled", "True")
+ end
+ else
+ -- also take care of "no level selected"
+ levelImage:setProperty("Image", nil)
+ levelDescription:setText("")
+ configButton:setProperty("Disabled", "True")
+ end
+end
+--]]
+function P.ShipSelectionStartButton_clicked(e)
+--[[
+ local level = P.ShipSelectionGetSelectedLevel()
+ if level ~= nil then
+
+ if level:hasTag("shipselection") then
+ orxout("working!")
+ showMenuSheet("ShipSelectionMenu", true)
+ else
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+ end
+ end
+--]]
+end
+
+function P.ShipSelectionConfigButton_clicked(e)
+--[[
+ local level = P.ShipSelectionGetSelectedLevel()
+ if level ~= nil then
+ local configMenu = showMenuSheet("ShipSelectionConfigMenu")
+ configMenu:loadConfig(level)
+ end
+--]]
+end
+
+function P.ShipSelectionBackButton_clicked(e)
+ --hideMenuSheet(P.name)
+end
+
+return P
Modified: code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua 2012-03-16 15:09:29 UTC (rev 9044)
+++ code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua 2012-03-16 15:54:46 UTC (rev 9045)
@@ -1,7 +1,7 @@
-- SingleplayerMenu.lua
local P = createMenuSheet("SingleplayerMenu")
-P.loadAlong = { "ShipSelectionMenu"}
+P.loadAlong = {"ShipSelectionMenu"}
P.levelList = {}
P.activeTabIndexes = {}
P.scrollbarWidth = 13
@@ -142,11 +142,13 @@
function P.SingleplayerStartButton_clicked(e)
local level = P.SingleplayerGetSelectedLevel()
if level ~= nil then
- if level:hasTag("shipselection") then
- showMenuSheet("ShipSelectionMenu", true)
+
+ if level:hasTag("shipselection") then
+ showMenuSheet("ShipSelectionMenu", true)
+ else
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
end
- orxonox.execute("startGame " .. level:getXMLFilename())
- hideAllMenuSheets()
end
end
Modified: code/branches/shipSelection/src/orxonox/LevelInfo.cc
===================================================================
--- code/branches/shipSelection/src/orxonox/LevelInfo.cc 2012-03-16 15:09:29 UTC (rev 9044)
+++ code/branches/shipSelection/src/orxonox/LevelInfo.cc 2012-03-16 15:54:46 UTC (rev 9045)
@@ -92,6 +92,7 @@
LevelInfoItem::possibleTags_s.insert("mission");
LevelInfoItem::possibleTags_s.insert("gametype");
LevelInfoItem::possibleTags_s.insert("minigame");
+ LevelInfoItem::possibleTags_s.insert("shipselection");
}
}
More information about the Orxonox-commit
mailing list