Fix critical bug causing a crash only in the .zip releases, where widgetry icons aren't present relative to the data/ directory.

This commit is contained in:
Dustin Carlino 2021-01-30 14:20:28 -08:00
parent 16124f3f3b
commit 8f0c027bb0
4 changed files with 25 additions and 11 deletions

View File

@ -10,9 +10,9 @@ use map_model::{
TurnPriority,
};
use widgetry::{
lctrl, Color, ControlState, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx,
HorizontalAlignment, Key, Line, MultiButton, Outcome, Panel, RewriteColor, State,
StyledButtons, Text, TextExt, VerticalAlignment, Widget,
include_labeled_bytes, lctrl, Color, ControlState, DrawBaselayer, Drawable, EventCtx,
GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, MultiButton, Outcome, Panel, RewriteColor,
State, StyledButtons, Text, TextExt, VerticalAlignment, Widget,
};
use crate::app::{App, ShowEverything, Transition};
@ -628,12 +628,16 @@ fn make_side_panel(
let up_button = ctx
.style()
.btn_solid_light_icon("../widgetry/icons/arrow_up.svg")
.btn_solid_light_icon_bytes(include_labeled_bytes!(
"../../../../widgetry/icons/arrow_up.svg"
))
.disabled(idx == 0);
let down_button = ctx
.style()
.btn_solid_light_icon("../widgetry/icons/arrow_down.svg")
.btn_solid_light_icon_bytes(include_labeled_bytes!(
"../../../../widgetry/icons/arrow_down.svg"
))
.disabled(idx == canonical_signal.stages.len() - 1);
let stage_controls = Widget::row(vec![

View File

@ -190,11 +190,13 @@ pub fn trips(
Widget::nothing()
},
{
let mut icon =
GeomBatch::load_svg(ctx.prerender, "../widgetry/icons/arrow_drop_down.svg")
.autocrop()
.color(RewriteColor::ChangeAll(Color::WHITE))
.scale(1.5);
// TODO Maybe generalize ImageSource::Bytes beyond just buttons
let mut icon = GeomBatch::from_uncached_svg_contents(include_bytes!(
"../../../widgetry/icons/arrow_drop_down.svg"
))
.autocrop()
.color(RewriteColor::ChangeAll(Color::WHITE))
.scale(1.5);
if !open_trips.contains_key(t) {
icon = icon.rotate(Angle::degrees(180.0));

View File

@ -75,7 +75,12 @@ impl Picker {
let instructions_panel = Panel::new(Widget::col(vec![
txt.draw(ctx),
Widget::row(vec![
Widget::draw_svg(ctx, "../widgetry/icons/arrow_keys.svg"),
Widget::draw_batch(
ctx,
GeomBatch::from_uncached_svg_contents(include_bytes!(
"../../widgetry/icons/arrow_keys.svg"
)),
),
Text::from_all(vec![
Line("arrow keys").fg(ctx.style().hotkey_color),
Line(" to move (or "),

View File

@ -41,6 +41,9 @@ pub trait StyledButtons<'a> {
fn btn_solid_light_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.btn_solid_light().image_path(image_path))
}
fn btn_solid_light_icon_bytes(&self, labeled_bytes: (&'a str, &'a [u8])) -> ButtonBuilder<'a> {
icon_button(self.btn_solid_light().image_bytes(labeled_bytes))
}
fn btn_solid_light_icon_text(&self, image_path: &'a str, text: &'a str) -> ButtonBuilder<'a> {
self.btn_solid_light()
.label_text(text)