예제 #1
0
def set_auxiliary_cvar(cvar, default, value):
    """Store the cvar and expected default value, and if set the value that it needs to be currently"""

    if cvar not in CVARS["current"]:
        CVARS["current"][cvar] = default

    general.set_cvar(cvar, value)
예제 #2
0
def reset_cvars():
    """Walk over all modified cvar values and return them to their default expected values"""
    for var in CVARS["current"]:
        if DEBUG:
            print("Var: {0}, Value: {1}".format(var, CVARS["current"][var]))

        try:
            general.set_cvar(var, CVARS["current"][var])
        except RuntimeError as exc:
            print(
                "Debug Views: WARNING - Unable to reset the CVAR {0} {1} due to error {2}".format(
                    var, CVARS["current"][var], exc
                )
            )
            general.log(
                "Debug Views: WARNING - Unable to reset the CVAR {0} {1} due to error {2}".format(
                    var, CVARS["current"][var], exc
                )
            )

    CVARS["current"].clear()

    CVARS["commands"] = None
    print("Debug Views: Reset To Default View Mode...")
    general.log("Debug Views: Resetting To Default View Mode...")
예제 #3
0
def cycleCvarsIntValue(cVars, cycleList):
	currentValueAsString = general.get_cvar(cVars)
	try:
		currentValue = int(currentValueAsString)
	except:
		currentValue = 0

	saveDefaultValue(cVars, currentValue)

	# find out what index we're on already
	# default to -1 so that when we increment to the next, we'll be at 0
	newIndex = -1
	for x in cycleList:
		if (currentValue == x):
			break
		newIndex = newIndex + 1

	# move to the next item
	newIndex = newIndex + 1

	# validate
	if newIndex >= len(cycleList):
		newIndex = 0

	general.set_cvar(cVars, cycleList[newIndex])
예제 #4
0
def set_auxiliary_cvar(cvar, default, value):
    """Store the cvar and expected default value, and if set the value that it needs to be currently"""

    if cvar not in CVARS["current"]:
        CVARS["current"][cvar] = default

    general.set_cvar(cvar, value)
예제 #5
0
 def bootstrap(self, init_funcs):
     try:
         # if it fails to get all it's because it's not json or something is wrong reset it
         self.get_all()
     except ValueError:
         # set some basic initialized json data
         general.set_cvar(self.cvar_key, json.dumps({"initialized": True}))
         for func in init_funcs:
             func()
예제 #6
0
파일: __init__.py 프로젝트: joqqy/CE_Python
 def bootstrap(self, init_funcs):
     try:
         # if it fails to get all it's because it's not json or something is wrong reset it
         self.get_all()
     except ValueError:
         # set some basic initialized json data
         general.set_cvar(self.cvar_key, json.dumps({"initialized": True}))
         for func in init_funcs:
             func()
예제 #7
0
def take_screenshot(open_folder=True):
    general.set_cvar('r_getScreenshot', 1)
    if open_folder:
        try:
            path = os.getcwd() + '\User\ScreenShots'
            command = r'explorer "%s"' % path
            print(command)
            subprocess.Popen(command)
        except Exception as e:
            print(e)
예제 #8
0
def restoreDefaultValue(cVars):
	if cVars not in CVARS:
		return

	defaultValue = CVARS[cVars]
	del CVARS[cVars]
	if cVars.startswith(HIDDEN_MASK_PREFIX):
		type = cVars[HIDDEN_MASK_PREFIX_LENGTH:]
		general.set_hidemask(type, defaultValue)
	else:
		general.set_cvar(cVars, defaultValue)
예제 #9
0
def toggleCvarsValue(mode, cVars, onValue, offValue):
	currentValue = general.get_cvar(cVars)

	if type(onValue) is str:
		saveDefaultValue(cVars, currentValue)
	elif type(onValue) is int:
		saveDefaultValue(cVars, int(currentValue))
	elif type(onValue) is float:
		saveDefaultValue(cVars, float(currentValue))
	else:
		general.log('Failed to store default value for {0}'.format(cVars))

	if currentValue == str(onValue):
		general.set_cvar(cVars, offValue)
	else:
		general.set_cvar(cVars, onValue)
