mirror of
https://scm.osdn.net/gitroot/planet/planet-launcher.git
synced 2024-08-07 20:56:56 +00:00
Reformat with black
This commit is contained in:
parent
ac24026242
commit
a92c443826
3 changed files with 56 additions and 42 deletions
|
@ -3,7 +3,10 @@ import os
|
||||||
|
|
||||||
|
|
||||||
def get_features_list() -> list:
|
def get_features_list() -> list:
|
||||||
features = subprocess.run(["minecraft-pi-reborn-client", '--print-available-feature-flags'], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
features = subprocess.run(
|
||||||
|
["minecraft-pi-reborn-client", "--print-available-feature-flags"],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
).stdout.decode("utf-8")
|
||||||
features = features.split("\n")
|
features = features.split("\n")
|
||||||
returnlist = list()
|
returnlist = list()
|
||||||
for feature in features:
|
for feature in features:
|
||||||
|
@ -17,25 +20,28 @@ def get_features_list() -> list:
|
||||||
|
|
||||||
|
|
||||||
def get_features_dict() -> dict:
|
def get_features_dict() -> dict:
|
||||||
features = subprocess.run(["minecraft-pi-reborn-client", '--print-available-feature-flags'], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
features = subprocess.run(
|
||||||
|
["minecraft-pi-reborn-client", "--print-available-feature-flags"],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
).stdout.decode("utf-8")
|
||||||
features = features.split("\n")
|
features = features.split("\n")
|
||||||
returndict = dict()
|
returndict = dict()
|
||||||
for feature in features:
|
for feature in features:
|
||||||
if feature.startswith("TRUE"):
|
if feature.startswith("TRUE"):
|
||||||
feature = feature[5:]
|
feature = feature[5:]
|
||||||
returndict[feature] = True
|
returndict[feature] = True
|
||||||
if feature.startswith("FALSE"):
|
if feature.startswith("FALSE"):
|
||||||
feature = feature[6:]
|
feature = feature[6:]
|
||||||
returndict[feature] = False
|
returndict[feature] = False
|
||||||
return returndict
|
return returndict
|
||||||
|
|
||||||
|
|
||||||
def set_username(env, username: str = "StevePi"):
|
def set_username(env, username: str = "StevePi"):
|
||||||
env["MCPI_USERNAME"] = username
|
env["MCPI_USERNAME"] = username
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def set_render_distance(env, distance: str = "SHORT"):
|
def set_render_distance(env, distance: str = "SHORT"):
|
||||||
if distance.upper() not in ["TINY", "SHORT", "NORMAL", "FAR"]:
|
if distance.upper() not in ["TINY", "SHORT", "NORMAL", "FAR"]:
|
||||||
raise Exception("Invalid render distance")
|
raise Exception("Invalid render distance")
|
||||||
else:
|
else:
|
||||||
|
@ -43,7 +49,7 @@ def set_render_distance(env, distance: str = "SHORT"):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def set_hud(env, options: str = "fps,simple"):
|
def set_hud(env, options: str = "fps,simple"):
|
||||||
env["GALLIUM_HUD"] = options
|
env["GALLIUM_HUD"] = options
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
@ -57,5 +63,8 @@ def set_options(env, options: dict):
|
||||||
env["MCPI_FEATURE_FLAGS"] = output
|
env["MCPI_FEATURE_FLAGS"] = output
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def run(env):
|
def run(env):
|
||||||
return subprocess.Popen(['/usr/bin/minecraft-pi-reborn-client'], env=env, preexec_fn=os.setsid)
|
return subprocess.Popen(
|
||||||
|
["/usr/bin/minecraft-pi-reborn-client"], env=env, preexec_fn=os.setsid
|
||||||
|
)
|
||||||
|
|
|
@ -47,11 +47,11 @@ USER = os.getenv("USER")
|
||||||
if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
||||||
os.makedirs(f"/home/{USER}/.planet-launcher/mods")
|
os.makedirs(f"/home/{USER}/.planet-launcher/mods")
|
||||||
|
|
||||||
#if os.path.exists(f"/home/{USER}/.gmcpil.json"):
|
# if os.path.exists(f"/home/{USER}/.gmcpil.json"):
|
||||||
# with open(f"/home/{USER}/.gmcpil.json") as f:
|
# with open(f"/home/{USER}/.gmcpil.json") as f:
|
||||||
# DEFAULT_FEATURES = json.loads(f.read())["features"]
|
# DEFAULT_FEATURES = json.loads(f.read())["features"]
|
||||||
#else:
|
# else:
|
||||||
#TODO: Add a tab with a button to import features from gMCPIL
|
# TODO: Add a tab with a button to import features from gMCPIL
|
||||||
DEFAULT_FEATURES = launcher.get_features_dict()
|
DEFAULT_FEATURES = launcher.get_features_dict()
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,13 +72,13 @@ class Planet(QMainWindow):
|
||||||
tabs.setMovable(True)
|
tabs.setMovable(True)
|
||||||
|
|
||||||
play_tab = tabs.addTab(self.play_tab(), "Play")
|
play_tab = tabs.addTab(self.play_tab(), "Play")
|
||||||
tabs.setTabIcon(play_tab, QIcon('assets/logo512.png'))
|
tabs.setTabIcon(play_tab, QIcon("assets/logo512.png"))
|
||||||
features_tab = tabs.addTab(self.features_tab(), "Features")
|
features_tab = tabs.addTab(self.features_tab(), "Features")
|
||||||
tabs.setTabIcon(features_tab, QIcon('assets/heart512.png'))
|
tabs.setTabIcon(features_tab, QIcon("assets/heart512.png"))
|
||||||
mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
|
mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
|
||||||
tabs.setTabIcon(mods_tab, QIcon('assets/portal512.png'))
|
tabs.setTabIcon(mods_tab, QIcon("assets/portal512.png"))
|
||||||
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
|
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
|
||||||
tabs.setTabIcon(changelog_tab, QIcon('assets/pi512.png'))
|
tabs.setTabIcon(changelog_tab, QIcon("assets/pi512.png"))
|
||||||
|
|
||||||
self.setCentralWidget(tabs)
|
self.setCentralWidget(tabs)
|
||||||
|
|
||||||
|
@ -102,18 +102,17 @@ class Planet(QMainWindow):
|
||||||
if date.today().month == 4 and date.today().day == 1:
|
if date.today().month == 4 and date.today().day == 1:
|
||||||
namelabel.setText("Banana Launcher")
|
namelabel.setText("Banana Launcher")
|
||||||
else:
|
else:
|
||||||
if random.randint(1, 100) == 1:
|
if random.randint(1, 100) == 1:
|
||||||
namelabel.setText("Pluto Launcher")
|
namelabel.setText("Pluto Launcher")
|
||||||
else:
|
else:
|
||||||
namelabel.setText('Planet Launcher')
|
namelabel.setText("Planet Launcher")
|
||||||
|
|
||||||
|
|
||||||
font = namelabel.font()
|
font = namelabel.font()
|
||||||
font.setPointSize(30)
|
font.setPointSize(30)
|
||||||
namelabel.setFont(font)
|
namelabel.setFont(font)
|
||||||
namelabel.setAlignment(Qt.AlignLeft)
|
namelabel.setAlignment(Qt.AlignLeft)
|
||||||
|
|
||||||
splashlabel = QLabel(f"<font color=\"gold\">{random.choice(SPLASHES)}</font>")
|
splashlabel = QLabel(f'<font color="gold">{random.choice(SPLASHES)}</font>')
|
||||||
splashlabel.adjustSize()
|
splashlabel.adjustSize()
|
||||||
splashlabel.setAlignment(Qt.AlignHCenter)
|
splashlabel.setAlignment(Qt.AlignHCenter)
|
||||||
|
|
||||||
|
@ -149,9 +148,9 @@ class Planet(QMainWindow):
|
||||||
titlewidget = QWidget()
|
titlewidget = QWidget()
|
||||||
titlewidget.setLayout(titlelayout)
|
titlewidget.setLayout(titlelayout)
|
||||||
|
|
||||||
layout.addWidget(titlewidget, 0, 0, 2, 5)
|
layout.addWidget(titlewidget, 0, 0, 2, 5)
|
||||||
|
|
||||||
layout.addWidget(splashlabel, 2, 0, 1, 6)
|
layout.addWidget(splashlabel, 2, 0, 1, 6)
|
||||||
|
|
||||||
layout.addWidget(usernamelabel, 3, 0)
|
layout.addWidget(usernamelabel, 3, 0)
|
||||||
layout.addWidget(self.usernameedit, 3, 4, 1, 2)
|
layout.addWidget(self.usernameedit, 3, 4, 1, 2)
|
||||||
|
@ -240,7 +239,11 @@ class Planet(QMainWindow):
|
||||||
|
|
||||||
def changelog_tab(self):
|
def changelog_tab(self):
|
||||||
web = QWebView()
|
web = QWebView()
|
||||||
web.load(QUrl().fromLocalFile(f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html"))
|
web.load(
|
||||||
|
QUrl().fromLocalFile(
|
||||||
|
f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html"
|
||||||
|
)
|
||||||
|
)
|
||||||
print(f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html")
|
print(f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html")
|
||||||
return web
|
return web
|
||||||
|
|
||||||
|
@ -252,9 +255,11 @@ class Planet(QMainWindow):
|
||||||
self.launchfeatures[feature] = False
|
self.launchfeatures[feature] = False
|
||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
self.env = launcher.set_username(self.env, self.usernameedit.text())
|
self.env = launcher.set_username(self.env, self.usernameedit.text())
|
||||||
self.env = launcher.set_options(self.env, self.launchfeatures)
|
self.env = launcher.set_options(self.env, self.launchfeatures)
|
||||||
self.env = launcher.set_render_distance(self.env, self.distancebox.currentText())
|
self.env = launcher.set_render_distance(
|
||||||
|
self.env, self.distancebox.currentText()
|
||||||
|
)
|
||||||
|
|
||||||
print(self.env)
|
print(self.env)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue