From 108ced5793a63fee19235a94c34f14647748bd2b Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 07:41:24 +0100 Subject: [PATCH] launcher: a Shader packs tab that installs Horizon's own shader packs The Mods page gets a fourth kind, Shader packs, which searches Horizon's registry and installs a `.hshader` into `shaderpacks/` once `index::check_file` has run the game's own `horizon_shader_api::check`. Modrinth and CurseForge answer that tab with a pointer to the registry: their shader packs are the shaders/ format and are not offered. The sample index lists a shader pack (`glow`, made with `horizon-shader new` and `pack`), so the registry build, check_file and the launcher's install are tested on a real file. A file of the same name the registry didn't put in place is no longer called a mod. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-mods/src/index.rs | 2 +- .../horizon-mods/src/index/registry/tests.rs | 31 +++++++++++++-- crates/horizon-mods/src/index/tests.rs | 11 ++++-- .../tests/index/glow-1.0.0.hshader | Bin 0 -> 689 bytes crates/horizon-mods/tests/index/index-v1.json | 28 ++++++++++++++ docs/api/mod-index.md | 4 +- docs/launcher-commands.md | 2 +- docs/mod-browser.md | 16 +++++--- docs/shaders.md | 3 +- launcher/src/browser.rs | 11 +++++- launcher/src/browser/curseforge.rs | 10 ++++- launcher/src/browser/horizon.rs | 17 ++++++--- launcher/src/browser/horizon/tests.rs | 36 ++++++++++++++++++ launcher/src/browser/modrinth.rs | 6 +++ launcher/src/cli.rs | 3 ++ launcher/src/cli_tools.rs | 2 +- launcher/src/main.rs | 6 +-- launcher/src/mods_page.rs | 29 +++++++++----- 18 files changed, 178 insertions(+), 39 deletions(-) create mode 100644 crates/horizon-mods/tests/index/glow-1.0.0.hshader diff --git a/crates/horizon-mods/src/index.rs b/crates/horizon-mods/src/index.rs index 13dd69eb6..3b456c538 100644 --- a/crates/horizon-mods/src/index.rs +++ b/crates/horizon-mods/src/index.rs @@ -449,7 +449,7 @@ pub fn check_file( (None, None) => Trust::Unsigned, _ => return Err("its signature and the project's key don't go together".into()), }; - if matches!(project.kind, Kind::Shader | Kind::Other(_)) { + if matches!(project.kind, Kind::Other(_)) { return Err(format!( "this Horizon can't install a {} yet", project.kind.name() diff --git a/crates/horizon-mods/src/index/registry/tests.rs b/crates/horizon-mods/src/index/registry/tests.rs index 9e17c695f..923d64615 100644 --- a/crates/horizon-mods/src/index/registry/tests.rs +++ b/crates/horizon-mods/src/index/registry/tests.rs @@ -1,9 +1,10 @@ -//! A registry checkout holding the sample index's mod and modpack builds the -//! sample index (`tests/index/index-v1.json`) exactly. +//! A registry checkout holding the sample index's mod, modpack and shader pack +//! builds the sample index (`tests/index/index-v1.json`) exactly. use super::*; const HMOD: &str = "e1135345692f6dd8fd4c51920151944b82333e17049c9bb7d756f27b8deefc53"; const HPACK: &str = "241ac840f9c5ea3f6252d849da10c90d36cb1da4d6cd8d1d268c2760a353cd65"; +const HSHADER: &str = "331cfe29a666a0de804e9a9ff3d19d246eebcfbfa70b4f49bba8482d30ad9f02"; fn fixtures() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/index") @@ -61,6 +62,23 @@ file = "cozy-1.0.0.hpack" sha256 = "241ac840f9c5ea3f6252d849da10c90d36cb1da4d6cd8d1d268c2760a353cd65" "#; +const GLOW: &str = r#"id = "glow" +kind = "shader" +name = "Soft Glow" +summary = "A post-processing pass over the world." +authors = ["Horizon"] +owners = ["ludovic111"] +license = "MIT" +source = "https://github.com/ludovic111/horizon-mods" + +[[versions]] +version = "1.0.0" +published = "2026-10-26" +game = "26.3" +file = "glow-1.0.0.hshader" +sha256 = "331cfe29a666a0de804e9a9ff3d19d246eebcfbfa70b4f49bba8482d30ad9f02" +"#; + const REVOKED_TOML: &str = r#"[[revoked]] id = "bad_mod" sha256 = "1111111111111111111111111111111111111111111111111111111111111111" @@ -82,9 +100,14 @@ impl Scratch { let s = Scratch(dir); s.write("mods/coords_hud.toml", &hud_entry()); s.write("mods/cozy.toml", COZY); + s.write("mods/glow.toml", GLOW); s.write("revoked.toml", REVOKED_TOML); s.write("icons/coords_hud.png", "png"); - for (name, hash) in [("coords_hud-0.1.0.hmod", HMOD), ("cozy-1.0.0.hpack", HPACK)] { + for (name, hash) in [ + ("coords_hud-0.1.0.hmod", HMOD), + ("cozy-1.0.0.hpack", HPACK), + ("glow-1.0.0.hshader", HSHADER), + ] { std::fs::copy(fixtures().join(name), s.0.join("files").join(hash)).unwrap(); } s @@ -117,7 +140,7 @@ fn builds_the_sample_index() { let s = Scratch::new("sample"); let built = s.build().unwrap(); let sample = sample(); - assert_eq!(built.projects, sample.projects[..2]); + assert_eq!(built.projects, sample.projects[..3]); assert_eq!(built.revoked, sample.revoked); assert_eq!(built.generated, sample.generated); // What it writes reads back. diff --git a/crates/horizon-mods/src/index/tests.rs b/crates/horizon-mods/src/index/tests.rs index 1da921300..be5abd910 100644 --- a/crates/horizon-mods/src/index/tests.rs +++ b/crates/horizon-mods/src/index/tests.rs @@ -1,7 +1,8 @@ //! The sample index (`tests/index/index-v1.json`, the one docs/api/mod-index.md //! shows) and its files: `coords_hud-0.1.0.hmod`, signed with the throwaway -//! key `test.pub` by minisign 0.12 (its secret key was deleted), and -//! `cozy-1.0.0.hpack`, unsigned. +//! key `test.pub` by minisign 0.12 (its secret key was deleted), +//! `cozy-1.0.0.hpack`, unsigned, and `glow-1.0.0.hshader`, unsigned +//! (`horizon-shader new --template post`, then `horizon-shader pack`). use super::*; use std::path::PathBuf; @@ -25,8 +26,8 @@ fn reads_the_sample_and_keeps_unknown_kinds() { let index = sample(); assert_eq!(index.schema, SCHEMA); let kinds: Vec<&str> = index.projects.iter().map(|p| p.kind.name()).collect(); - assert_eq!(kinds, ["mod", "modpack", "world"]); - assert_eq!(index.projects[2].kind, Kind::Other("world".into())); + assert_eq!(kinds, ["mod", "modpack", "shader", "world"]); + assert_eq!(index.projects[3].kind, Kind::Other("world".into())); let hud = index.project("coords_hud").unwrap(); assert_eq!( hud.versions[0].capabilities, @@ -44,6 +45,8 @@ fn files_pass_against_their_entries() { assert_eq!(check(&index, "coords_hud", &hmod), Ok(Trust::Verified)); let hpack = fixtures().join("cozy-1.0.0.hpack"); assert_eq!(check(&index, "cozy", &hpack), Ok(Trust::Unsigned)); + let hshader = fixtures().join("glow-1.0.0.hshader"); + assert_eq!(check(&index, "glow", &hshader), Ok(Trust::Unsigned)); let world = index.project("skyblock_start").unwrap(); let e = check_file(&index, world, &world.versions[0], &hpack).unwrap_err(); assert!(e.contains("bytes"), "{e}"); diff --git a/crates/horizon-mods/tests/index/glow-1.0.0.hshader b/crates/horizon-mods/tests/index/glow-1.0.0.hshader new file mode 100644 index 0000000000000000000000000000000000000000..dda1651f89f0f8cdb22180846e9e10316dcb1680 GIT binary patch literal 689 zcmWIWW@Zs#U|`??VnqfyGh>NkK$Zz30|Q7jBfluKDnC!RI3qD7wWwIHBtJLDw|`^a zVFMnQ^19Xqdz)epB)2bewqKB(AhJqVn@J^DV5Qa1-yL2JDN64j9-e7=8s($lCl8>XMr z?^(Zdv+knQ%$+x-BJY_#X3_Mx`HfqpI`ek*?T*-ehgY)xyL#1n-ofX;X0Q0nnHPZK zZ}I8}o0)-rUIfIPKz|qH7nkUjrx)j>_MP@SY#`wJ{b$#1<%vPh1HG1t>`G#^ZaK0~ zZJxc_MXi8<@@WW=-W zBfShWkIuZ1wKR;w+GgH8IoBy0yQDT9S;ckgir(bp={v)W9*2F~uFlqK5inOy{e6&( zls3CnOs?)%n@(?+6u*?*;=Vusu<609 ze&MUzzsuZztj)B3o=x90JIU~8hdOS3ImT68O5(SZg4>MmPfMNj zX5Bo=/` and turned on | Checked from its jar before install: **Works**, **Partly** or **Doesn't run** ([below](#java-mods)) | | Resource packs | `resourcepacks/` beside `options.txt` | **Works** when made for 26.3 ([resource-packs.md](resource-packs.md) lists what Horizon reads). Older packs are **Partly**: they load with vanilla's compatibility warning | | Modpacks (`.mrpack`, CurseForge zip) | the Modpacks page's import | **Partly**: Horizon runs the mods it can port, from the player's own downloads ([modpacks.md](modpacks.md)) | +| Shader packs (`.hshader`, Horizon's registry only) | `shaderpacks/` beside `options.txt` | **Works** when made for 26.3: checked by the game's own check before install ([shaders.md](shaders.md)). The `shaders/`-format packs on Modrinth and CurseForge are not offered | By default a search shows only what runs: Java mods made for 26.3, resource packs made for 26.3, and every modpack. **Show everything** lists the rest of the kind too, each marked with how well it runs; what doesn't run is never offered for install. @@ -74,7 +75,8 @@ start); the hedge places and its recipe crafts 4. ## The Mods page -The launcher's **Mods** page has the three kinds as tabs (Mods, Modpacks, Resource packs), a search field (Enter searches), **Show everything** and +The launcher's **Mods** page has the four kinds as tabs (Mods, Modpacks, Resource packs, Shader packs; the last +searches Horizon's registry), a search field (Enter searches), **Show everything** and the source: Modrinth, with **CurseForge (coming soon)** beside it, disabled. Each result is an index row: its summary, author, downloads, source and licence, how well it runs (and why), **Page** (the project's page on its source) and **Install** (**Import** for a modpack). The Modpacks tab lists the imported packs first, with their coverage @@ -125,7 +127,8 @@ same name the player put there is never overwritten. - **Install** picks the newest version that runs, then its required dependencies, checked before any download: a dependency that isn't a pack Horizon loads (a Java mod) stops the install. Dependencies go in first. A resource - pack still has to be turned on in the game's Resource Packs screen, as in vanilla. + pack still has to be turned on in the game's Resource Packs screen, as in vanilla, and a shader pack picked in + the game's Shader Packs page. - **Update** installs the newer version and removes the old file. - **Remove** deletes the file and its entry. Packs installed as dependencies stay. - **A modpack** is downloaded (checked the same way) into `ports/downloads/`, imported, and ported straight away @@ -149,7 +152,7 @@ horizon-launcher mods remove faithful-32x ## Sources -**Horizon's registry.** Mods (`.hmod`) and resource packs made for Horizon, reviewed as pull requests in +**Horizon's registry.** Mods (`.hmod`), modpacks (`.hpack`), resource packs and shader packs (`.hshader`) made for Horizon, reviewed as pull requests in [ludovic111/horizon-mods](https://github.com/ludovic111/horizon-mods) ([api/mod-index.md](api/mod-index.md)). The launcher reads its `index.json` (`browser/horizon.rs`; `HORIZON_MOD_INDEX=` reads a test registry instead, whose files may then be on disk) at most every ten minutes, and keeps the last copy in @@ -164,7 +167,8 @@ checked pack, `pack.json` and `home/`, the profile's game folder, where each of like any registry mod and turned on or off as the pack says; its overrides (settings, resource packs, a mod's saved settings) are copied in on the first install only, so the player's changes survive updates. A pack whose mod was taken down installs nothing. It is listed on the Modpacks tab with **Play** and **Remove**, and plays like an imported pack -(`modpacks::apply_profile`). Shader packs are listed by the index but not installed by this launcher yet. +(`modpacks::apply_profile`). A shader pack goes to `shaderpacks/` once `check_file` has run the game's own +check on it (`horizon_shader_api::check`); a taken-down one is named, for the player to remove. ```sh horizon-launcher mods search --source horizon --kind mod coords # with whether it is signed and what it may do diff --git a/docs/shaders.md b/docs/shaders.md index ef8521cfe..394397193 100644 --- a/docs/shaders.md +++ b/docs/shaders.md @@ -14,7 +14,8 @@ Horizon's own format. | Templates | `crates/horizon-shader-api/templates/` | post, sky, material | | Example pack | `crates/horizon-shader-api/packs/golden_hour` | a warm sky and two post passes | | In the game: the post stage | `HORIZON_SHADER_PACK=` (for development, until the Shader Packs page) | post passes, hot reload | -| In the game: sky and material; the launcher and the registry | | not yet | +| The registry and the launcher | `shader` kind ([api/mod-index.md](api/mod-index.md)); the Mods page's Shader packs tab | checked, then installed into `shaderpacks/` | +| In the game: sky and material | | not yet | ## Quick start diff --git a/launcher/src/browser.rs b/launcher/src/browser.rs index 7f81d5e37..295ba3c08 100644 --- a/launcher/src/browser.rs +++ b/launcher/src/browser.rs @@ -28,16 +28,20 @@ pub enum Kind { Modpack, /// A Java mod: its content is ported ([`java`]). Mod, + /// One of Horizon's own shader packs (`.hshader`, docs/shaders.md), from Horizon's registry + /// only. + Shader, } impl Kind { - pub const ALL: [Kind; 3] = [Kind::Mod, Kind::Modpack, Kind::ResourcePack]; + pub const ALL: [Kind; 4] = [Kind::Mod, Kind::Modpack, Kind::ResourcePack, Kind::Shader]; pub fn label(self) -> &'static str { match self { Kind::Mod => "Mods", Kind::ResourcePack => "Resource packs", Kind::Modpack => "Modpacks", + Kind::Shader => "Shader packs", } } @@ -46,6 +50,7 @@ impl Kind { pub fn folder(self) -> Option<&'static str> { match self { Kind::ResourcePack => Some("resourcepacks"), + Kind::Shader => Some("shaderpacks"), Kind::Modpack | Kind::Mod => None, } } @@ -237,6 +242,9 @@ pub trait Source: Send + Sync { /// What the launcher says wherever CurseForge would be. pub const CURSEFORGE_SOON: &str = "CurseForge support is coming soon."; +/// What another source answers for shader packs: Horizon's own are on its registry only. +pub const SHADERS_ON_HORIZON: &str = + "Horizon's shader packs are on Horizon's registry: pick Horizon."; /// The sources this launcher uses: Modrinth and Horizon's registry. CurseForge support is coming /// soon: its API needs a paid key, so no search or install goes to it; `curseforge` is kept for @@ -277,6 +285,7 @@ pub fn support(kind: Kind, game_versions: &[String], loaders: &[String]) -> Supp Kind::Modpack => { Support::Partial("Horizon runs the mods it can port, from your own downloads.".into()) } + Kind::Shader => Support::No("Not one of Horizon's own shader packs.".into()), Kind::Mod => { if !loaders.iter().any(|l| java::LOADERS.contains(&l.as_str())) { Support::No("Not a Fabric, NeoForge or Forge mod.".into()) diff --git a/launcher/src/browser/curseforge.rs b/launcher/src/browser/curseforge.rs index e17a6b822..1db533a93 100644 --- a/launcher/src/browser/curseforge.rs +++ b/launcher/src/browser/curseforge.rs @@ -24,11 +24,16 @@ fn class(kind: Kind) -> u64 { Kind::ResourcePack => 12, Kind::Modpack => 4471, Kind::Mod => 6, + Kind::Shader => 6552, } } +/// The kind of a CurseForge class; its shader packs (the shaders/ format) are not offered. fn kind_of(class_id: u64) -> Option { - Kind::ALL.into_iter().find(|k| class(*k) == class_id) + Kind::ALL + .into_iter() + .filter(|k| *k != Kind::Shader) + .find(|k| class(*k) == class_id) } /// The key: the environment's, else the one built in. Empty counts as none. @@ -196,6 +201,9 @@ impl Source for CurseForge { } fn search(&self, query: &Query) -> Result, String> { + if query.kind == Kind::Shader { + return Err(super::SHADERS_ON_HORIZON.into()); + } let found = self.get(&search_url(query))?; Ok(found["data"] .as_array() diff --git a/launcher/src/browser/horizon.rs b/launcher/src/browser/horizon.rs index 66553ab50..1aad20734 100644 --- a/launcher/src/browser/horizon.rs +++ b/launcher/src/browser/horizon.rs @@ -111,13 +111,14 @@ fn fetch_index() -> Result<(Index, String), String> { } /// The browser's kind for a registry kind; None for one the launcher doesn't install yet -/// (shader packs, kinds newer than this launcher). +/// (kinds newer than this launcher). fn kind_of(kind: &index::Kind) -> Option { match kind { index::Kind::Mod => Some(Kind::Mod), index::Kind::ResourcePack => Some(Kind::ResourcePack), index::Kind::Modpack => Some(Kind::Modpack), - index::Kind::Shader | index::Kind::Other(_) => None, + index::Kind::Shader => Some(Kind::Shader), + index::Kind::Other(_) => None, } } @@ -372,6 +373,7 @@ fn relative(kind: Kind, id: &str, file_name: &str) -> Result { match kind { Kind::Mod => Ok(format!("{}/{id}.hmod", java::MODS_DIR)), Kind::ResourcePack => Ok(format!("resourcepacks/{file_name}")), + Kind::Shader => Ok(format!("shaderpacks/{file_name}")), Kind::Modpack => Err("A modpack installs as its own profile (pack::install).".into()), } } @@ -418,7 +420,8 @@ fn newest<'a>(index: &Index, p: &'a index::Project) -> Result<&'a index::Version }) } -/// Installs version `v` of the registry's mod or resource pack `p` into the game folder `home`. +/// Installs version `v` of the registry's mod, resource pack or shader pack `p` into the game +/// folder `home`. fn install_version( index: &Index, local: bool, @@ -447,13 +450,17 @@ fn install_version( other.title )); } - if (target.exists() && old.as_ref().is_none_or(|o| o.file != relative)) || folder_mod.exists() { + let clash = target.exists() && old.as_ref().is_none_or(|o| o.file != relative); + if project.kind == Kind::Mod && (clash || folder_mod.exists()) { return Err(format!( "A mod with the id {} is already in {}: move it away first.", p.id, java::MODS_DIR )); } + if clash { + return Err(format!("{relative} is already there: move it away first.")); + } let line = format!("{} {}", p.name, v.version); let file = &version_of(index, p, v).files[0]; let staging = home.join("mod-browser/downloads"); @@ -518,7 +525,7 @@ pub fn turn_off_revoked(index: &Index, home: &Path) -> Vec { e.title, r.reason )); } - } else if e.kind == Kind::ResourcePack { + } else if matches!(e.kind, Kind::ResourcePack | Kind::Shader) { out.push(format!( "{} was taken down: {} Remove it.", e.title, r.reason diff --git a/launcher/src/browser/horizon/tests.rs b/launcher/src/browser/horizon/tests.rs index fb99462e1..314be2050 100644 --- a/launcher/src/browser/horizon/tests.rs +++ b/launcher/src/browser/horizon/tests.rs @@ -48,6 +48,7 @@ fn searches_by_kind_and_words() { // Modpacks under Modpacks; a kind this launcher can't install yet (a world) never. assert_eq!(found("", Kind::Modpack), ["cozy"]); assert!(found("skyblock", Kind::ResourcePack).is_empty()); + assert_eq!(found("", Kind::Shader), ["glow"]); let p = hud(&index); assert_eq!(p.support(), super::super::Support::Works); assert_eq!(p.page, "https://playhorizon.dev/mods/coords_hud"); @@ -95,6 +96,41 @@ fn installs_checked_turns_on_and_removes() { fs::remove_dir_all(&home).unwrap(); } +#[test] +fn installs_a_shader_pack_into_shaderpacks() { + let index = sample(); + let home = scratch("shader"); + let p = project_of(index.project("glow").unwrap()).unwrap(); + assert_eq!(p.support(), super::super::Support::Works); + let done = install_from(&index, true, &p, &home, &|_, _| {}).unwrap(); + assert_eq!(done[0].file, "shaderpacks/glow-1.0.0.hshader"); + assert_eq!(done[0].kind, Kind::Shader); + assert!(home.join("shaderpacks/glow-1.0.0.hshader").is_file()); + // Not a mod: nothing turns on in horizon-mods.txt; the game's Shader Packs page picks it. + assert!(!home.join("horizon-mods.txt").exists()); + + let mut revoked = index.clone(); + revoked.revoked.push(index::Revoked { + id: "glow".into(), + sha256: None, + reason: "Test.".into(), + date: String::new(), + }); + let said = turn_off_revoked(&revoked, &home); + assert_eq!(said, ["Soft Glow was taken down: Test. Remove it."]); + + installed::remove(&home, "glow").unwrap(); + assert!(!home.join("shaderpacks/glow-1.0.0.hshader").exists()); + // A file of the same name the registry didn't put there is left alone. + fs::write(home.join("shaderpacks/glow-1.0.0.hshader"), b"mine").unwrap(); + let e = install_from(&index, true, &p, &home, &|_, _| {}).unwrap_err(); + assert_eq!( + e, + "shaderpacks/glow-1.0.0.hshader is already there: move it away first." + ); + fs::remove_dir_all(&home).unwrap(); +} + #[test] fn refuses_a_changed_file_a_taken_id_and_local_files_from_the_real_registry() { let index = sample(); diff --git a/launcher/src/browser/modrinth.rs b/launcher/src/browser/modrinth.rs index 52e0aa7f0..dabd9a604 100644 --- a/launcher/src/browser/modrinth.rs +++ b/launcher/src/browser/modrinth.rs @@ -13,12 +13,15 @@ fn project_type(kind: Kind) -> &'static str { Kind::ResourcePack => "resourcepack", Kind::Modpack => "modpack", Kind::Mod => "mod", + Kind::Shader => "shader", } } +/// The kind of a Modrinth project; its shader packs (the shaders/ format) are not offered. fn kind_of(project_type: &str) -> Option { Kind::ALL .into_iter() + .filter(|k| *k != Kind::Shader) .find(|k| self::project_type(*k) == project_type) } @@ -170,6 +173,9 @@ impl Source for Modrinth { } fn search(&self, query: &Query) -> Result, String> { + if query.kind == Kind::Shader { + return Err(super::SHADERS_ON_HORIZON.into()); + } let found = get(&search_url(query))?; Ok(found["hits"] .as_array() diff --git a/launcher/src/cli.rs b/launcher/src/cli.rs index 25bbe0bee..64ddb1bd2 100644 --- a/launcher/src/cli.rs +++ b/launcher/src/cli.rs @@ -210,6 +210,8 @@ enum KindArg { Mod, Resource, Modpack, + /// Horizon's own shader packs (Horizon's registry only) + Shader, } #[derive(Clone, Copy, clap::ValueEnum)] @@ -1120,6 +1122,7 @@ fn mods(action: ModsCmd, as_json: bool) -> Result<(), String> { KindArg::Resource => Kind::ResourcePack, KindArg::Modpack => Kind::Modpack, KindArg::Mod => Kind::Mod, + KindArg::Shader => Kind::Shader, }; let query = Query { everything, diff --git a/launcher/src/cli_tools.rs b/launcher/src/cli_tools.rs index e420576b5..45763296a 100644 --- a/launcher/src/cli_tools.rs +++ b/launcher/src/cli_tools.rs @@ -394,7 +394,7 @@ mod tests { let kinds = &schema["inputSchema"]["properties"]["kind"]["enum"]; assert!( kinds.as_array().unwrap().contains(&json!("modpack")) - && !kinds.as_array().unwrap().contains(&json!("shader")), + && kinds.as_array().unwrap().contains(&json!("shader")), "{kinds}" ); assert_eq!( diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 9105f71a2..7d778b6b9 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -54,11 +54,11 @@ enum Page { } impl Page { - /// `HORIZON_LAUNCHER_PAGE=mods` (or `modpacks`, `servers`, `versions`, `notes`, `settings`) - /// opens on that page, for screenshots; Home otherwise. + /// `HORIZON_LAUNCHER_PAGE=mods` (or `modpacks`, `shaders`, `servers`, `versions`, `notes`, + /// `settings`) opens on that page, for screenshots; Home otherwise. fn from_env() -> Page { match std::env::var("HORIZON_LAUNCHER_PAGE").as_deref() { - Ok("mods" | "modpacks") => Page::Mods, + Ok("mods" | "modpacks" | "shaders") => Page::Mods, Ok("servers") => Page::Servers, Ok("versions") => Page::Versions, Ok("notes") => Page::Notes, diff --git a/launcher/src/mods_page.rs b/launcher/src/mods_page.rs index 50434756c..e6ebedc5b 100644 --- a/launcher/src/mods_page.rs +++ b/launcher/src/mods_page.rs @@ -14,10 +14,11 @@ use horizon_port_pack::check::Check; use std::collections::HashMap; /// The kinds, as the Mods page's tabs: name and icon. -const KINDS: [(PackKind, &str, &str); 3] = [ +const KINDS: [(PackKind, &str, &str); 4] = [ (PackKind::Mod, "Mods", "box"), (PackKind::Modpack, "Modpacks", "archive"), (PackKind::ResourcePack, "Resource packs", "image"), + (PackKind::Shader, "Shader packs", "zap"), ]; /// Java mods checked at once. const CHECKING: usize = 2; @@ -99,14 +100,18 @@ impl Mods { pub(super) fn new(cx: &mut App) -> Self { let (tx, rx) = channel(); + let page = std::env::var("HORIZON_LAUNCHER_PAGE"); + let kind = match page.as_deref() { + Ok("modpacks") => PackKind::Modpack, + Ok("shaders") => PackKind::Shader, + _ => PackKind::Mod, + }; Self { - kind: if std::env::var("HORIZON_LAUNCHER_PAGE").as_deref() == Ok("modpacks") { - PackKind::Modpack - } else { - PackKind::Mod - }, - // `HORIZON_LAUNCHER_SOURCE=horizon` opens on Horizon's registry, for screenshots. + kind, + // `HORIZON_LAUNCHER_SOURCE=horizon` opens on Horizon's registry, for screenshots; + // shader packs are only there. source: match std::env::var("HORIZON_LAUNCHER_SOURCE").as_deref() { + _ if kind == PackKind::Shader => SourceId::Horizon, Ok("horizon") => SourceId::Horizon, _ => SourceId::Modrinth, }, @@ -602,9 +607,9 @@ impl Launcher { } let header = page_header( "Mods", - "Mods made for Horizon from its own reviewed registry, and Java mods, modpacks and \ - resource packs from Modrinth: Horizon ports what a Java mod carries (blocks, items, \ - recipes, worldgen) and says before you install what runs. Each file is checked \ + "Mods and shader packs made for Horizon from its own reviewed registry, and Java \ + mods, modpacks and resource packs from Modrinth: Horizon ports what a Java mod \ + carries (blocks, items, recipes, worldgen) and says before you install what runs. Each file is checked \ against its source's checksum before it reaches your game folder.", &t, ); @@ -615,6 +620,10 @@ impl Launcher { let _ = this.update(cx, |this, cx| { if this.mods.kind != kind { this.mods.kind = kind; + // Horizon's own shader packs are on its registry only. + if kind == PackKind::Shader { + this.mods.source = SourceId::Horizon; + } // Categories and loaders differ by kind. this.mods.browse.filters = Default::default(); this.mods.browse.open = None;