예제 #10
0
def art():
    """Art related debug views."""

    if "e_debugdraw" not in CVARS["current"]:
        # Since it was desired to mix and match cvars, supporting additional cvar calls before we jump into cycling eDebugDraw
        if "r_wireframe" not in CVARS["current"]:
            try:
                general.set_cvar("r_wireframe", 1)
                CVARS["current"]["r_wireframe"] = 0
            except RuntimeError as exc:
                print("Debug Views: WARNING - Unable to set r_wireframe 1")
                general.log(
                    "Debug Views: WARNING - Unable to set r_wireframe 1")
        else:
            try:
                general.set_cvar("r_wireframe", 0)
                general.set_cvar("r_showlines", 2)
                CVARS["current"]["e_debugdraw"] = 0
            except RuntimeError as exc:
                print("Debug Views: WARNING - Unable to set r_wireframe 1")
                general.log(
                    "Debug Views: WARNING - Unable to set r_wireframe 1")
    else:
        # disabling any of the mixed cvars that could have been set above
        try:
            general.set_cvar("r_wireframe", 0)
            general.set_cvar("r_showlines", 0)
        except:
            pass

        eDebugDraw = cvar(
            "e_debugdraw",
            0,
            "art",
            "E_DEBUGDRAW - Review Art Assets LODs \ Texture Memory \ Render Mat Count \ Phys Tri Count.",
        )
        # NOTE: I removed e_debugdraw 1 because it was crashing after the 3.6 integration
        eDebugDraw.add_value(4, "Texture memory total for each object.")
        eDebugDraw.add_value(5, "Renderable material counts for each object.")
        eDebugDraw.add_value(19, "Physics triangle count for each object.")
        eDebugDraw.add_value(
            22,
            "Current LOD index and its corrisponding vertex count for each object."
        )

        eDebugDraw.next_value()
예제 #11
0
def init_screenshot_values():
    """
    This runs once on user_values init function created by the add to scene function which should be run every time
    an item is added to the scene so the screenshot bug never happens
    :return: None
    """
    general.set_cvar("r_DisplayInfo", 0)
    general.set_cvar("r_AntiAliasingMode", 3)
    general.set_cvar("r_CustomResWidth", 3840)
    general.set_cvar("r_CustomResHeight", 2160)
    take_screenshot(open_folder=False)
    return None
예제 #12
0
def main():
    mode = sys.argv[1]

    if mode == "start":
        print("starting")
        general.set_cvar("capture_frames", 1)
        # if we have a trackview selected play it
        try:
            trackview.play_sequence()
        except Exception:
            pass
    if mode == "stop":
        print("stopping")
        general.set_cvar("capture_frames", 0)
        # if we have a trackview playing stop it
        try:
            trackview.stop_sequence()
        except Exception:
            pass
예제 #13
0
def art():
    """Art related debug views."""

    if "e_debugdraw" not in CVARS["current"]:
        # Since it was desired to mix and match cvars, supporting additional cvar calls before we jump into cycling eDebugDraw
        if "r_wireframe" not in CVARS["current"]:
            try:
                general.set_cvar("r_wireframe", 1)
                CVARS["current"]["r_wireframe"] = 0
            except RuntimeError as exc:
                print("Debug Views: WARNING - Unable to set r_wireframe 1")
                general.log("Debug Views: WARNING - Unable to set r_wireframe 1")
        else:
            try:
                general.set_cvar("r_wireframe", 0)
                general.set_cvar("r_showlines", 2)
                CVARS["current"]["e_debugdraw"] = 0
            except RuntimeError as exc:
                print("Debug Views: WARNING - Unable to set r_wireframe 1")
                general.log("Debug Views: WARNING - Unable to set r_wireframe 1")
    else:
        # disabling any of the mixed cvars that could have been set above
        try:
            general.set_cvar("r_wireframe", 0)
            general.set_cvar("r_showlines", 0)
        except:
            pass

        eDebugDraw = cvar(
            "e_debugdraw",
            0,
            "art",
            "E_DEBUGDRAW - Review Art Assets LODs \ Texture Memory \ Render Mat Count \ Phys Tri Count.",
        )
        # NOTE: I removed e_debugdraw 1 because it was crashing after the 3.6 integration
        eDebugDraw.add_value(4, "Texture memory total for each object.")
        eDebugDraw.add_value(5, "Renderable material counts for each object.")
        eDebugDraw.add_value(19, "Physics triangle count for each object.")
        eDebugDraw.add_value(
            22, "Current LOD index and its corrisponding vertex count for each object."
        )

        eDebugDraw.next_value()
