Use vn-settings and don't display empty boxes
This commit is contained in:
parent
17945f9a1c
commit
d35517043d
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -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",
|
||||||
|
]
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/main.rs
30
src/main.rs
@ -588,20 +588,24 @@ 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();
|
||||||
|
|
||||||
convert_subheader(
|
let section_html = if block.lines.is_empty() {
|
||||||
block.lines.iter().map(|l| l.text.as_ref()),
|
html! {}
|
||||||
&mut block_content,
|
} else {
|
||||||
start_level,
|
convert_subheader(
|
||||||
);
|
block.lines.iter().map(|l| l.text.as_ref()),
|
||||||
|
&mut block_content,
|
||||||
|
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) }
|
||||||
}
|
}
|
||||||
div class="dialog-content" {
|
div class="dialog-content" {
|
||||||
@if let Ok(content) = String::from_utf8(block_content) {
|
@if let Ok(content) = String::from_utf8(block_content) {
|
||||||
(maud::PreEscaped(content))
|
(maud::PreEscaped(content))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user