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]]
name = "fyrox"
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 = [
"base64",
"bitflags 2.4.2",
@ -1003,9 +1078,12 @@ dependencies = [
"glutin",
"glutin-winit",
"half",
"hashbrown",
"image",
"inflate",
"lazy_static",
"libloading",
"lightmap",
"rapier2d",
"rapier3d",
"raw-window-handle 0.5.2",
@ -1021,76 +1099,34 @@ dependencies = [
]
[[package]]
name = "fyrox-animation"
name = "fyrox-math"
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 = [
"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",
"base64",
"bincode",
"bitflags 2.4.2",
"byteorder",
"futures",
"fxhash",
"fyrox-core-derive",
"instant",
"js-sys",
"lazy_static",
"memoffset",
"nalgebra",
"notify",
"num-traits",
"once_cell",
"parking_lot",
"rand",
"rectutils",
"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#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
dependencies = [
"convert_case",
"darling",
"fxhash",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "fyrox-graph"
name = "fyrox-math"
version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fxhash",
"fyrox-core",
"fyrox-resource",
"arrayvec",
"nalgebra",
"num-traits",
"rectutils",
"uuid",
]
[[package]]
name = "fyrox-resource"
version = "0.11.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fxhash",
"fyrox-core",
@ -1103,7 +1139,7 @@ dependencies = [
[[package]]
name = "fyrox-sound"
version = "0.34.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"fyrox-core",
"fyrox-resource",
@ -1120,7 +1156,7 @@ dependencies = [
[[package]]
name = "fyrox-ui"
version = "0.24.0"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"copypasta",
"fontdue",
@ -1140,7 +1176,7 @@ dependencies = [
[[package]]
name = "fyroxed_base"
version = "0.20.1"
source = "git+https://github.com/FyroxEngine/Fyrox#5398c6e8dd9385af9bbdd6c642f161dda9d13bfe"
source = "git+https://github.com/FyroxEngine/Fyrox?rev=5762ef5e75fd77639792d18cfbd3e34ff8c0ce46#5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
dependencies = [
"cargo_metadata",
"fyrox",
@ -1583,6 +1619,20 @@ dependencies = [
"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]]
name = "linux-raw-sys"
version = "0.4.13"

View File

@ -5,9 +5,11 @@ resolver = "2"
[workspace.dependencies.fyrox]
git = "https://github.com/FyroxEngine/Fyrox"
rev = "5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
[workspace.dependencies.fyroxed_base]
git = "https://github.com/FyroxEngine/Fyrox"
rev = "5762ef5e75fd77639792d18cfbd3e34ff8c0ce46"
# 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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff