Add a configure command for initial wad setup. Reshuffle a couple things that depend on it.
This commit is contained in:
parent
673e649e87
commit
5881c94c11
4 changed files with 34 additions and 10 deletions
|
@ -57,11 +57,3 @@ class Base(Command):
|
||||||
@property
|
@property
|
||||||
def dsda(self):
|
def dsda(self):
|
||||||
return self._doom.joinpath(self._dsda)
|
return self._doom.joinpath(self._dsda)
|
||||||
|
|
||||||
def iwad_path(self, wad):
|
|
||||||
iwad = self.iwads.joinpath(self._config.get("default_iwad"))
|
|
||||||
iwadpath = self.pwads.joinpath(wad).joinpath("iwad")
|
|
||||||
if iwadpath.exists():
|
|
||||||
with io.open(iwadpath) as f:
|
|
||||||
iwad = self.iwads.joinpath(f.read().strip() + ".WAD")
|
|
||||||
return iwad
|
|
||||||
|
|
24
dcc/configure.py
Normal file
24
dcc/configure.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import dcc.config
|
||||||
|
import tomlkit
|
||||||
|
from tomlkit.toml_file import TOMLFile
|
||||||
|
|
||||||
|
class Configure(dcc.config.Base):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super().get_parser(prog_name)
|
||||||
|
parser.add_argument("wad")
|
||||||
|
parser.add_argument("complevel")
|
||||||
|
parser.add_argument("--iwad")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
new_config = self.pwads.joinpath(parsed_args.wad).joinpath(self.config_name)
|
||||||
|
if new_config.exists():
|
||||||
|
raise Exception("Config %s already exists.".format(new_config))
|
||||||
|
|
||||||
|
doc = tomlkit.document()
|
||||||
|
doc.add("complevel", parsed_args.complevel)
|
||||||
|
if parsed_args.iwad is not None:
|
||||||
|
doc.add("iwad", parsed_args.iwad)
|
||||||
|
|
||||||
|
f = TOMLFile(new_config)
|
||||||
|
f.write(doc)
|
|
@ -29,6 +29,14 @@ class Wad(dcc.config.Base):
|
||||||
def wad(self):
|
def wad(self):
|
||||||
return self._wad
|
return self._wad
|
||||||
|
|
||||||
|
def iwad_path(self):
|
||||||
|
iwad = self.iwads.joinpath(self._config.get("iwad"))
|
||||||
|
iwadpath = self.pwads.joinpath(self.wad).joinpath("iwad")
|
||||||
|
if iwadpath.exists():
|
||||||
|
with io.open(iwadpath) as f:
|
||||||
|
iwad = self.iwads.joinpath(f.read().strip() + ".WAD")
|
||||||
|
return iwad
|
||||||
|
|
||||||
|
|
||||||
class WadMap(Wad):
|
class WadMap(Wad):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
|
@ -53,7 +61,7 @@ class WadMap(Wad):
|
||||||
return "" if self._name is None else "_" + self._name
|
return "" if self._name is None else "_" + self._name
|
||||||
|
|
||||||
def dsda_preamble(self):
|
def dsda_preamble(self):
|
||||||
args = ["-iwad", self.iwad_path(self.wad)]
|
args = ["-iwad", self.iwad_path()]
|
||||||
|
|
||||||
pwadpath = self.pwads.joinpath(self.wad)
|
pwadpath = self.pwads.joinpath(self.wad)
|
||||||
wads = sorted(pwadpath.glob('*.wad', case_sensitive=False))
|
wads = sorted(pwadpath.glob('*.wad', case_sensitive=False))
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Eureka(dcc.doom_base.WadMap):
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
iwad = self.iwad_path(parsed_args.wad)
|
iwad = self.iwad_path()
|
||||||
pwadpath = self.pwads.joinpath(parsed_args.wad)
|
pwadpath = self.pwads.joinpath(parsed_args.wad)
|
||||||
if parsed_args.main is not None:
|
if parsed_args.main is not None:
|
||||||
mw = pwadpath.joinpath(parsed_args.main)
|
mw = pwadpath.joinpath(parsed_args.main)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue