Basic saving
This commit is contained in:
parent
3dec77927a
commit
1daa5e8a0c
|
@ -2,9 +2,9 @@ import subprocess
|
|||
import os
|
||||
|
||||
|
||||
def get_features_list() -> list:
|
||||
def get_features_list(path_: str) -> list:
|
||||
features = subprocess.run(
|
||||
["minecraft-pi-reborn-client", "--print-available-feature-flags"],
|
||||
[path_, "--print-available-feature-flags"],
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.decode("utf-8")
|
||||
features = features.split("\n")
|
||||
|
@ -19,9 +19,9 @@ def get_features_list() -> list:
|
|||
return returnlist
|
||||
|
||||
|
||||
def get_features_dict() -> dict:
|
||||
def get_features_dict(path_: str) -> dict:
|
||||
features = subprocess.run(
|
||||
["minecraft-pi-reborn-client", "--print-available-feature-flags"],
|
||||
[path_, "--print-available-feature-flags"],
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.decode("utf-8")
|
||||
features = features.split("\n")
|
||||
|
@ -64,7 +64,7 @@ def set_options(env, options: dict):
|
|||
return env
|
||||
|
||||
|
||||
def run(env):
|
||||
def run(env, path_: str):
|
||||
return subprocess.Popen(
|
||||
["/usr/bin/minecraft-pi-reborn-client"], env=env, preexec_fn=os.setsid
|
||||
[path_], env=env, preexec_fn=os.setsid
|
||||
)
|
||||
|
|
|
@ -52,7 +52,7 @@ if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
|||
# DEFAULT_FEATURES = json.loads(f.read())["features"]
|
||||
# else:
|
||||
# TODO: Add a tab with a button to import features from gMCPIL
|
||||
DEFAULT_FEATURES = launcher.get_features_dict()
|
||||
DEFAULT_FEATURES = launcher.get_features_dict("/usr/bin/minecraft-pi-reborn-client")
|
||||
|
||||
|
||||
class Planet(QMainWindow):
|
||||
|
@ -62,6 +62,23 @@ class Planet(QMainWindow):
|
|||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
if not os.path.exists(f"/home/{USER}/.planet-launcher/config.json"):
|
||||
|
||||
self.conf = {
|
||||
"username": "StevePi",
|
||||
"options": DEFAULT_FEATURES,
|
||||
"hidelauncher": True,
|
||||
"profile": "Modded MCPi",
|
||||
"theme": "QDarkTheme Light"
|
||||
}
|
||||
|
||||
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
|
||||
file.write(json.dumps(self.conf))
|
||||
else:
|
||||
with open(f"/home/{USER}/.planet-launcher/config.json") as file:
|
||||
self.conf = json.loads(file.read())
|
||||
|
||||
|
||||
self.setWindowTitle("Planet")
|
||||
|
||||
|
@ -83,6 +100,8 @@ class Planet(QMainWindow):
|
|||
self.setCentralWidget(tabs)
|
||||
|
||||
self.setGeometry(600, 800, 200, 200)
|
||||
|
||||
self.usernameedit.setText(self.conf["username"])
|
||||
|
||||
self.set_features()
|
||||
|
||||
|
@ -268,6 +287,7 @@ class Planet(QMainWindow):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setPalette(qdarktheme.load_palette("dark"))
|
||||
|
||||
|
|
Loading…
Reference in New Issue