예제 #14
0
def toggleCvarsV(mode, cVars, onValue, offValue, ctrlFile):
    stateList = open(ctrlFile, 'r')
    setState = [x for x in enumerate(stateList)]
    blankCheck = [x for x in setState]
    getList = [x for x in stateList]

    if blankCheck == []:
        stateList = open(ctrlFile, 'w')
        stateList.write(
            ''.join(str("%s,{'%s': %s}" % (mode, cVars, offValue)) + '\n'))
        general.set_cvar(cVars, offValue)
    else:
        stateList = open(ctrlFile, 'r')
        checkFor = str([x for x in stateList])

        if mode not in str(checkFor):
            stateList = open(ctrlFile, 'r')
            getList = [x for x in stateList]
            getList.insert(1, str("%s,{'%s': %s}\n" % (mode, cVars, offValue)))
            print str("{'%s': %s}\n" % (cVars, offValue))
            stateList = open(ctrlFile, 'w')
            stateList.write(''.join(getList))
            general.set_cvar(cVars, offValue)

        else:
            stateList = open(ctrlFile, 'r')
            for d in enumerate(stateList):
                values = d[1].split(',')
                stateList = open(ctrlFile, 'r')
                getList = [x for x in stateList]

                if mode in values[0]:
                    getDict = ast.literal_eval(values[1])
                    getState = getDict.get(cVars)

                    if getState == offValue:
                        getDict[cVars] = onValue
                        joinStr = [mode, ",", str(getDict), '\n']
                        newLine = ''.join(joinStr)
                        print getDict
                        getList[d[0]] = newLine
                        stateList = open(ctrlFile, 'w')
                        stateList.write(''.join(str(''.join(getList))))
                        general.set_cvar(cVars, onValue)
                    else:
                        getDict[cVars] = offValue
                        joinStr = [mode, ",", str(getDict), '\n']
                        newLine = ''.join(joinStr)
                        print getDict
                        getList[d[0]] = newLine
                        stateList = open(ctrlFile, 'w')
                        stateList.write(''.join(str(''.join(getList))))
                        general.set_cvar(cVars, offValue)
예제 #15
0
def init_screenshot_values():
    """
    This runs once on user_values init function created by the add to scene function which should be run every time
    an item is added to the scene so the screenshot bug never happens
    :return: None
    """
    general.set_cvar("r_DisplayInfo", 0)
    general.set_cvar("r_AntiAliasingMode", 3)
    general.set_cvar("r_CustomResWidth", 3840)
    general.set_cvar("r_CustomResHeight", 2160)
    take_screenshot(open_folder=False)
    return None
def toggleCvarsV(mode, cVars, onValue, offValue, ctrlFile):
	stateList = open(ctrlFile, 'r') 
	setState = [x for x in enumerate(stateList)] 
	blankCheck = [x for x in setState]
	getList = [x for x in stateList]
	
	if blankCheck == []:
		stateList = open(ctrlFile, 'w')
		stateList.write(''.join(str("%s,{'%s': %s}" % (mode, cVars, offValue))+'\n'))
		general.set_cvar(cVars, offValue)
	else:
		stateList = open(ctrlFile, 'r')
		checkFor = str([x for x in stateList])

		if mode not in str(checkFor):
			stateList = open(ctrlFile, 'r')
			getList = [x for x in stateList] 
			getList.insert(1, str("%s,{'%s': %s}\n" % (mode, cVars , offValue)))
			print str("{'%s': %s}\n" % (cVars , offValue))
			stateList = open(ctrlFile, 'w')
			stateList.write(''.join(getList))	
			general.set_cvar(cVars, offValue)
			
		else:
			stateList = open(ctrlFile, 'r')
			for d in enumerate(stateList):
				values = d[1].split(',')
				stateList = open(ctrlFile, 'r')
				getList = [x for x in stateList] 
				
				if mode in values[0]:
					getDict = ast.literal_eval(values[1])
					getState = getDict.get(cVars)
					
					if getState == offValue:
						getDict[cVars] = onValue
						joinStr = [mode,",",str(getDict), '\n']
						newLine = ''.join(joinStr)
						print getDict
						getList[d[0]] = newLine
						stateList = open(ctrlFile, 'w')
						stateList.write(''.join(str(''.join(getList))))
						general.set_cvar(cVars, onValue)
					else: 
						getDict[cVars] = offValue
						joinStr = [mode,",",str(getDict), '\n']
						newLine = ''.join(joinStr)
						print getDict
						getList[d[0]] = newLine
						stateList = open(ctrlFile, 'w')
						stateList.write(''.join(str(''.join(getList))))
						general.set_cvar(cVars, offValue)
