mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
moved NoGui to Game.py, moved restart from Gui.py to definition.py
This commit is contained in:
parent
1bb84fce32
commit
742c1c3bfa
5 changed files with 45 additions and 35 deletions
|
@ -3,11 +3,9 @@ from PIL import Image
|
|||
import shutil
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
|
||||
from .CT_Config import CT_Config
|
||||
from .definition import *
|
||||
from .Gui import NoGui
|
||||
from . import wszst
|
||||
|
||||
|
||||
|
@ -41,6 +39,37 @@ class CantConvertTrack(Exception):
|
|||
super().__init__("Can't convert track, check if download are enabled.")
|
||||
|
||||
|
||||
class NoGui:
|
||||
"""
|
||||
'fake' gui if no gui are used for compatibility.
|
||||
"""
|
||||
class NoButton:
|
||||
def grid(self, *args, **kwargs): pass
|
||||
def config(self, *args, **kwargs): pass
|
||||
|
||||
class NoVariable:
|
||||
def __init__(self, value=None):
|
||||
self.value = None
|
||||
|
||||
def set(self, value):
|
||||
self.value = value
|
||||
|
||||
def get(self):
|
||||
return self.value
|
||||
|
||||
def progress(*args, **kwargs): print(args, kwargs)
|
||||
def translate(*args, **kwargs): return ""
|
||||
def log_error(*args, **kwargs): print(args, kwargs)
|
||||
|
||||
is_dev_version = False
|
||||
button_install_mod = NoButton()
|
||||
stringvar_game_format = NoVariable()
|
||||
boolvar_disable_download = NoVariable()
|
||||
intvar_process_track = NoVariable()
|
||||
boolvar_dont_check_track_sha1 = NoVariable()
|
||||
boolvar_del_track_after_conv = NoVariable()
|
||||
|
||||
|
||||
class Game:
|
||||
def __init__(self, path: str = "", region_ID: str = "P", game_ID: str = "RMCP01", gui=None):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from distutils.version import StrictVersion
|
||||
from tkinter import filedialog, ttk, messagebox
|
||||
from tkinter import *
|
||||
import subprocess
|
||||
import traceback
|
||||
import requests
|
||||
import zipfile
|
||||
|
@ -16,36 +15,6 @@ with open("./translation.json", encoding="utf-8") as f:
|
|||
translation_dict = json.load(f)
|
||||
|
||||
|
||||
def restart():
|
||||
"""
|
||||
restart the application
|
||||
"""
|
||||
subprocess.Popen([sys.executable] + sys.argv, creationflags=subprocess.CREATE_NO_WINDOW, cwd=os.getcwd())
|
||||
exit()
|
||||
|
||||
|
||||
class NoGui:
|
||||
"""
|
||||
'fake' gui if no gui are used for compatibility.
|
||||
"""
|
||||
class NoButton:
|
||||
def grid(self, *args, **kwargs): pass
|
||||
def config(self, *args, **kwargs): pass
|
||||
|
||||
def progress(*args, **kwargs): print(args, kwargs)
|
||||
def translate(*args, **kwargs): return ""
|
||||
def log_error(*args, **kwargs): print(args, kwargs)
|
||||
def restart(self): restart()
|
||||
|
||||
is_dev_version = False
|
||||
button_install_mod = NoButton()
|
||||
stringvar_game_format = StringVar()
|
||||
boolvar_disable_download = BooleanVar()
|
||||
intvar_process_track = IntVar()
|
||||
boolvar_dont_check_track_sha1 = BooleanVar()
|
||||
boolvar_del_track_after_conv = BooleanVar()
|
||||
|
||||
|
||||
class Gui:
|
||||
def __init__(self):
|
||||
"""
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from .definition import restart
|
||||
|
||||
|
||||
class Option:
|
||||
def __init__(self):
|
||||
|
@ -28,7 +30,7 @@ class Option:
|
|||
else:
|
||||
setattr(self, option, value.get())
|
||||
self.save_to_file()
|
||||
if need_restart: gui.restart()
|
||||
if need_restart: restart()
|
||||
|
||||
def load_from_file(self, option_file: str = "./option.json") -> None:
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import requests
|
||||
import os
|
||||
|
||||
from .definition import *
|
||||
from . import wszst
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
from threading import Thread
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
GITHUB_REPOSITORY = "Faraphel/MKWF-Install"
|
||||
GITHUB_MASTER_BRANCH = f"https://raw.githubusercontent.com/{GITHUB_REPOSITORY}/master/"
|
||||
|
@ -94,6 +97,14 @@ region_id_to_name = {
|
|||
}
|
||||
|
||||
|
||||
def restart():
|
||||
"""
|
||||
restart the application
|
||||
"""
|
||||
subprocess.Popen([sys.executable] + sys.argv, creationflags=subprocess.CREATE_NO_WINDOW, cwd=os.getcwd())
|
||||
exit()
|
||||
|
||||
|
||||
def in_thread(func):
|
||||
"""
|
||||
instead of calling a function, this will start it in a thread
|
||||
|
|
Loading…
Reference in a new issue