vn-settings 0.7.0

Various settings intended to simulate visual novels
Documentation

Visual Novel settings

Crates.io

A cross-platform configuration system for visual novels, featuring cascading overrides and real-time state management.

Overrides

This library provides various settings to simulate visual novels in Rust applications. It includes settings for colors, timing, images, objects, layout, and names.

Each parameter can have a default value and you can add temporary overrides to these values, which will only be active during a single continuous dialog.

Most parameters can also have a character specific values, which are only set when a character speaks. These character specific parameters can also have temporary overrides.

The priorities of the values is like this:

  1. Scene value (scene)
  2. Character specific scene value (characters_scene)
  3. Aspect value (aspect)
  4. Character specific aspect value (characters_aspect)
  5. Character specific default value (characters_default)
  6. Default value (default)

Aspects are story-driven overrides (e.g. a "Mood" aspect with values like "Happy" or "Sad") that globally affect visual settings based on the current state of the story.

This should make managing state for visual novels easy.

Features

🎨 Cascading Settings

Address any setting by its configuration key, globally or per character:

let mut settings = PlayerSettings::common();
let mut context = SettingsContext::new();

settings.apply_setting(&mut context, "Timing:letter", "0.05");
settings.apply_setting(&mut context, "Character:Alice:Timing:letter", "0.02");

assert_eq!(settings.timing.letter.get("Alice"), 0.02);
assert_eq!(settings.timing.letter.get("Bob"), 0.05);

🔄 State Management

Apply scene-level changes while a dialog runs, then drop them again:

let setter = Parameter::create_setter("Color:background", "blue", &mut context)
    .expect("background is a valid parameter");
settings.change(&setter.change());

settings.reset();

Unparsable values are reported and skipped rather than panicking, so a malformed configuration degrades instead of taking the application down.

🛠️ Editor Support

Parameter::names() lists every statically known key for completion, and two read-only checks answer different questions about a key while the user types:

assert!(Parameter::lookup("Timing:letter", &context).is_some());
assert!(Parameter::lookup("Image:Nobody:base", &context).is_none());

assert!(Parameter::accepts("Image:Nobody:base"));
assert!(!Parameter::accepts("Image:Nobody"));

lookup asks whether a key resolves against a loaded configuration, accepts only whether it is well-formed — useful for a document with no configuration beside it, where every object name is undeclared but the document is correct.

Parameter::create keeps declaring unknown object, anchor and custom parameter names, which is what loading a configuration needs.

Core Types

Type Description
PlayerSettings Root container for all configuration
Override<T> 6-level hierarchical value management
Parameter Addressable setting path
Setter Setting path paired with a value
Change Mutation operation for scene-level overrides

Documentation

API Reference

Developed with ❤️ for visual novel creators