mirror of
https://github.com/xgui4/LCE-Qt-Launcher.git
synced 2026-07-16 02:40:38 +00:00
start the logic of the launcher
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -290,3 +290,5 @@ tmp/
|
||||
/out/
|
||||
rc_res.py
|
||||
ui_form.py
|
||||
|
||||
MinecraftLCEClient/
|
||||
|
||||
16
config.py
16
config.py
@@ -8,6 +8,14 @@ class Config (QSettings):
|
||||
super().setValue("instances/repo", url_str)
|
||||
super().sync()
|
||||
|
||||
def set_instance_exe_name(self, filename : str):
|
||||
super().setValue("instances/filename", filename)
|
||||
super().sync()
|
||||
|
||||
def set_instance_archive(self, archive : str):
|
||||
super().setValue("instances/archive", archive)
|
||||
super().sync()
|
||||
|
||||
def set_instance_name(self, name : str):
|
||||
super().setValue("instances/name", name)
|
||||
super().sync()
|
||||
@@ -29,6 +37,12 @@ class Config (QSettings):
|
||||
|
||||
def get_instance_name(self) -> str:
|
||||
return self.value("instances/name", "default")
|
||||
|
||||
def get_instance_exe_name(self) -> str:
|
||||
return self.value("instances/filename", "Minecraft.Client.exe")
|
||||
|
||||
def get_instance_archive(self) -> str:
|
||||
return self.value("instances/archive", "LCEWindows64.zip")
|
||||
|
||||
def get_instance_version(self) -> str:
|
||||
return self.value("instances/version", "default")
|
||||
@@ -42,6 +56,8 @@ class Config (QSettings):
|
||||
def generate_default_config(self):
|
||||
self.set_instance_url("https://github.com/smartcmd/MinecraftConsoles")
|
||||
self.set_instance_name("default")
|
||||
self.set_instance_exe_name("Minecraft.Client.exe")
|
||||
self.set_instance_archive("LCEWindows64.zip")
|
||||
self.set_instance_version("nightly")
|
||||
self.set_profile_skin("default")
|
||||
self.set_profile_name("Steve")
|
||||
|
||||
67
launcher.py
67
launcher.py
@@ -1,4 +1,5 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow
|
||||
@@ -7,13 +8,70 @@ from PySide6.QtGui import QPalette, QPixmap, QBrush
|
||||
from config import Config
|
||||
|
||||
import webbrowser
|
||||
import requests
|
||||
import zipfile
|
||||
import io
|
||||
import os
|
||||
|
||||
config = Config()
|
||||
|
||||
LAUNCHER_REPO = "https://github.com/xgui4/LCE_QT_Launcher"
|
||||
|
||||
LAUNCHER_STRING = config.get__instance_url() + \
|
||||
"/releases/download/" + \
|
||||
config.get_instance_version() + "/" + \
|
||||
config.get_instance_archive()
|
||||
|
||||
SUCCESS_STATUS_CODE = 200
|
||||
|
||||
BACKGROUND_PIXMAP_IMG = ":/assets/assets/background.png"
|
||||
|
||||
GEN_CONFIG_CMD_ARG = "--gen-config"
|
||||
GEN_CONFIG_CMD_ARG_SHORT = "-g"
|
||||
|
||||
VERSION_CMD_ARG = "--version"
|
||||
VERSION_CMD_ARG_SHORT = "-v"
|
||||
|
||||
LICENSE_CMD_ARG = "--license"
|
||||
LICENSE_CMD_ARG_SHORT = "-L"
|
||||
|
||||
ABOUT_CMD_ARG = "--about"
|
||||
ABOUT_CMD_ARG_SHORT = "-a"
|
||||
|
||||
HELP_CMD_ARG = "--help"
|
||||
HELP_CMD_ARG_SHORT = "-h"
|
||||
|
||||
VERSION = "0.0.0.1-pre-alpha"
|
||||
DESCRIPTION = """
|
||||
This is a custom MCLCE Launcher written in python and Qt with Freedom
|
||||
and GNU/Linux support in mind.
|
||||
"""
|
||||
|
||||
def launch():
|
||||
config = Config()
|
||||
print(f"Lauching {config.get_instance_name()} {config.get_instance_version()}")
|
||||
|
||||
print(f"Downloading {LAUNCHER_STRING}.")
|
||||
|
||||
response = requests.get(LAUNCHER_STRING)
|
||||
|
||||
if response.status_code == SUCCESS_STATUS_CODE:
|
||||
try:
|
||||
with zipfile.ZipFile(io.BytesIO(response.content)) as archive:
|
||||
archive.extractall("./MinecraftLCEClient")
|
||||
except zipfile.BadZipFile as err:
|
||||
print(f"Error : {err}")
|
||||
except zipfile.zipfile.LargeZipFile as err:
|
||||
print(f"Error : {err}")
|
||||
else:
|
||||
client = f"./MinecraftLCEClient/{config.get_instance_exe_name}"
|
||||
print(f"Launching {client}")
|
||||
os.system(client)
|
||||
else:
|
||||
print(f"Error : {response.status_code} during the dowbloading of the Minecraft LCE Client")
|
||||
|
||||
def update_page():
|
||||
webbrowser.open_new_tab("https://github.com/xgui4/LCE_QT_Launcher")
|
||||
webbrowser.open_new_tab(LAUNCHER_REPO)
|
||||
|
||||
# Important:
|
||||
# You need to run the following command to generate the ui_form.py file
|
||||
@@ -25,7 +83,7 @@ class launcher(QMainWindow):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
background_pixmap = QPixmap(":/assets/assets/background.png")
|
||||
background_pixmap = QPixmap(BACKGROUND_PIXMAP_IMG)
|
||||
if not background_pixmap.isNull():
|
||||
palette = self.palette()
|
||||
palette.setBrush(QPalette.ColorRole.Window, QBrush(background_pixmap))
|
||||
@@ -42,10 +100,9 @@ class launcher(QMainWindow):
|
||||
|
||||
self.ui.actionAbout.triggered.connect(self.createPopupMenu)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == "--gen-config":
|
||||
if sys.argv[1] == GEN_CONFIG_CMD_ARG:
|
||||
config = Config()
|
||||
config.generate_default_config()
|
||||
else:
|
||||
|
||||
10
pkg/LCE-Qt-Launcher.desktop
Normal file
10
pkg/LCE-Qt-Launcher.desktop
Normal file
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Version=2.0
|
||||
Type=Application
|
||||
Name=LCE Qt Launcher
|
||||
Comment=This is a custom MCLCE Launcher written in python and Qt with Freedom and GNU/Linux support in mind.
|
||||
Exec=/usr/bin/python3 ./laucher.py
|
||||
Icon=Launcher.png
|
||||
Terminal=True
|
||||
StartupNotify=true
|
||||
Categories=Utility;Minecraft;Launcher;Qt;Games;Python
|
||||
@@ -1,15 +1,16 @@
|
||||
[project]
|
||||
[project]
|
||||
name = "LCE-Qt-Launcher"
|
||||
|
||||
[tool.pyside6-project]
|
||||
files = [
|
||||
"config.py",
|
||||
"config.py",
|
||||
"form.ui",
|
||||
"launcher.py",
|
||||
"license.md",
|
||||
"readme.md",
|
||||
"requirements.txt",
|
||||
"res.qrc",
|
||||
"setup.bat",
|
||||
"setup.sh"
|
||||
"launcher.py",
|
||||
"license.md",
|
||||
"pkg/LCE-Qt-Launcher.desktop",
|
||||
"readme.md",
|
||||
"requirements.txt",
|
||||
"res.qrc",
|
||||
"setup.bat",
|
||||
"setup.sh",
|
||||
]
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
## About
|
||||
|
||||
This is a upcoming MCLCE Launcher written in python and Qt with Freedom
|
||||
and GNU/Linux support in mind.
|
||||
This is a custom MCLCE Launcher written in python and Qt with Freedom and GNU/Linux support in mind.
|
||||
|
||||
## License
|
||||
[GPLV3](license.md)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PySide6
|
||||
requests
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
pyside6-uic form.ui -o ui_form.py
|
||||
|
||||
python -m pip install -r requirement.txt
|
||||
|
||||
Reference in New Issue
Block a user