add setting to change reticule/pointer
This commit is contained in:
parent
abb900d3f2
commit
c737e4ac8b
|
@ -1,6 +1,7 @@
|
|||
# v0.14.0-dev
|
||||
|
||||
- Add sparkles to Jupiter's ring ✨😍✨ best visible from Farview Station
|
||||
- Add setting to change pointer
|
||||
|
||||
# v0.13.0
|
||||
|
||||
|
|
BIN
assets/sprites/pointer_dot.png
Normal file
BIN
assets/sprites/pointer_dot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
88
src/hud.rs
88
src/hud.rs
|
@ -17,6 +17,7 @@ use bevy::prelude::*;
|
|||
use bevy::scene::SceneInstance;
|
||||
use bevy::transform::TransformSystem;
|
||||
use bevy_xpbd_3d::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::VecDeque;
|
||||
use std::time::SystemTime;
|
||||
|
||||
|
@ -57,6 +58,12 @@ pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[
|
|||
(Avatar::Asteroid, "metis", 1.3, "Asteroid"),
|
||||
];
|
||||
|
||||
pub const POINTERS: &[(Pointer, Option<&str>, &str)] = &[
|
||||
(Pointer::None, None, "Off"),
|
||||
(Pointer::Tri, Some("sprites/pointer_tri.png"), "Default"),
|
||||
(Pointer::Dot, Some("sprites/pointer_dot.png"), "Dot"),
|
||||
];
|
||||
|
||||
pub struct HudPlugin;
|
||||
impl Plugin for HudPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
|
@ -77,6 +84,7 @@ impl Plugin for HudPlugin {
|
|||
(
|
||||
update_overlay_visibility,
|
||||
update_avatar.run_if(on_event::<UpdateAvatarEvent>()),
|
||||
update_pointer.run_if(on_event::<UpdatePointerEvent>()),
|
||||
update_ar_overlays
|
||||
.run_if(game_running)
|
||||
.after(camera::position_to_transform)
|
||||
|
@ -105,6 +113,7 @@ impl Plugin for HudPlugin {
|
|||
)));
|
||||
app.add_event::<TargetEvent>();
|
||||
app.add_event::<UpdateAvatarEvent>();
|
||||
app.add_event::<UpdatePointerEvent>();
|
||||
app.add_event::<UpdateOverlayVisibility>();
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +124,8 @@ pub struct TargetEvent(pub Option<Entity>);
|
|||
pub struct UpdateOverlayVisibility;
|
||||
#[derive(Event)]
|
||||
pub struct UpdateAvatarEvent;
|
||||
#[derive(Event)]
|
||||
pub struct UpdatePointerEvent;
|
||||
#[derive(Component)]
|
||||
struct NodeHud;
|
||||
#[derive(Component)]
|
||||
|
@ -126,7 +137,7 @@ struct NodeSpeedometerText;
|
|||
#[derive(Component)]
|
||||
struct NodeCurrentChatLine;
|
||||
#[derive(Component)]
|
||||
struct Reticule;
|
||||
struct PointerComponent(pub Pointer);
|
||||
#[derive(Component)]
|
||||
struct Speedometer;
|
||||
#[derive(Component)]
|
||||
|
@ -180,6 +191,14 @@ pub struct AugmentedRealityOverlay {
|
|||
#[derive(Resource)]
|
||||
struct FPSUpdateTimer(Timer);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Pointer {
|
||||
None,
|
||||
#[default]
|
||||
Tri,
|
||||
Dot,
|
||||
}
|
||||
|
||||
pub enum Avatar {
|
||||
None,
|
||||
ChefHat,
|
||||
|
@ -296,6 +315,7 @@ impl Log {
|
|||
pub fn setup(
|
||||
mut commands: Commands,
|
||||
settings: Res<Settings>,
|
||||
prefs: Res<Preferences>,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
|
||||
) {
|
||||
|
@ -387,31 +407,38 @@ pub fn setup(
|
|||
parent.spawn((bundle_chatbox, NodeConsole));
|
||||
});
|
||||
|
||||
// Add Reticule
|
||||
let reticule_handle: Handle<Image> = asset_server.load("sprites/reticule4.png");
|
||||
commands
|
||||
.spawn((
|
||||
NodeBundle {
|
||||
style: style_centered(),
|
||||
visibility,
|
||||
..default()
|
||||
},
|
||||
ToggleableHudElement,
|
||||
))
|
||||
.with_children(|builder| {
|
||||
builder.spawn((
|
||||
ImageBundle {
|
||||
image: UiImage::new(reticule_handle),
|
||||
style: Style {
|
||||
width: Val::VMin(5.0),
|
||||
height: Val::VMin(5.0),
|
||||
// Add Pointer
|
||||
for (pointer_enum, sprite, _) in POINTERS {
|
||||
if sprite.is_none() {
|
||||
continue;
|
||||
}
|
||||
let sprite = sprite.unwrap();
|
||||
let pointer_handle: Handle<Image> = asset_server.load(sprite.to_string());
|
||||
commands
|
||||
.spawn((
|
||||
NodeBundle {
|
||||
style: style_centered(),
|
||||
visibility,
|
||||
..default()
|
||||
},
|
||||
ToggleableHudElement,
|
||||
))
|
||||
.with_children(|builder| {
|
||||
builder.spawn((
|
||||
ImageBundle {
|
||||
image: UiImage::new(pointer_handle),
|
||||
style: Style {
|
||||
width: Val::VMin(5.0),
|
||||
height: Val::VMin(5.0),
|
||||
..Default::default()
|
||||
},
|
||||
visibility: bool2vis(prefs.pointer == *pointer_enum),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Reticule,
|
||||
));
|
||||
});
|
||||
PointerComponent(pointer_enum.clone()),
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// HP/O2/Suit Integrity/Power Gauges
|
||||
let gauges_handle: Handle<Image> = asset_server.load("sprites/gauge_horizontal.png");
|
||||
|
@ -1300,6 +1327,19 @@ fn update_overlay_visibility(
|
|||
};
|
||||
}
|
||||
|
||||
fn update_pointer(
|
||||
prefs: ResMut<Preferences>,
|
||||
mut q_pointer: Query<(&PointerComponent, &mut Visibility)>,
|
||||
) {
|
||||
for (pointer, mut vis) in &mut q_pointer {
|
||||
*vis = if pointer.0 == prefs.pointer {
|
||||
Visibility::Inherited
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_avatar(
|
||||
mut commands: Commands,
|
||||
mut settings: ResMut<Settings>,
|
||||
|
|
30
src/menu.rs
30
src/menu.rs
|
@ -65,6 +65,7 @@ pub enum DeathScreenEvent {
|
|||
pub const MENUDEF: &[(&str, MenuAction)] = &[
|
||||
("", MenuAction::ToggleAR),
|
||||
("", MenuAction::ChangeARAvatar),
|
||||
("", MenuAction::ChangePointer),
|
||||
("", MenuAction::ToggleMap),
|
||||
("", MenuAction::ModLightAmp),
|
||||
("", MenuAction::ModFlashlightPower),
|
||||
|
@ -84,6 +85,7 @@ pub enum MenuAction {
|
|||
ToggleMap,
|
||||
ToggleAR,
|
||||
ChangeARAvatar,
|
||||
ChangePointer,
|
||||
ModLightAmp,
|
||||
ModFlashlightPower,
|
||||
ModThrusterBoost,
|
||||
|
@ -544,6 +546,14 @@ pub fn update_menu(
|
|||
text.sections[i].value = format!("Avatar: {avatar_title}\n");
|
||||
}
|
||||
}
|
||||
MenuAction::ChangePointer => {
|
||||
for pointer in hud::POINTERS {
|
||||
if pointer.0 == prefs.pointer {
|
||||
text.sections[i].value = format!("Pointer: {}\n", pointer.2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
MenuAction::ToggleMap => {
|
||||
let onoff = bool2string(settings.map_active);
|
||||
text.sections[i].value = format!("Map: {onoff} [M]\n");
|
||||
|
@ -577,6 +587,7 @@ pub fn handle_input(
|
|||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
mut ew_updatemenu: EventWriter<UpdateMenuEvent>,
|
||||
mut ew_updateavatar: EventWriter<hud::UpdateAvatarEvent>,
|
||||
mut ew_updatepointer: EventWriter<hud::UpdatePointerEvent>,
|
||||
mut ew_updateoverlays: EventWriter<hud::UpdateOverlayVisibility>,
|
||||
) {
|
||||
let last_menu_entry = MENUDEF.len() - 1;
|
||||
|
@ -631,6 +642,25 @@ pub fn handle_input(
|
|||
settings.ar_avatar += 1;
|
||||
ew_updateavatar.send(hud::UpdateAvatarEvent);
|
||||
}
|
||||
MenuAction::ChangePointer => {
|
||||
let mut index = 0;
|
||||
for (i, pointer) in hud::POINTERS.iter().enumerate() {
|
||||
if pointer.0 == prefs.pointer {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
index = (index + 1) % hud::POINTERS.len();
|
||||
for (i, pointer) in hud::POINTERS.iter().enumerate() {
|
||||
if i == index {
|
||||
prefs.pointer = pointer.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prefs.save();
|
||||
ew_updatepointer.send(hud::UpdatePointerEvent);
|
||||
ew_updatemenu.send(UpdateMenuEvent);
|
||||
}
|
||||
MenuAction::ModLightAmp => {
|
||||
prefs.light_amp += 1;
|
||||
if prefs.light_amp > 3 {
|
||||
|
|
|
@ -473,6 +473,7 @@ pub struct Preferences {
|
|||
pub third_person: bool,
|
||||
pub shadows_sun: bool,
|
||||
pub avatar: usize,
|
||||
pub pointer: hud::Pointer,
|
||||
#[serde(default = "Preferences::default_light_amp")]
|
||||
pub light_amp: usize, // 0-3
|
||||
#[serde(default = "Preferences::default_flashlight_power")]
|
||||
|
|
Loading…
Reference in a new issue