Added proper simulation
This commit is contained in:
parent
04d6a09b57
commit
19e1683786
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -245,9 +245,11 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"data-stream",
|
"data-stream",
|
||||||
"dialogi",
|
"dialogi",
|
||||||
|
"event-simulation",
|
||||||
"header-config",
|
"header-config",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"maud",
|
"maud",
|
||||||
|
"multilinear",
|
||||||
"multilinear-parser",
|
"multilinear-parser",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pukram2html",
|
"pukram2html",
|
||||||
|
|||||||
@ -13,4 +13,6 @@ vn-settings = "0.1.1"
|
|||||||
threadpool = "1.8.1"
|
threadpool = "1.8.1"
|
||||||
header-config = "0.1.5"
|
header-config = "0.1.5"
|
||||||
indexmap = "2.9.0"
|
indexmap = "2.9.0"
|
||||||
|
multilinear = "0.3.1"
|
||||||
multilinear-parser = "0.3.3"
|
multilinear-parser = "0.3.3"
|
||||||
|
event-simulation = "0.1.2"
|
||||||
|
|||||||
50
src/vn.rs
50
src/vn.rs
@ -1,8 +1,10 @@
|
|||||||
use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path};
|
use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path};
|
||||||
|
|
||||||
use dialogi::DialogBlock;
|
use dialogi::DialogBlock;
|
||||||
|
use event_simulation::Simulation;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use maud::{Markup, html};
|
use maud::{Markup, html};
|
||||||
|
use multilinear::{BorrowedMultilinearSimulation, Event};
|
||||||
use multilinear_parser::{NamedMultilinearInfo, parse_multilinear};
|
use multilinear_parser::{NamedMultilinearInfo, parse_multilinear};
|
||||||
use pukram2html::convert_subheader;
|
use pukram2html::convert_subheader;
|
||||||
use vn_settings::{Change, Parameter, PlayerSettings, SettingsContext, extract_layers};
|
use vn_settings::{Change, Parameter, PlayerSettings, SettingsContext, extract_layers};
|
||||||
@ -348,17 +350,47 @@ pub fn render_novel(
|
|||||||
let dialogs = parse_map(pk_path, &mut settings_context)?;
|
let dialogs = parse_map(pk_path, &mut settings_context)?;
|
||||||
let mut sections = process_dialog(&dialogs[choice], &mut player_settings, start_level);
|
let mut sections = process_dialog(&dialogs[choice], &mut player_settings, start_level);
|
||||||
|
|
||||||
if let Some(_named_multilinear_info) = load_multilinear(mld_path) {
|
if let Some(named_multilinear_info) = load_multilinear(mld_path) {
|
||||||
let choices_html = html! {
|
let multilinear_info = &named_multilinear_info.info;
|
||||||
div .choices-section {
|
let count = named_multilinear_info.channels.into_iter().count();
|
||||||
@for (i, dialog_sequence) in dialogs.iter().enumerate() {
|
let mut data = vec![0; count];
|
||||||
@if let Some(block) = dialog_sequence.blocks.first() {
|
for (i, num) in progress.split('+').enumerate() {
|
||||||
(render_choice(block, i, progress))
|
if i == count {
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
if let Ok(num) = num.parse() {
|
||||||
|
data[i] = num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut simulation =
|
||||||
|
BorrowedMultilinearSimulation::from_data(multilinear_info, data).unwrap();
|
||||||
|
simulation.try_call(Event(choice));
|
||||||
|
let progress: String = simulation
|
||||||
|
.data()
|
||||||
|
.iter()
|
||||||
|
.map(|i| format!("{i}"))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(" ");
|
||||||
|
|
||||||
|
let mut choices = Vec::new();
|
||||||
|
for (i, dialog_sequence) in dialogs.iter().enumerate() {
|
||||||
|
if let Some(block) = dialog_sequence.blocks.first() {
|
||||||
|
if simulation.callable(Event(i)) {
|
||||||
|
choices.push(render_choice(block, i, &progress))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
sections.push(choices_html);
|
|
||||||
|
if !choices.is_empty() {
|
||||||
|
let choices_html = html! {
|
||||||
|
div .choices-section {
|
||||||
|
@for choice in choices {
|
||||||
|
(choice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sections.push(choices_html);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let html = generate_html(sections);
|
let html = generate_html(sections);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user