[Orxonox-commit 4241] r8912 - in code/branches/menue: data/gui/layouts data/gui/scripts src/orxonox
baermatt at orxonox.net
baermatt at orxonox.net
Wed Nov 2 13:31:13 CET 2011
Author: baermatt
Date: 2011-11-02 13:31:12 +0100 (Wed, 02 Nov 2011)
New Revision: 8912
Modified:
code/branches/menue/data/gui/layouts/CreditsMenu.layout
code/branches/menue/data/gui/layouts/SingleplayerMenu.layout
code/branches/menue/data/gui/scripts/CreditsMenu.lua
code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
code/branches/menue/src/orxonox/LevelInfo.cc
code/branches/menue/src/orxonox/LevelInfo.h
Log:
Added screenshots and description-box in singleplayer menu
Modified: code/branches/menue/data/gui/layouts/CreditsMenu.layout
===================================================================
--- code/branches/menue/data/gui/layouts/CreditsMenu.layout 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/data/gui/layouts/CreditsMenu.layout 2011-11-02 12:31:12 UTC (rev 8912)
@@ -6,7 +6,7 @@
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
<Window Type="MenuWidgets/StaticText" Name="orxonox/CreditsWindow" >
- <Property Name="Text" Value="Keybindings" />
+ <Property Name="Text" Value="Credits" />
<Property Name="Alpha" Value="0.8" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="HorzFormatting" Value="HorzCentred" />
@@ -14,7 +14,6 @@
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.2125,0},{0.85,0},{0.6375,0}}" />
<Window Type="MenuWidgets/StaticText" Name="orxonox/CreditsMenuWrapper" >
- <Property Name="TextColours" Value="FF4444FF" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="HorzFormatting" Value="HorzCentred" />
@@ -26,7 +25,7 @@
<Property Name="VertStepSize" Value="0.005" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="HorzOverlapSize" Value="0.01" />
- <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0.997,0},{0.997,0}}" />
<Property Name="VertOverlapSize" Value="0.01" />
<Property Name="HorzScrollPosition" Value="0" />
<Property Name="VertScrollPosition" Value="0" />
@@ -37,14 +36,15 @@
<Property Name="HorzFormatting" Value="HorzCentred" />
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
- <Property Name="Text">wird sowieso nicht gelesen
-Orxonox version 0.0.3
-
-Programming Language: C++ - lua - tcl
-Environment: OpenAL - Ogre - OIS - CEGUI - enet - ODE
-Licence: GNU General Public Licence - Creative Commons
-
-http://www.orxonox.net
+ <Property Name="Text">Orxonox version 0.0.3
+
+ Programming Language: C++ - lua - tcl
+ Environment: OpenAL - Ogre - OIS - CEGUI - enet - ODE
+ Licence: GNU General Public Licence - Creative Commons
+
+ http://www.orxonox.net
+
+ Credits:
</Property>
</Window>
</Window>
@@ -58,8 +58,3 @@
</Window>
</Window>
</GUILayout>
-
-
-
-
-
Modified: code/branches/menue/data/gui/layouts/SingleplayerMenu.layout
===================================================================
--- code/branches/menue/data/gui/layouts/SingleplayerMenu.layout 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/data/gui/layouts/SingleplayerMenu.layout 2011-11-02 12:31:12 UTC (rev 8912)
@@ -14,24 +14,57 @@
<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.7,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.2,0},{0.8,0},{0.7,0}}" />
<Window Type="MenuWidgets/TabControl" Name="orxonox/SingleplayerTabControl" >
<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" >
+ <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.7,0}}" />
+ </Window>
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/SingleplayerLevelDescriptionWrapper" >
+ <Property Name="AlwaysOnTop" Value="True" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.75,0},{0.9,0},{0.85,0}}" />
+ <Window Type="MenuWidgets/ScrollablePane" Name="orxonox/SingleplayerLevelDescriptionPane" >
+ <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
+ <Property Name="HorzStepSize" Value="0.005" />
+ <Property Name="VertStepSize" Value="0.005" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzOverlapSize" Value="0.01" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0.997,0},{0.997,0}}" />
+ <Property Name="VertOverlapSize" Value="0.01" />
+ <Property Name="HorzScrollPosition" Value="0" />
+ <Property Name="VertScrollPosition" Value="0" />
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/SingleplayerLevelDescription" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ </Window>
+ </Window>
+ </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.725,0},{0.4875,0},{0.775,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.725,0},{0.4,0},{0.775,0}}" />
<Event Name="Clicked" Function="SingleplayerMenu.SingleplayerStartButton_clicked"/>
</Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/SingleplayerConfigButton" >
+ <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}}" />
+ <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerConfigButton_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.725,0},{0.7125,0},{0.775,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.725,0},{0.75,0},{0.775,0}}" />
<Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
</Window>
</Window>
Modified: code/branches/menue/data/gui/scripts/CreditsMenu.lua
===================================================================
--- code/branches/menue/data/gui/scripts/CreditsMenu.lua 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/data/gui/scripts/CreditsMenu.lua 2011-11-02 12:31:12 UTC (rev 8912)
@@ -13,13 +13,9 @@
function P.onShow()
local description = winMgr:getWindow("orxonox/CreditsText")
- description:setProperty("HorzFormatting", "WordWrapLeftAligned")
- description:setProperty("VertFormatting", "TopAligned")
- description:setText(" Orxonox version 0.0.3 \n\n Programming Language: C++ - lua - tcl \n Environment: OpenAL - Ogre - OIS - CEGUI - enet - ODE \n Licence: GNU General Public Licence - Creative Commons \n http://www.orxonox.net \n \n Credits:")
- description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
height = getStaticTextWindowHeight(description)
- description:setHeight(CEGUI.UDim(0, height))
+ description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
end
function P.CreditsBackButton_clicked(e)
Modified: code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/menue/data/gui/scripts/SingleplayerMenu.lua 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/data/gui/scripts/SingleplayerMenu.lua 2011-11-02 12:31:12 UTC (rev 8912)
@@ -3,25 +3,32 @@
local P = createMenuSheet("SingleplayerMenu")
P.levelList = {}
+P.activeTabIndexes = {}
+P.scrollbarWidth = 13
function P.onLoad()
P.createLevelList()
-- create tabs with desired tab as argument (nil for all)
- P.createFilterTab("Show All", nil)
P.createFilterTab("Tests", "test")
P.createFilterTab("Tutorials", "tutorial")
P.createFilterTab("Showcases", "showcase")
P.createFilterTab("SP?", "singleplayer")
P.createFilterTab("Presentations", "presentation")
+ P.createFilterTab("Show All", nil)
- --buttons are arranged in a 1x2 matrix
+ --buttons are arranged in a 1x3 matrix
P:setButton(1, 1, {
["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
["callback"] = P.SingleplayerStartButton_clicked
})
P:setButton(1, 2, {
+ ["button"] = winMgr:getWindow("orxonox/SingleplayerConfigButton"),
+ ["callback"] = P.SingleplayerConfigButton_clicked
+ })
+
+ P:setButton(1, 3, {
["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
["callback"] = P.SingleplayerBackButton_clicked
})
@@ -35,6 +42,13 @@
while index < size do
level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
if level ~= nil then
+ local levelXMLFilename = level:getXMLFilename()
+ 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
@@ -43,51 +57,82 @@
function P.createFilterTab(name, tag)
-- create unique tab window name
- local tabName = "orxonox/SingleplayerLevelListbox"
+ local tabName = "orxonox/SingleplayerLevelTab"
if tag ~= nil then
tabName = tabName..tag
end
-- add new tab window with desired name
local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl")
- local newWindow = winMgr:createWindow("MenuWidgets/Listbox", tabName)
- newWindow:setText(name)
- newWindow:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
- newWindow:setProperty("UnifiedAreaRect", "{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}")
+ 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.7,0}}")
tabControl:addChildWindow(tabName)
-- fill listbox with items
- local listbox = CEGUI.toListbox(newWindow)
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)
+ listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged")
+ tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged")
+ SingleplayerSelectionChanged()
end
-function P.SingleplayerStartButton_clicked(e)
+function P.SingleplayerGetSelectedLevel()
-- choose the active listbox
local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/SingleplayerTabControl"))
local listbox = CEGUI.toListbox(tabControl:getTabContentsAtIndex(tabControl:getSelectedTabIndex()))
local choice = listbox:getFirstSelectedItem()
if choice ~= nil then
- local index = listbox:getItemIndex(choice)
- local level = P.levelList[index+1]
- if level ~= nil then
- orxonox.execute("startGame " .. level:getXMLFilename())
- hideAllMenuSheets()
- end
+ local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
+ local index = tabIndexes[listbox:getItemIndex(choice)+1]
+ return P.levelList[index]
+ else
+ return nil
end
end
+function SingleplayerSelectionChanged(e)
+ local level = P.SingleplayerGetSelectedLevel()
+ if level ~= nil then
+ local levelXMLFilename = level:getXMLFilename()
+ local imageName = level:getScreenshot()
+ local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage")
+ levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
+ local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
+ local height = getStaticTextWindowHeight(levelDescription)
+-- local width = getStaticTextWindowWidth(levelDescription)
+ levelDescription:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
+ levelDescription:setText(level:getDescription())
+ end
+end
+
+function P.SingleplayerStartButton_clicked(e)
+ local level = P.SingleplayerGetSelectedLevel()
+ if level ~= nil then
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+ end
+end
+
+function P.SingleplayerConfigButton_clicked(e)
+ hideMenuSheet(P.name)
+end
+
function P.SingleplayerBackButton_clicked(e)
hideMenuSheet(P.name)
end
Modified: code/branches/menue/src/orxonox/LevelInfo.cc
===================================================================
--- code/branches/menue/src/orxonox/LevelInfo.cc 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/src/orxonox/LevelInfo.cc 2011-11-02 12:31:12 UTC (rev 8912)
@@ -188,6 +188,7 @@
SUPER(LevelInfo, XMLPort, xmlelement, mode);
XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
+ XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode);
XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode);
}
@@ -202,6 +203,7 @@
{
LevelInfoItem* info = new LevelInfoItem(this->BaseObject::getName(), this->getXMLFilename());
info->setDescription(this->getDescription());
+ info->setScreenshot(this->getScreenshot());
info->setTags(this->getTags());
return info;
}
Modified: code/branches/menue/src/orxonox/LevelInfo.h
===================================================================
--- code/branches/menue/src/orxonox/LevelInfo.h 2011-11-02 12:23:26 UTC (rev 8911)
+++ code/branches/menue/src/orxonox/LevelInfo.h 2011-11-02 12:31:12 UTC (rev 8912)
@@ -76,6 +76,17 @@
@return Returns the name of the Level.
*/
inline const std::string& getName(void) const { return this->name_; } // tolua_export
+
+ /**
+ @brief Set the screenshot of the Level.
+ @param screenshot The screenshot to be set.
+ */
+ inline void setScreenshot(const std::string& screenshot) { this->screenshot_ = std::string(screenshot); }
+ /**
+ @brief Get the screenshot of the Level.
+ @return Returns the screenshot of the Level.
+ */
+ inline const std::string& getScreenshot() const { return this->screenshot_; } // tolua_export
/**
@brief Set the description of the Level.
@@ -137,6 +148,7 @@
std::string name_; //!< The name of the Level.
std::string description_; //!< The description of the Level.
+ std::string screenshot_; //!< The screenshot 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
@@ -147,6 +159,7 @@
The following parameters can be specified:
- @b name The name of the level.
- @b description The description of the level.
+ - @b screenshot The screenshot 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:
@@ -154,6 +167,7 @@
<LevelInfo
name = "Levelname"lhs->compare(rhs) < 0
description = "This is just some awesome level."
+ screenshot = "Screenshot.png"
tags = "test, awesome"
/>
@endcode
@@ -171,6 +185,17 @@
virtual ~LevelInfo();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
+
+ /**
+ @brief Set the screenshot of the Level.
+ @param screenshot The screenshot to be set.
+ */
+ inline void setScreenshot(const std::string& screenshot) { this->LevelInfoItem::setScreenshot(screenshot); }
+ /**
+ @brief Get the screenshot of the Level.
+ @return Returns the screenshot of the Level.
+ */
+ inline const std::string& getScreenshot() const { return this->LevelInfoItem::getScreenshot(); }
/**
@brief Set the description of the Level.
More information about the Orxonox-commit
mailing list