mirror of
https://scm.osdn.net/gitroot/planet/planet-launcher.git
synced 2024-06-19 13:27:29 +00:00
Reformat with black
This commit is contained in:
parent
ac24026242
commit
a92c443826
|
@ -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:
|
||||||
|
@ -12,30 +15,33 @@ def get_features_list() -> list:
|
||||||
if feature.startswith("FALSE"):
|
if feature.startswith("FALSE"):
|
||||||
feature = feature[6:]
|
feature = feature[6:]
|
||||||
returnlist.append(feature)
|
returnlist.append(feature)
|
||||||
|
|
||||||
return returnlist
|
return returnlist
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -56,6 +62,9 @@ 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
|
||||||
|
)
|
||||||
|
|
|
@ -30,7 +30,7 @@ from datetime import date
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
from PyQt5.QtCore import *
|
from PyQt5.QtCore import *
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
from PyQt5.QtGui import *
|
from PyQt5.QtGui import *
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -88,32 +88,31 @@ class Planet(QMainWindow):
|
||||||
|
|
||||||
def play_tab(self) -> QWidget:
|
def play_tab(self) -> QWidget:
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
|
|
||||||
titlelayout = QGridLayout()
|
titlelayout = QGridLayout()
|
||||||
|
|
||||||
logopixmap = QPixmap("assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio)
|
logopixmap = QPixmap("assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio)
|
||||||
|
|
||||||
logolabel = QLabel()
|
logolabel = QLabel()
|
||||||
logolabel.setPixmap(logopixmap)
|
logolabel.setPixmap(logopixmap)
|
||||||
logolabel.setAlignment(Qt.AlignRight)
|
logolabel.setAlignment(Qt.AlignRight)
|
||||||
|
|
||||||
namelabel = QLabel()
|
namelabel = QLabel()
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -145,13 +144,13 @@ class Planet(QMainWindow):
|
||||||
|
|
||||||
titlelayout.addWidget(logolabel, 0, 0)
|
titlelayout.addWidget(logolabel, 0, 0)
|
||||||
titlelayout.addWidget(namelabel, 0, 1)
|
titlelayout.addWidget(namelabel, 0, 1)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -237,10 +236,14 @@ class Planet(QMainWindow):
|
||||||
widget.setLayout(fakelayout)
|
widget.setLayout(fakelayout)
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ SPLASHES = [
|
||||||
"Pluto = Planet",
|
"Pluto = Planet",
|
||||||
"Ayy Yep!",
|
"Ayy Yep!",
|
||||||
"What's my purpose?",
|
"What's my purpose?",
|
||||||
"MCPI_SPEEDHACK",
|
"MCPI_SPEEDHACK",
|
||||||
"MCPIL-Revival",
|
"MCPIL-Revival",
|
||||||
"Minescripters",
|
"Minescripters",
|
||||||
"I use Planet BTW",
|
"I use Planet BTW",
|
||||||
"Snowball",
|
"Snowball",
|
||||||
"Robo",
|
"Robo",
|
||||||
"If I could, I would. But I can't, so I shan't.",
|
"If I could, I would. But I can't, so I shan't.",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user