mirror of
https://github.com/nixietab/picodulce.git
synced 2025-12-14 02:03:59 +00:00
Compare commits
No commits in common. "main" and "0.13.10" have entirely different histories.
44
authser.py
44
authser.py
@ -134,8 +134,6 @@ class AuthenticationThread(QThread):
|
|||||||
|
|
||||||
return j["access_token"], j["refresh_token"]
|
return j["access_token"], j["refresh_token"]
|
||||||
|
|
||||||
raise Exception("Authentication cancelled by user")
|
|
||||||
|
|
||||||
async def _xbl_auth(self, access_token):
|
async def _xbl_auth(self, access_token):
|
||||||
data = {
|
data = {
|
||||||
"Properties": {
|
"Properties": {
|
||||||
@ -225,14 +223,13 @@ class AuthenticationThread(QThread):
|
|||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
|
||||||
class MinecraftAuthenticator(QObject):
|
class MinecraftAuthenticator(QObject):
|
||||||
auth_finished = pyqtSignal(bool, str)
|
auth_finished = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.auth_thread = None
|
self.auth_thread = None
|
||||||
self.auth_dialog = None
|
self.auth_dialog = None
|
||||||
self.success = False
|
self.success = False
|
||||||
self.error_message = None
|
|
||||||
self.username = None
|
self.username = None
|
||||||
|
|
||||||
# Initialize the launcher to get the correct config path
|
# Initialize the launcher to get the correct config path
|
||||||
@ -245,12 +242,6 @@ class MinecraftAuthenticator(QObject):
|
|||||||
|
|
||||||
# Create accounts.json if it doesn't exist
|
# Create accounts.json if it doesn't exist
|
||||||
if not self.save_to_accounts_json():
|
if not self.save_to_accounts_json():
|
||||||
self.auth_finished.emit(False, self.error_message)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Check if account is online
|
|
||||||
if not self.validate_account_type():
|
|
||||||
self.auth_finished.emit(False, "Cannot authenticate an offline account")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self.auth_thread = AuthenticationThread(username)
|
self.auth_thread = AuthenticationThread(username)
|
||||||
@ -272,24 +263,9 @@ class MinecraftAuthenticator(QObject):
|
|||||||
self.auth_thread.stop()
|
self.auth_thread.stop()
|
||||||
|
|
||||||
def show_error(self, error_msg):
|
def show_error(self, error_msg):
|
||||||
self.error_message = error_msg
|
QMessageBox.critical(None, "Error", error_msg)
|
||||||
self.success = False
|
self.success = False
|
||||||
|
self.auth_finished.emit(False)
|
||||||
def validate_account_type(self):
|
|
||||||
try:
|
|
||||||
accounts_file = Path(self.config_path) / "accounts.json"
|
|
||||||
if accounts_file.exists():
|
|
||||||
with open(accounts_file) as f:
|
|
||||||
config = json.load(f)
|
|
||||||
|
|
||||||
if self.username in config["accounts"]:
|
|
||||||
return config["accounts"][self.username].get("microsoft", False)
|
|
||||||
|
|
||||||
return True # New account, will be created as microsoft
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Failed to validate account type: {str(e)}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def save_to_accounts_json(self):
|
def save_to_accounts_json(self):
|
||||||
try:
|
try:
|
||||||
@ -329,7 +305,7 @@ class MinecraftAuthenticator(QObject):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to initialize account data: {str(e)}")
|
logger.error(f"Failed to initialize account data: {str(e)}")
|
||||||
self.error_message = f"Failed to initialize account data: {str(e)}"
|
QMessageBox.critical(None, "Error", f"Failed to initialize account data: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_access_token_received(self, data):
|
def on_access_token_received(self, data):
|
||||||
@ -352,15 +328,17 @@ class MinecraftAuthenticator(QObject):
|
|||||||
json.dump(config, f, indent=4)
|
json.dump(config, f, indent=4)
|
||||||
|
|
||||||
self.success = True
|
self.success = True
|
||||||
|
QMessageBox.information(None, "Success",
|
||||||
|
f"Successfully authenticated account: {self.username}")
|
||||||
else:
|
else:
|
||||||
raise Exception("Account not found in configuration")
|
raise Exception("Account not found in configuration")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to update account data: {str(e)}")
|
logger.error(f"Failed to update account data: {str(e)}")
|
||||||
self.error_message = f"Failed to update account data: {str(e)}"
|
QMessageBox.critical(None, "Error", f"Failed to update account data: {str(e)}")
|
||||||
self.success = False
|
self.success = False
|
||||||
|
|
||||||
# We don't emit here, we wait for the thread to finish
|
self.auth_finished.emit(self.success)
|
||||||
|
|
||||||
def on_authentication_finished(self):
|
def on_authentication_finished(self):
|
||||||
if self.auth_dialog is not None:
|
if self.auth_dialog is not None:
|
||||||
@ -372,9 +350,7 @@ class MinecraftAuthenticator(QObject):
|
|||||||
self.auth_thread = None
|
self.auth_thread = None
|
||||||
|
|
||||||
if not self.success:
|
if not self.success:
|
||||||
self.auth_finished.emit(False, self.error_message)
|
self.auth_finished.emit(False)
|
||||||
else:
|
|
||||||
self.auth_finished.emit(True, f"Successfully authenticated account: {self.username}")
|
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if self.auth_dialog is not None:
|
if self.auth_dialog is not None:
|
||||||
@ -387,4 +363,4 @@ class MinecraftAuthenticator(QObject):
|
|||||||
|
|
||||||
def create_authenticator():
|
def create_authenticator():
|
||||||
"""Factory function to create a new MinecraftAuthenticator instance"""
|
"""Factory function to create a new MinecraftAuthenticator instance"""
|
||||||
return MinecraftAuthenticator()
|
return MinecraftAuthenticator()
|
||||||
|
|||||||
42
picodulce.py
42
picodulce.py
@ -16,7 +16,7 @@ from healthcheck import HealthCheck
|
|||||||
import modulecli
|
import modulecli
|
||||||
import loaddaemon
|
import loaddaemon
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QComboBox, QWidget, QInputDialog, QVBoxLayout, QListWidget, QSpinBox, QFileDialog, QPushButton, QMessageBox, QDialog, QHBoxLayout, QLabel, QLineEdit, QCheckBox, QTabWidget, QFrame, QSpacerItem, QSizePolicy, QMainWindow, QGridLayout, QTextEdit, QListWidget, QListWidgetItem, QMenu, QRadioButton
|
from PyQt5.QtWidgets import QApplication, QComboBox, QWidget, QInputDialog, QVBoxLayout, QListWidget, QSpinBox, QFileDialog, QPushButton, QMessageBox, QDialog, QHBoxLayout, QLabel, QLineEdit, QCheckBox, QTabWidget, QFrame, QSpacerItem, QSizePolicy, QMainWindow, QGridLayout, QTextEdit, QListWidget, QListWidgetItem, QMenu
|
||||||
from PyQt5.QtGui import QFont, QIcon, QColor, QPalette, QMovie, QPixmap, QDesktopServices, QBrush
|
from PyQt5.QtGui import QFont, QIcon, QColor, QPalette, QMovie, QPixmap, QDesktopServices, QBrush
|
||||||
from PyQt5.QtCore import Qt, QObject, pyqtSignal, QThread, QUrl, QMetaObject, Q_ARG, QByteArray, QSize
|
from PyQt5.QtCore import Qt, QObject, pyqtSignal, QThread, QUrl, QMetaObject, Q_ARG, QByteArray, QSize
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -1074,11 +1074,11 @@ class zucaroVersionSelector(QWidget):
|
|||||||
logging.error(error_message)
|
logging.error(error_message)
|
||||||
QMessageBox.critical(dialog, "Error", error_message)
|
QMessageBox.critical(dialog, "Error", error_message)
|
||||||
|
|
||||||
def _on_auth_finished(self, success, message):
|
def _on_auth_finished(self, success):
|
||||||
if success:
|
if success:
|
||||||
QMessageBox.information(self, "Success", message)
|
QMessageBox.information(self, "Success", "Account authenticated successfully!")
|
||||||
else:
|
else:
|
||||||
QMessageBox.critical(self, "Error", message)
|
QMessageBox.critical(self, "Error", "Failed to authenticate account")
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
if self.authenticator:
|
if self.authenticator:
|
||||||
@ -1682,13 +1682,11 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
title_label.setFont(QFont("Arial", 14))
|
title_label.setFont(QFont("Arial", 14))
|
||||||
layout.addWidget(title_label)
|
layout.addWidget(title_label)
|
||||||
|
|
||||||
# Create radio buttons for mod loaders
|
# Create checkboxes for mod loaders
|
||||||
self.forge_checkbox = QRadioButton('Forge')
|
self.forge_checkbox = QCheckBox('Forge')
|
||||||
self.fabric_checkbox = QRadioButton('Fabric')
|
self.fabric_checkbox = QCheckBox('Fabric')
|
||||||
self.quilt_checkbox = QRadioButton('Quilt')
|
|
||||||
layout.addWidget(self.forge_checkbox)
|
layout.addWidget(self.forge_checkbox)
|
||||||
layout.addWidget(self.fabric_checkbox)
|
layout.addWidget(self.fabric_checkbox)
|
||||||
layout.addWidget(self.quilt_checkbox)
|
|
||||||
|
|
||||||
# Create dropdown menu for versions
|
# Create dropdown menu for versions
|
||||||
self.version_combo_mod = QComboBox()
|
self.version_combo_mod = QComboBox()
|
||||||
@ -1697,23 +1695,19 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
def update_versions():
|
def update_versions():
|
||||||
self.version_combo_mod.clear()
|
self.version_combo_mod.clear()
|
||||||
if self.forge_checkbox.isChecked():
|
if self.forge_checkbox.isChecked():
|
||||||
self.populate_available_releases(self.version_combo_mod, True, False, False)
|
self.populate_available_releases(self.version_combo_mod, True, False)
|
||||||
elif self.fabric_checkbox.isChecked():
|
elif self.fabric_checkbox.isChecked():
|
||||||
self.populate_available_releases(self.version_combo_mod, False, True, False)
|
self.populate_available_releases(self.version_combo_mod, False, True)
|
||||||
elif self.quilt_checkbox.isChecked():
|
|
||||||
self.populate_available_releases(self.version_combo_mod, False, False, True)
|
|
||||||
|
|
||||||
self.forge_checkbox.clicked.connect(update_versions)
|
self.forge_checkbox.clicked.connect(update_versions)
|
||||||
self.fabric_checkbox.clicked.connect(update_versions)
|
self.fabric_checkbox.clicked.connect(update_versions)
|
||||||
self.quilt_checkbox.clicked.connect(update_versions)
|
|
||||||
|
|
||||||
# Create install button
|
# Create install button
|
||||||
install_button = QPushButton('Install')
|
install_button = QPushButton('Install')
|
||||||
install_button.clicked.connect(lambda: self.install_mod_loader(
|
install_button.clicked.connect(lambda: self.install_mod_loader(
|
||||||
self.version_combo_mod.currentText(),
|
self.version_combo_mod.currentText(),
|
||||||
self.forge_checkbox.isChecked(),
|
self.forge_checkbox.isChecked(),
|
||||||
self.fabric_checkbox.isChecked(),
|
self.fabric_checkbox.isChecked()
|
||||||
self.quilt_checkbox.isChecked()
|
|
||||||
))
|
))
|
||||||
layout.addWidget(install_button)
|
layout.addWidget(install_button)
|
||||||
|
|
||||||
@ -1727,7 +1721,6 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
|
|
||||||
# Create checkboxes for different version types
|
# Create checkboxes for different version types
|
||||||
self.release_checkbox = QCheckBox('Releases')
|
self.release_checkbox = QCheckBox('Releases')
|
||||||
self.release_checkbox.setChecked(True)
|
|
||||||
self.snapshot_checkbox = QCheckBox('Snapshots')
|
self.snapshot_checkbox = QCheckBox('Snapshots')
|
||||||
self.alpha_checkbox = QCheckBox('Alpha')
|
self.alpha_checkbox = QCheckBox('Alpha')
|
||||||
self.beta_checkbox = QCheckBox('Beta')
|
self.beta_checkbox = QCheckBox('Beta')
|
||||||
@ -1785,9 +1778,6 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
# Connect the combo box signal to the update function
|
# Connect the combo box signal to the update function
|
||||||
self.version_combo.currentIndexChanged.connect(self.update_download_button_state)
|
self.version_combo.currentIndexChanged.connect(self.update_download_button_state)
|
||||||
|
|
||||||
# Initial update
|
|
||||||
update_versions()
|
|
||||||
|
|
||||||
def update_download_button_state(self):
|
def update_download_button_state(self):
|
||||||
self.download_button.setEnabled(self.version_combo.currentIndex() != -1)
|
self.download_button.setEnabled(self.version_combo.currentIndex() != -1)
|
||||||
|
|
||||||
@ -1798,7 +1788,7 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
else:
|
else:
|
||||||
QMessageBox.critical(self, "Error", f"Failed to prepare version {version}.")
|
QMessageBox.critical(self, "Error", f"Failed to prepare version {version}.")
|
||||||
|
|
||||||
def populate_available_releases(self, version_combo, install_forge, install_fabric, install_quilt):
|
def populate_available_releases(self, version_combo, install_forge, install_fabric):
|
||||||
try:
|
try:
|
||||||
command = "version list --release"
|
command = "version list --release"
|
||||||
output = modulecli.run_command(command)
|
output = modulecli.run_command(command)
|
||||||
@ -1809,7 +1799,7 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
logging.error("Error: %s", str(e))
|
logging.error("Error: %s", str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
if install_fabric or install_quilt:
|
if install_fabric:
|
||||||
releases = [version for version in output.splitlines() if version.startswith("1.") and int(version.split('.')[1]) >= 14]
|
releases = [version for version in output.splitlines() if version.startswith("1.") and int(version.split('.')[1]) >= 14]
|
||||||
elif install_forge:
|
elif install_forge:
|
||||||
releases = [version for version in output.splitlines() if version.startswith("1.") and float(version.split('.')[1]) >= 5]
|
releases = [version for version in output.splitlines() if version.startswith("1.") and float(version.split('.')[1]) >= 5]
|
||||||
@ -1819,8 +1809,8 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
version_combo.clear()
|
version_combo.clear()
|
||||||
version_combo.addItems(releases)
|
version_combo.addItems(releases)
|
||||||
|
|
||||||
def install_mod_loader(self, version, install_forge, install_fabric, install_quilt):
|
def install_mod_loader(self, version, install_forge, install_fabric):
|
||||||
if not install_forge and not install_fabric and not install_quilt:
|
if not install_forge and not install_fabric:
|
||||||
QMessageBox.warning(self, "Select Mod Loader", "Please select at least one mod loader.")
|
QMessageBox.warning(self, "Select Mod Loader", "Please select at least one mod loader.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1829,8 +1819,6 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
mod_loader = 'forge'
|
mod_loader = 'forge'
|
||||||
elif install_fabric:
|
elif install_fabric:
|
||||||
mod_loader = 'fabric'
|
mod_loader = 'fabric'
|
||||||
elif install_quilt:
|
|
||||||
mod_loader = 'quilt'
|
|
||||||
|
|
||||||
if not mod_loader:
|
if not mod_loader:
|
||||||
QMessageBox.warning(self, "Select Mod Loader", "Please select at least one mod loader.")
|
QMessageBox.warning(self, "Select Mod Loader", "Please select at least one mod loader.")
|
||||||
@ -1841,8 +1829,6 @@ class ModLoaderAndVersionMenu(QDialog):
|
|||||||
command = f"mod loader forge install --game {version}"
|
command = f"mod loader forge install --game {version}"
|
||||||
elif mod_loader == 'fabric':
|
elif mod_loader == 'fabric':
|
||||||
command = f"mod loader fabric install {version}"
|
command = f"mod loader fabric install {version}"
|
||||||
elif mod_loader == 'quilt':
|
|
||||||
command = f"mod loader quilt install {version}"
|
|
||||||
modulecli.run_command(command)
|
modulecli.run_command(command)
|
||||||
QMessageBox.information(self, "Success", f"{mod_loader.capitalize()} installed successfully for version {version}!")
|
QMessageBox.information(self, "Success", f"{mod_loader.capitalize()} installed successfully for version {version}!")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user