예제 #17
0
def reset_cvars():
    """Walk over all modified cvar values and return them to their default expected values"""
    for var in CVARS["current"]:
        if DEBUG:
            print("Var: {0}, Value: {1}".format(var, CVARS["current"][var]))

        try:
            general.set_cvar(var, CVARS["current"][var])
        except RuntimeError as exc:
            print(
                "Debug Views: WARNING - Unable to reset the CVAR {0} {1} due to error {2}"
                .format(var, CVARS["current"][var], exc))
            general.log(
                "Debug Views: WARNING - Unable to reset the CVAR {0} {1} due to error {2}"
                .format(var, CVARS["current"][var], exc))

    CVARS["current"].clear()

    CVARS["commands"] = None
    print("Debug Views: Reset To Default View Mode...")
    general.log("Debug Views: Resetting To Default View Mode...")
def cycleCvarsFloatValue(cVars, cycleList):
	currentValueAsString = general.get_cvar(cVars)
	try:
		currentValue = float(currentValueAsString)
	except:
		currentValue = -1.0

	# make sure we sort the list in ascending fashion
	cycleList = sorted(cycleList)

	# find out what the next closest index is
	newIndex = 0
	for x in cycleList:
		if (currentValue < x):
			break
		newIndex = newIndex + 1

	# loop around, if we need to
	if newIndex >= len(cycleList):
		newIndex = 0

	general.set_cvar(cVars, cycleList[newIndex])
예제 #19
0
def init_cvars(type):
    """Set any cvars that"""
    # Display info is often in the way when displaying debug views, so just disable it always
    set_auxiliary_cvar("r_displayinfo", int(general.get_cvar("r_displayinfo")),
                       0)

    # If the user has switched from one debug view type to a different one before switching,
    # Return the previous debug view type to its default value along with all auxiliary cvars
    reset = False

    if int(general.get_cvar("r_debugGBuffer")) and type != "gbuffers":
        reset = True
    if int(general.get_cvar("r_stats")) and type != "profiling":
        reset = True
    if int(general.get_cvar("ai_DebugDraw")) != -1 and type != "ai":
        reset = True
    if int(general.get_cvar("e_debugdraw")) and type != "art":
        reset = True
    if int(general.get_cvar("mfx_debug")) and type != "materialfx":
        reset = True
    # to be reinstated using ATL
    # if int(general.get_cvar('s_SoundInfo')) and type != 'soundfx': reset = True

    if int(general.get_cvar("r_wireframe")):
        try:
            general.set_cvar("r_wireframe", 0)
        except:
            pass

    if int(general.get_cvar("r_showlines")):
        try:
            general.set_cvar("r_showlines", 0)
        except:
            pass

    if reset:
        reset_cvars()
