Fix not responding error
This commit is contained in:
parent
de26e4a87e
commit
c908617c7e
|
@ -4,8 +4,7 @@ import os
|
||||||
|
|
||||||
def get_features_list(path_: str) -> list:
|
def get_features_list(path_: str) -> list:
|
||||||
features = subprocess.run(
|
features = subprocess.run(
|
||||||
[path_, "--print-available-feature-flags"],
|
[path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
features = features.split("\n")
|
features = features.split("\n")
|
||||||
returnlist = list()
|
returnlist = list()
|
||||||
|
@ -21,8 +20,7 @@ def get_features_list(path_: str) -> list:
|
||||||
|
|
||||||
def get_features_dict(path_: str) -> dict:
|
def get_features_dict(path_: str) -> dict:
|
||||||
features = subprocess.run(
|
features = subprocess.run(
|
||||||
[path_, "--print-available-feature-flags"],
|
[path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
features = features.split("\n")
|
features = features.split("\n")
|
||||||
returndict = dict()
|
returndict = dict()
|
||||||
|
@ -64,7 +62,5 @@ def set_options(env, options: dict):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def run(env, path_: str):
|
def run(env, path_: str):
|
||||||
return subprocess.Popen(
|
return subprocess.Popen([path_], env=env, preexec_fn=os.setsid)
|
||||||
[path_], env=env, preexec_fn=os.setsid
|
|
||||||
).wait()
|
|
||||||
|
|
164
planet/main.py
164
planet/main.py
|
@ -64,107 +64,124 @@ if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
||||||
# 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
|
||||||
|
|
||||||
|
|
||||||
class ConfigPluto(QDialog):
|
class ConfigPluto(QDialog):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowFlag(Qt.FramelessWindowHint)
|
self.setWindowFlag(Qt.FramelessWindowHint)
|
||||||
|
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
titlelayout = QGridLayout()
|
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")
|
namelabel = QLabel("Pluto Wizard")
|
||||||
|
|
||||||
logolabel = QLabel()
|
logolabel = QLabel()
|
||||||
logolabel.setPixmap(logopixmap)
|
logolabel.setPixmap(logopixmap)
|
||||||
logolabel.setAlignment(Qt.AlignRight)
|
logolabel.setAlignment(Qt.AlignRight)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
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 = QPushButton("Select executable")
|
||||||
self.executable_btn.clicked.connect(self.get_appimage)
|
self.executable_btn.clicked.connect(self.get_appimage)
|
||||||
|
|
||||||
self.premade_btn = QPushButton("Link /usr/bin/minecraft-pi-reborn-client")
|
self.premade_btn = QPushButton("Link /usr/bin/minecraft-pi-reborn-client")
|
||||||
self.premade_btn.clicked.connect(self.link_appimage)
|
self.premade_btn.clicked.connect(self.link_appimage)
|
||||||
|
|
||||||
layout.addWidget(titlewidget)
|
layout.addWidget(titlewidget)
|
||||||
layout.addWidget(info_label)
|
layout.addWidget(info_label)
|
||||||
layout.addWidget(self.executable_btn)
|
layout.addWidget(self.executable_btn)
|
||||||
layout.addWidget(self.premade_btn)
|
layout.addWidget(self.premade_btn)
|
||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() == Qt.LeftButton:
|
||||||
self.moveFlag = True
|
self.moveFlag = True
|
||||||
self.movePosition = event.globalPos() - self.pos()
|
self.movePosition = event.globalPos() - self.pos()
|
||||||
self.setCursor(QCursor(Qt.OpenHandCursor))
|
self.setCursor(QCursor(Qt.OpenHandCursor))
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
if Qt.LeftButton and self.moveFlag:
|
if Qt.LeftButton and self.moveFlag:
|
||||||
self.move(event.globalPos() - self.movePosition)
|
self.move(event.globalPos() - self.movePosition)
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
self.moveFlag = False
|
self.moveFlag = False
|
||||||
self.setCursor(Qt.ArrowCursor)
|
self.setCursor(Qt.ArrowCursor)
|
||||||
|
|
||||||
def get_appimage(self):
|
def get_appimage(self):
|
||||||
self.hide()
|
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):
|
def link_appimage(self):
|
||||||
self.hide()
|
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 = list()
|
||||||
self.filename.append(False)
|
self.filename.append(False)
|
||||||
|
|
||||||
|
|
||||||
class Planet(QMainWindow):
|
class Planet(QMainWindow):
|
||||||
|
|
||||||
launchfeatures = dict()
|
launchfeatures = dict()
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
RPC = pypresence.Presence(787496148763541505)
|
RPC = pypresence.Presence(787496148763541505)
|
||||||
try:
|
try:
|
||||||
RPC = pypresence.Presence(787496148763541505)
|
RPC = pypresence.Presence(787496148763541505)
|
||||||
RPC.connect()
|
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:
|
except:
|
||||||
print("Unable to initalize Discord RPC. Skipping.")
|
print("Unable to initalize Discord RPC. Skipping.")
|
||||||
|
|
||||||
if not os.path.exists(f"/home/{USER}/.planet-launcher/config.json"):
|
if not os.path.exists(f"/home/{USER}/.planet-launcher/config.json"):
|
||||||
|
|
||||||
self.conf = {
|
self.conf = {
|
||||||
"username": "StevePi",
|
"username": "StevePi",
|
||||||
"options": launcher.get_features_dict(f"/home/{USER}/.planet-launcher/minecraft.AppImage"),
|
"options": launcher.get_features_dict(
|
||||||
"hidelauncher": True,
|
f"/home/{USER}/.planet-launcher/minecraft.AppImage"
|
||||||
"profile": "Modded MCPE",
|
),
|
||||||
"render_distance": "Short",
|
"hidelauncher": True,
|
||||||
"theme": "QDarkTheme Light",
|
"profile": "Modded MCPE",
|
||||||
"discord_rpc": True,
|
"render_distance": "Short",
|
||||||
|
"theme": "QDarkTheme Light",
|
||||||
|
"discord_rpc": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
|
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
|
||||||
file.write(json.dumps(self.conf))
|
file.write(json.dumps(self.conf))
|
||||||
else:
|
else:
|
||||||
with open(f"/home/{USER}/.planet-launcher/config.json") as file:
|
with open(f"/home/{USER}/.planet-launcher/config.json") as file:
|
||||||
self.conf = json.loads(file.read())
|
self.conf = json.loads(file.read())
|
||||||
|
|
||||||
|
|
||||||
self.setWindowTitle("Planet")
|
self.setWindowTitle("Planet")
|
||||||
|
|
||||||
|
@ -178,27 +195,29 @@ class Planet(QMainWindow):
|
||||||
tabs.setTabIcon(play_tab, QIcon(f"{absolute_path}/assets/logo512.png"))
|
tabs.setTabIcon(play_tab, QIcon(f"{absolute_path}/assets/logo512.png"))
|
||||||
features_tab = tabs.addTab(self.features_tab(), "Features")
|
features_tab = tabs.addTab(self.features_tab(), "Features")
|
||||||
tabs.setTabIcon(features_tab, QIcon(f"{absolute_path}/assets/heart512.png"))
|
tabs.setTabIcon(features_tab, QIcon(f"{absolute_path}/assets/heart512.png"))
|
||||||
servers_tab = tabs.addTab(self.servers_tab(), "Servers")
|
servers_tab = tabs.addTab(self.servers_tab(), "Servers")
|
||||||
tabs.setTabIcon(servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png"))
|
tabs.setTabIcon(
|
||||||
#mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
|
servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png")
|
||||||
#tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.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")
|
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
|
||||||
tabs.setTabIcon(changelog_tab, QIcon(f"{absolute_path}/assets/pi512.png"))
|
tabs.setTabIcon(changelog_tab, QIcon(f"{absolute_path}/assets/pi512.png"))
|
||||||
|
|
||||||
self.setCentralWidget(tabs)
|
self.setCentralWidget(tabs)
|
||||||
|
|
||||||
self.setGeometry(600, 900, 200, 200)
|
self.setGeometry(600, 900, 200, 200)
|
||||||
|
|
||||||
self.usernameedit.setText(self.conf["username"])
|
self.usernameedit.setText(self.conf["username"])
|
||||||
self.profilebox.setCurrentText(self.conf["profile"])
|
self.profilebox.setCurrentText(self.conf["profile"])
|
||||||
self.distancebox.setCurrentText(self.conf["render_distance"])
|
self.distancebox.setCurrentText(self.conf["render_distance"])
|
||||||
|
|
||||||
for feature in self.features:
|
for feature in self.features:
|
||||||
if self.conf["options"][feature]:
|
if self.conf["options"][feature]:
|
||||||
self.features[feature].setCheckState(Qt.Checked)
|
self.features[feature].setCheckState(Qt.Checked)
|
||||||
else:
|
else:
|
||||||
self.features[feature].setCheckState(Qt.Unchecked)
|
self.features[feature].setCheckState(Qt.Unchecked)
|
||||||
|
|
||||||
self.showlauncher.setChecked(self.conf["hidelauncher"])
|
self.showlauncher.setChecked(self.conf["hidelauncher"])
|
||||||
|
|
||||||
self.set_features()
|
self.set_features()
|
||||||
|
@ -208,7 +227,9 @@ class Planet(QMainWindow):
|
||||||
|
|
||||||
titlelayout = QGridLayout()
|
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 = QLabel()
|
||||||
logolabel.setPixmap(logopixmap)
|
logolabel.setPixmap(logopixmap)
|
||||||
|
@ -293,7 +314,9 @@ class Planet(QMainWindow):
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
self.features = dict()
|
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:
|
for feature in default_features:
|
||||||
checkbox = QCheckBox(feature)
|
checkbox = QCheckBox(feature)
|
||||||
|
@ -326,7 +349,7 @@ class Planet(QMainWindow):
|
||||||
widget.setLayout(fakelayout)
|
widget.setLayout(fakelayout)
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
|
|
||||||
def servers_tab(self) -> QWidget:
|
def servers_tab(self) -> QWidget:
|
||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
|
@ -337,10 +360,12 @@ class Planet(QMainWindow):
|
||||||
with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers:
|
with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers:
|
||||||
self.serversedit.setPlainText(servers.read())
|
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(self.serversedit, 0, 0)
|
||||||
layout.addWidget(infolabel, 6, 0)
|
layout.addWidget(infolabel, 6, 0)
|
||||||
|
|
||||||
widget.setLayout(layout)
|
widget.setLayout(layout)
|
||||||
return widget
|
return widget
|
||||||
|
@ -375,11 +400,7 @@ class Planet(QMainWindow):
|
||||||
|
|
||||||
def changelog_tab(self):
|
def changelog_tab(self):
|
||||||
web = QWebView()
|
web = QWebView()
|
||||||
web.load(
|
web.load(QUrl().fromLocalFile(f"{absolute_path}/assets/changelog.html"))
|
||||||
QUrl().fromLocalFile(
|
|
||||||
f"{absolute_path}/assets/changelog.html"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return web
|
return web
|
||||||
|
|
||||||
|
@ -389,18 +410,18 @@ class Planet(QMainWindow):
|
||||||
self.launchfeatures[feature] = True
|
self.launchfeatures[feature] = True
|
||||||
else:
|
else:
|
||||||
self.launchfeatures[feature] = False
|
self.launchfeatures[feature] = False
|
||||||
|
|
||||||
def save_profile(self):
|
def save_profile(self):
|
||||||
self.conf["username"] = self.usernameedit.text()
|
self.conf["username"] = self.usernameedit.text()
|
||||||
self.conf["options"] = self.launchfeatures
|
self.conf["options"] = self.launchfeatures
|
||||||
self.conf["render_distance"] = self.distancebox.currentText()
|
self.conf["render_distance"] = self.distancebox.currentText()
|
||||||
self.conf["hidelauncher"] = self.showlauncher.isChecked()
|
self.conf["hidelauncher"] = self.showlauncher.isChecked()
|
||||||
|
|
||||||
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
|
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
|
||||||
file.write(json.dumps(self.conf))
|
file.write(json.dumps(self.conf))
|
||||||
|
|
||||||
def save_servers(self):
|
def save_servers(self):
|
||||||
with open(f"/home/{USER}/.minecraft-pi/servers.txt", "w") as file:
|
with open(f"/home/{USER}/.minecraft-pi/servers.txt", "w") as file:
|
||||||
file.write(self.serversedit.toPlainText())
|
file.write(self.serversedit.toPlainText())
|
||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
|
@ -411,39 +432,40 @@ class Planet(QMainWindow):
|
||||||
self.env, self.distancebox.currentText()
|
self.env, self.distancebox.currentText()
|
||||||
)
|
)
|
||||||
|
|
||||||
print(self.env)
|
|
||||||
if self.showlauncher.isChecked() == True:
|
if self.showlauncher.isChecked() == True:
|
||||||
self.hide()
|
self.hide()
|
||||||
launcher.run(self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage")
|
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()
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
apppath = str()
|
apppath = str()
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setPalette(qdarktheme.load_palette("dark"))
|
app.setPalette(qdarktheme.load_palette("dark"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
|
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
|
||||||
pluto = ConfigPluto()
|
pluto = ConfigPluto()
|
||||||
pluto.show()
|
pluto.show()
|
||||||
pluto.exec()
|
pluto.exec()
|
||||||
if pluto.filename[0] == '':
|
if pluto.filename[0] == "":
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
elif pluto.filename[0] == False:
|
elif pluto.filename[0] == False:
|
||||||
print("Using /usr/bin as an executable.")
|
print("Using /usr/bin as an executable.")
|
||||||
else:
|
else:
|
||||||
with open(pluto.filename[0], "rb") as appimage:
|
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())
|
out.write(appimage.read())
|
||||||
os.chmod(f"/home/{USER}/.planet-launcher/minecraft.AppImage", 0o777)
|
os.chmod(f"/home/{USER}/.planet-launcher/minecraft.AppImage", 0o777)
|
||||||
|
|
||||||
|
|
||||||
window = Planet()
|
window = Planet()
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
|
|
||||||
app.exec()
|
app.exec()
|
||||||
|
|
Loading…
Reference in New Issue