mirror of
https://github.com/seemueller-io/yachtpit.git
synced 2025-09-08 22:46:45 +00:00
Refactor instrument cluster components into individual modules for improved maintainability and reusability.
This commit is contained in:
5
crates/components/src/ais_indicator.rs
Normal file
5
crates/components/src/ais_indicator.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// AIS indicator component for displaying AIS system status
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct AisIndicator;
|
5
crates/components/src/compass_gauge.rs
Normal file
5
crates/components/src/compass_gauge.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Compass gauge component for displaying vessel heading
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct CompassGauge;
|
5
crates/components/src/depth_gauge.rs
Normal file
5
crates/components/src/depth_gauge.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Depth gauge component for displaying water depth
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct DepthGauge;
|
5
crates/components/src/engine_status.rs
Normal file
5
crates/components/src/engine_status.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Engine status component for displaying engine information
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct EngineStatus;
|
5
crates/components/src/gps_indicator.rs
Normal file
5
crates/components/src/gps_indicator.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// GPS indicator component for displaying GPS system status
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct GpsIndicator;
|
@@ -1,26 +1,21 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use super::instruments::*;
|
|
||||||
use super::theme::*;
|
use super::theme::*;
|
||||||
use super::composition::*;
|
use super::composition::*;
|
||||||
|
use super::speed_gauge::SpeedGauge;
|
||||||
|
use super::depth_gauge::DepthGauge;
|
||||||
|
use super::compass_gauge::CompassGauge;
|
||||||
|
use super::engine_status::EngineStatus;
|
||||||
|
use super::navigation_display::NavigationDisplay;
|
||||||
|
use super::gps_indicator::GpsIndicator;
|
||||||
|
use super::radar_indicator::RadarIndicator;
|
||||||
|
use super::ais_indicator::AisIndicator;
|
||||||
|
use super::system_display::SystemDisplay;
|
||||||
|
use super::wind_display::WindDisplay;
|
||||||
|
|
||||||
|
/// Main instrument cluster component
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct InstrumentCluster;
|
pub struct InstrumentCluster;
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct GpsIndicator;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct RadarIndicator;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct AisIndicator;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct SystemDisplay;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct WindDisplay;
|
|
||||||
|
|
||||||
/// Sets up the main instrument cluster UI using composable components
|
/// Sets up the main instrument cluster UI using composable components
|
||||||
pub fn setup_instrument_cluster(mut commands: Commands) {
|
pub fn setup_instrument_cluster(mut commands: Commands) {
|
||||||
// Spawn camera since we're bypassing the menu system
|
// Spawn camera since we're bypassing the menu system
|
||||||
@@ -110,45 +105,39 @@ pub fn setup_instrument_cluster(mut commands: Commands) {
|
|||||||
grid.spawn(progress_bar_node())
|
grid.spawn(progress_bar_node())
|
||||||
.with_children(|bar| {
|
.with_children(|bar| {
|
||||||
bar.spawn(create_text("FUEL", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
bar.spawn(create_text("FUEL", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
||||||
bar.spawn((
|
bar.spawn(progress_bar_background_node())
|
||||||
progress_bar_background_node(),
|
.with_children(|bg| {
|
||||||
BackgroundColor(BACKGROUND_COLOR_PRIMARY),
|
bg.spawn((
|
||||||
BorderColor(TEXT_COLOR_PRIMARY),
|
|
||||||
))
|
|
||||||
.with_children(|bar_bg| {
|
|
||||||
bar_bg.spawn((
|
|
||||||
progress_bar_fill_node(75.0),
|
progress_bar_fill_node(75.0),
|
||||||
BackgroundColor(TEXT_COLOR_SUCCESS),
|
BackgroundColor(TEXT_COLOR_SUCCESS),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
bar.spawn(create_text("75%", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
bar.spawn(create_text("75%", FONT_SIZE_SMALL, TEXT_COLOR_SUCCESS));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Battery Level Bar
|
// Battery Level Bar
|
||||||
grid.spawn(progress_bar_node())
|
grid.spawn(progress_bar_node())
|
||||||
.with_children(|bar| {
|
.with_children(|bar| {
|
||||||
bar.spawn(create_text("BATTERY", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
bar.spawn(create_text("BATT", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
||||||
bar.spawn((
|
bar.spawn(progress_bar_background_node())
|
||||||
progress_bar_background_node(),
|
.with_children(|bg| {
|
||||||
BackgroundColor(BACKGROUND_COLOR_SECONDARY),
|
bg.spawn((
|
||||||
BorderColor(BORDER_COLOR_SECONDARY),
|
|
||||||
))
|
|
||||||
.with_children(|bar_bg| {
|
|
||||||
bar_bg.spawn((
|
|
||||||
progress_bar_fill_node(88.0),
|
progress_bar_fill_node(88.0),
|
||||||
BackgroundColor(BACKGROUND_COLOR_SECONDARY),
|
BackgroundColor(TEXT_COLOR_SUCCESS),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
bar.spawn(create_text("88%", FONT_SIZE_SMALL, TEXT_COLOR_PRIMARY));
|
bar.spawn(create_text("88%", FONT_SIZE_SMALL, TEXT_COLOR_SUCCESS));
|
||||||
});
|
});
|
||||||
|
|
||||||
// System Status Indicators
|
// System Indicators Row
|
||||||
grid.spawn(Node {
|
grid.spawn((
|
||||||
flex_direction: FlexDirection::Row,
|
Node {
|
||||||
justify_content: JustifyContent::SpaceBetween,
|
flex_direction: FlexDirection::Row,
|
||||||
width: Val::Percent(100.0),
|
justify_content: JustifyContent::SpaceEvenly,
|
||||||
..default()
|
width: Val::Percent(100.0),
|
||||||
})
|
..default()
|
||||||
|
},
|
||||||
|
))
|
||||||
.with_children(|indicators| {
|
.with_children(|indicators| {
|
||||||
// GPS Indicator
|
// GPS Indicator
|
||||||
indicators.spawn((
|
indicators.spawn((
|
||||||
@@ -225,4 +214,4 @@ pub fn setup_instrument_cluster(mut commands: Commands) {
|
|||||||
display.spawn(create_text("Select a system above to view details", FONT_SIZE_SMALL, TEXT_COLOR_SECONDARY));
|
display.spawn(create_text("Select a system above to view details", FONT_SIZE_SMALL, TEXT_COLOR_SECONDARY));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
@@ -3,14 +3,38 @@
|
|||||||
// Components crate for yacht pit application
|
// Components crate for yacht pit application
|
||||||
// This crate contains reusable UI and game components
|
// This crate contains reusable UI and game components
|
||||||
|
|
||||||
|
// Shared modules
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod instruments;
|
|
||||||
pub mod theme;
|
pub mod theme;
|
||||||
pub mod cluster;
|
|
||||||
pub mod composition;
|
pub mod composition;
|
||||||
|
|
||||||
|
// Individual component modules
|
||||||
|
pub mod speed_gauge;
|
||||||
|
pub mod depth_gauge;
|
||||||
|
pub mod compass_gauge;
|
||||||
|
pub mod engine_status;
|
||||||
|
pub mod navigation_display;
|
||||||
|
pub mod yacht_data;
|
||||||
|
pub mod instrument_cluster;
|
||||||
|
pub mod gps_indicator;
|
||||||
|
pub mod radar_indicator;
|
||||||
|
pub mod ais_indicator;
|
||||||
|
pub mod system_display;
|
||||||
|
pub mod wind_display;
|
||||||
|
|
||||||
|
// Re-export everything
|
||||||
pub use ui::*;
|
pub use ui::*;
|
||||||
pub use instruments::*;
|
|
||||||
pub use theme::*;
|
pub use theme::*;
|
||||||
pub use cluster::*;
|
|
||||||
pub use composition::*;
|
pub use composition::*;
|
||||||
|
pub use speed_gauge::*;
|
||||||
|
pub use depth_gauge::*;
|
||||||
|
pub use compass_gauge::*;
|
||||||
|
pub use engine_status::*;
|
||||||
|
pub use navigation_display::*;
|
||||||
|
pub use yacht_data::*;
|
||||||
|
pub use instrument_cluster::*;
|
||||||
|
pub use gps_indicator::*;
|
||||||
|
pub use radar_indicator::*;
|
||||||
|
pub use ais_indicator::*;
|
||||||
|
pub use system_display::*;
|
||||||
|
pub use wind_display::*;
|
||||||
|
5
crates/components/src/navigation_display.rs
Normal file
5
crates/components/src/navigation_display.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Navigation display component for showing navigation information
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct NavigationDisplay;
|
5
crates/components/src/radar_indicator.rs
Normal file
5
crates/components/src/radar_indicator.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Radar indicator component for displaying radar system status
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct RadarIndicator;
|
5
crates/components/src/speed_gauge.rs
Normal file
5
crates/components/src/speed_gauge.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Speed gauge component for displaying vessel speed
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct SpeedGauge;
|
5
crates/components/src/system_display.rs
Normal file
5
crates/components/src/system_display.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// System display component for showing detailed system information
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct SystemDisplay;
|
5
crates/components/src/wind_display.rs
Normal file
5
crates/components/src/wind_display.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
/// Wind display component for showing wind information
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct WindDisplay;
|
@@ -1,20 +1,7 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use super::speed_gauge::SpeedGauge;
|
||||||
/// Individual instrument components
|
use super::depth_gauge::DepthGauge;
|
||||||
#[derive(Component)]
|
use super::compass_gauge::CompassGauge;
|
||||||
pub struct SpeedGauge;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct DepthGauge;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct CompassGauge;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct EngineStatus;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct NavigationDisplay;
|
|
||||||
|
|
||||||
/// Yacht data resource containing all sensor readings
|
/// Yacht data resource containing all sensor readings
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
Reference in New Issue
Block a user