Browse Source

dict saver

master
NCLanceman 2 days ago
parent
commit
773bced1b2
  1. 1
      .gitignore
  2. 60
      doomstarter.py

1
.gitignore

@ -2,3 +2,4 @@ gameplay/
maps/ maps/
misc/ misc/
settings.txt settings.txt
dictSettings.txt

60
doomstarter.py

@ -58,6 +58,7 @@ def settingsReader(mainDict, file):
if (i[:2] != "--"): if (i[:2] != "--"):
tempDict = {} tempDict = {}
tempDict["filename"] = "./maps/" + i tempDict["filename"] = "./maps/" + i
tempDict["listing"] = i
counter = counter + 1 counter = counter + 1
counterName = str(counter).zfill(2) counterName = str(counter).zfill(2)
else: else:
@ -70,6 +71,7 @@ def settingsReader(mainDict, file):
if (i[:2] != "--"): if (i[:2] != "--"):
tempDict = {} tempDict = {}
tempDict["filename"] = "./gameplay/" + i tempDict["filename"] = "./gameplay/" + i
tempDict["listing"] = i
counter = counter + 1 counter = counter + 1
counterName = str(counter).zfill(2) counterName = str(counter).zfill(2)
else: else:
@ -82,6 +84,7 @@ def settingsReader(mainDict, file):
if (i[:2] != "--"): if (i[:2] != "--"):
tempDict = {} tempDict = {}
tempDict["filename"] = "./misc/" + i tempDict["filename"] = "./misc/" + i
tempDict["listing"] = i
counter = counter + 1 counter = counter + 1
counterName = str(counter).zfill(2) counterName = str(counter).zfill(2)
else: else:
@ -104,6 +107,8 @@ def settingsReader(mainDict, file):
return mainDict return mainDict
# TODO: Print output and confirm before returning the itemDict
def detailAdder(itemDict, itemType): def detailAdder(itemDict, itemType):
if (itemType == "sourcePorts"): if (itemType == "sourcePorts"):
@ -142,6 +147,53 @@ def settingsGen(mapList, gameList, miscList):
return result return result
def settingsSave(mainDict):
result = ""
# Add Source Ports
result = result + "[Source Ports]\n"
for i in mainDict["sourcePorts"]:
result = result + mainDict["sourcePorts"][i]["title"] + "\n"
for j in mainDict["sourcePorts"][i].keys():
if not (j == "title"):
result = result + "--" + j + "=" + \
mainDict["sourcePorts"][i][j] + "\n"
# Add Maps
result = result + "[Maps]\n"
for i in mainDict["maps"]:
result = result + mainDict["maps"][i]["listing"] + "\n"
for j in mainDict["maps"][i].keys():
if not (j == "listing"):
result = result + "--" + j + "=" + \
mainDict["maps"][i][j] + "\n"
# Add Gameplay
result = result + "[Gameplay]\n"
for i in mainDict["gameplay"]:
result = result + mainDict["gameplay"][i]["listing"] + "\n"
for j in mainDict["gameplay"][i].keys():
if not (j == "listing"):
result = result + "--" + j + "=" + \
mainDict["gameplay"][i][j] + "\n"
# Add Misc
result = result + "[Misc]\n"
for i in mainDict["misc"]:
result = result + mainDict["misc"][i]["listing"] + "\n"
for j in mainDict["misc"][i].keys():
if not (j == "listing"):
result = result + "--" + j + "=" + \
mainDict["misc"][i][j] + "\n"
# Add Last Used
result = result + "[Last Used]" + "\n"
for i in mainDict["previous"]:
result = result + i + "\n"
return result
# INFO: MAIN METHOD! # INFO: MAIN METHOD!
# Dynamic Introduction! # Dynamic Introduction!
print("So it looks like you wanna play some fuckin\' DOOM!") print("So it looks like you wanna play some fuckin\' DOOM!")
@ -199,12 +251,16 @@ else:
print("Testing out trying to add detail to all maps...") print("Testing out trying to add detail to all maps...")
for i in range(len(settingsDict["maps"])): for i in range(len(settingsDict["maps"])):
mapDict = settingsDict["maps"][str(i+1).zfill(2)] mapDict = settingsDict["maps"][str(i+1).zfill(2)]
mapName = mapDict["filename"] mapListing = mapDict["listing"]
print("Enter description for " + mapName + ": ") print("Enter description for " + mapListing + ": ")
settingsDict["maps"].update( settingsDict["maps"].update(
{(str(i+1).zfill(2)): detailAdder(mapDict, "maps")}) {(str(i+1).zfill(2)): detailAdder(mapDict, "maps")})
print(settingsDict) print(settingsDict)
print("\n\n Saving to new file!")
with open("dictSettings.txt", "w") as f:
f.write(settingsSave(settingsDict))
f.close()
# print("Running UZDoom with no arguements...") # print("Running UZDoom with no arguements...")
# subprocess.run(sourceport_dict["UZDoom"]["runcommand"] # subprocess.run(sourceport_dict["UZDoom"]["runcommand"]

Loading…
Cancel
Save