Read complevel from the lump in the wad, if it exists.
This commit is contained in:
parent
fcc6b22785
commit
c4e360378f
1 changed files with 21 additions and 2 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
|
import omg
|
||||||
import tomlkit.toml_file
|
import tomlkit.toml_file
|
||||||
|
|
||||||
|
|
||||||
class Configure(dcc.doom_base.Wad):
|
class Configure(dcc.doom_base.Wad):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super().get_parser(prog_name)
|
parser = super().get_parser(prog_name)
|
||||||
parser.add_argument("complevel")
|
parser.add_argument("--complevel", "--cl")
|
||||||
parser.add_argument("--iwad")
|
parser.add_argument("--iwad")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
@ -14,8 +15,26 @@ class Configure(dcc.doom_base.Wad):
|
||||||
if new_config.exists():
|
if new_config.exists():
|
||||||
raise Exception(f"Config {new_config} already exists.")
|
raise Exception(f"Config {new_config} already exists.")
|
||||||
|
|
||||||
|
wads = sorted(
|
||||||
|
self.pwads.joinpath(self.wad).glob('*.wad', case_sensitive=False),
|
||||||
|
reverse=True
|
||||||
|
)
|
||||||
|
|
||||||
|
complevel = parsed_args.complevel
|
||||||
|
if complevel is None:
|
||||||
|
for w in wads:
|
||||||
|
try:
|
||||||
|
wad = omg.WadIO(w)
|
||||||
|
complevel = wad.read("COMPLVL").decode("ascii").strip()
|
||||||
|
except Exception as e:
|
||||||
|
print(
|
||||||
|
f"Wad {w} likely has no lump COMPLVL (exception {e})")
|
||||||
|
if complevel is None:
|
||||||
|
complevel = input("Complevel? ")
|
||||||
|
|
||||||
|
|
||||||
doc = tomlkit.document()
|
doc = tomlkit.document()
|
||||||
doc.add("complevel", parsed_args.complevel)
|
doc.add("complevel", complevel)
|
||||||
if parsed_args.iwad is not None:
|
if parsed_args.iwad is not None:
|
||||||
doc.add("iwad", parsed_args.iwad)
|
doc.add("iwad", parsed_args.iwad)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue