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])
Example #2
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()
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)
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)
Example #5
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()
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)
Example #7
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

    saveDefaultValue(cVars, currentValue)

    # 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])
Example #9
0
 def set_value(self, value, desc):
     print('Displaying {0} = {1} - {2}'.format(self.name, value, desc))
     general.set_cvar(self.name, value)
Example #10
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'''
    CVARS['current'][cvar] = default
    general.set_cvar(cvar, value)
def updateCvars(cVars, value):
    saveDefaultValue(cVars, value)
    general.set_cvar(cVars, value)
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])))
            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])