From: Côme Chilliet Date: Mon, 23 Jan 2017 17:11:13 +0000 (+0100) Subject: Reading the campaign end text from campaign file (see #60) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=f4bb5680c5056f3df67e0068b10f267a91268874;p=lugaru.git Reading the campaign end text from campaign file (see #60) --- diff --git a/Data/Campaigns/main.txt b/Data/Campaigns/main.txt index 083b8b2..677d2eb 100644 --- a/Data/Campaigns/main.txt +++ b/Data/Campaigns/main.txt @@ -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. diff --git a/Data/Campaigns/seventasks.txt b/Data/Campaigns/seventasks.txt index d616305..70b2aed 100644 --- a/Data/Campaigns/seventasks.txt +++ b/Data/Campaigns/seventasks.txt @@ -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 diff --git a/Source/Level/Campaign.cpp b/Source/Level/Campaign.cpp index 410abcc..02072d0 100644 --- a/Source/Level/Campaign.cpp +++ b/Source/Level/Campaign.cpp @@ -32,6 +32,7 @@ std::vector campaignlevels; bool campaign = false; int actuallevel = 0; +std::string campaignEndText[3]; std::vector 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")); diff --git a/Source/Level/Campaign.hpp b/Source/Level/Campaign.hpp index 77eb313..a9b8343 100644 --- a/Source/Level/Campaign.hpp +++ b/Source/Level/Campaign.hpp @@ -26,6 +26,7 @@ along with Lugaru. If not, see . extern bool campaign; extern int actuallevel; +extern std::string campaignEndText[3]; std::vector ListCampaigns(); void LoadCampaign(); diff --git a/Source/Menu/Menu.cpp b/Source/Menu/Menu.cpp index b181769..1fbecd2 100644 --- a/Source/Menu/Menu.cpp +++ b/Source/Menu/Menu.cpp @@ -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);