From b53a83fc008b0b857226ac7114d9bc623ead40eb Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Mon, 3 Jun 2024 17:50:28 +0300 Subject: [PATCH] split fyrox-template into lib + cli - lib can be used in the project manager --- .idea/rg3d-core.iml | 1 + Cargo.toml | 1 + project-manager/Cargo.toml | 1 + project-manager/src/main.rs | 7 +- template-core/Cargo.toml | 21 + template-core/LICENSE | 21 + template-core/README.md | 50 ++ {template => template-core}/src/2d.rgs | Bin {template => template-core}/src/3d.rgs | Bin .../src/android/README.md | 0 .../src/android/release.keystore | Bin template-core/src/lib.rs | 828 +++++++++++++++++ {template => template-core}/src/regex | 0 .../src/wasm/README.md | 0 .../src/wasm/index.html | 0 {template => template-core}/src/wasm/main.js | 0 .../src/wasm/styles.css | 0 template/Cargo.toml | 10 +- template/src/main.rs | 839 +----------------- 19 files changed, 938 insertions(+), 841 deletions(-) create mode 100644 template-core/Cargo.toml create mode 100644 template-core/LICENSE create mode 100644 template-core/README.md rename {template => template-core}/src/2d.rgs (100%) rename {template => template-core}/src/3d.rgs (100%) rename {template => template-core}/src/android/README.md (100%) rename {template => template-core}/src/android/release.keystore (100%) create mode 100644 template-core/src/lib.rs rename {template => template-core}/src/regex (100%) rename {template => template-core}/src/wasm/README.md (100%) rename {template => template-core}/src/wasm/index.html (100%) rename {template => template-core}/src/wasm/main.js (100%) rename {template => template-core}/src/wasm/styles.css (100%) diff --git a/.idea/rg3d-core.iml b/.idea/rg3d-core.iml index 721f98d15..c9fcd2b64 100644 --- a/.idea/rg3d-core.iml +++ b/.idea/rg3d-core.iml @@ -41,6 +41,7 @@ + diff --git a/Cargo.toml b/Cargo.toml index 2788b667b..373989dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "fyrox-animation", "editor", "editor-standalone", + "template-core", "template", "fyrox-graph", "fyrox-math", diff --git a/project-manager/Cargo.toml b/project-manager/Cargo.toml index 155e29b1d..c66dbb8c4 100644 --- a/project-manager/Cargo.toml +++ b/project-manager/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] fyrox = { path = "../fyrox" } +fyrox-template-core = { version = "0.11.0", path = "../template-core" } serde = { version = "1", features = ["derive"] } ron = "0.8.1" open = "5.0.1" \ No newline at end of file diff --git a/project-manager/src/main.rs b/project-manager/src/main.rs index 335074a0f..80bff473b 100644 --- a/project-manager/src/main.rs +++ b/project-manager/src/main.rs @@ -427,9 +427,10 @@ impl ProjectManager { )) } - fn on_button_click(&mut self, button: Handle) { + fn on_button_click(&mut self, button: Handle, ui: &mut UserInterface) { if button == self.create { - // TODO: Create project. + fyrox_template_core::init_project("test", "3d", "git", true).unwrap(); + self.refresh(ui); } else if button == self.import { // TODO: Import project. } else if button == self.download { @@ -450,7 +451,7 @@ impl ProjectManager { fn handle_ui_message(&mut self, message: &UiMessage, ui: &mut UserInterface) { if let Some(ButtonMessage::Click) = message.data() { - self.on_button_click(message.destination); + self.on_button_click(message.destination, ui); } else if let Some(ListViewMessage::SelectionChanged(selection)) = message.data() { if message.destination() == self.projects && message.direction() == MessageDirection::FromWidget diff --git a/template-core/Cargo.toml b/template-core/Cargo.toml new file mode 100644 index 000000000..8d46a6d8e --- /dev/null +++ b/template-core/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "fyrox-template-core" +version = "0.11.0" +edition = "2021" +authors = ["Dmitry Stepanov "] +license = "MIT" +description = "Project template generator for Fyrox engine" +keywords = ["fyrox", "game", "project"] +categories = ["game-development"] +include = ["/src/**/*", "/Cargo.toml", "/LICENSE", "/README.md"] +homepage = "https://fyrox.rs" +repository = "https://github.com/FyroxEngine/Fyrox" +readme = "README.md" +rust-version = "1.72" + +[dependencies] +uuid = { version = "1", features = ["v4"] } +convert_case = "0.6.0" +toml = "0.8.10" +toml_edit = "0.22.6" +regex = "1.7.3" \ No newline at end of file diff --git a/template-core/LICENSE b/template-core/LICENSE new file mode 100644 index 000000000..9bcce00dc --- /dev/null +++ b/template-core/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Dmitry Stepanov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/template-core/README.md b/template-core/README.md new file mode 100644 index 000000000..d47c4239c --- /dev/null +++ b/template-core/README.md @@ -0,0 +1,50 @@ +# Fyrox Engine Template Generator + +This tiny utility handles project and script generation for Fyrox Game Engine. + +## Installation + +Install it via `cargo install`: + +```shell +cargo install fyrox-template +``` + +## Generating New Project + +`fyrox-template init [--name --style