From 773bced1b20f0acddab15a24a3d387fc5142edbc Mon Sep 17 00:00:00 2001 From: NCLanceman Date: Thu, 20 Nov 2025 22:11:20 -0600 Subject: [PATCH] dict saver --- .gitignore | 1 + doomstarter.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3958f22..0f1aa41 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ gameplay/ maps/ misc/ settings.txt +dictSettings.txt diff --git a/doomstarter.py b/doomstarter.py index cac31da..564c12a 100644 --- a/doomstarter.py +++ b/doomstarter.py @@ -58,6 +58,7 @@ def settingsReader(mainDict, file): if (i[:2] != "--"): tempDict = {} tempDict["filename"] = "./maps/" + i + tempDict["listing"] = i counter = counter + 1 counterName = str(counter).zfill(2) else: @@ -70,6 +71,7 @@ def settingsReader(mainDict, file): if (i[:2] != "--"): tempDict = {} tempDict["filename"] = "./gameplay/" + i + tempDict["listing"] = i counter = counter + 1 counterName = str(counter).zfill(2) else: @@ -82,6 +84,7 @@ def settingsReader(mainDict, file): if (i[:2] != "--"): tempDict = {} tempDict["filename"] = "./misc/" + i + tempDict["listing"] = i counter = counter + 1 counterName = str(counter).zfill(2) else: @@ -104,6 +107,8 @@ def settingsReader(mainDict, file): return mainDict +# TODO: Print output and confirm before returning the itemDict + def detailAdder(itemDict, itemType): if (itemType == "sourcePorts"): @@ -142,6 +147,53 @@ def settingsGen(mapList, gameList, miscList): 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! # Dynamic Introduction! 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...") for i in range(len(settingsDict["maps"])): mapDict = settingsDict["maps"][str(i+1).zfill(2)] - mapName = mapDict["filename"] - print("Enter description for " + mapName + ": ") + mapListing = mapDict["listing"] + print("Enter description for " + mapListing + ": ") settingsDict["maps"].update( {(str(i+1).zfill(2)): detailAdder(mapDict, "maps")}) 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...") # subprocess.run(sourceport_dict["UZDoom"]["runcommand"]