2022-03-02 01:39:02 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2022 Alexey Pavlov
|
2022-03-03 02:13:28 +00:00
|
|
|
Copyright (C) 2022 Red-Exe-Engineer
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import sys
|
2022-03-03 00:55:02 +00:00
|
|
|
import launcher
|
2022-03-04 01:09:31 +00:00
|
|
|
from splashes import SPLASHES
|
2022-03-03 02:13:28 +00:00
|
|
|
import os
|
2022-03-04 01:09:31 +00:00
|
|
|
import random
|
|
|
|
from datetime import date
|
|
|
|
import json
|
2022-03-12 01:01:30 +00:00
|
|
|
import pathlib
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-02 01:39:02 +00:00
|
|
|
from PyQt5.QtCore import *
|
|
|
|
from PyQt5.QtWidgets import *
|
|
|
|
from PyQt5.QtGui import *
|
2022-03-12 01:01:30 +00:00
|
|
|
from PyQt5.QtWebKit import *
|
|
|
|
from PyQt5.QtWebKitWidgets import *
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-12 01:01:30 +00:00
|
|
|
import qdarktheme
|
2022-03-10 00:31:14 +00:00
|
|
|
|
|
|
|
|
2022-03-12 01:10:07 +00:00
|
|
|
dark_stylesheet = qdarktheme.load_stylesheet()
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
USER = os.getenv("USER")
|
2022-03-03 02:13:28 +00:00
|
|
|
|
|
|
|
if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
|
|
|
|
os.makedirs(f"/home/{USER}/.planet-launcher/mods")
|
|
|
|
|
2022-03-12 01:14:27 +00:00
|
|
|
# if os.path.exists(f"/home/{USER}/.gmcpil.json"):
|
2022-03-10 01:17:29 +00:00
|
|
|
# with open(f"/home/{USER}/.gmcpil.json") as f:
|
|
|
|
# DEFAULT_FEATURES = json.loads(f.read())["features"]
|
2022-03-12 01:14:27 +00:00
|
|
|
# else:
|
|
|
|
# TODO: Add a tab with a button to import features from gMCPIL
|
2022-03-10 01:17:29 +00:00
|
|
|
DEFAULT_FEATURES = launcher.get_features_dict()
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
class Planet(QMainWindow):
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
launchfeatures = dict()
|
|
|
|
env = os.environ.copy()
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-02 01:39:02 +00:00
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
self.setWindowTitle("Planet")
|
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
self.setWindowIcon(QIcon("assets/logo512.png"))
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
tabs = QTabWidget()
|
|
|
|
tabs.setTabPosition(QTabWidget.West)
|
|
|
|
tabs.setMovable(True)
|
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
play_tab = tabs.addTab(self.play_tab(), "Play")
|
2022-03-12 01:14:27 +00:00
|
|
|
tabs.setTabIcon(play_tab, QIcon("assets/logo512.png"))
|
2022-03-10 00:31:14 +00:00
|
|
|
features_tab = tabs.addTab(self.features_tab(), "Features")
|
2022-03-12 01:14:27 +00:00
|
|
|
tabs.setTabIcon(features_tab, QIcon("assets/heart512.png"))
|
2022-03-10 00:31:14 +00:00
|
|
|
mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
|
2022-03-12 01:14:27 +00:00
|
|
|
tabs.setTabIcon(mods_tab, QIcon("assets/portal512.png"))
|
2022-03-12 01:01:30 +00:00
|
|
|
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
|
2022-03-12 01:14:27 +00:00
|
|
|
tabs.setTabIcon(changelog_tab, QIcon("assets/pi512.png"))
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
self.setCentralWidget(tabs)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
self.setGeometry(600, 800, 200, 200)
|
|
|
|
|
|
|
|
self.set_features()
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
def play_tab(self) -> QWidget:
|
|
|
|
layout = QGridLayout()
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
titlelayout = QGridLayout()
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
logopixmap = QPixmap("assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio)
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
logolabel = QLabel()
|
|
|
|
logolabel.setPixmap(logopixmap)
|
|
|
|
logolabel.setAlignment(Qt.AlignRight)
|
|
|
|
|
|
|
|
namelabel = QLabel()
|
|
|
|
|
2022-03-12 01:14:27 +00:00
|
|
|
if date.today().month == 4 and date.today().day == 1:
|
2022-03-04 01:09:31 +00:00
|
|
|
namelabel.setText("Banana Launcher")
|
|
|
|
else:
|
2022-03-12 01:14:27 +00:00
|
|
|
if random.randint(1, 100) == 1:
|
2022-03-04 01:09:31 +00:00
|
|
|
namelabel.setText("Pluto Launcher")
|
|
|
|
else:
|
2022-03-12 01:14:27 +00:00
|
|
|
namelabel.setText("Planet Launcher")
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-02 01:39:02 +00:00
|
|
|
font = namelabel.font()
|
|
|
|
font.setPointSize(30)
|
|
|
|
namelabel.setFont(font)
|
2022-03-10 00:31:14 +00:00
|
|
|
namelabel.setAlignment(Qt.AlignLeft)
|
|
|
|
|
2022-03-12 01:14:27 +00:00
|
|
|
splashlabel = QLabel(f'<font color="gold">{random.choice(SPLASHES)}</font>')
|
2022-03-04 01:09:31 +00:00
|
|
|
splashlabel.adjustSize()
|
|
|
|
splashlabel.setAlignment(Qt.AlignHCenter)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
usernamelabel = QLabel("Username")
|
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
self.usernameedit = QLineEdit()
|
|
|
|
self.usernameedit.setPlaceholderText("StevePi")
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
distancelabel = QLabel("Render Distance")
|
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
self.distancebox = QComboBox()
|
|
|
|
self.distancebox.addItems(["Far", "Normal", "Short", "Tiny"])
|
|
|
|
self.distancebox.setCurrentText("Short")
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
profilelabel = QLabel("Profile")
|
|
|
|
|
|
|
|
self.profilebox = QComboBox()
|
|
|
|
self.profilebox.addItems(
|
|
|
|
["Vanilla MCPi", "Modded MCPi", "Modded MCPE", "Optimized MCPE", "Custom"]
|
|
|
|
)
|
|
|
|
self.profilebox.setCurrentText("Modded MCPE")
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-02 01:39:02 +00:00
|
|
|
self.showlauncher = QRadioButton("Hide Launcher")
|
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
self.playbutton = QPushButton("Play")
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
self.playbutton.setCheckable(True)
|
|
|
|
self.playbutton.clicked.connect(self.launch)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
titlelayout.addWidget(logolabel, 0, 0)
|
|
|
|
titlelayout.addWidget(namelabel, 0, 1)
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-10 00:31:14 +00:00
|
|
|
titlewidget = QWidget()
|
|
|
|
titlewidget.setLayout(titlelayout)
|
2022-03-12 01:14:27 +00:00
|
|
|
|
|
|
|
layout.addWidget(titlewidget, 0, 0, 2, 5)
|
|
|
|
|
|
|
|
layout.addWidget(splashlabel, 2, 0, 1, 6)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
layout.addWidget(usernamelabel, 3, 0)
|
|
|
|
layout.addWidget(self.usernameedit, 3, 4, 1, 2)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
layout.addWidget(distancelabel, 4, 0)
|
|
|
|
layout.addWidget(self.distancebox, 4, 4, 1, 2)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
layout.addWidget(profilelabel, 5, 0)
|
|
|
|
layout.addWidget(self.profilebox, 5, 4, 1, 2)
|
|
|
|
|
|
|
|
layout.addWidget(self.showlauncher, 6, 4, 1, 2)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
layout.addWidget(self.playbutton, 8, 5)
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
widget = QWidget()
|
|
|
|
|
|
|
|
widget.setLayout(layout)
|
|
|
|
|
|
|
|
return widget
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
def features_tab(self) -> QWidget:
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
layout = QVBoxLayout()
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
self.features = dict()
|
|
|
|
|
|
|
|
for feature in DEFAULT_FEATURES:
|
2022-03-03 00:55:02 +00:00
|
|
|
checkbox = QCheckBox(feature)
|
2022-03-04 01:09:31 +00:00
|
|
|
if DEFAULT_FEATURES[feature]:
|
2022-03-03 00:55:02 +00:00
|
|
|
checkbox.setCheckState(Qt.Checked)
|
|
|
|
else:
|
|
|
|
checkbox.setCheckState(Qt.Unchecked)
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
checkbox.clicked.connect(self.set_features)
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-04 01:09:31 +00:00
|
|
|
self.features[feature] = checkbox
|
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
layout.addWidget(checkbox)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
fakewidget = QWidget()
|
|
|
|
fakewidget.setLayout(layout)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
scroll = QScrollArea()
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
|
|
|
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
|
|
scroll.setWidgetResizable(True)
|
|
|
|
scroll.setWidget(fakewidget)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
fakelayout = QGridLayout()
|
2022-03-04 01:09:31 +00:00
|
|
|
fakelayout.addWidget(scroll, 0, 0)
|
2022-03-03 00:55:02 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
widget = QWidget()
|
|
|
|
|
|
|
|
widget.setLayout(fakelayout)
|
|
|
|
|
|
|
|
return widget
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
def custom_mods_tab(self) -> QWidget:
|
|
|
|
layout = QVBoxLayout()
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
for mod in os.listdir(f"/home/{USER}/.planet-launcher/mods/"):
|
|
|
|
checkbox = QCheckBox(mod)
|
|
|
|
checkbox.setCheckState(Qt.Unchecked)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
layout.addWidget(checkbox)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
fakewidget = QWidget()
|
|
|
|
fakewidget.setLayout(layout)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
scroll = QScrollArea()
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
|
|
|
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
|
|
scroll.setWidgetResizable(True)
|
|
|
|
scroll.setWidget(fakewidget)
|
2022-03-04 01:09:31 +00:00
|
|
|
|
2022-03-03 02:13:28 +00:00
|
|
|
fakelayout = QGridLayout()
|
2022-03-04 01:09:31 +00:00
|
|
|
fakelayout.addWidget(scroll, 0, 0)
|
2022-03-03 02:13:28 +00:00
|
|
|
|
2022-03-03 00:55:02 +00:00
|
|
|
widget = QWidget()
|
|
|
|
|
|
|
|
widget.setLayout(fakelayout)
|
|
|
|
|
|
|
|
return widget
|
2022-03-12 01:14:27 +00:00
|
|
|
|
2022-03-12 01:01:30 +00:00
|
|
|
def changelog_tab(self):
|
|
|
|
web = QWebView()
|
2022-03-12 01:14:27 +00:00
|
|
|
web.load(
|
|
|
|
QUrl().fromLocalFile(
|
|
|
|
f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html"
|
|
|
|
)
|
|
|
|
)
|
2022-03-12 01:01:30 +00:00
|
|
|
print(f"{pathlib.Path(__file__).parent.absolute()}/assets/changelog.html")
|
|
|
|
return web
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
def set_features(self):
|
|
|
|
for feature in self.features:
|
|
|
|
if self.features[feature].isChecked():
|
|
|
|
self.launchfeatures[feature] = True
|
|
|
|
else:
|
|
|
|
self.launchfeatures[feature] = False
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
def launch(self):
|
2022-03-12 01:14:27 +00:00
|
|
|
self.env = launcher.set_username(self.env, self.usernameedit.text())
|
|
|
|
self.env = launcher.set_options(self.env, self.launchfeatures)
|
|
|
|
self.env = launcher.set_render_distance(
|
|
|
|
self.env, self.distancebox.currentText()
|
|
|
|
)
|
2022-03-10 00:31:14 +00:00
|
|
|
|
2022-03-05 00:43:14 +00:00
|
|
|
print(self.env)
|
2022-03-12 01:30:19 +00:00
|
|
|
self.hide()
|
2022-03-12 03:58:33 +00:00
|
|
|
if self.showlauncher.isChecked() == True:
|
|
|
|
launcher.run(self.env)
|
2022-03-12 01:30:19 +00:00
|
|
|
self.show()
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app = QApplication(sys.argv)
|
2022-03-12 01:01:30 +00:00
|
|
|
app.setPalette(qdarktheme.load_palette("dark"))
|
2022-03-02 01:39:02 +00:00
|
|
|
|
|
|
|
window = Planet()
|
|
|
|
window.show()
|
|
|
|
|
|
|
|
app.exec()
|