Changeset 10253 for code/branches/storymodeHS14
- Timestamp:
- Feb 3, 2015, 11:38:07 PM (10 years ago)
- Location:
- code/branches/storymodeHS14
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout
r10157 r10253 10 10 <Window Type="MenuWidgets/Button" Name="orxonox/MissionOneButton" > 11 11 <Property Name="Text" Value="Mission 1" /> 12 <Property Name="Visible" Value="False"/> 12 13 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 13 14 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" /> … … 16 17 <Window Type="MenuWidgets/Button" Name="orxonox/MissionTwoButton" > 17 18 <Property Name="Text" Value="Mission 2" /> 19 <Property Name="Visible" Value="False"/> 18 20 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 19 21 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" /> … … 23 25 <Window Type="MenuWidgets/Button" Name="orxonox/MissionThreeButton" > 24 26 <Property Name="Text" Value="Mission 3" /> 27 <Property Name="Visible" Value="False"/> 25 28 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 26 29 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4375,0},{0.6,0},{0.4875,0}}" /> … … 30 33 <Window Type="MenuWidgets/Button" Name="orxonox/MissionFourButton" > 31 34 <Property Name="Text" Value="Mission 4" /> 35 <Property Name="Visible" Value="False"/> 32 36 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 33 37 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5125,0},{0.6,0},{0.5625,0}}" /> … … 38 42 <Property Name="Text" Value="Back" /> 39 43 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 40 <Property Name="UnifiedAreaRect" Value="{{0. 7,0},{0.8,0},{0.85,0},{0.85,0}}" />44 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8,0},{0.6,0},{0.85,0}}" /> 41 45 <Event Name="Clicked" Function="CampaignMenu.CampaignMenuBackButton_clicked"/> 42 46 </Window> 43 <Window Type="MenuWidgets/Button" Name="orxonox/CampaignMenuRefreshButton" > 44 <Property Name="Text" Value="Refresh" /> 45 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 46 <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.8,0},{0.3,0},{0.85,0}}" /> 47 <Event Name="Clicked" Function="CampaignMenu.CampaignMenuRefreshButton_clicked"/> 48 </Window> 49 <Window Type="MenuWidgets/StaticText" Name="orxonox/CampaignMenuCongratulation" > 47 <Window Type="MenuWidgets/StaticText" Name="orxonox/CampaignMenuCongratulation" > 50 48 <Property Name="Text" Value="Campaign Completed!!!" /> 51 <Property Name="Visible" Value="False"/> 49 <Property Name="Visible" Value="False"/> 52 50 <Property Name="InheritsAlpha" Value="False" /> 53 51 <Property Name="HorzFormatting" Value="HorzCentred" /> … … 55 53 <Property Name="UnifiedMaxSize" Value="{{2,1},{2,1}}" /> 56 54 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.15,0},{0.6,0},{0.2,0}}" /> 57 55 </Window> 58 56 </Window> 59 57 </GUILayout> -
code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua
r10251 r10253 3 3 local P = createMenuSheet("CampaignMenu") 4 4 5 function P.onLoad() 6 7 local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton") 8 if (P.CheckLevel("missionOne.oxw")) then 9 MissionTwoButton:setProperty("Disabled", "False") 10 end 11 12 local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton") 13 if (P.CheckLevel("fightInOurBack.oxw")) then 14 MissionThreeButton:setProperty("Disabled", "False") 15 end 5 function P:onShow() 6 P:updateButtons() 7 end 16 8 17 local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton") 18 if (P.CheckLevel("pirateAttack.oxw")) then 19 MissionFourButton:setProperty("Disabled", "False") 20 end 21 22 local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation") 23 if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then 24 Completed:setProperty("Visible","True") 9 function P.updateButtons() 10 P.updateButton(0, winMgr:getWindow("orxonox/MissionOneButton")) 11 P.updateButton(1, winMgr:getWindow("orxonox/MissionTwoButton")) 12 P.updateButton(2, winMgr:getWindow("orxonox/MissionThreeButton")) 13 P.updateButton(3, winMgr:getWindow("orxonox/MissionFourButton")) 14 15 if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then 16 local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation") 17 label:setProperty("Visible","True") 25 18 end 26 19 end 27 20 28 function P.GenerateHelperString(number) 29 local string = "" 30 while number > 1 do 31 string = string.." " 32 number = number-1 21 function P.updateButton(index, button) 22 if (P.shouldDisplayButton(index)) then 23 button:setProperty("Visible", "True") 24 25 if (P.shouldEnableButton(index)) then 26 button:setProperty("Disabled", "False") 27 end 33 28 end 34 string = string.."."35 return string36 29 end 37 30 38 function P.FindLevel(filename) 31 function P.shouldDisplayButton(index) 32 local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() 33 return index < size 34 end 35 36 function P.shouldEnableButton(index) 37 return index <= P.getIndexOfLastFinishedMission() + 1 38 end 39 40 function P.getIndexOfLastFinishedMission() 41 local lastMission = orxonox.LevelManager:getInstance():getLastFinishedCampaignMission() 42 if (lastMission and lastMission ~= "") then 43 local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() 44 local index = 0 45 while index < size do 46 local mission = orxonox.LevelManager:getInstance():getCampaignMission(index) 47 if (mission == lastMission) then 48 return index 49 end 50 index = index + 1 51 end 52 end 53 return -1 54 end 55 56 function P.MissionOneButton_clicked(e) 57 P.loadLevel(P.FindLevel(0)) 58 end 59 60 function P.MissionTwoButton_clicked(e) 61 P.loadLevel(P.FindLevel(1)) 62 end 63 64 function P.MissionThreeButton_clicked(e) 65 P.loadLevel(P.FindLevel(2)) 66 end 67 68 function P.MissionFourButton_clicked(e) 69 P.loadLevel(P.FindLevel(3)) 70 end 71 72 function P.loadLevel(level) 73 orxonox.execute("startGame " .. level:getXMLFilename()) 74 hideAllMenuSheets() 75 end 76 77 function P.FindLevel(index) 78 local filename = orxonox.LevelManager:getInstance():getCampaignMission(index) 39 79 local level = nil 40 80 local templevel = nil … … 50 90 return level 51 91 end 52 53 function P.CheckLevel(filename)54 local file = io.open("campaign.txt", "r+")55 local index = 056 local returnvalue = false57 local numberoflines = 58-string.len(filename)58 local helpstringfalse = filename.." 0"..P.GenerateHelperString(numberoflines)59 local helpstringtrue = filename.." 1"..P.GenerateHelperString(numberoflines)60 while index < 100 do61 local line = file:read()62 if(line == helpstringfalse) then63 returnvalue = false64 break65 end66 if(line == helpstringtrue) then67 returnvalue = true68 break69 end70 index=index+171 end72 io.close(file)73 return returnvalue74 end75 76 function P.MissionOneButton_clicked(e)77 local level = P.FindLevel("missionOne.oxw")78 orxonox.execute("startGame " .. level:getXMLFilename())79 hideAllMenuSheets()80 end81 82 function P.MissionTwoButton_clicked(e)83 local level = P.FindLevel("fightInOurBack.oxw")84 if (P.CheckLevel("missionOne.oxw")) then85 orxonox.execute("startGame " .. level:getXMLFilename())86 hideAllMenuSheets()87 end88 end89 90 function P.MissionThreeButton_clicked(e)91 local level = P.FindLevel("pirateAttack.oxw")92 if (P.CheckLevel("fightInOurBack.oxw")) then93 orxonox.execute("startGame " .. level:getXMLFilename())94 hideAllMenuSheets()95 else96 hideMenuSheet(P.name)97 end98 end99 100 function P.MissionFourButton_clicked(e)101 local level = P.FindLevel("iJohnVane_TriptoArea51.oxw")102 if (P.CheckLevel("pirateAttack.oxw")) then103 orxonox.execute("startGame " .. level:getXMLFilename())104 hideAllMenuSheets()105 else106 hideMenuSheet(P.name)107 end108 end109 110 function P.CampaignMenuRefreshButton_clicked(e)111 local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")112 if (P.CheckLevel("missionOne.oxw")) then113 MissionTwoButton:setProperty("Disabled", "False")114 end115 116 local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")117 if (P.CheckLevel("fightInOurBack.oxw")) then118 MissionThreeButton:setProperty("Disabled", "False")119 end120 121 local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")122 if (P.CheckLevel("pirateAttack.oxw")) then123 MissionFourButton:setProperty("Disabled", "False")124 end125 126 local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")127 if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then128 Completed:setProperty("Visible","True")129 end130 end131 92 132 93 function P.CampaignMenuBackButton_clicked(e) … … 134 95 end 135 96 136 137 138 97 return P -
code/branches/storymodeHS14/data/tcl
- Property svn:ignore deleted
-
code/branches/storymodeHS14/src/orxonox/LevelManager.cc
r9667 r10253 89 89 SetConfigValue(defaultLevelName_, "missionOne.oxw") 90 90 .description("Sets the pre selection of the level in the main menu."); 91 SetConfigValue(lastFinishedCampaignMission_, "") 92 .description("The last finished mission of a campaign"); 93 SetConfigValue(campaignMissions_, std::vector<std::string>()) 94 .description("The list of missions in the campaign"); 95 } 96 97 /** 98 * @brief Stores the argument in the corresponding config value. 99 */ 100 void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission) 101 { 102 ModifyConfigValue(lastFinishedCampaignMission_, set, lastFinishedCampaignMission); 91 103 } 92 104 -
code/branches/storymodeHS14/src/orxonox/LevelManager.h
r9667 r10253 91 91 LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels. 92 92 93 void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission); 94 inline const std::string& getLastFinishedCampaignMission() const 95 { return this->lastFinishedCampaignMission_; } 96 97 inline unsigned int getNumberOfCampaignMissions() 98 { return this->campaignMissions_.size(); } 99 inline const std::string& getCampaignMission(unsigned int index) 100 { return this->campaignMissions_[index]; } 101 93 102 /** 94 103 @brief Get the instance of the LevelManager. … … 116 125 // config values 117 126 std::string defaultLevelName_; 127 std::string lastFinishedCampaignMission_; 128 std::vector<std::string> campaignMissions_; 118 129 119 130 static LevelManager* singletonPtr_s; -
code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc
r10251 r10253 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/command/ConsoleCommand.h" 38 #include "core/config/ConfigValueIncludes.h" 38 39 #include "infos/PlayerInfo.h" 39 40 #include "network/Host.h" 40 41 #include "worldentities/pawns/Pawn.h" 41 #include <iostream> 42 #include <fstream> 43 #include <string> 44 #include <ios> 42 #include "LevelManager.h" 45 43 46 44 namespace orxonox … … 93 91 } 94 92 95 std::string GenerateHelperString(int number)96 {97 std::string helperstring = "";98 while (number > 1)99 {100 helperstring = helperstring + " ";101 number = number - 1;102 }103 helperstring = helperstring + ".";104 return helperstring;105 }106 107 93 void Mission::end() 108 94 { … … 112 98 this->gtinfo_->sendAnnounceMessage("Mission accomplished!"); 113 99 114 boost::filesystem::path filepath("campaign.txt"); 115 std::fstream myfile; 116 myfile.open(filepath.string().c_str(), std::fstream::out); 117 118 std::string line; 119 std::string mission = this->getFilename(); 120 int k = 58 - mission.length(); 121 std::string helperstring = ""; 122 if (myfile.is_open()) 123 { 124 while (k > 1) 125 { 126 helperstring = helperstring + " "; 127 k = k - 1; 128 } 129 helperstring = helperstring + "."; 130 while (getline(myfile, line)) 131 { 132 if (line == mission + " 0" + helperstring) 133 { 134 long pos = (long) myfile.tellp(); 135 myfile.seekp(pos - 61); 136 myfile << mission + " 1" + helperstring; 137 } 138 } 139 } else { 140 orxout(internal_warning) << "failed to open campaign file" << endl; 141 } 142 myfile.flush(); 143 myfile.clear(); 144 myfile.close(); 100 LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename()); 145 101 } 146 102
Note: See TracChangeset
for help on using the changeset viewer.