This repository was archived by the owner on Aug 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import logging
12import os
23import platform
34from pathlib import Path
67import tomlkit
78from tomlkit import toml_file
89
9- from vanilla_installer . log import logger
10+ logger = logging . getLogger ( __name__ )
1011
1112FILE_PATH = str (Path ("vanilla_installer.toml" ).resolve ())
1213
@@ -23,8 +24,15 @@ def init():
2324
2425 config = tomlkit .table ()
2526 # maybe call darkdetect from here?
26- # might want to just leave this alone to be
27+ # might want to just leave this alone to be honest
2728 config .add ("theme" , "dark" )
29+ config .add (
30+ tomlkit .comment (
31+ "Whether to use FO's directory or ask the user for a custom one."
32+ )
33+ )
34+ config .add ("fo_dir" , True )
35+ config .add (tomlkit .comment ("This is only used is fo_dir (above) is false." ))
2836 config .add ("path" , mll .utils .get_minecraft_directory ())
2937 if platform .system () == "Windows" :
3038 font = "Inter Regular"
Original file line number Diff line number Diff line change @@ -502,6 +502,23 @@ def changeFont(self, state) -> None:
502502 self .reloadTheme ()
503503 self .parentWindow .reloadTheme ()
504504
505+ def setFODir (self , state : bool ) -> None :
506+ """Set whether the FO dir should be used.
507+
508+ Args:
509+ state (bool): Whether the FO directory is being enabled or disabled.
510+ """
511+ if state is True :
512+ config .write ("fo_dir" , True )
513+ self .parentWindow .locationSelector .setDisabled (True )
514+ self .parentWindow .selectedLocation .setDisabled (True )
515+ else :
516+ config .write ("fo_dir" , False )
517+ self .parentWindow .locationSelector .setDisabled (False )
518+ self .parentWindow .selectedLocation .setDisabled (False )
519+ self .reloadTheme ()
520+ self .parentWindow .reloadTheme ()
521+
505522
506523class Worker (QRunnable ):
507524 def __init__ (self , fn ) -> None :
Original file line number Diff line number Diff line change 33"""Starts logging for Vanilla Installer."""
44import logging
55import logging .handlers # pylance moment
6- from pathlib import Path
76import sys
7+ from pathlib import Path
88
99
1010class LoggerWriter :
@@ -13,9 +13,9 @@ def __init__(self, logfct):
1313 self .buf = []
1414
1515 def write (self , msg ):
16- if msg .endswith (' \n ' ):
17- self .buf .append (msg .removesuffix (' \n ' ))
18- self .logfct ('' .join (self .buf ))
16+ if msg .endswith (" \n " ):
17+ self .buf .append (msg .removesuffix (" \n " ))
18+ self .logfct ("" .join (self .buf ))
1919 self .buf = []
2020 else :
2121 self .buf .append (msg )
@@ -32,11 +32,11 @@ def flush(self):
3232 with logfile_path as file :
3333 open (file , "x" , encoding = "utf-8" ).write ("" )
3434handler = logging .handlers .RotatingFileHandler (
35- filename = logfile_path ,
36- encoding = "utf-8" ,
37- maxBytes = 32 * 1024 * 1024 , # 32 MiB
38- backupCount = 5 , # Rotate through 5 files
39- )
35+ filename = logfile_path ,
36+ encoding = "utf-8" ,
37+ maxBytes = 32 * 1024 * 1024 , # 32 MiB
38+ backupCount = 5 , # Rotate through 5 files
39+ )
4040
4141dt_fmt = "%Y-%m-%d %H:%M:%S"
4242formatter = logging .Formatter (
Original file line number Diff line number Diff line change 55"""
66# IMPORTS
77
8-
98import base64
109import io
1110import json
1413import subprocess
1514import zipfile
1615from pathlib import Path
17- from typing import Optional
16+ from typing import Optional , Union
1817
1918import click
2019import minecraft_launcher_lib as mll
@@ -196,6 +195,29 @@ def get_version() -> str:
196195 return __version__
197196
198197
198+ def get_fo_dir () -> str :
199+ """Get the default directory to use when the independent FO directory is selected.
200+
201+ Returns:
202+ str: The path.
203+ """
204+ if platform .system () == "Windows" :
205+ fo_dir_path = (
206+ Path ("~/AppData/Roaming/Fabulously Optimized" ).expanduser ().resolve ()
207+ )
208+ elif platform .system () == "macOS" :
209+ fo_dir_path = (
210+ Path ("~/Library/Application Support/Fabulously Optimized" )
211+ .expanduser ()
212+ .resolve ()
213+ )
214+ else :
215+ fo_dir_path = Path ("~/.local/share/Fabulously Optimized" ).expanduser ().resolve ()
216+ if fo_dir_path .exists () is False :
217+ fo_dir_path .mkdir ()
218+ return str (fo_dir_path )
219+
220+
199221def text_update (
200222 text : str , widget = None , mode : str = "info" , interface : str = "GUI"
201223) -> None :
You can’t perform that action at this time.
0 commit comments