This commit is contained in:
commit
f29712d158
259 files changed
+52069
No files matched your search
@@ -0,0 +1,13 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy::remote::{http::RemoteHttpPlugin, RemotePlugin};
|
||||
|
||||
/// Bevy Remote Protocol support for future external editor, automation, and AI
|
||||
/// tooling. This is editor-only so the shipped game does not expose a port.
|
||||
pub struct BrpPlugin;
|
||||
|
||||
impl Plugin for BrpPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(RemotePlugin::default())
|
||||
.add_plugins(RemoteHttpPlugin::default());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//! Deferred editor command execution (palette, BRP bridge).
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct PendingEditorCommands {
|
||||
pub queue: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn queue_editor_command(world: &mut World, name: String) {
|
||||
world
|
||||
.resource_mut::<PendingEditorCommands>()
|
||||
.queue
|
||||
.push(name);
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
//! Editor extensibility: command registry, inspector sections, and extension hooks.
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::{egui, EguiContexts, EguiPrimaryContextPass};
|
||||
|
||||
use crate::history::group_selection_with_history;
|
||||
use crate::state::{EditorMode, PlayPossession};
|
||||
use crate::ui::helpers::{
|
||||
reset_scene_lighting_to_project_defaults, toggle_play_mode, toggle_play_paused,
|
||||
};
|
||||
use crate::ui::selection_ops::focus_editor_camera_on_selection;
|
||||
use crate::ui::theme::{apply_editor_theme, PANEL_BG, TEXT, TEXT_DIM};
|
||||
use crate::ui::UiState;
|
||||
|
||||
/// Named editor command invokable from the palette and BRP.
|
||||
pub trait EditorCommand: Send + Sync {
|
||||
fn name(&self) -> &str;
|
||||
fn execute(&self, world: &mut World);
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct EditorCommandRegistry {
|
||||
commands: Vec<Box<dyn EditorCommand>>,
|
||||
}
|
||||
|
||||
impl EditorCommandRegistry {
|
||||
pub fn register(&mut self, command: Box<dyn EditorCommand>) {
|
||||
self.commands.push(command);
|
||||
}
|
||||
|
||||
pub fn names(&self) -> Vec<String> {
|
||||
self.commands
|
||||
.iter()
|
||||
.map(|cmd| cmd.name().to_string())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn run(&self, world: &mut World, name: &str) -> bool {
|
||||
if let Some(command) = self.commands.iter().find(|cmd| cmd.name() == name) {
|
||||
command.execute(world);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Custom inspector body for level objects (game crates register via [`register_actor_inspector_section`]).
|
||||
pub trait ActorInspectorSection: Send + Sync {
|
||||
fn id(&self) -> &str;
|
||||
fn title(&self) -> &str;
|
||||
fn order(&self) -> i32;
|
||||
fn applies_to(&self, world: &World, entity: Entity) -> bool;
|
||||
fn ui(&self, world: &mut World, ui: &mut egui::Ui, entity: Entity);
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct ActorInspectorSectionRegistry {
|
||||
sections: Vec<Box<dyn ActorInspectorSection>>,
|
||||
}
|
||||
|
||||
impl ActorInspectorSectionRegistry {
|
||||
pub fn register(&mut self, section: Box<dyn ActorInspectorSection>) {
|
||||
self.sections.push(section);
|
||||
}
|
||||
|
||||
pub fn sections_for(&self, world: &World, entity: Entity) -> Vec<&dyn ActorInspectorSection> {
|
||||
let mut matched: Vec<_> = self
|
||||
.sections
|
||||
.iter()
|
||||
.filter(|section| section.applies_to(world, entity))
|
||||
.map(|section| section.as_ref())
|
||||
.collect();
|
||||
matched.sort_by_key(|section| section.order());
|
||||
matched
|
||||
}
|
||||
|
||||
pub fn draw_sections(&self, world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
let mut matched: Vec<_> = self
|
||||
.sections
|
||||
.iter()
|
||||
.filter(|section| section.applies_to(world, entity))
|
||||
.collect();
|
||||
matched.sort_by_key(|section| section.order());
|
||||
for section in matched {
|
||||
section.ui(world, ui, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_actor_inspector_section(app: &mut App, section: Box<dyn ActorInspectorSection>) {
|
||||
if !app
|
||||
.world()
|
||||
.contains_resource::<ActorInspectorSectionRegistry>()
|
||||
{
|
||||
app.init_resource::<ActorInspectorSectionRegistry>();
|
||||
}
|
||||
app.world_mut()
|
||||
.resource_mut::<ActorInspectorSectionRegistry>()
|
||||
.register(section);
|
||||
}
|
||||
|
||||
/// Optional extension point for registering editor panels and menu hooks.
|
||||
pub trait EditorExtension: Send + Sync {
|
||||
fn name(&self) -> &str;
|
||||
fn register(&self, _app: &mut App) {}
|
||||
}
|
||||
|
||||
/// Formal editor plugin surface for game-specific panels (H5).
|
||||
pub trait EditorPlugin: Send + Sync {
|
||||
fn name(&self) -> &str;
|
||||
fn register(&self, app: &mut App);
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct EditorExtensions {
|
||||
pub extensions: Vec<Box<dyn EditorExtension>>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct RegisteredEditorPlugins {
|
||||
pub plugins: Vec<Box<dyn EditorPlugin>>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct CommandPalette {
|
||||
pub open: bool,
|
||||
pub filter: String,
|
||||
pub pending_run: Option<String>,
|
||||
}
|
||||
|
||||
pub struct ExtensibilityPlugin;
|
||||
|
||||
impl Plugin for ExtensibilityPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<EditorCommandRegistry>()
|
||||
.init_resource::<ActorInspectorSectionRegistry>()
|
||||
.init_resource::<EditorExtensions>()
|
||||
.init_resource::<RegisteredEditorPlugins>()
|
||||
.init_resource::<CommandPalette>()
|
||||
.init_resource::<crate::command_queue::PendingEditorCommands>()
|
||||
.add_systems(Startup, register_builtin_commands)
|
||||
.add_systems(Update, run_palette_commands)
|
||||
.add_systems(EguiPrimaryContextPass, command_palette_ui);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_editor_plugin(app: &mut App, plugin: Box<dyn EditorPlugin>) {
|
||||
plugin.register(app);
|
||||
app.world_mut()
|
||||
.resource_mut::<RegisteredEditorPlugins>()
|
||||
.plugins
|
||||
.push(plugin);
|
||||
}
|
||||
|
||||
fn register_builtin_commands(mut registry: ResMut<EditorCommandRegistry>) {
|
||||
registry.register(Box::new(TogglePlayCommand));
|
||||
registry.register(Box::new(TogglePlayPausedCommand));
|
||||
registry.register(Box::new(TogglePossessionCommand));
|
||||
registry.register(Box::new(ResetLightingCommand));
|
||||
registry.register(Box::new(GroupSelectionCommand));
|
||||
registry.register(Box::new(FocusSelectionCommand));
|
||||
registry.register(Box::new(CreatePostProcessVolumeCommand));
|
||||
registry.register(Box::new(FocusActiveVolumesCommand));
|
||||
registry.register(Box::new(SelectVolumesAtCameraCommand));
|
||||
}
|
||||
|
||||
fn run_palette_commands(world: &mut World) {
|
||||
let pending = world.resource_mut::<CommandPalette>().pending_run.take();
|
||||
if let Some(name) = pending {
|
||||
dispatch_editor_command(world, &name);
|
||||
}
|
||||
let names = std::mem::take(
|
||||
&mut world
|
||||
.resource_mut::<crate::command_queue::PendingEditorCommands>()
|
||||
.queue,
|
||||
);
|
||||
for name in names {
|
||||
dispatch_editor_command(world, &name);
|
||||
}
|
||||
}
|
||||
|
||||
fn dispatch_editor_command(world: &mut World, name: &str) {
|
||||
let ran = world
|
||||
.resource_scope(|world, registry: Mut<EditorCommandRegistry>| registry.run(world, name));
|
||||
if !ran {
|
||||
warn!("unknown editor command: {name}");
|
||||
}
|
||||
}
|
||||
|
||||
struct TogglePlayCommand;
|
||||
|
||||
impl EditorCommand for TogglePlayCommand {
|
||||
fn name(&self) -> &str {
|
||||
"play.toggle"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
toggle_play_mode(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct TogglePlayPausedCommand;
|
||||
|
||||
impl EditorCommand for TogglePlayPausedCommand {
|
||||
fn name(&self) -> &str {
|
||||
"play.toggle_pause"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
toggle_play_paused(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct TogglePossessionCommand;
|
||||
|
||||
impl EditorCommand for TogglePossessionCommand {
|
||||
fn name(&self) -> &str {
|
||||
"play.toggle_possession"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
if *world.resource::<State<EditorMode>>().get() != EditorMode::Playing {
|
||||
return;
|
||||
}
|
||||
let next = match *world.resource::<PlayPossession>() {
|
||||
PlayPossession::Possessed => PlayPossession::Ejected,
|
||||
PlayPossession::Ejected => PlayPossession::Possessed,
|
||||
};
|
||||
*world.resource_mut::<PlayPossession>() = next;
|
||||
}
|
||||
}
|
||||
|
||||
struct ResetLightingCommand;
|
||||
|
||||
impl EditorCommand for ResetLightingCommand {
|
||||
fn name(&self) -> &str {
|
||||
"scene.reset_lighting"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
reset_scene_lighting_to_project_defaults(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct GroupSelectionCommand;
|
||||
|
||||
impl EditorCommand for GroupSelectionCommand {
|
||||
fn name(&self) -> &str {
|
||||
"selection.group"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
let selected: Vec<Entity> = world
|
||||
.resource::<UiState>()
|
||||
.selected_entities
|
||||
.iter()
|
||||
.collect();
|
||||
group_selection_with_history(world, &selected);
|
||||
}
|
||||
}
|
||||
|
||||
struct FocusSelectionCommand;
|
||||
|
||||
impl EditorCommand for FocusSelectionCommand {
|
||||
fn name(&self) -> &str {
|
||||
"selection.focus"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
focus_editor_camera_on_selection(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct CreatePostProcessVolumeCommand;
|
||||
|
||||
impl EditorCommand for CreatePostProcessVolumeCommand {
|
||||
fn name(&self) -> &str {
|
||||
"rendering.create_volume"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
crate::rendering_diagnostics::spawn_post_process_volume_at_camera(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct FocusActiveVolumesCommand;
|
||||
|
||||
impl EditorCommand for FocusActiveVolumesCommand {
|
||||
fn name(&self) -> &str {
|
||||
"rendering.focus_active_volumes"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
crate::rendering_diagnostics::select_volumes_at_camera(world);
|
||||
focus_editor_camera_on_selection(world);
|
||||
}
|
||||
}
|
||||
|
||||
struct SelectVolumesAtCameraCommand;
|
||||
|
||||
impl EditorCommand for SelectVolumesAtCameraCommand {
|
||||
fn name(&self) -> &str {
|
||||
"rendering.select_volumes_at_camera"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
crate::rendering_diagnostics::select_volumes_at_camera(world);
|
||||
}
|
||||
}
|
||||
|
||||
fn command_palette_ui(
|
||||
mut contexts: EguiContexts,
|
||||
mut palette: ResMut<CommandPalette>,
|
||||
registry: Res<EditorCommandRegistry>,
|
||||
) -> Result {
|
||||
let Ok(ctx) = contexts.ctx_mut() else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
apply_editor_theme(ctx);
|
||||
|
||||
if ctx.input(|input| input.modifiers.command && input.key_pressed(egui::Key::P)) {
|
||||
palette.open = true;
|
||||
}
|
||||
|
||||
if !palette.open {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut open = palette.open;
|
||||
egui::Window::new("Command Palette")
|
||||
.open(&mut open)
|
||||
.default_width(400.0)
|
||||
.frame(egui::Frame::window(&ctx.style()).fill(PANEL_BG))
|
||||
.show(ctx, |ui| {
|
||||
ui.label(
|
||||
egui::RichText::new("Ctrl+P — filter and run commands")
|
||||
.color(TEXT_DIM)
|
||||
.small(),
|
||||
);
|
||||
ui.add(
|
||||
egui::TextEdit::singleline(&mut palette.filter)
|
||||
.hint_text("Type to filter...")
|
||||
.desired_width(f32::INFINITY),
|
||||
);
|
||||
ui.separator();
|
||||
egui::ScrollArea::vertical()
|
||||
.max_height(280.0)
|
||||
.show(ui, |ui| {
|
||||
for name in registry.names() {
|
||||
if !palette.filter.is_empty()
|
||||
&& !name.to_lowercase().contains(&palette.filter.to_lowercase())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let response =
|
||||
ui.selectable_label(false, egui::RichText::new(&name).color(TEXT));
|
||||
if response.clicked() {
|
||||
palette.pending_run = Some(name);
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
palette.open = open;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//! Game-specific [`ActorInspectorSection`] implementations (ADR 0007 dogfood).
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use shared::{LevelObject, WeaponSpawn};
|
||||
|
||||
use super::extensibility::{register_actor_inspector_section, ActorInspectorSection};
|
||||
|
||||
/// Registers inspector sections declared in [`game::editor_ext::actor_inspector_section_ids`].
|
||||
pub fn register_game_inspector_sections(app: &mut App) {
|
||||
for id in game::editor_ext::actor_inspector_section_ids() {
|
||||
match *id {
|
||||
"game.fps_weapon_stats" => {
|
||||
register_actor_inspector_section(app, Box::new(FpsWeaponStatsSection));
|
||||
}
|
||||
other => {
|
||||
warn!("unknown game actor inspector section id: {other}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct FpsWeaponStatsSection;
|
||||
|
||||
impl ActorInspectorSection for FpsWeaponStatsSection {
|
||||
fn id(&self) -> &str {
|
||||
"game.fps_weapon_stats"
|
||||
}
|
||||
|
||||
fn title(&self) -> &str {
|
||||
"Weapon Stats (Demo)"
|
||||
}
|
||||
|
||||
fn order(&self) -> i32 {
|
||||
200
|
||||
}
|
||||
|
||||
fn applies_to(&self, world: &World, entity: Entity) -> bool {
|
||||
world
|
||||
.get_entity(entity)
|
||||
.is_ok_and(|e| e.contains::<LevelObject>() && e.contains::<WeaponSpawn>())
|
||||
}
|
||||
|
||||
fn ui(&self, _world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
ui.collapsing(self.title(), |ui| {
|
||||
ui.label(format!("Entity {entity:?}"));
|
||||
ui.small("Registered from `game::editor_ext` — extend with gameplay fields.");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//! Renders game-registered editor panel state (ADR 0007 dogfood UI).
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::{egui, EguiContexts, EguiPrimaryContextPass};
|
||||
|
||||
use game::editor_ext::FpsDemoPanelState;
|
||||
|
||||
pub struct GameEditorPanelsPlugin;
|
||||
|
||||
impl Plugin for GameEditorPanelsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(EguiPrimaryContextPass, fps_demo_panel_ui);
|
||||
}
|
||||
}
|
||||
|
||||
fn fps_demo_panel_ui(mut contexts: EguiContexts, mut panel: ResMut<FpsDemoPanelState>) -> Result {
|
||||
let Ok(ctx) = contexts.ctx_mut() else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if panel.headline.is_empty() {
|
||||
panel.headline = "FPS Foundation Demo".into();
|
||||
}
|
||||
|
||||
if ctx.input(|input| {
|
||||
input.modifiers.command && input.key_pressed(egui::Key::G) && input.modifiers.shift
|
||||
}) {
|
||||
panel.open = !panel.open;
|
||||
}
|
||||
|
||||
if !panel.open {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut open = panel.open;
|
||||
egui::Window::new("FPS Demo (Game EditorPlugin)")
|
||||
.open(&mut open)
|
||||
.default_width(280.0)
|
||||
.show(ctx, |ui| {
|
||||
ui.label("Registered from `game::editor_ext` via ADR 0007.");
|
||||
ui.small("Toggle: Ctrl+Shift+G");
|
||||
ui.separator();
|
||||
ui.heading(&panel.headline);
|
||||
ui.label("Game crate owns panel state; editor renders the dock window.");
|
||||
});
|
||||
panel.open = open;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
//! Dev-only hot reload polling and status for the `game_hot` dylib.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{mpsc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use game::{hot_reload_subscribe, on_hot_reload};
|
||||
use hot_lib_reloader::LibReloadObserver;
|
||||
use notify::Event;
|
||||
|
||||
/// Status label shown in the bottom status bar.
|
||||
#[derive(Resource, Debug, Clone)]
|
||||
pub struct HotReloadState {
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
impl Default for HotReloadState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
label: "Hot reload: idle".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct HotReloadPlugin;
|
||||
|
||||
impl Plugin for HotReloadPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<HotReloadState>()
|
||||
.add_systems(Startup, spawn_dylib_watcher)
|
||||
.add_systems(Last, poll_lib_reload)
|
||||
.add_systems(Last, manual_hot_reload);
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_dylib_watcher(mut commands: Commands) {
|
||||
let Some(path) = game_hot_dylib_path() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let watch_path = path.clone();
|
||||
std::thread::spawn(move || {
|
||||
use notify::{EventKind, RecommendedWatcher, RecursiveMode, Watcher};
|
||||
|
||||
let tx = tx.clone();
|
||||
let mut watcher = RecommendedWatcher::new(
|
||||
move |result: notify::Result<Event>| {
|
||||
if let Ok(event) = result {
|
||||
if matches!(event.kind, EventKind::Modify(_) | EventKind::Create(_)) {
|
||||
let _ = tx.send(());
|
||||
}
|
||||
}
|
||||
},
|
||||
notify::Config::default(),
|
||||
)
|
||||
.expect("hot reload watcher");
|
||||
|
||||
if let Some(parent) = watch_path.parent() {
|
||||
let _ = watcher.watch(parent, RecursiveMode::NonRecursive);
|
||||
}
|
||||
|
||||
loop {
|
||||
std::thread::sleep(Duration::from_secs(3600));
|
||||
}
|
||||
});
|
||||
|
||||
commands.insert_resource(DylibWatchReceiver(Mutex::new(rx)));
|
||||
info!("Watching for game_hot dylib changes at {}", path.display());
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct DylibWatchReceiver(Mutex<mpsc::Receiver<()>>);
|
||||
|
||||
fn poll_lib_reload(world: &mut World, mut observer: Local<Option<LibReloadObserver>>) {
|
||||
if observer.is_none() {
|
||||
*observer = Some(hot_reload_subscribe());
|
||||
}
|
||||
|
||||
let mut building = false;
|
||||
if let Some(watch) = world.get_resource::<DylibWatchReceiver>() {
|
||||
if let Ok(rx) = watch.0.lock() {
|
||||
while rx.try_recv().is_ok() {
|
||||
building = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if building {
|
||||
world.resource_mut::<HotReloadState>().label = "Hot reload: building…".into();
|
||||
}
|
||||
|
||||
let Some(obs) = observer.as_ref() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if obs.wait_for_reload_timeout(Duration::ZERO) {
|
||||
on_hot_reload(world);
|
||||
world.resource_mut::<HotReloadState>().label = "Hot reload: reloaded".into();
|
||||
info!("game_hot dylib reloaded");
|
||||
}
|
||||
}
|
||||
|
||||
fn manual_hot_reload(world: &mut World) {
|
||||
let ctrl = world
|
||||
.resource::<ButtonInput<KeyCode>>()
|
||||
.pressed(KeyCode::ControlLeft)
|
||||
|| world
|
||||
.resource::<ButtonInput<KeyCode>>()
|
||||
.pressed(KeyCode::ControlRight);
|
||||
let shift = world
|
||||
.resource::<ButtonInput<KeyCode>>()
|
||||
.pressed(KeyCode::ShiftLeft)
|
||||
|| world
|
||||
.resource::<ButtonInput<KeyCode>>()
|
||||
.pressed(KeyCode::ShiftRight);
|
||||
let reload = world
|
||||
.resource::<ButtonInput<KeyCode>>()
|
||||
.just_pressed(KeyCode::KeyR);
|
||||
|
||||
if ctrl && shift && reload {
|
||||
on_hot_reload(world);
|
||||
world.resource_mut::<HotReloadState>().label = "Hot reload: manual refresh".into();
|
||||
info!("Manual hot reload refresh (Ctrl+Shift+R)");
|
||||
}
|
||||
}
|
||||
|
||||
fn game_hot_dylib_path() -> Option<PathBuf> {
|
||||
let target = std::env::var("CARGO_TARGET_DIR").map_or_else(
|
||||
|_| PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target")),
|
||||
PathBuf::from,
|
||||
);
|
||||
let profile = if cfg!(debug_assertions) {
|
||||
"debug"
|
||||
} else {
|
||||
"release"
|
||||
};
|
||||
Some(target.join(profile).join(game_hot_lib_name()))
|
||||
}
|
||||
|
||||
fn game_hot_lib_name() -> &'static str {
|
||||
if cfg!(target_os = "macos") {
|
||||
"libgame_hot.dylib"
|
||||
} else if cfg!(target_os = "windows") {
|
||||
"game_hot.dll"
|
||||
} else {
|
||||
"libgame_hot.so"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//! Editor extensibility, BRP, command queue, and optional hot reload.
|
||||
|
||||
pub mod brp;
|
||||
pub mod command_queue;
|
||||
pub mod extensibility;
|
||||
pub mod game_inspector;
|
||||
pub mod game_panels;
|
||||
#[cfg(feature = "hot-reload")]
|
||||
pub mod hot_reload;
|
||||
Reference in new issue
Block a user