def __init__(self, name, default, category, description=None): self.name = name self.default = default self.description = description self.category = category self.values = [] CVARS["current"][self.name] = default try: self.curValue = eval(general.get_cvar(name)) except: self.curValue = general.get_cvar(name) if self.category in CVARS: if self not in CVARS[self.category]: CVARS[self.category].append(self)
def gbuffers(): """GBuffer related debug views.""" # Init the current cvar and add all desired values. rGBuffers = cvar( "r_debugGBuffer", 0, "gbuffers", "R_DebugGBuffers - Filter all gbuffers down via a given buffer.", ) rGBuffers.add_value(1, "Normals") rGBuffers.add_value(2, "Gloss") rGBuffers.add_value(3, "Specular") rGBuffers.add_value(4, "Diffuse") rGBuffers.add_value(5, "Translucency") rGBuffers.add_value(6, "Baked AO") rGBuffers.add_value(7, "Subsurface Scattering") rGBuffers.add_value(8, "Specular Validation Overlay") # Set default values for the cvars in-case we need to reset_cvars() back to original values # Set any other manditory cvars to display buffers. set_auxiliary_cvar( "r_AntialiasingMode", int(general.get_cvar("r_AntialiasingMode")), 0 ) # Display the first or next gbuffer, if exception met, or we have reached the final buffers, stop the update function and reset all changed cvars. rGBuffers.next_value()
def gbuffers(): """GBuffer related debug views.""" # Init the current cvar and add all desired values. rGBuffers = cvar( "r_debugGBuffer", 0, "gbuffers", "R_DebugGBuffers - Filter all gbuffers down via a given buffer.", ) rGBuffers.add_value(1, "Normals") rGBuffers.add_value(2, "Gloss") rGBuffers.add_value(3, "Specular") rGBuffers.add_value(4, "Diffuse") rGBuffers.add_value(5, "Translucency") rGBuffers.add_value(6, "Baked AO") rGBuffers.add_value(7, "Subsurface Scattering") rGBuffers.add_value(8, "Specular Validation Overlay") # Set default values for the cvars in-case we need to reset_cvars() back to original values # Set any other manditory cvars to display buffers. set_auxiliary_cvar("r_AntialiasingMode", int(general.get_cvar("r_AntialiasingMode")), 0) # Display the first or next gbuffer, if exception met, or we have reached the final buffers, stop the update function and reset all changed cvars. rGBuffers.next_value()
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])
def profiling(): """Profiling related debug views.""" rStats = cvar("r_stats", 0, "profiling", "R_STATS - Review CPU \ GPU \ Frame \ Asset Timings.") rStats.add_value(1, "Frame Timings.") rStats.add_value(3, "Object Timings.") rStats.add_value(6, "Per Instance Draw Calls.") rStats.add_value(16, "GPU Sync Timings.") # Disable GI when profiling as it causes unnecessary jittering in the threads output set_auxiliary_cvar("e_gi", int(general.get_cvar("e_gi")), 0) rStats.next_value()
def profiling(): """Profiling related debug views.""" rStats = cvar( "r_stats", 0, "profiling", "R_STATS - Review CPU \ GPU \ Frame \ Asset Timings." ) rStats.add_value(1, "Frame Timings.") rStats.add_value(3, "Object Timings.") rStats.add_value(6, "Per Instance Draw Calls.") rStats.add_value(16, "GPU Sync Timings.") # Disable GI when profiling as it causes unnecessary jittering in the threads output set_auxiliary_cvar("e_gi", int(general.get_cvar("e_gi")), 0) rStats.next_value()
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)
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()
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])
def get_all(self): return json.loads(general.get_cvar(self.cvar_key))
def get(self, key): values = json.loads(general.get_cvar(self.cvar_key)) try: return values[key] except KeyError: return None
def save(name=False, overwrite=False, embellishment=None): """ Save an Icon Setup :return: string name of the entity class name """ # name of icon_object in icon_level.cry ico_obj = "icon_object_shot" store = UserValues() # the obj to insert obj = dict() # instantiate our iodb try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return None # clear the selection general.clear_selection() # get the info from the icon_object_shot obj["pos"] = general.get_position(ico_obj) obj["scale"] = general.get_scale(ico_obj) obj["rot"] = general.get_rotation(ico_obj) obj["mtl"] = general.get_assigned_material(ico_obj) obj["tod"] = general.get_cvar("e_timeOfDay") # get the brush by selecting the ico_obj general.select_object(ico_obj) obj["brush"] = lodtools.getselected().lower() general.clear_selection() stored = io.get_obj_by_brush_and_mtl(obj["brush"], obj["mtl"]) if embellishment: print("Saving Embellishments") obj["embellishment_48"] = embellishment["embellishment_48"] obj["embellishment_200"] = embellishment["embellishment_200"] obj["embellishment_2048"] = embellishment["embellishment_2048"] if "embellishment_under" in embellishment.keys(): obj["embellishment_under"] = True else: icon_obj = store.get("current_icon_object") if icon_obj: keys = icon_obj.keys() if "embellishment_under" in keys: obj["embellishment_under"] = True if "embellishment_48" in keys: obj["embellishment_48"] = icon_obj["embellishment_48"] if "embellishment_200" in keys: obj["embellishment_200"] = icon_obj["embellishment_200"] if "embellishment_2048" in keys: obj["embellishment_2048"] = icon_obj["embellishment_2048"] if name: obj["name"] = name elif stored: obj["name"] = stored["name"] if not general.message_box_yes_no(str("Save " + stored["name"] + "?")): obj["name"] = general.edit_box("Entity ClassName") else: overwrite = True else: obj["name"] = general.edit_box("Entity ClassName") if io.insert_object(obj) is False: if overwrite: io.insert_object(obj, override=True) else: if general.message_box_yes_no("Overwrite?"): io.insert_object(obj, override=True) print("Storing Item into UserValues") store.set("current_icon_object", obj) return obj["name"]
def get_value(self): try: return eval(general.get_cvar(self.name)) except: return general.get_cvar(self.name)
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)