Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

feat(directory): ✨ FO dir #117

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion vanilla_installer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions vanilla_installer/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 25 additions & 2 deletions vanilla_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
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
import requests
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")
Expand Down Expand Up @@ -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:
Expand Down