Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 3, 2015, 11:38:07 PM (9 years ago)
Author:
landauf
Message:

improved campaign mode. use config value instead of writing a new file.
moved configuration of campaign (the list of missions) from the lua file to the default config. you need to delete your local orxonox.ini in order to see the changes.

Location:
code/branches/storymodeHS14/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/storymodeHS14/src/orxonox/LevelManager.cc

    r9667 r10253  
    8989        SetConfigValue(defaultLevelName_, "missionOne.oxw")
    9090            .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);
    91103    }
    92104
  • code/branches/storymodeHS14/src/orxonox/LevelManager.h

    r9667 r10253  
    9191            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
    9292
     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
    93102            /**
    94103            @brief Get the instance of the LevelManager.
     
    116125            // config values
    117126            std::string defaultLevelName_;
     127            std::string lastFinishedCampaignMission_;
     128            std::vector<std::string> campaignMissions_;
    118129
    119130            static LevelManager* singletonPtr_s;
  • code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc

    r10251 r10253  
    3636#include "core/CoreIncludes.h"
    3737#include "core/command/ConsoleCommand.h"
     38#include "core/config/ConfigValueIncludes.h"
    3839#include "infos/PlayerInfo.h"
    3940#include "network/Host.h"
    4041#include "worldentities/pawns/Pawn.h"
    41 #include <iostream>
    42 #include <fstream>
    43 #include <string>
    44 #include <ios>
     42#include "LevelManager.h"
    4543
    4644namespace orxonox
     
    9391    }
    9492
    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 
    10793    void Mission::end()
    10894    {
     
    11298            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    11399
    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());
    145101        }
    146102
Note: See TracChangeset for help on using the changeset viewer.