Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a basic TUI example for using yarnspinner standalone (fixes #123) #182

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

17cupsofcoffee
Copy link
Contributor

ConEmu64_2024-02-24_15-45-44.mp4

As discussed on #123, this is a simple (-ish, I may have gotten slightly carrried away!) example of how to use the yarnspinner crate directly, using a TUI interface (built with ratatui).

I used the existing Bevy examples as a starting point, as I thought it would be useful for people to be able to see how the same functionality can be achieved without a pre-built engine integration

This is my first time really working with Yarn Spinner, so I'm not 100% on whether I'm using the API optimally, but it does all seem to work! Any feedback would be much appreciated 😃

@janhohenheim
Copy link
Member

Woooah this looks so cool! Really good job!
I'll check the code over the next days :)

examples/yarnspinner_without_bevy/Cargo.toml Outdated Show resolved Hide resolved
crates/core/src/lib.rs Outdated Show resolved Hide resolved
@janhohenheim
Copy link
Member

Still need to review lib.rs, but here are some low hanging fruits first :)
Also, per the CI failure, we should probably use doc = false in the Cargo.tomls of the examples:

error: document output filename collision
The bin `access_variables` in package `yarnspinner_without_bevy_examples v0.1.0 (/home/runner/work/YarnSpinner-Rust/YarnSpinner-Rust/examples/yarnspinner_without_bevy)` has the same name as the bin `access_variables` in package `yarnspinner_examples v0.1.0 (/home/runner/work/YarnSpinner-Rust/YarnSpinner-Rust/examples/bevy_yarnspinner)`.
Only one may be documented at once since they output to the same path.
Consider documenting only one, renaming one, or marking one with `doc = false` in Cargo.toml.

@17cupsofcoffee
Copy link
Contributor Author

Resolved the comments and made the suggested change to the Cargo.tomls (though annoyingly, there's no way to say "set doc = false for all binaries", as far as I know).

@janhohenheim
Copy link
Member

Checked the rest and it looks good to me! It's a bit more than an example and more of a full-blown demo, but that's okay for the moment :) I can manually move it if I decide to add some minimal examples.
Thank you very much for your work! ❤️

@janhohenheim janhohenheim merged commit 980f564 into YarnSpinnerTool:main Feb 29, 2024
4 checks passed
@17cupsofcoffee 17cupsofcoffee deleted the tui-example branch February 29, 2024 16:44
@stargazing-dino
Copy link
Contributor

I'm having trouble running this

I tried:

❯ cargo run --bin custom_command     
error: `cargo run` can run at most one executable, but multiple were specified

I think it's because both bevy_yarnspinner and yarnspinner_without_bevy both have the same named binaries?

I then tried renaming the filename and [[bin.name]] field and I got this:

❯ cargo run --bin access_variables_without_bevy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.25s
     Running `target/debug/access_variables_without_bevy`
thread 'main' panicked at /Users/katzen/Documents/YarnSpinner-Rust/crates/compiler/src/compiler.rs:79:39:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I think because it's trying to get the file from relative to the root dir and no the cargo manifest dir:

let mut runner =
    TuiDialogueRunner::new("./assets/dialogue/access_variables.yarn", "AccessVariables")?;

oohhhhhh

yah, so I guess you just gotta be in that example's directory. Yup, got it working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants