Bundle some of the widgetry SVG assets in directly, so other users don't need to copy part of the data/ directory. [rebuild] [release]

This commit is contained in:
Dustin Carlino 2020-12-26 21:31:51 -08:00
parent f8ac0fc96b
commit fdfa2dbe8c
3 changed files with 54 additions and 30 deletions

View File

@ -140,7 +140,10 @@ impl<'a> EventCtx<'a> {
Widget::custom_col(vec![
Widget::draw_batch(
self,
GeomBatch::load_svg(self, "system/assets/map/dont_walk.svg").scale(5.0),
GeomBatch::from_svg_contents(
include_bytes!("../../data/system/assets/map/dont_walk.svg").to_vec(),
)
.scale(5.0),
)
.container()
.bg(Color::BLACK)

View File

@ -201,11 +201,12 @@ impl Btn {
let icon_container = Polygon::rectangle(20.0, 30.0);
icon_batch.push(Color::INVISIBLE, icon_container);
let path = "system/assets/widgetry/arrow_drop_down.svg";
let icon = GeomBatch::load_svg(ctx, &path)
.color(RewriteColor::ChangeAll(ctx.style().outline_color))
.autocrop()
.centered_on(icon_batch.get_bounds().center());
let icon = GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/arrow_drop_down.svg").to_vec(),
)
.color(RewriteColor::ChangeAll(ctx.style().outline_color))
.autocrop()
.centered_on(icon_batch.get_bounds().center());
icon_batch.append(icon);

View File

@ -35,16 +35,20 @@ impl Checkbox {
) -> Widget {
let label = label.into();
let (off, hitbox) = Widget::row(vec![
GeomBatch::load_svg(ctx, "system/assets/widgetry/toggle_off.svg")
.batch()
.centered_vert(),
GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/toggle_off.svg").to_vec(),
)
.batch()
.centered_vert(),
label.clone().batch_text(ctx),
])
.to_geom(ctx, None);
let (on, _) = Widget::row(vec![
GeomBatch::load_svg(ctx, "system/assets/widgetry/toggle_on.svg")
.batch()
.centered_vert(),
GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/toggle_on.svg").to_vec(),
)
.batch()
.centered_vert(),
label.clone().batch_text(ctx),
])
.to_geom(ctx, None);
@ -118,18 +122,22 @@ impl Checkbox {
pub fn colored(ctx: &EventCtx, label: &str, color: Color, enabled: bool) -> Widget {
let (off, hitbox) = Widget::row(vec![
GeomBatch::load_svg(ctx, "system/assets/widgetry/checkbox.svg")
.color(RewriteColor::ChangeAll(color.alpha(0.3)))
.batch()
.centered_vert(),
GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/checkbox.svg").to_vec(),
)
.color(RewriteColor::ChangeAll(color.alpha(0.3)))
.batch()
.centered_vert(),
label.batch_text(ctx),
])
.to_geom(ctx, None);
let (on, _) = Widget::row(vec![
GeomBatch::load_svg(ctx, "system/assets/widgetry/checkbox.svg")
.color(RewriteColor::Change(Color::BLACK, color))
.batch()
.centered_vert(),
GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/checkbox.svg").to_vec(),
)
.color(RewriteColor::Change(Color::BLACK, color))
.batch()
.centered_vert(),
label.batch_text(ctx),
])
.to_geom(ctx, None);
@ -172,20 +180,32 @@ impl Checkbox {
let left_label = left_label.into();
let right_label = right_label.into();
let hotkey = hotkey.into();
let right = GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/toggle_right.svg").to_vec(),
);
let left = GeomBatch::from_svg_contents(
include_bytes!("../../../data/system/assets/widgetry/toggle_left.svg").to_vec(),
);
let hitbox = right.get_bounds().get_rectangle();
Widget::row(vec![
left_label.clone().draw_text(ctx),
Checkbox::new(
enabled,
Btn::svg_def("system/assets/widgetry/toggle_right.svg").build(
ctx,
left_label,
hotkey.clone(),
),
Btn::svg_def("system/assets/widgetry/toggle_left.svg").build(
ctx,
right_label.clone(),
hotkey,
),
Btn::custom(
right.clone(),
right.color(RewriteColor::ChangeAll(ctx.style().hovering_color)),
hitbox.clone(),
None,
)
.build(ctx, left_label, hotkey.clone()),
Btn::custom(
left.clone(),
left.color(RewriteColor::ChangeAll(ctx.style().hovering_color)),
hitbox,
None,
)
.build(ctx, right_label.clone(), hotkey),
)
.named(label),
right_label.draw_text(ctx),