当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLSerializer.get方法代码示例

本文整理汇总了Python中fife.extensions.serializers.simplexml.SimpleXMLSerializer.get方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLSerializer.get方法的具体用法?Python SimpleXMLSerializer.get怎么用?Python SimpleXMLSerializer.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fife.extensions.serializers.simplexml.SimpleXMLSerializer的用法示例。


在下文中一共展示了SimpleXMLSerializer.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_project

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
    def new_project(self, settings_path, values):
        """Create a mew project and load it

        Args:
            settings_path: The path to the new settings file

            values: The starting values of the project.
        """
        import tkinter.messagebox
        settings_file = open(settings_path, "w")
        settings_file.write(BASIC_SETTINGS)
        settings_file.close()
        project = SimpleXMLSerializer(settings_path)
        project.load()
        update_settings(project, values)
        project.save()
        comp_file = project.get("fife-rpg", "ComponentsFile")
        act_file = comp_file or project.get("fife-rpg", "ActionsFile")
        syst_file = act_file or project.get("fife-rpg", "SystemsFile")
        beh_file = syst_file or project.get("fife-rpg", "BehavioursFile")
        comb_file = beh_file or project.get("fife-rpg", "CombinedFile")
        if not comb_file:
            dest = os.path.join(os.path.dirname(settings_path),
                                "combined.yaml")
            shutil.copy("combined.yaml.template", dest)
        self.try_load_project(settings_path)
        tkinter.messagebox.showinfo(_("Project created"),
                              _("Project successfully created"))
        self.editor_gui.enable_menus()
        self.project_changed = False
        self.entity_changed = False
开发者ID:fife-rpg,项目名称:editor,代码行数:33,代码来源:fife_rpg_editor.py

示例2: createPlayerObject

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
	def createPlayerObject(self):
		"""
		@todo: once we have all art assets this should be able to load one of 3 player models
		"""
		modeldict = self._modelsettings.get("models", "Player", {})
	
		print('loading: %s' % modeldict["file"])
		self._loader.loadImportFile(modeldict["file"])
		self._player = Player(self._gamecontroller, self.actorlayer, "warrior")
		
		playerfilename = os.path.join("saves", "player_save.xml")
		
		if os.path.isfile(playerfilename):
			player_settings = SimpleXMLSerializer(playerfilename)
			pvals = player_settings.get("player", "player", {})
			self._player.deserialize(pvals)
开发者ID:fifengine,项目名称:fifengine-demos,代码行数:18,代码来源:scene.py

示例3: convert_fife_project

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
    def convert_fife_project(self, project_filepath):
        """Converts a fife settings file to a fife-rpg project

        Args:
            Project_filepath: Path to the fife settings file
        """
        project = SimpleXMLSerializer(project_filepath)

        bak_file = "%s.bak" % project_filepath
        project.save(bak_file)
        settings = {}
        settings["ProjectName"] = project.get("FIFE", "WindowTitle", "")
        update_settings(project, settings)
        if not self.edit_project_settings(project_filepath, project):
            return None
        project.save()
        return bak_file
开发者ID:fife-rpg,项目名称:editor,代码行数:19,代码来源:fife_rpg_editor.py

示例4: _setup_settings

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
	def _setup_settings(self, check_file_version=True):
		_user_config_file = os.path.join( os.getcwd(), PATHS.USER_CONFIG_FILE )
		if check_file_version and os.path.exists(_user_config_file):
			# 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
				print 'Discovered old settings file, auto-upgrading: %s -> %s' % \
				      (user_settings_version, template_settings_version)
				# create settings so we have a list of all settings
				self._setup_settings(check_file_version=False)

				# save settings here
				entries = []

				# need safe default value
				default_value = object()

				def update_value(modulename, entryname):
					# retrieve values from loaded settings file
					try:
						value = self._setting.get(modulename, entryname, default_value)
					except UnicodeEncodeError: # this can happen when unicode data is saved as str
						value = "default"
					if value is not default_value:
						entries.append( (modulename, entryname, value ) )

				# collect values from 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)

				# patch old values
				if user_settings_version <= 10:
					old_entries = entries
					entries = []
					for i in old_entries:
						if i[0] == UH_MODULE and i[1] == "Language":
							entries.append( (i[0], i[1], LANGUAGENAMES.get_by_value(i[2])) )
						else:
							entries.append(i)

				# 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 = SettingsDialog(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)

		self._setting_handler.add_settings()
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:68,代码来源:engine.py

