style: remove redundant code narration
This commit is contained in:
1 parent
495f31778b
commit
783fb76f06
115 files changed
+19
-746
No files matched your search
@@ -1,4 +1,3 @@
|
||||
# cargo-dist artifact building and publishing, called by release.yml.
|
||||
# Based on cargo-dist's generated GitHub workflow.
|
||||
|
||||
name: build release
|
||||
@@ -13,7 +12,6 @@ on:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
# Run 'dist plan' (or host) to determine what tasks we need to do
|
||||
plan:
|
||||
runs-on: "ubuntu-22.04"
|
||||
outputs:
|
||||
@@ -39,11 +37,6 @@ jobs:
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/dist
|
||||
# sure would be cool if github gave us proper conditionals...
|
||||
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
|
||||
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||
- id: plan
|
||||
run: |
|
||||
dist host --steps=create --tag=${{ inputs.tag }} --output-format=json > plan-dist-manifest.json
|
||||
@@ -56,25 +49,13 @@ jobs:
|
||||
name: artifacts-plan-dist-manifest
|
||||
path: plan-dist-manifest.json
|
||||
|
||||
# Build and packages all the platform-specific things
|
||||
build-local-artifacts:
|
||||
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
|
||||
# Let the initial task tell us to not run (currently very blunt)
|
||||
needs:
|
||||
- plan
|
||||
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
# Target platforms/runners are computed by dist in create-release.
|
||||
# Each member of the matrix has the following arguments:
|
||||
#
|
||||
# - runner: the github runner
|
||||
# - dist-args: cli flags to pass to dist
|
||||
# - install-dist: expression to run to install dist on the runner
|
||||
#
|
||||
# Typically there will be:
|
||||
# - 1 "global" task that builds universal installers
|
||||
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||
matrix: ${{ fromJson(needs.plan.outputs.val || '{"ci":{"github":{"artifacts_matrix":{"include":[]}}}}').ci.github.artifacts_matrix }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
container: ${{ matrix.container && matrix.container.image || null }}
|
||||
@@ -108,7 +89,6 @@ jobs:
|
||||
run: sudo apt-get update && sudo apt-get install --yes libxcb1-dev
|
||||
- name: Install dist
|
||||
run: ${{ matrix.install_dist.run }}
|
||||
# Get the dist-manifest
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@@ -120,7 +100,6 @@ jobs:
|
||||
${{ matrix.packages_install }}
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
# Actually do builds and make zips and whatnot
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
- id: cargo-dist
|
||||
@@ -130,7 +109,6 @@ jobs:
|
||||
# inconsistent syntax between shell and powershell.
|
||||
shell: bash
|
||||
run: |
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
@@ -144,7 +122,6 @@ jobs:
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
|
||||
# Build and package all the platform-agnostic(ish) things
|
||||
build-global-artifacts:
|
||||
needs:
|
||||
- plan
|
||||
@@ -165,7 +142,6 @@ jobs:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@@ -178,7 +154,6 @@ jobs:
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
@@ -191,13 +166,11 @@ jobs:
|
||||
path: |
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
# Determines if we should publish/announce
|
||||
host:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
- build-global-artifacts
|
||||
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -218,7 +191,6 @@ jobs:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Fetch artifacts from scratch-storage
|
||||
- name: Fetch artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@@ -235,10 +207,8 @@ jobs:
|
||||
- name: "Upload dist-manifest.json"
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Overwrite the previous copy
|
||||
name: artifacts-dist-manifest
|
||||
path: dist-manifest.json
|
||||
# Create a GitHub Release while uploading all files to it
|
||||
- name: "Download GitHub Artifacts"
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@@ -330,7 +300,6 @@ jobs:
|
||||
persist-credentials: true
|
||||
repository: ${{ env.HOMEBREW_TAP_REPOSITORY }}
|
||||
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||
# So we have access to the formula
|
||||
- name: Fetch homebrew formulae
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@@ -379,7 +348,6 @@ jobs:
|
||||
plan: ${{ needs.plan.outputs.val }}
|
||||
dry_run: false
|
||||
secrets: inherit
|
||||
# publish jobs get escalated permissions
|
||||
permissions:
|
||||
"contents": "read"
|
||||
|
||||
@@ -392,7 +360,6 @@ jobs:
|
||||
with:
|
||||
plan: ${{ needs.plan.outputs.val }}
|
||||
secrets: inherit
|
||||
# publish jobs get escalated permissions
|
||||
permissions:
|
||||
"contents": "read"
|
||||
|
||||
@@ -405,7 +372,6 @@ jobs:
|
||||
with:
|
||||
plan: ${{ needs.plan.outputs.val }}
|
||||
secrets: inherit
|
||||
# publish jobs get escalated permissions
|
||||
permissions:
|
||||
"contents": "write"
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let out = Path::new(&out_dir);
|
||||
|
||||
// compile RmclShim.java into a jar that gets embedded via include_bytes!
|
||||
let status = Command::new("javac")
|
||||
.arg("-source")
|
||||
.arg("8")
|
||||
@@ -25,7 +24,6 @@ fn main() {
|
||||
|
||||
assert!(status.success(), "javac failed to compile RmclShim.java");
|
||||
|
||||
// package into a jar
|
||||
let jar_path = out.join("rmcl-shim.jar");
|
||||
let status = Command::new("jar")
|
||||
.arg("cfe")
|
||||
|
||||
+1
-38
@@ -1,14 +1,8 @@
|
||||
# git-cliff ~ configuration file
|
||||
# https://git-cliff.org/docs/configuration
|
||||
|
||||
|
||||
[remote.github]
|
||||
owner = "objz"
|
||||
repo = "rmcl"
|
||||
|
||||
[changelog]
|
||||
# A Tera template to be rendered for each release in the changelog.
|
||||
# See https://keats.github.io/tera/docs/#introduction
|
||||
body = """
|
||||
{% if version %}\
|
||||
## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
|
||||
@@ -32,41 +26,19 @@ body = """
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
"""
|
||||
# Remove leading and trailing whitespaces from the changelog's body.
|
||||
trim = true
|
||||
# Render body even when there are no releases to process.
|
||||
render_always = true
|
||||
# An array of regex based postprocessors to modify the changelog.
|
||||
postprocessors = [
|
||||
# Replace the placeholder <REPO> with a URL.
|
||||
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
|
||||
]
|
||||
# render body even when there are no releases to process
|
||||
# render_always = true
|
||||
# output file path
|
||||
# output = "test.md"
|
||||
postprocessors = []
|
||||
|
||||
[git]
|
||||
# Parse commits according to the conventional commits specification.
|
||||
# See https://www.conventionalcommits.org
|
||||
conventional_commits = true
|
||||
# Exclude commits that do not match the conventional commits specification.
|
||||
filter_unconventional = false
|
||||
# Require all commits to be conventional.
|
||||
# Takes precedence over filter_unconventional.
|
||||
require_conventional = false
|
||||
# Split commits on newlines, treating each line as an individual commit.
|
||||
split_commits = false
|
||||
# An array of regex based parsers to modify commit messages prior to further processing.
|
||||
commit_preprocessors = [
|
||||
# Replace issue numbers in commit messages with links.
|
||||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/objz/rmcl/issues/${2}))" },
|
||||
]
|
||||
# Prevent commits that are breaking from being excluded by commit parsers.
|
||||
protect_breaking_commits = false
|
||||
# An array of regex based parsers for extracting data from the commit message.
|
||||
# Assigns commits to groups.
|
||||
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
|
||||
commit_parsers = [
|
||||
{ message = "^feat", group = "<!-- 0 -->features" },
|
||||
{ message = "^fix", group = "<!-- 1 -->bug fixes" },
|
||||
@@ -84,20 +56,11 @@ commit_parsers = [
|
||||
{ message = "^revert", group = "<!-- 9 -->reverts" },
|
||||
{ message = ".*", group = "<!-- 10 -->other changes" },
|
||||
]
|
||||
# Exclude commits that are not matched by any commit parser.
|
||||
filter_commits = false
|
||||
# Fail on a commit that is not matched by any commit parser.
|
||||
fail_on_unmatched_commit = false
|
||||
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
|
||||
link_parsers = []
|
||||
# Include only the tags that belong to the current branch.
|
||||
use_branch_tags = false
|
||||
# Order releases topologically instead of chronologically.
|
||||
topo_order = false
|
||||
# Order commits topologically instead of chronologically.
|
||||
topo_order_commits = true
|
||||
# Order of commits in each group/release within the changelog.
|
||||
# Allowed values: newest, oldest
|
||||
sort_commits = "oldest"
|
||||
# Process submodules commits
|
||||
recurse_submodules = false
|
||||
@@ -1,29 +1,16 @@
|
||||
[workspace]
|
||||
members = ["cargo:."]
|
||||
|
||||
# Config for 'dist'
|
||||
[dist]
|
||||
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
|
||||
cargo-dist-version = "0.31.0"
|
||||
# CI backends to support
|
||||
ci = "github"
|
||||
# The installers to generate for each app
|
||||
installers = ["homebrew", "msi"]
|
||||
# A GitHub repo to push Homebrew formulas to
|
||||
tap = "objz/homebrew-tap"
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
|
||||
# Path that installers should place binaries in
|
||||
install-path = "CARGO_HOME"
|
||||
# Publish jobs to run in CI
|
||||
publish-jobs = ["homebrew", "./publish-crates", "./publish-aur", "./publish-winget"]
|
||||
# Custom permissions for publish jobs
|
||||
github-custom-job-permissions = { publish-crates = { contents = "read" }, publish-aur = { contents = "read" }, publish-winget = { contents = "read" } }
|
||||
# Extra setup steps for release artifact builders
|
||||
github-build-setup = "../dist-build-setup.yml"
|
||||
# Where to host releases
|
||||
hosting = "github"
|
||||
# Whether to install an updater program
|
||||
install-updater = false
|
||||
# Allow custom edits to the generated CI file
|
||||
allow-dirty = ["ci", "msi"]
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// account management: persistence, switching active accounts, and offline uuid generation
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// auth module: account storage (offline + microsoft) and the oauth device code flow
|
||||
mod accounts;
|
||||
mod oauth;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// microsoft oauth device code flow for minecraft authentication.
|
||||
// the flow goes: MSA device code -> MSA token -> xbox/mc token exchange -> mc profile fetch.
|
||||
// device code auth is used because it works without a redirect URI, which is nice for a TUI.
|
||||
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
@@ -50,7 +48,6 @@ fn normalize_profile_uuid(id: &str) -> Option<String> {
|
||||
})
|
||||
}
|
||||
|
||||
// shared slot so the TUI can poll for the device code to show the user
|
||||
pub static DEVICE_CODE_DISPLAY: LazyLock<Arc<Mutex<Option<DeviceCodeInfo>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(None)));
|
||||
|
||||
@@ -92,8 +89,6 @@ async fn run_full_oauth_flow() -> Result<(String, Option<String>), String> {
|
||||
Ok((ms_access_token, ms_refresh_token))
|
||||
}
|
||||
|
||||
// kicks off auth on a background task, returns a mutex the caller can poll for the result.
|
||||
// the TUI checks DEVICE_CODE_DISPLAY for the code to show, and this mutex for completion.
|
||||
pub fn start_microsoft_auth() -> Arc<Mutex<Option<AuthResult>>> {
|
||||
let result: Arc<Mutex<Option<AuthResult>>> = Arc::new(Mutex::new(None));
|
||||
let result_clone = result.clone();
|
||||
@@ -183,7 +178,6 @@ fn valid_cached_mc_token(account: &Account, now: i64) -> Option<&str> {
|
||||
}
|
||||
}
|
||||
|
||||
// returns (mc_access_token, new_refresh_token, new_mc_token_expires_at).
|
||||
// cached tokens return no expiry so callers don't rewrite the account store.
|
||||
pub async fn refresh_and_get_token(
|
||||
account: &Account,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// cli handlers for account management (microsoft oauth + offline accounts)
|
||||
use std::io;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -65,7 +64,6 @@ async fn add_microsoft_account() -> CliResult {
|
||||
|
||||
let result_arc = crate::auth::start_microsoft_auth();
|
||||
|
||||
// wait for the device code to become available before showing it
|
||||
loop {
|
||||
if let Ok(slot) = crate::auth::DEVICE_CODE_DISPLAY.lock()
|
||||
&& let Some(info) = slot.as_ref()
|
||||
@@ -77,7 +75,6 @@ async fn add_microsoft_account() -> CliResult {
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
}
|
||||
|
||||
// now wait for the user to complete auth in their browser
|
||||
loop {
|
||||
if let Ok(slot) = result_arc.lock()
|
||||
&& let Some(result) = slot.as_ref()
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// unified content management for mods, resource packs, and shaders.
|
||||
// all three content types share the same list/enable/disable workflow,
|
||||
// just with different scanner functions plugged in.
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modpack importing from modrinth (remote slug/url) or local files (.mrpack, mmc zips).
|
||||
// resolves the input, downloads if needed, then hands off to the import engine.
|
||||
use clap::ArgMatches;
|
||||
|
||||
use crate::instance::InstanceManager;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// instance lifecycle: create, delete, rename, launch, config, desktop shortcuts.
|
||||
// the heaviest handler in the CLI since instances are the core concept.
|
||||
use std::io;
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// viewing minecraft log files from the CLI, with optional `--follow` for tailing
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
@@ -67,7 +66,6 @@ async fn show_log(matches: &ArgMatches) -> CliResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// if no file is specified, grab the most recent log (first from the sorted scan)
|
||||
pub(crate) fn resolve_log_path(
|
||||
instances_dir: &Path,
|
||||
instance: &str,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// cli entry point and clap command definitions.
|
||||
// no subcommand = launch TUI, otherwise dispatch to the appropriate handler.
|
||||
mod account;
|
||||
mod content;
|
||||
mod import;
|
||||
@@ -17,9 +15,7 @@ use clap::{Arg, ArgAction, ArgGroup, Command};
|
||||
pub async fn init() {
|
||||
let matches = build_command().get_matches();
|
||||
|
||||
// no subcommand means the user just ran `rmcl` bare, so fall through to TUI mode
|
||||
if matches.subcommand().is_none() {
|
||||
// force-init the theme so it's ready before the TUI renders
|
||||
let _ = &*crate::config::theme::THEME;
|
||||
if let Err(e) = crate::tui::show().await {
|
||||
tracing::error!("TUI error: {}", e);
|
||||
@@ -265,7 +261,6 @@ fn build_command() -> Command {
|
||||
)
|
||||
}
|
||||
|
||||
// mods, resource packs, and shaders all share the same list/enable/disable shape
|
||||
fn build_content_command(name: &'static str, about: &'static str) -> Command {
|
||||
Command::new(name)
|
||||
.about(format!("Manage {}", about))
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// plain-text table rendering for CLI output. no fancy box-drawing,
|
||||
// just left-aligned columns with two-space gaps. keeps it pipeable.
|
||||
use chrono::{DateTime, Utc};
|
||||
use ratatui::text::Span;
|
||||
|
||||
@@ -47,7 +45,6 @@ fn display_width(value: &str) -> usize {
|
||||
Span::raw(value).width()
|
||||
}
|
||||
|
||||
// find the widest value in each column to pad everything evenly
|
||||
fn column_widths(headers: &[&str], rows: &[Vec<String>]) -> Vec<usize> {
|
||||
let mut widths: Vec<usize> = headers.iter().map(|header| display_width(header)).collect();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shared CLI helpers: confirmation prompts, arg extraction, instance validation
|
||||
use std::io::{self, Write};
|
||||
|
||||
use clap::ArgMatches;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// lists available game versions, optionally filtered by mod loader support.
|
||||
// fetches the mojang manifest and cross-references with loader APIs
|
||||
// to show only versions that actually work with a given loader.
|
||||
use std::collections::HashSet;
|
||||
use std::io;
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// config loading: reads config.toml from the platform config dir, creates defaults if missing.
|
||||
// everything lands in the SETTINGS static so the rest of the app can just grab it.
|
||||
|
||||
use config::{Config as ConfigLoader, ConfigError, File};
|
||||
use std::fs;
|
||||
use std::io;
|
||||
@@ -22,7 +19,6 @@ pub fn get_config_path() -> PathBuf {
|
||||
.join("rmcl")
|
||||
}
|
||||
|
||||
// seeds the config file from the bundled default on first run
|
||||
fn ensure_config_exists() -> PathBuf {
|
||||
let config_path = get_config_path().join("config.toml");
|
||||
if !config_path.exists() {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// all the config structs that map to sections in config.toml.
|
||||
// everything has sane defaults so a blank file (or no file) still works.
|
||||
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
fmt,
|
||||
@@ -250,7 +247,6 @@ impl Default for Paths {
|
||||
}
|
||||
}
|
||||
|
||||
// expand ~ in paths since toml doesn't do that for us
|
||||
pub fn resolve_path(raw: &str) -> PathBuf {
|
||||
if let Some(stripped) = raw.strip_prefix("~/") {
|
||||
if let Some(home) = dirs_next::home_dir() {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// theme resolution: loads theme.toml, picks a base theme (builtin or custom file),
|
||||
// then layers user color overrides on top. supports loading .toml themes from the
|
||||
// config/theme/ directory or by absolute path.
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, LazyLock, RwLock};
|
||||
|
||||
@@ -101,7 +97,6 @@ fn ensure_theme_exists(path: &Path) {
|
||||
let _ = std::fs::write(path, include_str!("../../assets/theme.toml"));
|
||||
}
|
||||
|
||||
// start from a base theme, then override individual colors if the user specified any
|
||||
fn resolve_app_theme(config: &ThemeConfig) -> Box<dyn Theme> {
|
||||
let base = load_base_theme(&config.theme);
|
||||
|
||||
@@ -134,7 +129,6 @@ fn resolve_app_theme(config: &ThemeConfig) -> Box<dyn Theme> {
|
||||
})
|
||||
}
|
||||
|
||||
// tries to find the theme: absolute path > config/theme/<name> > config/theme/<name>.toml > builtin
|
||||
fn load_base_theme(name: &str) -> Box<dyn Theme> {
|
||||
let path = if Path::new(name).is_absolute() {
|
||||
Some(std::path::PathBuf::from(name))
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// thread-safe FIFO queue for error/warning toasts displayed in the UI.
|
||||
// also (ab)used for INFO toasts like "desktop shortcut created" because
|
||||
// why build a separate notification system when this one works fine.
|
||||
//
|
||||
// callers pass id: 0 and push_error assigns a real unique id. the id is
|
||||
// used by the render layer to track per-toast animation state.
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// application feedback shared by background work and every frontend.
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub mod errors;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// global progress state shared between background tasks and the status bar widget.
|
||||
// background tasks set the action/progress, the render loop reads it every frame.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// data pack scanning backed by the same pack.mcmeta reader as resource packs.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -55,7 +55,6 @@ pub struct ContentEntry {
|
||||
pub icon_lines: Option<Vec<Vec<IconCell>>>,
|
||||
}
|
||||
|
||||
// enable/disable by renaming the file with/without ".disabled" suffix.
|
||||
pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> {
|
||||
toggle_entry_path(entry).map(drop)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// terminal icon rasterization shared by every content type and markdown.
|
||||
|
||||
// a single "pixel" in a terminal icon.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct IconCell {
|
||||
pub symbol: char,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// scanning and toggling instance content (mods, resource packs, shaders, worlds).
|
||||
// minecraft uses a ".disabled" suffix convention for disabled content, so this leans on that heavily.
|
||||
|
||||
pub mod datapacks;
|
||||
@@ -30,8 +29,6 @@ pub use worlds::{scan_one_world, scan_worlds};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
// figures out if a file is enabled or disabled based on the ".disabled" suffix,
|
||||
// and strips the extension to get a clean stem name
|
||||
pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, String)> {
|
||||
let disabled_ext = format!("{ext}.disabled");
|
||||
if let Some(stem) = file_name.strip_suffix(&disabled_ext) {
|
||||
@@ -43,7 +40,6 @@ pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, St
|
||||
}
|
||||
}
|
||||
|
||||
// same idea but for directories, which don't have a file extension to strip
|
||||
pub(crate) fn parse_enabled_stem_dir(file_name: &str) -> (bool, String) {
|
||||
if let Some(stem) = file_name.strip_suffix(".disabled") {
|
||||
(false, stem.to_string())
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mod scanning and loader-specific metadata extraction.
|
||||
// jar files are just zips, so it cracks them open looking for loader-specific
|
||||
// metadata (fabric.mod.json, quilt.mod.json, mods.toml, mcmod.info) to get
|
||||
// names, descriptions, and icons. if none of those work, falls back to common
|
||||
// root-level icon paths (logo.png, icon.png, pack.png) or just the filename.
|
||||
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -47,7 +41,6 @@ fn icon_path_from_value(value: &serde_json::Value) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
// quilt puts its metadata under a "metadata" sub-object
|
||||
#[derive(Deserialize, Default)]
|
||||
struct QuiltModJson {
|
||||
#[serde(default)]
|
||||
@@ -142,10 +135,6 @@ pub fn scan_mods(instances_dir: &Path, instance_name: &str) -> Vec<ContentEntry>
|
||||
entries
|
||||
}
|
||||
|
||||
// tries each loader's metadata file to extract name, description, and icon.
|
||||
// checks fabric.mod.json, quilt.mod.json, META-INF/mods.toml (forge),
|
||||
// META-INF/neoforge.mods.toml, and mcmod.info (legacy forge). if none of
|
||||
// those yield an icon, falls back to common root-level paths.
|
||||
fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option<Vec<u8>>) {
|
||||
let file = match std::fs::File::open(jar_path) {
|
||||
Ok(file) => file,
|
||||
@@ -197,7 +186,6 @@ fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option<Vec<u8>
|
||||
}
|
||||
}
|
||||
|
||||
// no recognized metadata at all, try common icon paths
|
||||
let icon_bytes = try_fallback_icons(&mut archive);
|
||||
tracing::trace!(
|
||||
"No recognized mod metadata in {}; fallback_icon={}",
|
||||
@@ -291,8 +279,6 @@ fn read_forge_toml_meta(
|
||||
Some((name, description, version, logo))
|
||||
}
|
||||
|
||||
// legacy forge mcmod.info is either a bare json array of mod entries
|
||||
// or an object with a "modList" key wrapping the array
|
||||
fn read_mcmod_info(
|
||||
archive: &mut zip::ZipArchive<std::fs::File>,
|
||||
) -> Option<(String, String, String, String)> {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shared pack.mcmeta scanning for resource packs and shader packs.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// resource pack scanner backed by the shared pack.mcmeta reader.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shader pack scanner backed by the shared pack.mcmeta reader.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// world save scanning. worlds are always directories (never zips) and store
|
||||
// their icon as icon.png. also computes an approximate size from top-level
|
||||
// files + region data so the user gets some sense of how chonky their world is.
|
||||
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
use flate2::read::GzDecoder;
|
||||
@@ -204,7 +200,6 @@ fn dir_size_approx(path: &Path) -> u64 {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check region folder too (main chunk data)
|
||||
let region = path.join("region");
|
||||
if let Ok(rd) = std::fs::read_dir(region) {
|
||||
for entry in rd.flatten() {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// creates OS-native shortcuts for launching instances directly:
|
||||
// .desktop files on linux, .bat on windows, .command on macos
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::instance::models::InstanceConfig;
|
||||
@@ -42,7 +39,6 @@ pub fn icon_path() -> Option<PathBuf> {
|
||||
dirs_next::data_dir().map(|d| d.join("rmcl").join("icon.svg"))
|
||||
}
|
||||
|
||||
// lazily writes the bundled svg icon to disk the first time a shortcut needs it
|
||||
fn ensure_icon() -> Option<PathBuf> {
|
||||
let path = icon_path()?;
|
||||
if std::fs::read(&path).ok().as_deref() == Some(ICON_BYTES) {
|
||||
@@ -229,7 +225,6 @@ fn quote_windows_arg(value: &str) -> String {
|
||||
quoted
|
||||
}
|
||||
|
||||
// replaces anything that isn't alphanumeric, dash, or underscore with _
|
||||
fn sanitize(name: &str) -> String {
|
||||
name.chars()
|
||||
.map(|c| {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// multimc / prism launcher instance import: mods and configs are bundled
|
||||
// in the zip. we install the game + loader normally, then extract the
|
||||
// archive contents over it.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::feedback::progress;
|
||||
@@ -119,7 +115,6 @@ pub async fn execute_import(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// extracts everything under .minecraft/ from the archive into the instance dir
|
||||
fn extract_mmc_archive(
|
||||
archive_path: &Path,
|
||||
minecraft_dir: &Path,
|
||||
@@ -239,7 +234,6 @@ fn instance_name_from_cfg(path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
// finds the prefix for the archive: empty for flat zips, "DirName/" for nested
|
||||
fn find_archive_prefix(archive: &zip::ZipArchive<std::fs::File>) -> String {
|
||||
for name in archive.file_names() {
|
||||
if name.ends_with("mmc-pack.json") {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modpack importing: parses user input, detects pack format from zip contents,
|
||||
// builds a summary, and delegates the actual import to format-specific modules.
|
||||
|
||||
pub mod curseforge;
|
||||
pub mod mmc;
|
||||
pub mod mrpack;
|
||||
@@ -28,9 +25,6 @@ pub enum ImportInput {
|
||||
LocalFile(String),
|
||||
}
|
||||
|
||||
// figures out what the user gave us: a modrinth URL, a local pack file,
|
||||
// or just a project slug. accepts a pretty wide range of inputs so users
|
||||
// don't have to think about it.
|
||||
pub fn parse_import_input(input: &str) -> ImportInput {
|
||||
let input = input.trim();
|
||||
|
||||
@@ -78,8 +72,6 @@ pub struct ImportSummary {
|
||||
pub source: Option<crate::instance::ProviderProject>,
|
||||
}
|
||||
|
||||
// peeks inside a zip to figure out what format it is.
|
||||
// checks provider manifests first, then mmc-pack.json.
|
||||
pub fn detect_format(path: &Path) -> Result<PackFormat, String> {
|
||||
tracing::debug!("Detecting modpack format for {}", path.display());
|
||||
let file =
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modrinth .mrpack import: parse the manifest, download all the mods,
|
||||
// and extract config/resource overrides from the zip
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -43,7 +40,6 @@ pub struct MrpackFile {
|
||||
pub file_size: u64,
|
||||
}
|
||||
|
||||
// .mrpack is just a zip with modrinth.index.json at the root
|
||||
pub fn parse_mrpack(path: &Path) -> Result<MrpackIndex, String> {
|
||||
tracing::debug!("Parsing .mrpack manifest from {}", path.display());
|
||||
let file = std::fs::File::open(path).map_err(|e| format!("Cannot open .mrpack: {e}"))?;
|
||||
@@ -63,8 +59,6 @@ pub fn parse_mrpack(path: &Path) -> Result<MrpackIndex, String> {
|
||||
Ok(index)
|
||||
}
|
||||
|
||||
// mrpack dependencies use keys like "fabric-loader", "forge", etc.
|
||||
// checks in priority order and returns the first match.
|
||||
pub fn loader_from_dependencies(
|
||||
deps: &HashMap<String, String>,
|
||||
) -> (Option<ModLoader>, Option<String>) {
|
||||
@@ -132,7 +126,6 @@ pub fn build_summary(path: &Path) -> Result<ImportSummary, String> {
|
||||
})
|
||||
}
|
||||
|
||||
// peek into the zip to count files under overrides/ and client-overrides/
|
||||
fn count_overrides(mrpack_path: &Path) -> Result<usize, String> {
|
||||
let file = std::fs::File::open(mrpack_path).map_err(|e| e.to_string())?;
|
||||
let archive = zip::ZipArchive::new(file).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// java runtime discovery shared by launching, loader installation, and settings.
|
||||
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
path::{Path, PathBuf},
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// builds the full java command line and spawns minecraft as a child process.
|
||||
// handles classpath assembly, auth token injection, and log capture.
|
||||
// loader-specific patches live in submodules (e.g. patches.rs for lwjgl3ify).
|
||||
|
||||
pub(crate) mod parser;
|
||||
mod patches;
|
||||
|
||||
@@ -300,9 +296,6 @@ async fn migrate_legacy_loader_profile_if_needed(
|
||||
Ok(Some(refreshed))
|
||||
}
|
||||
|
||||
// resolved auth credentials passed into the launch-invocation builder.
|
||||
// keeping these as borrowed strs lets callers pass owned strings or string
|
||||
// slices without forcing allocation.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LaunchAuth<'a> {
|
||||
pub username: &'a str,
|
||||
@@ -312,9 +305,7 @@ pub struct LaunchAuth<'a> {
|
||||
pub user_type: &'a str,
|
||||
}
|
||||
|
||||
// everything the spawner needs to construct the java command. assembled by
|
||||
// build_launch_invocation, consumed by launch(). exposed so integration tests
|
||||
// can assert on the rendered invocation without spawning a real process.
|
||||
// Exposed so integration tests can inspect the invocation without spawning Java.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LaunchInvocation {
|
||||
pub java: String,
|
||||
@@ -368,11 +359,6 @@ fn validate_quick_play_world(minecraft_dir: &Path, world: &str) -> Result<(), La
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// builds a fully-resolved java invocation for the given instance. reads
|
||||
// meta.json and the loader profile from disk, migrates legacy formats if
|
||||
// needed (may hit Mojang to refetch), resolves inheritsFrom, applies
|
||||
// loader-specific patches, and renders all template arguments. all I/O
|
||||
// except auth resolution and process spawning happens here.
|
||||
pub async fn build_launch_invocation(
|
||||
config: &InstanceConfig,
|
||||
instances_dir: &Path,
|
||||
@@ -555,7 +541,6 @@ pub async fn build_launch_invocation(
|
||||
.collect::<Vec<_>>()
|
||||
.join(sep);
|
||||
|
||||
// java resolution: instance override > global setting > auto-detect
|
||||
let java = config
|
||||
.java_path
|
||||
.clone()
|
||||
@@ -739,10 +724,6 @@ fn finish_config_sync(
|
||||
}
|
||||
}
|
||||
|
||||
// resolves auth credentials, then builds the launch invocation and spawns
|
||||
// the java process. only thin wrapper logic lives here: token refresh,
|
||||
// process spawn, child supervision. all the heavy lifting (profile loading,
|
||||
// classpath assembly, template rendering) sits behind build_launch_invocation.
|
||||
pub async fn launch(
|
||||
config: &InstanceConfig,
|
||||
instances_dir: &Path,
|
||||
@@ -751,7 +732,6 @@ pub async fn launch(
|
||||
) -> Result<(), LaunchError> {
|
||||
let name = config.name.clone();
|
||||
|
||||
// resolve auth credentials, refreshing the microsoft token if needed.
|
||||
let mut account_store = crate::auth::AccountStore::load();
|
||||
let account =
|
||||
select_launch_account(&account_store.accounts, config.preferred_account.as_deref());
|
||||
@@ -919,8 +899,6 @@ pub async fn launch(
|
||||
let config_for_post_exit = config.clone();
|
||||
let invocation_for_post_exit = invocation.clone();
|
||||
|
||||
// spawn a background task to babysit the child process: capture stdout/stderr
|
||||
// into both the TUI log viewer and a timestamped log file on disk
|
||||
tokio::spawn(async move {
|
||||
use std::io::Write;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -1004,7 +982,6 @@ pub async fn launch(
|
||||
}
|
||||
drop(log_tx);
|
||||
|
||||
// wait for either the process to exit naturally or a kill signal from the TUI
|
||||
let (code, killed_by_user) = tokio::select! {
|
||||
_ = kill_rx => {
|
||||
tracing::info!("[{}] Kill requested, terminating process", name_for_task);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// live minecraft process log parser.
|
||||
//
|
||||
// disk launch logs stay raw, but the tui needs enough structure to color and
|
||||
// group output sanely. this parser keeps stdout/stderr as a hint, frames
|
||||
// multiline java/jvm/native bursts into events, then assigns a semantic level.
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// classpath and jvm patches for legacy forge on java 9+.
|
||||
// lwjgl3ify ships a patched launchwrapper and retrofuturabootstrap that
|
||||
// replace the old URLClassLoader-based launcher with one that works on
|
||||
// modern java. this module handles extracting those patches, building
|
||||
// the right --add-opens flags, and swapping out the broken log4j jars.
|
||||
// modern java.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -19,12 +17,6 @@ pub struct LwjglifyPatches {
|
||||
pub extra_args: Vec<String>,
|
||||
}
|
||||
|
||||
// checks if lwjgl3ify is present in the mods folder, and if so:
|
||||
// 1. extracts forge patches from the lwjgl3ify jar
|
||||
// 2. prepends them to the classpath so they shadow vanilla launchwrapper
|
||||
// 3. parses --add-opens from the patches manifest
|
||||
// 4. replaces log4j 2.0-beta9 with prism's patched builds
|
||||
// 5. returns the jvm args and overridden main class
|
||||
pub async fn apply(
|
||||
minecraft_dir: &Path,
|
||||
lib_dir: &Path,
|
||||
@@ -43,7 +35,6 @@ pub async fn apply(
|
||||
return None;
|
||||
}
|
||||
|
||||
// prepend so patched classes shadow vanilla launchwrapper
|
||||
classpath.insert(0, patches_dest.clone());
|
||||
|
||||
let mut jvm_args = parse_add_opens(&patches_dest).unwrap_or_default();
|
||||
@@ -214,7 +205,6 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec<PathBuf>) {
|
||||
insert_pos += 1;
|
||||
}
|
||||
|
||||
// natives
|
||||
let natives = if *module == "lwjgl" {
|
||||
lib_dir.join(format!(
|
||||
"org/lwjgl/lwjgl/3.3.3/lwjgl-3.3.3-{os_classifier}.jar"
|
||||
@@ -234,11 +224,8 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec<PathBuf>) {
|
||||
tracing::info!("Added {} LWJGL 3.3.3 jars to classpath", insert_pos - 1);
|
||||
}
|
||||
|
||||
// writes a log4j2.xml config that sets the root logger to INFO. this
|
||||
// prevents LaunchClassLoader's debug() call from ever firing, which
|
||||
// avoids the ThrowableProxy -> SecurityManager -> StackWalker infinite
|
||||
// recursion on java 24+. the config is written to .minecraft/ and
|
||||
// pointed to via -Dlog4j.configurationFile.
|
||||
// Suppresses LaunchClassLoader's debug() call to avoid the
|
||||
// ThrowableProxy -> SecurityManager -> StackWalker recursion on Java 24+.
|
||||
fn write_log4j_config(minecraft_dir: &Path, jvm_args: &mut Vec<String>) {
|
||||
let config_path = minecraft_dir.join(".rmcl-log4j2.xml");
|
||||
let config = r#"<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// fabric installation. the nice one: just fetch a profile json and download
|
||||
// the libraries. no java installer nonsense required.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// forge installation. modern forge runs a java installer, old forge (pre-1.13)
|
||||
// can't run headless so we extract the profile and libraries from the jar
|
||||
// directly. the installer jar gets cleaned up either way.
|
||||
// Old Forge installers cannot run headless, so their profiles and libraries
|
||||
// must be extracted from the jar instead.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -85,7 +84,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
let profile_filename = format!("forge-{game_version}-{loader_version}.json");
|
||||
|
||||
if has_legacy_install_profile(&installer_jar) {
|
||||
// old forge: no --installClient support, extract directly from jar
|
||||
tracing::debug!("Forge installer uses legacy install_profile.json path");
|
||||
if let Err(e) =
|
||||
install_forge_from_profile(client, &installer_jar, meta_dir, &profile_filename)
|
||||
@@ -95,7 +93,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
return Err(e);
|
||||
}
|
||||
} else {
|
||||
// modern forge: run the java installer
|
||||
let java_path = java_path.map(str::to_owned).unwrap_or_else(|| {
|
||||
crate::config::SETTINGS
|
||||
.read()
|
||||
@@ -110,7 +107,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
return Err(InstallError::Installer(e));
|
||||
}
|
||||
|
||||
// extract the profile from what the installer just wrote to disk
|
||||
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)
|
||||
.map_err(InstallError::Installer)?;
|
||||
}
|
||||
@@ -271,7 +267,6 @@ pub(crate) async fn install_forge_from_profile(
|
||||
InstallError::Installer(InstallerError::Profile("missing install.path".into()))
|
||||
})?;
|
||||
|
||||
// extract the universal jar to the correct maven location
|
||||
let universal_maven_path = crate::instance::loader::maven::maven_coord_to_path(
|
||||
install_path_coord,
|
||||
)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// maven coordinate handling shared by loader installation and launch profiles.
|
||||
|
||||
#[must_use]
|
||||
pub fn maven_coord_to_path(coord: &str) -> Option<String> {
|
||||
let parts: Vec<&str> = coord.split(':').collect();
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mod loader installation. each loader (fabric, forge, neoforge, quilt, vanilla)
|
||||
// implements the same trait so the UI can treat them uniformly: pick game version,
|
||||
// pick loader version, install. the actual installation strategies differ wildly
|
||||
// though (fabric/quilt just download jars, forge/neoforge run a whole java installer).
|
||||
|
||||
mod fabric;
|
||||
pub mod forge;
|
||||
pub mod maven;
|
||||
@@ -83,8 +78,7 @@ pub trait ModLoaderInstaller: Send + Sync {
|
||||
}
|
||||
}
|
||||
|
||||
// writes raw profile JSON bytes to meta_dir/loader-profiles/<filename>.
|
||||
// callers that already have the upstream bytes (fabric/quilt http fetch,
|
||||
// Callers that already have the upstream bytes (fabric/quilt http fetch,
|
||||
// legacy forge versionInfo extract) use this directly to keep the on-disk
|
||||
// file byte-for-byte identical to the source.
|
||||
pub(crate) fn save_profile_bytes(
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// neoforge installation. same java installer dance as forge (they forked from it,
|
||||
// after all), just with different URLs and version naming.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// quilt installation. same clean approach as fabric (profile json + library
|
||||
// downloads). they're basically fabric's cooler sibling.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// per-launch log files stored under minecraft/logs/launches/
|
||||
// each launch gets its own timestamped file so you can go back and see what
|
||||
// crashed last tuesday at 3am
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// in-memory ring buffer for stdout/stderr from running mc instances.
|
||||
// capped at 2000 lines per instance so it doesn't eat all the RAM
|
||||
// if someone leaves a server running for a week. you're welcome.
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// CRUD for instances: create, delete, rename, load, save.
|
||||
// creation is the heavy one since it downloads the game, assets, and libraries.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use chrono::Utc;
|
||||
@@ -94,7 +91,6 @@ impl InstanceManager {
|
||||
.create_inner(name, game_version, loader, loader_version, &instance_dir)
|
||||
.await;
|
||||
|
||||
// clean up on failure so there's no half-baked instance left around
|
||||
if result.is_err() {
|
||||
tracing::debug!(
|
||||
"Cleaning up incomplete instance '{}' after creation failed",
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// instance management: creation, launching, importing modpacks, and all the
|
||||
// bookkeeping that comes with pretending to be a real launcher
|
||||
|
||||
pub mod config_sync;
|
||||
pub mod content;
|
||||
pub mod desktop;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// core data types for an instance: what loader it uses, what version, memory
|
||||
// settings, etc. this is what gets persisted to instance.json
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// global tracking for running minecraft instances. everything is behind
|
||||
// Arc<Mutex<>> because the launch/monitor tasks live on separate tokio threads
|
||||
// and the TUI render loop needs to read state every frame.
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
// width/height are read from the actual image file so the TUI can show
|
||||
// dimensions. falls back to 1920x1080 if the file is corrupt or unreadable
|
||||
// because honestly, what else are you gonna pick
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ScreenshotEntry {
|
||||
pub name: String,
|
||||
@@ -44,7 +41,6 @@ pub fn scan_screenshots(instances_dir: &Path, instance_name: &str) -> Vec<Screen
|
||||
})
|
||||
.collect();
|
||||
|
||||
// sorted newest-first since minecraft names them with timestamps
|
||||
entries.sort_by(|a, b| b.name.cmp(&a.name));
|
||||
entries
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
use super::super::packs::extract_description;
|
||||
use serde_json::json;
|
||||
|
||||
// every case exercises a distinct match arm in extract_description.
|
||||
#[rstest::rstest]
|
||||
#[case::string(json!("Simple pack"), "Simple pack")]
|
||||
#[case::object_with_text(json!({"text": "Hello world"}), "Hello world")]
|
||||
|
||||
@@ -39,9 +39,6 @@ fn parse_mmc_pack_vanilla() {
|
||||
assert!(pack.loader().0.is_none());
|
||||
}
|
||||
|
||||
// builds an in-memory mmc-style pack zip and verifies that
|
||||
// extract_mmc_archive copies only the .minecraft/ subtree into the
|
||||
// destination, preserving relative paths and skipping siblings.
|
||||
#[test]
|
||||
fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
use std::io::Write;
|
||||
@@ -51,9 +48,6 @@ fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
let dest = tmp.path().join("instance/.minecraft");
|
||||
std::fs::create_dir_all(&dest).unwrap();
|
||||
|
||||
// Pack/ is the prefix; only .minecraft/ entries should land in dest.
|
||||
// mmc-style pack: a root dir "Pack/" wrapping the .minecraft tree
|
||||
// plus a sibling mmc-pack.json that should NOT be extracted.
|
||||
{
|
||||
let file = std::fs::File::create(&archive_path).unwrap();
|
||||
let mut zip = zip::ZipWriter::new(file);
|
||||
@@ -74,13 +68,11 @@ fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
|
||||
extract_mmc_archive(&archive_path, &dest).expect("extract");
|
||||
|
||||
// .minecraft/ entries must have been copied with their relative paths
|
||||
let options = std::fs::read(dest.join("options.txt")).expect("options.txt");
|
||||
assert_eq!(options, b"lang:en_us");
|
||||
let modjar = std::fs::read(dest.join("mods/test-mod.jar")).expect("mods/test-mod.jar");
|
||||
assert_eq!(modjar, b"jar-bytes");
|
||||
|
||||
// and the sibling outside .minecraft/ must not have been copied
|
||||
assert!(
|
||||
!dest.join("mmc-pack.json").exists(),
|
||||
"mmc-pack.json should not land in the instance dir"
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
use super::*;
|
||||
use std::io::Write;
|
||||
|
||||
// builds an in-memory zip with the given entries, writes it to tmp, and
|
||||
// returns the path. shared by parse_add_opens tests.
|
||||
fn make_zip(tmp: &Path, name: &str, entries: &[(&str, &[u8])]) -> PathBuf {
|
||||
let path = tmp.join(name);
|
||||
let file = std::fs::File::create(&path).unwrap();
|
||||
@@ -29,7 +27,6 @@ fn strip_replaced_libs_removes_dominated_prefixes() {
|
||||
PathBuf::from("/libs/commons-compress-1.4.1.jar"),
|
||||
PathBuf::from("/libs/commons-io-2.4.jar"),
|
||||
PathBuf::from("/libs/guava-15.0.jar"),
|
||||
// these stay
|
||||
PathBuf::from("/libs/log4j-core-2.0.jar"),
|
||||
PathBuf::from("/libs/guava-21.0.jar"),
|
||||
];
|
||||
@@ -130,8 +127,6 @@ fn add_lwjgl3_inserts_only_jars_that_exist() {
|
||||
let mut classpath = vec![PathBuf::from("/leading/forge-patches.jar")];
|
||||
add_lwjgl3(lib_dir, &mut classpath);
|
||||
|
||||
// forge-patches stays at index 0; lwjgl core is inserted at index 1.
|
||||
// none of the other modules existed so nothing else was added.
|
||||
assert_eq!(classpath[0], PathBuf::from("/leading/forge-patches.jar"));
|
||||
assert_eq!(classpath[1], core_jar);
|
||||
assert_eq!(classpath.len(), 2);
|
||||
|
||||
@@ -57,13 +57,6 @@ fn push_and_drain_last_played() {
|
||||
assert!(drained.iter().any(|(k, _)| k == "run_test_lp"));
|
||||
}
|
||||
|
||||
// Removed drain_empty_returns_empty: it relied on no other test pushing
|
||||
// to LAST_PLAYED between the two drain calls, which races with the
|
||||
// parallel push_and_drain_last_played test. The drain semantics are
|
||||
// already covered by push_and_drain_last_played, which asserts a
|
||||
// specific entry is present, and the empty-result path is exercised
|
||||
// implicitly any time drain runs after that test's cleanup.
|
||||
|
||||
#[test]
|
||||
fn send_kill_returns_false_for_missing() {
|
||||
assert!(!send_kill("run_never_registered_xyz"));
|
||||
@@ -74,7 +67,6 @@ fn register_and_send_kill() {
|
||||
let (tx, mut rx) = tokio::sync::oneshot::channel::<()>();
|
||||
register_kill("run_test_kill", tx);
|
||||
assert!(send_kill("run_test_kill"));
|
||||
// the kill signal itself must arrive, not just report success
|
||||
assert!(rx.try_recv().is_ok());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// primitives for parsing, merging, and rendering mojang-format launch
|
||||
// profiles. consumed by the vanilla launcher and the loader install paths
|
||||
// (forge/neoforge/fabric/quilt) - anything that reads a mojang-style
|
||||
// version JSON.
|
||||
|
||||
pub mod model;
|
||||
pub mod render;
|
||||
pub mod resolve;
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mojang-format launch profile types. mirrors the on-disk JSON schema
|
||||
// used by vanilla versions, forge installer output, neoforge installer
|
||||
// output, fabric profiles, and quilt profiles. parsing is lossless for
|
||||
// the fields we care about; unknown fields are silently dropped (serde
|
||||
// default behavior) - which is fine because we write upstream JSON
|
||||
// byte-for-byte on the install side.
|
||||
// Unknown JSON fields are dropped when parsing, but installer paths write the
|
||||
// upstream bytes unchanged, so this model never strips fields from the cache.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// renders a parsed launch profile into final argv-style lists for the JVM
|
||||
// and the game. resolves conditional argument shapes (`{rules, value}`),
|
||||
// filters them through the rule evaluator, and substitutes mojang template
|
||||
// variables. legacy `minecraftArguments` strings are tokenised on whitespace
|
||||
// and treated as a list of game args. pure function; no I/O.
|
||||
|
||||
use super::model::{Argument, ArgumentValue, LaunchProfile};
|
||||
use super::rules::{RuleContext, evaluate};
|
||||
use super::templates::{TemplateContext, substitute};
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// resolves the `inheritsFrom` chain of a parsed `LaunchProfile`. mojang's
|
||||
// version JSON allows a profile to inherit from another profile by id; the
|
||||
// loaders (forge / neoforge / fabric / quilt) use this to layer their
|
||||
// additions on top of a vanilla base. this module walks the chain and
|
||||
// returns a single flat profile.
|
||||
//
|
||||
// merge semantics (per the mojang launcher and the major third-party
|
||||
// launchers that interoperate with it):
|
||||
// - scalar fields: child wins if Some, else parent.
|
||||
@@ -15,10 +9,6 @@
|
||||
// - merge_into preserves parent's inherits_from so resolve() can keep
|
||||
// walking; resolve() clears the final result's inherits_from after
|
||||
// the loop exits.
|
||||
//
|
||||
// pure function `merge_into` handles the field-by-field merge math.
|
||||
// async `resolve` does the chain walking with cycle detection and a depth
|
||||
// cap. tests cover both layers independently.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -68,8 +58,6 @@ pub fn merge_into(child: LaunchProfile, parent: LaunchProfile) -> LaunchProfile
|
||||
// version and any classifier. used as the dedup key when merging library
|
||||
// lists from a child profile on top of its parent.
|
||||
fn coord_key(name: &str) -> &str {
|
||||
// mojang maven coords are `group:artifact:version[:classifier]`. take
|
||||
// everything up to the second colon.
|
||||
let mut it = name.match_indices(':').map(|(i, _)| i);
|
||||
it.next();
|
||||
it.next().map_or(name, |i| &name[..i])
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mojang rule evaluation. profiles, libraries, and argument entries can
|
||||
// carry conditional rules that filter them by OS, architecture, or feature
|
||||
// flags. this module is the single source of truth for that semantics -
|
||||
// see `evaluate` below for the exact rules.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// system-detection helpers shared by launch and install paths. mojang
|
||||
// names some things differently from rust's std::env::consts (e.g. macOS
|
||||
// Mojang names some things differently from rust's std::env::consts (e.g. macOS
|
||||
// is "osx" in mojang profile rules), so this module is the single source
|
||||
// of truth for translating.
|
||||
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// template substitution for mojang-style launch arguments. profiles use
|
||||
// `${variable_name}` placeholders that the launcher fills in at launch
|
||||
// time from the active session: paths, the user's account info, the
|
||||
// classpath, the resolved natives directory, and so on.
|
||||
//
|
||||
// the full set of variables is documented in `TemplateContext`. unknown
|
||||
// placeholders are left as-is and logged at `warn` level - that way if
|
||||
// mojang adds a new variable in the future, the launcher fails open
|
||||
// rather than silently swallowing it.
|
||||
// Keep unknown placeholders and warn so future Mojang variables remain visible
|
||||
// instead of silently disappearing.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -95,12 +95,10 @@ fn parses_modern_arguments_object() {
|
||||
assert_eq!(args.game.len(), 3);
|
||||
assert_eq!(args.jvm.len(), 2);
|
||||
|
||||
// first game arg should be a literal "--username"
|
||||
match &args.game[0] {
|
||||
Argument::Literal(s) => assert_eq!(s, "--username"),
|
||||
_ => panic!("expected literal"),
|
||||
}
|
||||
// third game arg should be a conditional with a single-string value
|
||||
match &args.game[2] {
|
||||
Argument::Conditional { rules, value } => {
|
||||
assert_eq!(rules.len(), 1);
|
||||
@@ -109,7 +107,6 @@ fn parses_modern_arguments_object() {
|
||||
}
|
||||
_ => panic!("expected conditional"),
|
||||
}
|
||||
// second jvm arg should be a conditional with a multi-string value
|
||||
match &args.jvm[1] {
|
||||
Argument::Conditional { value, .. } => {
|
||||
assert!(matches!(value, ArgumentValue::Multiple(_)));
|
||||
|
||||
@@ -239,12 +239,10 @@ async fn end_to_end_resolve_then_render_modern_forge_shape() {
|
||||
let fx = Fixture::new();
|
||||
let rendered = render_args(&merged, &fx.rule_ctx(), &fx.template_ctx()).unwrap();
|
||||
|
||||
// child main_class wins after merge
|
||||
assert_eq!(
|
||||
rendered.main_class,
|
||||
"cpw.mods.bootstraplauncher.BootstrapLauncher"
|
||||
);
|
||||
// game args: parent first then child
|
||||
assert_eq!(
|
||||
rendered.game,
|
||||
vec![
|
||||
@@ -256,7 +254,6 @@ async fn end_to_end_resolve_then_render_modern_forge_shape() {
|
||||
"forge_client"
|
||||
]
|
||||
);
|
||||
// jvm args: parent first then child
|
||||
assert_eq!(
|
||||
rendered.jvm,
|
||||
vec![
|
||||
|
||||
@@ -54,7 +54,6 @@ fn merge_carries_parent_inherits_from() {
|
||||
|
||||
#[test]
|
||||
fn merge_with_root_parent_clears_inherits_from() {
|
||||
// parent with no inherits_from means the chain ends.
|
||||
let mut child = empty_profile("child");
|
||||
child.inherits_from = Some("parent".into());
|
||||
let parent = empty_profile("parent");
|
||||
@@ -109,8 +108,6 @@ fn child_library_supersedes_parent_with_same_group_artifact() {
|
||||
];
|
||||
let merged = merge_into(child, parent);
|
||||
let names: Vec<_> = merged.libraries.iter().map(|l| l.name.as_str()).collect();
|
||||
// parent's log4j-core is filtered (superseded by child); parent's
|
||||
// lwjgl stays (no conflict); child's log4j and forge come last.
|
||||
assert_eq!(
|
||||
names,
|
||||
vec![
|
||||
@@ -128,12 +125,10 @@ fn coord_key_extracts_group_artifact() {
|
||||
coord_key("org.apache.logging.log4j:log4j-core:2.17.0"),
|
||||
"org.apache.logging.log4j:log4j-core"
|
||||
);
|
||||
// with classifier
|
||||
assert_eq!(
|
||||
coord_key("org.lwjgl:lwjgl:3.3.1:natives-linux"),
|
||||
"org.lwjgl:lwjgl"
|
||||
);
|
||||
// malformed (no colons) - return as-is
|
||||
assert_eq!(coord_key("malformed"), "malformed");
|
||||
}
|
||||
|
||||
@@ -346,7 +341,6 @@ async fn resolve_errors_when_parent_is_invalid_json() {
|
||||
async fn resolve_multi_level_chain_merges_all_parents() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
|
||||
// chain: grandchild -> child -> root (vanilla).
|
||||
let mut root = empty_profile("1.20.1");
|
||||
root.main_class = Some("net.minecraft.client.main.Main".into());
|
||||
root.libraries = vec![lib("vanilla-lib")];
|
||||
@@ -368,7 +362,6 @@ async fn resolve_multi_level_chain_merges_all_parents() {
|
||||
resolved.main_class.as_deref(),
|
||||
Some("net.minecraft.client.main.Main")
|
||||
);
|
||||
// libs: root ++ child ++ grandchild (each parent prepended)
|
||||
let names: Vec<_> = resolved.libraries.iter().map(|l| l.name.as_str()).collect();
|
||||
assert_eq!(names, vec!["vanilla-lib", "forge-lib", "modpack-lib"]);
|
||||
}
|
||||
@@ -377,7 +370,6 @@ async fn resolve_multi_level_chain_merges_all_parents() {
|
||||
async fn resolve_detects_circular_chain() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
|
||||
// a -> b -> a (cycle)
|
||||
let mut a = empty_profile("a");
|
||||
a.inherits_from = Some("b".into());
|
||||
write_profile(tmp.path(), &a);
|
||||
@@ -386,7 +378,6 @@ async fn resolve_detects_circular_chain() {
|
||||
b.inherits_from = Some("a".into());
|
||||
write_profile(tmp.path(), &b);
|
||||
|
||||
// start from a fresh "a" profile that asks to inherit from b
|
||||
let mut entry = empty_profile("a");
|
||||
entry.inherits_from = Some("b".into());
|
||||
|
||||
@@ -401,8 +392,6 @@ async fn resolve_detects_circular_chain() {
|
||||
async fn resolve_caps_depth() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
|
||||
// build a chain 0 -> 1 -> 2 -> ... -> 10. with cap of 8, hitting 10
|
||||
// should fail with DepthExceeded.
|
||||
for i in 0..=10 {
|
||||
let mut p = empty_profile(&format!("v{i}"));
|
||||
if i < 10 {
|
||||
|
||||
@@ -53,8 +53,6 @@ fn single_disallow_matching_os_disallows() {
|
||||
|
||||
#[test]
|
||||
fn allow_without_os_match_disallows_by_default() {
|
||||
// explicit allow for windows; we are on linux; nothing matches;
|
||||
// default state remains disallow.
|
||||
let rules = vec![Rule {
|
||||
action: RuleAction::Allow,
|
||||
os: Some(OsCondition {
|
||||
@@ -95,7 +93,6 @@ fn last_matching_rule_wins_when_allow_then_disallow() {
|
||||
features: &features,
|
||||
};
|
||||
assert!(!evaluate(&rules, &osx_ctx));
|
||||
// and on linux: only the first rule matches → still allow.
|
||||
let lin = linux_ctx(&features);
|
||||
assert!(evaluate(&rules, &lin));
|
||||
}
|
||||
@@ -136,7 +133,6 @@ fn arch_mismatch_blocks_rule() {
|
||||
}];
|
||||
let features = FeatureSet::default();
|
||||
let ctx = linux_ctx(&features);
|
||||
// we are on linux but x86_64, not arm64 → rule does not match.
|
||||
assert!(!evaluate(&rules, &ctx));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// crate root. main.rs is a thin wrapper that imports the two entry points
|
||||
// re-exported below; everything else stays crate-private. integration tests
|
||||
// in tests/ that need to reach in deeper can use `rmcl::auth`, `rmcl::net`,
|
||||
// etc. directly; cli + migrate stay private because they have nothing
|
||||
// general to expose.
|
||||
|
||||
pub mod auth;
|
||||
mod cli;
|
||||
pub mod config;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// curseforge api client. responses are mapped into the same app-facing
|
||||
// project/version types used by discovery, so the tui stays provider-neutral.
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::instance::{ContentKind, ModLoader};
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// fabric mod loader: fetches loader metadata and downloads libraries
|
||||
// from fabric's maven. structurally very similar to quilt (they forked).
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -51,9 +48,6 @@ pub async fn fetch_fabric_game_versions(client: &HttpClient) -> Result<Vec<GameV
|
||||
fetch_fabric_game_versions_from(client, FABRIC_META_BASE).await
|
||||
}
|
||||
|
||||
// same as fetch_fabric_game_versions but lets tests point at a wiremock
|
||||
// server. fabric's API is hierarchical, so we take the base URL and append
|
||||
// the rest of the path inside.
|
||||
pub async fn fetch_fabric_game_versions_from(
|
||||
client: &HttpClient,
|
||||
meta_base: &str,
|
||||
@@ -151,8 +145,6 @@ pub async fn fetch_fabric_profile_with_raw_from(
|
||||
client.get_json_with_raw(&url, "Fabric profile").await
|
||||
}
|
||||
|
||||
// each fabric library entry has a maven coordinate and a base url.
|
||||
// the coordinate gets resolved to a path and combined with the url to download.
|
||||
pub async fn download_fabric_libraries(
|
||||
client: &HttpClient,
|
||||
profile: &FabricProfile,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// forge mod loader: version discovery via promotions API, download and
|
||||
// installation. modern forge runs a java installer, old forge (pre-1.13ish)
|
||||
// doesn't support headless install so we extract directly from the jar.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -23,8 +19,6 @@ struct ForgePromotions {
|
||||
promos: HashMap<String, String>,
|
||||
}
|
||||
|
||||
// forge promotions use keys like "1.20.1-recommended", "1.20.1-latest"
|
||||
// so this filters by game version prefix and extracts the forge version values
|
||||
pub async fn fetch_forge_versions(
|
||||
client: &HttpClient,
|
||||
game_version: &str,
|
||||
@@ -32,7 +26,6 @@ pub async fn fetch_forge_versions(
|
||||
fetch_forge_versions_from(client, FORGE_PROMOTIONS_URL, game_version).await
|
||||
}
|
||||
|
||||
// same as fetch_forge_versions but lets tests point at a wiremock server.
|
||||
pub async fn fetch_forge_versions_from(
|
||||
client: &HttpClient,
|
||||
promotions_url: &str,
|
||||
@@ -58,8 +51,6 @@ pub async fn fetch_forge_versions_from(
|
||||
Ok(versions)
|
||||
}
|
||||
|
||||
// extracts unique game versions from the promotion keys by splitting off
|
||||
// the "-recommended"/"-latest" suffix
|
||||
pub async fn fetch_forge_game_versions(client: &HttpClient) -> Result<Vec<GameVersion>, NetError> {
|
||||
fetch_forge_game_versions_from(client, FORGE_PROMOTIONS_URL).await
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// networking layer: http client, file downloads, and shared utilities
|
||||
// for fetching game assets from mojang, mod loaders, and modrinth.
|
||||
|
||||
pub mod curseforge;
|
||||
pub mod fabric;
|
||||
pub mod forge;
|
||||
@@ -181,9 +178,6 @@ impl HttpClient {
|
||||
}
|
||||
}
|
||||
|
||||
// shared retry envelope around `client.get(url).await? -> decode`. retries
|
||||
// transient failures (timeouts, connect errors, 5xx) with exponential
|
||||
// backoff. used by both get_json and get_bytes.
|
||||
async fn get_with_retry<T, F, Fut>(client: &HttpClient, url: &str, decode: F) -> Result<T, NetError>
|
||||
where
|
||||
F: Fn(reqwest::Response) -> Fut,
|
||||
@@ -230,9 +224,7 @@ async fn sleep_before_retry(kind: &str, url: &str, attempt: u32, err: &NetError)
|
||||
tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
|
||||
}
|
||||
|
||||
// streams a file to disk in chunks, calling progress_cb(downloaded, total) along the way.
|
||||
// total will be 0 if the server doesn't send content-length, so callers
|
||||
// should handle that gracefully. retries transient failures with exponential backoff.
|
||||
// total is 0 without a Content-Length; callers must handle unknown sizes.
|
||||
pub async fn download_file(
|
||||
client: &HttpClient,
|
||||
url: &str,
|
||||
@@ -265,7 +257,6 @@ pub async fn download_file(
|
||||
result
|
||||
}
|
||||
|
||||
// single attempt at downloading a file to disk
|
||||
async fn download_file_once(
|
||||
client: &HttpClient,
|
||||
url: &str,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modrinth api client and provider file downloads.
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
||||
+1
-24
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// handles all downloads from mojang's servers: version manifests,
|
||||
// client jars, libraries, and asset objects. this is the core of
|
||||
// getting vanilla minecraft onto disk.
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
@@ -136,9 +132,6 @@ pub async fn fetch_version_manifest(client: &HttpClient) -> Result<VersionManife
|
||||
fetch_version_manifest_from(client, MANIFEST_URL).await
|
||||
}
|
||||
|
||||
// same as fetch_version_manifest but lets the caller pick the URL. exists so
|
||||
// integration tests can point at a wiremock server; production callers go
|
||||
// through fetch_version_manifest with the upstream Mojang URL.
|
||||
pub async fn fetch_version_manifest_from(
|
||||
client: &HttpClient,
|
||||
url: &str,
|
||||
@@ -170,7 +163,6 @@ pub async fn fetch_version_meta_with_raw(
|
||||
client.get_json_with_raw(&entry.url, "version meta").await
|
||||
}
|
||||
|
||||
// sha1 of a file as lowercase hex, or None if unreadable.
|
||||
fn sha1_hex(path: &Path) -> Option<String> {
|
||||
use sha1::Digest;
|
||||
use std::io::Read;
|
||||
@@ -187,7 +179,6 @@ fn sha1_hex(path: &Path) -> Option<String> {
|
||||
Some(format!("{:x}", hasher.finalize()))
|
||||
}
|
||||
|
||||
// true when the cached file matches mojang's recorded size + sha1.
|
||||
// guards against partial files left by killed downloads: those used to be
|
||||
// trusted forever on the strength of an exists() check alone. size is
|
||||
// checked first so truncated files skip the hashing cost.
|
||||
@@ -282,8 +273,6 @@ pub async fn download_libraries(
|
||||
features: &features,
|
||||
};
|
||||
|
||||
// matches the directory launch passes as java.library.path
|
||||
// (instance/launch/mod.rs).
|
||||
let natives_dir = crate::storage::MetadataPaths::new(meta_dir)
|
||||
.versions()
|
||||
.join(&meta.id)
|
||||
@@ -383,9 +372,6 @@ pub async fn download_libraries(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// relative path of a library artifact inside the shared library cache.
|
||||
// upstream usually records it; fall back to deriving it from the maven
|
||||
// coordinate when the field is missing/empty.
|
||||
fn library_relative_path(library: &Library, recorded_path: &str) -> Option<String> {
|
||||
if !recorded_path.is_empty() {
|
||||
return Some(recorded_path.to_owned());
|
||||
@@ -393,8 +379,6 @@ fn library_relative_path(library: &Library, recorded_path: &str) -> Option<Strin
|
||||
crate::instance::loader::maven::maven_coord_to_path(&library.name)
|
||||
}
|
||||
|
||||
// unpacks a natives jar into dest. skips directories, archive entries with
|
||||
// traversal paths, and anything matching an `extract.exclude` prefix.
|
||||
fn extract_natives(jar: &Path, dest: &Path, exclude: &[String]) -> Result<(), NetError> {
|
||||
let file = std::fs::File::open(jar)?;
|
||||
let mut archive = zip::ZipArchive::new(file)
|
||||
@@ -410,7 +394,6 @@ fn extract_natives(jar: &Path, dest: &Path, exclude: &[String]) -> Result<(), Ne
|
||||
if entry.is_dir() {
|
||||
continue;
|
||||
}
|
||||
// enclosed_name is None for absolute paths / .. traversal
|
||||
let Some(rel) = entry.enclosed_name() else {
|
||||
tracing::warn!(
|
||||
"Skipping unsafe path in natives jar {}: {}",
|
||||
@@ -443,8 +426,6 @@ pub async fn download_assets(
|
||||
download_assets_from(client, meta, meta_dir, ASSETS_BASE_URL).await
|
||||
}
|
||||
|
||||
// same as download_assets but lets tests point at a wiremock server for the
|
||||
// per-asset CDN downloads. the asset index URL still comes from meta.
|
||||
pub async fn download_assets_from(
|
||||
client: &HttpClient,
|
||||
meta: &VersionMeta,
|
||||
@@ -503,8 +484,6 @@ pub async fn download_assets_from(
|
||||
index
|
||||
};
|
||||
|
||||
// assets are stored by hash with the first 2 chars as a directory prefix,
|
||||
// e.g. "ab/ab1234..." - same layout mojang uses on their CDN
|
||||
let mut downloads = Vec::new();
|
||||
for object in asset_index.objects.values() {
|
||||
if object.hash.len() < 2 {
|
||||
@@ -546,9 +525,7 @@ pub async fn download_assets_from(
|
||||
result
|
||||
}
|
||||
|
||||
// bounded parallel downloader. spawns up to MAX_CONCURRENT_DOWNLOADS tasks
|
||||
// and feeds new ones in as each completes. collects errors but keeps going
|
||||
// so it downloads as much as possible before reporting the first failure.
|
||||
// Continue other downloads after one fails; report the first error afterward.
|
||||
async fn run_parallel_downloads(
|
||||
client: &HttpClient,
|
||||
downloads: Vec<(String, PathBuf, String)>,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// neoforge: the forge fork that broke away after 1.20.1.
|
||||
// uses a different versioning scheme where neoforge versions map to
|
||||
// minecraft versions by dropping the "1." prefix (e.g. MC 1.21 = NF 21.x).
|
||||
// like forge, installation requires running their installer jar.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
@@ -30,15 +25,11 @@ struct NeoForgeMavenVersions {
|
||||
fn game_version_to_neoforge_prefix(game_version: &str) -> Option<String> {
|
||||
let parts: Vec<&str> = game_version.split('.').collect();
|
||||
match parts.as_slice() {
|
||||
// "1.21" → prefix "21.0."
|
||||
["1", minor] => Some(format!("{}.0.", minor)),
|
||||
// "1.20.4" → prefix "20.4."
|
||||
["1", minor, patch] => Some(format!("{}.{}.", minor, patch)),
|
||||
// "26.1.2" → prefix "26.1.2."
|
||||
[major, minor, patch] if leading_u32(major).is_some_and(|major| major >= 26) => {
|
||||
Some(format!("{major}.{minor}.{patch}."))
|
||||
}
|
||||
// "26.1" → prefix "26.1."
|
||||
[major, minor] if leading_u32(major).is_some_and(|major| major >= 26) => {
|
||||
Some(format!("{major}.{minor}."))
|
||||
}
|
||||
@@ -80,7 +71,6 @@ pub async fn fetch_neoforge_versions(
|
||||
fetch_neoforge_versions_from(client, NEOFORGE_API_BASE, game_version).await
|
||||
}
|
||||
|
||||
// same as fetch_neoforge_versions but lets tests point at a wiremock server.
|
||||
pub async fn fetch_neoforge_versions_from(
|
||||
client: &HttpClient,
|
||||
api_url: &str,
|
||||
@@ -113,8 +103,6 @@ pub async fn fetch_neoforge_versions_from(
|
||||
Ok(versions)
|
||||
}
|
||||
|
||||
// reverse-engineers minecraft versions from neoforge version numbers.
|
||||
// e.g. neoforge "21.0.x" means MC 1.21, "20.4.x" means MC 1.20.4
|
||||
pub async fn fetch_neoforge_game_versions(
|
||||
client: &HttpClient,
|
||||
) -> Result<Vec<GameVersion>, NetError> {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// quilt mod loader: fabric fork with a nearly identical metadata API.
|
||||
// if you're getting deja vu reading this after fabric.rs, that's why.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -48,8 +45,6 @@ pub async fn fetch_quilt_game_versions(client: &HttpClient) -> Result<Vec<GameVe
|
||||
fetch_quilt_game_versions_from(client, QUILT_META_BASE).await
|
||||
}
|
||||
|
||||
// same as fetch_quilt_game_versions but lets tests point at a wiremock
|
||||
// server. quilt mirrors the fabric API shape.
|
||||
pub async fn fetch_quilt_game_versions_from(
|
||||
client: &HttpClient,
|
||||
meta_base: &str,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// app state: holds everything the TUI needs between frames.
|
||||
// this is basically the "god struct" of the UI. not ideal, but ratatui
|
||||
// kinda pushes you into this pattern since you need mutable access
|
||||
// to all the widget states during rendering.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
@@ -15,8 +10,6 @@ use tachyonfx::Effect;
|
||||
use super::widgets::{self, instances};
|
||||
use crate::instance::{InstanceConfig, InstanceManager};
|
||||
|
||||
// background tasks (instance creation, import) push completed configs here
|
||||
// so the main loop can pick them up without blocking
|
||||
pub(super) static PENDING_INSTANCES: LazyLock<Arc<Mutex<Vec<InstanceConfig>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(Vec::new())));
|
||||
pub(super) static COMPLETED_INSTANCE_SETTINGS_UPDATES: LazyLock<Arc<Mutex<Vec<InstanceConfig>>>> =
|
||||
@@ -78,7 +71,6 @@ pub(super) struct ProviderConflictState {
|
||||
pub selected: usize,
|
||||
}
|
||||
|
||||
// lifecycle of an error toast animation: slide in -> sit there -> fade out
|
||||
pub(super) enum ErrorEffectState {
|
||||
SlidingIn(Effect, std::time::Instant),
|
||||
Idle,
|
||||
|
||||
@@ -20,7 +20,6 @@ use crate::feedback::progress;
|
||||
use crate::instance::InstanceManager;
|
||||
|
||||
impl App {
|
||||
/// main loop: poll async results and input at ~60Hz, drawing only when state changes
|
||||
pub async fn run(&mut self, terminal: &mut Tui) -> color_eyre::Result<()> {
|
||||
let mut last_draw = std::time::Instant::now()
|
||||
.checked_sub(Duration::from_secs(1))
|
||||
@@ -30,7 +29,6 @@ impl App {
|
||||
let mut image_redraw_marker = false;
|
||||
while !self.exit {
|
||||
let redraw_requested = crate::feedback::take_redraw_request();
|
||||
// check if any popup wizard finished and wants to create/import
|
||||
if let Some(params) = new_instance::take_result() {
|
||||
self.spawn_create(params);
|
||||
}
|
||||
@@ -42,9 +40,6 @@ impl App {
|
||||
|
||||
self.dismiss_expired_errors();
|
||||
|
||||
// drain all the channels from background tasks.
|
||||
// every content type has its own pending queue because they each
|
||||
// get scanned/loaded on separate tokio tasks
|
||||
self.drain_pending_instances();
|
||||
self.drain_completed_instance_settings_updates();
|
||||
self.drain_failed_instance_settings_updates();
|
||||
@@ -543,8 +538,6 @@ impl App {
|
||||
});
|
||||
}
|
||||
|
||||
// polls for input with a 16ms timeout (~60fps). only key presses are handled,
|
||||
// releases and repeats are ignored thanks to the enhanced keyboard protocol
|
||||
fn handle_events(&mut self) -> color_eyre::Result<bool> {
|
||||
match crossterm::event::poll(Duration::from_millis(16)) {
|
||||
Ok(true) => match event::read() {
|
||||
@@ -879,8 +872,6 @@ impl App {
|
||||
});
|
||||
}
|
||||
|
||||
// pops errors from the front of the queue once they've been visible long enough.
|
||||
// loops because multiple errors could expire in the same frame
|
||||
fn dismiss_expired_errors(&self) {
|
||||
use crate::config::SETTINGS;
|
||||
loop {
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// keybindings and input dispatch.
|
||||
// the general pattern: check which area is focused, give it first crack at the
|
||||
// keypress, and fall through to global bindings if nobody claimed it.
|
||||
// vim-style navigation (j/k/g/G) where it makes sense.
|
||||
|
||||
use ratatui::crossterm::event::{
|
||||
KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind,
|
||||
};
|
||||
@@ -415,8 +410,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
// content area delegates to whichever tab is active.
|
||||
// worlds use the same list navigation without the toggle
|
||||
if self.focused == FocusedArea::Content
|
||||
&& self.content_mode == widgets::content::ContentMode::Installed
|
||||
&& let Some(state) = self.active_discovery_state_mut()
|
||||
@@ -956,7 +949,6 @@ impl App {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// global keybindings (uppercase = area switch, lowercase = action)
|
||||
match key_event.code {
|
||||
KeyCode::Char('q') => self.exit = true,
|
||||
KeyCode::Esc
|
||||
@@ -1049,7 +1041,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
// shift+enter = open .minecraft folder in file manager
|
||||
KeyCode::Enter
|
||||
if self.focused == FocusedArea::Instances
|
||||
&& !self.instances_state.search.active
|
||||
@@ -1066,7 +1057,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
// plain enter = focus the content area for the selected instance
|
||||
KeyCode::Enter
|
||||
if self.focused == FocusedArea::Instances
|
||||
&& !self.instances_state.search.active =>
|
||||
@@ -1110,7 +1100,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
// esc = kill running instance. brutal but effective
|
||||
KeyCode::Esc
|
||||
if self.focused == FocusedArea::Instances
|
||||
&& !self.instances_state.search.active =>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// sets up the tracing subscriber stack: file logging, tui-logger widget, and
|
||||
// our custom StatusLayer that feeds WARN/ERROR events into the error toast system.
|
||||
// also keeps an in-memory ring buffer of log lines for the log overlay viewer.
|
||||
|
||||
use std::fmt;
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -24,7 +20,6 @@ use crate::feedback::errors::{self as error_buffer, ErrorEvent};
|
||||
const MINECRAFT_LOG_TARGET: &str = "mc_instance";
|
||||
const DEFAULT_FILE_FILTER: &str = "warn,rmcl=trace";
|
||||
|
||||
// capped at 5000 lines so it doesn't eat all the ram if something goes haywire
|
||||
static APP_LOG_LINES: LazyLock<Arc<Mutex<Vec<String>>>> =
|
||||
LazyLock::new(|| Arc::new(Mutex::new(Vec::new())));
|
||||
|
||||
@@ -44,8 +39,6 @@ fn push_app_log(line: String) {
|
||||
|
||||
// returns a WorkerGuard that must be held alive for the duration of the
|
||||
// program, otherwise the file logging thread gets dropped immediately.
|
||||
// yes, you will spend 30 minutes debugging "why aren't my logs writing"
|
||||
// before you remember this. ask me how i know.
|
||||
pub fn init() -> WorkerGuard {
|
||||
let log_dir = match dirs_next::cache_dir() {
|
||||
Some(d) => d.join("rmcl"),
|
||||
@@ -118,9 +111,6 @@ fn open_log_writer(log_dir: &Path) -> (NonBlocking, WorkerGuard) {
|
||||
}
|
||||
}
|
||||
|
||||
// custom tracing layer that intercepts all log events:
|
||||
// - everything gets appended to the in-memory log buffer for the overlay viewer
|
||||
// - WARN and ERROR additionally get pushed as error toasts
|
||||
struct StatusLayer;
|
||||
|
||||
impl StatusLayer {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// tui entrypoint: sets up the terminal, runs the app, cleans up on exit.
|
||||
|
||||
pub mod app;
|
||||
mod event;
|
||||
mod input;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// layout and rendering. the main frame is split into:
|
||||
// left 20%: instance sidebar
|
||||
// right 80%: title bar + content area + bottom bar (account / details / status)
|
||||
// popups and error toasts render on top of everything.
|
||||
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
@@ -165,7 +160,6 @@ impl App {
|
||||
widgets::popups::global_settings::render(frame, area, state);
|
||||
}
|
||||
|
||||
// error toasts stack from the top, each one below the previous
|
||||
let all_errors = error_buffer::peek_all_errors();
|
||||
self.sync_error_effects(&all_errors);
|
||||
let mut next_y: u16 = 1;
|
||||
@@ -220,8 +214,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
// full-screen log viewer with search highlighting and auto-scroll.
|
||||
// auto-sticks to the bottom unless the user scrolled up manually
|
||||
fn render_log_overlay(&mut self, frame: &mut Frame) {
|
||||
use crate::config::theme::{BORDER_STYLE, THEME};
|
||||
use crate::tui::logging::get_app_logs;
|
||||
@@ -322,8 +314,6 @@ impl App {
|
||||
);
|
||||
}
|
||||
|
||||
// keeps the effect map in sync with current errors: removes effects for
|
||||
// dismissed errors and creates slide-in effects for new ones
|
||||
fn sync_error_effects(&mut self, events: &[error_buffer::ErrorEvent]) {
|
||||
use crate::config::theme::THEME;
|
||||
let theme = THEME.as_ref();
|
||||
@@ -348,8 +338,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
// drives the slide-in / idle / slide-out state machine for each error toast.
|
||||
// transitions to FadingOut at the configured slide-start time
|
||||
fn render_error_effect(
|
||||
&mut self,
|
||||
frame: &mut Frame,
|
||||
|
||||
@@ -1428,7 +1428,6 @@ fn confirming_popup_toggles_skip_dependencies_with_s() {
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('s')), &mut state));
|
||||
assert!(!state.version_popup.as_ref().unwrap().skip_dependencies);
|
||||
|
||||
// Toggling is blocked while loading or installing.
|
||||
state.version_popup.as_mut().unwrap().loading = true;
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('s')), &mut state));
|
||||
assert!(!state.version_popup.as_ref().unwrap().skip_dependencies);
|
||||
@@ -1505,7 +1504,6 @@ fn installed_mode_defaults_to_any_game_version() {
|
||||
assert_eq!(state.filters.game_version, GameVersionFilter::Any);
|
||||
assert_eq!(state.active_filter_count(), 0);
|
||||
|
||||
// The same Any filter counts as active in discovery mode.
|
||||
state.set_local_mode(false);
|
||||
state.filters.game_version = GameVersionFilter::Any;
|
||||
assert_eq!(state.active_filter_count(), 1);
|
||||
|
||||
@@ -13,7 +13,6 @@ fn confirm_keeps_query_but_deactivates() {
|
||||
s.confirm();
|
||||
assert!(!s.active);
|
||||
assert_eq!(s.query, "ab");
|
||||
// filter should still match
|
||||
assert!(s.matches("abc"));
|
||||
assert!(!s.matches("xyz"));
|
||||
s.activate();
|
||||
@@ -29,7 +28,6 @@ fn deactivate_clears_query() {
|
||||
s.deactivate();
|
||||
assert!(!s.active);
|
||||
assert!(s.query.is_empty());
|
||||
// with empty query, everything matches
|
||||
assert!(s.matches("anything"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// account management panel: list, add (microsoft/offline), delete
|
||||
// microsoft auth uses the device code flow, so it polls a shared mutex
|
||||
// for the result while showing the user a code to enter in their browser
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
@@ -196,8 +192,6 @@ pub fn handle_key(key_event: &KeyEvent, state: &mut AccountState) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// the device code arrives asynchronously from the auth thread,
|
||||
// so it gets pulled out of a global mutex once it's ready
|
||||
pub fn drain_device_code(state: &mut AccountState) {
|
||||
if let AddMode::DeviceCodeWaiting { info, .. } = &mut state.add_mode
|
||||
&& info.user_code.is_empty()
|
||||
@@ -335,7 +329,6 @@ fn render_account_list(
|
||||
frame.render_stateful_widget(list, area, &mut state.list_state);
|
||||
}
|
||||
|
||||
// center a popup of given size within the terminal. nothing fancy
|
||||
fn popup_area(frame: &Frame, width: u16, height: u16) -> Rect {
|
||||
let area = frame.area();
|
||||
let x = area.x + (area.width.saturating_sub(width)) / 2;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// generic scrollable list for content items (mods, resource packs, shaders, worlds).
|
||||
// supports toggling items on/off by renaming files with .disabled suffix,
|
||||
// search filtering, per-instance caching, and directory change detection.
|
||||
// also handles minecraft's formatting codes for colored mod names/descriptions
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::Path;
|
||||
@@ -245,7 +240,6 @@ struct PaginationState {
|
||||
|
||||
const REMOVAL_GRACE: std::time::Duration = std::time::Duration::from_millis(500);
|
||||
|
||||
// result from the notify-triggered background diff
|
||||
struct WatcherDiff {
|
||||
toggled: Vec<(String, bool, std::path::PathBuf)>,
|
||||
removed: Vec<String>,
|
||||
@@ -292,19 +286,15 @@ pub struct ContentListState {
|
||||
cache: HashMap<String, CachedList>,
|
||||
sort_metadata: RefCell<HashMap<std::path::PathBuf, FileSortMetadata>>,
|
||||
filtered_cache: RefCell<Option<CachedSelection>>,
|
||||
// streaming: individual entries arrive here during initial load
|
||||
stream_rx: Option<mpsc::Receiver<ContentStreamUpdate>>,
|
||||
stream_order: ContentStreamOrder,
|
||||
progressive_source_stream: bool,
|
||||
staged_source_updates: Option<Vec<ContentStreamUpdate>>,
|
||||
source_order_ready: bool,
|
||||
preview_count: usize,
|
||||
// file watcher: notify callback spawns background work,
|
||||
// precomputed diff lands here for the UI to pick up
|
||||
watcher_diff: Arc<Mutex<Option<WatcherDiff>>>,
|
||||
_watcher: Option<notify::RecommendedWatcher>,
|
||||
watched_dir: Option<std::path::PathBuf>,
|
||||
// stored for the watcher to scan individual new files
|
||||
scan_one_fn: Option<ScanOneFn>,
|
||||
content_ext: Option<&'static str>,
|
||||
pagination: Option<PaginationState>,
|
||||
@@ -1175,7 +1165,6 @@ impl ContentListState {
|
||||
};
|
||||
self.images_dirty |= update.requires_reconcile;
|
||||
|
||||
// apply toggles (enabled/path changes)
|
||||
tracing::debug!(
|
||||
"Applying content watcher diff for {}: toggled={} removed={} added={}",
|
||||
self.loaded_for.as_deref().unwrap_or("<unknown>"),
|
||||
@@ -1214,7 +1203,6 @@ impl ContentListState {
|
||||
.or_insert_with(std::time::Instant::now);
|
||||
}
|
||||
|
||||
// insert new entries in sorted position
|
||||
for mut entry in diff.added {
|
||||
self.sort_metadata.get_mut().remove(&entry.path);
|
||||
let replacement = self.entries.iter().position(|existing| {
|
||||
@@ -1310,13 +1298,10 @@ impl ContentListState {
|
||||
removed
|
||||
}
|
||||
|
||||
// starts a notify file watcher on the given directory. changes trigger
|
||||
// a background diff that lands in watcher_diff for drain_watcher to apply.
|
||||
pub fn watch_dir(&mut self, dir: std::path::PathBuf) {
|
||||
use notify::{RecursiveMode, Watcher};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
// drop previous watcher
|
||||
self._watcher = None;
|
||||
|
||||
let watcher_diff = self.watcher_diff.clone();
|
||||
@@ -1706,9 +1691,6 @@ impl ContentListState {
|
||||
}
|
||||
}
|
||||
|
||||
// saves current entries to cache before loading new ones, and restores
|
||||
// from cache if this instance was seen before (avoids re-scanning).
|
||||
// content_dir is the actual directory to scan (e.g. .minecraft/mods).
|
||||
pub fn start_load(
|
||||
&mut self,
|
||||
content_dir: &Path,
|
||||
@@ -1724,7 +1706,6 @@ impl ContentListState {
|
||||
self.pending_entry_images.clear();
|
||||
self.pending_removals.clear();
|
||||
|
||||
// save current entries to cache
|
||||
if let Some(prev) = self.loaded_for.take()
|
||||
&& !self.entries.is_empty()
|
||||
{
|
||||
@@ -1743,7 +1724,6 @@ impl ContentListState {
|
||||
);
|
||||
}
|
||||
|
||||
// try cache first
|
||||
// files modified while another instance was active become a real problem.
|
||||
if let Some(cached) = self.cache.remove(instance_name) {
|
||||
self.entries = cached.entries;
|
||||
@@ -1769,7 +1749,6 @@ impl ContentListState {
|
||||
return;
|
||||
}
|
||||
|
||||
// no cache, stream entries one by one as each file is scanned
|
||||
let stream = self.start_stream(instance_name);
|
||||
|
||||
let dir = content_dir.to_path_buf();
|
||||
@@ -2690,8 +2669,6 @@ fn searchable_spans(
|
||||
}
|
||||
}
|
||||
|
||||
// parses minecraft's section-sign (U+00A7) formatting codes into styled spans.
|
||||
// handles colors (0-f), bold (l), strikethrough (m), underline (n), italic (o), reset (r)
|
||||
fn parse_mc_text(text: &str, base_style: Style) -> Vec<Span<'static>> {
|
||||
let mut spans = Vec::new();
|
||||
let mut current_style = base_style;
|
||||
@@ -2976,10 +2953,6 @@ fn watcher_event_handling(kind: ¬ify::EventKind) -> WatcherEventHandling {
|
||||
}
|
||||
}
|
||||
|
||||
// reads a content directory and builds a stem -> (path, enabled) map.
|
||||
// used both by watch_dir to initialize known state and by the watcher
|
||||
// thread to detect changes. when ext is empty (worlds), only directories
|
||||
// are included.
|
||||
fn diff_directory(
|
||||
dir: &std::path::Path,
|
||||
ext: &str,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// the tabbed content area: mods, resource packs, shaders, screenshots, worlds, logs
|
||||
|
||||
pub mod discovery;
|
||||
pub mod list;
|
||||
pub mod tabs;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// the outer frame for the content area: tab bar, keybind footer,
|
||||
// and dispatching render calls to the active tab's widget.
|
||||
// also renders the instance name/version header with run state indicators.
|
||||
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
|
||||
@@ -357,8 +353,6 @@ pub fn render(
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// keybinds change depending on which tab is active and whether
|
||||
// the content panel or instances panel has focus
|
||||
let kb: Option<&[(&str, &str)]> = if is_focused {
|
||||
Some(match (mode, tab) {
|
||||
(ContentMode::Discover, _) if discovery_unavailable => {
|
||||
@@ -1762,8 +1756,6 @@ fn discovery_version_label(version: &crate::net::modrinth::VersionInfo) -> Strin
|
||||
version.version_number.clone()
|
||||
}
|
||||
|
||||
// the header bar above the content tabs, showing instance name, loader info,
|
||||
// and a spinner/error indicator when the instance is running or crashed
|
||||
pub fn title(
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// the instance list on the left side of the UI.
|
||||
// handles search/filter, scrollbar sync, and inline renaming.
|
||||
// each row shows instance name + "last played" or current run state.
|
||||
|
||||
use crate::config::theme::{BORDER_STYLE, THEME};
|
||||
use crossterm::event::KeyCode;
|
||||
use ratatui::{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// split-pane log viewer: file list on the left, log content on the right.
|
||||
// supports live log tailing when the instance is running, plus search
|
||||
// filtering in both the file list and the viewer pane.
|
||||
// log scanning runs on a background thread to avoid blocking the UI.
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -132,7 +127,6 @@ impl LogsState {
|
||||
}
|
||||
}
|
||||
|
||||
// periodically re-scan log files in case new ones appeared while playing.
|
||||
pub fn try_rescan(&mut self) {
|
||||
if self.last_rescan.elapsed() < std::time::Duration::from_secs(2) {
|
||||
return;
|
||||
@@ -676,8 +670,6 @@ fn log_level_style(level: LogLevel) -> Style {
|
||||
}
|
||||
}
|
||||
|
||||
// color-code log lines by severity so errors actually stand out
|
||||
// instead of drowning in a wall of white text
|
||||
fn line_level_style(line: &str) -> Style {
|
||||
let theme = THEME.as_ref();
|
||||
let upper = line.to_uppercase();
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shared widget utilities and the trait all key-handling widgets implement
|
||||
|
||||
use crate::config::theme::THEME;
|
||||
use crossterm::event::KeyEvent;
|
||||
use ratatui::{
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// base frame that all popups render inside. handles the border, title bar,
|
||||
// keybind footer, and optional search indicator. content is injected via closure
|
||||
// so each popup type only worries about its inner area.
|
||||
|
||||
use ratatui::{
|
||||
buffer::{Buffer, CellDiffOption},
|
||||
layout::{Alignment, Rect},
|
||||
@@ -40,7 +36,6 @@ impl<'a> Widget for PopupFrame<'a> {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// clear first so the popup doesn't layer on top of whatever was underneath
|
||||
Clear.render(area, buf);
|
||||
|
||||
if let Some(bg) = self.bg {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// "are you sure?" popup for destructive actions. uses global state so the
|
||||
// confirmation target persists across render frames.
|
||||
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::Mutex;
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// toast-style error/warning popup that auto-dismisses after a timeout.
|
||||
// stacks in the top-right corner; border color changes based on severity.
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
@@ -66,8 +63,6 @@ impl Widget for ErrorPopup {
|
||||
}
|
||||
}
|
||||
|
||||
// returns None when the toast has lived past its expiry, which is
|
||||
// what triggers removal from the render loop
|
||||
pub fn popup_area(frame_area: Rect, message: &str, base_y: u16, elapsed_ms: u128) -> Option<Rect> {
|
||||
use super::word_wrap_size;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modal editor for launcher-wide settings.
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// rendering for the modpack import wizard. same pattern as new_instance:
|
||||
// snapshot the state, pick the right step renderer, done.
|
||||
|
||||
use super::super::LoadState;
|
||||
use super::super::base::PopupFrame;
|
||||
use super::state::{DISCOVERY_STATE, IMPORT_STATE, ImportStep, ImportWizardState};
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// state machine for the modpack import wizard.
|
||||
// browses modpacks from configured providers and keeps the archive import flow
|
||||
// for modrinth URLs, project slugs, version IDs, and local pack archives.
|
||||
|
||||
use super::super::LoadState;
|
||||
use crate::instance::import::{ImportInput, ImportSummary, parse_import_input};
|
||||
use crate::net::modrinth::{self, VersionInfo};
|
||||
@@ -387,7 +383,6 @@ fn handle_confirm_key(
|
||||
}
|
||||
}
|
||||
|
||||
// pushes an error toast and rewinds the wizard to a previous step
|
||||
fn update_current_request(
|
||||
state_arc: &Arc<Mutex<ImportWizardState>>,
|
||||
request_id: u64,
|
||||
@@ -419,8 +414,6 @@ fn begin_import_request(state: &mut ImportWizardState) -> u64 {
|
||||
request_id
|
||||
}
|
||||
|
||||
// parses user input to figure out what they gave us, then dispatches
|
||||
// to the appropriate resolve path (slug lookup, direct version, or local file)
|
||||
fn start_resolve(state: &mut ImportWizardState) {
|
||||
let input_text = state.input.clone();
|
||||
state.step = ImportStep::Fetching;
|
||||
@@ -559,8 +552,6 @@ fn resolve_local_file(state_arc: Arc<Mutex<ImportWizardState>>, request_id: u64,
|
||||
}
|
||||
}
|
||||
|
||||
// user picked a version from the list. download the .mrpack,
|
||||
// build a summary, and move to confirm.
|
||||
fn start_version_download(state: &mut ImportWizardState) {
|
||||
let version = match selected_version(state) {
|
||||
Some(v) => v.clone(),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modal editor for settings belonging to the selected Minecraft instance.
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shared utilities for popup widgets: layout helpers, word wrapping, keybind rendering.
|
||||
// individual popup types live in their own submodules.
|
||||
|
||||
pub mod base;
|
||||
pub mod confirm;
|
||||
pub mod error;
|
||||
@@ -41,8 +38,6 @@ pub(crate) fn compare_game_versions(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
a_parts.len().cmp(&b_parts.len())
|
||||
}
|
||||
|
||||
// figures out the (width, height) a text block will need after word wrapping.
|
||||
// used to size popups before rendering so they fit their content snugly.
|
||||
pub fn word_wrap_size(text: &str, max_inner_width: usize) -> (usize, usize) {
|
||||
if text.is_empty() || max_inner_width == 0 {
|
||||
return (0, 1);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// rendering for the new instance wizard. each step gets its own render fn
|
||||
// and the popup resizes itself based on which step is active.
|
||||
|
||||
use super::super::LoadState;
|
||||
use super::state::{
|
||||
WIZARD_STATE, WizardState, WizardStep, clamp_loader_version_index, clamp_version_index,
|
||||
@@ -33,7 +30,6 @@ pub fn render(frame: &mut Frame, area: Rect, _focused: FocusedArea) {
|
||||
clamp_version_index(&mut state);
|
||||
}
|
||||
|
||||
// vanilla has no loader version, so skip straight to confirm
|
||||
if state.step == WizardStep::LoaderVersion {
|
||||
if state.selected_loader() == ModLoader::Vanilla {
|
||||
state.step = WizardStep::Confirm;
|
||||
@@ -141,7 +137,6 @@ fn step_keybinds(state: &WizardState) -> ratatui::text::Line<'static> {
|
||||
fn render_name_step(state: &WizardState, area: Rect, buf: &mut ratatui::buffer::Buffer) {
|
||||
let theme = THEME.as_ref();
|
||||
let value = state.name_state.value();
|
||||
// \u{2588} is the full block char used as a fake blinking cursor
|
||||
let line = if value.is_empty() {
|
||||
Line::from(vec![
|
||||
Span::styled("Instance name...", Style::default().fg(theme.text_dim())),
|
||||
|
||||
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user