diff --git a/.gitignore b/.gitignore index b6fd254..49a16c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ **/__pycache__ __pycache__ *.pyc +**/build +*.deb +build diff --git a/planet/assets/planet-launcher.desktop b/planet/assets/planet-launcher.desktop new file mode 100644 index 0000000..e80c84c --- /dev/null +++ b/planet/assets/planet-launcher.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Planet Launcher +Exec=/usr/bin/planet-launcher +Icon=/usr/lib/planet-launcher/assets/logo512.png +Type=Application +Comment=A better launcher +GenericName=Minecraft Pi Launcher +Categories=games, minecraft +Keywords=Minecraft, MCPIL, gMCPIL, jMCPIL, Minecraft Pi, Minecraft launcher, MCPI, MCPI-Revival, mcpiscript diff --git a/planet/main.py b/planet/main.py index 6e24838..596466b 100644 --- a/planet/main.py +++ b/planet/main.py @@ -1,3 +1,4 @@ +#!/usr/bin/python3 """ @@ -22,14 +23,24 @@ with this program; if not, write to the Free Software Foundation, Inc., import sys -import launcher -from splashes import SPLASHES import os import random from datetime import date import json import pathlib +absolute_path = pathlib.Path(__file__).parent.absolute() + +if str(absolute_path).startswith("/usr/bin"): + absolute_path = "/usr/lib/planet-launcher/" + +sys.path.append(absolute_path) +if os.path.exists("/usr/lib/planet-launcher/"): + sys.path.append("/usr/lib/planet-launcher/") + +import launcher +from splashes import SPLASHES + from PyQt5.QtCore import * from PyQt5.QtWidgets import * @@ -40,7 +51,6 @@ from PyQt5.QtWebKitWidgets import * import qdarktheme import pypresence - dark_stylesheet = qdarktheme.load_stylesheet() USER = os.getenv("USER") @@ -62,7 +72,7 @@ class ConfigPluto(QDialog): layout = QVBoxLayout() titlelayout = QGridLayout() - logopixmap = QPixmap(f"{pathlib.Path(__file__).parent.absolute()}/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() @@ -158,22 +168,22 @@ class Planet(QMainWindow): self.setWindowTitle("Planet") - self.setWindowIcon(QIcon(f"{pathlib.Path(__file__).parent.absolute()}/assets/logo512.png")) + self.setWindowIcon(QIcon(f"{absolute_path}/assets/logo512.png")) tabs = QTabWidget() tabs.setTabPosition(QTabWidget.West) tabs.setMovable(True) play_tab = tabs.addTab(self.play_tab(), "Play") - tabs.setTabIcon(play_tab, QIcon(f"{pathlib.Path(__file__).parent.absolute()}/assets/logo512.png")) + tabs.setTabIcon(play_tab, QIcon(f"{absolute_path}/assets/logo512.png")) features_tab = tabs.addTab(self.features_tab(), "Features") - tabs.setTabIcon(features_tab, QIcon(f"{pathlib.Path(__file__).parent.absolute()}/assets/heart512.png")) + 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"{pathlib.Path(__file__).parent.absolute()}/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"{pathlib.Path(__file__).parent.absolute()}/assets/portal512.png")) + #tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png")) changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog") - tabs.setTabIcon(changelog_tab, QIcon(f"{pathlib.Path(__file__).parent.absolute()}/assets/pi512.png")) + tabs.setTabIcon(changelog_tab, QIcon(f"{absolute_path}/assets/pi512.png")) self.setCentralWidget(tabs) @@ -198,7 +208,7 @@ class Planet(QMainWindow): titlelayout = QGridLayout() - logopixmap = QPixmap(f"{pathlib.Path(__file__).parent.absolute()}/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) @@ -367,7 +377,7 @@ class Planet(QMainWindow): web = QWebView() web.load( QUrl().fromLocalFile( - f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html" + f"{absolute_path}/assets/changelog.html" ) ) diff --git a/scripts/control b/scripts/control new file mode 100755 index 0000000..6211c8d --- /dev/null +++ b/scripts/control @@ -0,0 +1,12 @@ +Package: planet-launcher +Version: 1.0rc2 +Architecture: all +Maintainer: mcpiscript +Depends: python3-pyqt5, python3:any +Recommends: minecraft-pi-reborn-client, minecraft-pi-reborn-server, python3-pyqtdarkmode, python3-mcpi, python3-minecraft-pi, python3-morpheus-mcpi +Section: games +Priority: optional +Homepage: https://github.com/mcpiscript/Planet +Description: A better launcher for Minecraft: Pi Edition + A better launcher. + This launcher requires you to download an AppImage file from the official Jenkins. diff --git a/scripts/debian.sh b/scripts/debian.sh new file mode 100755 index 0000000..65b8270 --- /dev/null +++ b/scripts/debian.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +rm -r planet/__pycache__ + +mkdir build +mkdir build/planet +mkdir build/planet/usr +mkdir build/planet/usr/lib + +cp -r ./planet/ ./build/planet/usr/lib/planet-launcher + +mkdir build/planet/DEBIAN +cp ./scripts/control ./build/planet/DEBIAN/control +cp ./scripts/postinst ./build/planet/DEBIAN/postinst +cp ./scripts/postrm ./build/planet/DEBIAN/postrm + +dpkg-deb --build ./build/planet +mkdir dist +cp ./build/planet.deb ./dist/planet.deb +rm -r build diff --git a/scripts/postinst b/scripts/postinst new file mode 100755 index 0000000..7533034 --- /dev/null +++ b/scripts/postinst @@ -0,0 +1,4 @@ +pip3 install pyqtdarktheme pypresence +link /usr/lib/planet-launcher/main.py /usr/bin/planet-launcher +chmod 755 /usr/lib/planet-launcher/main.py +link /usr/lib/planet-launcher/assets/planet-launcher.desktop /usr/share/applications/planet-launcher.desktop diff --git a/scripts/postrm b/scripts/postrm new file mode 100755 index 0000000..63220c7 --- /dev/null +++ b/scripts/postrm @@ -0,0 +1,2 @@ +rm -rf /usr/bin/planet-launcher +rm -rf /usr/share/applications/planet-launcher.desktop