Skip to main content

Crate supreme_hook_config

Crate supreme_hook_config 

Source
Expand description

Shared data contract for the file-hooking modding system.

This crate has no Windows-specific dependencies: it is compiled into both the launcher (which writes a HookConfig out to disk) and the supreme_hook_proxy DLL (which reads it back and applies it). Keeping it platform-neutral means the redirection/patch logic can be unit tested on any host, even though the DLL that consumes it only runs on Windows.

Module layout:

  • [error], the shared HookConfigError type.
  • mods_state, plain load/save I/O for the mods directory’s single state file (mods.json), and the MOD_FILE_NAME constant for each mod’s own mod.json.
  • mod_config, ModConfig, one mod’s authored mod.json.
  • ui, the optional ui section of a mod.json (ModUi): launcher buttons/popups rendered generically by the Mods page.
  • hook_config, HookConfig, the merged/resolved shape the proxy DLL consumes, and how a mods directory becomes one.
  • dir_listing, patch, resolver, script_engine, see their own module docs.

Re-exports§

pub use dir_listing::EntryOffsets;
pub use dir_listing::FilterResult;
pub use dir_listing::filter_redirected_entries;
pub use dir_listing::wildcard_match;
pub use dir_listing::write_directory_entry;
pub use hook_config::HookConfig;
pub use hook_config::RedirectionMode;
pub use hook_config::RedirectionRule;
pub use hook_config::ResolvedAction;
pub use hook_config::RuleTarget;
pub use mod_config::ModConfig;
pub use mod_config::ModParameter;
pub use mod_config::ParameterKind;
pub use mods_state::DEFAULT_MODS_DIR_NAME;
pub use mods_state::MOD_FILE_NAME;
pub use mods_state::MODS_STATE_FILE_NAME;
pub use mods_state::ModConfigurations;
pub use mods_state::ModsPreset;
pub use mods_state::ModsState;
pub use mods_state::load_mods_state;
pub use mods_state::save_mods_state;
pub use patch::BytesReplacement;
pub use patch::MemoryPatch;
pub use patch::ScriptSource;
pub use patch::StringReplacement;
pub use resolver::HookResolver;
pub use resolver::ManagedFileSpec;
pub use resolver::compute_target_path;
pub use resolver::is_write_operation;
pub use resolver::managed_file_specs;
pub use resolver::seed_target_file;
pub use ui::ModUi;
pub use ui::UiButton;
pub use ui::UiField;
pub use ui::UiFieldKind;
pub use ui::UiPopup;
pub use ui::UiPopupKind;
pub use validation::PLAYER_NAME_TAG;
pub use validation::ROOM_NAME_TAG;
pub use validation::is_known_tag;
pub use validation::validate_value;

Modules§

dir_listing
Pure logic supporting hooks::query_dir’s directory-listing hook: buffer rewriting, plus the glob-style filename matching used to decide which mod-provided files belong in a given listing.
hook_config
The merged, resolved redirection config the proxy DLL actually consumes: HookConfig (a flat list of RedirectionRules) and ResolvedAction, the outcome of resolving one requested path against it. Distinct from crate::mod_config::ModConfig, which is the per-mod authored (possibly conditional/templated) shape, see ModConfig::resolved_rules for how one becomes the other.
mod_config
The per-mod authored shape: ModConfig (one mod’s mod.json, metadata, conditional/templated rules, and the parameters it exposes), plus the ${param_id} substitution/gating logic that turns it into the plain crate::hook_config::RedirectionRules crate::hook_config::HookConfig::load_from_mods_dir merges across mods.
mods_state
On-disk I/O for the mods directory’s single state file: ModsState (persisted as mods.json), which replaces the older enabled_mods.json + mod_configuration.json pair. Consolidating them fixes a specific bug in that older layout: with two files, a mod’s display position was reconstructed at load time from which bucket it happened to be in (enabled vs. not), so toggling a mod would visibly reshuffle the whole list.
patch
resolver
Disk-aware resolution: given a loaded HookConfig plus a game directory and a scratch/temp directory, decide what should happen to a given rel_key for reads, writes, and deletes, including staging patched replacement files and seeding write targets.
script_engine
Encapsulates all Rhai usage for the modding system.
ui
The optional ui section of a mod’s mod.json, the launcher-UI schema the Mods page renders generically: buttons shown for the mod, and the popups those buttons open. See crate::mod_config::ModConfig::ui, which holds this as an Option, a mod without a ui section (e.g. the existing practice-as-race mod) stays fully valid and simply gets no buttons.
validation
Shared field-validation tags for mod-authored inputs.

Enums§

HookConfigError