From b7af7e34691fa952b1ebb23c33be6248b1231774 Mon Sep 17 00:00:00 2001 From: wei Date: Sun, 18 Oct 2026 23:58:43 +0800 Subject: [PATCH] Add customize qss support for theme. Fix an issue that causes all feature flags will not be added to the launch command regardless of it is enabled. Add some default themes. --- README.md | 118 ++++++++- app.py | 36 ++- core_lib/common/common.py | 4 +- core_lib/common/exception.py | 8 +- core_lib/game/account.py | 3 + core_lib/game/argument.py | 163 ++++++++++-- core_lib/game/authentication.py | 40 ++- core_lib/qt/messagebox.py | 1 + core_lib/qt/progress_dialog.py | 7 +- manager/account.py | 21 +- manager/game.py | 6 +- pages/launch_profile.py | 6 +- pages/manage_profile.py | 3 +- pages/process_log.py | 71 +----- pages/settings.py | 9 +- pages/test.py | 17 +- resources/icons/plugin.png | Bin 0 -> 4025 bytes resources/styles/manage_profile.qss | 5 + resources/styles/process_log.qss | 65 +++++ resources/styles/profile.qss | 12 + resources/styles/progress_dialog.qss | 3 + resources/styles/test.qss | 3 + resources/themes/README.md | 41 ++++ resources/themes/aqua/palette.toml | 14 ++ resources/themes/aqua/styles/login_dialog.qss | 7 + resources/themes/aqua/styles/main.qss | 83 +++++++ .../themes/aqua/styles/manage_profile.qss | 20 ++ resources/themes/aqua/styles/process_log.qss | 8 + resources/themes/aqua/styles/profile.qss | 37 +++ resources/themes/aqua/styles/settings.qss | 22 ++ resources/themes/aqua/styles/toolbar.qss | 23 ++ resources/themes/aqua/theme.toml | 1 + resources/themes/dark/palette.toml | 14 ++ resources/themes/dark/theme.toml | 1 + resources/themes/forest-moss/palette.toml | 14 ++ resources/themes/forest-moss/theme.toml | 1 + resources/themes/light/palette.toml | 14 ++ resources/themes/light/theme.toml | 1 + resources/themes/ocean-night/palette.toml | 14 ++ resources/themes/ocean-night/theme.toml | 1 + resources/themes/solarized-sand/palette.toml | 14 ++ resources/themes/solarized-sand/theme.toml | 1 + resources/themes/windows-9x/palette.toml | 14 ++ .../themes/windows-9x/styles/login_dialog.qss | 23 ++ resources/themes/windows-9x/styles/main.qss | 106 ++++++++ .../windows-9x/styles/manage_profile.qss | 24 ++ .../themes/windows-9x/styles/process_log.qss | 23 ++ .../themes/windows-9x/styles/profile.qss | 27 ++ .../themes/windows-9x/styles/settings.qss | 36 +++ .../themes/windows-9x/styles/toolbar.qss | 29 +++ resources/themes/windows-9x/theme.toml | 1 + resources/translations/zh-TW.json.bak | 232 ++++++++++++++++++ window.py | 2 +- 53 files changed, 1319 insertions(+), 130 deletions(-) create mode 100644 resources/icons/plugin.png create mode 100644 resources/styles/process_log.qss create mode 100644 resources/styles/progress_dialog.qss create mode 100644 resources/styles/test.qss create mode 100644 resources/themes/README.md create mode 100644 resources/themes/aqua/palette.toml create mode 100644 resources/themes/aqua/styles/login_dialog.qss create mode 100644 resources/themes/aqua/styles/main.qss create mode 100644 resources/themes/aqua/styles/manage_profile.qss create mode 100644 resources/themes/aqua/styles/process_log.qss create mode 100644 resources/themes/aqua/styles/profile.qss create mode 100644 resources/themes/aqua/styles/settings.qss create mode 100644 resources/themes/aqua/styles/toolbar.qss create mode 100644 resources/themes/aqua/theme.toml create mode 100644 resources/themes/dark/palette.toml create mode 100644 resources/themes/dark/theme.toml create mode 100644 resources/themes/forest-moss/palette.toml create mode 100644 resources/themes/forest-moss/theme.toml create mode 100644 resources/themes/light/palette.toml create mode 100644 resources/themes/light/theme.toml create mode 100644 resources/themes/ocean-night/palette.toml create mode 100644 resources/themes/ocean-night/theme.toml create mode 100644 resources/themes/solarized-sand/palette.toml create mode 100644 resources/themes/solarized-sand/theme.toml create mode 100644 resources/themes/windows-9x/palette.toml create mode 100644 resources/themes/windows-9x/styles/login_dialog.qss create mode 100644 resources/themes/windows-9x/styles/main.qss create mode 100644 resources/themes/windows-9x/styles/manage_profile.qss create mode 100644 resources/themes/windows-9x/styles/process_log.qss create mode 100644 resources/themes/windows-9x/styles/profile.qss create mode 100644 resources/themes/windows-9x/styles/settings.qss create mode 100644 resources/themes/windows-9x/styles/toolbar.qss create mode 100644 resources/themes/windows-9x/theme.toml create mode 100644 resources/translations/zh-TW.json.bak diff --git a/README.md b/README.md index 65fdd7c..91fb8b6 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -# TestLauncher (TapLauncher) +# TapLauncher -# Still thinking about its name... # There's no stable branch because this project is still under development. +## How to use? -## How to use ? - -#### Below are this project dependencies. Install them before use the launcher. +#### Below are the project dependencies. Install them before use the launcher. * `git` : [Website](https://git-scm.com/) * `uv` : [Install Guide](https://docs.astral.sh/uv/getting-started/installation/) @@ -26,14 +24,118 @@ uv sync ``` 3. Run the launcher -> The launcher provide `--work-dir` argument to change working directory. (If not provided, launcher will use application directory) +> The launcher provide `--work-dir` argument to change the working directory. (If not provided, the launcher will use the application directory) ```bash uv run python main.py uv run python main.py --work-dir path_to_work_dir # With custom working directory ``` +### Themes + +You can customize the appearance of the launcher by adding a new theme to the `data/themes` under working directory. +Its `palette.toml` defines colors, and `styles/*.qss` customizes individual pages. +To create a variant, create a folder to `/data/themes/` and edit its `theme.toml`, palette, +and QSS files. Restart the launcher to discover the new theme. You can copy the built-in theme folder as the reference. +Missing QSS files use the default styles. See the [custom theme guide](resources/themes/README.md) for details. + ## Troubleshooting #### Unable to log in Microsoft account. Launcher throw error "Signing in to Minecraft services failed (HTTP 403). This account is not allowed to complete this step. Check Xbox privacy settings and account restrictions. Or check the client id has authorized to use Minecraft API." -Now this launcher have registered to Minecraft API. If you use custom client ID. Please make sure -its valid and registered to API system (If not, see [this](https://forms.cloud.microsoft/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR-ajEQ1td1ROpz00KtS8Gd5UNVpPTkVLNFVROVQxNkdRMEtXVjNQQjdXVC4u)) \ No newline at end of file +Now this launcher has registered to Minecraft API. If you use custom client ID. Please make sure + it is valid and registered to the API system (If not, see [this](https://forms.cloud.microsoft/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR-ajEQ1td1ROpz00KtS8Gd5UNVpPTkVLNFVROVQxNkdRMEtXVjNQQjdXVC4u)) + +### Missing Python packages (`ModuleNotFoundError`) + +Run `uv sync` from the project directory, then start the launcher with `uv run python main.py`. +This uses the project's environment instead of a separate system Python installation. +If the same module is still missing, include its name and the full traceback when reporting the issue. + +### Invalid working directory or permission errors + +If you see `Specified work directory "..." does not exist or is not a directory`, create the directory first. +Use a directory that your account can write to, and quote paths containing spaces: + +```bash +uv run python main.py --work-dir "path to an existing directory" +``` + +For `PermissionError`, `Unable to save version manifest`, or `Unable to save profile`, check the permissions +and available disk space for the working directory and any custom game directory. + +### Login session expired (`HTTP 401`) + +For `Authentication failed. Session may expire.` or a message saying the login session is invalid or expired, +sign in again from the account page and retry. If signing in still fails, check the accompanying server message. +For `HTTP 429`, wait before retrying; repeated login attempts can keep hitting the service's request limit. + +### Xbox account errors (`XErr`) + +The launcher displays an Xbox error code when the account needs additional setup: + +| Error code | Suggested action | +| --- | --- | +| `2148916233` | Sign in to Xbox and create an Xbox profile, then retry. | +| `2148916235` | Check whether Xbox Live is available for the account's country or region. | +| `2148916236` / `2148916237` | Complete the adult or age verification requested on the Xbox website. | +| `2148916238` | Ask an adult to add the child account to a Microsoft family and allow Xbox access. | + +### Connection, manifest, or download failures + +For `Unable to fetch version manifest`, `Unable to fetch asset manifest`, `Some files failed to download`, +or authentication connection/time-out errors: + +1. Check your internet connection and whether your proxy or firewall permits the launcher to connect. +2. Retry later if the remote service is temporarily unavailable. +3. If downloads or saves still fail, check available disk space and write permissions. +4. For a file hash mismatch, retry the download. If it repeats, include the affected file path and error details + when reporting the issue. + +### Java runtime missing or no longer available + +For `No compatible Java runtime found (required major version: ...)` or +`No Java executable found for major version ...`, install or register a Java runtime matching the major version +shown in the error using the launcher's Java settings. A different major version may not satisfy the requirement. +If you see `Some runtimes are no longer available after last check`, check whether Java was moved or removed, +then refresh the runtime list or register its new executable path. + +Links for available Java runtimes provider: +[Oracle](https://www.java.com/download/) +[Eclipse Temurin](https://adoptium.net/) +[Azul Zulu](https://www.azul.com/downloads/) +[Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) + +### No profile selected or profile data cannot be loaded + +For `There is no profile is selected. Please create one first.`, create a profile and select it before launching. +For `Unable to load profile` or a missing profile-key error, back up the profile data before attempting repairs. +Try creating a separate profile for the same game version to check whether the problem is limited to the original profile. + +### Game closes immediately after launch + +Check the Minecraft Log window for the error preceding the exit message. An exit code alone does not identify the cause. +If you changed the profile's Java arguments, try restoring those arguments to their previous values. +For a modded profile, try a separate vanilla profile for the same Minecraft version to help isolate the failure. + +### Collecting debug information + +Run the launcher from a terminal with debug logging enabled: + +```bash +uv run python main.py --debug --work-dir "path to an existing directory" +``` + +Use the same working directory as the failing session so that the launcher loads the same data. +When reporting a problem, include the launcher version, operating system, Minecraft version, steps to reproduce, +and the relevant terminal output or Minecraft Log messages. Remove any sensitive information such as access tokens, +refresh tokens, and sign-in codes before sharing logs. + +## Misc + +### TODO + +- [ ] Add support for installing Forge/Neoforge mod loader. +- [ ] Design the home page. +- [ ] Add more custom settings. +- [ ] Add a usage guide. +- [ ] Add download mod from third party website support. +- [ ] Add a simple plugin system, allows customizing launcher behavior such as adding a new page or button. diff --git a/app.py b/app.py index d2b58c1..a015dd5 100644 --- a/app.py +++ b/app.py @@ -12,7 +12,7 @@ except ModuleNotFoundError: # Python 3.10 from PySide6.QtCore import QSize from PySide6.QtGui import QIcon, QPixmap, QPalette, QColor -from PySide6.QtWidgets import QApplication, QStyle, QToolButton +from PySide6.QtWidgets import QApplication, QStyle, QToolButton, QWidget from constant import LAUNCHER_VERSION from core_lib.qt.hack import move_window_to_center, is_light_theme, \ @@ -241,6 +241,21 @@ class Launcher(QApplication, LauncherObject): def styles_path(self): return self.resources_dir / "styles" + def locate_styles_path(self, relative_path: Path | str) -> Path: + appearance = self.settings_manager.get("appearance", AppearanceSettings) + theme = getattr(self, "_active_theme", appearance.theme) + theme_directory = self._theme_packages().get(theme) + + if not theme_directory: + return self.styles_path / relative_path + + full_path = theme_directory / "styles" / relative_path + + if not full_path.is_file(): + return self.styles_path / relative_path + + return full_path + @property def built_in_themes_dir(self) -> Path: return self.resources_dir / "themes" @@ -250,7 +265,8 @@ class Launcher(QApplication, LauncherObject): return self.data_dir / "themes" def apply_qss(self, qss_relative_path: Path, apply_qss_callback: Callable[[str], None]) -> str: - full_path = self.styles_path / qss_relative_path + full_path = self.locate_styles_path(qss_relative_path) + if not full_path.exists(): messagebox.error( None, @@ -260,11 +276,14 @@ class Launcher(QApplication, LauncherObject): return "" try: - data = full_path.read_text() + data = full_path.read_text(encoding="utf-8") apply_qss_callback(data) + target = getattr(apply_qss_callback, "__self__", None) + if isinstance(target, QWidget): + target.setProperty("qssRelativePath", str(qss_relative_path)) except Exception as e: messagebox.error( - self.main_window, + None, self.tr_text("Resource Error"), self.tr_text( "Unable to apply QSS stylesheet {path}: {error}", @@ -297,6 +316,7 @@ class Launcher(QApplication, LauncherObject): appearance = self.settings_manager.get("appearance", AppearanceSettings) theme = appearance.theme + active_theme = theme if theme == "system": # Apply system palette palette = QPalette(self._system_palette) @@ -309,6 +329,7 @@ class Launcher(QApplication, LauncherObject): theme, ) palette = QPalette(self._system_palette) + active_theme = "system" else: try: self._read_theme_manifest(directory / "theme.toml") @@ -321,10 +342,17 @@ class Launcher(QApplication, LauncherObject): error, ) palette = QPalette(self._system_palette) + active_theme = "system" + self._active_theme = active_theme self.setPalette(palette) + # Application-wide styles also reach parentless dialogs and message boxes. + self.apply_qss(Path("main.qss"), self.setStyleSheet) for widget in self.allWidgets(): + qss_path = widget.property("qssRelativePath") + if qss_path: + self.apply_qss(Path(qss_path), widget.setStyleSheet) widget.style().unpolish(widget) widget.style().polish(widget) widget.update() diff --git a/core_lib/common/common.py b/core_lib/common/common.py index 012d94f..843b6b6 100644 --- a/core_lib/common/common.py +++ b/core_lib/common/common.py @@ -101,7 +101,7 @@ class FileObject: return self.sha512 == expected_hash if expected_hash else self.expected_sha512 == self.sha512 def verify_md5(self, expected_hash=None): - return self.sha1 == expected_hash if expected_hash else self.expected_sha1 == self.sha1 + return self.md5 == expected_hash if expected_hash else self.expected_sha1 == self.md5 def verify(self, algorithm, expected_hash=None): if algorithm == "sha1": @@ -219,6 +219,8 @@ def download_file(file: FileObject, overwrite=True, progress_callback: Callable[ raise HashMismatchException("sha1", file.sha1, file.expected_sha1, file.posix_path) elif file.expected_md5 and not file.verify_md5(): raise HashMismatchException("md5", file.md5, file.expected_md5, file.posix_path) + elif file.expected_sha512 and not file.verify_sha512(): + raise HashMismatchException("sha512", file.sha512, file.expected_sha512, file.posix_path) if any([file.expected_sha1, file.expected_md5, file.expected_sha256]): logger.debug("File hash is match as the expected hash.") diff --git a/core_lib/common/exception.py b/core_lib/common/exception.py index 9c46c4c..3018d8c 100644 --- a/core_lib/common/exception.py +++ b/core_lib/common/exception.py @@ -138,4 +138,10 @@ class ConfigValidationError(SettingsError): details = "\n".join( f"[{section}]\n{error}" for section, error in self.errors.items() ) - super().__init__(f"Invalid settings configuration:\n{details}") \ No newline at end of file + super().__init__(f"Invalid settings configuration:\n{details}") + +class ArgumentError(LauncherException): + user_message = "An error occurred while parsing arguments." + +class ArgumentValueError(ArgumentError): + user_message = "An invalid argument value was provided." \ No newline at end of file diff --git a/core_lib/game/account.py b/core_lib/game/account.py index 2d66cda..4802fc4 100644 --- a/core_lib/game/account.py +++ b/core_lib/game/account.py @@ -48,6 +48,7 @@ class Account: avatar: str = "" type: str = "msa" user_properties: list = field(default_factory=list) + xuid: str | None = None def _datetime_string(value: str | datetime.datetime, field_name: str) -> str: @@ -83,6 +84,7 @@ def create_account_data_from_object(account: Account) -> dict: "type": account.type, "userProperties": deepcopy(account.user_properties), "username": account.username, + "xuid": account.xuid, } SUPPORT_DATA_URL_IMAGE_TYPE = [ @@ -427,6 +429,7 @@ def convert_account_data_to_object(accounts: dict, account_id: str) -> Account: avatar=data.get("avatar", ""), type=data.get("type", "msa"), user_properties=deepcopy(data.get("userProperties", [])), + xuid=data.get("xuid"), ) diff --git a/core_lib/game/argument.py b/core_lib/game/argument.py index daef1df..7155aaa 100644 --- a/core_lib/game/argument.py +++ b/core_lib/game/argument.py @@ -2,13 +2,54 @@ import json import logging import re import shlex - +from dataclasses import dataclass +from typing import Callable from core_lib.common.common import get_platform_info -from core_lib.common.exception import LauncherException +from core_lib.common.exception import LauncherException, ArgumentValueError from core_lib.game.library import get_natives_platform_info logger = logging.getLogger("Launcher.CoreLib") +# =============== Features =============== +@dataclass(frozen=True) +class FeatureSpec: + required_placeholders: tuple[str, ...] = () + validate: Callable[[dict], None] | None = None + + +def validate_resolution(values: dict) -> None: + for key in ("resolution_width", "resolution_height"): + value = values[key] + if type(value) is not int or value <= 0: + raise ArgumentValueError( + f"{key} must be a positive integer." + ) + + +FEATURE_SPECS = { + "has_custom_resolution": FeatureSpec( + required_placeholders=( + "resolution_width", + "resolution_height", + ), + validate=validate_resolution, + ), + "is_demo_user": FeatureSpec(), + "has_quick_plays_support": FeatureSpec( + required_placeholders=("quickPlayPath",), + ), + "is_quick_play_singleplayer": FeatureSpec( + required_placeholders=("quickPlaySingleplayer",), + ), + "is_quick_play_multiplayer": FeatureSpec( + required_placeholders=("quickPlayMultiplayer",), + ), + "is_quick_play_realms": FeatureSpec( + required_placeholders=("quickPlayRealms",), + ), +} +# =============== Features end =============== + def compare_versions(left: str, right: str) -> int: left_parts = tuple(map(int, left.split("."))) right_parts = tuple(map(int, right.split("."))) @@ -104,12 +145,24 @@ def is_argument_allowed(argument: dict | str, allow_features: dict | None = None return allowed -def replace_placeholders(argument, placeholders: dict) -> str: - if argument: - for key, value in placeholders.items(): - argument = argument.replace("${" + key + "}", "" if value is None else str(value)) +PLACEHOLDER_PATTERN = re.compile(r"\$\{([^{}]+)\}") - return argument +def replace_placeholders(argument, placeholders: dict, *, strict: bool = False,) -> str: + def replace(match: re.Match) -> str: + key = match.group(1) + + if key not in placeholders or placeholders[key] is None: + if not strict: + return match.group(0) + + reason = "unknown" if key not in placeholders else "has no value" + raise ArgumentValueError( + f"Argument placeholder {reason}: {key}" + ) + + return str(placeholders[key]) + + return PLACEHOLDER_PATTERN.sub(replace, argument) class ArgumentMappings: @@ -217,7 +270,9 @@ def find_game_and_jvm_args(arguments: dict | str) -> tuple[list, list]: return game_args, jvm_args -def parse_and_generate_arguments(arguments: list | str, mappings: ArgumentMappings, features: dict | None = None) -> \ +def parse_and_generate_arguments(arguments: list | str, mappings: ArgumentMappings, + features: dict | None = None, *, extra_placeholders: dict | None = None, + strict_placeholders: bool = False) -> \ list[str]: if features is None: features = {} @@ -230,6 +285,9 @@ def parse_and_generate_arguments(arguments: list | str, mappings: ArgumentMappin placeholders = mappings.generate_placeholders() + if extra_placeholders: + placeholders.update(extra_placeholders) + for argument in arguments: # Check rules if not is_argument_allowed(argument, allow_features=features): @@ -237,7 +295,7 @@ def parse_and_generate_arguments(arguments: list | str, mappings: ArgumentMappin # Each argument (section) may contain multiple items, convert it to list before replace placeholder for item in convert_argument_to_multiple_string(argument): - parsed = replace_placeholders(item, placeholders) + parsed = replace_placeholders(item, placeholders, strict=strict_placeholders) parsed_arguments.append(parsed) return parsed_arguments @@ -265,19 +323,80 @@ def append_missing_necessary_jvm_arguments(arguments: list, arg_maps: ArgumentMa return result -def add_feature_arguments(arguments: dict, arg_maps: ArgumentMappings, features: dict | None = None) -> list[str]: - result = [] +def find_match_feature_argument(arguments: list | str, feature) -> dict | None: + if isinstance(arguments, str): + arguments = shlex.split(arguments) - if features is None: - return result + for argument in arguments: + # Check rules + if not is_argument_allowed(argument, allow_features=feature): + continue - if features.get("has_custom_resolution"): - result.append(f"-Dminecraft.overrideResolution={features['resolution']}") + # Only dict argument has feature rule + if not isinstance(argument, dict): + continue + + return argument + + return None + +def generate_enabled_feature_arguments(arguments: list | str, arg_maps: ArgumentMappings, + features: dict | None = None, feature_placeholders: dict | None=None, + strict_placeholders=False) -> list[str]: + enabled_features = dict(features or {}) + extra_values = dict(feature_placeholders or {}) + + values = arg_maps.generate_placeholders() + values.update(extra_values) + + for name, enabled in enabled_features.items(): + if type(enabled) is not bool: + raise ArgumentValueError( + f"Feature {name} must be a boolean." + ) + + if not enabled: + continue + + spec = FEATURE_SPECS.get(name) + + # Ignore unknown feature flag, hand it to parse_and_generate_arguments + if spec is None: + continue + + for key in spec.required_placeholders: + if key not in values or values[key] is None or values[key] == "": + raise ArgumentValueError( + f"Feature {name} requires placeholder {key}." + ) + + if spec.validate: + spec.validate(values) + + return parse_and_generate_arguments( + arguments, + arg_maps, + features=enabled_features, + extra_placeholders=extra_values, + strict_placeholders=strict_placeholders, + ) + +def generate_feature_placeholders(maps: ArgumentMappings): + if not isinstance(maps.resolution, tuple): + width, height = None, None + else: + width = maps.resolution[0] + height = maps.resolution[1] or None + + return { + "resolution_width": width, + "resolution_height": height, + } - return result def generate_launch_command(arg_maps: ArgumentMappings, main_class: str, java_path: str, full_args: dict | str - , features: dict | None = None, user_jvm_args: list[str] | None | str = None) -> list[str]: + , features: dict | None = None, user_jvm_args: list[str] | None | str = None, + strict_placeholders=False) -> list[str]: cmd = [java_path] game_args, jvm_args = find_game_and_jvm_args(full_args) @@ -296,6 +415,7 @@ def generate_launch_command(arg_maps: ArgumentMappings, main_class: str, java_pa default_args, arg_maps, features=features, + strict_placeholders=strict_placeholders, ) else: # Use jvm arguments that provided by user @@ -305,13 +425,17 @@ def generate_launch_command(arg_maps: ArgumentMappings, main_class: str, java_pa jvm_args, arg_maps, features=features, + strict_placeholders=strict_placeholders, ) - parsed_game_args = parse_and_generate_arguments( + feature_placeholders = generate_feature_placeholders(arg_maps) + parsed_game_args = generate_enabled_feature_arguments( game_args, arg_maps, features=features, - ) + feature_placeholders=feature_placeholders, + strict_placeholders=strict_placeholders, + ) # Generate arguments that enabled by features and necessary arguments that from manifest # Legacy Minecraft don't have jvm arguments exist in the version library. We need to generate by ourselves parsed_jvm_args = append_missing_necessary_jvm_arguments( @@ -322,7 +446,6 @@ def generate_launch_command(arg_maps: ArgumentMappings, main_class: str, java_pa cmd.extend(parsed_jvm_args) cmd.append(main_class) cmd.extend(parsed_game_args) - return cmd diff --git a/core_lib/game/authentication.py b/core_lib/game/authentication.py index 65a4420..2e58504 100644 --- a/core_lib/game/authentication.py +++ b/core_lib/game/authentication.py @@ -10,7 +10,7 @@ from typing import Callable import requests -from core_lib.common.exception import AuthenticationSessionException, AuthenticationConnectException, \ +from core_lib.common.exception import LauncherException, AuthenticationSessionException, AuthenticationConnectException, \ AuthenticationException, LauncherHTTPException MICROSOFT_DEVICE_CODE_URL = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode" @@ -259,7 +259,8 @@ def get_xbox_token_and_user_hash(access_token: str) -> tuple[str, str, dict]: data = auth_exception_handler(_request_handler, stage="Signing in to Xbox Live") return verify_data(data) -def get_xsts_token(xbox_token: str) -> tuple[str, dict]: +def get_xsts_token(xbox_token: str, *, + relying_party: str = "rp://api.minecraftservices.com/") -> tuple[str, dict]: """ Get xsts token :param xbox_token: @@ -270,9 +271,9 @@ def get_xsts_token(xbox_token: str) -> tuple[str, dict]: def _request_handler(): r = requests.post(XSTS_AUTH_URL, json={ "Properties": {"SandboxId": "RETAIL", "UserTokens": [xbox_token]}, - "RelyingParty": "rp://api.minecraftservices.com/", + "RelyingParty": relying_party, "TokenType": "JWT", - }, headers={"Accept": "application/json"}) + }, headers={"Accept": "application/json"}, timeout=30) r.raise_for_status() return r.json() @@ -295,6 +296,37 @@ def get_xsts_token(xbox_token: str) -> tuple[str, dict]: return verify_data(data) +def extract_xuid(data: dict, user_hash: str) -> str | None: + """Read the numeric Xbox ID for the same user as the authentication chain.""" + if not isinstance(data, dict): + return None + claims = data.get("DisplayClaims") + users = claims.get("xui") if isinstance(claims, dict) else None + if not isinstance(users, list): + return None + for user in users: + if not isinstance(user, dict) or user.get("uhs") != user_hash: + continue + xuid = user.get("xid") + if isinstance(xuid, str) and len(xuid) <= 20 and xuid.isascii() and xuid.isdecimal(): + if 0 < int(xuid) < 2 ** 64: + return xuid + return None + + +def get_xbox_xuid(xbox_token: str, user_hash: str, xsts_data: dict) -> str | None: + """Best-effort XUID lookup without changing the Minecraft token's relying party.""" + xuid = extract_xuid(xsts_data, user_hash) + if xuid is not None: + return xuid + try: + _, xbox_data = get_xsts_token(xbox_token, relying_party="https://xboxlive.com") + except (LauncherException, requests.RequestException): + logger.warning("Unable to retrieve optional Xbox user ID; continuing without it.") + return None + return extract_xuid(xbox_data, user_hash) + + def get_minecraft_access_token(user_hash: str, xsts_token: str) -> tuple[str, dict]: """ Get minecraft access token diff --git a/core_lib/qt/messagebox.py b/core_lib/qt/messagebox.py index e766748..181280a 100644 --- a/core_lib/qt/messagebox.py +++ b/core_lib/qt/messagebox.py @@ -6,6 +6,7 @@ def create_messagebox(parent: QWidget | None, title: str, message: str, icon: QMessageBox.Icon = QMessageBox.Icon.Information, button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> QMessageBox: msg = QMessageBox(parent) + msg.setOption(QMessageBox.Option.DontUseNativeDialog, True) msg.setWindowTitle(title) msg.setText(message) msg.setIcon(icon) diff --git a/core_lib/qt/progress_dialog.py b/core_lib/qt/progress_dialog.py index 6b72f9d..9abdcf8 100644 --- a/core_lib/qt/progress_dialog.py +++ b/core_lib/qt/progress_dialog.py @@ -155,9 +155,10 @@ class ProgressDialog(QDialog): row = self.rows[task_id] row.status_label.setText(f"Failed: {error}") - row.progress_bar.setStyleSheet( - "QProgressBar::chunk { background-color: #c62828; }" - ) + row.progress_bar.setProperty("failed", True) + row.progress_bar.style().unpolish(row.progress_bar) + row.progress_bar.style().polish(row.progress_bar) + row.progress_bar.update() # Move to top self.download_layout.removeWidget(row) self.download_layout.insertWidget(0, row) diff --git a/manager/account.py b/manager/account.py index 47e483b..436ad2f 100644 --- a/manager/account.py +++ b/manager/account.py @@ -38,7 +38,7 @@ from core_lib.game.account import ( ) from core_lib.game.authentication import get_xbox_token_and_user_hash, get_microsoft_token, get_xsts_token, \ get_minecraft_access_token, get_account_entitlements, get_minecraft_profile, has_minecraft_license, \ - get_device_code, refresh_microsoft_token, is_access_token_valid + get_device_code, refresh_microsoft_token, is_access_token_valid, get_xbox_xuid from core_lib.game.third_party import get_minecraft_head from core_lib.qt.hack import data_url_to_qt_image from manager.settings_models import AccountSettings @@ -65,6 +65,7 @@ class AccountDetail(AccountSummary): access_token_expires_at: str | datetime.datetime refresh_token_expires_at: str | datetime.datetime user_properties: list + xuid: str | None = None @dataclass(frozen=True) @@ -80,6 +81,7 @@ class CreateAccountRequest: avatar: str = "" account_type: str = "msa" user_properties: list = field(default_factory=list) + xuid: str | None = None class _AccountUnsetType: @@ -106,6 +108,7 @@ class UpdateAccountRequest: avatar: str | None = None account_type: str | None = None user_properties: list | _AccountUnsetType = _UNSET + xuid: str | None = None @dataclass(frozen=True) @@ -116,6 +119,7 @@ class LaunchAccount: access_token: str = field(repr=False) user_type: str = "msa" user_properties: list = field(default_factory=list) + xuid: str | None = None @dataclass(frozen=True) @@ -409,6 +413,7 @@ class AccountManager(QObject): access_token_expires_at=account.access_token_expires_at, refresh_token_expires_at=account.refresh_token_expires_at, user_properties=copy.deepcopy(account.user_properties), + xuid=account.xuid, ) def contains(self, account_id: str, show_error: bool = False) -> bool: @@ -474,6 +479,7 @@ class AccountManager(QObject): avatar=request.avatar, type=request.account_type, user_properties=copy.deepcopy(request.user_properties), + xuid=request.xuid, ) # Check before actually update @@ -525,6 +531,7 @@ class AccountManager(QObject): "refresh_token_expires_at": "refreshTokenExpiresAt", "avatar": "avatar", "account_type": "type", + "xuid": "xuid", } # Replace value inside the account raw data to new value (from UpdateAccountRequest) @@ -699,6 +706,7 @@ class AccountManager(QObject): access_token=access_token, user_type=account.account_type, user_properties=copy.deepcopy(account.user_properties), + xuid=account.xuid, ) # Validation @@ -1165,6 +1173,7 @@ class AccountManager(QObject): refresh_token=result["refresh_token"], access_token_expires_at=result["access_token_expires_at"], refresh_token_expires_at=result["refresh_token_expires_at"], + xuid=result.get("xuid"), ), ) if updated and self.save(): @@ -1259,6 +1268,7 @@ class AccountManager(QObject): minecraft_uuid=account_id, # account_id's value is provided account's uuid minecraft_name=account.get("name", ""), account_type="msa", + xuid=account.get("xuid"), ) if self.contains(account_id): @@ -1273,6 +1283,7 @@ class AccountManager(QObject): minecraft_uuid=request.minecraft_uuid, minecraft_name=request.minecraft_name, account_type=request.account_type, + xuid=request.xuid, ), ) if not updated: @@ -1550,7 +1561,8 @@ class LoginWorker(QObject): xbox_token, user_hash, _ = get_xbox_token_and_user_hash(microsoft_access_token) self.progress_changed.emit(65, "Getting XSTS token...", False) - xsts_token, _ = get_xsts_token(xbox_token) + xsts_token, xsts_data = get_xsts_token(xbox_token) + xuid = get_xbox_xuid(xbox_token, user_hash, xsts_data) self.progress_changed.emit(75, "Getting minecraft access token...", False) minecraft_access_token, minecraft = get_minecraft_access_token(user_hash, xsts_token) @@ -1579,6 +1591,7 @@ class LoginWorker(QObject): # Microsoft does not provide a refresh-token expiry timestamp. "refresh_token_expires_at": now + datetime.timedelta(days=90), "has_license": has_minecraft_license(entitlements), + "xuid": xuid, }) self.progress_changed.emit(100, "Finished!", True) except InterruptedError: @@ -1616,7 +1629,8 @@ class TokenRefreshWorker(QObject): self.client_id, self.refresh_token ) xbox_token, user_hash, _ = get_xbox_token_and_user_hash(microsoft_token) - xsts_token, _ = get_xsts_token(xbox_token) + xsts_token, xsts_data = get_xsts_token(xbox_token) + xuid = get_xbox_xuid(xbox_token, user_hash, xsts_data) minecraft_token, minecraft = get_minecraft_access_token(user_hash, xsts_token) now = datetime.datetime.now(datetime.timezone.utc) @@ -1630,6 +1644,7 @@ class TokenRefreshWorker(QObject): refresh_expires_in = 90 * 86400 self.succeeded.emit(self.account_id, { + "xuid": xuid, "access_token": minecraft_token, "refresh_token": refresh_token, "access_token_expires_at": now + datetime.timedelta(seconds=expires_in), diff --git a/manager/game.py b/manager/game.py index 32d3047..33859c3 100644 --- a/manager/game.py +++ b/manager/game.py @@ -1170,6 +1170,7 @@ class LaunchManager: auth_uuid=launch_account.minecraft_uuid, auth_access_token=launch_account.access_token, clientid=CLIENT_ID, + auth_xuid=launch_account.xuid, user_type=launch_account.user_type, version_type=profile.version_type, natives_directory=natives_dir.as_posix(), @@ -1178,7 +1179,7 @@ class LaunchManager: classpath=classpath, classpath_separator=os.pathsep, library_directory=libraries_dir.as_posix(), - resolution=profile.resolution, + resolution=profile.resolution ) target_args = arguments if arguments else old_args @@ -1271,7 +1272,8 @@ class LaunchManager: java_path=java_path, full_args=target_args, features=features, - user_jvm_args=profile.java_args + user_jvm_args=profile.java_args, + strict_placeholders=False, ) safe_cmd = ["" if value == launch_account.access_token else value for value in cmd] diff --git a/pages/launch_profile.py b/pages/launch_profile.py index 0ec52c5..cc37b28 100644 --- a/pages/launch_profile.py +++ b/pages/launch_profile.py @@ -10,6 +10,7 @@ from core_lib.game.version_info import LATEST_VERSION_ALIASES from manager.profile import ProfileSummary, LaunchProfile, ProfileManager from manager.widgets import AskForRequest, WidgetManager from pages.process_log import ProcessLogWindow +from core_lib.qt.item_button import ItemButton class ProfileButton(QFrame): @@ -46,7 +47,6 @@ class ProfileButton(QFrame): self.version_label.setObjectName("profileVersion") self.arrow_label = QLabel("▾") self.arrow_label.setObjectName("profileArrow") - self.arrow_label.setStyleSheet("border-style:solid; background-color: transparent; ") self.arrow_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.arrow_label.setFixedWidth(24) @@ -87,7 +87,7 @@ class ProfileButton(QFrame): self.clicked.emit() super().mousePressEvent(event) -class ProfileListItem(QPushButton): +class ProfileListItem(ItemButton): selected = Signal(object) def __init__(self, profile: ProfileSummary, parent: QWidget | None = None) -> None: @@ -209,7 +209,7 @@ class LaunchProfilePage(QWidget): # Widgets self.status_label = QLabel(self.app.tr_text("Select a profile to launch")) - self.status_label.setStyleSheet("font-size: 12px; font-weight: 600;") + self.status_label.setObjectName("launchStatus") self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter) # Profile button (just like the official launcher look like) diff --git a/pages/manage_profile.py b/pages/manage_profile.py index 8728508..1d74623 100644 --- a/pages/manage_profile.py +++ b/pages/manage_profile.py @@ -12,9 +12,10 @@ from PySide6.QtWidgets import ( from manager.profile import ProfileDetail, ProfileManager, ProfileSummary, UpdateProfileRequest from manager.game import AvailableVersion from pages.add_modded_version import AddModdedVersionDialog +from core_lib.qt.item_button import ItemButton -class ManageProfileItem(QPushButton): +class ManageProfileItem(ItemButton): selected = Signal(object) def __init__(self, app, profile: ProfileSummary, diff --git a/pages/process_log.py b/pages/process_log.py index d159538..0c321d5 100644 --- a/pages/process_log.py +++ b/pages/process_log.py @@ -3,6 +3,7 @@ import threading from collections import deque from collections.abc import Callable from datetime import datetime +from pathlib import Path from PySide6.QtCore import QObject, Signal from PySide6.QtGui import QCloseEvent @@ -79,75 +80,7 @@ class ProcessLogWindow(QMainWindow): layout.addWidget(self.log_output) self.setCentralWidget(container) - self.setStyleSheet( - """ - QMainWindow { - spacing: 0; - } - - QPlainTextEdit { - background-color: #0f0f10; - color: "#e5e5e5"; - font-family: Consolas; - font-size: 10pt; - } - - QScrollBar:vertical { - background-color: #0f0f10; - width: 5px; - margin: 0; - } - - QScrollBar::handle:vertical { - background-color: #3a3a3a; - min-height: 24px; - border-radius: 5px; - } - - QScrollBar::handle:vertical:hover { - background-color: #4a4a4a; - } - - QScrollBar::add-line:vertical, - QScrollBar::sub-line:vertical { - height: 0; - } - - QScrollBar::add-page:vertical, - QScrollBar::sub-page:vertical { - background: none; - } - - - /* Horizontal scrollbar */ - - QScrollBar:horizontal { - background-color: #0f0f10; - height: 5px; - margin: 0; - } - - QScrollBar::handle:horizontal { - background-color: #3a3a3a; - min-width: 24px; - border-radius: 5px; - } - - QScrollBar::handle:horizontal:hover { - background-color: #4a4a4a; - } - - QScrollBar::add-line:horizontal, - QScrollBar::sub-line:horizontal { - width: 0; - } - - QScrollBar::add-page:horizontal, - QScrollBar::sub-page:horizontal { - background: none; - } - """ - ) + self.app.apply_qss(Path("process_log.qss"), self.setStyleSheet) self._signals.output.connect(self._append_output) self._signals.finished.connect(self._process_finished) diff --git a/pages/settings.py b/pages/settings.py index d5ca536..cf684ee 100644 --- a/pages/settings.py +++ b/pages/settings.py @@ -16,6 +16,7 @@ from PySide6.QtWidgets import ( ) from constant import LAUNCHER_DESCRIPTION, LAUNCHER_NAME, LAUNCHER_VERSION +from core_lib.qt import messagebox from manager.settings_models import AccountSettings, AppearanceSettings, GeneralSettings LANGUAGE_LABELS = { @@ -403,6 +404,7 @@ class SettingsPage(QWidget): self.client_id_edit.selectAll() return False + old_theme = self.settings.get("appearance", AppearanceSettings).theme data = { "general": {"language": self.language_combo.currentData()}, "appearance": {"theme": self.theme_combo.currentData()}, @@ -410,7 +412,7 @@ class SettingsPage(QWidget): "credentials_save_method": selected_credentials_method, "token_refresh_interval": current_token_refresh_interval - }, + } } try: self.settings.validate(data) @@ -456,6 +458,11 @@ 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: + messagebox.info(None, "Launcher", + self.app.tr_text("To make all page apply new theme." + " Is recommend to restart the launcher after change it.")) + self._settings_dirty = False selected_language = data["general"]["language"] self.app.apply_language(selected_language) diff --git a/pages/test.py b/pages/test.py index 4abad3f..9f1bf6c 100644 --- a/pages/test.py +++ b/pages/test.py @@ -1,7 +1,6 @@ import json import subprocess import sys -import textwrap import threading import traceback from pathlib import Path @@ -10,6 +9,7 @@ from PySide6.QtCore import Qt, QObject, Signal, Slot from PySide6.QtWidgets import QPushButton, QVBoxLayout, QPlainTextEdit, \ QHBoxLayout, QComboBox, QWidget +from constant import CLIENT_ID from core_lib.common.common import FileObject, download_multiple_files from core_lib.common.exception import VersionNotSelectedException, UnsupportedPlatformException, \ NativeResolveException, DownloadException, DependencyException, AssetManifestFetchException, \ @@ -106,12 +106,7 @@ class TestPage(QWidget): self.setLayout(self.layout) - self.setStyleSheet( - textwrap.dedent(""" - QPushButton#ActionButton { - padding: 6px 12px; - } - """)) + self.app.apply_qss(Path("test.qss"), self.setStyleSheet) self.signals = self.PageSignals(self) @@ -663,11 +658,13 @@ class TestPage(QWidget): game_args, jvm_args = find_game_and_jvm_args(target_args) parsed_jvm_args = parse_and_generate_arguments( jvm_args, - arg_maps + arg_maps, + strict_placeholders=False, ) parsed_game_args = parse_and_generate_arguments( game_args, - arg_maps + arg_maps, + strict_placeholders=False, ) self.widget_mgr.download_signal.log.emit(f"Parsed jvm arguments: \n{parsed_jvm_args}\n{" ".join(parsed_jvm_args)}") self.widget_mgr.download_signal.log.emit(f"Parsed game arguments: \n{parsed_game_args}\n{" ".join(parsed_game_args)}") @@ -772,6 +769,7 @@ class TestPage(QWidget): classpath=classpath, classpath_separator=";", library_directory=libraries_dir.as_posix(), + clientid=CLIENT_ID, ) target_args = arguments if arguments else old_args @@ -818,6 +816,7 @@ class TestPage(QWidget): main_class=main_class, java_path=java_path, full_args=target_args, + strict_placeholders=False, ) self.widget_mgr.download_signal.log.emit(f"Launch command: {cmd}") diff --git a/resources/icons/plugin.png b/resources/icons/plugin.png new file mode 100644 index 0000000000000000000000000000000000000000..5a157aaf6e4fa844efa7813bbcfc4b7b99a2a88b GIT binary patch literal 4025 zcmeHKdr(tn7C-mqk_YdHRu)0;wy@RG}IR;N{}~2bI~^Hs9@Dr z6bo^kZEe7SWmR5EG%8yKfl>rf$_-ROi6Lk)QA6&20lT}?e|G=q%ywt?&U|yucfNDZ zcklVm`F-aeT)r&S%G}8u0Ib5pf>#3Ih{b`;MC6x@AKxH?C9e!!0P=gzPtkb%)kjV0}OGC(HQ@ZN3R3ZFvf_Sfp{+r2RlU9qY=NK z7?CF+-t?S14$y~`ex<+N6#y+BWdVV7x!$w6m~_;yX-_lhsIM;(Z+dX#86VMH>FSg$gbVr z4}UH>EA*kpSX~XX&0`vqWm{B*Ga5aX{8U=a`OXyf-{B$0bY@^w$-rAz!BAifefz_< zRB_!QeiQ-AhhCS7OJw_-JJOd4hJ4mLm^C?KaF*w&UnLp7bbEyxTeuO2y@w^nV+=ar z{Ono!RI()-gZzbEx}Z1L=)_tZ`uSU<&elV5;|wUU4eB>hj|Rnc2cd)y ziX3&eHjjfv9tD!&*G{VssiJ4vfv-I@`6=mblVGPC zNMj{*gE3`;ZhH;8Mprb5H!+psW1&IrL|YOLR^Enz?inCQdh>U8(Q;W)PpaGZR1sNj3MDPLMroO@-`x9GG*nnO0{{v*oD>=y;K!Z@jY~S2^I|r0Nsf$#Kd7Sz)=x zalJEO(HY>6cOLe8YDc3_FD~(1`vI>C(0i zj-p&;qaZZK#2=S{Wi?$lI1jQ_s|8}`;V${X_aT&qB~&|YeSuI6s7?+86@YdsmW@-2 zs~Q*zjjM1~Z*0|6CT+Q%4b@^YHG7WQs%3crlk5yqbkEvC;0F(C~X>TI|HdAE`-Ek#vr#I~eX_WK$t@3>Dj*_B`H-+HVy zVq{^Xe)fZBqf)M+@-AZGQG>R3XEBrP5tHlmPop%Kx54Vx^2A|A#og~Cy1e&aVgUKn zd3g4C49Z+{ji(y6VU*F8nuXZbcWfG6zpVj4=u|D|hodL01` z=_Q=noKZLy;uJG5ZeZOTpBNSuRY(Z!ijm*rnf7D|>U~UL-O=krKHvcPs*)*8+s-7X zV(@jcxuRr^1w`QR=+<;7Uq2JIOa-f8%VdC8J!fSxA&?vy0NK_+@g|Y$N}Pbl0d*!%{6e2)dTv-QZh`&`4q-7dyKTvWSC@PSo_T;u<6%XV6;&&&_RD@o(h9WbFyzfse zwiLy;z_f1wwpSg_@k+A&`ZExjL)q2RZt2{QH!}-Ze19{be0W{leQR*Vbbu@NczWC< zSWE!-E6@3-rKez;9Vk-7Rr0rUV}4GK+GE!gaBZS3dC)Mg`^af?GAEHuP;0K4zh1O- z19qm;9E6kBVr#bz5>)nB?awHJUp8-o6Kr(CMP?N%kFSN3(JT;6ZiBUPuL!C>9H74R zwP_D1e;8s?B-cH6H*K#-NE-`7iG;xp2X2D~mrB@n(_~ zhqbmN%T%Dg)fe z(2k5f3T)`vcJR<1j-ETE61(HV035vM_!=66Az>jX2ImGC8YOgM*X~v>cQOWb_YK-w zZTA?sKN+a@pVGVy8_X1U2ykwTZx;+miXk!&$exY{jrgWuq!sphzEdZDg7hZ>mH(>h zZBVi~SU3Pb`3$ajf$SQ0=FvGrZ15|*>Pi-oj^@r z>~DIt^-ostBM$(aevD}DAEKEvHJSfm4@pk;7qs5Z_*{o#u-}(=KC8bYVWLV!+ibJ{X!0E+R}oed(KzWvr8HBq+i;umk|6O ziMT%ECxiZmD*b~PRE7v#Bh`*$up)Z&PBftTuAF7QmM;UUX{ QWidget > QWidget { background: #c0c0c0; } +QLabel#settingsPageTitle, QLabel#settingsSubPageTitle { + background: #000080; + color: #ffffff; + font-size: 16px; + font-weight: bold; + padding: 5px; +} +QPushButton#settingsItem { + min-height: 68px; + background: #c0c0c0; + border: 2px outset #c0c0c0; + border-radius: 0; + text-align: left; +} +QPushButton#settingsItem:pressed { border-style: inset; } +QLabel#settingsItemTitle { color: #000000; font-size: 13px; font-weight: bold; } +QLabel#settingsItemDescription, QLabel#settingsHelpText { color: #404040; font-size: 12px; } +QPushButton#settingsBackButton { border-radius: 0; font-size: 20px; } +QLabel#settingsBrand { font-size: 20px; font-weight: bold; } +QLabel#settingsVersion { font-size: 12px; } +QPlainTextEdit#settingsDescription { font-size: 13px; } +QWidget#settingsPage QComboBox { + min-height: 22px; + padding: 3px 24px 3px 5px; + border: 2px inset #c0c0c0; + border-radius: 0; + background: #ffffff; + color: #000000; + selection-background-color: #000080; + selection-color: #ffffff; +} diff --git a/resources/themes/windows-9x/styles/toolbar.qss b/resources/themes/windows-9x/styles/toolbar.qss new file mode 100644 index 0000000..1f7d45a --- /dev/null +++ b/resources/themes/windows-9x/styles/toolbar.qss @@ -0,0 +1,29 @@ +QToolBar { + background: #c0c0c0; + border: 2px outset #c0c0c0; + spacing: 3px; + padding: 2px; +} +QToolBar QToolButton, QToolBar QPushButton { + background: #c0c0c0; + color: #000000; + border: 2px solid; + border-top-color: #ffffff; + border-left-color: #ffffff; + border-bottom-color: #404040; + border-right-color: #404040; + border-radius: 0; + padding: 6px; + font-size: 12px; +} +QToolBar QToolButton:pressed, QToolBar QToolButton:checked, +QToolBar QPushButton:pressed, QToolBar QPushButton:checked { + border-top-color: #404040; + border-left-color: #404040; + border-bottom-color: #ffffff; + border-right-color: #ffffff; +} +QToolBar QToolButton:focus, QToolBar QPushButton:focus { background: #dfdfdf; } +QToolBar QToolButton:disabled, QToolBar QPushButton:disabled { color: #808080; } +QToolBar::separator { background: #808080; width: 2px; height: 2px; margin: 3px; } +QToolBar::handle { background: #c0c0c0; border: 1px outset #ffffff; width: 4px; height: 4px; } diff --git a/resources/themes/windows-9x/theme.toml b/resources/themes/windows-9x/theme.toml new file mode 100644 index 0000000..d100580 --- /dev/null +++ b/resources/themes/windows-9x/theme.toml @@ -0,0 +1 @@ +name = "Windows 9x" diff --git a/resources/translations/zh-TW.json.bak b/resources/translations/zh-TW.json.bak new file mode 100644 index 0000000..9ca836e --- /dev/null +++ b/resources/translations/zh-TW.json.bak @@ -0,0 +1,232 @@ +{ + "About": "關於", + "Account": "帳號", + "Account status": "帳號狀態", + "Accounts": "所有帳號", + "Add Account": "新增帳號", + "Add Modded Version": "新增模組化版本", + "Add Version": "新增版本", + "Added version {version_id}.": "新增版本 {version_id} 。", + "All assets downloaded successfully.": "所有資源檔案已下載完成。", + "All libraries downloaded successfully.": "所有依賴已下載完成", + "Appearance": "外觀", + "Authentication failed.": "驗證失敗。", + "Authentication failed. Session may expire.": "無法通過驗證,帳號工作階段可能已過期", + "Available": "可用", + "Cancel": "取消", + "Check login status": "檢查登入狀態", + "Checking Minecraft ownership": "正在檢查是否擁有Minecraft", + "Choose a Mojang Java runtime component to install.": "選取一個 Mojang Java 組件來安裝", + "Close": "關閉", + "Completed": "已完成", + "Copied!": "複製成功!", + "Copy code": "複製代碼", + "Copy the code below, then continue in your browser.": "複製下方驗證代碼,並在瀏覽器內繼續操作。", + "Create a local mod-loader version manifest without creating a profile.": "建立本地模組化版本 (無需建立Profile)", + "Create Profile": "建立安裝檔", + "Creating the Fabric version manifest...": "正在建立 Fabric 版本清單...", + "Current": "目前", + "Current launcher working directory": "目前工作路徑", + "Current program directory": "目前程式工作路徑", + "Current version: {version}": "目前版本: {version}", + "Dark": "暗黑", + "Default": "預設", + "Delete": "刪除", + "Delete account": "刪除帳號", + "Delete All": "全部刪除", + "Delete Profile": "刪除安裝檔", + "Delete this profile? Game files will not be removed.": "確定刪除此安裝檔? (遊戲檔案不會被刪除)", + "Detected Java runtimes": "檢測 Java 安裝", + "Don't Install": "不安裝", + "Download assets": "下載資源", + "Download client": "下載客戶端核心檔案", + "Download Error": "下載錯誤", + "Download libraries": "下載依賴", + "Downloaded": "已下載", + "Downloading": "下載中", + "Downloading assets for version {version}": "正在為版本 {version} 下載資源", + "Downloading libraries for version {version}": "正在為版本 {version} 下載依賴", + "Downloading missing assets": "正在下載遺失的資源", + "Downloads": "下載", + "Duplicate": "複製", + "English": "English", + "Error": "錯誤", + "Fabric": "Fabric", + "Failed: {error}": "錯誤: {error}", + "Fetch Error": "抓取資料錯誤", + "Fetch Version Data": "抓取版本資料", + "Follow system settings": "跟隨系統", + "Game directory": "遊戲資料夾", + "Game Log": "遊戲日誌", + "General": "一般", + "Home": "主頁", + "Icon": "圖示", + "Import Mods": "導入模組", + "Import Mods…": "導入模組...", + "Imported {count} mod(s).": "共{count}個模組已導入。", + "Info": "資訊", + "Install": "安裝", + "Install Java": "安裝 Java", + "Installation failed: {error}": "安裝失敗: {error}", + "Installing {component}...": "安裝組件 {component} 中...", + "Java {version} installed successfully.": "已成功安裝 Java 版本 {version}。", + "Java arguments": "Java 引數", + "Java Version:": "Java 版本;", + "Kill Process": "強制關閉", + "Killing process...": "強制關閉中...", + "Language": "語言", + "Language and launcher directories": "語言和啟動器目錄", + "Launch Failed": "啟動失敗", + "Launch Game": "開始遊戲", + "Launch Game! (Offline)": "已啟動! (離線)", + "Launch Profile": "啟動安裝檔", + "Launch Request": "啟動請求", + "Launched!": "已啟動", + "Launcher error occurred.": "發生啟動器錯誤", + "Launcher theme": "啟動器主題", + "Light": "明亮", + "Loading all types...": "正在加載所有類型...", + "Loading all versions...": "正在加載所有版本...", + "Loading available Mojang runtimes...": "正在加載可用的 Mojang 執行環境...", + "Loading Fabric versions for {version}...": "正在為版本 {version} 加載 Fabric 版本列表...", + "Loading Minecraft versions...": "加載 Minecraft 版本列表...", + "Login Minecraft Account": "登入 Minecraft 帳號", + "Main repo": "主儲存庫", + "Manage Profiles": "管理安裝檔", + "Microsoft authentication settings": "Microsoft 驗證設定", + "Microsoft Client ID": "Microsoft Client ID", + "Microsoft Login": "Microsoft Login", + "Microsoft OAuth Client ID": "Microsoft OAuth Client ID", + "Microsoft sign-in could not be completed.": "Microsoft 登入無法完成", + "Microsoft sign-in failed": "Microsoft 登入失敗", + "Minecraft Client Error": "Minecraft 客戶端錯誤", + "Minecraft exited with code {exit_code}.": "Minecraft 退出代碼 {exit_code}.", + "Minecraft type": "Minecraft 類型", + "Minecraft version": "Minecraft 版本", + "Mod Loader": "模組加載器", + "Mod Loader Version": "模組加載器版本", + "Mod loader": "模組加載器", + "Modded": "已修改", + "Mojang runtime component": "Mojang 執行環境組件", + "No accounts yet. Use Add Account to sign in.": "無帳號可用。請透過 \"新增帳號\" 功能來登入。", + "No content": "無內容", + "No Minecraft version is available for this type.": "類型無可用 Minecraft 版本", + "No profiles available": "無設定檔可用", + "No type selected.": "尚未選取類型。", + "No version selected.": "尚未選取版本。", + "Open browser": "開啟瀏覽器", + "Open Profile Folder": "開啟安裝檔目錄", + "Ouch. The icon is missing.": "歐不,圖示不見了。", + "Parse Arguments": "解析引數", + "Parse Error": "解析錯誤", + "Preparing...": "準備中...", + "Preparing to launch...": "正在準備啟動...", + "Process exited with code {exit_code}": "行程已退出,代碼 {exit_code}", + "Profile name": "安裝檔名稱", + "Profile name:": "安裝黨名稱;", + "Profile name cannot be empty.": "安裝檔名稱不能為空;", + "Profile settings saved.": "安裝檔設定已處存", + "Ready to install.": "準備安裝", + "Redownload": "重新下載", + "Refresh": "重新整理", + "Refresh all": "重新整理", + "Refresh versions": "重新整理版本", + "Requesting a Microsoft sign-in code…": "正在請求 Microsoft 登入代碼...", + "Resolution": "解析度", + "Resource Error": "資源錯誤", + "Running (PID {pid})": "執行中 (PID {pid})", + "Save Changes": "儲存變更", + "Select a loader version to continue.": "選取一個模組加載器來繼續。", + "Select a Minecraft and loader version.": "請先選取 Minecraft 和模組加載器版本。", + "Select a profile from the list to edit its settings.": "從列表內選取一個安裝檔來修改設定", + "Select a profile to launch": "選取要啟動的安裝檔", + "Select a runtime component.": "選取一個執行環境組件", + "Select a version.": "選取一個版本", + "Select a version before continuing.": "選取一個版本再繼續。", + "Select a version to continue:": "選取一個版本來繼續;", + "Set both resolution values, or set both to Default.": "需要同時設定解析度的兩個參數,或同時設定為預設值。", + "Settings": "設定", + "Settings error": "設定檔錯誤", + "Signing in to Minecraft services": "正在登入 Minecraft 服務", + "Signing in to Xbox Live": "正在登入 Xbox Live", + "Some assets could not be downloaded. They are not required to launch the game, but missing assets may cause texture issues while you play.": "Some assets could not be downloaded. They are not required to launch the game, but missing assets may cause texture issues while you play.", + "Some files failed to download.": "Some files failed to download.", + "Some files failed to download. Would you like to retry downloading them?": "Some files failed to download. Would you like to retry downloading them?", + "Still digging!": "Still digging!", + "Switch to this account": "Switch to this account", + "Test Error": "Test Error", + "Tests": "Tests", + "The Client ID must belong to an Azure application configured for Microsoft device-code authentication.": "The Client ID must belong to an Azure application configured for Microsoft device-code authentication.", + "The selected loader version is invalid.": "The selected loader version is invalid.", + "Theme": "Theme", + "There is no profile is selected. Please create one first.": "There is no profile is selected. Please create one first.", + "This version requires Java {version}.": "This version requires Java {version}.", + "Type": "Type", + "Unable to kill process": "Unable to kill process", + "Unable to launch profile": "Unable to launch profile", + "Unable to load the Minecraft version manifest.": "Unable to load the Minecraft version manifest.", + "Unable to load the selected profile.": "Unable to load the selected profile.", + "Version": "Version", + "Version and project information": "Version and project information", + "Version Type": "Version Type", + "Version: Vanilla": "Version: Vanilla", + "Version: {version}": "Version: {version}", + "Waiting for Microsoft sign-in approval": "Waiting for Microsoft sign-in approval", + "Warning": "Warning", + "If you find an issue, you can report it in the main repository. Suggestions are always welcome!": "If you find an issue, you can report it in the main repository. Suggestions are always welcome!" +, + "An error occurred while connecting to authentication server.": "An error occurred while connecting to authentication server.", + "An error occurred while executing Java runtime.": "An error occurred while executing Java runtime.", + "An error occurred while fetching third party API.": "An error occurred while fetching third party API.", + "An error occurred while processing account data.": "An error occurred while processing account data.", + "An error occurred while processing profile.": "An error occurred while processing profile.", + "An settings error occurred.": "An settings error occurred.", + "Current platform or architecture is not supported.": "Current platform or architecture is not supported.", + "Delete all accounts": "Delete all accounts", + "Delete every saved account? This cannot be undone.": "Delete every saved account? This cannot be undone.", + "Microsoft approved the sign-in but did not return an access token. Please sign in again.": "Microsoft approved the sign-in but did not return an access token. Please sign in again.", + "Microsoft could not refresh this account. Please sign in again.": "Microsoft could not refresh this account. Please sign in again.", + "Microsoft did not return a refresh token. Ensure the offline_access permission is enabled, then sign in again.": "Microsoft did not return a refresh token. Ensure the offline_access permission is enabled, then sign in again.", + "Microsoft did not return a sign-in code. Check the client ID or update the launcher.": "Microsoft did not return a sign-in code. Check the client ID or update the launcher.", + "Microsoft sign-in was rejected (HTTP {status}): {description}": "Microsoft sign-in was rejected (HTTP {status}): {description}", + "Minecraft services accepted the Xbox session but did not return a game access token. Please sign in again.": "Minecraft services accepted the Xbox session but did not return a game access token. Please sign in again.", + "Minecraft services did not return a valid player profile. Ensure this account owns Minecraft and has created a profile.": "Minecraft services did not return a valid player profile. Ensure this account owns Minecraft and has created a profile.", + "Minecraft services returned an invalid ownership response. Please sign in again or try later.": "Minecraft services returned an invalid ownership response. Please sign in again or try later.", + "Modded version {version_id} added.": "Modded version {version_id} added.", + "No compatible native library was found for this platform.": "No compatible native library was found for this platform.", + "No version found. (This should never happen)": "No version found. (This should never happen)", + "Runtime manifest is missing or corrupted.": "Runtime manifest is missing or corrupted.", + "Settings section could not be registered.": "Settings section could not be registered.", + "Settings section could not be validated.": "Settings section could not be validated.", + "Specified account was not found.": "Specified account was not found.", + "Specified asset data section (key) not found.": "Specified asset data section (key) not found.", + "Specified profile key not found. Profile may corrupted.": "Specified profile key not found. Profile may corrupted.", + "Specified version data section (key) not found.": "Specified version data section (key) not found.", + "Specified version or type not found.": "Specified version or type not found.", + "The authentication request or session was rejected.": "The authentication request or session was rejected.", + "The authentication service received too many requests. Wait a moment and try again.": "The authentication service received too many requests. Wait a moment and try again.", + "The authentication service returned an unexpected response. Try again later.": "The authentication service returned an unexpected response. Try again later.", + "The login session is invalid or expired. Sign in again.": "The login session is invalid or expired. Sign in again.", + "Unable to extract native libraries.": "Unable to extract native libraries.", + "Unable to fetch asset manifest.": "Unable to fetch asset manifest.", + "Unable to fetch runtime manifest.": "Unable to fetch runtime manifest.", + "Unable to fetch third party API. Provider may no longer exist. Try updating the launcher.": "Unable to fetch third party API. Provider may no longer exist. Try updating the launcher.", + "Unable to fetch third party API. Try updating the launcher.": "Unable to fetch third party API. Try updating the launcher.", + "Unable to fetch version manifest.": "Unable to fetch version manifest.", + "Unable to find dependency.": "Unable to find dependency.", + "Unable to load account data. The account file may be corrupted.": "Unable to load account data. The account file may be corrupted.", + "Unable to load asset manifest.": "Unable to load asset manifest.", + "Unable to load profile. Profile may corrupted": "Unable to load profile. Profile may corrupted", + "Unable to load version manifest.": "Unable to load version manifest.", + "Unable to parse Java runtime details.": "Unable to parse Java runtime details.", + "Unable to resolve native libraries.": "Unable to resolve native libraries.", + "Unable to save account data. Try again later.": "Unable to save account data. Try again later.", + "Unable to save asset manifest.": "Unable to save asset manifest.", + "Unable to save profile. Try again later.": "Unable to save profile. Try again later.", + "Unable to save version manifest.": "Unable to save version manifest.", + "Unable to verify Minecraft ownership because the ownership list is missing or invalid.": "Unable to verify Minecraft ownership because the ownership list is missing or invalid.", + "Unable to verify Minecraft ownership because the ownership response is invalid.": "Unable to verify Minecraft ownership because the ownership response is invalid.", + "Xbox Live accepted the sign-in but did not return an authentication token. Please sign in again.": "Xbox Live accepted the sign-in but did not return an authentication token. Please sign in again.", + "Xbox Live did not return the account identifier. Check the account's Xbox profile and try again.": "Xbox Live did not return the account identifier. Check the account's Xbox profile and try again.", + "Xbox security authorization did not return a token. The account may need an Xbox profile or may be restricted.": "Xbox security authorization did not return a token. The account may need an Xbox profile or may be restricted." +} diff --git a/window.py b/window.py index d964a50..7ffc9bd 100644 --- a/window.py +++ b/window.py @@ -138,6 +138,7 @@ class LauncherMainWindow(QMainWindow): # Dialog self.download_dialog = ProgressDialog(self) + self.app.apply_qss(Path("progress_dialog.qss"), self.download_dialog.setStyleSheet) self.download_dialog.setWindowTitle(self.app.tr_text("Downloads")) # Homepage @@ -191,7 +192,6 @@ class LauncherMainWindow(QMainWindow): self.setCentralWidget(self.central) # Apply qss - self.app.apply_qss(Path("main.qss"), self.setStyleSheet) self.app.apply_qss(Path("toolbar.qss"), self.toolbar.setStyleSheet) # Toolbar