예제 #20
0
def init_cvars(type):
    """Set any cvars that"""
    # Display info is often in the way when displaying debug views, so just disable it always
    set_auxiliary_cvar("r_displayinfo", int(general.get_cvar("r_displayinfo")), 0)

    # If the user has switched from one debug view type to a different one before switching,
    # Return the previous debug view type to its default value along with all auxiliary cvars
    reset = False

    if int(general.get_cvar("r_debugGBuffer")) and type != "gbuffers":
        reset = True
    if int(general.get_cvar("r_stats")) and type != "profiling":
        reset = True
    if int(general.get_cvar("ai_DebugDraw")) != -1 and type != "ai":
        reset = True
    if int(general.get_cvar("e_debugdraw")) and type != "art":
        reset = True
    if int(general.get_cvar("mfx_debug")) and type != "materialfx":
        reset = True
    # to be reinstated using ATL
    # if int(general.get_cvar('s_SoundInfo')) and type != 'soundfx': reset = True

    if int(general.get_cvar("r_wireframe")):
        try:
            general.set_cvar("r_wireframe", 0)
        except:
            pass

    if int(general.get_cvar("r_showlines")):
        try:
            general.set_cvar("r_showlines", 0)
        except:
            pass

    if reset:
        reset_cvars()
예제 #21
0
 def set(self, key, value):
     user_values = self.get_all()
     user_values[key] = value
     return general.set_cvar(self.cvar_key, json.dumps(user_values))
def cycleCvarsV(mode, cVars, cycleList, ctrlFile):
	stateList = open(ctrlFile, 'r') 
	setState 	= [x for x in enumerate(stateList)] 
	blankCheck 	= [x for x in setState]
	getList = [x for x in stateList]

	if blankCheck == []:
		stateList = open(ctrlFile, 'w')
		stateList.write(''.join(str("%s,{'%s': %s}" % (mode, cVars, cycleList[1]))+'\n'))
		general.set_cvar(cVars, cycleList[1])
	else:
		stateList = open(ctrlFile, 'r')
		checkFor = str([x for x in stateList])
		
		if mode not in str(checkFor):
			stateList = open(ctrlFile, 'r')
			getList = [x for x in stateList] 
			getList.insert(1, str("%s,{'%s': %s}\n" % (mode, cVars , cycleList[1])))
			#print '%s' % cycleList[1]
			stateList = open(ctrlFile, 'w')
			stateList.write(''.join(getList))	
			general.set_cvar(cVars, cycleList[1])

		else:
			stateList = open(ctrlFile, 'r')
			
			for d in enumerate(stateList):
				stateList = open(ctrlFile, 'r')
				getList = [x for x in stateList] 
				values = d[1].split(',')
				
				if mode in values[0]:
					getDict = ast.literal_eval(values[1])
					getState = getDict.get(cVars)

					cycleL = [x for x in enumerate(cycleList)]

					for x in cycleL:
						if getState == x[1]:
							number = [n[1] for n in cycleL] 
							getMax = max(number)
							nextNum = x[0]+1
						
							if nextNum > getMax:
								getDict[cVars] = cycleList[0]
								joinStr = [mode,",",str(getDict), '\n']
								newLine = ''.join(joinStr)
								getList[d[0]] = newLine
								print getDict
								stateList = open(ctrlFile, 'w')
								stateList.write(''.join(str(''.join(getList))))
								general.set_cvar(cVars, cycleList[0])
							else:
								getDict[cVars] = cycleList[x[0]+1]
								joinStr = [mode,",",str(getDict), '\n']
								newLine = ''.join(joinStr)
								getList[d[0]] = newLine
								print getDict
								stateList = open(ctrlFile, 'w')
								stateList.write(''.join(str(''.join(getList))))
								general.set_cvar(cVars, cycleList[x[0]+1])
예제 #23
0
 def set_value(self, value, desc):
     print("Displaying {0} = {1} - {2}".format(self.name, value, desc))
     general.set_cvar(self.name, value)
예제 #24
0
파일: __init__.py 프로젝트: joqqy/CE_Python
 def set(self, key, value):
     user_values = self.get_all()
     user_values[key] = value
     return general.set_cvar(self.cvar_key, json.dumps(user_values))
예제 #25
0
파일: __init__.py 프로젝트: joqqy/CE_Python
 def delete(self, key):
     user_values = self.get_all()
     del user_values[key]
     return general.set_cvar(self.cvar_key, json.dumps(user_values))
예제 #26
0
def set_cvar(cvar, value):
    general.set_cvar(cvar, value)
