-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
cli.py
118 lines (111 loc) · 3.52 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from __future__ import unicode_literals
import os
import sys
# Embedded python doesn't have current directory as path
if os.getcwd() not in sys.path:
print("Startup: Adding {} to path".format(os.getcwd()))
sys.path.append(os.getcwd())
import argparse
import main as gui_main
import common
import uminekoInstaller
import uminekoNScripterInstaller
import higurashiInstaller
import logger
import installConfiguration
import sys
def main(*, game_name, game_path, mod_type, mod_options=[], is_steam=True):
sys.stdout = logger.Logger(common.Globals.LOG_FILE_PATH)
logger.setGlobalLogger(sys.stdout)
sys.stderr = logger.StdErrRedirector(sys.stdout)
common.Globals.scanForExecutables()
modList = gui_main.getModList()
subModList = gui_main.getSubModConfigList(modList)
print("\n")
suitableSubMods = [
x
for x in subModList
if all(y in x.modName.lower().split() for y in game_name.lower().split("-"))
and x.subModName == mod_type
]
if len(suitableSubMods) != 1:
print(f'Could not find a mod matching "{game_name}"')
return
neededSubMod = suitableSubMods[0]
neededModOptions = []
for i in mod_options:
neededModOption = [
x
for x in neededSubMod.modOptions
if all(y in x.id.lower().split() for y in i.lower().split("-"))
]
if len(neededModOption) == 1:
neededModOptions += neededModOption
if len(neededModOptions) != len(mod_options):
print("Couldn't find specified mod options.")
return
for i in neededSubMod.modOptions:
if i.id in [x.id for x in neededModOptions]:
i.value = True
install_config = installConfiguration.FullInstallConfiguration(
neededSubMod, game_path, is_steam
)
if neededSubMod.family == "umineko":
uminekoInstaller.mainUmineko(install_config)
elif neededSubMod.family == "umineko_nscripter":
uminekoNScripterInstaller.main(install_config)
elif neededSubMod.family == "higurashi":
higurashiInstaller.main(install_config)
else:
print(
f"Submod family is not recognised, the script may be out of date."
"Please ask us to update it."
)
if __name__ == "__main__":
argparser = argparse.ArgumentParser()
argparser.add_argument(
"-g",
"--game",
dest="game_name",
required=True,
help='Name of the game, e.g. "minagoroshi" or "umineko-question"',
)
argparser.add_argument(
"-p",
"--path",
dest="game_path",
required=True,
help="Path to the game's install location",
)
argparser.add_argument(
"-m",
"--mod-type",
dest="mod_type",
required=True,
help=(
'Submod type, can be "full" or "voice-only".'
"For Umineko Answer Arcs, this should be "
'"novel-mode", "adv-mode" or "voice-only".'
),
)
argparser.add_argument(
"-o",
"--mod-option",
action="append",
dest="mod_options",
metavar="MOD_OPTION",
default=[],
help=(
'Enable a specific mod option, e.g. "bgm-fix". '
"Can be repeated multiple times to enable many options."
),
)
argparser.add_argument(
"--non-steam",
action="store_false",
dest="is_steam",
default=True,
help="Specify if you're modding a non-Steam version of the game.",
)
args = argparser.parse_args()
main(**vars(args))