Browse Source

Textfile parsing

master
NCLanceman 5 days ago
parent
commit
9aeb23298f
  1. 18
      Settings.txt
  2. 78
      doomstarter.py

18
Settings.txt

@ -1,16 +1,18 @@
[Source Ports]
Woof!
--"runcommand"="~/Games/Woof/woof/build/src/woof"
--description=Dog-themed successor to MBF and DSDA-Doom!
--runcommand=~/Games/Woof/woof/build/src/woof
UZDoom
--"runcommand"="uzdoom-alpha"
DSDA-Doom
Chocolate Doom
--description=The ever capable modern sourceport!
--runcommand=uzdoom-alpha
[Maps]
300minvr.wad
--name=300 Minutes of /vr/
--description=4chan's /vr/ board gives us a megawad of solid bangers!
[Gameplay]
PVT_STONE_V12_5.wad
--name=Pvt.Stone
--description=Play as anglo muscle mommy Pvt. Stone as you rip and tear through DOOM!
[Misc]
[Last Used]

78
doomstarter.py

@ -34,27 +34,38 @@ if (os.path.isdir('misc') == False):
# Load Config File
settings = ((open("Settings.txt")).read()).splitlines()
for i in range(len(settings)):
currentSettingGroup = []
currentSetting = ""
for i in settings:
print("Examining " + i)
print("Current Setting is: " + currentSetting)
if (i == "[Source Ports]"):
currentSettingGroup = sourceSettings
currentSetting = "Source Ports"
elif (i == "[Maps]"):
sourceSettings = currentSettingGroup
currentSettingGroup = mapsSettings
currentSetting = "Maps"
elif (i == "[Gameplay]"):
mapsSettings = currentSettingGroup
currentSettingGroup = gameplaySettings
currentSetting = "Gameplay"
elif (i == "[Misc]"):
gameplaySettings = currentSettingGroup
currentSettingGroup = miscSettings
currentSetting = "Misc"
elif (i == "[Last Used]"):
miscSettings = currentSettingGroup
currentSettingGroup = previousSettings
else:
currentSettingGroup.append(i)
previousSettings = currentSettingGroup
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)
@ -71,17 +82,14 @@ print(previousSettings)
# Detect SourcePorts
# Source Port list: GZDoom, UZDoom, ChocolateDoom, DSDA-Doom, Woof!
sourceport_dict = {
"UZDoom": {
"runcommand": "uzdoom-alpha"
},
"Woof": {
"runcommand": "~/Games/Woof/woof/build/src/woof"
}
settingsDict = {
"sourcePorts": {},
"maps": {},
"gameplay": {},
"misc": {},
"previous": {}
}
print("The command for running UZDoom is: " +
sourceport_dict["UZDoom"]["runcommand"])
# print("Running UZDoom with no arguements...")
# subprocess.run(sourceport_dict["UZDoom"]["runcommand"]
# + " ./gameplay/PVT_STONE_V12_5.wad", shell = True)
@ -91,15 +99,33 @@ print("The command for running UZDoom is: " +
print("Listing everything in Maps...")
print(os.listdir("./maps/"))
print("Adding maps to the main dict...")
mapName = ""
tempDict = {}
for i in range(len(mapsSettings)):
tempName = "map" + str(i)
print("Examining " + mapsSettings[i])
if (mapsSettings[i][:2] != "--"):
if len(tempDict) != 0:
settingsDict["maps"].update({tempName: tempDict})
tempDict["filename"] = mapsSettings[i]
else:
temp = mapsSettings[i][2:].split("=")
tempDict.update({temp[0]: temp[1]})
if len(tempDict) != 0:
settingsDict["maps"].update({tempName: tempDict})
print("Listing everything in Gameplay...")
print(os.listdir("./gameplay/"))
print("Listing everything in Misc...")
print(os.listdir("./misc/"))
print(settingsDict)
print("Sample Maps listing: ")
menuPrinter(os.listdir("./maps/"))
# print("Sample Maps listing: ")
# menuPrinter(os.listdir("./maps/"))
# Store last configs for later use

Loading…
Cancel
Save