mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
added a very experimental cli (can be enabled with -i=cli)
This commit is contained in:
parent
f093e3462a
commit
63089497b5
5 changed files with 91 additions and 8 deletions
|
@ -22,7 +22,7 @@
|
|||
"fr": "Mode"
|
||||
},
|
||||
"description": {
|
||||
"en": "Special mod's configuration.",
|
||||
"en": "Special mod configuration.",
|
||||
"fr": "Configuration spécial du mod."
|
||||
},
|
||||
"type": "choices",
|
||||
|
|
|
@ -107,6 +107,11 @@
|
|||
"ERROR_SOURCE_NOT_IMPLEMENTED": "Source \"%s\" is not implemented (in patch : \"%s\")",
|
||||
"ERROR_OPERATION_NOT_IMPLEMENTED": "Operation \"%s\" is not implemented",
|
||||
"ERROR_BMG_LAYER_MODE_NOT_IMPLEMENTED": "Bmg layer mode \"%s\" not implemented",
|
||||
"ERROR_IMAGE_LAYER_TYPE_NOT_IMPLEMENTED": "Image layer type \"%s\" not implemented"
|
||||
"ERROR_IMAGE_LAYER_TYPE_NOT_IMPLEMENTED": "Image layer type \"%s\" not implemented",
|
||||
|
||||
"TEXT_INPUT_MOD_NAME": "Name of the mod to install %s : ",
|
||||
"TEXT_INPUT_SOURCE_PATH": "Enter the path to the source game : ",
|
||||
"TEXT_INPUT_DESTINATION_DIRECTORY": "Enter the path to the destination directory : ",
|
||||
"TEXT_INPUT_OUPUT_TYPE": "Enter output type %s : "
|
||||
}
|
||||
}
|
24
main.pyw
24
main.pyw
|
@ -1,4 +1,5 @@
|
|||
from source.gui import install
|
||||
import argparse
|
||||
|
||||
from source.option import Options
|
||||
from source.translation import load_language
|
||||
|
||||
|
@ -9,5 +10,22 @@ self = __import__(__name__)
|
|||
options = Options.from_file("./option.json")
|
||||
translater = load_language(options.language.get())
|
||||
|
||||
self.window = install.Window(options)
|
||||
self.window.run()
|
||||
|
||||
def main_gui():
|
||||
from source.gui import install
|
||||
self.window = install.Window(options)
|
||||
self.window.run()
|
||||
|
||||
|
||||
def main_cli():
|
||||
from source.cli import install
|
||||
install.cli(options)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-i", "--interface", choices=["gui", "cli"], default="gui")
|
||||
args = parser.parse_args()
|
||||
|
||||
match args.interface:
|
||||
case "gui": main_gui()
|
||||
case "cli": main_cli()
|
||||
|
|
61
source/cli/install.py
Normal file
61
source/cli/install.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
from pathlib import Path
|
||||
|
||||
from source.mkw.Game import Game
|
||||
from source.mkw.ModConfig import ModConfig
|
||||
from source.translation import translate as _
|
||||
from source.mkw.collection.Extension import Extension
|
||||
|
||||
|
||||
def cli(options):
|
||||
print(_("TITLE_INSTALL"))
|
||||
|
||||
packs = []
|
||||
for pack in Path("./Pack/").iterdir():
|
||||
packs.append(pack)
|
||||
|
||||
mod_name = input(_("TEXT_INPUT_MOD_NAME") % [pack.name for pack in packs])
|
||||
mod_config = ModConfig.from_file(Path(f"./Pack/{mod_name}/mod_config.json"))
|
||||
|
||||
source_path = input(_("TEXT_INPUT_SOURCE_PATH"))
|
||||
game = Game(source_path)
|
||||
|
||||
destination_directory = input(_("TEXT_INPUT_DESTINATION_DIRECTORY"))
|
||||
destination_path = Path(destination_directory)
|
||||
|
||||
output_name = input(_("TEXT_INPUT_OUPUT_TYPE") % [extension.name for extension in Extension])
|
||||
output_type = Extension[output_name]
|
||||
|
||||
progressbar_max: int = 30
|
||||
|
||||
title: str = ""
|
||||
description: str = ""
|
||||
current_part: int = 0
|
||||
max_part: int = 0
|
||||
current_step: int = 0
|
||||
max_step: int = 0
|
||||
|
||||
for step in game.install_mod(
|
||||
dest=destination_path,
|
||||
mod_config=mod_config,
|
||||
output_type=output_type,
|
||||
options=options
|
||||
):
|
||||
if step.title is not None: title = step.title
|
||||
if step.description is not None: description = step.description
|
||||
if step.max_part is not None: max_part = step.max_part
|
||||
if step.set_part is not None: current_part = step.set_part
|
||||
if step.part is not None: current_part += step.part
|
||||
if step.max_step is not None: max_step = step.max_step
|
||||
if step.set_step is not None: current_step = step.set_step
|
||||
if step.step is not None: current_step += step.step
|
||||
|
||||
progressbar_step: int = current_step * progressbar_max // max_step if max_step > 0 else 0
|
||||
|
||||
print("\033[H\033[J", end="")
|
||||
print(title, f"({current_part} / {max_part})")
|
||||
print(description)
|
||||
print(
|
||||
f"{round((current_step / max_step if max_step > 0 else 0) * 100, 2)}% "
|
||||
f"[{'#' * progressbar_step}{' ' * (progressbar_max - progressbar_step)}]"
|
||||
)
|
||||
|
|
@ -523,8 +523,7 @@ class SelectPack(ttk.Frame):
|
|||
"""
|
||||
self.packs = []
|
||||
|
||||
for pack in Path("./Pack/").iterdir():
|
||||
if self.is_valid_pack(pack):
|
||||
for pack in filter(lambda pack: self.is_valid_pack(pack), Path("./Pack/").iterdir()):
|
||||
self.packs.append(pack)
|
||||
|
||||
self.combobox["values"] = [pack.name for pack in self.packs]
|
||||
|
|
Loading…
Reference in a new issue