def update_languages(self, data=None): if data is None: data = self._setting.get(UH_MODULE, "Language") languages_map = dict(find_available_languages()) languages_map['System default'] = '' symbol = None if data == unicode('System default'): symbol = 'System default' else: for key, value in LANGUAGENAMES.iteritems(): if value == data: symbol = key assert symbol is not None, "Something went badly wrong with the translation update!" + \ " Searching for: " + str(data) + " in " + str(LANGUAGENAMES) index = sorted(languages_map.keys()).index(symbol) name, position = sorted(languages_map.items())[index] try: if name != 'System default': trans = gettext.translation('unknownhorizons', position, languages=[name]) trans.install(unicode=1) else: gettext.install('unknownhorizons', 'build/mo', unicode=1) name = '' except IOError: print _("Configured language %(lang)s at %(place)s could not be loaded") % {'lang': settings.language.name, 'place': settings.language.position} install('unknownhorizons', 'build/mo', unicode=1) self._setting.set(UH_MODULE, "Language", 'System default') update_all_translations()
def _setup_settings(self): self._setting = Setting(app_name="unknownhorizons", settings_file=PATHS.USER_CONFIG_FILE, settings_gui_xml="content/gui/settings.xml", changes_gui_xml="content/gui/requirerestart.xml") self._setting.setGuiStyle("book") #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval", initialdata=range(0, 60, 2)) self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount", initialdata=range(1, 30)) self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount", initialdata=range(1, 30)) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages_map = dict(find_available_languages()) languages_map[_('System default')] = '' self._setting.createAndAddEntry(UH_MODULE, "Language", "language", applyfunction=self.update_languages, initialdata= [LANGUAGENAMES[x] for x in sorted(languages_map.keys())]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=lambda x: self.set_volume_music(x)) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=lambda x: self.set_volume_effects(x)) self._setting.entries[FIFE_MODULE]['PlaySounds'].applyfunction = lambda x: self.setup_sound() self._setting.entries[FIFE_MODULE]['PlaySounds'].requiresrestart = False
def update_languages(self, data=None): """ Load/Change language of Unknown Horizons. Called on startup and when changing the language. data is used when changing the language in the settings menu. """ if data is None: data = self._setting.get(UH_MODULE, "Language") languages_map = dict(find_available_languages()) languages_map['System default'] = '' # English is not shipped as .mo file. languages_map['en'] = '' symbol = None if data == unicode('System default'): symbol = 'System default' else: for key, value in LANGUAGENAMES.iteritems(): if value == data: symbol = key assert symbol is not None, "Something went badly wrong with the translation update!" + \ " Searching for: " + str(data) + " in " + str(LANGUAGENAMES) try: index = sorted(languages_map.keys()).index(symbol) # This only happens on startup when the language is not available # (either from the settings file or $LANG). except ValueError: print "Language %s is not available!" % data index = sorted(languages_map.keys()).index('System default') # Reset the language or the settings crashes. self._setting.set(UH_MODULE, "Language", 'System default') name, position = sorted(languages_map.items())[index] try: if name != 'System default': # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = name == 'en' trans = gettext.translation('unknownhorizons', position, languages=[name], fallback=fallback) trans.install(unicode=True) else: gettext.install('unknownhorizons', 'build/mo', unicode=True) name = '' except IOError: print _( "Configured language %(lang)s at %(place)s could not be loaded" ) % { 'lang': name, 'place': position } gettext.install('unknownhorizons', 'build/mo', unicode=True) self._setting.set(UH_MODULE, "Language", 'System default') update_all_translations()
def change_language(language=None): """Load/change the language of Unknown Horizons. Called on startup and when changing the language in the settings menu. """ if language: # non-default try: # NOTE about gettext fallback mechanism: # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = (language == 'en') trans = gettext.translation('unknown-horizons', find_available_languages()[language], languages=[language], fallback=fallback) trans.install(unicode=True, names=[ 'ngettext', ]) except (IOError, KeyError, ValueError) as err: # KeyError can happen with a settings file written to by more than one UH # installation (one that has compiled language files and one that hasn't) # ValueError can be raised by gettext if for instance the plural forms are # corrupted. log.warning("Configured language %s could not be loaded.", language) log.warning("Error: %s", err) log.warning("Continuing with English as fallback.") horizons.globals.fife.set_uh_setting('Language', LANGUAGENAMES['']) return change_language() # recurse else: # default locale if platform.system( ) == "Windows": # win doesn't set the language variable by default os.environ['LANGUAGE'] = locale.getdefaultlocale()[0] gettext.install('unknown-horizons', 'content/lang', unicode=True, names=[ 'ngettext', ]) # expose the plural-aware translate function as builtin N_ (gettext does the same to _) import __builtin__ __builtin__.__dict__['N_'] = __builtin__.__dict__['ngettext'] # update fonts new_locale = language or horizons.globals.fife.get_locale() fontdef = get_fontdef_for_locale(new_locale) horizons.globals.fife.pychan.loadFonts(fontdef) # dynamically reset all translations of active widgets update_all_translations() LanguageChanged.broadcast(None)
def update_languages(self, data=None): """ Load/Change language of Unknown Horizons. Called on startup and when changing the language. data is used when changing the language in the settings menu. """ if data is None: data = self._setting.get(UH_MODULE, "Language") languages_map = dict(find_available_languages()) languages_map['System default'] = '' # English is not shipped as .mo file. languages_map['en'] = '' symbol = None if data == unicode('System default'): symbol = 'System default' else: for key, value in LANGUAGENAMES.iteritems(): if value == data: symbol = key assert symbol is not None, "Something went badly wrong with the translation update!" + \ " Searching for: " + str(data) + " in " + str(LANGUAGENAMES) try: index = sorted(languages_map.keys()).index(symbol) # This only happens on startup when the language is not available # (either from the settings file or $LANG). except ValueError: print "Language %s is not available!" % data index = sorted(languages_map.keys()).index('System default') # Reset the language or the settings crashes. self._setting.set(UH_MODULE, "Language", 'System default') name, position = sorted(languages_map.items())[index] try: if name != 'System default': # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = name == 'en' trans = gettext.translation('unknown-horizons', position, languages=[name], fallback=fallback) trans.install(unicode=True, names=['ngettext',]) else: if platform.system() == "Windows": # win doesn't set the language variable by default os.environ[ 'LANGUAGE' ] = locale.getdefaultlocale()[0] gettext.install('unknown-horizons', 'content/lang', unicode=True, names=['ngettext',]) name = '' except IOError: print _("Configured language %(lang)s at %(place)s could not be loaded") % {'lang': name, 'place': position} gettext.install('unknown-horizons', 'content/lang', unicode=True, names=['ngettext',]) self._setting.set(UH_MODULE, "Language", 'System default') update_all_translations()
def add_settings(self): # TODO: find a way to apply changing to a running game in a clean fashion # possibility: use singaling via changelistener def update_minimap(*args): try: horizons.main._modules.session.ingame_gui.minimap.draw() except AttributeError: pass # session or gui not yet initialised def update_autosave_interval(*args): try: horizons.main._modules.session.reset_autosave() except AttributeError: pass # session or gui not yet initialised #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval", applyfunction=update_autosave_interval) self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "EdgeScrolling", "edgescrolling") self._setting.createAndAddEntry(UH_MODULE, "UninterruptedBuilding", "uninterrupted_building") self._setting.createAndAddEntry(UH_MODULE, "AutoUnload", "auto_unload") self._setting.createAndAddEntry(UH_MODULE, "MinimapRotation", "minimaprotation", \ applyfunction=update_minimap) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages = find_available_languages().keys() self._setting.createAndAddEntry(UH_MODULE, "Language", "cjkv_language", applyfunction=self.update_languages, initialdata= [LANGUAGENAMES[x] for x in sorted(languages)]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=self.set_volume_music) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=self.set_volume_effects) self._setting.createAndAddEntry(UH_MODULE, "NetworkPort", "network_port", applyfunction=self.set_network_port) self._setting.createAndAddEntry(UH_MODULE, "DebugLog", "debug_log", applyfunction=self.set_debug_log) self._setting.entries[FIFE_MODULE]['PlaySounds'].applyfunction = lambda x: self.engine.sound.setup_sound() self._setting.entries[FIFE_MODULE]['PlaySounds'].requiresrestart = False self._setting.entries[FIFE_MODULE]['RenderBackend'].applyfunction = lambda x: self._show_renderbackend_warning() self._setting.createAndAddEntry(FIFE_MODULE, "MouseSensitivity", "mousesensitivity", \ #read comment in set_mouse_sensitivity function about this #applyfunction=self.set_mouse_sensitivity, \ requiresrestart=True)
def setup_i18n(self): domain = 'unknown-horizons-server' for lang, dir in find_available_languages(domain).items(): if len(dir) <= 0: continue try: self.i18n[lang] = gettext.translation(domain, dir, [lang]) except IOError: pass import __builtin__ __builtin__.__dict__['S_'] = self.gettext __builtin__.__dict__['SN_'] = self.ngettext __builtin__.__dict__['__'] = lambda x : x
def setup_i18n(self): domain = 'unknown-horizons-server' for lang, dir in find_available_languages(domain).items(): if len(dir) <= 0: continue try: self.i18n[lang] = gettext.translation(domain, dir, [lang]) except IOError: pass import __builtin__ __builtin__.__dict__['S_'] = self.gettext __builtin__.__dict__['SN_'] = self.ngettext __builtin__.__dict__['__'] = lambda x: x
def _setup_settings(self): self._setting = LocalizedSetting(app_name="unknownhorizons", settings_file=PATHS.USER_CONFIG_FILE, settings_gui_xml="settings.xml", changes_gui_xml="requirerestart.xml") # TODO: find a way to apply changing to a running game in a clean fashion # possibility: use singaling via changelistener def update_minimap(*args): try: horizons.main._modules.session.ingame_gui.minimap.draw() except AttributeError: pass # session or gui not yet initialised def update_autosave_interval(*args): try: horizons.main._modules.session.reset_autosave() except AttributeError: pass # session or gui not yet initialised #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval", applyfunction=update_autosave_interval) self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "EdgeScrolling", "edgescrolling") self._setting.createAndAddEntry(UH_MODULE, "MinimapRotation", "minimaprotation", \ applyfunction=update_minimap) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages_map = dict(find_available_languages()) languages_map[_('System default')] = '' # English is not shipped as .mo file. languages_map['en'] = '' self._setting.createAndAddEntry(UH_MODULE, "Language", "language", applyfunction=self.update_languages, initialdata= [LANGUAGENAMES[x] for x in sorted(languages_map.keys())]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=self.set_volume_music) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=self.set_volume_effects) self._setting.createAndAddEntry(UH_MODULE, "NetworkPort", "network_port", applyfunction=self.set_network_port) self._setting.entries[FIFE_MODULE]['PlaySounds'].applyfunction = lambda x: self.setup_sound() self._setting.entries[FIFE_MODULE]['PlaySounds'].requiresrestart = False self._setting.entries[FIFE_MODULE]['RenderBackend'].applyfunction = lambda x: self._show_renderbackend_warning()
def change_language(language=None): """Load/change the language of Unknown Horizons. Called on startup and when changing the language in the settings menu. """ if language: # non-default try: # NOTE about gettext fallback mechanism: # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = (language == 'en') trans = gettext.translation('unknown-horizons', find_available_languages()[language], languages=[language], fallback=fallback) trans.install(unicode=True, names=['ngettext',]) except (IOError, KeyError, ValueError) as err: # KeyError can happen with a settings file written to by more than one UH # installation (one that has compiled language files and one that hasn't) # ValueError can be raised by gettext if for instance the plural forms are # corrupted. log.warning("Configured language %s could not be loaded.", language) log.warning("Error: %s", err) log.warning("Continuing with English as fallback.") horizons.globals.fife.set_uh_setting('Language', LANGUAGENAMES['']) return change_language() # recurse else: # default locale if platform.system() == "Windows": # win doesn't set the language variable by default os.environ['LANGUAGE'] = locale.getdefaultlocale()[0] gettext.install('unknown-horizons', 'content/lang', unicode=True, names=['ngettext',]) # expose the plural-aware translate function as builtin N_ (gettext does the same to _) import __builtin__ __builtin__.__dict__['N_'] = __builtin__.__dict__['ngettext'] # update fonts new_locale = language or horizons.globals.fife.get_locale() fontdef = get_fontdef_for_locale(new_locale) horizons.globals.fife.pychan.loadFonts(fontdef) # dynamically reset all translations of active widgets update_all_translations() LanguageChanged.broadcast(None)
def _setup_settings(self): self._setting = LocalizedSetting(app_name="unknownhorizons", settings_file=PATHS.USER_CONFIG_FILE, settings_gui_xml="settings.xml", changes_gui_xml="requirerestart.xml") self._setting.setGuiStyle("book") #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval") self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "EdgeScrolling", "edgescrolling") def update_minimap(*args): # sry for this gross violation of the encapsulation principle try: horizons.main._modules.session.ingame_gui.minimap.draw() except AttributeError: pass # session or gui not yet initialised self._setting.createAndAddEntry(UH_MODULE, "MinimapRotation", "minimaprotation", \ applyfunction=update_minimap) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages_map = dict(find_available_languages()) languages_map[_('System default')] = '' # English is not shipped as .mo file. languages_map['en'] = '' self._setting.createAndAddEntry(UH_MODULE, "Language", "language", applyfunction=self.update_languages, initialdata= [LANGUAGENAMES[x] for x in sorted(languages_map.keys())]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=lambda x: self.set_volume_music(x)) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=lambda x: self.set_volume_effects(x)) self._setting.entries[FIFE_MODULE]['PlaySounds'].applyfunction = lambda x: self.setup_sound() self._setting.entries[FIFE_MODULE]['PlaySounds'].requiresrestart = False self._setting.entries[FIFE_MODULE]['RenderBackend'].applyfunction = lambda x: self._show_renderbackend_warning()
def update_languages(self, data=None): """ Load/Change language of Unknown Horizons. Called on startup and when changing the language. data is used when changing the language in the settings menu. """ if data is None: data = self._setting.get(UH_MODULE, "Language") # get language key symbol = LANGUAGENAMES.get_by_value(data) if symbol != '': # non-default try: # NOTE about gettext fallback mechanism: # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = (symbol == 'en') trans = gettext.translation('unknown-horizons', find_available_languages()[symbol], \ languages=[symbol], fallback=fallback) trans.install(unicode=True, names=['ngettext',]) except IOError: #xgettext:python-format print _("Configured language {lang} could not be loaded").format(lang=symbol) self._setting.set(UH_MODULE, "Language", LANGUAGENAMES['']) return self.update_languages() # recurse else: # default locale if platform.system() == "Windows": # win doesn't set the language variable by default os.environ[ 'LANGUAGE' ] = locale.getdefaultlocale()[0] gettext.install('unknown-horizons', 'content/lang', unicode=True, names=['ngettext',]) # update fonts fontdef = get_fontdef_for_locale(symbol) self.engine.pychan.loadFonts(fontdef) # dynamically reset all translations of active widgets update_all_translations()
def change_language(language=None): """Load/change the language of Unknown Horizons. Called on startup and when changing the language in the settings menu. """ if language: # non-default try: # NOTE about gettext fallback mechanism: # English is not shipped as .mo file, thus if English is # selected we use NullTranslations to get English output. fallback = language == "en" trans = gettext.translation( "unknown-horizons", find_available_languages()[language], languages=[language], fallback=fallback ) trans.install(unicode=True, names=["ngettext"]) except IOError: # xgettext:python-format print "Configured language {lang} could not be loaded.".format(lang=language) horizons.globals.fife.set_uh_setting("Language", LANGUAGENAMES[""]) return change_language() # recurse else: # default locale if platform.system() == "Windows": # win doesn't set the language variable by default os.environ["LANGUAGE"] = locale.getdefaultlocale()[0] gettext.install("unknown-horizons", "content/lang", unicode=True, names=["ngettext"]) # expose the plural-aware translate function as builtin N_ (gettext does the same to _) import __builtin__ __builtin__.__dict__["N_"] = __builtin__.__dict__["ngettext"] # update fonts fontdef = get_fontdef_for_locale(language or horizons.globals.fife.get_locale()) horizons.globals.fife.pychan.loadFonts(fontdef) # dynamically reset all translations of active widgets update_all_translations()
def _setup_settings(self, check_file_version=True): _user_config_file = os.path.join( os.getcwd(), PATHS.USER_CONFIG_FILE ) if not os.path.exists(_user_config_file): check_file_version = False if check_file_version: # check if user settings file is the current one # NOTE: SimpleXMLSerializer can't handle relative paths, it fails silently # (although the doc states otherwise) - thus translate paths to absolute ones user_config_parser = SimpleXMLSerializer( _user_config_file ) user_settings_version = user_config_parser.get("meta", "SettingsVersion", -1) _template_config_file = os.path.join( os.getcwd(), PATHS.CONFIG_TEMPLATE_FILE ) template_config_parser = SimpleXMLSerializer( _template_config_file ) template_settings_version = template_config_parser.get("meta", "SettingsVersion") if template_settings_version > user_settings_version: # we have to update the file # create settings so we have a list of all settings self._setup_settings(check_file_version=False) # save settings here entries = [] def update_value(modulename, entryname): # retrieve values from loaded settings file try: value = self._setting.get(modulename, entryname) except UnicodeEncodeError: # this can happen when unicode data is saved as str value = "default" entries.append( (modulename, entryname, value ) ) # update known settings and unreferenced settings for modulename, module in self._setting.entries.iteritems(): for entryname in module.iterkeys(): update_value(modulename, entryname) for modulename, entry_list in self.UNREFERENCED_SETTINGS.iteritems(): for entryname in entry_list: update_value(modulename, entryname) # write actual new file shutil.copy( PATHS.CONFIG_TEMPLATE_FILE, PATHS.USER_CONFIG_FILE ) user_config_parser = SimpleXMLSerializer( _user_config_file ) for modulename, entryname, value in entries: user_config_parser.set(modulename, entryname, value) user_config_parser.save() self._setting = LocalizedSetting(app_name=UH_MODULE, settings_file=PATHS.USER_CONFIG_FILE, settings_gui_xml="settings.xml", changes_gui_xml="requirerestart.xml", default_settings_file=PATHS.CONFIG_TEMPLATE_FILE) # TODO: find a way to apply changing to a running game in a clean fashion # possibility: use singaling via changelistener def update_minimap(*args): try: horizons.main._modules.session.ingame_gui.minimap.draw() except AttributeError: pass # session or gui not yet initialised def update_autosave_interval(*args): try: horizons.main._modules.session.reset_autosave() except AttributeError: pass # session or gui not yet initialised #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval", applyfunction=update_autosave_interval) self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "EdgeScrolling", "edgescrolling") self._setting.createAndAddEntry(UH_MODULE, "UninterruptedBuilding", "uninterrupted_building") self._setting.createAndAddEntry(UH_MODULE, "MinimapRotation", "minimaprotation", \ applyfunction=update_minimap) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages_map = dict(find_available_languages()) languages_map[_('System default')] = '' # English is not shipped as .mo file. languages_map['en'] = '' self._setting.createAndAddEntry(UH_MODULE, "Language", "language", applyfunction=self.update_languages, initialdata= [LANGUAGENAMES[x] for x in sorted(languages_map.keys())]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=self.set_volume_music) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=self.set_volume_effects) self._setting.createAndAddEntry(UH_MODULE, "NetworkPort", "network_port", applyfunction=self.set_network_port) self._setting.entries[FIFE_MODULE]['PlaySounds'].applyfunction = lambda x: self.setup_sound() self._setting.entries[FIFE_MODULE]['PlaySounds'].requiresrestart = False self._setting.entries[FIFE_MODULE]['RenderBackend'].applyfunction = lambda x: self._show_renderbackend_warning()
def _setup_settings(self): self._setting = LocalizedSetting(app_name="unknownhorizons", settings_file=PATHS.USER_CONFIG_FILE, settings_gui_xml="settings.xml", changes_gui_xml="requirerestart.xml") self._setting.setGuiStyle("book") #self.createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False) self._setting.createAndAddEntry(UH_MODULE, "AutosaveInterval", "autosaveinterval") self._setting.createAndAddEntry(UH_MODULE, "AutosaveMaxCount", "autosavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "QuicksaveMaxCount", "quicksavemaxcount") self._setting.createAndAddEntry(UH_MODULE, "EdgeScrolling", "edgescrolling") def update_minimap(*args): # sry for this gross violation of the encapsulation principle try: horizons.main._modules.session.ingame_gui.minimap.draw() except AttributeError: pass # session or gui not yet initialised self._setting.createAndAddEntry(UH_MODULE, "MinimapRotation", "minimaprotation", \ applyfunction=update_minimap) self._setting.createAndAddEntry(FIFE_MODULE, "BitsPerPixel", "screen_bpp", initialdata=[0, 16, 32], requiresrestart=True) languages_map = dict(find_available_languages()) languages_map[_('System default')] = '' # English is not shipped as .mo file. languages_map['en'] = '' self._setting.createAndAddEntry( UH_MODULE, "Language", "language", applyfunction=self.update_languages, initialdata=[ LANGUAGENAMES[x] for x in sorted(languages_map.keys()) ]) self._setting.createAndAddEntry(UH_MODULE, "VolumeMusic", "volume_music", applyfunction=self.set_volume_music) self._setting.createAndAddEntry(UH_MODULE, "VolumeEffects", "volume_effects", applyfunction=self.set_volume_effects) self._setting.createAndAddEntry(UH_MODULE, "NetworkPort", "network_port", applyfunction=self.set_network_port) self._setting.entries[FIFE_MODULE][ 'PlaySounds'].applyfunction = lambda x: self.setup_sound() self._setting.entries[FIFE_MODULE][ 'PlaySounds'].requiresrestart = False self._setting.entries[FIFE_MODULE][ 'RenderBackend'].applyfunction = lambda x: self._show_renderbackend_warning( )