add dashboard icon for leaky suit

This commit is contained in:
yuni 2024-05-08 05:17:47 +02:00
parent 0ba64421d7
commit 626c685003
3 changed files with 177 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -83,8 +83,6 @@ impl Plugin for HudPlugin {
#[derive(Component)] struct Reticule; #[derive(Component)] struct Reticule;
#[derive(Component)] struct Speedometer; #[derive(Component)] struct Speedometer;
#[derive(Component)] struct Speedometer2; #[derive(Component)] struct Speedometer2;
#[derive(Component)] struct Dashboard;
#[derive(Component)] struct DashboardFlashlight;
#[derive(Component)] struct GaugeLength(f32); #[derive(Component)] struct GaugeLength(f32);
#[derive(Component)] pub struct ToggleableHudElement; #[derive(Component)] pub struct ToggleableHudElement;
#[derive(Component)] pub struct ToggleableHudMapElement; #[derive(Component)] pub struct ToggleableHudMapElement;
@ -92,6 +90,12 @@ impl Plugin for HudPlugin {
#[derive(Component)] pub struct IsTargeted; #[derive(Component)] pub struct IsTargeted;
#[derive(Component)] pub struct PointOfInterestMarker(pub Entity); #[derive(Component)] pub struct PointOfInterestMarker(pub Entity);
#[derive(Component, Debug, Copy, Clone)]
enum Dashboard {
Leak,
Flashlight,
}
#[derive(Component, Debug, Copy, Clone)] #[derive(Component, Debug, Copy, Clone)]
enum Gauge { enum Gauge {
Health, Health,
@ -362,7 +366,6 @@ fn setup(
visibility, visibility,
..default() ..default()
}, },
Dashboard,
ToggleableHudElement, ToggleableHudElement,
)).with_children(|builder| { )).with_children(|builder| {
builder.spawn(( builder.spawn((
@ -398,7 +401,6 @@ fn setup(
visibility, visibility,
..default() ..default()
}, },
Dashboard,
ToggleableHudElement, ToggleableHudElement,
)).with_children(|builder| { )).with_children(|builder| {
// The gauge symbol // The gauge symbol
@ -435,7 +437,11 @@ fn setup(
// Car-Dashboard-Style icons // Car-Dashboard-Style icons
let flashlight_visibility = bool2vis(visibility == Visibility::Visible && settings.flashlight_active); let flashlight_visibility = bool2vis(visibility == Visibility::Visible && settings.flashlight_active);
let dashboard_flashlight_handle: Handle<Image> = asset_server.load("sprites/dashboard_highbeams.png"); let style_dashboard = Style {
width: Val::VMin(6.0),
height: Val::VMin(6.0),
..Default::default()
};
commands.spawn(( commands.spawn((
NodeBundle { NodeBundle {
style: Style { style: Style {
@ -450,21 +456,25 @@ fn setup(
visibility, visibility,
..default() ..default()
}, },
Dashboard,
ToggleableHudElement, ToggleableHudElement,
)).with_children(|builder| { )).with_children(|builder| {
builder.spawn(( builder.spawn((
ImageBundle { ImageBundle {
image: UiImage::new(dashboard_flashlight_handle), image: UiImage::new(asset_server.load("sprites/dashboard_highbeams.png")),
style: Style { style: style_dashboard.clone(),
width: Val::VMin(6.0),
height: Val::VMin(6.0),
..Default::default()
},
visibility: flashlight_visibility, visibility: flashlight_visibility,
..Default::default() ..Default::default()
}, },
DashboardFlashlight, Dashboard::Flashlight,
));
builder.spawn((
ImageBundle {
image: UiImage::new(asset_server.load("sprites/dashboard_leak.png")),
style: style_dashboard.clone(),
visibility: flashlight_visibility,
..Default::default()
},
Dashboard::Leak,
)); ));
}); });
@ -609,14 +619,26 @@ fn setup(
fn update_dashboard( fn update_dashboard(
timer: ResMut<FPSUpdateTimer>, timer: ResMut<FPSUpdateTimer>,
mut q_flashlight: Query<&mut Visibility, With<DashboardFlashlight>>, mut q_dashboard: Query<(&mut Visibility, &Dashboard)>,
q_player: Query<&actor::Suit, With<actor::Player>>,
settings: Res<var::Settings>, settings: Res<var::Settings>,
) { ) {
if !settings.hud_active || !timer.0.just_finished() { if !settings.hud_active || !timer.0.just_finished() {
return; return;
} }
for mut vis in &mut q_flashlight { let player = q_player.get_single();
*vis = bool2vis(settings.flashlight_active); if player.is_err() { return; }
let suit = player.unwrap();
for (mut vis, icon) in &mut q_dashboard {
*vis = bool2vis(match icon {
Dashboard::Flashlight => {
settings.flashlight_active
}
Dashboard::Leak => {
suit.integrity < 0.5
}
});
} }
} }

139
src/svg/dashboard_leak.svg Normal file
View file

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="256"
height="256"
viewBox="0 0 67.733334 67.733334"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
sodipodi:docname="dashboard_leak.svg"
xml:space="preserve"
inkscape:export-filename="../../assets/sprites/dashboard_leak.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#000000"
bordercolor="#252525"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#000000"
inkscape:document-units="px"
inkscape:zoom="0.90142722"
inkscape:cx="-64.897086"
inkscape:cy="472.02923"
inkscape:window-width="2880"
inkscape:window-height="1765"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g227"
showgrid="false"
inkscape:export-bgcolor="#00000000"><inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="0.26458334"
spacingy="0.26458334"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="8"
dotted="false"
gridanglex="30"
gridanglez="30"
visible="false" /></sodipodi:namedview><defs
id="defs1"><marker
style="overflow:visible"
id="Triangle"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Triangle arrow"
markerWidth="0.75"
markerHeight="1"
viewBox="0 0 1 1"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="none"><path
transform="scale(0.5)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 5.77,0 -2.88,5 V -5 Z"
id="path135" /></marker><filter
style="color-interpolation-filters:sRGB"
id="filter1"
inkscape:label="bloom"
x="-0.17074027"
y="-0.16525779"
width="1.3414529"
height="1.3305156"><feConvolveMatrix
order="1 1"
kernelMatrix="1.0000000 "
id="feConvolveMatrix1"
result="result1"
bias="0.30000000000000004"
preserveAlpha="true"
edgeMode="none"
divisor="0" /><feGaussianBlur
stdDeviation="3"
id="feGaussianBlur1"
in="SourceGraphic" /><feComposite
id="feComposite1"
operator="arithmetic"
k1="1"
k2="1.5"
k3="1"
k4="0"
in2="result1" /></filter></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><g
id="g227"
style="filter:url(#filter1)"><path
style="font-variation-settings:'wght' 400;display:inline;fill:none;stroke:#be1251;stroke-width:3.43958;stroke-linejoin:round;stroke-dasharray:none"
d="m 12.7,49.741667 h 38.100002 c 0,0 14.816752,-40.2166687 -19.050001,-40.2166687 C -2.1166668,9.5249983 12.7,49.741667 12.7,49.741667 Z"
id="path3"
sodipodi:nodetypes="ccsc"
inkscape:label="Helmet" /><path
style="font-variation-settings:'wght' 400;display:none;fill:#be1251;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:normal"
d="m 45.73128,27.516669 -4.233333,8.466668 -7.455338,-7.65886 5.338672,9.775527 -8.466669,0.748606 6.350002,1.368061 -4.233335,7.809454 6.350002,-5.692788 0.843071,7.166799 1.273595,-7.166799 5.068722,6.349999 -2.952055,-6.349999 7.383041,3.63801 -7.383042,-5.754678 8.466668,-2.799589 -7.623804,-0.678689 z"
id="path4"
sodipodi:nodetypes="ccccccccccccccccc" /><path
id="path6"
style="font-variation-settings:'wght' 400;display:inline;fill:#be1251;fill-opacity:1;stroke:none;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:normal"
d="m 43.334305,29.492254 3.232361,4.170288 0.264583,3.643705 -2.38125,1.852083 -1.85208,-0.264578 -0.264583,-4.45091 -0.529167,4.45091 -4.233337,-0.264588 0.264584,-3.96875 1.852083,-2.38125 -2.38125,2.38125 -4.7625,-1.5875 4.497917,2.116666 -0.264584,3.439584 -6.35,2.38125 -3.107304,-1.657263 -0.332279,-3.898987 0.08113,3.832324 -3.256132,0.930176 3.082499,-0.599447 3.280937,1.965255 -0.542603,1.809192 -6.35,7.115328 27.516667,-0.765328 2.116667,-9.492961 -4.7625,-2.677873 -0.79375,-3.96875 z m 4.026111,8.607743 3.704167,2.38125 -0.529167,3.175 -5.291667,-0.264583 -2.645831,-3.968748 2.116664,0.264581 z m -10.583334,1.058333 -1.5875,4.7625 -3.96875,-0.529166 V 41.53958 Z m 0.529167,0 4.762502,0.264586 2.38125,4.233334 -8.466667,0.529166 z m 7.408333,5.027084 -0.79375,3.704167 h -7.672916 l -0.264584,-3.175001 5.556252,-0.264577 -1.852083,4.23333 1.058334,-0.26458 1.322916,-3.96875 z m -14.022916,0.264583 4.233333,0.529167 -0.264581,3.175003 -7.143752,-3e-6 z m 14.816666,0 4.762501,0.529167 -0.264584,3.175 -4.497914,-0.264581 z"
sodipodi:nodetypes="cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
inkscape:label="split" /><path
style="font-variation-settings:'wght' 400;display:none;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 40.21667,57.150004 c 6.349999,-4.233334 14.816667,4.233333 21.166668,0"
id="path13"
sodipodi:nodetypes="cc" /><path
style="font-variation-settings:'wght' 400;display:none;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
d="m 40.21667,60.227636 c 6.349999,-4.665132 14.816667,3.801535 21.166668,0"
id="path14"
sodipodi:nodetypes="cc" /><path
style="font-variation-settings:'wght' 400;display:none;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
d="m 40.21667,63.305268 c 6.349999,-5.096931 14.816667,3.369737 21.166668,0"
id="path15"
sodipodi:nodetypes="cc" /><path
style="font-variation-settings:'wght' 400;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Triangle);paint-order:normal"
d="m 55.033337,44.450003 h 6.35"
id="path16"
sodipodi:nodetypes="cc" /><path
style="font-variation-settings:'wght' 400;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Triangle);paint-order:normal"
d="m 52.165122,52.91667 7.101548,6.35"
id="path17"
sodipodi:nodetypes="cc" /><path
style="font-variation-settings:'wght' 400;fill:none;fill-opacity:1;stroke:#be1251;stroke-width:1.32292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Triangle);paint-order:normal"
d="m 44.450003,55.033337 0,4.233333"
id="path18"
sodipodi:nodetypes="cc" /></g></g></svg>

After

Width:  |  Height:  |  Size: 7.8 KiB