Exemple #1
0
    def init(self):
#        self.logconfigfilename = os.path.join(os.path.dirname(os.path.abspath(__file__)), LOGCONFIGFILE)
#        lm = ogre.LogManager()
#        l = lm.getSingleton()
#        lm.logMessage("python")
        self.logconfigfilename = rorSettings().concatToToolkitHomeFolder(['logs', LOGCONFIGFILE], True)

        logidentifier = 'RoRToolkit'
        # set up logging to file
        logfilename = self.logconfigfilename = rorSettings().concatToToolkitHomeFolder(['logs', 'editor.log'], True)
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                            datefmt='%m-%d %H:%M',
                            filename=logfilename,
                            filemode='w')
        # define a Handler which writes INFO messages or higher to the sys.stderr
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        # set a format which is simpler for console use
        formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
        # tell the handler to use this format
        console.setFormatter(formatter)
        # add the handler to the root logger
        logging.getLogger('').addHandler(console)
        
        self.myLog = logging.getLogger(logidentifier)
Exemple #2
0
def getBitmap(title):
	""" get The image that represent the toolbar button glyph
	- replace spaces by underscore
	- extension  .png
	
	return wx.Bitmap
	"""
	imgfile = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ['media', 'gui', title.replace(" ", "_") + ".png"], True)
	print "image to load for toolbar labeled %s " % imgfile
	if os.path.isfile(imgfile):
		return wx.Bitmap(imgfile, wx.BITMAP_TYPE_PNG)
	else:
		return wx.Bitmap(rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ['media', 'gui', "blank.png"], True))
Exemple #3
0
def checkRoRDirectory(fpath=None):
	""" Return True if RoR.exe is found physically in disk 
	"""
	 
	rorexecutable = ''
	if getPlatform() == 'linux':
		rorexecutable = "RoR.bin"
	elif getPlatform() == 'windows':
		rorexecutable = "RoR.exe"

	if fpath is None:
		from settingsManager import  rorSettings
		fpath = rorSettings().rorFolder
	fpath = os.path.join(fpath, rorexecutable)
	#log().info(fpath)
	return os.path.isfile(fpath)
Exemple #4
0
def pause(text="pause"):
	dlg = wx.MessageDialog(rorSettings().mainApp, text, "pause", 0)
	dlg.ShowModal()
	dlg.Destroy()
Exemple #5
0
def initResources():
	global _loaded
	if _loaded:
		return
	counter = 1
	
	# aabb offset setup to zero
	ogre.MeshManager.getSingleton().setBoundsPaddingFactor(0.0)

	log().debug("init Resources")
	#ogre.ResourceGroupManager.getSingleton().addResourceLocation("media/packs/OgreCore.zip", "Zip", "Bootstrap", False)
	media = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ["media"])
	mat = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ["media", "materials"])
	models = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ["media", "models"])
	overlay = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ["media", "overlay"])
#	etm = rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ["media", "ET"])

	ogre.ResourceGroupManager.getSingleton().addResourceLocation(mat, "FileSystem", "ToolkitBase", False)
	ogre.ResourceGroupManager.getSingleton().addResourceLocation(models, "FileSystem", "ToolkitBase", False)
	ogre.ResourceGroupManager.getSingleton().addResourceLocation(overlay, "FileSystem", "ToolkitBase", False)
#	ogre.ResourceGroupManager.getSingleton().addResourceLocation(etm, "FileSystem", "ToolkitBase", False)
	ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup("ToolkitBase")	
	resourceGroupNames["ToolkitBase"] = None #multiples paths
	
	(normalResources, zipResources) = readResourceConfig()
	# only init things in the main window, not in shared ones!
	# setup resources
	
	for r in zipResources:
		files = glob.glob(os.path.join(r, "*.zip"))
		for file in files:
			try:
				if Ignore(file): 
					continue
				groupName = "General-%d" % counter
				ogre.ResourceGroupManager.getSingleton().addResourceLocation(file, "Zip", groupName, False)
				counter += 1
				resourceGroupNames[groupName] = file
				ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup(groupName)
			except:
				log().debug("error adding or initialising Zip Resource group %s of file %s" % (groupName, file))
				continue
		
	# normalResources are uncompressed folders and may have subfolders with maps/vehicles
	# only first level of subfolders is scanned
	for r in normalResources:
		subfolder = os.listdir(r)
		for s in subfolder:
			try:
				fullname = os.path.join(r, s) 
				#print 'adding normal resource: ' + fullname
				if os.path.isdir(fullname):
					groupName = "General-%d" % counter
					ogre.ResourceGroupManager.getSingleton().addResourceLocation(fullname, "FileSystem", groupName, False)
					counter += 1
					resourceGroupNames[groupName] = fullname
					ogre.ResourceGroupManager.getSingleton().initialiseResourceGroup(groupName)
			except:
				log().debug("error adding or initialising Zip Resource group %s of file %s" % (groupName, file))
				
	log().info("loaded %d all resource Groups" % counter)
	_loaded = True
Exemple #6
0
def readResourceConfig():
	from settingsManager import rorSettings
	normalResources = []
	zipResources = []
	
	if rorSettings().onlyParseTrucks:
		normalResources.append(os.path.join(rorSettings().rorHomeFolder, 'terrains'))
		normalResources.append(os.path.join(rorSettings().rorHomeFolder, 'vehicles'))
		zipResources.append(os.path.join(rorSettings().rorFolder, 'resources'))
		return (normalResources, zipResources)
	 
	log().debug("reading main resource: %s" % (rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ['resources.cfg'], True)))
	f = open(rorSettings().getConcatPath(rorSettings().toolkitMainFolder, ['resources.cfg'], True), 'r')
	lines = f.readlines()
	f.close()
	isZip = False
	basePath = ""
	for line in lines:
		try:
			if '#' in line:
				continue
			# all lines readed after [RoR] section will use 
			# RoR folder on program files.
			elif line.strip() == '[zipRoR]' :
				isZip = True
				basePath = rorSettings().rorFolder
			elif line.strip() == '[zipRoRHome]':
				isZip = True
				basePath = rorSettings().rorHomeFolder
			elif line.strip() == '[folderRoR]':
				isZip = False
				basePath = rorSettings().rorFolder
			
			elif line.strip() == '[folderRoRHome]':
				isZip = False
				basePath = rorSettings().rorHomeFolder
			
			elif line[:11] == 'FileSystem=':
				dir = line[11:].strip()
				dirname = dir.replace('/', '\\')
				path = os.path.join(basePath, dirname)
				log().info("adding resource: %s isZip: %s" % (path, str(isZip)))
				if isZip:
					zipResources.append(path)
				else:
					normalResources.append(path)
		except:
			pass
	return (normalResources, zipResources)