示例5: __init__

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class Settings:

	# Settings key storing the SettingsVersion used to upgrade settings
	SETTINGS_VERSION = "SettingsVersion"

	def __init__(self, settings_file, settings_template_file):
		self._module_settings = {}
		self._module_settings_template = {}
		self._settings_file = settings_file
		self._settings_template_file = settings_template_file
		self._settings_serializer = SimpleXMLSerializer()
		self._settings_serializer.load(settings_file)
		self._settings_template_serializer = SimpleXMLSerializer()
		self._settings_template_serializer.load(settings_template_file)
		if not hasattr(self._settings_template_serializer, 'getModuleName'):
			# Renamed after 0.3.5: https://github.com/fifengine/fifengine/issues/819.
			new_api = self._settings_template_serializer.getModuleNameList
			self._settings_template_serializer.getModuleName = new_api
		self.upgrade_settings()

	def get(self, module, name, default=None):
		if default is None:
			default = self._settings_template_serializer.get(module, name)

		v = self._settings_serializer.get(module, name, default)
		getter = getattr(self, 'get_' + module + '_' + name, None)
		if getter:
			return getter(v)
		else:
			return v

	def set(self, module, name, value):
		setter = getattr(self, 'set_' + module + '_' + name, None)
		if setter:
			value = setter(value)

		# This is necessary, as empty fields return None, but saving
		# None will result in the String 'None' being stored
		if value is None:
			value = ''

		if module in self._module_settings:
			self._module_settings[module][name] = value

		self._settings_serializer.set(module, name, value, {})

	def get_module_settings(self, module):
		self._module_settings[module] = self._settings_serializer.getAllSettings(module)
		self._module_settings_template[module] = self._settings_template_serializer.getAllSettings(module)
		for name, value in self._module_settings_template[module].items():
			if name not in self._module_settings[module]:
				self._module_settings[module][name] = value
		return self._module_settings[module]

	def get_module_template_settings(self, module):
		return self._settings_template_serializer.getAllSettings(module)

	def save(self):
		self._settings_serializer.save(self._settings_file)

	def apply(self):
		data = self.get(SETTINGS.UH_MODULE, "Language")
		language = LANGUAGENAMES.get_by_value(data)
		change_language(language)

	def set_defaults(self):
		for module in self._settings_template_serializer.getModuleName():
			for setting_name in self._settings_template_serializer.getAllSettings(module):
				value = self._settings_template_serializer.get(module, setting_name)
				self.set(module, setting_name, value)
		self.save()

	def upgrade_settings(self):
		"""Upgrades the settings to a newer version necessary."""
		# if the settings file doesn't exist, force an update with
		# settings version 1 as default value
		current_version = self.get(SETTINGS.META_MODULE, self.SETTINGS_VERSION, 1)
		template_version = self._settings_template_serializer.get(SETTINGS.META_MODULE, self.SETTINGS_VERSION)
		if current_version != template_version:
			print('Discovered old settings file, auto-upgrading: {} -> {}'.format(
		          current_version, template_version))
			for module in self._settings_template_serializer.getModuleName():
				for setting_name in self._settings_template_serializer.getAllSettings(module):
					default_value = self._settings_template_serializer.get(module, setting_name)
					if self.get(module, setting_name, default=default_value) is default_value:
						self.set(module, setting_name, default_value)
			self.set(SETTINGS.META_MODULE, self.SETTINGS_VERSION, template_version)
			self.save()

	# settings

	def get_unknownhorizons_Language(self, value):
		if value is None: # the entry is None for empty strings
			value = ""
		return LANGUAGENAMES[value]

	def set_unknownhorizons_Language(self, value):
		return LANGUAGENAMES.get_by_value(value)
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:100,代码来源:settings.py

