Update to 0.1.7-alpha

Add custom game directory and launch log controls

CoreLib update to 0.1.9
This commit is contained in:
wei committed 2026-11-14 17:10:33 +08:00
1 parent fea979fb6f
commit ad38cf726e
24 files changed
+541 -123

No files matched your search

+1 -1
View File
@@ -224,7 +224,7 @@ refresh tokens, and sign-in codes before sharing logs.
- [X] Add support for installing Forge/Neoforge (even Quilt) mod loader.
- [X] Add a simple plugin system, allows customizing launcher behavior such as adding a new page or button.
- [ ] Design the home page.
- [ ] Add more custom settings.
- [X] Add more custom settings.
- [ ] Add a usage guide.
- [ ] Add download mod from third party website support.
- [ ] Design a new icon to replace the current one (looks horrible).
+63 -6
View File
@@ -1,3 +1,4 @@
import os
import platform
import sys
import traceback
@@ -12,11 +13,12 @@ try:
except ModuleNotFoundError: # Python 3.10
import tomli as tomllib
from PySide6.QtCore import QSize
from PySide6.QtCore import QSize, QProcess
from PySide6.QtGui import QIcon, QPixmap, QPalette, QColor
from PySide6.QtWidgets import QApplication, QStyle, QToolButton, QWidget
from constant import LAUNCHER_VERSION
from core_lib.common.exception import ConfigValidationError
from core_lib.qt.hack import move_window_to_center, is_light_theme, \
recolor_icon
from core_lib.qt import messagebox
@@ -48,8 +50,26 @@ PALETTE_ROLES = {
}
def get_official_launcher_game_dir() -> Path:
"""
Get the official launcher game directory.
"""
system = platform.system()
home = Path.home()
if system == "Windows":
appdata = os.environ.get("APPDATA")
return (Path(appdata) if appdata else home / "AppData" / "Roaming") / ".minecraft"
if system == "Darwin":
return home / "Library" / "Application Support" / "minecraft"
if system == "Linux":
return home / ".minecraft"
raise OSError(f"Unsupported operating system: {system}")
class Launcher(QApplication, LauncherObject):
def __init__(self, logger, log_capture_handler, debug: bool = False):
def __init__(self, logger, log_capture_handler, custom_game_dir: Path, debug: bool = False):
super().__init__()
self._system_palette = QPalette(self.palette()) # theme
@@ -62,6 +82,7 @@ class Launcher(QApplication, LauncherObject):
# dirs
self.program_dir = Path(__file__).parent
self.work_dir = Path.cwd()
self.custom_game_dir = custom_game_dir
# Widget (Signal, Event)
self.widget_manager = WidgetManager()
@@ -255,8 +276,18 @@ class Launcher(QApplication, LauncherObject):
@property
def default_game_dir(self) -> Path:
# Completely with official Minecraft launcher
return self.work_dir
return self.work_dir / "game"
@property
def game_dir(self) -> Path:
compatibility_mode = self.settings_manager.get("general", GeneralSettings).compatibility_mode
if compatibility_mode == "official-launcher":
# Share the official launcher's default game directory.
official_dir = get_official_launcher_game_dir()
return official_dir
return self.custom_game_dir or self.default_game_dir
@property
def resources_dir(self) -> Path:
@@ -463,9 +494,35 @@ class Launcher(QApplication, LauncherObject):
try:
self.settings_manager.load()
except Exception as e:
raw_traceback = traceback.format_exc()
self.settings_manager.load_defaults(prevent_save=True)
if isinstance(e, ConfigValidationError):
problems = []
for section, error in e.errors.items():
for detail in error.errors(include_url=False):
field = ".".join(str(part) for part in detail["loc"])
location = f"[{section}] {field}" if field else f"[{section}]"
problems.append(f"- {location}: {detail['msg']}")
summary = "Some settings contain invalid values:\n" + "\n".join(problems)
elif isinstance(e, tomllib.TOMLDecodeError):
summary = f"The settings file contains invalid TOML syntax.\n{e}"
elif isinstance(e, OSError):
summary = (
"The settings file could not be read.\n"
"Check that the file exists and that you have permission to read it."
)
else:
summary = "An unexpected error prevented the settings from loading."
messagebox.error_with_plain_text(
None,
"Settings Error",
"An unexpected error occurred while loading settings.",
f"Below are the raw data of the error\n\nError: {str(e)}\n\nTraceback:\n{traceback.format_exc()}",
"Settings could not be loaded. Default settings are now in use.\n"
"The original settings file will not be overwritten.\n"
"Settings changes made during this session will not be saved.",
f"Settings file: {self.settings_manager.path}\n\n"
f"{summary}\n\n"
"Correct the settings file and restart the launcher to try again.\n\n"
f"--- Raw details (Python traceback) ---\n{raw_traceback}",
)
+2 -2
View File
@@ -1,4 +1,4 @@
LAUNCHER_VERSION = "0.1.6-alpha-1"
LAUNCHER_VERSION = "0.1.7-alpha"
LAUNCHER_NAME = "TapLauncher"
LAUNCHER_DIR_NAME = "TapLauncher"
MAIN_REPO_URL = "https://repo.weispace.net/wei/Launcher/"
@@ -34,4 +34,4 @@ It aims to maintain maximum compatibility with the official Minecraft
"""
LAUNCHER_DESCRIPTION_KEYWORD = "$ABOUT_THIS_LAUNCHER"
LAUNCHER_DESCRIPTION_MARKDOWN_KEYWORD = "$ABOUT_THIS_LAUNCHER_MARKDOWN"
WHEEL_PLUGIN_API_VERSION = "0.0.2"
WHEEL_PLUGIN_API_VERSION = "0.0.3"
+1 -1
View File
@@ -1,4 +1,4 @@
__version__ = '0.1.8'
__version__ = '0.1.9'
__description__ = """
A library for Python-based block game launcher.
+1 -1
View File
@@ -311,7 +311,7 @@ def download_assets_and_copy(assets: list[FileObject], legacy_assets: list[dict]
return fails
# Use thread pool to handle copy file process
with ThreadPoolExecutor(max_workers=ASSET_DOWNLOAD_MAX_WORKERS, verify_hash=not no_hash_check) as executor:
with ThreadPoolExecutor(max_workers=ASSET_DOWNLOAD_MAX_WORKERS) as executor:
futures = [
executor.submit(
__worker,
+10 -1
View File
@@ -22,6 +22,7 @@ import os
import sys
import argparse
import logging
from pathlib import Path
from PySide6.QtWidgets import QApplication, QMainWindow
from platformdirs import (
@@ -53,6 +54,7 @@ def main():
parser.add_argument("-d", "--debug", action="store_true",
help="Enable debug mode", default=False)
parser.add_argument("-wd", "--work-dir", default=None, help="Work directory")
parser.add_argument("-gd", "--game-dir", default=None, help="Game directory that used for storing game files")
args, unknown = parser.parse_known_args()
for arg in unknown:
@@ -82,6 +84,13 @@ def main():
show_error(f"Specified work directory \"{work_dir}\" does not exist or is not a directory.")
sys.exit(-1)
game_dir = args.game_dir
if game_dir is None:
game_dir = Path(work_dir, "game")
game_dir.mkdir(exist_ok=True)
if os.getcwd() != args.work_dir:
os.chdir(work_dir)
@@ -108,7 +117,7 @@ def main():
logging.basicConfig(format=DEFAULT_FORMAT, datefmt=DEFAULT_DATE_FORMAT, level=level)
# Start (the real) launcher
app = Launcher(logger, capture_handler, debug=debug)
app = Launcher(logger, capture_handler, custom_game_dir=game_dir, debug=debug)
sys.exit(app.exec())
+14 -14
View File
@@ -61,10 +61,10 @@ class ManifestManager:
#
@property
def version_manifest_path(self) -> Path:
return Path(self.app.work_dir, "versions", "version_manifest_v2.json")
return Path(self.app.game_dir, "versions", "version_manifest_v2.json")
def get_specific_version_manifest_path(self, target_version: str) -> Path | None:
return Path(self.app.work_dir, "versions", target_version, f"{target_version}.json")
return Path(self.app.game_dir, "versions", target_version, f"{target_version}.json")
def _manifest_rebuild_text(self, text: str, **values) -> str:
translate = getattr(self.app, "tr_text", None)
@@ -73,7 +73,7 @@ class ManifestManager:
def _get_manifest_backup_path(self, version_id: str) -> Path:
if not validate_minecraft_version(version_id):
raise ValueError("Invalid version ID: {}".format(version_id))
root = Path(self.app.work_dir).resolve()
root = Path(self.app.game_dir).resolve()
path = root / "cache" / "version_manifests" / "{}.json".format(version_id)
if not path.resolve().is_relative_to(root):
raise ValueError("Manifest backup path is outside the launcher directory.")
@@ -87,7 +87,7 @@ class ManifestManager:
source = self.get_specific_version_manifest_path(version_id)
if source is None:
raise ValueError("Version manifest path is unavailable")
root = Path(self.app.work_dir).resolve() / "versions"
root = Path(self.app.game_dir).resolve() / "versions"
if not source.resolve().is_relative_to(root):
raise ValueError("Version manifest path is outside the versions directory")
payload = source.read_bytes()
@@ -105,7 +105,7 @@ class ManifestManager:
try:
backup = self._get_manifest_backup_path(version_id)
path = self.get_specific_version_manifest_path(version_id)
root = Path(self.app.work_dir).resolve() / "versions"
root = Path(self.app.game_dir).resolve() / "versions"
if path is None or not path.resolve().is_relative_to(root):
raise ValueError("Version manifest path is outside the versions directory")
# Another launch may have completed recovery while this one waited.
@@ -447,7 +447,7 @@ class ManifestManager:
)
# Locally created modded and custom versions.
versions_dir = Path(self.app.work_dir, "versions")
versions_dir = Path(self.app.game_dir, "versions")
for manifest_path in versions_dir.glob("*/*.json"):
try:
@@ -1003,7 +1003,7 @@ class GameFileManager:
assets_dir,
no_hash_check=not verify_hash,
progress_callback=callback,
launcher_root=self.app.work_dir,
launcher_root=self.app.game_dir,
)
result, fails = self.redownload_files(fails, verify_hash=verify_hash)
@@ -1169,7 +1169,7 @@ class GameFileManager:
if vanilla is None:
raise LoaderInstallError("Unable to load the vanilla manifest.")
root = Path(self.app.work_dir).resolve()
root = Path(self.app.game_dir).resolve()
libraries_dir = root / "libraries"
client_jar = root / "versions" / minecraft_version / "{}.jar".format(minecraft_version)
@@ -1370,9 +1370,9 @@ class LaunchManager:
java_major_version = java_version.get("majorVersion")
# Game paths
core_file_path = Path(self.app.work_dir, "versions", client_version_id, f"{client_version_id}.jar")
natives_dir = Path(self.app.work_dir, "versions", version_id, "natives")
libraries_dir = Path(self.app.work_dir, "libraries")
core_file_path = Path(self.app.game_dir, "versions", client_version_id, f"{client_version_id}.jar")
natives_dir = Path(self.app.game_dir, "versions", version_id, "natives")
libraries_dir = Path(self.app.game_dir, "libraries")
game_dir = profile.game_dir
@@ -1432,8 +1432,8 @@ class LaunchManager:
)
# Asset
default_assets_dir = Path(self.app.work_dir, "assets")
if not check_assets_exist(version_manifest, default_assets_dir, launcher_root=self.app.work_dir):
default_assets_dir = Path(self.app.game_dir, "assets")
if not check_assets_exist(version_manifest, default_assets_dir, launcher_root=self.app.game_dir):
request = GameFileDownloadRequest(
"download_assets",
(version_id, default_assets_dir, version_manifest)
@@ -1449,7 +1449,7 @@ class LaunchManager:
"Unable to launch game due to certain assets download failure."
)
assets_dir = find_correct_assets_dir(asset_id, default_assets_dir, self.app.work_dir)
assets_dir = find_correct_assets_dir(asset_id, default_assets_dir, self.app.game_dir)
classpath = generate_classpath(
version_manifest,
+9 -2
View File
@@ -22,6 +22,7 @@ from core_lib.game.profile import read_profile_file, is_profiles_valid, \
set_last_used_time
from core_lib.game.version_info import LATEST_VERSION_ALIASES
from core_lib.qt.hack import is_qt_supported_image, image_to_data_url, base64_to_qicon, prepare_profile_icon
from manager.settings_models import GeneralSettings
from manager.widgets import AskForRequest
DEFAuLT_PROFILE_RELATIVE_PATH = Path("launcher_profiles.json")
@@ -102,6 +103,7 @@ class ProfileManager(QObject):
QObject.__init__(self, app)
self.app = app
self.widget_manager = widget_manager
self.settings_manager = app.settings_manager
self.profiles = {}
@@ -116,6 +118,11 @@ class ProfileManager(QObject):
@property
def default_profile_path(self):
compatibility_mode = self.settings_manager.get("general", GeneralSettings).compatibility_mode
if compatibility_mode == "official-launcher":
return Path(self.app.game_dir, DEFAuLT_PROFILE_RELATIVE_PATH)
return Path(self.app.work_dir, DEFAuLT_PROFILE_RELATIVE_PATH)
def register_plugin_apis(self, plugin_manager):
@@ -346,7 +353,7 @@ class ProfileManager(QObject):
if request.game_dir is not None:
game_dir = Path(request.game_dir).as_posix()
else:
default_game_dir = self.app.default_game_dir
default_game_dir = self.app.game_dir
game_dir = default_game_dir.as_posix()
try:
@@ -704,7 +711,7 @@ class ProfileManager(QObject):
game_dir = (
profile.game_dir
if profile.game_dir is not None
else self.app.default_game_dir
else self.app.game_dir
)
return LaunchProfile(
+13 -1
View File
@@ -29,6 +29,8 @@ class SettingsManager:
self.path = Path(path) if path is not None else None
self._models: dict[str, type[BaseModel]] = {}
self._settings: dict[str, BaseModel] = {}
self._prevent_save: bool = False # This flag prevents the settings from being saved to disk. Used
# when errors occur during loading the settings.
@property
def registered_sections(self) -> tuple[str, ...]:
@@ -143,23 +145,33 @@ class SettingsManager:
self._settings[section] = validated
return validated
def load_defaults(self) -> SettingsManager:
def load_defaults(self, prevent_save: bool=False) -> SettingsManager:
"""Load every registered model using its declared default values."""
loaded: dict[str, BaseModel] = {}
errors: dict[str, ValidationError] = {}
for section, model in self._models.items():
try:
loaded[section] = model.model_validate({})
except ValidationError as error:
errors[section] = error
if errors:
raise ConfigValidationError(errors)
if prevent_save:
self._prevent_save = True
self._settings = loaded
return self
def save(self, path: str | Path | None = None) -> Path:
"""Validate all loaded sections and save them as UTF-8 TOML."""
config_path = self._resolve_path(path)
if self._prevent_save:
return config_path
missing = set(self._models).difference(self._settings)
if missing:
names = ", ".join(sorted(missing))
+6
View File
@@ -28,6 +28,8 @@ class GeneralSettings(WarnExtraModel):
language: Literal["en", "zh-TW"] = "zh-TW"
compatibility_mode: Literal["none", "official-launcher"] = 'none'
class AppearanceSettings(WarnExtraModel):
model_config = ConfigDict()
@@ -49,6 +51,7 @@ class AccountSettings(WarnExtraModel):
credentials_save_method: Literal["system-keyring", "file"] = "system-keyring"
custom_client_id: UUID | None = None
enable_token_updater: bool = True
token_refresh_interval: int = 600
@field_validator("custom_client_id", mode="before")
@classmethod
@@ -89,3 +92,6 @@ class PageBarSettings(WarnExtraModel):
class GameSettings(WarnExtraModel):
verify_hash_on_download: bool = True
verify_hash_on_launch: bool = True
open_log_view_when_launch: bool = True
action_after_launch: Literal["close", "stay-open", "minimize"] = "stay-open"
+103 -4
View File
@@ -10,7 +10,7 @@ from manager.game import LaunchManager, LaunchResult
from core_lib.game.version_info import LATEST_VERSION_ALIASES
from manager.profile import ProfileSummary, LaunchProfile, ProfileManager, _profile_icon
from manager.widgets import AskForRequest, WidgetManager
from manager.settings_models import AppearanceSettings
from manager.settings_models import AppearanceSettings, GameSettings
from pages.process_log import ProcessLogWindow
@@ -197,7 +197,7 @@ class LaunchProfilePage(QWidget):
self.status_label.setObjectName("launchStatus")
self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
# Profile button (just like the official launcher look like)
# Profile button (just like the official launcher looks like)
self.profile_button = ProfileButton(self.app)
self.profile_button.setMinimumWidth(260)
self.profile_button.setMaximumWidth(360)
@@ -217,6 +217,20 @@ class LaunchProfilePage(QWidget):
)
launch_button.clicked.connect(self.launch_profile)
self.log_button = QPushButton("≡", self)
self.log_button.setObjectName("logButton")
self.log_button.setFocusPolicy(Qt.FocusPolicy.TabFocus)
self.log_button.setToolTip(self.app.tr_text("Show game log"))
self.log_button.setFixedWidth(36)
self.log_button.setMinimumHeight(42)
self.log_button.setMaximumHeight(64)
self.log_button.setSizePolicy(
QSizePolicy.Policy.Fixed,
QSizePolicy.Policy.Expanding,
)
self.log_button.clicked.connect(self.show_selected_profile_log)
self.log_button.hide()
# Profile overlay
self.profile_frame = self.ProfileBackgroundFrame(
parent=self,
@@ -260,7 +274,13 @@ class LaunchProfilePage(QWidget):
self.bottom_layout.addStretch()
self.bottom_layout.addWidget(self.status_label)
self.bottom_layout.addStretch()
self.bottom_layout.addWidget(launch_button)
launch_actions = QHBoxLayout()
launch_actions.setContentsMargins(0, 0, 0, 0)
launch_actions.setSpacing(4)
launch_actions.setAlignment(Qt.AlignmentFlag.AlignRight)
launch_actions.addWidget(launch_button)
self.launch_actions = launch_actions
self.bottom_layout.addLayout(launch_actions)
self.layout.addWidget(self.profile_frame, 1)
self.layout.addLayout(self.bottom_layout)
@@ -355,13 +375,52 @@ class LaunchProfilePage(QWidget):
)
self.process_log_windows.append(log_window)
log_window.show()
self._update_log_button()
settings = self.app.settings_manager.get("game", GameSettings)
if settings.open_log_view_when_launch:
log_window.show()
self.status_label.setText(self.app.tr_text("Launched!"))
# Cleanup for status label
self.status_label_cleanup()
main_window = self.app.main_window
if settings.action_after_launch == "close":
main_window.close()
elif settings.action_after_launch == "minimize":
main_window.showMinimized()
def _selected_profile_log(self) -> ProcessLogWindow | None:
profile_id = self.profile_button.property("profile_id")
if profile_id is None:
return None
return next(
(window for window in reversed(self.process_log_windows)
if window.profile_id == profile_id),
None,
)
def _update_log_button(self) -> None:
if self._selected_profile_log() is not None:
if self.launch_actions.indexOf(self.log_button) == -1:
self.launch_actions.addWidget(self.log_button)
self.log_button.show()
else:
self.log_button.hide()
self.launch_actions.removeWidget(self.log_button)
def show_selected_profile_log(self) -> None:
# Release the button's visual state before activating another window.
self.log_button.setDown(False)
self.log_button.clearFocus()
self.log_button.update()
window = self._selected_profile_log()
if window is not None:
window.showNormal()
window.raise_()
window.activateWindow()
def status_label_cleanup(self):
timer = QTimer(self)
timer.setSingleShot(True)
@@ -378,6 +437,7 @@ class LaunchProfilePage(QWidget):
self.profile_button.setProperty("profile_id", None)
self.profile_button.name_label.setText(self.app.tr_text("No profiles available"))
self.profile_button.version_label.clear()
self._update_log_button()
return
selected_id = self.profile_button.property("profile_id")
@@ -445,6 +505,7 @@ class LaunchProfilePage(QWidget):
def select_profile(self, profile: ProfileSummary) -> None:
# Update select profile id
self.profile_button.set_profile(profile)
self._update_log_button()
self.profile_popup.hide()
self.profile_button.set_popup_open(False)
@@ -486,3 +547,41 @@ class LaunchProfilePage(QWidget):
self.launch_manager.start_launch_task(launch_profile)
# The log view window creation process has been moved to the method self.launch_finished, move to there!
def show_profile_launch_log_view(self, profile_id: str):
"""
Show processLogView that related to the provided profile id
:param profile_id:
:return:
"""
profile = self.profile_manager.get_profile(profile_id)
if not profile:
return
if profile_id not in [window.profile_id for window in self.process_log_windows]:
return
related_windows = [window for window in self.process_log_windows if window.profile_id == profile_id]
if len(related_windows) > 1:
request = AskForRequest(
self.app.tr_text("Launch Request"),
self.app.tr_text(
"Multiple log views (among {count} windows) are running for profile {profile}. Are you sure you want to open all log view?",
profile=profile.name,
count=len(related_windows),
),
)
if not request.wait(60):
self.widget_mgr.signal.show_error_message.emit(
self.app.tr_text("Time out waiting for request for open window.")
)
return
if not request.result() is True:
return
for window in related_windows:
window.show()
+11 -8
View File
@@ -523,10 +523,12 @@ class ManageProfilePage(QWidget):
)
def duplicate_profile(self, profile: ProfileSummary | None=None) -> None:
if self.selected_profile_id is None and profile is None:
return
profile_id = self.selected_profile_id
if isinstance(profile, ProfileSummary):
profile_id = profile.id
if profile_id is None:
return
new_id = self.profile_manager.duplicate_profile(profile_id)
@@ -535,10 +537,12 @@ class ManageProfilePage(QWidget):
self.load_profiles()
def delete_profile(self, profile: ProfileSummary | None=None) -> None:
if self.selected_profile_id is None and profile is None:
return
profile_id = self.selected_profile_id
if isinstance(profile, ProfileSummary):
profile_id = profile.id
if profile_id is None:
return
answer = QMessageBox.question(
self,
@@ -548,8 +552,7 @@ class ManageProfilePage(QWidget):
QMessageBox.StandardButton.No,
)
if answer == QMessageBox.StandardButton.Yes:
if self.profile_manager.remove_profile(profile_id):
self.selected_profile_id = None
self.profile_manager.remove_profile(profile_id)
def add_page(self, page_name: str, page: QScrollArea) -> Callable[[], None]:
"""Add a plugin tab and return an idempotent cleanup callback."""
+18 -15
View File
@@ -38,7 +38,7 @@ class _ProcessSignals(QObject):
output = Signal(str, object)
# Windows may return an unsigned 32-bit exit code (for example
# 0xFFFFFFFF), which does not fit in Qt's signed Signal(int).
finished = Signal(object)
finished = Signal(object, bool)
read_failed = Signal(str)
@@ -51,13 +51,14 @@ class ProcessLogWindow(QMainWindow):
LOG_TRIM_LINES = 10_000
def __init__(self, app, process: subprocess.Popen, profile_id: str, title: str = "Game Log",
parent: QWidget | None = None, finished_callback: Callable[[str, int], None]=None) -> None:
parent: QWidget | None = None, finished_callback: Callable[[str, int], None] | None = None) -> None:
super().__init__(parent)
self.app = app
self.process = process
self.profile_id = profile_id
self._signals = _ProcessSignals(self)
self._last_error_message: str | None = None
self._killed_by_user = False
self.lines: list[tuple[str, str]] = [] # type, message
self._trimmed_line_count = 0
self._stderr_lines: deque[str] = deque(maxlen=500)
@@ -240,7 +241,7 @@ class ProcessLogWindow(QMainWindow):
exit_code = self._normalize_exit_code(self.process.wait())
self._stdout_reader.join()
self._stderr_reader.join()
self._signals.finished.emit(exit_code)
self._signals.finished.emit(exit_code, self._killed_by_user)
@staticmethod
def _normalize_exit_code(exit_code: int) -> int:
@@ -251,17 +252,17 @@ class ProcessLogWindow(QMainWindow):
def kill_process(self) -> None:
if self.process.poll() is not None:
self._process_finished(
self._normalize_exit_code(self.process.returncode or 0)
)
# The waiter reports completion after both output streams are drained.
return
self.kill_button.setEnabled(False)
self.status_label.setText(self.app.tr_text("Killing process..."))
try:
self._killed_by_user = True
self.process.kill()
except Exception as exc:
self._killed_by_user = False
self.kill_button.setEnabled(True)
self.status_label.setText(self.app.tr_text("Unable to kill process"))
self.append_message(f"[launcher] Unable to kill process: {exc}")
@@ -303,7 +304,8 @@ class ProcessLogWindow(QMainWindow):
self.app.tr_text("Unable to save log file: {error}", error=exc),
)
def _process_finished(self, exit_code: int) -> None:
@Slot(object, bool)
def _process_finished(self, exit_code: int, killed_by_user: bool = False) -> None:
self.kill_button.setEnabled(False)
self.status_label.setText(self.app.tr_text(
"Process exited with code {exit_code}", exit_code=exit_code
@@ -311,11 +313,16 @@ class ProcessLogWindow(QMainWindow):
self.append_message(f"[launcher] Process exited with code {exit_code}.")
if exit_code != 0 and self._last_error_message:
self.append_message(
f"[launcher] Last error: {self._last_error_message}"
)
if not killed_by_user:
self.append_message(
f"[launcher] Last error: {self._last_error_message}"
)
else:
self.append_message(
"[launcher] " + self.app.tr_text("Process interrupted by user")
)
if exit_code != 0:
if exit_code != 0 and not killed_by_user:
error_content = "\n".join(self._stderr_lines)
if not error_content:
error_content = (
@@ -337,10 +344,6 @@ class ProcessLogWindow(QMainWindow):
def _read_failed(self, message: str) -> None:
self.append_message(f"[launcher] Unable to read process output: {message}")
if self.process.poll() is not None:
self._process_finished(
self._normalize_exit_code(self.process.returncode or 0)
)
def closeEvent(self, event: QCloseEvent) -> None:
# Closing the log window must not stop the game. The process remains
+161 -34
View File
@@ -19,17 +19,32 @@ from PySide6.QtWidgets import (
from constant import LAUNCHER_NAME, LAUNCHER_VERSION, LAUNCHER_DESCRIPTION_KEYWORD, \
LAUNCHER_DESCRIPTION_MARKDOWN, LAUNCHER_DESCRIPTION_MARKDOWN_KEYWORD
from core_lib.qt import messagebox
from manager.settings_models import AccountSettings, AppearanceSettings, GeneralSettings, GameSettings
from manager.settings_models import AccountSettings, AppearanceSettings, GeneralSettings, GameSettings, PageBarSettings
from pages.plugins import PluginsDialog
LANGUAGE_LABELS = {
"en": "English",
"zh-TW": "Chinese (Traditional)",
}
POSITION_LABELS = {
"left": "Left",
"right": "Right",
"top": "Top",
"bottom": "Bottom",
}
CREDENTIALS_SAVE_METHODS = {
"system-keyring": "Use system keyring",
"file": "Save as a regular file",
}
COMPATIBILITY_MODE_LABELS = {
"none": "Disabled",
"official-launcher": "Minecraft Launcher",
}
LAUNCH_ACTION_LABELS = {
"close": "Close launcher window",
"stay-open": "Keep launcher open",
"minimize": "Minimize launcher window",
}
class SettingsItem(QPushButton):
@@ -79,7 +94,6 @@ class SettingsSubPage(QWidget):
header_layout.addStretch()
self.content_layout = QVBoxLayout()
self.content_layout.setSpacing(12)
main_layout.addLayout(header_layout)
self.content_layout.setContentsMargins(0, 0, 0, 0)
self.content_layout.setSpacing(6)
@@ -89,6 +103,17 @@ class SettingsSubPage(QWidget):
main_layout.addLayout(self.content_layout)
main_layout.addStretch()
def add_section_title(self, title: str) -> None:
if self.content_layout.count():
self.content_layout.addSpacing(16)
label = QLabel(title)
label.setObjectName("settingsSectionTitle")
font = label.font()
font.setPointSize(12)
font.setBold(True)
label.setFont(font)
self.content_layout.addWidget(label)
class SettingsPage(QWidget):
def __init__(self, app, parent=None) -> None:
@@ -194,7 +219,7 @@ class SettingsPage(QWidget):
pages = (
(tr("General"), tr("Language and launcher directories"), "general_page"),
(tr("Game"), tr("Game file hash verification"), "game_page"),
(tr("Game"), tr("Game downloading and launching configuration"), "game_page"),
(tr("Appearance"), tr("Launcher theme"), "appearance_page"),
(tr("Account"), tr("Microsoft authentication settings"), "account_page"),
(tr("About"), tr("Version and project information"), "about_page"),
@@ -226,7 +251,9 @@ class SettingsPage(QWidget):
tr = self.app.tr_text
page = SettingsSubPage(tr("General"), self._go_back)
current = self.settings.get("general", GeneralSettings)
pagebar_setting = self.settings.get("page-bar", PageBarSettings)
page.add_section_title(tr("Environment Information"))
page.content_layout.addWidget(QLabel(tr("Current launcher working directory")))
launcher_dir = QLineEdit(self.app.work_dir.as_posix())
launcher_dir.setReadOnly(True)
@@ -237,25 +264,75 @@ class SettingsPage(QWidget):
program_dir.setReadOnly(True)
page.content_layout.addWidget(program_dir)
page.content_layout.addSpacing(8)
page.content_layout.addWidget(QLabel(tr("Language")))
page.content_layout.addWidget(QLabel(tr("Current game directory")))
program_dir = QLineEdit(self.app.game_dir.as_posix())
program_dir.setReadOnly(True)
page.content_layout.addWidget(program_dir)
page.add_section_title(tr("Language"))
self.language_combo = self._choice_combo(
"general", "language", LANGUAGE_LABELS, current.language
)
page.content_layout.addWidget(self.language_combo)
page.add_section_title(tr("PageBar"))
self.reset_to_last_used_page = QCheckBox(tr("Reset to last used page"))
self.reset_to_last_used_page.setChecked(pagebar_setting.focus_at_after_restart)
self.reset_to_last_used_page.toggled.connect(
self._mark_settings_dirty
)
page.content_layout.addWidget(self.reset_to_last_used_page)
page.content_layout.addSpacing(2)
page.content_layout.addWidget(QLabel(tr("Position")))
self.pagebar_position_combo = self._choice_combo(
"page-bar", "page_bar_position", POSITION_LABELS, pagebar_setting.page_bar_position
)
self.pagebar_position_combo.currentIndexChanged.connect(
self._mark_settings_dirty
)
page.content_layout.addWidget(self.pagebar_position_combo)
page.content_layout.addSpacing(2)
page.add_section_title(tr("Compatibility Mode"))
self.compatibility_mode_combo = self._choice_combo(
"general", "compatibility_mode", COMPATIBILITY_MODE_LABELS, current.compatibility_mode
)
self.compatibility_mode_combo.currentIndexChanged.connect(
self._mark_settings_dirty
)
page.content_layout.addWidget(self.compatibility_mode_combo)
page.content_layout.addSpacing(2)
return page
def _create_game_page(self) -> QWidget:
tr = self.app.tr_text
page = SettingsSubPage(tr("Game"), self._go_back)
current = self.settings.get("game", GameSettings)
page.add_section_title(tr("Download"))
self.verify_hash_on_download = QCheckBox(tr("Verify file hashes when downloading"))
self.verify_hash_on_download.setChecked(current.verify_hash_on_download)
self.verify_hash_on_download.toggled.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.verify_hash_on_download)
page.add_section_title(tr("Game Launching"))
self.verify_hash_on_launch = QCheckBox(tr("Verify library hashes before launch"))
self.verify_hash_on_launch.setChecked(current.verify_hash_on_launch)
for checkbox in (self.verify_hash_on_download, self.verify_hash_on_launch):
checkbox.toggled.connect(self._mark_settings_dirty)
page.content_layout.addWidget(checkbox)
self.verify_hash_on_launch.toggled.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.verify_hash_on_launch)
self.open_log_view_when_launch = QCheckBox(tr("Open game log when launching"))
self.open_log_view_when_launch.setChecked(current.open_log_view_when_launch)
self.open_log_view_when_launch.toggled.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.open_log_view_when_launch)
page.content_layout.addWidget(QLabel(tr("After game launch")))
self.action_after_launch = self._choice_combo(
"game", "action_after_launch", LAUNCH_ACTION_LABELS, current.action_after_launch
)
self.action_after_launch.currentIndexChanged.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.action_after_launch)
return page
def _create_appearance_page(self) -> QWidget:
@@ -263,7 +340,8 @@ class SettingsPage(QWidget):
page = SettingsSubPage(tr("Appearance"), self._go_back)
current = self.settings.get("appearance", AppearanceSettings)
page.content_layout.addWidget(QLabel(tr("Theme")))
# Theme
page.add_section_title(tr("Theme"))
self.theme_combo = QComboBox()
for theme_id, name in self.app.available_themes().items():
self.theme_combo.addItem(tr(name), theme_id)
@@ -279,7 +357,9 @@ class SettingsPage(QWidget):
help_label.setObjectName("settingsHelpText")
help_label.setWordWrap(True)
page.content_layout.addWidget(help_label)
page.content_layout.addWidget(QLabel(tr("Launch page background")))
# Launch game page background
page.add_section_title(tr("Launch page background"))
self.launch_background = current.launch_background
self.background_preview = QLabel()
self.background_preview.setFixedSize(320, 180)
@@ -345,6 +425,24 @@ class SettingsPage(QWidget):
page = SettingsSubPage(tr("Account"), self._go_back)
current = self.settings.get("account", AccountSettings)
# TokeUpdater
page.add_section_title(tr("TokenUpdater"))
self.enable_token_updater_checkbox = QCheckBox(tr("Enable token updater"))
page.content_layout.addWidget(self.enable_token_updater_checkbox)
page.content_layout.addWidget(QLabel(tr("Token refresh check interval")))
self.token_refresh_interval = QSpinBox()
self.token_refresh_interval.setRange(1, 1440) # minutes
self.token_refresh_interval.setSingleStep(1)
self.token_refresh_interval.setSuffix(
" " + tr("minutes")
)
self.token_refresh_interval.setValue(current.token_refresh_interval // 60)
self.token_refresh_interval.valueChanged.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.token_refresh_interval)
page.add_section_title(tr("Custom"))
page.content_layout.addWidget(QLabel(tr("Credentials save method")))
self.credentials_save_method = self._choice_combo(
"account", "credentials_save_method", CREDENTIALS_SAVE_METHODS,
@@ -372,22 +470,6 @@ class SettingsPage(QWidget):
))
help_label.setObjectName("settingsHelpText")
help_label.setWordWrap(True)
page.content_layout.addWidget(
QLabel(tr("Token refresh check interval"))
)
self.token_refresh_interval = QSpinBox()
self.token_refresh_interval.setRange(1, 1440) # minutes
self.token_refresh_interval.setSingleStep(1)
self.token_refresh_interval.setSuffix(
" " + tr("minutes")
)
self.token_refresh_interval.setValue(current.token_refresh_interval // 60)
self.token_refresh_interval.valueChanged.connect(self._mark_settings_dirty)
page.content_layout.addWidget(self.token_refresh_interval)
page.content_layout.addWidget(help_label)
return page
@@ -455,7 +537,7 @@ class SettingsPage(QWidget):
previous_credentials_method = (
self.settings
.get("account", AccountSettings)
.credentials_save_method # sec
.credentials_save_method # sec
)
previous_token_refresh_interval = (
@@ -463,22 +545,45 @@ class SettingsPage(QWidget):
.token_refresh_interval
)
previous_page_bar_position = (
self.settings.get("page-bar", PageBarSettings)
.page_bar_position
)
previous_compatibility_mode = (
self.settings.get("general", GeneralSettings)
.compatibility_mode
)
current_token_refresh_interval = (
self.token_refresh_interval.value() * 60 # minutes to seconds
self.token_refresh_interval.value() * 60 # minutes to seconds
)
selected_credentials_method = (
self.credentials_save_method.currentData()
)
current_page_bar_position = self.pagebar_position_combo.currentData()
current_compatibility_mode = self.compatibility_mode_combo.currentData()
credentials_method_changed = (
previous_credentials_method
!= selected_credentials_method
)
token_refresh_interval_changed = (
previous_token_refresh_interval
!= current_token_refresh_interval
previous_token_refresh_interval
!= current_token_refresh_interval
)
previous_page_bar_position_changed = (
previous_page_bar_position
!= current_page_bar_position
)
compatibility_mode_changed = (
previous_compatibility_mode
!= current_compatibility_mode
)
client_id = self.client_id_edit.text().strip()
@@ -502,9 +607,16 @@ class SettingsPage(QWidget):
old_theme = self.settings.get("appearance", AppearanceSettings).theme
data = {
"general": {"language": self.language_combo.currentData()},
"general": {"language": self.language_combo.currentData(),
"compatibility_mode": current_compatibility_mode},
"page-bar": {
"page_bar_position": current_page_bar_position,
"focus_at_after_restart": self.reset_to_last_used_page.isChecked()
},
"game": {"verify_hash_on_download": self.verify_hash_on_download.isChecked(),
"verify_hash_on_launch": self.verify_hash_on_launch.isChecked()},
"verify_hash_on_launch": self.verify_hash_on_launch.isChecked(),
"open_log_view_when_launch": self.open_log_view_when_launch.isChecked(),
"action_after_launch": self.action_after_launch.currentData()},
"appearance": {"theme": self.theme_combo.currentData(),
"launch_background": self.launch_background},
"account": {"custom_client_id": client_id if client_id else None,
@@ -557,10 +669,25 @@ class SettingsPage(QWidget):
QMessageBox.critical(self, self.app.tr_text("Settings error"), str(error))
return False
if old_theme !=self.settings.get("appearance", AppearanceSettings).theme:
if old_theme != self.settings.get("appearance", AppearanceSettings).theme:
messagebox.info(None, "Launcher",
self.app.tr_text("To make all page apply new theme."
" Is recommend to restart the launcher after change it."))
" Is recommend to restart the launcher after change it."))
if previous_page_bar_position_changed:
main_window = getattr(self.app, "main_window")
if main_window:
main_window.apply_page_bar_settings()
if compatibility_mode_changed:
messagebox.info(
None,
"Launcher",
self.app.tr_text(
"Compatibility mode changed. Please restart the launcher to apply the changes."
)
)
self._settings_dirty = False
selected_language = data["general"]["language"]
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "testlauncher"
version = "0.1.6a1"
version = "0.1.7a0"
description = "A lightweight Minecraft launcher."
readme = "README.md"
requires-python = ">=3.10"
@@ -2,6 +2,6 @@ group = "net.wei"
id = "offline-support"
name = "Offline Support"
version = "1.1.0"
api_version = ">=0.0.1"
api_version = ">=0.0.3"
entrypoint = "__init__.py:setup"
description = "Adds offline accounts after at least one Microsoft account is signed in."
+8 -6
View File
@@ -52,8 +52,7 @@ QPushButton#profileItem QLabel[itemHovered="true"] {
background: transparent;
}
QPushButton#launchButton {
min-width: 150px;
QPushButton#launchButton, QPushButton#logButton {
font-size: 15px;
font-weight: 600;
background-color: palette(button);
@@ -63,21 +62,21 @@ QPushButton#launchButton {
padding: 6px 14px;
}
QPushButton#launchButton:hover {
QPushButton#launchButton:hover, QPushButton#logButton:hover {
background-color: palette(midlight);
color: palette(button-text);
}
QPushButton#launchButton:focus {
QPushButton#launchButton:focus, QPushButton#logButton:focus {
border-color: palette(highlight);
}
QPushButton#launchButton:pressed {
QPushButton#launchButton:pressed, QPushButton#logButton:pressed {
background-color: palette(highlight);
color: palette(highlighted-text);
}
QPushButton#launchButton:disabled {
QPushButton#launchButton:disabled, QPushButton#logButton:disabled {
color: palette(placeholder-text);
}
@@ -91,3 +90,6 @@ QFrame#profileFrame {
border: 1px solid palette(mid);
border-radius: 10px;
}
QPushButton#launchButton { min-width: 150px; }
QPushButton#logButton { min-width: 0; padding-left: 0; padding-right: 0; }
+5 -3
View File
@@ -23,15 +23,17 @@ QPushButton#profileItem:hover {
background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #80b8f4,stop:1 #3875d7);
}
QPushButton#profileItem QLabel[itemHovered="true"] { color: #ffffff; background: transparent; }
QPushButton#launchButton {
min-width: 150px;
QPushButton#launchButton, QPushButton#logButton {
font-size: 15px;
font-weight: bold;
border-radius: 16px;
border-color: #3266ac;
background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #effaff,stop:0.45 #a7d0ff,stop:0.5 #649be5,stop:1 #c2e2ff);
}
QPushButton#launchButton:pressed { background: #79a5db; }
QPushButton#launchButton:pressed, QPushButton#logButton:pressed { background: #79a5db; }
QFrame#profileFrame { background: #dceaff; border: 1px solid #8fa8c9; border-radius: 12px; }
QFrame#header { background: rgba(245, 250, 255, 220); border: 1px solid #b6c9e3; border-radius: 8px; }
QLabel#headerLabel { color: #203653; background: transparent; font-size: 20px; font-weight: bold; }
QPushButton#launchButton { min-width: 150px; }
QPushButton#logButton { min-width: 0; padding-left: 0; padding-right: 0; }
+7 -5
View File
@@ -23,8 +23,7 @@ QPushButton#profileItem:hover {
background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #5286d4,stop:1 #316ac5);
}
QPushButton#profileItem QLabel[itemHovered="true"] { color: #ffffff; background: transparent; }
QPushButton#launchButton {
min-width: 150px;
QPushButton#launchButton, QPushButton#logButton {
font-size: 15px;
font-weight: bold;
color: #ffffff;
@@ -33,9 +32,9 @@ QPushButton#launchButton {
background: qlineargradient(x1:0,y1:0,x2:0,y2:1,
stop:0 #93d875,stop:0.15 #55ad39,stop:0.8 #31851e,stop:1 #246514);
}
QPushButton#launchButton:hover { border-color: #e59700; background: #4b9f2c; }
QPushButton#launchButton:pressed { background: #28691b; }
QPushButton#launchButton:disabled { color: #d9e3d5; background: #7b9472; }
QPushButton#launchButton:hover, QPushButton#logButton:hover { border-color: #e59700; background: #4b9f2c; }
QPushButton#launchButton:pressed, QPushButton#logButton:pressed { background: #28691b; }
QPushButton#launchButton:disabled, QPushButton#logButton:disabled { color: #d9e3d5; background: #7b9472; }
QFrame#profileFrame { background: #dceaff; border: 1px solid #8fa8c9; border-radius: 3px; }
QFrame#header {
background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 #5794f5,stop:0.18 #2879ed,stop:1 #0053cf);
@@ -43,3 +42,6 @@ QFrame#header {
border-radius: 5px;
}
QLabel#headerLabel { color: #ffffff; background: transparent; font-size: 20px; font-weight: bold; }
QPushButton#launchButton { min-width: 150px; }
QPushButton#logButton { min-width: 0; padding-left: 0; padding-right: 0; }
@@ -17,8 +17,7 @@ QPushButton#profileItem {
QPushButton#profileItem:hover { background: #3c8527; }
QPushButton#profileItem:focus { border-color: #a0e081; }
QPushButton#profileItem QLabel[itemHovered="true"] { color: #ffffff; background: transparent; }
QPushButton#launchButton {
min-width: 150px;
QPushButton#launchButton, QPushButton#logButton {
min-height: 32px;
font-size: 18px;
font-weight: bold;
@@ -29,10 +28,13 @@ QPushButton#launchButton {
border-bottom: 5px solid #1d4d13;
border-radius: 0;
}
QPushButton#launchButton:hover { background: #4f9f30; }
QPushButton#launchButton:pressed { background: #2f6b1f; border-top-color: #1d4d13; border-bottom-color: #3c8527; }
QPushButton#launchButton:focus { border-left-color: #b5f293; border-right-color: #b5f293; }
QPushButton#launchButton:disabled { background: #3c3c3c; color: #858585; border-color: #505050; }
QPushButton#launchButton:hover, QPushButton#logButton:hover { background: #4f9f30; }
QPushButton#launchButton:pressed, QPushButton#logButton:pressed { background: #2f6b1f; border-top-color: #1d4d13; border-bottom-color: #3c8527; }
QPushButton#launchButton:focus, QPushButton#logButton:focus { border-left-color: #b5f293; border-right-color: #b5f293; }
QPushButton#launchButton:disabled, QPushButton#logButton:disabled { background: #3c3c3c; color: #858585; border-color: #505050; }
QFrame#profileFrame { background: #202020; border: 1px solid #505050; border-radius: 0; }
QFrame#header { background: #202020; border-bottom: 1px solid #505050; }
QLabel#headerLabel { color: #ffffff; background: transparent; font-size: 22px; font-weight: bold; }
QPushButton#launchButton { min-width: 150px; }
QPushButton#logButton { min-width: 0; padding-left: 0; padding-right: 0; }
@@ -21,7 +21,10 @@ QPushButton#profileItem {
}
QPushButton#profileItem:hover { background: #000080; }
QPushButton#profileItem QLabel[itemHovered="true"] { color: #ffffff; background: transparent; }
QPushButton#launchButton { min-width: 150px; font-size: 14px; font-weight: bold; }
QPushButton#launchButton, QPushButton#logButton { font-size: 14px; font-weight: bold; }
QFrame#profileFrame { background: #008080; border: 2px inset #c0c0c0; border-radius: 0; }
QFrame#header { background: #000080; border: 0; }
QLabel#headerLabel { color: #ffffff; background: transparent; font-size: 18px; font-weight: bold; }
QPushButton#launchButton { min-width: 150px; }
QPushButton#logButton { min-width: 0; padding-left: 0; padding-right: 0; }
+38 -3
View File
@@ -1,4 +1,10 @@
{
"Settings Error": "Settings Error",
"Open game log when launching": "Open game log when launching",
"After game launch": "After game launch",
"Close launcher window": "Close launcher window",
"Keep launcher open": "Keep launcher open",
"Minimize launcher window": "Minimize launcher window",
"Image file does not exist or is not a file": "Image file does not exist or is not a file",
"Unable to set profile icon. Icon may invalid.": "Unable to set profile icon. The icon may be invalid.",
"Launch page background": "Launch page background",
@@ -11,7 +17,7 @@
"Image format is not supported.": "Image format is not supported.",
"Select a profile before replacing the icon": "Select a profile before replacing the icon",
"Game": "Game",
"Game file hash verification": "Game file hash verification",
"Game downloading and launching configuration": "Game downloading and launching configuration",
"Verify file hashes when downloading": "Verify file hashes when downloading",
"Verify library hashes before launch": "Verify library hashes before launch",
"OK": "OK",
@@ -98,7 +104,10 @@
"Current": "Current",
"Current launcher working directory": "Current launcher working directory",
"Current program directory": "Current program directory",
"Current game directory": "Current game directory",
"Current version: {version}": "Current version: {version}",
"Compatibility Mode": "Compatibility Mode",
"Minecraft Launcher": "Minecraft Launcher",
"Dark": "Dark",
"Default": "Default",
"Delete": "Delete",
@@ -129,6 +138,7 @@
"Game directory": "Game directory",
"Game Log": "Game Log",
"General": "General",
"Toolbar": "Toolbar",
"Home": "Home",
"Icon": "Icon",
"Import Mods": "Import Mods",
@@ -154,7 +164,6 @@
"Launched!": "Launched!",
"Launcher error occurred.": "Launcher error occurred.",
"Launcher theme": "Launcher theme",
"Minecraft Launcher": "Minecraft Launcher",
"Light": "Light",
"Loading all types...": "Loading all types...",
"Loading all versions...": "Loading all versions...",
@@ -418,5 +427,31 @@
"{account}'s session has expired.": "{account}'s session has expired.",
"Plugins can run code on your computer and access your files and account data. Only enable plugins from sources you trust.": "Plugins can run code on your computer and access your files and account data. Only enable plugins from sources you trust.",
"$ABOUT_THIS_LAUNCHER": "<ORIGINAL>",
"$ABOUT_THIS_LAUNCHER_MARKDOWN": "<ORIGINAL>"
"$ABOUT_THIS_LAUNCHER_MARKDOWN": "<ORIGINAL>",
"Download": "Download",
"Enable token updater": "Enable token updater",
"Environment Information": "Environment Information",
"Game Launching": "Game Launching",
"Multiple log views (among {count} windows) are running for profile {profile}. Are you sure you want to open all log view?": "Multiple log views (among {count} windows) are running for profile {profile}. Are you sure you want to open all log view?",
"PageBar": "PageBar",
"Position": "Position",
"Reset to last used page": "Reset to last used page",
"Show game log": "Show game log",
"Time out waiting for request for open window.": "Time out waiting for request for open window.",
"TokenUpdater": "TokenUpdater",
"Left": "Left",
"Right": "Right",
"Top": "Top",
"Bottom": "Bottom",
"Process interrupted by user": "Process interrupted by user",
"Some settings contain invalid values:": "Some settings contain invalid values:",
"The settings file contains invalid TOML syntax.": "The settings file contains invalid TOML syntax.",
"The settings file could not be read.\nCheck that the file exists and that you have permission to read it.": "The settings file could not be read.\nCheck that the file exists and that you have permission to read it.",
"An unexpected error prevented the settings from loading.": "An unexpected error prevented the settings from loading.",
"Settings could not be loaded. Default settings are now in use.\nThe original settings file will not be overwritten.\nSettings changes made during this session will not be saved.": "Settings could not be loaded. Default settings are now in use.\nThe original settings file will not be overwritten.\nSettings changes made during this session will not be saved.",
"Settings file: {path}": "Settings file: {path}",
"Correct the settings file and restart the launcher to try again.": "Correct the settings file and restart the launcher to try again.",
"Raw details (Python traceback)": "Raw details (Python traceback)",
"Reset Icon": "Reset Icon",
"This image exceeds 128 x 128 pixels and will be resized to 128 x 128.": "This image exceeds 128 x 128 pixels and will be resized to 128 x 128."
}
+36 -3
View File
@@ -1,4 +1,10 @@
{
"Settings Error": "設定錯誤",
"Open game log when launching": "啟動遊戲時開啟日誌",
"After game launch": "遊戲啟動後",
"Close launcher window": "關閉啟動器視窗",
"Keep launcher open": "保持啟動器開啟",
"Minimize launcher window": "最小化啟動器視窗",
"Reset Icon": "重設圖示",
"Profile icons must be square and at least 128 x 128 pixels.": "不支援此圖片:設定檔圖示必須是正方形,且尺寸至少為 128×128 像素。",
"This image exceeds 128 x 128 pixels and will be resized to 128 x 128.": "此圖片超過 128×128 像素,將縮小為 128×128。",
@@ -15,7 +21,7 @@
"Image format is not supported.": "圖片格式不支援或檔案已損壞。",
"Select a profile before replacing the icon": "請先選取要替換圖示的設定檔",
"Game": "遊戲",
"Game file hash verification": "遊戲檔案雜湊驗證",
"Game downloading and launching configuration": "遊戲檔案下載與啟動設定",
"Verify file hashes when downloading": "下載時驗證檔案雜湊",
"Verify library hashes before launch": "啟動前驗證函式庫雜湊",
"OK": "確定",
@@ -101,6 +107,9 @@
"Current": "目前使用",
"Current launcher working directory": "目前啟動器工作目錄",
"Current program directory": "目前程式目錄",
"Current game directory": "目前遊戲目錄",
"Compatibility Mode": "相容性模式",
"Minecraft Launcher": "Minecraft Launcher",
"Current version: {version}": "目前版本:{version}",
"Dark": "深色",
"Default": "預設",
@@ -132,6 +141,7 @@
"Game directory": "遊戲目錄",
"Game Log": "遊戲記錄",
"General": "一般",
"Toolbar": "工具列",
"Home": "首頁",
"Icon": "圖示",
"Import Mods": "匯入模組",
@@ -157,7 +167,6 @@
"Launched!": "已啟動!",
"Launcher error occurred.": "啟動器發生錯誤。",
"Launcher theme": "啟動器佈景主題",
"Minecraft Launcher": "Minecraft 官方啟動器風格",
"Light": "淺色",
"Loading all types...": "正在載入所有類型……",
"Loading all versions...": "正在載入所有版本……",
@@ -422,5 +431,29 @@
"{account} is currently signed in.": "{account} 目前已登入。",
"{account}'s session has expired.": "{account} 的工作階段已過期。",
"$ABOUT_THIS_LAUNCHER": "一個使用Python編寫的非官方 Minecraft 啟動器。旨在與官方啟動器保持最大程度的兼容,同時更加輕量且易於使用。\n\n本啟動器和 Mojang 工作室 或 Microsoft 沒有任何隸屬關係。只是一個為了好玩而開發的專案。",
"$ABOUT_THIS_LAUNCHER_MARKDOWN": "一個使用Python編寫的非官方 Minecraft 啟動器。\n旨在與官方啟動器保持最大程度的兼容,同時更加輕量且易於使用。\n\n\n*本啟動器和 Mojang 工作室 或 Microsoft 沒有任何隸屬關係。只是一個為了好玩而開發的專案。*\n\n\n\n### 鳴謝\n- [PySide6](https://pypi.org/project/PySide6/): GUI 框架\n- [Nuitka](https://nuitka.net/): 構建工具\n- [Minecraft Wiki](https://minecraft.wiki/): 帳號系統和啟動器開發參考 ([Writing a launcher](https://zh.minecraft.wiki/w/Tutorial:%E7%BC%96%E5%86%99%E5%90%AF%E5%8A%A8%E5%99%A8))\n\n\n### 開發者\n- [Wei](https://repo.weispace.net/wei): 主要開發者"
"$ABOUT_THIS_LAUNCHER_MARKDOWN": "一個使用Python編寫的非官方 Minecraft 啟動器。\n旨在與官方啟動器保持最大程度的兼容,同時更加輕量且易於使用。\n\n\n*本啟動器和 Mojang 工作室 或 Microsoft 沒有任何隸屬關係。只是一個為了好玩而開發的專案。*\n\n\n\n### 鳴謝\n- [PySide6](https://pypi.org/project/PySide6/): GUI 框架\n- [Nuitka](https://nuitka.net/): 構建工具\n- [Minecraft Wiki](https://minecraft.wiki/): 帳號系統和啟動器開發參考 ([Writing a launcher](https://zh.minecraft.wiki/w/Tutorial:%E7%BC%96%E5%86%99%E5%90%AF%E5%8A%A8%E5%99%A8))\n\n\n### 開發者\n- [Wei](https://repo.weispace.net/wei): 主要開發者",
"Download": "下載",
"Enable token updater": "啟用權杖自動更新",
"Environment Information": "環境資訊",
"Game Launching": "遊戲啟動",
"Multiple log views (among {count} windows) are running for profile {profile}. Are you sure you want to open all log view?": "啟動設定檔 {profile} 有 {count} 個日誌視窗。確定要開啟全部日誌視窗嗎?",
"PageBar": "頁面列",
"Position": "位置",
"Reset to last used page": "啟動時還原上次使用的頁面",
"Show game log": "顯示遊戲日誌",
"Time out waiting for request for open window.": "等待開啟視窗的確認已逾時。",
"TokenUpdater": "權杖自動更新",
"Left": "左側",
"Right": "右側",
"Top": "上方",
"Bottom": "下方",
"Process interrupted by user": "使用者已中止程序",
"Some settings contain invalid values:": "下列設定值無效:",
"The settings file contains invalid TOML syntax.": "設定檔的 TOML 語法有誤。",
"The settings file could not be read.\nCheck that the file exists and that you have permission to read it.": "無法讀取設定檔。\n請確認檔案存在,且您具有讀取權限。",
"An unexpected error prevented the settings from loading.": "載入設定時發生未預期的錯誤。",
"Settings could not be loaded. Default settings are now in use.\nThe original settings file will not be overwritten.\nSettings changes made during this session will not be saved.": "設定無法載入,目前使用預設值。\n原始設定檔不會被覆寫。\n本次執行期間的設定變更不會儲存。",
"Settings file: {path}": "設定檔:{path}",
"Correct the settings file and restart the launcher to try again.": "請修正設定檔,再重新啟動啟動器。",
"Raw details (Python traceback)": "原始資訊(Python traceback)"
}
+20 -4
View File
@@ -326,6 +326,7 @@ class LauncherMainWindow(QMainWindow):
# Apply page bar settings
self.apply_page_bar_settings()
self.apply_stacked_page()
self.toolbar.position_changed.connect(self.save_page_bar_position)
# Bind signal event
@@ -692,13 +693,28 @@ class LauncherMainWindow(QMainWindow):
return Path(selected) if selected else None
def apply_page_bar_settings(self):
"""
Apply page bar settings. (Such as page bar position)
:return:
"""
settings = self.app.settings_manager.get("page-bar", PageBarSettings)
self.addToolBar(self.page_bar_areas[settings.page_bar_position], self.toolbar)
self.toolbar.update_all()
focus = settings.focus_at_after_restart or settings.last_focused_page
self._pending_page_button = focus
button = self.toolbar.buttons.get(focus, self.home_button)
self.set_current_page(button.page, button, persist=False)
def apply_stacked_page(self):
"""
Apply page bar settings. (Such as change focus page to last focused page)
:return:
"""
settings = self.app.settings_manager.get("page-bar", PageBarSettings)
last_focused_page = settings.last_focused_page
focus_button = self.home_button
if settings.focus_at_after_restart:
focus_button = self.toolbar.buttons.get(last_focused_page,
self.home_button)
self._pending_page_button = focus_button
self.set_current_page(focus_button.page, focus_button, persist=False)
page_bar_areas = {
"left": Qt.ToolBarArea.LeftToolBarArea,