Browse Source

single file reader

master
NCLanceman 3 days ago
parent
commit
836f2c98e4
  1. 235
      doomstarter.py

235
doomstarter.py

@ -16,95 +16,95 @@ def menuPrinter(list):
# TODO: Make a single function that reads settings # TODO: Make a single function that reads settings
def sourcePortSettingsRead(mainDict, ports): def settingsReader(mainDict, file):
tempDict = {}
counter = 0
for i in range(len(ports)):
tempName = "port" + str(counter).zfill(2)
print("Examining " + ports[i])
if (ports[i][:2] != "--"):
if len(tempDict) != 0:
mainDict["sourcePorts"].update({tempName: tempDict})
tempDict = {}
counter = counter + 1
tempDict["title"] = ports[i]
else:
temp = ports[i][2:].split("=")
tempDict.update({temp[0]: temp[1]})
if len(tempDict) != 0:
mainDict["sourcePorts"].update({tempName: tempDict})
return mainDict
def mapSettingsRead(mainDict, maps):
tempDict = {}
counter = 0
for i in range(len(maps)):
tempName = "map" + str(counter).zfill(2)
print("Examining " + maps[i])
if (maps[i][:2] != "--"):
if len(tempDict) != 0:
mainDict["maps"].update({tempName: tempDict})
tempDict = {}
counter = counter + 1
tempDict["filename"] = "./maps/" + maps[i]
else:
temp = maps[i][2:].split("=")
tempDict.update({temp[0]: temp[1]})
if len(tempDict) != 0:
mainDict["maps"].update({tempName: tempDict})
return mainDict
def gameplaySettingsRead(mainDict, game):
tempDict = {} tempDict = {}
currentSetting = ""
counter = 0 counter = 0
for i in range(len(game)): counterName = str(counter).zfill(2)
tempName = "gameplay" + str(counter).zfill(2) settings = ((open(file)).read()).splitlines()
print("Examining " + game[i])
if (game[i][:2] != "--"):
if len(tempDict) != 0:
mainDict["gameplay"].update({tempName: tempDict})
tempDict = {}
counter = counter + 1
tempDict["filename"] = "./gameplay/" + game[i]
else:
temp = game[i][2:].split("=")
tempDict.update({temp[0]: temp[1]})
if len(tempDict) != 0:
mainDict["gameplay"].update({tempName: tempDict})
return mainDict
for i in settings:
print("Examining " + i)
print("Current Setting is: " + currentSetting)
counterName = str(counter).zfill(2)
def previousSettingsRead(mainDict, prev): if (i == "[Source Ports]"):
tempDict = {} currentSetting = "Source Ports"
counter = 0 print("Addings Source Ports from Settings file...")
for i in range(len(prev)): elif (i == "[Maps]"):
tempName = "previous" + str(counter).zfill(2) currentSetting = "Maps"
print("Examining " + prev[i]) counter = 0
print("Adding maps to the main dict...")
if (prev[i][:2] != "--"): elif (i == "[Gameplay]"):
if len(tempDict) != 0: currentSetting = "Gameplay"
mainDict["previous"].update({tempName: tempDict}) counter = 0
tempDict = {} elif (i == "[Misc]"):
counter = counter + 1 currentSetting = "Misc"
tempDict["command"] = prev[i] counter = 0
else: elif (i == "[Last Used]"):
temp = prev[i][2:].split("=") currentSetting = "Previous"
tempDict.update({temp[0]: temp[1]}) counter = 0
if i:
if len(tempDict) != 0: if (currentSetting == "Source Ports" and i[0] != '['):
mainDict["previous"].update({tempName: tempDict}) # sourcePortSettingsRead
if (i[:2] != "--"):
tempDict = {}
tempDict["title"] = i
counter = counter + 1
counterName = str(counter).zfill(2)
else:
temp = i[2:].split("=")
tempDict.update({temp[0]: temp[1]})
mainDict["sourcePorts"].update({counterName: tempDict})
elif (currentSetting == "Maps" and i[0] != '['):
# mapSettingsRead
if (i[:2] != "--"):
tempDict = {}
tempDict["filename"] = "./maps/" + i
counter = counter + 1
counterName = str(counter).zfill(2)
else:
temp = i[2:].split("=")
tempDict.update({temp[0]: temp[1]})
mainDict["maps"].update({counterName: tempDict})
elif (currentSetting == "Gameplay" and i[0] != '['):
# gameplaySettingsRead
if (i[:2] != "--"):
tempDict = {}
tempDict["filename"] = "./gameplay/" + i
counter = counter + 1
counterName = str(counter).zfill(2)
else:
temp = i[2:].split("=")
tempDict.update({temp[0]: temp[1]})
mainDict["gameplay"].update({counterName: tempDict})
elif (currentSetting == "Misc" and i[0] != '['):
# miscSettingsRead
if (i[:2] != "--"):
tempDict = {}
tempDict["filename"] = "./misc/" + i
counter = counter + 1
counterName = str(counter).zfill(2)
else:
temp = i[2:].split("=")
tempDict.update({temp[0]: temp[1]})
mainDict["misc"].update({counterName: tempDict})
elif (currentSetting == "Previous" and i[0] != '['):
# previousSettingsRead
if (i[:2] != "--"):
tempDict = {}
tempDict["command"] = i
counter = counter + 1
counterName = str(counter).zfill(2)
else:
temp = i[2:].split("=")
tempDict.update({temp[0]: temp[1]})
mainDict["previous"].update({counterName: tempDict})
return mainDict return mainDict
@ -126,55 +126,11 @@ if not (os.path.isdir('gameplay') and os.path.isdir('maps') and os.path.isdir('m
print("Folders Created! Now go forth and fill them! Return when you are ready to DOOM!") print("Folders Created! Now go forth and fill them! Return when you are ready to DOOM!")
else: else:
# Load Config File # Load Config File
settings = ((open("Settings.txt")).read()).splitlines() # settings = ((open("Settings.txt")).read()).splitlines()
currentSetting = ""
for i in settings: # Load Config File and return populated settingsDict
print("Examining " + i)
print("Current Setting is: " + currentSetting)
if (i == "[Source Ports]"): blankDict = {
currentSetting = "Source Ports"
elif (i == "[Maps]"):
currentSetting = "Maps"
elif (i == "[Gameplay]"):
currentSetting = "Gameplay"
elif (i == "[Misc]"):
currentSetting = "Misc"
elif (i == "[Last Used]"):
currentSetting = "Previous"
if i:
if (currentSetting == "Source Ports" and i[0] != '['):
sourceSettings.append(i)
print("Adding " + i + " to Source Ports")
elif (currentSetting == "Maps" and i[0] != '['):
mapsSettings.append(i)
print("Adding " + i + " to Maps")
elif (currentSetting == "Gameplay" and i[0] != '['):
gameplaySettings.append(i)
print("Adding " + i + " to Gameplay")
elif (currentSetting == "Misc" and i[0] != '['):
miscSettings.append(i)
print("Adding " + i + " to Misc")
elif (currentSetting == "Previous" and i[0] != '['):
previousSettings.append(i)
print("Adding " + i + " to Previous Settings")
print("Printing Source Settings...")
print(sourceSettings)
print("Printing Maps...")
print(mapsSettings)
print("Printing Gameplay WADs...")
print(gameplaySettings)
print("Printing Misc WADs...")
print(miscSettings)
print("Printing Previous Settings...")
print(previousSettings)
# Detect SourcePorts
# Source Port list: GZDoom, UZDoom, ChocolateDoom, DSDA-Doom, Woof!
settingsDict = {
"sourcePorts": {}, "sourcePorts": {},
"maps": {}, "maps": {},
"gameplay": {}, "gameplay": {},
@ -182,33 +138,20 @@ else:
"previous": {} "previous": {}
} }
settingsDict = settingsReader(blankDict, "Settings.txt")
# print("Running UZDoom with no arguements...") # print("Running UZDoom with no arguements...")
# subprocess.run(sourceport_dict["UZDoom"]["runcommand"] # subprocess.run(sourceport_dict["UZDoom"]["runcommand"]
# + " ./gameplay/PVT_STONE_V12_5.wad", shell = True) # + " ./gameplay/PVT_STONE_V12_5.wad", shell = True)
# subprocess.run(sourceport_dict["Woof"]["runcommand"], shell=True) # subprocess.run(sourceport_dict["Woof"]["runcommand"], shell=True)
# List all that stuff in a file
print("Addings Source Ports from Settings file...")
settingsDict = sourcePortSettingsRead(settingsDict, sourceSettings)
print("Listing everything in Maps...") print("Listing everything in Maps...")
print(os.listdir("./maps/")) print(os.listdir("./maps/"))
print("Adding maps to the main dict...")
settingsDict = mapSettingsRead(settingsDict, mapsSettings)
print("Listing everything in Gameplay...") print("Listing everything in Gameplay...")
print(os.listdir("./gameplay/")) print(os.listdir("./gameplay/"))
# TODO: Add gameplay WADS to main dict
settingsDict = gameplaySettingsRead(settingsDict, gameplaySettings)
print("Listing everything in Misc...") print("Listing everything in Misc...")
print(os.listdir("./misc/")) print(os.listdir("./misc/"))
# TODO: Add misc wads to the main dict
print("Listing everything in Previous...")
print(previousSettings)
settingsDict = previousSettingsRead(settingsDict, previousSettings)
print(settingsDict) print(settingsDict)

Loading…
Cancel
Save