Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5231: Move files around and split .cpp files across the class border.
- Loading branch information
1 parent
9f917c9
commit 6cbf5e5
Showing
7 changed files
with
108 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "LocalisationModule.h" | ||
|
||
#include "i18n.h" | ||
#include "ipreferencesystem.h" | ||
#include "registry/registry.h" | ||
|
||
#include "module/StaticModule.h" | ||
#include "LocalisationProvider.h" | ||
|
||
namespace settings | ||
{ | ||
|
||
const std::string& LocalisationModule::getName() const | ||
{ | ||
static std::string _name("LocalisationModule"); | ||
return _name; | ||
} | ||
|
||
const StringSet& LocalisationModule::getDependencies() const | ||
{ | ||
static StringSet _dependencies; | ||
|
||
if (_dependencies.empty()) | ||
{ | ||
_dependencies.insert(MODULE_PREFERENCESYSTEM); | ||
_dependencies.insert(MODULE_XMLREGISTRY); | ||
} | ||
|
||
return _dependencies; | ||
} | ||
|
||
void LocalisationModule::initialiseModule(const ApplicationContext& ctx) | ||
{ | ||
rMessage() << getName() << "::initialiseModule called" << std::endl; | ||
|
||
// Construct the list of available languages | ||
ComboBoxValueList langs; | ||
|
||
LocalisationProvider::Instance()->foreachAvailableLanguage([&](const LocalisationProvider::Language& lang) | ||
{ | ||
langs.emplace_back(lang.twoDigitCode + " - " + lang.displayName); | ||
}); | ||
|
||
auto registryKey = LocalisationProvider::RKEY_LANGUAGE; | ||
|
||
// Load the currently selected index into the registry | ||
registry::setValue(registryKey, LocalisationProvider::Instance()->getCurrentLanguageIndex()); | ||
GlobalRegistry().setAttribute(registryKey, "volatile", "1"); // don't save this to user.xml | ||
|
||
// Add Preferences | ||
IPreferencePage& page = GlobalPreferenceSystem().getPage(_("Settings/Language")); | ||
page.appendCombo(_("Language"), registryKey, langs); | ||
|
||
page.appendLabel(_("<b>Note:</b> You'll need to restart DarkRadiant\nafter changing the language setting.")); | ||
} | ||
|
||
void LocalisationModule::shutdownModule() | ||
{ | ||
LocalisationProvider::Instance()->saveLanguageSetting(); | ||
} | ||
|
||
module::StaticModule<LocalisationModule> localisationModule; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include "imodule.h" | ||
|
||
namespace settings | ||
{ | ||
|
||
// Localisation module, taking care of the Language Preferences page | ||
class LocalisationModule : | ||
public RegisterableModule | ||
{ | ||
public: | ||
const std::string& getName() const override; | ||
const StringSet& getDependencies() const override; | ||
void initialiseModule(const ApplicationContext& ctx) override; | ||
void shutdownModule() override; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters