Also use tabs for the game
This commit is contained in:
parent
27fa8be23e
commit
3bb1ceaf49
64
src/main.rs
64
src/main.rs
@ -20,6 +20,7 @@ use data_stream::{
|
|||||||
from_stream, to_stream,
|
from_stream, to_stream,
|
||||||
};
|
};
|
||||||
use header_config::parse_config;
|
use header_config::parse_config;
|
||||||
|
use indexmap::IndexMap;
|
||||||
use maud::html;
|
use maud::html;
|
||||||
use percent_encoding::percent_decode_str;
|
use percent_encoding::percent_decode_str;
|
||||||
use pukram2html::{Settings, convert, convert_extended, convert_subheader};
|
use pukram2html::{Settings, convert, convert_extended, convert_subheader};
|
||||||
@ -652,35 +653,26 @@ fn handle_relative_connection(
|
|||||||
.parent()
|
.parent()
|
||||||
.map(|parent| parent.with_extension("mlc"));
|
.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,
|
|
||||||
relative_path,
|
|
||||||
&mut stream,
|
|
||||||
choice,
|
|
||||||
progress,
|
|
||||||
)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
fail(stream);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let Ok(pk_file) = File::open(file_paths.pk) else {
|
|
||||||
unreachable!();
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Section {
|
struct Section {
|
||||||
title: Box<str>,
|
title: Box<str>,
|
||||||
lines: Vec<String>,
|
lines: Vec<String>,
|
||||||
|
config_map: Option<IndexMap<Box<str>, Box<str>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut sections = Vec::new();
|
let mut sections = Vec::new();
|
||||||
|
|
||||||
|
if config_map.is_some() {
|
||||||
|
sections.push(Section {
|
||||||
|
title: "Game".into(),
|
||||||
|
lines: Vec::new(),
|
||||||
|
config_map,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let Ok(pk_file) = File::open(file_paths.pk) else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
let mut current_section = Section::default();
|
let mut current_section = Section::default();
|
||||||
|
|
||||||
for line in BufReader::new(pk_file).lines() {
|
for line in BufReader::new(pk_file).lines() {
|
||||||
@ -694,6 +686,7 @@ fn handle_relative_connection(
|
|||||||
current_section = Section {
|
current_section = Section {
|
||||||
title: title.into(),
|
title: title.into(),
|
||||||
lines: vec![line],
|
lines: vec![line],
|
||||||
|
config_map: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -703,6 +696,7 @@ fn handle_relative_connection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sections.push(current_section);
|
sections.push(current_section);
|
||||||
|
}
|
||||||
|
|
||||||
let count = sections.len();
|
let count = sections.len();
|
||||||
|
|
||||||
@ -784,9 +778,16 @@ fn handle_relative_connection(
|
|||||||
}
|
}
|
||||||
let _ = write!(stream, "</div>");
|
let _ = write!(stream, "</div>");
|
||||||
|
|
||||||
for (i, Section { lines, .. }) in sections.iter().enumerate() {
|
for (
|
||||||
|
i,
|
||||||
|
Section {
|
||||||
|
lines, config_map, ..
|
||||||
|
},
|
||||||
|
) in sections.into_iter().enumerate()
|
||||||
|
{
|
||||||
let index = i + 1;
|
let index = i + 1;
|
||||||
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
||||||
|
if !lines.is_empty() {
|
||||||
convert_extended(
|
convert_extended(
|
||||||
lines,
|
lines,
|
||||||
&mut stream,
|
&mut stream,
|
||||||
@ -795,11 +796,28 @@ fn handle_relative_connection(
|
|||||||
.with_start_level(start_level)
|
.with_start_level(start_level)
|
||||||
.with_use_textboxes(true),
|
.with_use_textboxes(true),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if let Some(config_map) = config_map {
|
||||||
|
if render_novel(
|
||||||
|
config_map,
|
||||||
|
file_paths.pk,
|
||||||
|
mlc_path.as_deref(),
|
||||||
|
file_paths.mld,
|
||||||
|
relative_path,
|
||||||
|
&mut stream,
|
||||||
|
choice,
|
||||||
|
progress,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
fail(stream);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
let _ = write!(stream, "</div>");
|
let _ = write!(stream, "</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = write!(stream, "</div>");
|
let _ = write!(stream, "</div>");
|
||||||
}
|
|
||||||
|
|
||||||
section(&mut stream);
|
section(&mut stream);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user