mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
ability to set startup data for the editor
- this decreases iteration times dramatically allowing you to immeadiately load desired scene and start editing it
This commit is contained in:
+38
-8
@@ -319,6 +319,15 @@ pub struct GameLoopData {
|
||||
elapsed_time: f32,
|
||||
}
|
||||
|
||||
pub struct StartupData {
|
||||
/// Working directory that should be set when starting the editor. If it is empty, then
|
||||
/// current working directory won't be changed.
|
||||
pub working_directory: PathBuf,
|
||||
|
||||
/// A scene to load at the editor start. If it is empty, no scene will be loaded.
|
||||
pub scene: PathBuf,
|
||||
}
|
||||
|
||||
pub struct Editor {
|
||||
game_loop_data: GameLoopData,
|
||||
engine: Engine,
|
||||
@@ -352,7 +361,7 @@ pub struct Editor {
|
||||
}
|
||||
|
||||
impl Editor {
|
||||
pub fn new(event_loop: &EventLoop<()>) -> Self {
|
||||
pub fn new(event_loop: &EventLoop<()>, startup_data: Option<StartupData>) -> Self {
|
||||
let inner_size = if let Some(primary_monitor) = event_loop.primary_monitor() {
|
||||
let mut monitor_dimensions = primary_monitor.size();
|
||||
monitor_dimensions.height = (monitor_dimensions.height as f32 * 0.7) as u32;
|
||||
@@ -393,13 +402,6 @@ impl Editor {
|
||||
message_sender.clone(),
|
||||
&mut engine.user_interface.build_ctx(),
|
||||
);
|
||||
engine
|
||||
.user_interface
|
||||
.send_message(WindowMessage::open_modal(
|
||||
configurator.window,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
));
|
||||
|
||||
let mut settings = Settings::default();
|
||||
|
||||
@@ -617,6 +619,34 @@ impl Editor {
|
||||
|
||||
editor.set_interaction_mode(Some(InteractionModeKind::Move));
|
||||
|
||||
if let Some(data) = startup_data {
|
||||
if data.working_directory != PathBuf::default() {
|
||||
editor
|
||||
.message_sender
|
||||
.send(Message::Configure {
|
||||
working_directory: data.working_directory,
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if data.scene != PathBuf::default() {
|
||||
editor
|
||||
.message_sender
|
||||
.send(Message::LoadScene(data.scene))
|
||||
.unwrap();
|
||||
}
|
||||
} else {
|
||||
// Open configurator as usual.
|
||||
editor
|
||||
.engine
|
||||
.user_interface
|
||||
.send_message(WindowMessage::open_modal(
|
||||
editor.configurator.window,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
));
|
||||
}
|
||||
|
||||
editor
|
||||
}
|
||||
|
||||
|
||||
Generated
+4
-3
@@ -10,12 +10,11 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f1aceae8-7c33-40c3-a2da-82b82ccfcb24" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/../../editor/src/inspector/handlers/node/base.rs" beforeDir="false" afterPath="$PROJECT_DIR$/../../editor/src/inspector/handlers/node/base.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../../editor/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/../../editor/src/lib.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/editor/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/editor/src/main.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/game/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/game/src/lib.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/unnamed.rgs" beforeDir="false" afterPath="$PROJECT_DIR$/unnamed.rgs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../../fyrox-ui/src/inspector/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/../../fyrox-ui/src/inspector/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../../src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/../../src/lib.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../../src/script/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/../../src/script/mod.rs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -136,6 +135,8 @@
|
||||
<workItem from="1646729605140" duration="10000" />
|
||||
<workItem from="1646730677754" duration="1167000" />
|
||||
<workItem from="1646732845950" duration="1279000" />
|
||||
<workItem from="1646738292422" duration="3646000" />
|
||||
<workItem from="1646743503532" duration="309000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
use fyrox::event_loop::EventLoop;
|
||||
use fyroxed::Editor;
|
||||
use fyroxed::{Editor, StartupData};
|
||||
use game::GamePlugin;
|
||||
|
||||
fn main() {
|
||||
let event_loop = EventLoop::new();
|
||||
let mut editor = Editor::new(&event_loop);
|
||||
let mut editor = Editor::new(
|
||||
&event_loop,
|
||||
Some(StartupData {
|
||||
working_directory: Default::default(),
|
||||
scene: "unnamed.rgs".into(),
|
||||
}),
|
||||
);
|
||||
editor.add_game_plugin(GamePlugin::new());
|
||||
editor.run(event_loop)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use std::{cell::RefCell, rc::Rc, str::FromStr};
|
||||
pub struct GamePlugin {
|
||||
scene: Handle<Scene>,
|
||||
ui: Rc<RefCell<UserInterface>>,
|
||||
debug_draw: bool,
|
||||
}
|
||||
|
||||
impl Default for GamePlugin {
|
||||
@@ -46,6 +47,7 @@ impl GamePlugin {
|
||||
Self {
|
||||
scene: Default::default(),
|
||||
ui: Rc::new(RefCell::new(UserInterface::new(Vector2::new(100.0, 100.0)))),
|
||||
debug_draw: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,9 +151,11 @@ impl Plugin for GamePlugin {
|
||||
fn update(&mut self, context: &mut PluginContext) {
|
||||
let scene = &mut context.scenes[self.scene];
|
||||
|
||||
let drawing_context = &mut scene.drawing_context;
|
||||
drawing_context.clear_lines();
|
||||
scene.graph.physics.draw(drawing_context);
|
||||
if self.debug_draw {
|
||||
let drawing_context = &mut scene.drawing_context;
|
||||
drawing_context.clear_lines();
|
||||
scene.graph.physics.draw(drawing_context);
|
||||
}
|
||||
|
||||
let mut ui = self.ui.borrow_mut();
|
||||
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -105,7 +105,7 @@ pub trait ScriptTrait: BaseScript {
|
||||
/// }
|
||||
/// ```
|
||||
fn on_property_changed(&mut self, #[allow(unused_variables)] args: &PropertyChanged) -> bool {
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
/// Called on parent scene initialization. It is guaranteed to be called once, and before any
|
||||
|
||||
Reference in New Issue
Block a user