def __init__(self, app_name="", settings_file="", settings_gui_xml="", changes_gui_xml="", copy_dist=True):
		"""
		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 settings_gui_xml: If you specify this parameter you can customize the look
		of the settings dialog box.
		@param copy_dist: Copies the settings-dist.xml file to the settings_file location.  If
		this is False it will create a new empty xml file.

		"""
		self._app_name = app_name
		self._settings_file = settings_file
		self._settings_gui_xml = settings_gui_xml
		self._changes_gui_xml = changes_gui_xml

		# Holds SettingEntries
		self._entries = {}
		
		self._xmlserializer = None

		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('settings-dist.xml') and copy_dist:
				shutil.copyfile('settings-dist.xml', os.path.join(self._appdata, self._settings_file))

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

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

		#Initialize the XML serializer
		self.loadSettings()

		self._initDefaultSettingEntries()
Example #2
0
	def _captureScreen(self):
		""" Saves a screenshot to the users data directory """
		userDir = fife_utils.getUserDataDirectory("fife", "editor")
		t = userDir+"/screenshots"
		if not os.path.isdir(t):
			os.makedirs(t)
		t += "/screen-%s-%s.png" % (date.today().strftime('%Y-%m-%d'),
									time.strftime('%H-%M-%S'))
		
		self._editor.getEngine().getRenderBackend().captureScreen(t)
		print "Saved screenshot to:", t		
Example #3
0
    def _pump(self):
        if self.listener.quit:
            self.breakRequested = True

            # get the correct directory to save the map file to
            mapSaveDir = getUserDataDirectory("fife", "rio_de_hola") + "/maps"

            # create the directory structure if it does not exist
            if not os.path.isdir(mapSaveDir):
                os.makedirs(mapSaveDir)

            # save map file to directory
            self.world.save(mapSaveDir + "/savefile.xml")
        else:
            self.world.pump()
Example #4
0
	def _pump(self):
		if self.listener.quit:
			self.breakRequested = True
			
			# get the correct directory to save the map file to
			mapSaveDir = getUserDataDirectory("fife", "rio_de_hola") + "/maps"
			
			# create the directory structure if it does not exist
			if not os.path.isdir(mapSaveDir):
				os.makedirs(mapSaveDir)
			
			# save map file to directory
			self.world.save(mapSaveDir + "/savefile.xml")
		else:
			self.world.pump()
Example #5
0
	def __init__(self, app_name="", settings_file="", default_settings_file= "settings-dist.xml", copy_dist=True, serializer=None):
		r"""
		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 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], 'RefreshRate':[0,200], 'Display':[0,9], 'VSync':[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':"", 'RenderDriver':"",
			'PlaySounds':[True,False], 'LogToFile':[True,False],
			'LogToPrompt':[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],
			'NativeImageCursor':[True,False], 'JoystickSupport':[True, False]
			}

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

		# we at this point assume default values are final values for engineSettings
		self._defaultSetting = {}
		self._defaultSetting['FIFE'] = {
			'FullScreen':False, 'RefreshRate':60, 'Display':0, 'VSync':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':"", 'RenderDriver':"",
			'PlaySounds':True, 'LogToFile':False,
			'LogToPrompt':False,'LogLevelFilter':0,
			'LogModules':['controller','script'],
			'FrameLimitEnabled':False, 'FrameLimit':60,
			'MouseSensitivity':0.0,
			'MouseAcceleration':False,
			'NativeImageCursor':False,
                        'JoystickSupport':False
			}

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

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

		# the logger needed to write in log file. It will be initialized in this file when self.getSettings()
		# method is called by logger
		self._logger = None

		#default settings
		self._resolutions = self._validSetting['FIFE']['ScreenResolution']
		self._renderbackends = self._validSetting['FIFE']['RenderBackend']
		self._lightingmodels = self._validSetting['FIFE']['Lighting']

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

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

		self.initSerializer()

		# if there's no FIFE module assume the settings file is broken
		# and replace with default settings file
		if "FIFE" not in self._serializer.getModuleNameList():
			self.setDefaults()

		# Get all modules and initialize reading of them from xml file as false
		self._allModules = self._serializer.getModuleNameList()
		# print("All Module Names:",self._allModules)
		for module in self._allModules:
			self._readSettingsCompleted[module] = False

		self._initDefaultSettingEntries()
Example #6
0
	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.,!?-+/():;%&`'*#=[]\\\""

		# 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 = {}

		# the logger needed to write in log file. It will be initialized in this file when self.getSettings()
		# method is called by logger
		self._logger = None

		#default settings
		self._resolutions = self._validSetting['FIFE']['ScreenResolution']
		self._renderbackends = self._validSetting['FIFE']['RenderBackend']
		self._lightingmodels = self._validSetting['FIFE']['Lighting']

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

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

		self.initSerializer()

		# Get all modules and initialize reading of them from xml file as false
		self._allModules = self._serializer.getModuleNameList()
		# print("All Module Names:",self._allModules)
		for module in self._allModules:
			self._readSettingsCompleted[module] = False

		self._initDefaultSettingEntries()
Example #7
0
    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.,!?-+/():;%&`'*#=[]\\\""

        # 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 = {}

        # the logger needed to write in log file. It will be initialized in this file when self.getSettings()
        # method is called by logger
        self._logger = None

        # default settings
        self._resolutions = self._validSetting["FIFE"]["ScreenResolution"]
        self._renderbackends = self._validSetting["FIFE"]["RenderBackend"]
        self._lightingmodels = self._validSetting["FIFE"]["Lighting"]

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

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

        self.initSerializer()

        # Get all modules and initialize reading of them from xml file as false
        self._allModules = self._serializer.getModuleNameList()
        # print("All Module Names:",self._allModules)
        for module in self._allModules:
            self._readSettingsCompleted[module] = False

        self._initDefaultSettingEntries()