mirror of
https://scm.osdn.net/gitroot/planet/planet-launcher.git
synced 2024-08-15 03:28:13 +00:00
Fix not responding error
This commit is contained in:
parent
de26e4a87e
commit
c908617c7e
2 changed files with 97 additions and 79 deletions
|
@ -4,8 +4,7 @@ import os
|
|||
|
||||
def get_features_list(path_: str) -> list:
|
||||
features = subprocess.run(
|
||||
[path_, "--print-available-feature-flags"],
|
||||
stdout=subprocess.PIPE,
|
||||
[path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
|
||||
).stdout.decode("utf-8")
|
||||
features = features.split("\n")
|
||||
returnlist = list()
|
||||
|
@ -21,8 +20,7 @@ def get_features_list(path_: str) -> list:
|
|||
|
||||
def get_features_dict(path_: str) -> dict:
|
||||
features = subprocess.run(
|
||||
[path_, "--print-available-feature-flags"],
|
||||
stdout=subprocess.PIPE,
|
||||
[path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
|
||||
).stdout.decode("utf-8")
|
||||
features = features.split("\n")
|
||||
returndict = dict()
|
||||
|
@ -65,6 +63,4 @@ def set_options(env, options: dict):
|
|||
|
||||
|
||||
def run(env, path_: str):
|
||||
return subprocess.Popen(
|
||||
[path_], env=env, preexec_fn=os.setsid
|
||||
).wait()
|
||||
return subprocess.Popen([path_], env=env, preexec_fn=os.setsid)
|
||||
|
|
|
@ -64,6 +64,7 @@ if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
|||
# else:
|
||||
# TODO: Add a tab with a button to import features from gMCPIL
|
||||
|
||||
|
||||
class ConfigPluto(QDialog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
@ -72,7 +73,9 @@ class ConfigPluto(QDialog):
|
|||
layout = QVBoxLayout()
|
||||
titlelayout = QGridLayout()
|
||||
|
||||
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio)
|
||||
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(
|
||||
100, 100, Qt.KeepAspectRatio
|
||||
)
|
||||
namelabel = QLabel("Pluto Wizard")
|
||||
|
||||
logolabel = QLabel()
|
||||
|
@ -90,7 +93,9 @@ class ConfigPluto(QDialog):
|
|||
titlewidget = QWidget()
|
||||
titlewidget.setLayout(titlelayout)
|
||||
|
||||
info_label = QLabel("Please select the executable you downloaded.\nIf you installed a DEB, please select the \"Link\" option")
|
||||
info_label = QLabel(
|
||||
'Please select the executable you downloaded.\nIf you installed a DEB, please select the "Link" option'
|
||||
)
|
||||
|
||||
self.executable_btn = QPushButton("Select executable")
|
||||
self.executable_btn.clicked.connect(self.get_appimage)
|
||||
|
@ -123,10 +128,16 @@ class ConfigPluto(QDialog):
|
|||
|
||||
def get_appimage(self):
|
||||
self.hide()
|
||||
self.filename = QFileDialog.getOpenFileName(self, 'Select executable', '/',"Executable files (*.AppImage *.bin *.sh *)")
|
||||
self.filename = QFileDialog.getOpenFileName(
|
||||
self, "Select executable", "/", "Executable files (*.AppImage *.bin *.sh *)"
|
||||
)
|
||||
|
||||
def link_appimage(self):
|
||||
self.hide()
|
||||
os.symlink("/usr/bin/minecraft-pi-reborn-client", f"/home/{USER}/.planet-launcher/minecraft.AppImage")
|
||||
os.symlink(
|
||||
"/usr/bin/minecraft-pi-reborn-client",
|
||||
f"/home/{USER}/.planet-launcher/minecraft.AppImage",
|
||||
)
|
||||
self.filename = list()
|
||||
self.filename.append(False)
|
||||
|
||||
|
@ -143,7 +154,12 @@ class Planet(QMainWindow):
|
|||
try:
|
||||
RPC = pypresence.Presence(787496148763541505)
|
||||
RPC.connect()
|
||||
RPC.update(state="Launched with Planet Launcher", details="Minecraft Pi Edition: Reborn", large_image="logo", small_image=random.choice(["heart", "portal", "multiplayer", "pi"]))
|
||||
RPC.update(
|
||||
state="Launched with Planet Launcher",
|
||||
details="Minecraft Pi Edition: Reborn",
|
||||
large_image="logo",
|
||||
small_image=random.choice(["heart", "portal", "multiplayer", "pi"]),
|
||||
)
|
||||
except:
|
||||
print("Unable to initalize Discord RPC. Skipping.")
|
||||
|
||||
|
@ -151,7 +167,9 @@ class Planet(QMainWindow):
|
|||
|
||||
self.conf = {
|
||||
"username": "StevePi",
|
||||
"options": launcher.get_features_dict(f"/home/{USER}/.planet-launcher/minecraft.AppImage"),
|
||||
"options": launcher.get_features_dict(
|
||||
f"/home/{USER}/.planet-launcher/minecraft.AppImage"
|
||||
),
|
||||
"hidelauncher": True,
|
||||
"profile": "Modded MCPE",
|
||||
"render_distance": "Short",
|
||||
|
@ -165,7 +183,6 @@ class Planet(QMainWindow):
|
|||
with open(f"/home/{USER}/.planet-launcher/config.json") as file:
|
||||
self.conf = json.loads(file.read())
|
||||
|
||||
|
||||
self.setWindowTitle("Planet")
|
||||
|
||||
self.setWindowIcon(QIcon(f"{absolute_path}/assets/logo512.png"))
|
||||
|
@ -179,7 +196,9 @@ class Planet(QMainWindow):
|
|||
features_tab = tabs.addTab(self.features_tab(), "Features")
|
||||
tabs.setTabIcon(features_tab, QIcon(f"{absolute_path}/assets/heart512.png"))
|
||||
servers_tab = tabs.addTab(self.servers_tab(), "Servers")
|
||||
tabs.setTabIcon(servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png"))
|
||||
tabs.setTabIcon(
|
||||
servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png")
|
||||
)
|
||||
# mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
|
||||
# tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png"))
|
||||
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
|
||||
|
@ -208,7 +227,9 @@ class Planet(QMainWindow):
|
|||
|
||||
titlelayout = QGridLayout()
|
||||
|
||||
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio)
|
||||
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(
|
||||
100, 100, Qt.KeepAspectRatio
|
||||
)
|
||||
|
||||
logolabel = QLabel()
|
||||
logolabel.setPixmap(logopixmap)
|
||||
|
@ -293,7 +314,9 @@ class Planet(QMainWindow):
|
|||
layout = QVBoxLayout()
|
||||
|
||||
self.features = dict()
|
||||
default_features = launcher.get_features_dict(f"/home/{USER}/.planet-launcher/minecraft.AppImage")
|
||||
default_features = launcher.get_features_dict(
|
||||
f"/home/{USER}/.planet-launcher/minecraft.AppImage"
|
||||
)
|
||||
|
||||
for feature in default_features:
|
||||
checkbox = QCheckBox(feature)
|
||||
|
@ -337,7 +360,9 @@ class Planet(QMainWindow):
|
|||
with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers:
|
||||
self.serversedit.setPlainText(servers.read())
|
||||
|
||||
infolabel = QLabel("Servers are stored in the format of <font color=\"gold\">IP: </font><font color=\"blue\">Port</font>")
|
||||
infolabel = QLabel(
|
||||
'Servers are stored in the format of <font color="gold">IP: </font><font color="blue">Port</font>'
|
||||
)
|
||||
|
||||
layout.addWidget(self.serversedit, 0, 0)
|
||||
layout.addWidget(infolabel, 6, 0)
|
||||
|
@ -375,11 +400,7 @@ class Planet(QMainWindow):
|
|||
|
||||
def changelog_tab(self):
|
||||
web = QWebView()
|
||||
web.load(
|
||||
QUrl().fromLocalFile(
|
||||
f"{absolute_path}/assets/changelog.html"
|
||||
)
|
||||
)
|
||||
web.load(QUrl().fromLocalFile(f"{absolute_path}/assets/changelog.html"))
|
||||
|
||||
return web
|
||||
|
||||
|
@ -411,9 +432,12 @@ class Planet(QMainWindow):
|
|||
self.env, self.distancebox.currentText()
|
||||
)
|
||||
|
||||
print(self.env)
|
||||
if self.showlauncher.isChecked() == True:
|
||||
self.hide()
|
||||
launcher.run(
|
||||
self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage"
|
||||
).wait()
|
||||
else:
|
||||
launcher.run(self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage")
|
||||
self.show()
|
||||
|
||||
|
@ -425,25 +449,23 @@ if __name__ == "__main__":
|
|||
app = QApplication(sys.argv)
|
||||
app.setPalette(qdarktheme.load_palette("dark"))
|
||||
|
||||
|
||||
|
||||
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
|
||||
pluto = ConfigPluto()
|
||||
pluto.show()
|
||||
pluto.exec()
|
||||
if pluto.filename[0] == '':
|
||||
if pluto.filename[0] == "":
|
||||
sys.exit(-1)
|
||||
elif pluto.filename[0] == False:
|
||||
print("Using /usr/bin as an executable.")
|
||||
else:
|
||||
with open(pluto.filename[0], "rb") as appimage:
|
||||
with open(f"/home/{USER}/.planet-launcher/minecraft.AppImage", "wb") as out:
|
||||
with open(
|
||||
f"/home/{USER}/.planet-launcher/minecraft.AppImage", "wb"
|
||||
) as out:
|
||||
out.write(appimage.read())
|
||||
os.chmod(f"/home/{USER}/.planet-launcher/minecraft.AppImage", 0o777)
|
||||
|
||||
|
||||
window = Planet()
|
||||
window.show()
|
||||
|
||||
|
||||
app.exec()
|
||||
|
|
Loading…
Reference in a new issue