Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10480 for code


Ignore:
Timestamp:
May 25, 2015, 9:01:33 PM (9 years ago)
Author:
landauf
Message:

removed dependency of Language on CoreConfig.

Location:
code/branches/core7/src/libraries/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/Core.cc

    r10479 r10480  
    182182        orxout(internal_info) << "configuring Core" << endl;
    183183        this->config_ = new CoreConfig();
    184         this->config_->setConfigValues(); // TODO: move this into CoreConfig constructor (but resolve dependency to Language)
    185184
    186185        // Set the correct log path and rewrite the log file with the correct log levels
  • code/branches/core7/src/libraries/core/CoreConfig.cc

    r10479 r10480  
    4747    {
    4848        RegisterObject(CoreConfig);
     49        this->setConfigValues();
    4950    }
    5051
     
    114115    {
    115116        // Read the translation file after the language was configured
    116         Language::getInstance().readTranslatedLanguageFile();
     117        bool success = Language::getInstance().readTranslatedLanguageFile(this->language_);
     118        if (!success)
     119        {
     120            // Set the language in the config-file back to the default.
     121            ResetConfigValue(language_);
     122            orxout(internal_info, context::language) << "Reset language to " << this->language_ << '.' << endl;
     123        }
    117124    }
    118125
     
    126133            bInitialized = true;
    127134        }
    128     }
    129 
    130     //! Sets the language in the config-file back to the default.
    131     void CoreConfig::resetLanguage()
    132     {
    133         ResetConfigValue(language_);
    134135    }
    135136
  • code/branches/core7/src/libraries/core/CoreConfig.h

    r10479 r10480  
    4747                { return this->bDevMode_; }
    4848
    49             //! Returns the configured language.
    50             const std::string& getLanguage()
    51                 { return this->language_; }
    52             void resetLanguage();
    53 
    5449            inline bool getStartIOConsole() const
    5550                { return this->bStartIOConsole_; }
  • code/branches/core7/src/libraries/core/Language.cc

    r10479 r10480  
    3737#include "util/Output.h"
    3838#include "util/StringUtils.h"
    39 #include "Core.h"
    4039#include "PathConfig.h"
    4140
     
    247246    /**
    248247        @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
    249     */
    250     void Language::readTranslatedLanguageFile()
    251     {
    252         orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getConfig()->getLanguage() << ")." << endl;
    253 
    254         const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getConfig()->getLanguage());
     248        @return Returns false if the language file couldn't be found.
     249    */
     250    bool Language::readTranslatedLanguageFile(const std::string& language)
     251    {
     252        orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl;
     253
     254        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(language);
    255255
    256256        // Open the file
     
    261261        {
    262262            orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
    263             orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getConfig()->getLanguage()) << " to read the translated language entries!" << endl;
    264             Core::getInstance().getConfig()->resetLanguage();
    265             orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl;
    266             return;
     263            orxout(internal_error, context::language) << "Couldn't open file " << getFilename(language) << " to read the translated language entries!" << endl;
     264            return false;
    267265        }
    268266
     
    291289                else
    292290                {
    293                     orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getConfig()->getLanguage()) << endl;
     291                    orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(language) << endl;
    294292                }
    295293            }
     
    297295
    298296        file.close();
     297        return true;
    299298    }
    300299
  • code/branches/core7/src/libraries/core/Language.h

    r10479 r10480  
    174174
    175175            void readDefaultLanguageFile();
    176             void readTranslatedLanguageFile();
     176            bool readTranslatedLanguageFile(const std::string& language);
    177177            void writeDefaultLanguageFile() const;
    178178            static std::string getFilename(const std::string& language);
Note: See TracChangeset for help on using the changeset viewer.