new version of editor

This commit is contained in:
artem 2024-03-19 22:21:28 +03:00
parent fea363554e
commit 5a8ead0046
6 changed files with 764 additions and 680 deletions

164
Cargo.lock generated
View File

@ -984,7 +984,82 @@ dependencies = [
[[package]] [[package]]
name = "fyrox" name = "fyrox"
version = "0.33.1" version = "0.33.1"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fyrox-impl",
]
[[package]]
name = "fyrox-animation"
version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fxhash",
"fyrox-core",
"spade",
"strum",
"strum_macros",
]
[[package]]
name = "fyrox-core"
version = "0.27.0"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"android-activity",
"arrayvec",
"base64",
"bincode",
"bitflags 2.4.2",
"byteorder",
"futures",
"fxhash",
"fyrox-core-derive",
"fyrox-math 0.1.0 (git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46)",
"instant",
"js-sys",
"lazy_static",
"memoffset",
"nalgebra",
"notify",
"num-traits",
"once_cell",
"parking_lot",
"rand",
"serde",
"uuid",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "fyrox-core-derive"
version = "0.22.0"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"convert_case",
"darling",
"fxhash",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "fyrox-graph"
version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fxhash",
"fyrox-core",
"fyrox-resource",
]
[[package]]
name = "fyrox-impl"
version = "0.33.1"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"base64", "base64",
"bitflags 2.4.2", "bitflags 2.4.2",
@ -1003,9 +1078,12 @@ dependencies = [
"glutin", "glutin",
"glutin-winit", "glutin-winit",
"half", "half",
"hashbrown",
"image", "image",
"inflate", "inflate",
"lazy_static", "lazy_static",
"libloading",
"lightmap",
"rapier2d", "rapier2d",
"rapier3d", "rapier3d",
"raw-window-handle 0.5.2", "raw-window-handle 0.5.2",
@ -1021,76 +1099,34 @@ dependencies = [
] ]
[[package]] [[package]]
name = "fyrox-animation" name = "fyrox-math"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4811e6142fd4c525f171e0851503afc57de4d81a02201e33b630de536bc1bf26"
dependencies = [ dependencies = [
"fxhash",
"fyrox-core",
"spade",
"strum",
"strum_macros",
]
[[package]]
name = "fyrox-core"
version = "0.27.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
dependencies = [
"android-activity",
"arrayvec", "arrayvec",
"base64",
"bincode",
"bitflags 2.4.2",
"byteorder",
"futures",
"fxhash",
"fyrox-core-derive",
"instant",
"js-sys",
"lazy_static",
"memoffset",
"nalgebra", "nalgebra",
"notify",
"num-traits", "num-traits",
"once_cell",
"parking_lot",
"rand",
"rectutils", "rectutils",
"serde",
"uuid", "uuid",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
] ]
[[package]] [[package]]
name = "fyrox-core-derive" name = "fyrox-math"
version = "0.22.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
dependencies = [
"convert_case",
"darling",
"fxhash",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "fyrox-graph"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"fxhash", "arrayvec",
"fyrox-core", "nalgebra",
"fyrox-resource", "num-traits",
"rectutils",
"uuid",
] ]
[[package]] [[package]]
name = "fyrox-resource" name = "fyrox-resource"
version = "0.11.0" version = "0.11.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"fxhash", "fxhash",
"fyrox-core", "fyrox-core",
@ -1103,7 +1139,7 @@ dependencies = [
[[package]] [[package]]
name = "fyrox-sound" name = "fyrox-sound"
version = "0.34.0" version = "0.34.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"fyrox-core", "fyrox-core",
"fyrox-resource", "fyrox-resource",
@ -1120,7 +1156,7 @@ dependencies = [
[[package]] [[package]]
name = "fyrox-ui" name = "fyrox-ui"
version = "0.24.0" version = "0.24.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"copypasta", "copypasta",
"fontdue", "fontdue",
@ -1140,7 +1176,7 @@ dependencies = [
[[package]] [[package]]
name = "fyroxed_base" name = "fyroxed_base"
version = "0.20.1" version = "0.20.1"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe" source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [ dependencies = [
"cargo_metadata", "cargo_metadata",
"fyrox", "fyrox",
@ -1583,6 +1619,20 @@ dependencies = [
"redox_syscall 0.4.1", "redox_syscall 0.4.1",
] ]
[[package]]
name = "lightmap"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cbfbe5e3b568920f20dbfa053810bc6d1be08aa96d077c2509da1c9be2217ee"
dependencies = [
"arrayvec",
"fxhash",
"fyrox-math 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nalgebra",
"rayon",
"uvgen",
]
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.13" version = "0.4.13"

View File

@ -5,9 +5,11 @@ resolver = "2"
[workspace.dependencies.fyrox] [workspace.dependencies.fyrox]
git = "https://github.com/FyroxEngine/Fyrox" git = "https://github.com/FyroxEngine/Fyrox"
rev = "5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
[workspace.dependencies.fyroxed_base] [workspace.dependencies.fyroxed_base]
git = "https://github.com/FyroxEngine/Fyrox" git = "https://github.com/FyroxEngine/Fyrox"
rev = "5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
# Optimize the engine in debug builds, but leave project's code non-optimized. # Optimize the engine in debug builds, but leave project's code non-optimized.
# By using this technique, you can still debug you code, but engine will be fully # By using this technique, you can still debug you code, but engine will be fully

View File

@ -1,7 +1,7 @@
//! Editor with your game connected to it as a plugin. //! Editor with your game connected to it as a plugin.
use fyrox::event_loop::EventLoop; use fyrox::event_loop::EventLoop;
use fyroxed_base::{Editor, StartupData}; use fyroxed_base::{Editor, StartupData};
use platformer::GameConstructor; use platformer::Game;
fn main() { fn main() {
let event_loop = EventLoop::new().unwrap(); let event_loop = EventLoop::new().unwrap();
@ -11,6 +11,6 @@ fn main() {
scenes: vec!["data/scene.rgs".into()], scenes: vec!["data/scene.rgs".into()],
}), }),
); );
editor.add_game_plugin(GameConstructor); editor.add_game_plugin::<Game>(Game::default());
editor.run(event_loop) editor.run(event_loop)
} }

View File

@ -1,9 +1,9 @@
//! Executor with your game connected to it as a plugin. //! Executor with your game connected to it as a plugin.
use fyrox::engine::executor::Executor; use fyrox::engine::executor::Executor;
use platformer::GameConstructor; use platformer::Game;
fn main() { fn main() {
let mut executor = Executor::new(); let mut executor = Executor::new();
executor.add_plugin_constructor(GameConstructor); executor.add_plugin::<Game>(Game::default());
executor.run() executor.run()
} }

View File

@ -3,7 +3,11 @@ use fyrox::core::color::Color;
use fyrox::graph::SceneGraph; use fyrox::graph::SceneGraph;
use fyrox::{ use fyrox::{
asset::manager::ResourceManager, asset::manager::ResourceManager,
core::{log::Log, pool::Handle}, core::{
log::Log,
pool::Handle,
visitor::{Visit, VisitResult, Visitor},
},
engine::GraphicsContext, engine::GraphicsContext,
event::{Event, WindowEvent}, event::{Event, WindowEvent},
gui::{ gui::{
@ -17,11 +21,8 @@ use fyrox::{
UiNode, UserInterface, UiNode, UserInterface,
}, },
keyboard::{KeyCode, PhysicalKey}, keyboard::{KeyCode, PhysicalKey},
plugin::{Plugin, PluginConstructor, PluginContext, PluginRegistrationContext}, plugin::{Plugin, PluginContext},
scene::{ scene::{graph::Graph, Scene},
graph::Graph,
Scene,
},
}; };
use std::path::Path; use std::path::Path;
mod enemies; mod enemies;
@ -40,20 +41,21 @@ use sound::Sound;
const START_LEVEL: u32 = 1; const START_LEVEL: u32 = 1;
pub struct GameConstructor; pub struct GameConstructor;
impl PluginConstructor for GameConstructor { // impl PluginConstructor for GameConstructor {
fn register(&self, context: PluginRegistrationContext) { // fn register(&self, context: PluginRegistrationContext) {
// Register your scripts here. // // Register your scripts here.
let script_constructors = &context.serialization_context.script_constructors; // let script_constructors = &context.serialization_context.script_constructors;
script_constructors.add::<Swordman>("Enemy"); // script_constructors.add::<Swordman>("Enemy");
script_constructors.add::<Player>("Player"); // script_constructors.add::<Player>("Player");
script_constructors.add::<Sound>("Sound"); // script_constructors.add::<Sound>("Sound");
} // }
fn create_instance(&self, scene_path: Option<&str>, context: PluginContext) -> Box<dyn Plugin> { // fn create_instance(&self, scene_path: Option<&str>, context: PluginContext) -> Box<dyn Plugin> {
Box::new(Game::new(scene_path, context)) // Box::new(Game::new(scene_path, context))
} // }
} // }
#[derive(Visit, Default)]
pub struct Game { pub struct Game {
scene: Handle<Scene>, scene: Handle<Scene>,
@ -66,7 +68,15 @@ pub struct Game {
} }
impl Game { impl Game {
pub fn new(_scene_path: Option<&str>, ctx: PluginContext) -> Self {
pub fn default() -> Self {
return Game {
level: 1,
..Default::default()
};
}
pub fn init_game(&self, ctx: PluginContext) -> Self {
ctx.task_pool.spawn_plugin_task( ctx.task_pool.spawn_plugin_task(
UserInterface::load_from_file("data/menu.ui", ctx.resource_manager.clone()), UserInterface::load_from_file("data/menu.ui", ctx.resource_manager.clone()),
|result, game: &mut Game, ctx| match result { |result, game: &mut Game, ctx| match result {
@ -105,6 +115,18 @@ impl Game {
} }
impl Plugin for Game { impl Plugin for Game {
fn register(&self, #[allow(unused_variables)] context: fyrox::plugin::PluginRegistrationContext) {
let script_constructors = &context.serialization_context.script_constructors;
script_constructors.add::<Swordman>("Enemy");
script_constructors.add::<Player>("Player");
script_constructors.add::<Sound>("Sound");
}
fn init(&mut self, _scene_path: Option<&str>, context: PluginContext) {
self.init_game(context);
}
fn on_deinit(&mut self, _context: PluginContext) { fn on_deinit(&mut self, _context: PluginContext) {
// Do a cleanup here. // Do a cleanup here.
} }
@ -151,20 +173,24 @@ impl Plugin for Game {
if let GraphicsContext::Initialized(ref graphics_context) = context.graphics_context { if let GraphicsContext::Initialized(ref graphics_context) = context.graphics_context {
let window_size = graphics_context.window.inner_size(); let window_size = graphics_context.window.inner_size();
for script_scene in &context.script_processor.scripted_scenes { for script_scene in &context.script_processor.scripted_scenes {
script_scene.message_sender.send_global(ScreenSizeMessage::Resize { script_scene
width: window_size.width, .message_sender
height: window_size.height, .send_global(ScreenSizeMessage::Resize {
}); width: window_size.width,
height: window_size.height,
});
} }
} }
} }
if let Event::WindowEvent { event, .. } = event { if let Event::WindowEvent { event, .. } = event {
if let WindowEvent::Resized(size) = event { if let WindowEvent::Resized(size) = event {
for script_scene in &context.script_processor.scripted_scenes { for script_scene in &context.script_processor.scripted_scenes {
script_scene.message_sender.send_global(ScreenSizeMessage::Resize { script_scene
width: size.width, .message_sender
height: size.height, .send_global(ScreenSizeMessage::Resize {
}); width: size.width,
height: size.height,
});
} }
} }
} }

File diff suppressed because it is too large Load Diff