mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
added argument for the cli, gui and cli source are now inside the interface directory
This commit is contained in:
parent
63089497b5
commit
9059824f5a
13 changed files with 41 additions and 24 deletions
21
main.pyw
21
main.pyw
|
@ -12,20 +12,25 @@ translater = load_language(options.language.get())
|
||||||
|
|
||||||
|
|
||||||
def main_gui():
|
def main_gui():
|
||||||
from source.gui import install
|
from source.interface.gui import install
|
||||||
self.window = install.Window(options)
|
self.window = install.Window(options)
|
||||||
self.window.run()
|
self.window.run()
|
||||||
|
|
||||||
|
|
||||||
def main_cli():
|
def main_cli(argparser: argparse.ArgumentParser):
|
||||||
from source.cli import install
|
from source.interface.cli import install
|
||||||
install.cli(options)
|
install.cli(options, argparser)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
argparser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-i", "--interface", choices=["gui", "cli"], default="gui")
|
argparser.add_argument(
|
||||||
args = parser.parse_args()
|
"-i", "--interface",
|
||||||
|
choices=["gui", "cli"],
|
||||||
|
default="gui",
|
||||||
|
help="should the installer be started with a graphical interface or with the command line interface"
|
||||||
|
)
|
||||||
|
args, _ = argparser.parse_known_args()
|
||||||
|
|
||||||
match args.interface:
|
match args.interface:
|
||||||
case "gui": main_gui()
|
case "gui": main_gui()
|
||||||
case "cli": main_cli()
|
case "cli": main_cli(argparser)
|
||||||
|
|
0
source/interface/__init__.py
Normal file
0
source/interface/__init__.py
Normal file
0
source/interface/cli/__init__.py
Normal file
0
source/interface/cli/__init__.py
Normal file
|
@ -1,3 +1,4 @@
|
||||||
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from source.mkw.Game import Game
|
from source.mkw.Game import Game
|
||||||
|
@ -6,26 +7,36 @@ from source.translation import translate as _
|
||||||
from source.mkw.collection.Extension import Extension
|
from source.mkw.collection.Extension import Extension
|
||||||
|
|
||||||
|
|
||||||
def cli(options):
|
def cli(options, argparser: argparse.ArgumentParser):
|
||||||
print(_("TITLE_INSTALL"))
|
argparser.add_argument("-m", "--mod", help="name of the mod to install")
|
||||||
|
argparser.add_argument("-s", "--source", help="path to the original game")
|
||||||
|
argparser.add_argument("-d", "--dest", help="destination directory of the patched game")
|
||||||
|
argparser.add_argument("-ot", "--output_type", help="format of the patched game")
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
packs = []
|
packs = []
|
||||||
for pack in Path("./Pack/").iterdir():
|
for pack in Path("./Pack/").iterdir():
|
||||||
packs.append(pack)
|
packs.append(pack)
|
||||||
|
|
||||||
mod_name = input(_("TEXT_INPUT_MOD_NAME") % [pack.name for pack in packs])
|
mod_name = args.mod
|
||||||
|
choices = [pack.name for pack in packs]
|
||||||
|
while mod_name is None or mod_name not in choices: mod_name = input(_("TEXT_INPUT_MOD_NAME") % choices)
|
||||||
mod_config = ModConfig.from_file(Path(f"./Pack/{mod_name}/mod_config.json"))
|
mod_config = ModConfig.from_file(Path(f"./Pack/{mod_name}/mod_config.json"))
|
||||||
|
|
||||||
source_path = input(_("TEXT_INPUT_SOURCE_PATH"))
|
source_path = args.source
|
||||||
|
if source_path is None: source_path = input(_("TEXT_INPUT_SOURCE_PATH"))
|
||||||
game = Game(source_path)
|
game = Game(source_path)
|
||||||
|
|
||||||
destination_directory = input(_("TEXT_INPUT_DESTINATION_DIRECTORY"))
|
destination_directory = args.dest
|
||||||
|
if destination_directory is None: destination_directory = input(_("TEXT_INPUT_DESTINATION_DIRECTORY"))
|
||||||
destination_path = Path(destination_directory)
|
destination_path = Path(destination_directory)
|
||||||
|
|
||||||
output_name = input(_("TEXT_INPUT_OUPUT_TYPE") % [extension.name for extension in Extension])
|
output_name = args.output_type
|
||||||
|
choices = [extension.name for extension in Extension]
|
||||||
|
if output_name is None or mod_name not in choices: output_name = input(_("TEXT_INPUT_OUPUT_TYPE") % choices)
|
||||||
output_type = Extension[output_name]
|
output_type = Extension[output_name]
|
||||||
|
|
||||||
progressbar_max: int = 30
|
progressbar_max: int = 40
|
||||||
|
|
||||||
title: str = ""
|
title: str = ""
|
||||||
description: str = ""
|
description: str = ""
|
|
@ -9,7 +9,8 @@ from tkinter import messagebox
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from source.gui import better_gui_error, mystuff, mod_settings
|
from source.interface.gui import better_gui_error
|
||||||
|
from source.interface.gui import mod_settings, mystuff
|
||||||
from source.mkw.Game import Game
|
from source.mkw.Game import Game
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
||||||
from source.option import Options
|
from source.option import Options
|
||||||
|
@ -373,7 +374,7 @@ class ButtonInstall(ttk.Button):
|
||||||
if available_space_local < minimum_space_available:
|
if available_space_local < minimum_space_available:
|
||||||
if not messagebox.askokcancel(
|
if not messagebox.askokcancel(
|
||||||
_("WARNING"),
|
_("WARNING"),
|
||||||
_("WARNING_LOW_SPACE_CONTINUE") % (Path(".").resolve().drive, available_space_local/Go)
|
_("WARNING_LOW_SPACE_CONTINUE") % (Path(".").resolve().drive, available_space_local / Go)
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
|
@ -36,4 +36,4 @@ class AbstractPreviewWindow(tkinter.Toplevel, ABC):
|
||||||
raise InvalidPreviewWindowName(name)
|
raise InvalidPreviewWindowName(name)
|
||||||
|
|
||||||
|
|
||||||
from source.gui.preview import track_formatting, track_selecting, track_sorting
|
from source.interface.gui.preview import track_formatting, track_selecting, track_sorting
|
|
@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from source.mkw.collection import MKWColor
|
from source.mkw.collection import MKWColor
|
||||||
from source.gui.preview import AbstractPreviewWindow
|
from source.interface.gui.preview import AbstractPreviewWindow
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
|
@ -3,8 +3,8 @@ from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from source.mkw.collection import MKWColor
|
from source.mkw.collection import MKWColor
|
||||||
from source.gui.preview import AbstractPreviewWindow
|
from source.interface.gui.preview import AbstractPreviewWindow
|
||||||
from source.gui import better_gui_error
|
from source.interface.gui import better_gui_error
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
|
@ -3,8 +3,8 @@ from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from source.mkw.collection import MKWColor
|
from source.mkw.collection import MKWColor
|
||||||
from source.gui.preview import AbstractPreviewWindow
|
from source.interface.gui.preview import AbstractPreviewWindow
|
||||||
from source.gui import better_gui_error
|
from source.interface.gui import better_gui_error
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
|
@ -1,5 +1,5 @@
|
||||||
from source.mkw.ModSettings.AbstractModSettings import AbstractModSettings
|
from source.mkw.ModSettings.AbstractModSettings import AbstractModSettings
|
||||||
from source.gui.preview import AbstractPreviewWindow
|
from source.interface.gui.preview import AbstractPreviewWindow
|
||||||
|
|
||||||
|
|
||||||
class String(AbstractModSettings):
|
class String(AbstractModSettings):
|
||||||
|
|
Loading…
Reference in a new issue