Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timjentzsch/bevy_mod_bbcode
Use BBCode-formatted text in Bevy.
https://github.com/timjentzsch/bevy_mod_bbcode
bbcode bevy bevy-plugin
Last synced: 3 months ago
JSON representation
Use BBCode-formatted text in Bevy.
- Host: GitHub
- URL: https://github.com/timjentzsch/bevy_mod_bbcode
- Owner: TimJentzsch
- License: apache-2.0
- Created: 2024-07-21T17:22:22.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-28T10:51:30.000Z (6 months ago)
- Last Synced: 2024-10-09T20:03:44.468Z (3 months ago)
- Topics: bbcode, bevy, bevy-plugin
- Language: Rust
- Homepage:
- Size: 4.81 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_mod_bbcode
Rich text support in Bevy using a custom [BBCode](https://en.wikipedia.org/wiki/BBCode) markup flavor.
## Bevy Compatibility
| `bevy` version | `bevy_mod_bbcode` version |
| -------------- | ------------------------- |
| `0.14` | `0.1` - `0.2` |## Installation
```cli
cargo add bevy_mod_bbcode
```## Usage
Instead of spawning a `TextBundle`, spawn a `BbcodeBundle`!
```rs
use bevy::prelude::*;
use bevy_mod_bbcode::{BbcodeBundle, BbcodePlugin, BbcodeSettings};fn main() {
App::new()
// Register the font files stored in `assets/fonts`
.add_plugins((DefaultPlugins, BbcodePlugin::new().with_fonts("fonts")))
.add_systems(Startup, setup)
.run();
}fn setup(mut commands: Commands, asset_server: Res) {
commands.spawn(Camera2dBundle::default());commands.spawn(BbcodeBundle::from_content(
"test [b]bold[/b] with [i]italic[/i] and [c=#ff00ff]color[/c]",
// Use the "Fira Sans" font family with a default font size of 40
BbcodeSettings::new("Fira Sans", 40., Color::WHITE),
));
}
```See `examples` for more usage patterns!
### Supported Tags
- `b`: \[b]**bold**\[/b] text
- `i`: \[i]_italic_\[/i] text
- `c`: \[c=\#ff0000]colored\[/c] text
- Register named colors via `ResMut` and use the names instead of hex values
- `m`: \[m=foo]text with marker component\[/m]
- Register marker components via `BbcodeSettings::with_marker` and use them to update text dynamically
- `font`: \[font="Fira Sans"]change the font family\[/font]## License
This project is licensed under the terms of the [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE) license at your choice.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Note that the assets used in the examples might use different licenses, see [`assets/CREDITS.md`](assets/CREDITS.md).