예제 #27
0
def updateCvars(cVars, value):
	saveDefaultValue(cVars, value)
	general.set_cvar(cVars, value)
예제 #28
0
def cycleCvarsV(mode, cVars, cycleList, ctrlFile):
    stateList = open(ctrlFile, 'r')
    setState = [x for x in enumerate(stateList)]
    blankCheck = [x for x in setState]
    getList = [x for x in stateList]

    if blankCheck == []:
        stateList = open(ctrlFile, 'w')
        stateList.write(
            ''.join(str("%s,{'%s': %s}" % (mode, cVars, cycleList[1])) + '\n'))
        general.set_cvar(cVars, cycleList[1])
    else:
        stateList = open(ctrlFile, 'r')
        checkFor = str([x for x in stateList])

        if mode not in str(checkFor):
            stateList = open(ctrlFile, 'r')
            getList = [x for x in stateList]
            getList.insert(
                1, str("%s,{'%s': %s}\n" % (mode, cVars, cycleList[1])))
            #print '%s' % cycleList[1]
            stateList = open(ctrlFile, 'w')
            stateList.write(''.join(getList))
            general.set_cvar(cVars, cycleList[1])

        else:
            stateList = open(ctrlFile, 'r')

            for d in enumerate(stateList):
                stateList = open(ctrlFile, 'r')
                getList = [x for x in stateList]
                values = d[1].split(',')

                if mode in values[0]:
                    getDict = ast.literal_eval(values[1])
                    getState = getDict.get(cVars)

                    cycleL = [x for x in enumerate(cycleList)]

                    for x in cycleL:
                        if getState == x[1]:
                            number = [n[1] for n in cycleL]
                            getMax = max(number)
                            nextNum = x[0] + 1

                            if nextNum > getMax:
                                getDict[cVars] = cycleList[0]
                                joinStr = [mode, ",", str(getDict), '\n']
                                newLine = ''.join(joinStr)
                                getList[d[0]] = newLine
                                print getDict
                                stateList = open(ctrlFile, 'w')
                                stateList.write(''.join(str(''.join(getList))))
                                general.set_cvar(cVars, cycleList[0])
                            else:
                                getDict[cVars] = cycleList[x[0] + 1]
                                joinStr = [mode, ",", str(getDict), '\n']
                                newLine = ''.join(joinStr)
                                getList[d[0]] = newLine
                                print getDict
                                stateList = open(ctrlFile, 'w')
                                stateList.write(''.join(str(''.join(getList))))
                                general.set_cvar(cVars, cycleList[x[0] + 1])
예제 #29
0
 def set_value(self, value, desc):
     print("Displaying {0} = {1} - {2}".format(self.name, value, desc))
     general.set_cvar(self.name, value)
예제 #30
0
 def delete(self, key):
     user_values = self.get_all()
     del user_values[key]
     return general.set_cvar(self.cvar_key, json.dumps(user_values))
def toggleCvarsValue(mode, cVars, onValue, offValue):
	currentValue = general.get_cvar(cVars)
	if currentValue == str(onValue):
		general.set_cvar(cVars, offValue)
	else:
		general.set_cvar(cVars, onValue)
예제 #32
0
def main():
    output_format = general.edit_box("Output Format [jpg | tga]")
    general.set_cvar("capture_file_format", output_format)
    [folder] = bfd.get_file_path_list(False, general.get_game_folder(), True)
    general.set_cvar("capture_folder", folder)
    general.set_cvar("r_displayInfo", 0)
    # 1 second / amount of frames 1/30 = 0.03333 =  30fps
    fps = general.edit_box("Frames Per Second")
    general.set_cvar("t_fixedstep", 1.0 / int(fps))
    general.set_cvar("r_CustomResPreview", 1)
    general.set_cvar("r_CustomResMaxSize", 4096)
    width = general.edit_box("Width")
    height = general.edit_box("Height")
    general.set_cvar("r_CustomResWidth", int(width))
    general.set_cvar("r_CustomResHeight", int(height))
    try:
        command = r'explorer "%s"' % folder
        subprocess.Popen(command)
    except Exception as e:
        print(e)