示例6: Setting

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class Setting(object):
	"""
	This class manages loading and saving of game settings.

	Usage::
		from fife.extensions.fife_settings import Setting
		settings = Setting(app_name="myapp")
		screen_width = settings.get("FIFE", "ScreenWidth", 1024)
		screen_height = settings.get("FIFE", "ScreenHeight", 768)
	"""

	def __init__(self, app_name="", settings_file="", default_settings_file= "settings-dist.xml", copy_dist=True, serializer=None):
		"""
		Initializes the Setting object.

		@param app_name: The applications name.  If this parameter is provided
		alone it will try to read the settings file from the users home directory.
		In windows this will be	something like:	C:\Documents and Settings\user\Application Data\fife
		@type app_name: C{string}
		@param settings_file: The name of the settings file.  If this parameter is
		provided it will look for the setting file as you specify it, first looking
		in the working directory.  It will NOT look in the users home directory.
		@type settings_file: C{string}
		@param default_settings_file: The name of the default settings file.  If the settings_file
		does not exist this file will be copied into the place of the settings_file.  This file
		must exist in the root directory of your project!
		@type default_settings_file: C{string}
		@param settings_gui_xml: If you specify this parameter you can customize the look
		of the settings dialog box.
		@param copy_dist: Copies the default settings file to the settings_file location.  If
		this is False it will create a new empty setting file.
		@param serializer: Overrides the default XML serializer
		@type serializer: C{SimpleSerializer}

		"""
		self._app_name = app_name
		self._settings_file = settings_file
		self._default_settings_file = default_settings_file

		# Holds SettingEntries
		self._entries = {}

		if self._settings_file == "":
			self._settings_file = "settings.xml"
			self._appdata = getUserDataDirectory("fife", self._app_name)
		else:
			self._appdata = os.path.dirname(self._settings_file)
			self._settings_file = os.path.basename(self._settings_file)

		if not os.path.exists(os.path.join(self._appdata, self._settings_file)):
			if os.path.exists(self._default_settings_file) and copy_dist:
				shutil.copyfile(self._default_settings_file, os.path.join(self._appdata, self._settings_file))

		# valid values possible for the engineSettings
		self._validSetting = {}
		self._validSetting['FIFE'] = {
			'FullScreen':[True,False], 'PychanDebug':[True,False]
			, 'ProfilingOn':[True,False], 'SDLRemoveFakeAlpha':[True,False], 'GLCompressImages':[False,True], 'GLUseFramebuffer':[False,True], 'GLUseNPOT':[False,True],
			'GLUseMipmapping':[False,True], 'GLTextureFiltering':['None', 'Bilinear', 'Trilinear', 'Anisotropic'], 'GLUseMonochrome':[False,True],
			'GLUseDepthBuffer':[False,True], 'GLAlphaTestValue':[0.0,1.0],
			'RenderBackend':['OpenGL', 'SDL'],
			'ScreenResolution':['640x480', '800x600', '1024x600', '1024x768', '1280x768',
								'1280x800', '1280x960', '1280x1024', '1366x768', '1440x900',
								'1600x900', '1600x1200', '1680x1050', '1920x1080', '1920x1200'],
			'BitsPerPixel':[0,16,24,32],
			'InitialVolume':[0.0,10.0], 'WindowTitle':"", 'WindowIcon':"", 'Font':"",
			'FontGlyphs':"", 'DefaultFontSize':"", 'Lighting':[0,1],
			'ColorKeyEnabled':[True,False], 'ColorKey':['a','b','c'], 'VideoDriver':"",
			'PlaySounds':[True,False], 'LogToFile':[True,False],
			'LogToPrompt':[True,False],'UsePsyco':[True,False], 'LogLevelFilter':[0,1,2,3],
			'LogModules':['all', 'controller','script','video','audio','loaders','vfs','pool','view','model','metamodel','event_channel','xml'],
			'FrameLimitEnabled':[True,False], 'FrameLimit':[0], 'MouseSensitivity':[0.0], 'MouseAcceleration':[True,False]
			}

		glyphDft = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&amp;`'*#=[]\\\""

		# we at this point assume default values are final values for engineSettings
		self._defaultSetting = {}
		self._defaultSetting['FIFE'] = {
			'FullScreen':False, 'PychanDebug':False
			, 'ProfilingOn':False, 'SDLRemoveFakeAlpha':False, 'GLCompressImages':False, 'GLUseFramebuffer':True, 'GLUseNPOT':True,
			'GLUseMipmapping':False, 'GLTextureFiltering':'None', 'GLUseMonochrome':False, 'GLUseDepthBuffer':False, 'GLAlphaTestValue':0.3,
			'RenderBackend':'OpenGL', 'ScreenResolution':"1024x768", 'BitsPerPixel':0,
			'InitialVolume':5.0, 'WindowTitle':"", 'WindowIcon':"", 'Font':"",
			'FontGlyphs':glyphDft, 'DefaultFontSize':12, 'Lighting':0,
			'ColorKeyEnabled':False, 'ColorKey':[255,0,255], 'VideoDriver':"",
			'PlaySounds':True, 'LogToFile':False,
			'LogToPrompt':False,'UsePsyco':False,'LogLevelFilter':[0],
			'LogModules':['controller','script'],
			'FrameLimitEnabled':False, 'FrameLimit':60,
			'MouseSensitivity':0.0,
			'MouseAcceleration':False
			}

		# has the settings file been read
		self._readSettingsCompleted = {}

		# the global dictionary from which we will read after self._readSettingsCompleted is True
		self._settingsFromFile = {}

#.........这里部分代码省略.........
开发者ID:cheif,项目名称:fifengine,代码行数:103,代码来源:fife_settings.py

示例7: InteractiveObject

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class InteractiveObject(fife.InstanceActionListener):
	def __init__(self, objectmanager, model, file):
		fife.InstanceActionListener.__init__(self)
		self._manager = objectmanager
		self._model = model
		self._objectFile = SimpleXMLSerializer(file)
		self._agentName = self._objectFile.get("object", "agentname", "dummy")
		self._layer = self._manager._world._map.getLayer(self._objectFile.get("object", "layer", "player"))
		self._agent = self._layer.getInstance(self._agentName)
		self._agent.addActionListener(self)
		self._status = self._objectFile.get("object", "status", 'INACTIVE')
		
		self._actions = { 'use' : self.use,
				  'destroy' : self.destroy,
				  'turnon' : self.activate,
				  'turnoff' : self.deactivate,
				  'explode' : self.explode,
				  'describe': self.describe,
				  'glitch' : self.glitch }
		self._availableactions = { 'use' : False,
					   'destroy' : False,
					   'turnon' : False,
					   'turnoff' : False,
					   'explode' : False,
					   'describe' : True,
					   'glitch' : False }
		
		actionstr = self._objectFile.get("object", "actions", None)
		actions = self._objectFile._deserializeDict(actionstr)
		for action, bool in actions.iteritems():
			if bool in ("True"):
				self._availableactions[action] = True
			else:
				self._availableactions[action] = False
		self._description = self._objectFile.get("object", "description", "I can see something, but\n I can't tell what it is")
		self._talk = self._objectFile.get("object", "talk", False)
		self._message = self._objectFile._deserializeList(self._objectFile.get("object", "messages", ""))
		self._usesound = self._objectFile.get("object", "sound", False)
		if self._usesound:
			self._manager._world._sounds._loadclip(self._agentName, self._objectFile.get("object", "soundfile", ""), False, False)
			self._sound = self._manager._world._sounds._emitters[self._agentName]
		self._loadObject()
		self.onInstanceActionFinished(self._agent, "")
	
	def onInstanceActionFinished(self, instance, action):
		if self._status == 'ACTIVE':
			self._agent.act('on', self._agent.getFacingLocation())
		elif self._status == 'INACTIVE':
			self._agent.act('off', self._agent.getFacingLocation())
		elif self._status == 'DESTROYED':
			self._agent.act('dead', self._agent.getFacingLocation())
		elif self._status == 'GLITCHED':
			self._agent.act('glitch', self._agent.getFacingLocation())
	
	def use(self):
		if self._status == 'ACTIVE':
			self._agent.act('use', self._agent.getFacingLocation())
			self._manager._world._player._agent.setFacingLocation(self._agent.getLocation())
			if self._noactioncallbacks == 0:
				self._action()
			elif self._noactioncallbacks == 1:
				self._action(self._actioncallbacks[0])
			elif self._noactioncallbacks == 2:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1])
			elif self._noactioncallbacks == 3:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2])
			elif self._noactioncallbacks == 4:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2], self._actioncallbacks[3])
			elif self._noactioncallbacks == 5:
				self._action(self._actioncallbacks[0], self._actioncallbacks[1], self._actioncallbacks[2], self._actioncallbacks[3], self._actioncallbacks[4])
			if self._talk:
				rand = random.randint(0, len(self._message) - 1)
				self._manager._world._player._agent.say(self._message[rand], 3500)
			if self._usesound:
				self._sound.play()

	def destroy(self):
		self._agent.act('die', self._agent.getFacingLoaction)
		self._status = 'DESTROYED'
	
	def activate(self):
		self._agent.act('turnon', self._agent.getFacingLoaction)
		self._status = 'ACTIVE'
	
	def deactivate(self):
		self._agent.act('turnoff', self._agent.getFacingLoaction)
		self._status = 'INACTIVE'
	
	def explode(self):
		self._agent.act('explode', self._agent.getFacingLoaction)
		self._status = 'DESTROYED'
	
	def describe(self):
		self._manager._world._player._agent.say(self._description, 5000)
	
	def glitch(self):
		self._agent.act('glitch', self._agent.getFacingLoaction)
		self._status = 'GLITCHED'
		
	def noAction(self):
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:objectmanager.py

示例8: Setting

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class Setting(object):
	"""
	This class manages loading and saving of game settings.

	Usage::
		from fife.extensions.fife_settings import Setting
		settings = Setting(app_name="myapp")
		screen_width = settings.get("FIFE", "ScreenWidth", 1024)
		screen_height = settings.get("FIFE", "ScreenHeight", 768)
	"""

	def __init__(self, app_name="", settings_file="", default_settings_file= "settings-dist.xml", settings_gui_xml="", changes_gui_xml="", copy_dist=True, serializer=None):
		"""
		Initializes the Setting object.

		@param app_name: The applications name.  If this parameter is provided
		alone it will try to read the settings file from the users home directory.
		In windows this will be	something like:	C:\Documents and Settings\user\Application Data\fife
		@type app_name: C{string}
		@param settings_file: The name of the settings file.  If this parameter is
		provided it will look for the setting file as you specify it, first looking
		in the working directory.  It will NOT look in the users home directory.
		@type settings_file: C{string}
		@param default_settings_file: The name of the default settings file.  If the settings_file
		does not exist this file will be copied into the place of the settings_file.  This file
		must exist in the root directory of your project!
		@type default_settings_file: C{string}
		@param settings_gui_xml: If you specify this parameter you can customize the look
		of the settings dialog box.
		@param copy_dist: Copies the default settings file to the settings_file location.  If
		this is False it will create a new empty setting file.
		@param serializer: Overrides the default XML serializer
		@type serializer: C{SimpleSerializer}

		"""
		self._app_name = app_name
		self._settings_file = settings_file
		self._default_settings_file = default_settings_file
		self._settings_gui_xml = settings_gui_xml
		self._changes_gui_xml = changes_gui_xml
		self.OptionsDlg = None

		# Holds SettingEntries
		self._entries = {}
		
		if self._settings_file == "":
			self._settings_file = "settings.xml"
			self._appdata = getUserDataDirectory("fife", self._app_name)
		else:
			self._appdata = os.path.dirname(self._settings_file)
			self._settings_file = os.path.basename(self._settings_file)


		if self._settings_gui_xml == "":
			self._settings_gui_xml = SETTINGS_GUI_XML

		if self._changes_gui_xml == "":
			self._changes_gui_xml = CHANGES_REQUIRE_RESTART


		if not os.path.exists(os.path.join(self._appdata, self._settings_file)):
			if os.path.exists(self._default_settings_file) and copy_dist:
				shutil.copyfile(self._default_settings_file, os.path.join(self._appdata, self._settings_file))

		#default settings
		self._resolutions = ['640x480', '800x600', '1024x768', '1280x800', '1440x900']
		self._renderbackends = ['OpenGL', 'SDL']
		self._lightingmodels = [0, 1, 2]

		#Used to stylize the options gui
		self._gui_style = "default"

		#Initialize the serializer
		if serializer:
			self._serializer = serializer
		else:
			self._serializer = SimpleXMLSerializer()
	
		self.initSerializer()
	
		self._initDefaultSettingEntries()

	def initSerializer(self):
		self._serializer.load(os.path.join(self._appdata, self._settings_file))
		
	def _initDefaultSettingEntries(self):
		"""Initializes the default fife setting entries. Not to be called from
		outside this class."""
		self.createAndAddEntry(FIFE_MODULE, "PlaySounds", "enable_sound",
		              requiresrestart=True)
		self.createAndAddEntry(FIFE_MODULE, "FullScreen", "enable_fullscreen",
		              requiresrestart=True)
		self.createAndAddEntry(FIFE_MODULE, "ScreenResolution", "screen_resolution", initialdata = self._resolutions,
		              requiresrestart=True)
		self.createAndAddEntry(FIFE_MODULE, "RenderBackend", "render_backend", initialdata = self._renderbackends,
		              requiresrestart=True)
		self.createAndAddEntry(FIFE_MODULE, "Lighting", "lighting_model", initialdata = self._lightingmodels,
		              requiresrestart=True)

	def createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False):
#.........这里部分代码省略.........
开发者ID:mgeorgehansen,项目名称:FIFE_Technomage,代码行数:103,代码来源:fife_settings.py

示例9: QuestManager

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class QuestManager(Serializer):
	def __init__(self, gamecontroller):
		self._gamecontroller = gamecontroller

		self._questsettings = None
		
		self._quests = {}
		self._activequests = []
		self._completedquests = []
	
	def serialize(self):
		pass
	
	def deserialize(self, valuedict=None):
		questfile = self._gamecontroller.settings.get("RPG", "QuestFile", "maps/quests.xml")
		
		self._questsettings = SimpleXMLSerializer(questfile)
		
		for identifier in self._questsettings.get("QuestGivers", "list", []):
			for quest in self._questsettings.get(identifier, "questlist", []):
					questdict = self._questsettings.get(identifier, quest, {})
					if questdict['type'] == "RETURN_ITEM":
						questobj = ReturnItemQuest(identifier, quest, questdict['name'], questdict['desc'])
						for ritem in self._questsettings.get(quest+"_items", "itemlist", []):
							itemdict = self._questsettings.get(quest+"_items", ritem, {})
							if itemdict["name"] == "GOLD_COINS":
								questobj.addRequiredGold(int(itemdict['value']))
							else:
								questobj.addRequiredItem(ritem)
					else:
						questobj = Quest(identifier, quest, questdict['name'], questdict['desc'])

					if questdict.has_key("quest_incomplete_dialog"):
						questobj._incomplete_dialog = questdict['quest_incomplete_dialog']
						
					if questdict.has_key("quest_complete_dialog"):
						questobj._complete_dialog = questdict['quest_complete_dialog']

					self._gamecontroller.questmanager.addQuest(questobj)
	
	def reset(self):
		self._quests = {}
		self._activequests = []
		self._completedquests = []
		
	def addQuest(self, quest):
		if self._quests.has_key(quest.ownerid):
			if not quest in self._quests[quest.ownerid]:
				self._quests[quest.ownerid].append(quest)
		else:
			self._quests[quest.ownerid] = [quest]

	def getQuest(self, questid):
		for owner in self._quests:
			for quest in self._quests[owner]:
				if quest.id == questid:
					return quest
		
		return None

	def getNextQuest(self, ownerid):
		if self._quests.has_key(ownerid):
			for quest in self._quests[ownerid]:
				if not quest in self._activequests and not quest in self._completedquests:
					return quest

		return None
		
	def activateQuest(self, quest):
		"""
		Adds the quest to the "active quests" list.  Note that this does NOT affect
		the quest in any way.  It's just a way of keeping track of which quests
		the player has accepted.
		"""
		if not quest in self._activequests:
			self._activequests.append(quest)
		
	def completeQuest(self, quest):
		"""
		Marks the quest as completed.  Note that this does NOT modify the quest in
		any way.  This is just a way to keep track of completed quests.
		"""
		if not quest in self._completedquests:
			self._completedquests.append(quest)
		
		if quest in self._activequests:
			self._activequests.remove(quest)
		
	def activateQuestById(self, questid):
		quest = self.getQuest(questid)
		if quest:
			self.activateQuest(quest)
		
	def completeQuestById(self, questid):
		quest = self.getQuest(questid)
		if quest:
			self.completeQuest(quest)
	
	def _getActiveQuests(self):
		return self._activequests
#.........这里部分代码省略.........
开发者ID:karottenreibe,项目名称:FIFE,代码行数:103,代码来源:questmanager.py

示例10: Event

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class Event():
	def __init__(self, eventfile, tracker):
		self._file = SimpleXMLSerializer(filename=eventfile)
		self._eventname = self._file.get("event", "name", len(tracker._events))
		self._status = 'INACTIVE'
		self._type = self._file.get("event", "type", "dummy")
		self._tracker = tracker
		
		if self._file.get("event", "active", False):
			self._status = 'ACTIVE'

		self._repeating = self._file.get("event", "repeating", False)
		
		self._activates = self._file.get("event", "activates", "none")
		
		if self._type == "dummy":
			pass
			self._status = 'FULFILLED'
		if self._type == "trip":
			self._target = self._file.get("event", "target", None)
			self._x = self._file.get("event", "x", 0)
			self._y = self._file.get("event", "y", 0)
		if self._type == "areatrip":
			self._target = self._file.get("event", "target", None)
			self._xmin = self._file.get("event", "xmin", 0)
			self._xmax = self._file.get("event", "xmax", 0)
			self._ymin = self._file.get("event", "ymin", 0)
			self._ymax = self._file.get("event", "ymax", 0)
		if self._type == "item":
			self._item = self._file.get("event", "item", None)
		if self._type == "dialogue":
			self._dialogue = self._file.get("event", "dialogue")
		if self._type == "plot":
			self._subtype = self._file.get("event", "subtype", "dummy")
			if self._subtype == "dummy":
				pass
				self._status = 'FULFILLED'
			if self._subtype == "trip":
				self._target = self._file.get("event", "target", None)
				self._x = self._file.get("event", "x", 0)
				self._y = self._file.get("event", "y", 0)
			if self._subtype == "areatrip":
				self._target = self._file.get("event", "target", None)
				self._xmin = self._file.get("event", "xmin", 0)
				self._xmax = self._file.get("event", "xmax", 0)
				self._ymin = self._file.get("event", "ymin", 0)
				self._ymax = self._file.get("event", "ymax", 0)
			if self._subtype == "item":
				self._item = self._file.get("event", "item", None)
			if self._subtype == "dialogue":
				self._dialogue = self._file.get("event", "dialogue")
		
		action = self._file.get("event", "action", "none")
		if action == "eventmusic":
			self._tracker._eventmusic[self._eventname] = ThreePartMusic(self._file.get("event", "musicintro", ""), self._file.get("event", "musicloop", ""), self._file.get("event", "musicend", ""), True, tracker._musicmanager._soundmanager)
			self._action = self._tracker._eventmusic(self._eventname)._play
			self._noactioncallbacks = 0
			self._actioncallbacks = {}
		elif action == "playsound":
			self._action = self._tracker._musicmanager._startClip
			self._noactioncallbacks = 1
			self._actioncallbacks = {0: self._file.get("event", "clip", "default")}
		elif action == "stopsound":
			self._action = self._tracker._musicmanager._startClip
			self._noactioncallbacks = 1
			self._actioncallbacks = {0: self._file.get("event", "clip", "default")}
		elif action == "swapmap":
			self._action = self._tracker._world._loadMap
			self._noactioncallbacks = 2
			self._actioncallbacks = {0: self._file.get("event", "newmap", ""),
						 1: 'LEVEL'}
		elif action == "movenpc":
			self._action = self._tracker._world._npcs[self._file.get("event", "npc", "")].run
			location = fife.Location()
			location.setLayer(tracker._world._map.getLayer('player'))
			location.setExactLayerCoordinates(fife.ExactModelCoordinate(self._file.get("event", "newx", 0), self._file.get("event", "newy", 0)))
			self._actioncallbacks = {0: location}
		elif action == "moveplayer":
			self._action = self._tracker._world._player.run
			location = fife.Location()
			location.setLayer(tracker._world._map.getLayer('player'))
			location.setExactLayerCoordinates(fife.ExactModelCoordinate(self._file.get("event", "newx", 0), self._file.get("event", "newy", 0)))
			self._actioncallbacks = {0: location}
		elif action == "npcaction":
			reaction = self._file.get("event", "clip", "default")
			if self._tracker._world._npcs[self._file.get("event", "npc", "")]._availableActions[reaction]:
				self._action = self._tracker._world._npcs[self._file.get("event", "npc", "")]._action[reaction]
				self._noactioncallbacks = 0
		elif action == "playeraction":
			reaction = self._file.get("event", "clip", "default")
			if self._tracker._world._player._availableActions[reaction]:
				self._action = self._tracker._world._player._action[reaction]
				self._noactioncallbacks = 0
		elif action == "portnpc":
			self._action = self._tracker._world._npcs[self._file.get("event", "npc", "")]._agent.setLocation
			location = fife.Location()
			location.setLayer(tracker._world._map.getLayer('player'))
			location.setExactLayerCoordinates(fife.ExactModelCoordinate(self._file.get("event", "newx", 0), self._file.get("event", "newy", 0)))
			self._actioncallbacks = {0: location}
		elif action == "portplayer":
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:eventtracker.py

示例11: _setup_settings

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
	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()
开发者ID:slbucur,项目名称:unknown-horizons,代码行数:98,代码来源:engine.py

示例12: NPC

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class NPC(Agent):
	def __init__(self, settings, model, agentName, layer, world, uniqInMap=True, name=""):
		super(NPC, self).__init__(settings, model, agentName, layer, uniqInMap)
		self._state = _STATE_NONE
		self._name = name
		self._agentName = agentName
		self._layer = layer
		self._availableActions = { 'walk': False,
					   'run': False,
					   'talk': False,
					   'die': False,
					   'explode': False,
					   'holdgun': False,
					   'firegun': False,
					   'beshot': False,
					   'walkgun': False,
					   'rungun': False,
					   'diegun': False,
					   'beshotgun': False,
					   'holdpistol': False,
					   'aimpistolleft': False,
					   'aimpistolright': False,
					   'firepistolleft': False,
					   'firepistolright': False,
					   'walkpistol': False,
					   'runpistol': False,
					   'diepistol': False,
					   'beshotpistol': False,
					   'teleportstart': False,
					   'teleportend': False,
					   'glitch': False,
					   'describe' : True}
		self._action = { 'walk': self.walk,
				 'run': self.run,
				 'talk': self.talk,
				 'die': self.die,
				 'explode': self.explode,
				 'holdgun': self._idle,
				 'firegun': self.fire,
				 'beshot': self.beshot,
				 'walkgun': self.walk,
				 'rungun': self.run,
				 'diegun': self.die,
				 'beshotgun': self.beshot,
				 'holdpistol': self._idle,
				 'aimpistolleft': self.aimleft,
				 'aimpistolright': self.aimright,
				 'firepistolleft': self.fireleft,
				 'firepistolright': self.fireright,
				 'walkpistol': self.walk,
				 'runpistol': self.run,
				 'diepistol': self.die,
				 'beshotpistol': self.beshot,
				 'teleportstart': self.teleportstart,
				 'teleportend': self.teleportend,
				 'glitch': self.glitch,
				 'decribe' : self.describe }
		self._world = world
		self._loadNPC(self._name)
		
	def _loadNPC(self, name):
		self._npcFile = SimpleXMLSerializer(filename="npcs/" + name + ".xml")
		actionstr = self._npcFile.get("npc", "actions", None)
		actions = self._npcFile._deserializeDict(actionstr)
		for action, bool in actions.iteritems():
			if bool == "True":
				self._availableActions[action] = True
			else:
				self._availableActions[action] = False
		self._actionchance = self._npcFile.get("npc", "actionchance", 0)
		self._description = self._npcFile.get("npc", "description", "I can see a mysterious figure,\n but I can't quite make them out.")
		self._autowalk = self._npcFile.get("npc", "autowalk", True)
		self._hasdialogue = self._npcFile.get("npc", "hasdialogue", False)
		self._autowalk = self._npcFile.get("npc", "autowalk", True)
		self._loadDialogue()
		self._idle()
	
	def _loadDialogue(self):
		if not self._hasdialogue:
			return
		self._dialogue = {}
		self._idledialogue = []
		index = []
		index = self._npcFile._deserializeList(self._npcFile.get("dialogue", "index", ""))
		for line in index:
			self._dialogue[line] = self._npcFile._deserializeDict(self._npcFile.get("dialogue", line, ""))
		idleindex = self._npcFile._deserializeList(self._npcFile.get("dialogue", "idleindex", ""))
		for line in idleindex:
			self._idledialogue.append(self._dialogue[line])
	
	def _listAvailableTopics(self):
		returninglist = []
		if not self._hasdialogue:
			return returninglist
		for index, dialogue in self._dialogue.iteritems():
			if dialogue["requires"] in self._world._player._plots or dialogue["requires"] == '0' and dialogue not in self._idledialogue:
				returninglist.append((index, dialogue["topic"]))
		return returninglist
	
	def _talk(self, index):
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:npc.py

示例13: QuestManager

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class QuestManager(Serializer):
    def __init__(self, gameplay):
        self._gameplay = gameplay
        
        self._questSettings = None
        
        self._quests = []
        self._activeQuests = []
        self._completedQuests = []
    
    def serialize(self):
        pass
    
    def deserialize(self, valueDict):
        questFile = "maps/quests.xml"
        
        self._questSettings = SimpleXMLSerializer(questFile)
        
        for identifier in self._questSettings.get("QuestGivers", "list", []):
            for quest in self._questSettings.get(identifier, "questList", []):
                questDict = self._questSettings.get(identifier, quest, [])
                if questDict["type"] == 'RETURN_ITEM':
                    questObj = ReturnItemQuest(identifier, quest, questDict["name"], questDict["desc"])
                    for ritem in self._questSettings.get(quest + "_items", "itemlist", []):
                        itemDict = self._questSettings.get(quest + "_items", ritem, [])
                        if itemDict["name"] == "GOLD_COINS":
                            questObj.addRequiredGold(itemDict["value"])
                        else:
                            questObj.addRequiredItem(ritem)
                else:
                    questObj = Quest(identifier, quest, questDict["name"], questDict["desc"])
                
                if questDict.has_key("quest_incomplete_dialog"):
                    questObj._incompleteDialog = questDict["quest_incomplete_dialog"]
                
                if questDict.has_key("quest_complete_dialog"):
                    questObj._completeDialog = questDict["quest_complete_dialog"]
                
                self._gameplay.questManager.addQuest(questObj)
    
    def reset(self):
        self._quests = []
        self._activeQuests = []
        self._completedQuests = []
    
    def addQuest(self, quest):
        if self._quests.has_key(quest.ownerId):
            if not quest in self._quests[quest.ownerId]:
                self._quests[quest.ownerId].append(quest)
        else:
            self._quests[quest.ownerId] = [quest]
    
    def getQuest(self, questId):
        for owner in self._quests:
            for quest in self._quests[owner]:
                if quest.id == questId:
                    return quest
        return None
    
    def getNextQuest(self, ownerId):
        if self._quests.has_key(ownerId):
            for quest in self._quests[ownerId]:
                if not quest in self._activeQuests and not quest in self._completedQuests:
                    return quest
        return None

    def activateQuest(self, quest):
        if not quest in self._activeQuests:
            self._activeQuests.append(quest)
    
    def completeQuest(self, quest):
        if not quest in self._completedQuests:
            self._completedQuests.append(quest)
        
        if quest in self._activeQuests:
            self._activeQuests.remove(quest)
    
    def activateQuestById(self, questId):
        quest = self.getQuest(questId)
        if quest:
            self.activateQuest(quest)
    
    def completeQuestById(self, questId):
        quest = self.getQuest(questId)
        if quest:
            self.completeQuest(quest)
    
    def _getActiveQuests(self):
        return self._activeQuests
    
    def _getCompletedQuests(self):
        return self._completedQuests
    
    def _getAllQuests(self):
        return self._quests
    
    activeQuests = property(_getActiveQuests)
    completedQuests = property(_getCompletedQuests)
    quests = property(_getAllQuests)
开发者ID:florinp,项目名称:untitled_game,代码行数:101,代码来源:questManager.py

示例14: Settings

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class Settings(object):

	# Settings key storing the SettingsVersion used to upgrade settings
	SETTINGS_VERSION = "SettingsVersion"

	def __init__(self, settings_file, settings_template_file):
		self._module_settings = {}
		self._module_settings_template = {}
		self._settings_file = settings_file
		self._settings_template_file = settings_template_file
		self._settings_serializer = SimpleXMLSerializer()
		self._settings_serializer.load(settings_file)
		self._settings_template_serializer = SimpleXMLSerializer()
		self._settings_template_serializer.load(settings_template_file)
		self.upgrade_settings()

	def get(self, module, name, default=None):
		if default is None:
			default = self._settings_template_serializer.get(module, name)

		v = self._settings_serializer.get(module, name, default)
		getter = getattr(self, 'get_' + module + '_' + name, None)
		if getter:
			return getter(v)
		else:
			return v

	def set(self, module, name, value):
		setter = getattr(self, 'set_' + module + '_' + name, None)
		if setter:
			value = setter(value)

		# This is necessary, as empty fields return None, but saving
		# None will result in the String 'None' being stored
		if value is None:
			value = ''

		if module in self._module_settings:
			self._module_settings[module][name] = value

		self._settings_serializer.set(module, name, value, {})

	def get_module_settings(self, module):
		self._module_settings[module] = self._settings_serializer.getAllSettings(module)
		self._module_settings_template[module] = self._settings_template_serializer.getAllSettings(module)
		for name, value in self._module_settings_template[module].iteritems():
			if name not in self._module_settings[module]:
				self._module_settings[module][name] = value
		return self._module_settings[module]

	def get_module_template_settings(self, module):
		return self._settings_template_serializer.getAllSettings(module)

	def save(self):
		self._settings_serializer.save(self._settings_file)

	def apply(self):
		data = self.get(SETTINGS.UH_MODULE, "Language")
		language = LANGUAGENAMES.get_by_value(data)
		change_language(language)

	def set_defaults(self):
		for module in self._settings_template_serializer.getModuleName():
			for setting_name in self._settings_template_serializer.getAllSettings(module):
				value = self._settings_template_serializer.get(module, setting_name)
				self.set(module, setting_name, value)
		self.save()

	def upgrade_settings(self):
		"""Upgrades the settings to a newer version necessary."""
		current_version = self.get(SETTINGS.META_MODULE, self.SETTINGS_VERSION)
		template_version = self._settings_template_serializer.get(SETTINGS.META_MODULE, self.SETTINGS_VERSION)
		if current_version != template_version:
			print 'Discovered old settings file, auto-upgrading: %s -> %s' % \
		          (current_version, template_version)
			for module in self._settings_template_serializer.getModuleName():
				for setting_name in self._settings_template_serializer.getAllSettings(module):
					default_value = self._settings_template_serializer.get(module, setting_name)
					if self.get(module, setting_name, default=default_value) is default_value:
						self.set(module, setting_name, default_value)
			self.set(SETTINGS.META_MODULE, self.SETTINGS_VERSION, template_version)
			self.save()

	# settings

	def get_unknownhorizons_Language(self, value):
		if value is None: # the entry is None for empty strings
			value = ""
		return LANGUAGENAMES[value]

	def set_unknownhorizons_Language(self, value):
		return LANGUAGENAMES.get_by_value(value)
开发者ID:JonathanMeans,项目名称:unknown-horizons,代码行数:94,代码来源:settings.py

示例15: World

# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import get [as 别名]
class World(EventListenerBase):
	"""
	World Class
	Sets up the map, gui, soundmanager and calls the Actor class to deal with actors
	
	Keyword Arguments
	EventListenerBase - World inherits from EventListenerBase
	"""
	def __init__(self, app, engine, setting):
		"""
		__init__ Function
		Starts an instance of the World class
		
		Keyword Arguments
		app - A pointer to the main application
		engine - A pointer to fife.engine
		setting - A pointer to a fife settings XML file
		"""
		super(World, self).__init__(engine, regKeys=True, regCmd=False, regMouse=True)

		# Throw values into their variables
		self._applictaion = app
		self._engine = engine
		self._setting = setting
		self._timemanager = engine.getTimeManager()
		self._eventmanager = engine.getEventManager()
		self._model = engine.getModel()
		self._filename = ''
		self._keystate = { 'UP': False, 
		                   'DOWN': False, 
		                   'LEFT': False, 
		                   'RIGHT': False, 
		                   'CTRL': False, 
		                   'SPACE': False,
				   'Q': False,
				   'E': False,}
		self._cameras = {}
		self._npcs = {}
		self._npclist = None
		self._pump_ctr = 0
		self._map = None
		self._scene = None
		self._paused = True
		self._pausedtime = 0
		self._starttime = 0
		self._gamestate = 'NONE'
		self._quit = False
		self._player = None
		self._eventtracker = None
		self._objects = {}
		self._contextmenu = contextmenu.ContextMenu('rightclickmenu', self)
		self._mouseMoved = False
		
		# Start pychan
		pychan.init(self._engine)
		
		# Set all GUI types to empty
		self._hud = None
		self._mainmenu = None
		self._pausemenu = None
		self._loadingmenu = None
		self._settingsmenu = None
		self._aboutmenu = None
		
		# Start the sound manager
		self._soundmanager = SoundManager(self._engine)
		self._sounds = musicmanager.MusicManager(self._engine, self._soundmanager, self._timemanager)
		
	def _loadGui(self, type, guifile, imports):
		"""
		_loadGui Function
		Loads a pychan GUI file to one of the four GUI slots, then loads a python package to run to initilise the gui
		
		Keyword Arguments
		type - String, the type of GUI being loaded
		guifile - String, name of the pychan file being loaded
		imports - Boolean
		"""
		if type == 'MAIN':
			self._mainmenu = menuhandler.MenuHandler(guifile, self)
		elif type == 'HUD':
			self._hud = hudhandler.HUDHandler(guifile, self)
		elif type == 'SETTINGS':
			self._settingsmenu = settingshandler.SettingsHandler(guifile, self)
		elif type == 'ABOUT':
			self._aboutmenu = abouthandler.AboutHandler(guifile, self)
		elif type == 'PAUSE':
			self._pause = pychan.loadXML('gui/' + guifile + '.xml')
			if imports:
				guiinit = __import__('scripts.gui.' + guifile)
				guiinit.run()
		elif type == 'LOAD':
			self._loadingmenu = pychan.loadXML('gui/' + guifile + '.xml')
			if imports:
				guiinit = __import__('scripts.gui.' + guifile)
				guiinit.run()
		else:
			pass
	
	def _hideAllGuis(self):
#.........这里部分代码省略.........
开发者ID:Drakekin,项目名称:Zero-Sum-Cascade-Old,代码行数:103,代码来源:world.py


注:本文中的fife.extensions.serializers.simplexml.SimpleXMLSerializer.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。