use bevy::app::PluginGroupBuilder; use bevy::asset::ChangeWatcher; use bevy::log::{Level, LogPlugin}; use bevy::prelude::*; use bevy::window::{PresentMode, WindowMode, WindowResolution}; use std::time::Duration; use crate::system::{get_asset_path_string, initial_size}; pub struct DefaultResourcesPlugin; impl Plugin for DefaultResourcesPlugin { fn build(&self, app: &mut App) { app.insert_resource(Msaa::Sample4) .insert_resource(ClearColor(Color::hex("040720").unwrap())); } } pub fn configure_default_plugins() -> PluginGroupBuilder { let (width, height) = initial_size(); let plugin_set = DefaultPlugins .set(WindowPlugin { primary_window: Some(Window { resolution: WindowResolution::new(width, height), resizable: true, mode: WindowMode::Windowed, title: String::from("KJ: Explore"), present_mode: PresentMode::AutoNoVsync, fit_canvas_to_parent: true, ..Default::default() }), ..Default::default() }) .set(AssetPlugin { asset_folder: get_asset_path_string(), watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(25)), }) .set(ImagePlugin::default_nearest()) .set(LogPlugin { filter: String::from( "info,game_core=debug,symphonia_core=warn,symphonia_format_ogg=warn,winit=warn,symphonia_bundle_mp3=warn,wgpu_core=warn,wgpu_hal=warn", ), level: if cfg!(debug_assertions) { Level::DEBUG } else { Level::WARN }, }); #[cfg(feature = "embed")] { plugin_set.add_before::<AssetPlugin, _>(bevy_embedded_assets::EmbeddedAssetPlugin) } #[cfg(not(feature = "embed"))] { plugin_set } } pub struct InitAppPlugins; impl PluginGroup for InitAppPlugins { fn build(self) -> PluginGroupBuilder { configure_default_plugins() .add(DefaultResourcesPlugin) .add(super::web::WebPlugin) } }