]> git.jsancho.org Git - lugaru.git/commitdiff
Reading the campaign end text from campaign file (see #60)
authorCôme Chilliet <come@chilliet.eu>
Mon, 23 Jan 2017 17:11:13 +0000 (18:11 +0100)
committerCôme Chilliet <come@chilliet.eu>
Mon, 23 Jan 2017 17:11:13 +0000 (18:11 +0100)
Data/Campaigns/main.txt
Data/Campaigns/seventasks.txt
Source/Level/Campaign.cpp
Source/Level/Campaign.hpp
Source/Menu/Menu.cpp

index 083b8b2219cfc7773e61fe4ac64c5208bb28e0cb..677d2eb86327ad184df84509c6c8aaca1ee7e3a7 100644 (file)
@@ -241,3 +241,7 @@ ChooseNext: 1
 NumNext: 0
 LocationX: 284
 LocationY: 312
+
+EndText:Congratulations!
+You have avenged your family and
+restored peace to the island of Lugaru.
index d6163057b1aa2468a93f9f563b41c06b8dff639a..70b2aedb163d4cc11d66322b29c04db7dd0cf886 100644 (file)
@@ -72,7 +72,6 @@ NextLevel: 9
 LocationX: 153
 LocationY: 210
 
-
 Level 9:
 Name: task9
 Description: Desert_-_camp
@@ -159,6 +158,5 @@ Name: task18
 Description: Bonus_Level_-_ZOMBIES!
 ChooseNext: 1
 NumNext: 0
-NextLevel: 19
 LocationX: 400
 LocationY: 400
index 410abcc7535c3177a203ee5f0dc79a70d82219e9..02072d0137d101338dd3f0e8b908156e9c14ae6c 100644 (file)
@@ -32,6 +32,7 @@ std::vector<CampaignLevel> campaignlevels;
 bool campaign = false;
 
 int actuallevel = 0;
+std::string campaignEndText[3];
 
 std::vector<std::string> ListCampaigns()
 {
@@ -64,10 +65,10 @@ void LoadCampaign()
     std::ifstream ipstream(Folders::getResourcePath("Campaigns/" + Account::active().getCurrentCampaign() + ".txt"));
     if (!ipstream.good()) {
         if (Account::active().getCurrentCampaign() == "main") {
-            cerr << "Could not found main campaign!" << endl;
+            cerr << "Could not find main campaign!" << endl;
             return;
         }
-        cerr << "Could not found campaign \"" << Account::active().getCurrentCampaign() << "\", falling back to main." << endl;
+        cerr << "Could not find campaign \"" << Account::active().getCurrentCampaign() << "\", falling back to main." << endl;
         Account::active().setCurrentCampaign("main");
         return LoadCampaign();
     }
@@ -80,6 +81,15 @@ void LoadCampaign()
         ipstream >> cl;
         campaignlevels.push_back(cl);
     }
+    campaignEndText[0] = "Congratulations!";
+    campaignEndText[1] = string("You have completed ") + Account::active().getCurrentCampaign() + " campaign";
+    campaignEndText[2] = "and restored peace to the island of Lugaru.";
+    if (ipstream.good()) {
+        ipstream.ignore(256, ':');
+        getline(ipstream, campaignEndText[0]);
+        getline(ipstream, campaignEndText[1]);
+        getline(ipstream, campaignEndText[2]);
+    }
     ipstream.close();
 
     std::ifstream test(Folders::getResourcePath("Textures/" + Account::active().getCurrentCampaign() + "/World.png"));
index 77eb313aa11eb1c32307c2127410f139faac81b2..a9b83439da6a5b1bf23b1afe6e7d16524d95e782 100644 (file)
@@ -26,6 +26,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 extern bool campaign;
 
 extern int actuallevel;
+extern std::string campaignEndText[3];
 
 std::vector<std::string> ListCampaigns();
 void LoadCampaign();
index b181769562e05babc5327ea7298dfccb650bf4d1..1fbecd21644384e4a019444c8bbe05fccee5c514 100644 (file)
@@ -501,9 +501,9 @@ void Menu::Load()
             addButton(numchallengelevels, "Back", 10, 10);
             break;
         case 10: {
-            addLabel(0, "Congratulations!", 220, 330);
-            addLabel(1, "You have avenged your family and", 140, 300);
-            addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
+            addLabel(0, campaignEndText[0], 220, 330);
+            addLabel(1, campaignEndText[1], 140, 300);
+            addLabel(2, campaignEndText[2], 110, 270);
             addButton(3, "Back", 10, 10);
             addLabel(4, string("Your score:         ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
             addLabel(5, string("Highest score:      ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);