Added mlc support
This commit is contained in:
parent
5378ee9837
commit
bf92f9277d
@ -607,11 +607,15 @@ fn handle_relative_connection(
|
||||
.parent()
|
||||
.map(|parent| parse_config(&parent.with_extension("vng")).ok())
|
||||
.unwrap_or_default();
|
||||
let mlc_path: Option<PathBuf> = check_path
|
||||
.parent()
|
||||
.map(|parent| parent.with_extension("mlc"));
|
||||
|
||||
if let Some(config_map) = config_map {
|
||||
if render_novel(
|
||||
config_map,
|
||||
file_paths.pk,
|
||||
mlc_path.as_deref(),
|
||||
file_paths.mld,
|
||||
&mut stream,
|
||||
choice,
|
||||
|
||||
42
src/vn.rs
42
src/vn.rs
@ -1,11 +1,17 @@
|
||||
use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::File,
|
||||
io::{BufReader, prelude::*},
|
||||
net::TcpStream,
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use dialogi::{DialogBlock, DialogSequence, ParsingError};
|
||||
use event_simulation::Simulation;
|
||||
use indexmap::IndexMap;
|
||||
use maud::{Markup, html};
|
||||
use multilinear::{BorrowedMultilinearSimulation, Event};
|
||||
use multilinear_parser::{NamedMultilinearInfo, parse_multilinear};
|
||||
use multilinear_parser::{MultilinearParser, NamedMultilinearInfo};
|
||||
use pukram2html::convert;
|
||||
use vn_settings::{Change, Parameter, PlayerSettings, SettingsContext, extract_layers};
|
||||
|
||||
@ -439,13 +445,39 @@ fn apply_block_changes(
|
||||
}
|
||||
}
|
||||
|
||||
fn load_multilinear(mld_path: &Path) -> Option<NamedMultilinearInfo> {
|
||||
parse_multilinear(File::open(mld_path).ok()?).ok()
|
||||
fn load_multilinear(mlc_path: Option<&Path>, mld_path: &Path) -> Option<NamedMultilinearInfo> {
|
||||
let mut parser = MultilinearParser::default();
|
||||
if let Some(mlc_path) = mlc_path {
|
||||
if let Ok(file) = File::open(mlc_path) {
|
||||
for line in BufReader::new(file).lines() {
|
||||
let Ok(line) = line else {
|
||||
break;
|
||||
};
|
||||
|
||||
if let Some((channel, default_value)) = line.split_once(':') {
|
||||
let _ = parser.add_new_channel(channel, default_value);
|
||||
continue;
|
||||
}
|
||||
|
||||
let line = line.trim();
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parser.parse(File::open(mld_path).ok()?, &[]).ok()?;
|
||||
|
||||
Some(parser.into_info())
|
||||
}
|
||||
|
||||
pub fn render_novel(
|
||||
mut config_map: IndexMap<Box<str>, Box<str>>,
|
||||
pk_path: &Path,
|
||||
mlc_path: Option<&Path>,
|
||||
mld_path: &Path,
|
||||
stream: &mut TcpStream,
|
||||
mut choice: usize,
|
||||
@ -461,7 +493,7 @@ pub fn render_novel(
|
||||
let mut sections = Vec::new();
|
||||
process_dialog(&dialogs[choice], &mut player_settings, &mut sections);
|
||||
|
||||
if let Some(named_multilinear_info) = load_multilinear(mld_path) {
|
||||
if let Some(named_multilinear_info) = load_multilinear(mlc_path, mld_path) {
|
||||
let multilinear_info = &named_multilinear_info.info;
|
||||
let count = named_multilinear_info.channels.into_iter().count();
|
||||
let mut data = vec![0; count];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user