diff --git a/poetry.lock b/poetry.lock index 20c32e2..c47c4e5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. [[package]] name = "anyio" diff --git a/vanilla_installer/config.py b/vanilla_installer/config.py index 87f6d6c..4afe65d 100644 --- a/vanilla_installer/config.py +++ b/vanilla_installer/config.py @@ -32,8 +32,15 @@ def init(): config = tomlkit.table() # maybe call darkdetect from here? - # might want to just leave this alone to be + # might want to just leave this alone to be honest config.add("theme", "dark") + config.add( + tomlkit.comment( + "Whether to use FO's directory or ask the user for a custom one." + ) + ) + config.add("fo_dir", True) + config.add(tomlkit.comment("This is only used is fo_dir (above) is false.")) config.add("path", mll.utils.get_minecraft_directory()) if platform.system() == "Windows": font = "Inter Regular" diff --git a/vanilla_installer/gui.py b/vanilla_installer/gui.py index 0a4e15b..a54c85b 100644 --- a/vanilla_installer/gui.py +++ b/vanilla_installer/gui.py @@ -540,6 +540,23 @@ def changeFont(self, state) -> None: self.reloadTheme() self.parentWindow.reloadTheme() + def setFODir(self, state: bool) -> None: + """Set whether the FO dir should be used. + + Args: + state (bool): Whether the FO directory is being enabled or disabled. + """ + if state is True: + config.write("fo_dir", True) + self.parentWindow.locationSelector.setDisabled(True) + self.parentWindow.selectedLocation.setDisabled(True) + else: + config.write("fo_dir", False) + self.parentWindow.locationSelector.setDisabled(False) + self.parentWindow.selectedLocation.setDisabled(False) + self.reloadTheme() + self.parentWindow.reloadTheme() + class Worker(QRunnable): def __init__(self, fn) -> None: diff --git a/vanilla_installer/main.py b/vanilla_installer/main.py index 47e0971..a8af1d3 100644 --- a/vanilla_installer/main.py +++ b/vanilla_installer/main.py @@ -14,7 +14,7 @@ import subprocess import zipfile from pathlib import Path -from typing import Optional +from typing import Optional, Union import click import minecraft_launcher_lib as mll @@ -22,7 +22,7 @@ import tomlkit as toml # Local -from vanilla_installer import __version__, config, log +from vanilla_installer import __version__, config logger = log.setup_logging() logger.info("Starting Vanilla Installer") @@ -152,6 +152,29 @@ def get_version() -> str: return __version__ +def get_fo_dir() -> str: + """Get the default directory to use when the independent FO directory is selected. + + Returns: + str: The path. + """ + if platform.system() == "Windows": + fo_dir_path = ( + Path("~/AppData/Roaming/Fabulously Optimized").expanduser().resolve() + ) + elif platform.system() == "macOS": + fo_dir_path = ( + Path("~/Library/Application Support/Fabulously Optimized") + .expanduser() + .resolve() + ) + else: + fo_dir_path = Path("~/.local/share/Fabulously Optimized").expanduser().resolve() + if fo_dir_path.exists() is False: + fo_dir_path.mkdir() + return str(fo_dir_path) + + def text_update( text: str, widget=None, mode: str = "info", interface: str = "GUI" ) -> None: