Use vn-settings and don't display empty boxes
This commit is contained in:
@@ -1,40 +1,19 @@
|
||||
use std::path::Path;
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use dialogi::{DialogChange, DialogParameter, DialogSequence};
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
use dialogi::DialogSequence;
|
||||
use vn_settings::{Change, Parameter, SettingsContext};
|
||||
|
||||
pub fn parse_map(
|
||||
story_path: &Path,
|
||||
) -> Result<Vec<DialogSequence<EmptyDialogChange, EmptyDialogParameter>>, dialogi::ParsingError> {
|
||||
DialogSequence::map_from_path(story_path, &mut EmptyDialogContext)
|
||||
) -> Result<Vec<DialogSequence<Change, Parameter>>, dialogi::ParsingError> {
|
||||
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 {
|
||||
let mut block_content = Vec::new();
|
||||
|
||||
convert_subheader(
|
||||
block.lines.iter().map(|l| l.text.as_ref()),
|
||||
&mut block_content,
|
||||
start_level,
|
||||
);
|
||||
let section_html = if block.lines.is_empty() {
|
||||
html! {}
|
||||
} else {
|
||||
convert_subheader(
|
||||
block.lines.iter().map(|l| l.text.as_ref()),
|
||||
&mut block_content,
|
||||
start_level,
|
||||
);
|
||||
|
||||
let section_html = html! {
|
||||
fieldset class="visual-novel-box" {
|
||||
@if !block.name.is_empty() {
|
||||
legend class="character-name" { (block.name) }
|
||||
}
|
||||
div class="dialog-content" {
|
||||
@if let Ok(content) = String::from_utf8(block_content) {
|
||||
(maud::PreEscaped(content))
|
||||
html! {
|
||||
fieldset class="visual-novel-box" {
|
||||
@if !block.name.is_empty() {
|
||||
legend class="character-name" { (block.name) }
|
||||
}
|
||||
div class="dialog-content" {
|
||||
@if let Ok(content) = String::from_utf8(block_content) {
|
||||
(maud::PreEscaped(content))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user