diff --git a/Cargo.lock b/Cargo.lock index 68406cca..7147e818 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" [[package]] name = "antlr-rust" @@ -672,7 +672,7 @@ dependencies = [ "bevy", "bevy-inspector-egui", "egui_dock", - "indexmap 2.1.0", + "indexmap 2.2.1", ] [[package]] @@ -686,7 +686,7 @@ dependencies = [ "bevy_editor_pls_core", "bevy_mod_debugdump", "egui-gizmo", - "indexmap 2.1.0", + "indexmap 2.2.1", "opener", "pretty-type-name", ] @@ -1414,7 +1414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "serde", ] @@ -1426,9 +1426,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" dependencies = [ "bytemuck_derive", ] @@ -2561,9 +2561,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -3436,7 +3436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.1", ] [[package]] @@ -3707,7 +3707,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -3722,9 +3722,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -3851,18 +3851,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -3871,9 +3871,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -3978,15 +3978,15 @@ checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" [[package]] name = "strum" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" dependencies = [ "heck", "proc-macro2", @@ -4182,7 +4182,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "toml_datetime", "winnow", ] @@ -4193,7 +4193,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "toml_datetime", "winnow", ] @@ -4982,9 +4982,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" dependencies = [ "memchr", ] diff --git a/crates/bevy_plugin/Cargo.toml b/crates/bevy_plugin/Cargo.toml index 672fea5f..5969f823 100644 --- a/crates/bevy_plugin/Cargo.toml +++ b/crates/bevy_plugin/Cargo.toml @@ -2,6 +2,11 @@ name = "bevy_yarnspinner" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" exclude = ["assets", "wasm"] @@ -14,7 +19,7 @@ anyhow = "1" csv = "1" seldom_fn_plugin = "0.5" serde = { version = "1", features = ["derive"] } -yarnspinner = { path = "../yarnspinner", features = ["bevy", "serde"] } +yarnspinner = { path = "../yarnspinner", features = ["bevy", "serde"], version = "0.1" } sha2 = "0.10" rand = { version = "0.8", features = ["small_rng"] } diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml index 195c644f..3018b863 100644 --- a/crates/codegen/Cargo.toml +++ b/crates/codegen/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner_codegen" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [features] diff --git a/crates/compiler/Cargo.toml b/crates/compiler/Cargo.toml index 91e6c8e6..bd1400a9 100644 --- a/crates/compiler/Cargo.toml +++ b/crates/compiler/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner_compiler" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [features] @@ -13,10 +18,10 @@ bevy = ["dep:bevy", "yarnspinner_core/bevy"] antlr-rust = "=0.3.0-beta" better_any = "=0.2.0" regex = "1" -yarnspinner_core = { path = "../core" } +yarnspinner_core = { path = "../core", version = "0.1" } thiserror = "1" -strum = "0.25" -strum_macros = "0.25" +strum = "0.26" +strum_macros = "0.26" annotate-snippets = "0.10" serde = { version = "1", features = ["derive"], optional = true } bevy = { version = "0.12", default-features = false, optional = true } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index bea588f9..775aac42 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner_core" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [features] @@ -12,9 +17,9 @@ bevy = ["dep:bevy"] [dependencies] bytes = "1" paste = "1" -yarnspinner_macros = { path = "../macros" } -strum = "0.25" -strum_macros = "0.25" +yarnspinner_macros = { path = "../macros", version = "0.1" } +strum = "0.26" +strum_macros = "0.26" thiserror = "1" prost = "0.12" serde = { version = "1", features = ["derive"], optional = true } diff --git a/crates/example_dialogue_view/Cargo.toml b/crates/example_dialogue_view/Cargo.toml index b3a80b0e..83e5fcb7 100644 --- a/crates/example_dialogue_view/Cargo.toml +++ b/crates/example_dialogue_view/Cargo.toml @@ -2,13 +2,18 @@ name = "bevy_yarnspinner_example_dialogue_view" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" exclude = ["assets", "wasm"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy_yarnspinner = { path = "../bevy_plugin" } +bevy_yarnspinner = { path = "../bevy_plugin", version = "0.1" } unicode-segmentation = "1" seldom_fn_plugin = "0.5" diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 4886ffab..7e2bd860 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner_macros" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [lib] diff --git a/crates/runtime/Cargo.toml b/crates/runtime/Cargo.toml index a7722e9c..84a54dc5 100644 --- a/crates/runtime/Cargo.toml +++ b/crates/runtime/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner_runtime" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [features] @@ -15,7 +20,7 @@ serde = [ bevy = ["dep:bevy", "yarnspinner_core/bevy"] [dependencies] -yarnspinner_core = { path = "../core" } +yarnspinner_core = { path = "../core", version = "0.1" } unicode-normalization = "0.1" unicode-segmentation = "1" log = "0.4" diff --git a/crates/yarnspinner/Cargo.toml b/crates/yarnspinner/Cargo.toml index 969d0c77..26bf3c45 100644 --- a/crates/yarnspinner/Cargo.toml +++ b/crates/yarnspinner/Cargo.toml @@ -2,6 +2,11 @@ name = "yarnspinner" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] license = "MIT OR Apache-2.0" [features] @@ -20,9 +25,9 @@ bevy = [ ] [dependencies] -yarnspinner_core = { path = "../core" } -yarnspinner_compiler = { path = "../compiler" } -yarnspinner_runtime = { path = "../runtime" } +yarnspinner_core = { path = "../core", version = "0.1" } +yarnspinner_compiler = { path = "../compiler", version = "0.1" } +yarnspinner_runtime = { path = "../runtime", version = "0.1" } log = { version = "0.4", features = ["std"] } [dev-dependencies] diff --git a/demo/Cargo.toml b/demo/Cargo.toml index 91183e90..c1844535 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -2,7 +2,11 @@ name = "bevy_yarnspinner_demo" version = "0.1.0" edition = "2021" -publish = false +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] [features] default = [] @@ -10,7 +14,7 @@ editor = ["dep:bevy_editor_pls"] [dependencies] bevy = "0.12" -bevy_yarnspinner = { path = "../crates/bevy_plugin" } -bevy_yarnspinner_example_dialogue_view = { path = "../crates/example_dialogue_view" } +bevy_yarnspinner = { path = "../crates/bevy_plugin", version = "0.1" } +bevy_yarnspinner_example_dialogue_view = { path = "../crates/example_dialogue_view", version = "0.1" } bevy_sprite3d = "2.7" bevy_editor_pls = { version = "0.7", optional = true } diff --git a/docs/src/bevy_plugin/setup.md b/docs/src/bevy_plugin/setup.md index d213a755..e90415ec 100644 --- a/docs/src/bevy_plugin/setup.md +++ b/docs/src/bevy_plugin/setup.md @@ -11,8 +11,8 @@ Run the following in your terminal to create a new crate with the required depen ```bash cargo new yarnspinner_playground cd yarnspinner_playground -cargo add bevy --features filesystem_watcher -cargo add bevy_yarnspinner bevy_yarnspinner_example_dialogue_view --git "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +cargo add bevy --features file_watcher +cargo add bevy_yarnspinner bevy_yarnspinner_example_dialogue_view ``` The line `cargo add bevy --features filesystem_watcher` ensures that we can use *hot reloading* in our project, which means that we can edit the Yarn files diff --git a/examples/bevy_yarnspinner/Cargo.toml b/examples/bevy_yarnspinner/Cargo.toml index f119d9cb..4935b8f5 100644 --- a/examples/bevy_yarnspinner/Cargo.toml +++ b/examples/bevy_yarnspinner/Cargo.toml @@ -2,9 +2,14 @@ name = "yarnspinner_examples" version = "0.1.0" edition = "2021" +repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust" +homepage = "https://docs.yarnspinner.dev/" +keywords = ["gamedev", "dialog", "yarn", "bevy"] +categories = ["game-development", "compilers"] +authors = ["Jan Hohenheim "] publish = false [dependencies] bevy = "0.12" -bevy_yarnspinner = { path = "../../crates/bevy_plugin" } -bevy_yarnspinner_example_dialogue_view = { path = "../../crates/example_dialogue_view" } +bevy_yarnspinner = { path = "../../crates/bevy_plugin", version = "0.1" } +bevy_yarnspinner_example_dialogue_view = { path = "../../crates/example_dialogue_view", version = "0.1" } diff --git a/readme.md b/readme.md index 06304738..4c75b7fe 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,103 @@ # Yarn Spinner for Rust - +[![Crates.io](https://img.shields.io/crates/v/bevy_yarnspinner.svg)](https://crates.io/crates/bevy_yarnspinner) +[![Docs](https://docs.rs/bevy_yarnspinner/badge.svg)](https://docs.rs/bevy_yarnspinner/latest/bevy/) +[![Discord](https://img.shields.io/discord/754171172693868585.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/yarnspinner) > **Note:** > Yarn Spinner for Rust is a work-in-progress project. We don't currently offer any official support for it. We encourage you to file [issues](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/issues/new) if you have them, and to join the official [Yarn Spinner Discord](https://discord.gg/yarnspinner) to discuss the project! The Rust port of Yarn Spinner, the friendly tool for writing game dialogue. Read more in [The Book™](https://yarnspinnertool.github.io/YarnSpinner-Rust/) or check out -the [live demo](https://janhohenheim.itch.io/yarnspinner-rust-demo)! +the [live demo](https://janhohenheim.itch.io/yarnspinner-rust-demo), which was written using the [Bevy engine](https://bevyengine.org/). +This project offers first class support for Bevy and assumes you are using it. If you are not, check out the [relevant section of the book](https://yarnspinnertool.github.io/YarnSpinner-Rust/working_without_bevy) [![Yarn Spinner for Rust Demo](https://img.itch.zone/aW1hZ2UvMjExMjc5NC8xMjQ0MjEwNy5wbmc=/original/LpAOnR.png)](https://janhohenheim.itch.io/yarn-slinger-demo) + +## Quickstart +Taken straight from our [examples](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/tree/main/examples/bevy_yarnspinner): + +First, let's add our dependencies: +```bash +cargo add bevy bevy_yarnspinner bevy_yarnspinner_example_dialogue_view +``` + +Now, the `main.rs`: +```rust +use bevy::prelude::*; +use bevy_yarnspinner::prelude::*; +use bevy_yarnspinner_example_dialogue_view::prelude::*; + +fn main() { + let mut app = App::new(); + app.add_plugins(( + DefaultPlugins, + // Register the Yarn Spinner plugin using its default settings, which will look for Yarn files in the "dialogue" folder. + // If this app should support Wasm or Android, we cannot load files without specifying them, so use the following instead. + // YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file("dialogue/hello_world.yarn")), + YarnSpinnerPlugin::new(), + // Initialize the bundled example UI + ExampleYarnSpinnerDialogueViewPlugin::new(), + )) + .add_systems(Startup, setup_camera) + .add_systems( + Update, + // Spawn the dialogue runner once the Yarn project has finished compiling + spawn_dialogue_runner.run_if(resource_added::()), + ) + .run(); +} + +fn setup_camera(mut commands: Commands) { + commands.spawn(Camera2dBundle::default()); +} + +fn spawn_dialogue_runner(mut commands: Commands, project: Res) { + // Create a dialogue runner from the project. + let mut dialogue_runner = project.create_dialogue_runner(); + // Immediately start showing the dialogue to the player + dialogue_runner.start_node("HelloWorld"); + commands.spawn(dialogue_runner); +} +``` + +And finally, the `assets/dialogue/hello_world.yarn`: +```text +title: HelloWorld +--- +Hello World! To continue the dialogue, click with your mouse, press the space bar or the enter key. +These are options. You can select one by clicking on it or pressing the corresponding number on your keyboard. +-> Some cool option +-> Some other cool option +Now we'll jump to another node! +<> + +=== + +title: AnotherNode +--- +Now, a character will talk. Notice how the upper left corner of the dialogue will show their name. +Hohenheim: Hi, I'm Jan Hohenheim, creator of Yarn Spinner for Rust. I hope you enjoy using it! +Let's set a condition. Do you prefer dogs or cats? +-> Dogs + <> +-> Cats + <> +-> Turtles + I, uuuh... okay, why not. + <> +Now let's print the result of the condition. Your preference is... +(Drum roll) +<> +Dogs! Arf Arf! +<> +Cats! (Can't say I agree, but you do you) +<> +Turtles! Solid choice. +<> +Et voilà! That was all. Thanks for checking out Yarn Spinner for Rust! Continuing from the last node will exit the dialogue. +=== +``` + +## Version Table + +| Bevy | Yarn Spinner for Rust | +|------|-----------------------| +| 0.12 | 0.1 |