Use vn-settings and don't display empty boxes

This commit is contained in:
p11 2025-04-09 22:01:58 +02:00
parent 17945f9a1c
commit d35517043d
4 changed files with 52 additions and 48 deletions

20
Cargo.lock generated
View File

@ -149,6 +149,7 @@ dependencies = [
"percent-encoding", "percent-encoding",
"pukram2html", "pukram2html",
"rayon", "rayon",
"vn-settings",
] ]
[[package]] [[package]]
@ -189,6 +190,15 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "simple-color"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0869e0c3d2f70dff69e4797b5af38d18bbf74374b0253843d79b31d63334f33"
dependencies = [
"thiserror",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.96" version = "2.0.96"
@ -231,3 +241,13 @@ name = "version_check"
version = "0.9.5" version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "vn-settings"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f799fd65b2bf363a1c70c8dce20b9ea2e2e594173dd9bcd5475dd257b0e0b44a"
dependencies = [
"dialogi",
"simple-color",
]

View File

@ -10,3 +10,4 @@ pukram2html = "0.3.0"
data-stream = "0.3.0" data-stream = "0.3.0"
rayon = "1.10.0" rayon = "1.10.0"
dialogi = "0.3.1" dialogi = "0.3.1"
vn-settings = "0.1.0"

View File

@ -1,40 +1,19 @@
use std::path::Path; use std::{collections::HashMap, path::Path};
use dialogi::{DialogChange, DialogParameter, DialogSequence}; use dialogi::DialogSequence;
use vn_settings::{Change, Parameter, SettingsContext};
pub struct EmptyDialogContext;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct EmptyDialogParameter;
impl DialogParameter for EmptyDialogParameter {
type Context = EmptyDialogContext;
fn create(_: &str, _: &mut Self::Context) -> Option<Self> {
None
}
}
pub struct EmptyDialogChange;
impl DialogChange for EmptyDialogChange {
type Parameter = EmptyDialogParameter;
fn default_change(_: Self::Parameter) -> Self {
Self
}
fn value_change(
_: Self::Parameter,
_: &str,
_: &mut <<Self as DialogChange>::Parameter as DialogParameter>::Context,
) -> Self {
Self
}
}
pub fn parse_map( pub fn parse_map(
story_path: &Path, story_path: &Path,
) -> Result<Vec<DialogSequence<EmptyDialogChange, EmptyDialogParameter>>, dialogi::ParsingError> { ) -> Result<Vec<DialogSequence<Change, Parameter>>, dialogi::ParsingError> {
DialogSequence::map_from_path(story_path, &mut EmptyDialogContext) let mut layers = HashMap::new();
layers.insert("Background".into(), 0);
layers.insert("Character".into(), 1);
let mut settings_context = SettingsContext {
object_cache: HashMap::new(),
layers,
};
DialogSequence::map_from_path(story_path, &mut settings_context)
} }

View File

@ -588,13 +588,16 @@ fn handle_relative_connection(
for block in &dialog_sequence.blocks { for block in &dialog_sequence.blocks {
let mut block_content = Vec::new(); let mut block_content = Vec::new();
let section_html = if block.lines.is_empty() {
html! {}
} else {
convert_subheader( convert_subheader(
block.lines.iter().map(|l| l.text.as_ref()), block.lines.iter().map(|l| l.text.as_ref()),
&mut block_content, &mut block_content,
start_level, start_level,
); );
let section_html = html! { html! {
fieldset class="visual-novel-box" { fieldset class="visual-novel-box" {
@if !block.name.is_empty() { @if !block.name.is_empty() {
legend class="character-name" { (block.name) } legend class="character-name" { (block.name) }
@ -605,6 +608,7 @@ fn handle_relative_connection(
} }
} }
} }
}
}; };
sections.push(section_html); sections.push(section_html);