mirror of
https://github.com/seemueller-io/yachtpit.git
synced 2025-09-08 22:46:45 +00:00
webview displays in gps map with wry, happy 4th, boom boom (#4)
Co-authored-by: geoffsee <>
This commit is contained in:
14
.aiignore
Normal file
14
.aiignore
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# An .aiignore file follows the same syntax as a .gitignore file.
|
||||||
|
# .gitignore documentation: https://git-scm.com/docs/gitignore
|
||||||
|
# Junie will ask for explicit approval before view or edit the file or file within a directory listed in .aiignore.
|
||||||
|
# Only files contents is protected, Junie is still allowed to view file names even if they are listed in .aiignore.
|
||||||
|
# Be aware that the files you included in .aiignore can still be accessed by Junie in two cases:
|
||||||
|
# - If Brave Mode is turned on.
|
||||||
|
# - If a command has been added to the Allowlist — Junie will not ask for confirmation, even if it accesses - files and folders listed in .aiignore.
|
||||||
|
target
|
||||||
|
**/**/dist
|
||||||
|
.idea
|
||||||
|
.github
|
||||||
|
Cargo.lock
|
||||||
|
LICENSE
|
||||||
|
yachtpit.png
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -33,3 +33,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|||||||
|
|
||||||
# Finder (MacOS) folder config
|
# Finder (MacOS) folder config
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/.junie/
|
||||||
|
3089
Cargo.lock
generated
3089
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -62,11 +62,14 @@ webbrowser = { version = "1", features = ["hardened"] }
|
|||||||
systems = { path = "../systems" }
|
systems = { path = "../systems" }
|
||||||
components = { path = "../components" }
|
components = { path = "../components" }
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
web-sys = { version = "0.3", features = ["Document", "Element", "HtmlElement", "Window"] }
|
web-sys = { version = "0.3.53", features = ["Document", "Element", "HtmlElement", "Window"] }
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
|
||||||
# Platform-specific tokio features
|
# Platform-specific tokio features
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
tokio = { version = "1.0", features = ["rt", "rt-multi-thread"] }
|
tokio = { version = "1.0", features = ["rt", "rt-multi-thread"] }
|
||||||
|
image = "0.25"
|
||||||
|
winit = "0.30"
|
||||||
|
bevy_webview_wry = { version = "0.4", default-features = false, features = ["api"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
tokio = { version = "1.0", features = ["rt"] }
|
tokio = { version = "1.0", features = ["rt"] }
|
||||||
|
@@ -8,6 +8,7 @@ use bevy::prelude::*;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use systems::{VesselSystem, SystemInteraction, SystemStatus};
|
use systems::{VesselSystem, SystemInteraction, SystemStatus};
|
||||||
use components::{VesselData, SystemIndicator, SystemDisplayArea};
|
use components::{VesselData, SystemIndicator, SystemDisplayArea};
|
||||||
|
use crate::ui::{spawn_gps_map_window, GpsMapState};
|
||||||
// use crate::ui::{spawn_gps_map_window, GpsMapState};
|
// use crate::ui::{spawn_gps_map_window, GpsMapState};
|
||||||
|
|
||||||
/// Resource for managing all yacht systems
|
/// Resource for managing all yacht systems
|
||||||
@@ -123,7 +124,7 @@ fn update_all_systems(
|
|||||||
fn handle_system_indicator_interactions(
|
fn handle_system_indicator_interactions(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut system_manager: ResMut<SystemManager>,
|
mut system_manager: ResMut<SystemManager>,
|
||||||
// mut gps_map_state: ResMut<GpsMapState>,
|
mut gps_map_state: ResMut<GpsMapState>,
|
||||||
mut interaction_query: Query<
|
mut interaction_query: Query<
|
||||||
(&Interaction, &mut BackgroundColor, &SystemIndicator),
|
(&Interaction, &mut BackgroundColor, &SystemIndicator),
|
||||||
(Changed<Interaction>, With<Button>),
|
(Changed<Interaction>, With<Button>),
|
||||||
@@ -139,9 +140,9 @@ fn handle_system_indicator_interactions(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// If GPS system is selected, spawn the map window
|
// If GPS system is selected, spawn the map window
|
||||||
// if indicator.system_id == "gps" {
|
if indicator.system_id == "gps" {
|
||||||
// spawn_gps_map_window(&mut commands, &mut gps_map_state);
|
spawn_gps_map_window(&mut commands, &mut gps_map_state);
|
||||||
// }
|
}
|
||||||
|
|
||||||
*background_color = BackgroundColor(Color::linear_rgb(0.0, 0.3, 0.5));
|
*background_color = BackgroundColor(Color::linear_rgb(0.0, 0.3, 0.5));
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,7 @@ impl Plugin for GamePlugin {
|
|||||||
SystemManagerPlugin,
|
SystemManagerPlugin,
|
||||||
PlayerPlugin,
|
PlayerPlugin,
|
||||||
))
|
))
|
||||||
|
|
||||||
.add_systems(OnEnter(GameState::Playing), (setup_instrument_cluster, initialize_vessel_systems));
|
.add_systems(OnEnter(GameState::Playing), (setup_instrument_cluster, initialize_vessel_systems));
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
@@ -8,6 +8,7 @@ use bevy::winit::WinitWindows;
|
|||||||
use bevy::DefaultPlugins;
|
use bevy::DefaultPlugins;
|
||||||
use yachtpit::GamePlugin;
|
use yachtpit::GamePlugin;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
use bevy_webview_wry::WebviewWryPlugin;
|
||||||
use winit::window::Icon;
|
use winit::window::Icon;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -33,9 +34,9 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.add_plugins(GamePlugin)
|
.add_plugins(GamePlugin)
|
||||||
.add_systems(Startup, set_window_icon)
|
.add_systems(Startup, set_window_icon)
|
||||||
|
.add_plugins(WebviewWryPlugin::default())
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the icon on windows and X11
|
// Sets the icon on windows and X11
|
||||||
fn set_window_icon(
|
fn set_window_icon(
|
||||||
windows: NonSend<WinitWindows>,
|
windows: NonSend<WinitWindows>,
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy::render::view::RenderLayers;
|
||||||
use bevy::window::Window;
|
use bevy::window::Window;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use bevy_webview_wry::prelude::*;
|
||||||
|
/// Render layer for GPS map entities to isolate them from other cameras
|
||||||
|
const GPS_MAP_LAYER: usize = 1;
|
||||||
|
|
||||||
/// Component to mark the GPS map window
|
/// Component to mark the GPS map window
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
@@ -79,7 +83,7 @@ fn update_map_tiles(
|
|||||||
|
|
||||||
// For now, we'll create a simple placeholder map
|
// For now, we'll create a simple placeholder map
|
||||||
// In a full implementation, this would fetch actual OSM tiles
|
// In a full implementation, this would fetch actual OSM tiles
|
||||||
if map_tiles.is_empty() {
|
if map_tiles.is_empty() && gps_map_state.window_id.is_some() {
|
||||||
spawn_placeholder_map(&mut commands, &asset_server);
|
spawn_placeholder_map(&mut commands, &asset_server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,35 +100,34 @@ fn spawn_placeholder_map(commands: &mut Commands, _asset_server: &Res<AssetServe
|
|||||||
};
|
};
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
GpsMapWindow,
|
||||||
|
Transform::from_translation(Vec3::new(x as f32 * 100.0, y as f32 * 100.0, 0.0)),
|
||||||
|
GlobalTransform::default(),
|
||||||
Sprite {
|
Sprite {
|
||||||
color,
|
color,
|
||||||
custom_size: Some(Vec2::new(256.0, 256.0)),
|
custom_size: Some(Vec2::new(100.0, 100.0)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Transform::from_translation(Vec3::new(
|
|
||||||
x as f32 * 256.0,
|
|
||||||
y as f32 * 256.0,
|
|
||||||
0.0,
|
|
||||||
)),
|
|
||||||
MapTile {
|
MapTile {
|
||||||
x,
|
x: x as i32,
|
||||||
y,
|
y: y as i32,
|
||||||
zoom: 10,
|
zoom: 10,
|
||||||
},
|
},
|
||||||
GpsMapWindow,
|
RenderLayers::layer(GPS_MAP_LAYER),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a marker for the vessel position
|
// Add a marker for the vessel position
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Sprite {
|
// Sprite {
|
||||||
color: Color::linear_rgb(1.0, 0.0, 0.0),
|
// color: Color::linear_rgb(1.0, 0.0, 0.0),
|
||||||
custom_size: Some(Vec2::new(20.0, 20.0)),
|
// custom_size: Some(Vec2::new(20.0, 20.0)),
|
||||||
..default()
|
// ..default()
|
||||||
},
|
// },
|
||||||
Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
|
// Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
|
||||||
GpsMapWindow,
|
GpsMapWindow,
|
||||||
|
RenderLayers::layer(GPS_MAP_LAYER),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,10 +161,27 @@ pub fn spawn_gps_map_window(
|
|||||||
target: bevy::render::camera::RenderTarget::Window(bevy::window::WindowRef::Entity(window_entity)),
|
target: bevy::render::camera::RenderTarget::Window(bevy::window::WindowRef::Entity(window_entity)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
RenderLayers::layer(GPS_MAP_LAYER),
|
||||||
GpsMapWindow,
|
GpsMapWindow,
|
||||||
));
|
));
|
||||||
|
|
||||||
gps_map_state.window_id = Some(window_entity);
|
gps_map_state.window_id = Some(window_entity);
|
||||||
|
|
||||||
|
spawn_gps_webview(commands, gps_map_state);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
info!("GPS map window spawned with entity: {:?}", window_entity);
|
info!("GPS map window spawned with entity: {:?}", window_entity);
|
||||||
}
|
}
|
||||||
|
fn spawn_gps_webview(
|
||||||
|
commands: &mut Commands,
|
||||||
|
gps_map_state: &mut ResMut<GpsMapState>,
|
||||||
|
) {
|
||||||
|
if let Some(win) = gps_map_state.window_id {
|
||||||
|
commands
|
||||||
|
.entity(win)
|
||||||
|
.insert(Webview::Uri(WebviewUri::new(
|
||||||
|
"https://www.openstreetmap.org/", // or any URL you like
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user