add second speedometer for very high speeds
This commit is contained in:
parent
54da276091
commit
21df9da95c
BIN
assets/sprites/speedometer_white.png
Normal file
BIN
assets/sprites/speedometer_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
|
@ -2,9 +2,9 @@
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
width="1000"
|
width="985"
|
||||||
height="200"
|
height="200"
|
||||||
viewBox="0 0 264.58333 52.916667"
|
viewBox="0 0 260.61458 52.916667"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg1"
|
id="svg1"
|
||||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
inkscape:pagecheckerboard="0"
|
inkscape:pagecheckerboard="0"
|
||||||
inkscape:deskcolor="#d1d1d1"
|
inkscape:deskcolor="#d1d1d1"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:zoom="2.3358165"
|
inkscape:zoom="9.343266"
|
||||||
inkscape:cx="415.70046"
|
inkscape:cx="1011.1025"
|
||||||
inkscape:cy="74.706211"
|
inkscape:cy="67.695814"
|
||||||
inkscape:window-width="2880"
|
inkscape:window-width="2880"
|
||||||
inkscape:window-height="1685"
|
inkscape:window-height="1685"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="0"
|
||||||
|
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
295
media/speedometer2white.svg
Normal file
295
media/speedometer2white.svg
Normal file
|
@ -0,0 +1,295 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="985"
|
||||||
|
height="200"
|
||||||
|
viewBox="0 0 260.61458 52.916667"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
|
sodipodi:docname="speedometer2white.svg"
|
||||||
|
inkscape:export-filename="speedometer.png"
|
||||||
|
inkscape:export-xdpi="200"
|
||||||
|
inkscape:export-ydpi="200"
|
||||||
|
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="#999999"
|
||||||
|
borderopacity="1"
|
||||||
|
inkscape:showpageshadow="0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:zoom="1.2086006"
|
||||||
|
inkscape:cx="618.07017"
|
||||||
|
inkscape:cy="108.80352"
|
||||||
|
inkscape:window-width="2880"
|
||||||
|
inkscape:window-height="1685"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="80"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:export-bgcolor="#00000000"
|
||||||
|
showgrid="true">
|
||||||
|
<inkscape:grid
|
||||||
|
id="grid1"
|
||||||
|
units="px"
|
||||||
|
originx="0"
|
||||||
|
originy="0"
|
||||||
|
spacingx="0.26458333"
|
||||||
|
spacingy="0.26458333"
|
||||||
|
empcolor="#0099e5"
|
||||||
|
empopacity="0.30196078"
|
||||||
|
color="#0099e5"
|
||||||
|
opacity="0.14901961"
|
||||||
|
empspacing="5"
|
||||||
|
dotted="false"
|
||||||
|
gridanglex="30"
|
||||||
|
gridanglez="30"
|
||||||
|
visible="true" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.594583;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1"
|
||||||
|
width="6.614583"
|
||||||
|
height="5.2916651"
|
||||||
|
x="5.3530993e-08"
|
||||||
|
y="47.624996" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.594579;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1"
|
||||||
|
width="6.614583"
|
||||||
|
height="5.2916675"
|
||||||
|
x="7.9374995"
|
||||||
|
y="47.624996" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.664764;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9"
|
||||||
|
width="6.614583"
|
||||||
|
height="6.6145825"
|
||||||
|
x="15.874999"
|
||||||
|
y="46.302082" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.664761;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5"
|
||||||
|
width="6.6145825"
|
||||||
|
height="6.6145835"
|
||||||
|
x="23.8125"
|
||||||
|
y="46.302082" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.728215;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3"
|
||||||
|
width="6.6145825"
|
||||||
|
height="7.9375"
|
||||||
|
x="31.75"
|
||||||
|
y="44.979164" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.728212;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1"
|
||||||
|
width="6.6145825"
|
||||||
|
height="7.9375"
|
||||||
|
x="39.6875"
|
||||||
|
y="44.979164" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.786555;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8"
|
||||||
|
width="6.6145821"
|
||||||
|
height="9.2604189"
|
||||||
|
x="47.625"
|
||||||
|
y="43.656246" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.786559;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4"
|
||||||
|
width="6.6145821"
|
||||||
|
height="9.2604189"
|
||||||
|
x="55.5625"
|
||||||
|
y="43.656246" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.84087;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6"
|
||||||
|
width="6.6145821"
|
||||||
|
height="10.583335"
|
||||||
|
x="63.5"
|
||||||
|
y="42.333332" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.840873;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5"
|
||||||
|
width="6.6145816"
|
||||||
|
height="10.583337"
|
||||||
|
x="71.4375"
|
||||||
|
y="42.333332" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.891875;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1"
|
||||||
|
width="6.6145816"
|
||||||
|
height="11.906252"
|
||||||
|
x="79.375"
|
||||||
|
y="41.010414" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.94012;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7"
|
||||||
|
width="6.6145797"
|
||||||
|
height="13.229167"
|
||||||
|
x="87.3125"
|
||||||
|
y="39.687496" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.940122;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5"
|
||||||
|
width="6.6145811"
|
||||||
|
height="13.229168"
|
||||||
|
x="95.25"
|
||||||
|
y="39.687496" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:0.986006;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3"
|
||||||
|
width="6.6145811"
|
||||||
|
height="14.552086"
|
||||||
|
x="103.1875"
|
||||||
|
y="38.364582" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.02985;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-1"
|
||||||
|
width="6.6145806"
|
||||||
|
height="15.875004"
|
||||||
|
x="111.125"
|
||||||
|
y="37.041664" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.02985;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8"
|
||||||
|
width="6.6145806"
|
||||||
|
height="15.875003"
|
||||||
|
x="119.0625"
|
||||||
|
y="37.041664" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.0719;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9"
|
||||||
|
width="6.6145806"
|
||||||
|
height="17.19792"
|
||||||
|
x="127"
|
||||||
|
y="35.718746" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.11236;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6"
|
||||||
|
width="6.6145802"
|
||||||
|
height="18.520832"
|
||||||
|
x="134.9375"
|
||||||
|
y="34.395832" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.11236;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-3"
|
||||||
|
width="6.6145802"
|
||||||
|
height="18.520832"
|
||||||
|
x="142.875"
|
||||||
|
y="34.395832" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.15141;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-86"
|
||||||
|
width="6.6145954"
|
||||||
|
height="19.843752"
|
||||||
|
x="150.81248"
|
||||||
|
y="33.072914" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.18917;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-0"
|
||||||
|
width="6.6145949"
|
||||||
|
height="21.166664"
|
||||||
|
x="158.74998"
|
||||||
|
y="31.749998" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.22577;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-4"
|
||||||
|
width="6.6145949"
|
||||||
|
height="22.489586"
|
||||||
|
x="166.68748"
|
||||||
|
y="30.427082" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.2613;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-1-8"
|
||||||
|
width="6.6145949"
|
||||||
|
height="23.812502"
|
||||||
|
x="174.62498"
|
||||||
|
y="29.104164" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.29586;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8-8"
|
||||||
|
width="6.6145945"
|
||||||
|
height="25.135418"
|
||||||
|
x="182.56248"
|
||||||
|
y="27.781248" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.36236;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9-8"
|
||||||
|
width="6.6145945"
|
||||||
|
height="27.781252"
|
||||||
|
x="190.49998"
|
||||||
|
y="25.135416" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.42576;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9"
|
||||||
|
width="6.6145792"
|
||||||
|
height="30.427082"
|
||||||
|
x="198.4375"
|
||||||
|
y="22.489582" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.48646;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4"
|
||||||
|
width="6.6145792"
|
||||||
|
height="33.072914"
|
||||||
|
x="206.375"
|
||||||
|
y="19.843748" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.54477;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0"
|
||||||
|
width="6.6145792"
|
||||||
|
height="35.718746"
|
||||||
|
x="214.31248"
|
||||||
|
y="17.197916" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.60096;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4"
|
||||||
|
width="6.6145792"
|
||||||
|
height="38.364578"
|
||||||
|
x="222.24998"
|
||||||
|
y="14.552082" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.65525;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4"
|
||||||
|
width="6.6145792"
|
||||||
|
height="41.010414"
|
||||||
|
x="230.05521"
|
||||||
|
y="11.906249" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.73349;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2"
|
||||||
|
width="6.6145792"
|
||||||
|
height="44.97916"
|
||||||
|
x="238.125"
|
||||||
|
y="7.937501" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.80835;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2-5"
|
||||||
|
width="6.6145792"
|
||||||
|
height="48.94791"
|
||||||
|
x="246.0625"
|
||||||
|
y="3.9687498" />
|
||||||
|
<rect
|
||||||
|
style="font-variation-settings:'wght' 700;fill:#ffffff;stroke:none;stroke-width:1.88023;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1"
|
||||||
|
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2-5-2"
|
||||||
|
width="6.6145792"
|
||||||
|
height="52.91666"
|
||||||
|
x="253.99998"
|
||||||
|
y="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 11 KiB |
76
src/hud.rs
76
src/hud.rs
|
@ -25,6 +25,8 @@ pub const LOG_MAX_TIME_S: f64 = 30.0;
|
||||||
pub const LOG_MAX_ROWS: usize = 30;
|
pub const LOG_MAX_ROWS: usize = 30;
|
||||||
pub const LOG_MAX: usize = LOG_MAX_ROWS;
|
pub const LOG_MAX: usize = LOG_MAX_ROWS;
|
||||||
pub const MAX_CHOICES: usize = 10;
|
pub const MAX_CHOICES: usize = 10;
|
||||||
|
pub const SPEEDOMETER_WIDTH: f32 = 40.0;
|
||||||
|
pub const SPEEDOMETER_HEIGHT: f32 = 10.0;
|
||||||
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
||||||
pub const AMBIENT_LIGHT_AR: f32 = 30.0;
|
pub const AMBIENT_LIGHT_AR: f32 = 30.0;
|
||||||
//pub const REPLY_NUMBERS: [char; 10] = ['❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '⓿'];
|
//pub const REPLY_NUMBERS: [char; 10] = ['❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '⓿'];
|
||||||
|
@ -37,6 +39,7 @@ impl Plugin for HudPlugin {
|
||||||
app.add_systems(Startup, setup);
|
app.add_systems(Startup, setup);
|
||||||
app.add_systems(Update, (
|
app.add_systems(Update, (
|
||||||
update_hud,
|
update_hud,
|
||||||
|
update_speedometer,
|
||||||
handle_input,
|
handle_input,
|
||||||
handle_target_event,
|
handle_target_event,
|
||||||
));
|
));
|
||||||
|
@ -75,6 +78,7 @@ impl Plugin for HudPlugin {
|
||||||
#[derive(Component)] struct NodeCurrentChatLine;
|
#[derive(Component)] struct NodeCurrentChatLine;
|
||||||
#[derive(Component)] struct Reticule;
|
#[derive(Component)] struct Reticule;
|
||||||
#[derive(Component)] struct Speedometer;
|
#[derive(Component)] struct Speedometer;
|
||||||
|
#[derive(Component)] struct Speedometer2;
|
||||||
#[derive(Component)] pub struct ToggleableHudElement;
|
#[derive(Component)] pub struct ToggleableHudElement;
|
||||||
#[derive(Component)] pub struct ToggleableHudMapElement;
|
#[derive(Component)] pub struct ToggleableHudMapElement;
|
||||||
#[derive(Component)] struct Selectagon;
|
#[derive(Component)] struct Selectagon;
|
||||||
|
@ -321,11 +325,12 @@ fn setup(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add Speedometer
|
// Add Speedometer
|
||||||
let reticule_handle: Handle<Image> = asset_server.load("sprites/speedometer.png");
|
let speedometer_height = 10.0;
|
||||||
|
let speedometer_handle: Handle<Image> = asset_server.load("sprites/speedometer.png");
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
NodeBundle {
|
NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(10.0),
|
width: Val::VMin(0.0),
|
||||||
height: Val::Percent(100.0),
|
height: Val::Percent(100.0),
|
||||||
align_items: AlignItems::End,
|
align_items: AlignItems::End,
|
||||||
overflow: Overflow::clip(),
|
overflow: Overflow::clip(),
|
||||||
|
@ -339,10 +344,38 @@ fn setup(
|
||||||
)).with_children(|builder| {
|
)).with_children(|builder| {
|
||||||
builder.spawn((
|
builder.spawn((
|
||||||
ImageBundle {
|
ImageBundle {
|
||||||
image: UiImage::new(reticule_handle),
|
image: UiImage::new(speedometer_handle),
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(50.0),
|
width: Val::VMin(SPEEDOMETER_WIDTH),
|
||||||
height: Val::VMin(10.0),
|
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
});
|
||||||
|
let speedometer_handle: Handle<Image> = asset_server.load("sprites/speedometer_white.png");
|
||||||
|
commands.spawn((
|
||||||
|
NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
width: Val::VMin(0.0),
|
||||||
|
height: Val::Percent(100.0),
|
||||||
|
align_items: AlignItems::End,
|
||||||
|
overflow: Overflow::clip(),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
visibility,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
Speedometer2,
|
||||||
|
ToggleableHudElement,
|
||||||
|
)).with_children(|builder| {
|
||||||
|
builder.spawn((
|
||||||
|
ImageBundle {
|
||||||
|
image: UiImage::new(speedometer_handle),
|
||||||
|
style: Style {
|
||||||
|
width: Val::VMin(SPEEDOMETER_WIDTH),
|
||||||
|
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -411,6 +444,30 @@ fn setup(
|
||||||
ew_updateoverlays.send(UpdateOverlayVisibility);
|
ew_updateoverlays.send(UpdateOverlayVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_speedometer(
|
||||||
|
q_camera: Query<&LinearVelocity, With<actor::PlayerCamera>>,
|
||||||
|
mut q_speedometer: Query<&mut Style, (With<Speedometer>, Without<Speedometer2>)>,
|
||||||
|
mut q_speedometer2: Query<&mut Style, (With<Speedometer2>, Without<Speedometer>)>,
|
||||||
|
) {
|
||||||
|
if let Ok(cam_v) = q_camera.get_single() {
|
||||||
|
let speed = cam_v.length();
|
||||||
|
|
||||||
|
let speedometer_split = 5_000.0;
|
||||||
|
if let Ok(mut speedometer) = q_speedometer.get_single_mut() {
|
||||||
|
let custom_c = speedometer_split;
|
||||||
|
let fraction = nature::lorenz_factor_custom_c((custom_c - speed).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
||||||
|
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
||||||
|
speedometer.width = Val::VMin(wid);
|
||||||
|
}
|
||||||
|
if let Ok(mut speedometer2) = q_speedometer2.get_single_mut() {
|
||||||
|
let custom_c = nature::C - speedometer_split;
|
||||||
|
let fraction = nature::lorenz_factor_custom_c((custom_c - speed + speedometer_split).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
||||||
|
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
||||||
|
speedometer2.width = Val::VMin(wid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn update_hud(
|
fn update_hud(
|
||||||
diagnostics: Res<DiagnosticsStore>,
|
diagnostics: Res<DiagnosticsStore>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
|
@ -426,7 +483,6 @@ fn update_hud(
|
||||||
mut q_node_currentline: Query<&mut Text, (With<NodeCurrentChatLine>, Without<NodeHud>, Without<NodeConsole>, Without<NodeChoiceText>)>,
|
mut q_node_currentline: Query<&mut Text, (With<NodeCurrentChatLine>, Without<NodeHud>, Without<NodeConsole>, Without<NodeChoiceText>)>,
|
||||||
query_all_actors: Query<&actor::Actor>,
|
query_all_actors: Query<&actor::Actor>,
|
||||||
settings: Res<var::Settings>,
|
settings: Res<var::Settings>,
|
||||||
mut q_speedometer: Query<&mut Style, With<Speedometer>>,
|
|
||||||
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||||
) {
|
) {
|
||||||
// TODO only when hud is actually on
|
// TODO only when hud is actually on
|
||||||
|
@ -526,14 +582,6 @@ fn update_hud(
|
||||||
let speed_readable = nature::readable_distance(speed);
|
let speed_readable = nature::readable_distance(speed);
|
||||||
text.sections[14].value = format!("\n{speed_readable}/s\n{gforce:.1}g{dev_speed}");
|
text.sections[14].value = format!("\n{speed_readable}/s\n{gforce:.1}g{dev_speed}");
|
||||||
|
|
||||||
if let Ok(mut speedometer) = q_speedometer.get_single_mut() {
|
|
||||||
let custom_c = nature::C / 1000.0;
|
|
||||||
let fraction = nature::lorenz_factor_custom_c(custom_c - speed, custom_c) as f32;
|
|
||||||
info!(fraction);
|
|
||||||
let wid = (fraction * 100.0).clamp(0.0, 100.0);
|
|
||||||
speedometer.width = Val::VMin(wid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if target_multiple {
|
if target_multiple {
|
||||||
text.sections[15].value = "\n\nERROR: MULTIPLE TARGETS".to_string();
|
text.sections[15].value = "\n\nERROR: MULTIPLE TARGETS".to_string();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue