use mlua::{ObjectLike, Table}; use crate::framexml::{self, Element}; use super::{children_named, color_of, tex_coords_of, Loader}; impl Loader<'_> { /// `` LoadXML extras (RF-28, byte-verified table `0x782ef0`): `minValue`/`maxValue` /// (a reversed pair is swapped — SetMinMaxValues normalizes identically), `defaultValue` → /// SetValue, `orientation`, and the ``/`` children; the element's /// `drawLayer` names the bar texture's layer (widget default ARTWORK). The Slider's parallel /// `` path lives in [`Self::apply_slider`]. pub(super) fn apply_statusbar(&mut self, el: &Element, wrapper: &Table, dbg: &str) { if !el.tag.eq_ignore_ascii_case("StatusBar") { return; } let parse = |attr: &str| el.attr(attr).and_then(|v| v.trim().parse::().ok()); let (min, max) = (parse("minValue"), parse("maxValue")); if min.is_some() || max.is_some() { self.call( wrapper, "SetMinMaxValues", (min.unwrap_or(0.0), max.unwrap_or(0.0)), dbg, ); } if let Some(o) = el.attr("orientation") { self.call(wrapper, "SetOrientation", o.to_string(), dbg); } let layer = el.attr("drawLayer").map(str::to_string); for bar in children_named(el, "BarTexture") { let color = children_named(bar, "Color").next().map(color_of); if let Some(file) = bar.attr("file") { self.call( wrapper, "SetStatusBarTexture", (file.to_string(), layer.clone()), dbg, ); // File + `` DISCARDS the colour, it does not tint — the same // `CSimpleTexture::LoadXML` ordering `regions.rs`'s `` arm cites // (`0x76fe20`: the child loop runs first, then `file=` overwrites the same `+0xcc`). // `` below is this widget's real tint. } else if let Some(c) = color { // No file: a solid-color bar (the SetStatusBarTexture(r,g,b,a) form). self.call( wrapper, "SetStatusBarTexture", (c[0], c[1], c[2], c[3]), dbg, ); } } for bc in children_named(el, "BarColor") { let c = color_of(bc); self.call(wrapper, "SetStatusBarColor", (c[0], c[1], c[2], c[3]), dbg); } if let Some(v) = parse("defaultValue") { self.call(wrapper, "SetValue", v, dbg); } } /// `