Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// What the world leaves undrawn this frame.
|
||||
fn incari_norender_hide(
|
||||
game: &crate::game::Game<'_>,
|
||||
hide: &mut crate::game::native_hooks::NativeNoRender,
|
||||
) {
|
||||
use crate::game::{incari_client as c, incari_norender as m};
|
||||
let _ = game;
|
||||
let Some(h) = c::settings(m::ID, |s| {
|
||||
let (items_hidden, items_still, one_copy) = m::items(s.choice("items"), s.bool("one-copy"));
|
||||
m::Hide {
|
||||
items_hidden,
|
||||
items_still,
|
||||
one_copy,
|
||||
orbs: s.bool("orbs"),
|
||||
falling_blocks: s.bool("falling-blocks"),
|
||||
fireworks: s.bool("fireworks"),
|
||||
growth: s.bool("growth"),
|
||||
breaking: s.bool("breaking"),
|
||||
explosions: s.bool("explosions"),
|
||||
all_particles: s.bool("all-particles"),
|
||||
}
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
hide.items_hidden = h.items_hidden;
|
||||
hide.items_still = h.items_still;
|
||||
hide.one_copy = h.one_copy;
|
||||
hide.orbs = h.orbs;
|
||||
hide.falling_blocks = h.falling_blocks;
|
||||
hide.fireworks = h.fireworks;
|
||||
hide.particles = horizon_client::particles::ParticleHide {
|
||||
all: h.all_particles,
|
||||
growth: h.growth,
|
||||
breaking: h.breaking,
|
||||
explosions: h.explosions,
|
||||
fireworks: h.fireworks,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# Incari's No Render (features/norender) for the Rust build (ADR 0068, 0069). Hooks by name where
|
||||
# Horizon has stamped the hook point (native-hooks.json), by function where it's still pending. Its
|
||||
# settings are the client's (rust/mods/incari), shown in the module menu.
|
||||
[mod]
|
||||
id = "incari_norender"
|
||||
version = "0.1.0"
|
||||
priority = 100
|
||||
|
||||
[[module]]
|
||||
id = "runtime"
|
||||
file = "crates/horizon-client/src/game.rs"
|
||||
name = "incari_norender"
|
||||
source = "runtime.rs"
|
||||
|
||||
[[injection]]
|
||||
id = "hide"
|
||||
# Horizon's no_render hook point is still a pending fragment
|
||||
# (tools/native-hook-fragments/incari_no_render.json), so this targets its function. Make it
|
||||
# `hook = "no_render"` and `hook_version = 1` once Horizon stamps it.
|
||||
target = "horizon_client::game::native_hooks::Game<'_>::native_no_render"
|
||||
kind = "HEAD"
|
||||
helper = "hide.rs"
|
||||
bindings = [
|
||||
{ name = "game", ty = "&crate::game::Game<'_>", value = "self" },
|
||||
{ name = "hide", ty = "&mut crate::game::native_hooks::NativeNoRender", value = "&mut *hide" },
|
||||
]
|
||||
@@ -0,0 +1,47 @@
|
||||
// Incari's No Render for the Rust build (ADR 0068, 0069), as features/norender does it: items on
|
||||
// the ground hidden or lying still, a stack as one item, and XP orbs, falling blocks, fireworks and
|
||||
// the particles you pick hidden, on this client only. Horizon asks once a frame
|
||||
// (`native_no_render`); hidden particles are never made. Its settings are the module's in
|
||||
// `incari_core::modules`. No game types: rust/lib.rs tests it.
|
||||
|
||||
/// The module's id, as the Java client's profiles name it.
|
||||
pub const ID: &str = "norender";
|
||||
|
||||
/// What the settings hide, flat, as Horizon's `NativeNoRender` takes it.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Hide {
|
||||
pub items_hidden: bool,
|
||||
pub items_still: bool,
|
||||
pub one_copy: bool,
|
||||
pub orbs: bool,
|
||||
pub falling_blocks: bool,
|
||||
pub fireworks: bool,
|
||||
pub growth: bool,
|
||||
pub breaking: bool,
|
||||
pub explosions: bool,
|
||||
pub all_particles: bool,
|
||||
}
|
||||
|
||||
/// The "items" choice ("shown", "still", "hidden") and the "one-copy" setting as Horizon takes
|
||||
/// them: (hidden, still, one copy). One copy means nothing while the items are hidden.
|
||||
pub fn items(choice: &str, one_copy: bool) -> (bool, bool, bool) {
|
||||
let hidden = choice == "hidden";
|
||||
(hidden, choice == "still", one_copy && !hidden)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn items_follow_the_choice() {
|
||||
assert_eq!(items("hidden", true), (true, false, false));
|
||||
assert_eq!(items("still", true), (false, true, true));
|
||||
assert_eq!(items("shown", false), (false, false, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_choice_draws_items_as_the_game_does() {
|
||||
assert_eq!(items("", false), (false, false, false));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user