Changed how game does tabs
This commit is contained in:
parent
84f57449f8
commit
3e6ba8ac02
83
src/main.rs
83
src/main.rs
@ -644,6 +644,21 @@ fn handle_relative_connection(
|
||||
let _ = writeln!(stream, "<h1>{title}</h1>");
|
||||
}
|
||||
|
||||
enum SectionInfo {
|
||||
Game(IndexMap<Box<str>, Box<str>>),
|
||||
Description,
|
||||
Comment(Vec<Comment>),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Section {
|
||||
title: Box<str>,
|
||||
lines: Vec<String>,
|
||||
info: Option<SectionInfo>,
|
||||
}
|
||||
|
||||
let mut sections = Vec::new();
|
||||
|
||||
let check_path: &Path = relative_path.as_ref();
|
||||
let config_map = check_path
|
||||
.parent()
|
||||
@ -653,27 +668,11 @@ fn handle_relative_connection(
|
||||
.parent()
|
||||
.map(|parent| parent.with_extension("mlc"));
|
||||
|
||||
enum SectionInfo {
|
||||
Description,
|
||||
Comment(Vec<Comment>),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Section {
|
||||
title: Box<str>,
|
||||
lines: Vec<String>,
|
||||
config_map: Option<IndexMap<Box<str>, Box<str>>>,
|
||||
info: Option<SectionInfo>,
|
||||
}
|
||||
|
||||
let mut sections = Vec::new();
|
||||
|
||||
if config_map.is_some() {
|
||||
if let Some(config_map) = config_map {
|
||||
sections.push(Section {
|
||||
title: "Game".into(),
|
||||
lines: Vec::new(),
|
||||
config_map,
|
||||
info: None,
|
||||
info: Some(SectionInfo::Game(config_map)),
|
||||
});
|
||||
} else {
|
||||
let Ok(pk_file) = File::open(file_paths.pk) else {
|
||||
@ -693,7 +692,6 @@ fn handle_relative_connection(
|
||||
current_section = Section {
|
||||
title: title.into(),
|
||||
lines: vec![line],
|
||||
config_map: None,
|
||||
info: None,
|
||||
};
|
||||
|
||||
@ -710,7 +708,6 @@ fn handle_relative_connection(
|
||||
sections.push(Section {
|
||||
title: "Description".into(),
|
||||
lines: Vec::new(),
|
||||
config_map: None,
|
||||
info: Some(SectionInfo::Description),
|
||||
});
|
||||
}
|
||||
@ -718,7 +715,6 @@ fn handle_relative_connection(
|
||||
sections.push(Section {
|
||||
title: "Comments".into(),
|
||||
lines: Vec::new(),
|
||||
config_map: None,
|
||||
info: Some(SectionInfo::Comment(comments)),
|
||||
});
|
||||
|
||||
@ -802,16 +798,7 @@ fn handle_relative_connection(
|
||||
}
|
||||
let _ = write!(stream, "</div>");
|
||||
|
||||
for (
|
||||
i,
|
||||
Section {
|
||||
lines,
|
||||
config_map,
|
||||
info,
|
||||
..
|
||||
},
|
||||
) in sections.into_iter().enumerate()
|
||||
{
|
||||
for (i, Section { lines, info, .. }) in sections.into_iter().enumerate() {
|
||||
let index = i + 1;
|
||||
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
||||
if !lines.is_empty() {
|
||||
@ -824,25 +811,25 @@ fn handle_relative_connection(
|
||||
.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;
|
||||
}
|
||||
}
|
||||
if let Some(info) = info {
|
||||
match info {
|
||||
SectionInfo::Game(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;
|
||||
}
|
||||
}
|
||||
SectionInfo::Description => {
|
||||
let Ok(pki_file) = File::open(file_paths.pki.unwrap()) else {
|
||||
unreachable!();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user