Use specified colors for textboxes
This commit is contained in:
parent
447df9d9ea
commit
40b88cefff
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -260,6 +260,7 @@ dependencies = [
|
||||
"multilinear-parser",
|
||||
"percent-encoding",
|
||||
"pukram2html",
|
||||
"simple-color",
|
||||
"threadpool",
|
||||
"vn-settings",
|
||||
]
|
||||
|
||||
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
simple-color = "0.2.3"
|
||||
percent-encoding = "2.3"
|
||||
maud = "0.27.0"
|
||||
pukram2html = "0.3.0"
|
||||
|
||||
38
src/vn.rs
38
src/vn.rs
@ -13,6 +13,7 @@ use maud::{Markup, html};
|
||||
use multilinear::{BorrowedMultilinearSimulation, Event};
|
||||
use multilinear_parser::{MultilinearParser, NamedMultilinearInfo};
|
||||
use pukram2html::convert;
|
||||
use simple_color::Color;
|
||||
use vn_settings::{Change, Parameter, PlayerSettings, SettingsContext, extract_layers};
|
||||
|
||||
use crate::dialog::parse_map;
|
||||
@ -72,18 +73,47 @@ fn render_choice(block: &DialogBlock<Parameter>, index: usize, progress: &str) -
|
||||
}
|
||||
}
|
||||
|
||||
fn render_dialog_block(block: &DialogBlock<Parameter>) -> Markup {
|
||||
fn rgba_string(color: Color) -> String {
|
||||
format!(
|
||||
"rgba({}, {}, {}, {})",
|
||||
color.r,
|
||||
color.g,
|
||||
color.b,
|
||||
color.a as f32 / 255.0
|
||||
)
|
||||
}
|
||||
|
||||
fn render_dialog_block(settings: &PlayerSettings, block: &DialogBlock<Parameter>) -> Markup {
|
||||
if block.lines.is_empty() {
|
||||
return html! {};
|
||||
}
|
||||
|
||||
let text_fill_color = rgba_string(settings.colors.dialog_box.text_fill.get(&block.name));
|
||||
let text_line_color = rgba_string(settings.colors.dialog_box.text_line.get(&block.name));
|
||||
let name_fill_color = rgba_string(settings.colors.dialog_box.name_fill.get(&block.name));
|
||||
let name_line_color = rgba_string(settings.colors.dialog_box.name_line.get(&block.name));
|
||||
|
||||
let mut content = Vec::new();
|
||||
convert(block.lines.iter().map(|l| l.text.as_ref()), &mut content);
|
||||
|
||||
html! {
|
||||
fieldset .visual-novel-box onclick="playCurrentAudio()" {
|
||||
fieldset .visual-novel-box onclick="playCurrentAudio()"
|
||||
style=(format!(
|
||||
"background: {}; border-color: {}; color: {};",
|
||||
text_fill_color,
|
||||
text_line_color,
|
||||
text_line_color,
|
||||
)) {
|
||||
@if !block.name.is_empty() {
|
||||
legend .character-name { (block.name) }
|
||||
legend .character-name
|
||||
style=(format!(
|
||||
"background: {}; border-color: {}; color: {};",
|
||||
name_fill_color,
|
||||
name_line_color,
|
||||
name_line_color,
|
||||
)) {
|
||||
(block.name)
|
||||
}
|
||||
}
|
||||
div .dialog-content {
|
||||
@match String::from_utf8(content) {
|
||||
@ -449,7 +479,7 @@ fn process_dialog(
|
||||
|
||||
sections.push(html! {
|
||||
(render_scene(player_settings, &block.name))
|
||||
(render_dialog_block(block))
|
||||
(render_dialog_block(player_settings, block))
|
||||
audio {
|
||||
source src=(format!("/{base_path}.{}.mp3", start_index + i)) type="audio/mpeg";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user