From 049bcc62aacdf27fb8b3188a8fd2f7b89b6674bc Mon Sep 17 00:00:00 2001 From: xgui4 <134389196+xgui4@users.noreply.github.com> Date: Fri, 8 May 2026 22:25:02 -0400 Subject: [PATCH] add default instances to GUI --- res.qrc | 1 - src/form.ui | 421 ++++++++++++++++---------- src/lce_qt_launcher/features.py | 12 +- src/lce_qt_launcher/views/launcher.py | 89 +++++- 4 files changed, 348 insertions(+), 175 deletions(-) diff --git a/res.qrc b/res.qrc index a3d54bf..56a7d53 100644 --- a/res.qrc +++ b/res.qrc @@ -30,7 +30,6 @@ data/defaults_instances/default.lce_inst - data/defaults_instances/legacy_evolved.lce_inst data/defaults_instances/neoLegacy.lce_inst data/defaults_instances/hellishends.lce_inst data/defaults_instances/360Revived.lce_inst diff --git a/src/form.ui b/src/form.ui index 9dbac16..b3d8b2e 100644 --- a/src/form.ui +++ b/src/form.ui @@ -6,10 +6,15 @@ 0 0 - 1268 - 967 + 1044 + 1044 + + + Monocraft + + Minecraft LCE QT Launcher @@ -31,9 +36,9 @@ - Qt::ContextMenuPolicy::ActionsContextMenu + Qt::ActionsContextMenu - + @@ -52,19 +57,19 @@ - Qt::FocusPolicy::NoFocus + Qt::NoFocus - Qt::LayoutDirection::LeftToRight + Qt::LeftToRight false - QTabWidget::TabPosition::North + QTabWidget::North - QTabWidget::TabShape::Rounded + QTabWidget::Rounded 0 @@ -92,9 +97,9 @@ Launcher - + - + 1 @@ -113,71 +118,7 @@ 1 - - - - - true - - - - true - - - - Steam Link : - - - - - - - Play - - - - - - - - - - true - - - - - - Play On Steam - - - - - - - - - - Change Instance Icon - - - - - - - - - - - 14 - true - - - - Default (MCLCE) - Vanilla Client - - - + @@ -195,6 +136,8 @@ + Monocraft + 75 true @@ -203,27 +146,109 @@ - - + + + + true + + + Setting + + + + + + + + + + + 16777215 + 16777215 + + + + + + + :/assets/minecraft_lce_title.png + + + false + + + 0 + + + + + + + true + + + + + + Play On Steam + + + + + + + + false - + Open Instances Editor + + + false + + + false + + + false + + + + + + + Play + + + + + + + + + + Update + + + - + - + + Monocraft 14 + 75 true @@ -242,6 +267,8 @@ + Monocraft + 75 true @@ -264,6 +291,8 @@ + Monocraft + 75 true @@ -286,6 +315,8 @@ + Monocraft + 75 true @@ -311,6 +342,8 @@ + Monocraft + 75 true @@ -339,6 +372,8 @@ + Monocraft + 75 true @@ -393,6 +428,8 @@ + Monocraft + 75 true @@ -414,26 +451,28 @@ - - - - Update + + + + + Monocraft + 14 + 75 + true + - - + + Default (MCLCE) - Vanilla Client - - - - true - + + - Setting + Change Instance Icon - + @@ -451,34 +490,39 @@ The percentage of the installation - - install progress bar - 0 + + install progress bar + - - - - - 16777215 - 16777215 - + + + + true + + + + Monocraft + 75 + true + + + + Steam Link : + + + + + + + false - - :/assets/minecraft_lce_title.png - - - false - - - 0 - @@ -496,26 +540,7 @@ :/assets/minecraft.png - Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - - - - - - - false - - - Open Instances Editor - - - false - - - false - - - false + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -532,20 +557,22 @@ Instances - + + Monocraft 24 + 75 true false - QFrame::Shape::NoFrame + QFrame::NoFrame @@ -554,13 +581,10 @@ - QListView::ResizeMode::Fixed + QListView::Fixed - Qt::AlignmentFlag::AlignCenter - - - Qt::DropAction::ActionMask + Qt::AlignCenter @@ -576,14 +600,14 @@ Workshop - + - - + + https://lce-hub.github.io/piston/ @@ -604,10 +628,10 @@ News - + - - + + https://github.com/MCLCE/MinecraftConsoles/commits @@ -626,7 +650,7 @@ 0 0 - 1268 + 1044 22 @@ -634,12 +658,35 @@ File - - + + + false + + + Create New Instance + + + + + + + Load Default Instance + + + + + + + + + - + + + + @@ -716,7 +763,7 @@ Quit the app - QAction::MenuRole::QuitRole + QAction::QuitRole @@ -730,7 +777,7 @@ Update The App - QAction::MenuRole::ApplicationSpecificRole + QAction::ApplicationSpecificRole @@ -741,7 +788,7 @@ About LCE Qt Launcher - QAction::MenuRole::AboutRole + QAction::AboutRole @@ -752,7 +799,7 @@ About Qt - QAction::MenuRole::AboutQtRole + QAction::AboutQtRole @@ -763,7 +810,7 @@ System Information - QAction::MenuRole::ApplicationSpecificRole + QAction::ApplicationSpecificRole @@ -846,20 +893,6 @@ See Instance Options - - - false - - - false - - - - - - Create New Instance - - false @@ -1038,6 +1071,57 @@ Install Content + + + true + + + Default Templates + + + + + No Templates + + + + + Default + + + + + NeoLegacy + + + + + Revelations + + + + + 360Revived + + + + + HellishEnds + + + + + false + + + Portable MCLE + + + + + Aether + + @@ -1048,6 +1132,7 @@ + diff --git a/src/lce_qt_launcher/features.py b/src/lce_qt_launcher/features.py index 546f077..4e29032 100644 --- a/src/lce_qt_launcher/features.py +++ b/src/lce_qt_launcher/features.py @@ -25,6 +25,8 @@ from lce_qt_launcher.views.setting_dialog import SettingDialog import lce_qt_launcher.views.cli as cli import lce_qt_launcher.views.term_service as term_service +import os + def install_game(parent : QWidget, instance : Instance, instanceManager : InstanceManager) -> None: """Features : Install the game instance selected #TODO : Separe the GUI with the logic of the model @@ -84,7 +86,11 @@ def show_instance_editor(parent : QWidget) -> None: """Features : Open the Instance Editor""" parent.instance_window.show() -def load_instance(parent : QWidget, instanceManager : InstanceManager, appContext: AppContext, buildInfo : BuildInfo, appData : AppData) -> None: +def load_instance_from_file(parent : QWidget, + instanceManager : InstanceManager, + appContext: AppContext, + buildInfo : BuildInfo, + appData : AppData) -> None: """Features : Load the Selected Instance""" file_name: tuple[str, str] = QFileDialog.getOpenFileName( parent, "Load Instance File", @@ -96,6 +102,10 @@ def load_instance(parent : QWidget, instanceManager : InstanceManager, appContex except FileExistsError: term_service.print_information("Instance already in data folder. Skipping making symlink. ") +def load_instance_from_instance(instanceManager : InstanceManager, instance : Instance) -> None: + """Features : Load the Selected Instance""" + instanceManager.instance = instance + def show_about_qt(parent : QWidget) -> None: """Features : Load the Selected Instance""" print("Show About Qt popup.") diff --git a/src/lce_qt_launcher/views/launcher.py b/src/lce_qt_launcher/views/launcher.py index 914403e..5f0090b 100644 --- a/src/lce_qt_launcher/views/launcher.py +++ b/src/lce_qt_launcher/views/launcher.py @@ -1,5 +1,3 @@ -import os - from PySide6.QtWidgets import ( QApplication, QFileDialog, @@ -17,7 +15,9 @@ from PySide6.QtGui import ( ) from PySide6.QtCore import ( qVersion, - Qt + Qt, + QFile, + QIODevice ) import sys @@ -46,6 +46,7 @@ from lce_qt_launcher.managers.steam_manager import add_instance_to_steam import lce_qt_launcher.views.term_service as term_service import lce_qt_launcher.features as features import lce_qt_launcher.utils.holiday as holiday +import lce_qt_launcher.res_rc class LauncherView(QMainWindow): """_summary_ The Main Window / launcher of the QApplcation @@ -132,7 +133,7 @@ class LauncherView(QMainWindow): def loadInstanceActionCommand() -> None: """_summary_ Open the Load Save File Dialog """ - features.load_instance(self, instanceManager, appContext, buildInfo, appData) + features.load_instance_from_file(self, instanceManager, appContext, buildInfo, appData) self.ui.instanceNameLabel.setText(instanceManager.instance.name) self.image_label = instanceManager.instance.image self.news_feed = instanceManager.instance.news_feed @@ -207,6 +208,7 @@ class LauncherView(QMainWindow): self.ui.instance_img.setPixmap(pixmap) self.ui.repo_name_branch.setText(self.instance_name) self.ui.newsEngineView.setUrl(self.news_feed) + self.ui.steamLinkValue.setText(instanceManager.instance.steam_link) else: term_service.print_information("No file argument given or file not found. Loading default instance.") except json.JSONDecodeError as err: @@ -305,6 +307,64 @@ class LauncherView(QMainWindow): open_github_issues = lambda : webbrowser.open(appContext.buildInfo.git_repo_url + "/issues") self.ui.actionReport_a_Bugs_or_Sugess_a_feature.triggered.connect(open_github_issues) + loadDefaultInstance = lambda : self.load_instance(dict(), instanceManager) + self.ui.actionLoadDefaultInstance.triggered.connect(loadDefaultInstance) + + neoLegacyJson = QFile(":/instances/neoLegacy.lce_inst") + if not neoLegacyJson.open(QIODevice.OpenModeFlag.ReadOnly): + term_service.print_error("Cannot found or open NeoLegacy Instance") + self.ui.actionLoadNeoLegacyInstance.setEnabled(False) + return None + else: + raw_text_neo = bytes(neoLegacyJson.readAll().data()).decode('utf-8') + data_neo = json.loads(raw_text_neo) + loadNeoLegacyInstance = lambda : self.load_instance(data_neo, instanceManager) + self.ui.actionLoadNeoLegacyInstance.triggered.connect(loadNeoLegacyInstance) + + hellishEndsJson = QFile(":/instances/hellishends.lce_inst") + if not hellishEndsJson.open(QIODevice.OpenModeFlag.ReadOnly): + term_service.print_error("Cannot found or open Helish Ends Instance") + self.ui.actionLoadHellishEndsInstance.setEnabled(False) + return None + else: + raw_text_hellish_end = bytes(hellishEndsJson.readAll().data()).decode('utf-8') + data_hellish_end = json.loads(raw_text_hellish_end) + loadhellishEndsInstance = lambda : self.load_instance(data_hellish_end, instanceManager) + self.ui.actionLoadHellishEndsInstance.triggered.connect(loadhellishEndsInstance) + + i360RevivedJson = QFile(":/instances/360Revived.lce_inst") + if not i360RevivedJson.open(QIODevice.OpenModeFlag.ReadOnly): + term_service.print_error("Cannot found or open 360Revived Instance") + self.ui.actionLoad360RevivedInstance.setEnabled(False) + return None + else: + raw_text_360 = bytes(i360RevivedJson.readAll().data()).decode('utf-8') + data_360 = json.loads(raw_text_360) + load360RevivedInstance = lambda : self.load_instance(data_360, instanceManager) + self.ui.actionLoad360RevivedInstance.triggered.connect(load360RevivedInstance) + + revelationJson = QFile(":/instances/revelations.lce_inst") + if not revelationJson.open(QIODevice.OpenModeFlag.ReadOnly): + term_service.print_error("Cannot found or open revelations Instance") + self.ui.actionLoadRevelationsInstance.setEnabled(False) + return None + else: + raw_text_rev = bytes(revelationJson.readAll().data()).decode('utf-8') + data_rev = json.loads(raw_text_rev) + loadRevelationInstance = lambda : self.load_instance(data_rev, instanceManager) + self.ui.actionLoadRevelationsInstance.triggered.connect(loadRevelationInstance) + + aetherJson = QFile(":/instances/aether.lce_inst") + if not aetherJson.open(QIODevice.OpenModeFlag.ReadOnly): + term_service.print_error("Cannot found or open Aether Instance") + self.ui.actionLoadAetherInstance.setEnabled(False) + return None + else: + raw_text_aether = bytes(aetherJson.readAll().data()).decode('utf-8') + data_aether = json.loads(raw_text_aether) + loadAetherInstance = lambda : self.load_instance(data_aether, instanceManager) + self.ui.actionLoadAetherInstance.triggered.connect(loadAetherInstance) + def addSteamLinkIntegrationButtonCommand(): steamIntegrationDialog = QInputDialog(self) value = steamIntegrationDialog.getText(self, "Add Steam Integration", "steamid") @@ -319,7 +379,26 @@ class LauncherView(QMainWindow): self.ui.addSteamLinkIntegration.clicked.connect(addSteamLinkIntegrationButtonCommand) + self.ui.InstancesList.setEnabled(False) + self.versionlabel: QLabel = QLabel(f"Version {buildInfo.version}") self.ui.statusbar.addPermanentWidget(self.versionlabel) holyday_label: QLabel = QLabel(holiday.get_holiday()) - self.ui.statusbar.addWidget(holyday_label) \ No newline at end of file + self.ui.statusbar.addWidget(holyday_label) + + def load_instance(self, data : dict[str, str], instanceManager : InstanceManager, ) -> None: + instance = Instance() + instance.load_inst_from_dict(data) + features.load_instance_from_instance(instanceManager, instance) + self.ui.instanceNameLabel.setText(instanceManager.instance.name) + self.image_label = instanceManager.instance.image + self.news_feed = instanceManager.instance.news_feed + self.instance_name = instanceManager.instance.name + self.ui.usernameInputBox.setText(instanceManager.instance.username) + self.ui.pathInputBox.setText(instanceManager.instance.installation_path) + self.ui.repoURLInputBox.setText(instanceManager.instance.repo_url) + pixmap = QPixmap(self.image_label) + self.ui.instance_img.setPixmap(pixmap) + self.ui.repo_name_branch.setText(self.instance_name) + self.ui.newsEngineView.setUrl(self.news_feed) + self.ui.steamLinkValue.setText(instanceManager.instance.steam_link) \ No newline at end of file