Changeset 7626 for code/branches/releasetodo
- Timestamp:
- Nov 6, 2010, 9:52:48 PM (14 years ago)
- Location:
- code/branches/releasetodo
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/releasetodo/data/gui/layouts/SingleplayerMenu.layout
r6746 r7626 15 15 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 16 16 <Property Name="VertFormatting" Value="TopAligned" /> 17 <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0. 6375,0}}" />17 <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.7,0}}" /> 18 18 <Window Type="MenuWidgets/Listbox" Name="orxonox/SingleplayerLevelListbox" > 19 19 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 20 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" /> 20 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}" /> 21 </Window> 22 <Window Type="MenuWidgets/RadioButton" Name="orxonox/SingleplayerShowRestrictedButton" > 23 <Property Name="Text" Value="show only restricted" /> 24 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 25 <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.87,0},{0.5,0},{.97,0}}" /> 26 <Event Name="SelectStateChanged" Function="SingleplayerMenu.SingleplayerShowRestrictedButton_clicked"/> 27 </Window> 28 <Window Type="MenuWidgets/RadioButton" Name="orxonox/SingleplayerShowAllButton" > 29 <Property Name="Text" Value="show all" /> 30 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 31 <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.87,0},{0.85,0},{.97,0}}" /> 32 <Event Name="SelectStateChanged" Function="SingleplayerMenu.SingleplayerShowAllButton_clicked"/> 21 33 </Window> 22 34 </Window> … … 24 36 <Property Name="Text" Value="Start" /> 25 37 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 26 <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0. 6625,0},{0.4875,0},{0.7125,0}}" />38 <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.725,0},{0.4875,0},{0.775,0}}" /> 27 39 <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerStartButton_clicked"/> 28 40 </Window> … … 30 42 <Property Name="Text" Value="Back" /> 31 43 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 32 <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0. 6625,0},{0.7125,0},{0.7125,0}}" />44 <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.725,0},{0.7125,0},{0.775,0}}" /> 33 45 <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/> 34 46 </Window> -
code/branches/releasetodo/data/gui/scripts/MultiplayerMenu.lua
r7163 r7626 2 2 3 3 local P = createMenuSheet("MultiplayerMenu") 4 5 P.levelList = {} 6 P.itemList = {} 7 P.showAll = false 4 8 5 9 function P.onLoad() … … 69 73 70 74 function P.showLevelList() 71 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 72 CEGUI.toListbox(listbox):resetList() 75 P.createLevelList() 76 end 77 78 function P.createLevelList() 79 P.levelList = {} 80 P.itemList = {} 81 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox")) 82 listbox:resetList() 73 83 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 74 orxonox.LevelManager:getInstance():compileAvailableLevelList() 75 local levelList = {} 84 local size = orxonox.LevelManager:getInstance():getNumberOfLevels() 76 85 local index = 0 77 local level = ""78 while true do86 local level = nil 87 while index < size do 79 88 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 80 if level == "" then 81 break 89 if level ~= nil then 90 if P.showAll or not level:hasTag("test") then 91 table.insert(P.levelList, level) 92 end 82 93 end 83 table.insert(levelList, level)84 94 index = index + 1 85 95 end 86 table.sort(levelList)87 index = 188 for k,v in pairs( levelList) do89 local item = CEGUI.createListboxTextItem(v )96 --TODO: Reintroduce sorting, if needed. 97 --table.sort(levelList) 98 for k,v in pairs(P.levelList) do 99 local item = CEGUI.createListboxTextItem(v:getName()) 90 100 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 91 item:setID(index) 92 index = index + 1 93 CEGUI.toListbox(listbox):addItem(item) 94 if v .. ".oxw" == preselect then 101 listbox:addItem(item) 102 if v:getXMLFilename() == preselect then 95 103 listbox:setItemSelectState(item, true) 96 104 end 105 P.itemList[k] = listbox:getListboxItemFromIndex(k-1) 106 --TODO: The description as tooltip would be nice. 107 --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k]) 108 --lItem:setTooltipText(v:getDescription()) 97 109 end 98 99 110 end 111 100 112 function P.showServerList() 101 113 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") -
code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua
r7625 r7626 3 3 local P = createMenuSheet("SingleplayerMenu") 4 4 5 P.levelList = {} 6 P.itemList = {} 7 P.showAll = false 8 5 9 function P.onLoad() 6 listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox") 7 preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 8 size = orxonox.LevelManager:getInstance():getNumberOfLevels() 9 local levelList = {} 10 local window = winMgr:getWindow("orxonox/SingleplayerShowRestrictedButton") 11 local button = tolua.cast(window,"CEGUI::RadioButton") 12 button:setSelected(true) 13 P.createLevelList() 14 end 15 16 function P.createLevelList() 17 P.levelList = {} 18 P.itemList = {} 19 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")) 20 listbox:resetList() 21 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 22 local size = orxonox.LevelManager:getInstance():getNumberOfLevels() 10 23 local index = 0 11 local level = ""24 local level = nil 12 25 while index < size do 13 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 14 table.insert(levelList, level) 15 index = index + 1 26 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 27 if level ~= nil then 28 if P.showAll or not level:hasTag("test") then 29 table.insert(P.levelList, level) 30 end 31 end 32 index = index + 1 16 33 end 17 table.sort(levelList) 18 for k,v in pairs(levelList) do 19 item = CEGUI.createListboxTextItem(v) 34 --TODO: Reintroduce sorting, if needed. 35 --table.sort(levelList) 36 for k,v in pairs(P.levelList) do 37 local item = CEGUI.createListboxTextItem(v:getName()) 20 38 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 21 CEGUI.toListbox(listbox):addItem(item)22 if v .. ".oxw"== preselect then39 listbox:addItem(item) 40 if v:getXMLFilename() == preselect then 23 41 listbox:setItemSelectState(item, true) 24 42 end 43 P.itemList[k] = listbox:getListboxItemFromIndex(k-1) 44 --TODO: The description as tooltip would be nice. 45 --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k]) 46 --lItem:setTooltipText(v:getDescription()) 25 47 end 26 27 48 end 28 49 29 50 function P.SingleplayerStartButton_clicked(e) 30 local choice = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")):getFirstSelectedItem() 31 if choice then 32 orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") 33 orxonox.execute("startGame") 34 hideAllMenuSheets() 51 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")) 52 local choice = listbox:getFirstSelectedItem() 53 if choice ~= nil then 54 local index = listbox:getItemIndex(choice) 55 local level = P.levelList[index+1] 56 if level ~= nil then 57 orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename()) 58 orxonox.execute("startGame") 59 hideAllMenuSheets() 60 end 35 61 end 62 end 63 64 function P.SingleplayerShowRestrictedButton_clicked(e) 65 P.showAll = false 66 P.createLevelList() 67 end 68 69 function P.SingleplayerShowAllButton_clicked(e) 70 P.showAll = true 71 P.createLevelList() 36 72 end 37 73 -
code/branches/releasetodo/src/orxonox/LevelInfo.h
r7625 r7626 44 44 #include "core/OrxonoxClass.h" 45 45 46 namespace orxonox 47 { 46 namespace orxonox // tolua_export 47 { // tolua_export 48 48 49 49 /** … … 55 55 Damian 'Mozork' Frick 56 56 */ 57 class _OrxonoxExport LevelInfoItem : virtual public OrxonoxClass 58 { 57 class _OrxonoxExport LevelInfoItem // tolua_export 58 : virtual public OrxonoxClass 59 { // tolua_export 59 60 public: 60 61 LevelInfoItem(); //!< Default constructor. … … 72 73 @return Returns the name of the Level. 73 74 */ 74 inline const std::string& getName(void) 75 { return this->name_; } 75 inline const std::string& getName(void) { return this->name_; } // tolua_export 76 76 77 77 /** … … 85 85 @return Returns the description of the Level. 86 86 */ 87 inline const std::string& getDescription() const 88 { return this->description_; } 87 inline const std::string& getDescription() const { return this->description_; } // tolua_export 89 88 90 89 void setTags(const std::string& tags); //!< Set the tags the Level is tagged with. … … 101 100 @return Returns true if the Level is tagged with the input tag. 102 101 */ 103 bool hasTag(const std::string& tag) const 104 { return this->tags_.find(tag) != this->tags_.end(); } 102 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 105 103 106 104 /** … … 108 106 @return Returns the XML-filename (including *.oxw extension) of the Level. 109 107 */ 110 inline const std::string& getXMLFilename(void) 111 { return this->xmlfilename_; } 108 inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export 112 109 113 110 protected: … … 128 125 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 129 126 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 130 }; 127 }; // tolua_export 131 128 132 129 /** … … 188 185 189 186 }; 190 } 187 } // tolua_export 191 188 192 189 #endif /* _LevelInfo_H__ */ -
code/branches/releasetodo/src/orxonox/LevelManager.cc
r7625 r7626 134 134 this->updateAvailableLevelList(); 135 135 136 COUT(0) << "Number of Levels: " << this->infos_.size() << std::endl;137 138 136 return this->availableLevels_.size(); 139 137 } 140 138 141 const std::string&LevelManager::getAvailableLevelListItem(unsigned int index) const139 LevelInfoItem* LevelManager::getAvailableLevelListItem(unsigned int index) const 142 140 { 143 141 if (index >= this->availableLevels_.size()) 144 return BLANKSTRING;142 return NULL; 145 143 else 146 144 { 147 145 std::map<std::string, LevelInfoItem*>::const_iterator it = this->infos_.find(this->availableLevels_[index]); 148 assert(it->second); 149 return it->second->getName(); 146 return it->second; 150 147 } 151 148 } … … 172 169 { 173 170 LevelInfoItem* info = item->copy(); 174 COUT(0) << "BUUUUUUUUUH: " << info->getName() << " | " << info->getXMLFilename() << " | " << it->substr(0, pos) << std::endl;175 171 if(info->getXMLFilename() == *it) 176 172 { -
code/branches/releasetodo/src/orxonox/LevelManager.h
r7625 r7626 61 61 const std::string& getDefaultLevel() const; //tolua_export 62 62 unsigned int getNumberOfLevels(void); //tolua_export 63 const std::string&getAvailableLevelListItem(unsigned int index) const; //tolua_export63 LevelInfoItem* getAvailableLevelListItem(unsigned int index) const; //tolua_export 64 64 65 65 static LevelManager& getInstance() { return Singleton<LevelManager>::getInstance(); } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.