Skip to content

Commit

Permalink
split fyrox-template into lib + cli
Browse files Browse the repository at this point in the history
- lib can be used in the project manager
  • Loading branch information
mrDIMAS committed Jun 3, 2024
1 parent 3a1fe2b commit b53a83f
Show file tree
Hide file tree
Showing 19 changed files with 938 additions and 841 deletions.
1 change: 1 addition & 0 deletions .idea/rg3d-core.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"fyrox-animation",
"editor",
"editor-standalone",
"template-core",
"template",
"fyrox-graph",
"fyrox-math",
Expand Down
1 change: 1 addition & 0 deletions project-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 4 additions & 3 deletions project-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,10 @@ impl ProjectManager {
))
}

fn on_button_click(&mut self, button: Handle<UiNode>) {
fn on_button_click(&mut self, button: Handle<UiNode>, 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 {
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions template-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "fyrox-template-core"
version = "0.11.0"
edition = "2021"
authors = ["Dmitry Stepanov <[email protected]>"]
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"
21 changes: 21 additions & 0 deletions template-core/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
50 changes: 50 additions & 0 deletions template-core/README.md
Original file line number Diff line number Diff line change
@@ -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 <name> --style <style>]`

- `name` - a name of new project (default is `my_game`)
- `style` - defines a default scene type, either `2d` or `3d` (default is `3d`)

It creates a workspace with three projects:

- Game - your game project (library)
- Editor - the editor with your game attached as a plugin
- Executor - the "runner" for your game.

It also populates each project with boilerplate code. The main purpose of the project is to reduce amount of time
that is needed to set up a new project.

It will create a new folder with `<project_name>` and it will contain three projects, runnable only two of them:

- `cargo run --package editor --release` - to run your game inside the editor.
- `cargo run --package executor --release` - to run your game as a standalone project. It will also produce final
binary of your game, that can be shipped to a store.

### Tips

There is nothing special in generated project, so you can tweak them as you wish.

## Adding New Scripts

`fyrox-template script [--name <name>]`

- `name` - a name of your script (default is `MyScript`)

The tool is also capable to generate script skeleton for you, filling it with all required boilerplate. Generated scripts
will be added to `game/src` folder, so you should run the tool from the root folder of your game (where the root Cargo.toml
is located).

Do not forget to add the script to your module tree at required position, you probably will need some small tweaks
to generated content, it can be easily automated by modern IDEs.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b53a83f

Please sign in to comment.