Removed legacy scripts, closes #2549
Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com>
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
"""
|
||||
This script loads every level in a game project and exports them. You will be prompted with the standard
|
||||
Check-Out/Overwrite/Cancel dialog for each level.
|
||||
This is useful when there is a version update to a file that requires re-exporting.
|
||||
"""
|
||||
import sys, os
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.legacy.checkout_dialog as checkout_dialog
|
||||
|
||||
|
||||
class CheckOutDialogEnableAll:
|
||||
"""
|
||||
Helper class to wrap enabling the "Apply to all" checkbox in the CheckOutDialog.
|
||||
Guarantees that the old setting will be restored.
|
||||
To use, do:
|
||||
|
||||
with CheckOutDialogEnableAll():
|
||||
# your code here
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.old_setting = False
|
||||
|
||||
def __enter__(self):
|
||||
self.old_setting = checkout_dialog.enable_for_all(True)
|
||||
print(self.old_setting)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
checkout_dialog.enable_for_all(self.old_setting)
|
||||
|
||||
|
||||
level_list = []
|
||||
|
||||
|
||||
def is_in_special_folder(file_full_path):
|
||||
if file_full_path.find("_savebackup") >= 0:
|
||||
return True
|
||||
if file_full_path.find("_autobackup") >= 0:
|
||||
return True
|
||||
if file_full_path.find("_hold") >= 0:
|
||||
return True
|
||||
if file_full_path.find("_tmpresize") >= 0:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
game_folder = general.get_game_folder()
|
||||
|
||||
|
||||
# Recursively search every directory in the game project for files ending with .cry and .ly
|
||||
for root, dirs, files in os.walk(game_folder):
|
||||
for file in files:
|
||||
if file.endswith(".cry") or file.endswith(".ly"):
|
||||
# The engine expects the full path of the .cry file
|
||||
file_full_path = os.path.abspath(os.path.join(root, file))
|
||||
# Exclude files in special directories
|
||||
if not is_in_special_folder(file_full_path):
|
||||
level_list.append(file_full_path)
|
||||
|
||||
# make the checkout dialog enable the 'Apply to all' checkbox
|
||||
with CheckOutDialogEnableAll():
|
||||
|
||||
# For each valid .cry file found, open it in the editor and export it
|
||||
for level in level_list:
|
||||
if not isinstance(level, str):
|
||||
# general.open_level_no_prompt expects the file path in utf8 format
|
||||
level = level.encode("utf-8")
|
||||
|
||||
general.open_level_no_prompt(level)
|
||||
general.export_to_engine()
|
||||
@@ -1,40 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
'''
|
||||
Generates a 50% lod for the selected model
|
||||
|
||||
@argument name="Lod Percentage", type="string", default="50.0f"
|
||||
'''
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
percentage = float(sys.argv[1])
|
||||
|
||||
selectedcgf = lodtools.getselected()
|
||||
selectedmaterial = lodtools.getselectedmaterial()
|
||||
|
||||
loadedmodel = lodtools.loadcgf(selectedcgf)
|
||||
loadedmaterial = lodtools.loadmaterial(selectedmaterial)
|
||||
|
||||
if loadedmodel == True and loadedmaterial == True:
|
||||
lodtools.generatelodchain()
|
||||
finished = 0.0
|
||||
while finished >= 0.0:
|
||||
finished = lodtools.generatetick()
|
||||
print 'Lod Chain Generation progress: ' + str(finished)
|
||||
time.sleep(1)
|
||||
if finished == 1.0:
|
||||
break
|
||||
|
||||
lodtools.createlod(1,percentage)
|
||||
lodtools.generatematerials(1,512,512)
|
||||
lodtools.savetextures(1)
|
||||
lodtools.savesettings()
|
||||
lodtools.reloadmodel()
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
# This script shows basic usage of LuaSymbolsReporterBus,
|
||||
# Which can be used to report all symbols available for
|
||||
# game scripting with Lua.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
import azlmbr.bus as azbus
|
||||
import azlmbr.script as azscript
|
||||
import azlmbr.legacy.general as azgeneral
|
||||
|
||||
|
||||
def _dump_class_symbol(class_symbol: azlmbr.script.LuaClassSymbol):
|
||||
print(f"** {class_symbol}")
|
||||
print("Properties:")
|
||||
for property_symbol in class_symbol.properties:
|
||||
print(f" - {property_symbol}")
|
||||
print("Methods:")
|
||||
for method_symbol in class_symbol.methods:
|
||||
print(f" - {method_symbol}")
|
||||
|
||||
|
||||
def _dump_lua_classes():
|
||||
class_symbols = azscript.LuaSymbolsReporterBus(azbus.Broadcast,
|
||||
"GetListOfClasses")
|
||||
print("======== Classes ==========")
|
||||
sorted_classes_by_named = sorted(class_symbols, key=lambda class_symbol: class_symbol.name)
|
||||
for class_symbol in sorted_classes_by_named:
|
||||
_dump_class_symbol(class_symbol)
|
||||
print("\n\n")
|
||||
|
||||
|
||||
def _dump_lua_globals():
|
||||
global_properties = azscript.LuaSymbolsReporterBus(azbus.Broadcast,
|
||||
"GetListOfGlobalProperties")
|
||||
print("======== Global Properties ==========")
|
||||
sorted_properties_by_name = sorted(global_properties, key=lambda symbol: symbol.name)
|
||||
for property_symbol in sorted_properties_by_name:
|
||||
print(f"- {property_symbol}")
|
||||
print("\n\n")
|
||||
global_functions = azscript.LuaSymbolsReporterBus(azbus.Broadcast,
|
||||
"GetListOfGlobalFunctions")
|
||||
print("======== Global Functions ==========")
|
||||
sorted_functions_by_name = sorted(global_functions, key=lambda symbol: symbol.name)
|
||||
for function_symbol in sorted_functions_by_name:
|
||||
print(f"- {function_symbol}")
|
||||
print("\n\n")
|
||||
|
||||
|
||||
def _dump_lua_ebus(ebus_symbol: azlmbr.script.LuaEBusSymbol):
|
||||
print(f">> {ebus_symbol}")
|
||||
sorted_senders = sorted(ebus_symbol.senders, key=lambda symbol: symbol.name)
|
||||
for sender in sorted_senders:
|
||||
print(f" - {sender}")
|
||||
print("\n")
|
||||
|
||||
|
||||
def _dump_lua_ebuses():
|
||||
ebuses = azscript.LuaSymbolsReporterBus(azbus.Broadcast,
|
||||
"GetListOfEBuses")
|
||||
print("======== Ebus List ==========")
|
||||
sorted_ebuses_by_name = sorted(ebuses, key=lambda symbol: symbol.name)
|
||||
for ebus_symbol in sorted_ebuses_by_name:
|
||||
_dump_lua_ebus(ebus_symbol)
|
||||
print("\n\n")
|
||||
|
||||
|
||||
class WhatToDo:
|
||||
DumpClasses = "c"
|
||||
DumpGlobals = "g"
|
||||
DumpEBuses = "e"
|
||||
|
||||
if __name__ == "__main__":
|
||||
redirecting_stdout = False
|
||||
orig_stdout = sys.stdout
|
||||
if len(sys.argv) > 1:
|
||||
output_file_name = sys.argv[1]
|
||||
if not os.path.isabs(output_file_name):
|
||||
game_root_path = os.path.normpath(azgeneral.get_game_folder())
|
||||
output_file_name = os.path.join(game_root_path, output_file_name)
|
||||
try:
|
||||
file_obj = open(output_file_name, 'wt')
|
||||
sys.stdout = file_obj
|
||||
redirecting_stdout = True
|
||||
except Exception as e:
|
||||
print(f"Failed to open {output_file_name}: {e}")
|
||||
sys.exit(-1)
|
||||
|
||||
what_to_do = [action.lower() for action in sys.argv[2:]]
|
||||
|
||||
# If the user did not specify what to do, then let's dump
|
||||
# all the symbols.
|
||||
if len(what_to_do) < 1:
|
||||
what_to_do = [WhatToDo.DumpClasses, WhatToDo.DumpGlobals, WhatToDo.DumpEBuses]
|
||||
|
||||
for action in what_to_do:
|
||||
if action == WhatToDo.DumpClasses:
|
||||
_dump_lua_classes()
|
||||
elif action == WhatToDo.DumpGlobals:
|
||||
_dump_lua_globals()
|
||||
elif action == WhatToDo.DumpEBuses:
|
||||
_dump_lua_ebuses()
|
||||
|
||||
if redirecting_stdout:
|
||||
sys.stdout.close()
|
||||
sys.stdout = orig_stdout
|
||||
print(f" Lua Symbols Are available in: {output_file_name}")
|
||||
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
objects = general.get_all_objects("", "") # Get the name list of all objects in the level.
|
||||
# If there is any object with the geometry file of "objects\\default\\primitive_box.cgf",
|
||||
# change it to "objects\\default\\primitive_cube.cgf".
|
||||
for obj in objects:
|
||||
geometry_file = general.get_entity_geometry_file(obj)
|
||||
if geometry_file == "objects\\default\\primitive_box.cgf":
|
||||
general.set_entity_geometry_file(obj, "objects\\default\\primitive_cube.cgf")
|
||||
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
objects = general.get_all_objects("AnimObject", "") # Get the name list of all anim objects in the level.
|
||||
general.clear_selection()
|
||||
# If there is any object with the geometry file whose name contains "\\story\\", select it
|
||||
for obj in objects:
|
||||
geometry_file = general.get_entity_geometry_file(obj)
|
||||
if geometry_file.find("\\story\\") != -1:
|
||||
general.select_object(obj)
|
||||
@@ -1,508 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
import __future__
|
||||
import time, re, os, sys, itertools, ast
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
global ctrlFile
|
||||
ctrlFile = 'setState.txt'
|
||||
global logfile
|
||||
logfile = 'Editor.log'
|
||||
|
||||
global HIDDEN_MASK_PREFIX
|
||||
HIDDEN_MASK_PREFIX= 'hidden_mask_for_'
|
||||
global HIDDEN_MASK_PREFIX_LENGTH
|
||||
HIDDEN_MASK_PREFIX_LENGTH = len(HIDDEN_MASK_PREFIX)
|
||||
|
||||
def getLogList(logfile):
|
||||
logList = [x for x in open(logfile, 'r')]
|
||||
return logList
|
||||
|
||||
def getCheckList(ctrlFile):
|
||||
try:
|
||||
with open(ctrlFile):
|
||||
stateList = open(ctrlFile, 'r')
|
||||
|
||||
except:
|
||||
open(ctrlFile, 'w').close()
|
||||
stateList = open(ctrlFile, 'r')
|
||||
|
||||
checkList = [x for x in stateList]
|
||||
return checkList
|
||||
|
||||
#Store/Restore CVars default values -----------------------------------------------------------------#
|
||||
if 'CVARS' not in globals():
|
||||
CVARS = {}
|
||||
|
||||
def saveDefaultValue(cVars, value):
|
||||
if cVars not in CVARS:
|
||||
CVARS[cVars] = value
|
||||
|
||||
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)
|
||||
|
||||
#toggle CVars--------------------------------------------------------------------#
|
||||
|
||||
def updateCvars(cVars, value):
|
||||
saveDefaultValue(cVars, value)
|
||||
general.set_cvar(cVars, value)
|
||||
|
||||
def toggleCvarsRestartCheck(log, state, mode, cVars, onValue, offValue, ctrlFile):
|
||||
if log in state:
|
||||
toggleCvarsV(mode, cVars, onValue, offValue, ctrlFile)
|
||||
else:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(log)
|
||||
stateList = open(ctrlFile, 'r')
|
||||
toggleCvarsV(mode, cVars, onValue, offValue, ctrlFile)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
#toggleConsol--------------------------------------------------------------------#
|
||||
|
||||
def toggleConsolRestartCheck(log,state, mode, onValue, offValue, ctrlFile):
|
||||
if log in state:
|
||||
toggleConsolV(mode, onValue, offValue, ctrlFile)
|
||||
else:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(log)
|
||||
stateList = open(ctrlFile, 'r')
|
||||
toggleConsolV(mode, onValue, offValue, ctrlFile)
|
||||
|
||||
def toggleConsolV(mode, onValue, offValue):
|
||||
stateList = open(ctrlFile, 'r')
|
||||
setState = [x for x in enumerate(stateList)]
|
||||
blankCheck = [x for x in setState]
|
||||
getList = [x for x in stateList]
|
||||
onOffList = [onValue, offValue]
|
||||
|
||||
if blankCheck == []:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(str("%s,'%s'" % (mode, offValue))+'\n'))
|
||||
general.run_console(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'\n" % (mode, offValue)))
|
||||
print (str("{'%s': %s}\n" % (cVars , offValue)))
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(getList))
|
||||
general.run_console(onValue)
|
||||
|
||||
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 = values[1]
|
||||
off = ["'",str(offValue),"'", '\n']
|
||||
joinoff = ''.join(off)
|
||||
|
||||
if values[1] == joinoff:
|
||||
getDict = onValue
|
||||
joinStr = [mode,",","'",getDict,"'", '\n']
|
||||
newLine = ''.join(joinStr)
|
||||
print (getDict)
|
||||
getList[d[0]] = str(newLine)
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(str(''.join(getList))))
|
||||
general.run_console(onValue)
|
||||
else:
|
||||
getDict = offValue
|
||||
joinStr = [mode,",","'",getDict,"'", '\n']
|
||||
newLine = ''.join(joinStr)
|
||||
print (getDict)
|
||||
getList[d[0]] = str(newLine)
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(str(''.join(getList))))
|
||||
general.run_console(offValue)
|
||||
|
||||
def toggleConsolValue(log, state, mode, onValue, offValue):
|
||||
logList = getLogList(logfile)
|
||||
checkList = getCheckList(ctrlFile)
|
||||
toggleConsolRestartCheck(logList[1],checkList, mode, onValue, offValue, ctrlFile)
|
||||
|
||||
#cycleCvars----------------------------------------------------------------------#
|
||||
|
||||
def cycleCvarsRestartCheck(log, state, mode, cVars, cycleList, ctrlFile):
|
||||
if log in state:
|
||||
cycleCvarsV(mode, cVars, cycleList, ctrlFile)
|
||||
else:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(log)
|
||||
stateList = open(ctrlFile, 'r')
|
||||
cycleCvarsV(mode, cVars, cycleList, ctrlFile)
|
||||
|
||||
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])
|
||||
|
||||
def cycleCvarsValue(log, state, mode, cVars, cycleList):
|
||||
logList = getLogList(logfile)
|
||||
checkList = getCheckList(ctrlFile)
|
||||
cycleCvarsRestartCheck(logList[1],checkList, mode, cVars, cycleList, ctrlFile)
|
||||
|
||||
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])
|
||||
|
||||
|
||||
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])
|
||||
|
||||
#cycleConsol----------------------------------------------------------------------#
|
||||
|
||||
def cycleConsolRestartCheck(log, state, mode, cycleList, ctrlFile):
|
||||
if log in state:
|
||||
cycleConsolV(mode, cycleList, ctrlFile)
|
||||
else:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(log)
|
||||
stateList = open(ctrlFile, 'r')
|
||||
cycleConsolV(mode, cycleList, ctrlFile)
|
||||
|
||||
def cycleConsolV(mode, 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'" % (mode, cycleList[0]))+'\n'))
|
||||
general.run_console(cycleList[0])
|
||||
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'\n" % (mode, cycleList[0])))
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(getList))
|
||||
general.run_console(cycleList[0])
|
||||
|
||||
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]:
|
||||
newValue = ''.join(values[1].split('\n'))
|
||||
cycleL = [e for e in enumerate(cycleList)]
|
||||
getDict = ''.join(values[1].split('\n'))
|
||||
|
||||
for x in cycleL:
|
||||
|
||||
if newValue in "'%s'" % x[1]:
|
||||
number = [n[0] for n in cycleL]
|
||||
getMax = max(number)
|
||||
nextNum = x[0]+1
|
||||
|
||||
if nextNum > getMax:
|
||||
getDict = '%s' % cycleList[0]
|
||||
joinStr = [mode,",","'",getDict,"'", '\n']
|
||||
newLine = ''.join(joinStr)
|
||||
getList[d[0]] = newLine
|
||||
print (getDict)
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(str(''.join(getList))))
|
||||
general.run_console(getDict)
|
||||
else:
|
||||
getDict = '%s' % cycleList[x[0]+1]
|
||||
joinStr = [mode,",","'",getDict,"'", '\n']
|
||||
newLine = ''.join(joinStr)
|
||||
getList[d[0]] = newLine
|
||||
print (getDict)
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(str(''.join(getList))))
|
||||
general.run_console(getDict)
|
||||
|
||||
def cycleConsolValue(mode, cycleList):
|
||||
logList = getLogList(logfile)
|
||||
checkList = getCheckList(ctrlFile)
|
||||
cycleConsolRestartCheck(logList[1],checkList, mode, cycleList, ctrlFile)
|
||||
|
||||
def toggleHideMaskValues(type):
|
||||
cVars = "%s%s" % (HIDDEN_MASK_PREFIX, type)
|
||||
currentValue = general.get_hidemask(type)
|
||||
saveDefaultValue(cVars, int(currentValue))
|
||||
if (currentValue):
|
||||
general.set_hidemask(type, 0)
|
||||
else:
|
||||
general.set_hidemask(type, 1)
|
||||
|
||||
#toggleHide------------------------------------------------------------------------#
|
||||
|
||||
def toggleHideRestartCheck(log, state, mode, type, onValue, offValue, ctrlFile):
|
||||
if log in state:
|
||||
toggleHideByT(mode, type, onValue, offValue, ctrlFile)
|
||||
else:
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(log)
|
||||
stateList = open(ctrlFile, 'r')
|
||||
toggleHideByT(mode, type, onValue, offValue, ctrlFile)
|
||||
|
||||
def toggleHideByType(mode, type, onValue, offValue):
|
||||
logList = getLogList(logfile)
|
||||
checkList = getCheckList(ctrlFile)
|
||||
toggleHideRestartCheck(logList[1],checkList, mode, type, onValue, offValue, ctrlFile)
|
||||
|
||||
def toggleHideByT(mode, type, 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, type, offValue))+'\n'))
|
||||
|
||||
hideByType(type)
|
||||
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, type , offValue)))
|
||||
print (str("{'%s': %s}\n" % (type , offValue)))
|
||||
stateList = open(ctrlFile, 'w')
|
||||
stateList.write(''.join(getList))
|
||||
hideByType(type)
|
||||
|
||||
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(type)
|
||||
|
||||
if getState == offValue:
|
||||
getDict[type] = 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))))
|
||||
unHideByType(type)
|
||||
else:
|
||||
getDict[type] = 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))))
|
||||
hideByType(type)
|
||||
|
||||
def hideByType(type):
|
||||
typeList = general.get_all_objects(str(type), "")
|
||||
for x in typeList:
|
||||
general.hide_object(x)
|
||||
|
||||
def unHideByType(type):
|
||||
typeList = general.get_all_objects(str(type), "")
|
||||
for x in typeList:
|
||||
general.unhide_object(x)
|
||||
Reference in New Issue
Block a user