Compare commits
3 commits
fd643f702c
...
847c824307
Author | SHA1 | Date | |
---|---|---|---|
yuni | 847c824307 | ||
yuni | abb900d3f2 | ||
yuni | 5f783d6d16 |
|
@ -1,3 +1,7 @@
|
||||||
|
# v0.14.0-dev
|
||||||
|
|
||||||
|
- Add sparkles to Jupiter's ring ✨😍✨ best visible from Farview Station
|
||||||
|
|
||||||
# v0.13.0
|
# v0.13.0
|
||||||
|
|
||||||
- Reduce power usage when the menu is open or the window is unfocused
|
- Reduce power usage when the menu is open or the window is unfocused
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3039,7 +3039,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.13.0"
|
version = "0.14.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy_embedded_assets",
|
"bevy_embedded_assets",
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.13.0"
|
version = "0.14.0-dev"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://codeberg.org/outfly/outfly"
|
homepage = "https://codeberg.org/outfly/outfly"
|
||||||
repository = "https://codeberg.org/outfly/outfly"
|
repository = "https://codeberg.org/outfly/outfly"
|
||||||
|
|
|
@ -14,9 +14,9 @@ fn smooth_edge(start: f32, end: f32, value: f32) -> f32 {
|
||||||
return 4 * x * x * (1 - x * x);
|
return 4 * x * x * (1 - x * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn rand(co: vec2<f32>) -> f32 {
|
fn rand(co: vec2<f32>) -> f32 {
|
||||||
//return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//const PHI: f32 = 1.61803398874989484820459;
|
//const PHI: f32 = 1.61803398874989484820459;
|
||||||
//fn gold_noise(xy: vec2<f32>, seed: f32) -> f32 {
|
//fn gold_noise(xy: vec2<f32>, seed: f32) -> f32 {
|
||||||
|
@ -95,8 +95,8 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||||
//if (sin(in.uv[0] * 1000.0) + cos(in.uv[1] * 10412.0) > 1.999) {
|
//if (sin(in.uv[0] * 1000.0) + cos(in.uv[1] * 10412.0) > 1.999) {
|
||||||
//if (sin(in.uv[0] * 10000.0 + in.uv[1] * 5132.0) + cos(in.uv[0] * 12399.0 + in.uv[1] * 10412.0) > 1.999) {
|
//if (sin(in.uv[0] * 10000.0 + in.uv[1] * 5132.0) + cos(in.uv[0] * 12399.0 + in.uv[1] * 10412.0) > 1.999) {
|
||||||
//if (sin(sin(in.uv[0] * 10000000.0) * 412.0 + cos(in.uv[1] * 11132000.0) * 12.0) + cos(sin(in.uv[0] * 12309900.0) * 93.0 + sin(in.uv[1] * 10410200.0) * 115.0) > 1.999) {
|
//if (sin(sin(in.uv[0] * 10000000.0) * 412.0 + cos(in.uv[1] * 11132000.0) * 12.0) + cos(sin(in.uv[0] * 12309900.0) * 93.0 + sin(in.uv[1] * 10410200.0) * 115.0) > 1.999) {
|
||||||
//if (rand(in.uv) + rand(vec2(in.uv[1]*10.0, in.uv[0]*10.0)) > 1.997) {
|
if (rand(in.uv) + rand(vec2(in.uv[1]*10.0, in.uv[0]*10.0)) > 1.997) {
|
||||||
//alpha *= 200.0;
|
alpha *= 200.0;
|
||||||
//}
|
}
|
||||||
return vec4<f32>(color, alpha);
|
return vec4<f32>(color, alpha);
|
||||||
}
|
}
|
||||||
|
|
BIN
assets/sprites/pointer_dot.png
Normal file
BIN
assets/sprites/pointer_dot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
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::scene::SceneInstance;
|
||||||
use bevy::transform::TransformSystem;
|
use bevy::transform::TransformSystem;
|
||||||
use bevy_xpbd_3d::prelude::*;
|
use bevy_xpbd_3d::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
@ -57,6 +58,12 @@ pub const PLAYER_AR_AVATARS: &[(Avatar, &str, f32, &str)] = &[
|
||||||
(Avatar::Asteroid, "metis", 1.3, "Asteroid"),
|
(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;
|
pub struct HudPlugin;
|
||||||
impl Plugin for HudPlugin {
|
impl Plugin for HudPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
@ -77,6 +84,7 @@ impl Plugin for HudPlugin {
|
||||||
(
|
(
|
||||||
update_overlay_visibility,
|
update_overlay_visibility,
|
||||||
update_avatar.run_if(on_event::<UpdateAvatarEvent>()),
|
update_avatar.run_if(on_event::<UpdateAvatarEvent>()),
|
||||||
|
update_pointer.run_if(on_event::<UpdatePointerEvent>()),
|
||||||
update_ar_overlays
|
update_ar_overlays
|
||||||
.run_if(game_running)
|
.run_if(game_running)
|
||||||
.after(camera::position_to_transform)
|
.after(camera::position_to_transform)
|
||||||
|
@ -105,6 +113,7 @@ impl Plugin for HudPlugin {
|
||||||
)));
|
)));
|
||||||
app.add_event::<TargetEvent>();
|
app.add_event::<TargetEvent>();
|
||||||
app.add_event::<UpdateAvatarEvent>();
|
app.add_event::<UpdateAvatarEvent>();
|
||||||
|
app.add_event::<UpdatePointerEvent>();
|
||||||
app.add_event::<UpdateOverlayVisibility>();
|
app.add_event::<UpdateOverlayVisibility>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,6 +124,8 @@ pub struct TargetEvent(pub Option<Entity>);
|
||||||
pub struct UpdateOverlayVisibility;
|
pub struct UpdateOverlayVisibility;
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct UpdateAvatarEvent;
|
pub struct UpdateAvatarEvent;
|
||||||
|
#[derive(Event)]
|
||||||
|
pub struct UpdatePointerEvent;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct NodeHud;
|
struct NodeHud;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -126,7 +137,7 @@ struct NodeSpeedometerText;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct NodeCurrentChatLine;
|
struct NodeCurrentChatLine;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct Reticule;
|
struct PointerComponent(pub Pointer);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct Speedometer;
|
struct Speedometer;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
|
@ -180,6 +191,14 @@ pub struct AugmentedRealityOverlay {
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct FPSUpdateTimer(Timer);
|
struct FPSUpdateTimer(Timer);
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub enum Pointer {
|
||||||
|
None,
|
||||||
|
#[default]
|
||||||
|
Tri,
|
||||||
|
Dot,
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Avatar {
|
pub enum Avatar {
|
||||||
None,
|
None,
|
||||||
ChefHat,
|
ChefHat,
|
||||||
|
@ -296,6 +315,7 @@ impl Log {
|
||||||
pub fn setup(
|
pub fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
|
prefs: Res<Preferences>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
|
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
|
||||||
) {
|
) {
|
||||||
|
@ -387,31 +407,38 @@ pub fn setup(
|
||||||
parent.spawn((bundle_chatbox, NodeConsole));
|
parent.spawn((bundle_chatbox, NodeConsole));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add Reticule
|
// Add Pointer
|
||||||
let reticule_handle: Handle<Image> = asset_server.load("sprites/reticule4.png");
|
for (pointer_enum, sprite, _) in POINTERS {
|
||||||
commands
|
if sprite.is_none() {
|
||||||
.spawn((
|
continue;
|
||||||
NodeBundle {
|
}
|
||||||
style: style_centered(),
|
let sprite = sprite.unwrap();
|
||||||
visibility,
|
let pointer_handle: Handle<Image> = asset_server.load(sprite.to_string());
|
||||||
..default()
|
commands
|
||||||
},
|
.spawn((
|
||||||
ToggleableHudElement,
|
NodeBundle {
|
||||||
))
|
style: style_centered(),
|
||||||
.with_children(|builder| {
|
visibility,
|
||||||
builder.spawn((
|
..default()
|
||||||
ImageBundle {
|
},
|
||||||
image: UiImage::new(reticule_handle),
|
ToggleableHudElement,
|
||||||
style: Style {
|
))
|
||||||
width: Val::VMin(5.0),
|
.with_children(|builder| {
|
||||||
height: Val::VMin(5.0),
|
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()
|
||||||
},
|
},
|
||||||
..Default::default()
|
PointerComponent(pointer_enum.clone()),
|
||||||
},
|
));
|
||||||
Reticule,
|
});
|
||||||
));
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// HP/O2/Suit Integrity/Power Gauges
|
// HP/O2/Suit Integrity/Power Gauges
|
||||||
let gauges_handle: Handle<Image> = asset_server.load("sprites/gauge_horizontal.png");
|
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(
|
fn update_avatar(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut settings: ResMut<Settings>,
|
mut settings: ResMut<Settings>,
|
||||||
|
|
29
src/menu.rs
29
src/menu.rs
|
@ -65,6 +65,7 @@ pub enum DeathScreenEvent {
|
||||||
pub const MENUDEF: &[(&str, MenuAction)] = &[
|
pub const MENUDEF: &[(&str, MenuAction)] = &[
|
||||||
("", MenuAction::ToggleAR),
|
("", MenuAction::ToggleAR),
|
||||||
("", MenuAction::ChangeARAvatar),
|
("", MenuAction::ChangeARAvatar),
|
||||||
|
("", MenuAction::ChangePointer),
|
||||||
("", MenuAction::ToggleMap),
|
("", MenuAction::ToggleMap),
|
||||||
("", MenuAction::ModLightAmp),
|
("", MenuAction::ModLightAmp),
|
||||||
("", MenuAction::ModFlashlightPower),
|
("", MenuAction::ModFlashlightPower),
|
||||||
|
@ -84,6 +85,7 @@ pub enum MenuAction {
|
||||||
ToggleMap,
|
ToggleMap,
|
||||||
ToggleAR,
|
ToggleAR,
|
||||||
ChangeARAvatar,
|
ChangeARAvatar,
|
||||||
|
ChangePointer,
|
||||||
ModLightAmp,
|
ModLightAmp,
|
||||||
ModFlashlightPower,
|
ModFlashlightPower,
|
||||||
ModThrusterBoost,
|
ModThrusterBoost,
|
||||||
|
@ -544,6 +546,14 @@ pub fn update_menu(
|
||||||
text.sections[i].value = format!("Avatar: {avatar_title}\n");
|
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 => {
|
MenuAction::ToggleMap => {
|
||||||
let onoff = bool2string(settings.map_active);
|
let onoff = bool2string(settings.map_active);
|
||||||
text.sections[i].value = format!("Map: {onoff} [M]\n");
|
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_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
mut ew_updatemenu: EventWriter<UpdateMenuEvent>,
|
mut ew_updatemenu: EventWriter<UpdateMenuEvent>,
|
||||||
mut ew_updateavatar: EventWriter<hud::UpdateAvatarEvent>,
|
mut ew_updateavatar: EventWriter<hud::UpdateAvatarEvent>,
|
||||||
|
mut ew_updatepointer: EventWriter<hud::UpdatePointerEvent>,
|
||||||
mut ew_updateoverlays: EventWriter<hud::UpdateOverlayVisibility>,
|
mut ew_updateoverlays: EventWriter<hud::UpdateOverlayVisibility>,
|
||||||
) {
|
) {
|
||||||
let last_menu_entry = MENUDEF.len() - 1;
|
let last_menu_entry = MENUDEF.len() - 1;
|
||||||
|
@ -631,6 +642,24 @@ pub fn handle_input(
|
||||||
settings.ar_avatar += 1;
|
settings.ar_avatar += 1;
|
||||||
ew_updateavatar.send(hud::UpdateAvatarEvent);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ew_updatepointer.send(hud::UpdatePointerEvent);
|
||||||
|
ew_updatemenu.send(UpdateMenuEvent);
|
||||||
|
}
|
||||||
MenuAction::ModLightAmp => {
|
MenuAction::ModLightAmp => {
|
||||||
prefs.light_amp += 1;
|
prefs.light_amp += 1;
|
||||||
if prefs.light_amp > 3 {
|
if prefs.light_amp > 3 {
|
||||||
|
|
|
@ -473,6 +473,7 @@ pub struct Preferences {
|
||||||
pub third_person: bool,
|
pub third_person: bool,
|
||||||
pub shadows_sun: bool,
|
pub shadows_sun: bool,
|
||||||
pub avatar: usize,
|
pub avatar: usize,
|
||||||
|
pub pointer: hud::Pointer,
|
||||||
#[serde(default = "Preferences::default_light_amp")]
|
#[serde(default = "Preferences::default_light_amp")]
|
||||||
pub light_amp: usize, // 0-3
|
pub light_amp: usize, // 0-3
|
||||||
#[serde(default = "Preferences::default_flashlight_power")]
|
#[serde(default = "Preferences::default_flashlight_power")]
|
||||||
|
|
Loading…
Reference in a new issue