Skip to content

Commit 7b70e08

Browse files
authored
Release v0.2.0 (#13)
* Bump version to 0.2.0 * Add a changelog
1 parent 5b37e87 commit 7b70e08

File tree

4 files changed

+91
-3
lines changed

4 files changed

+91
-3
lines changed

CHANGELOG.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Changelog
2+
3+
## v0.2.0
4+
5+
This release simplifies font handling, adds named colors and adds support for efficiently changing text dynamically.
6+
7+
### Simplified Font Handling
8+
9+
In the past, you needed to pass around multiple `Handle<Font>`s for each variant of a font (e.g. bold, italic, bold and italic, etc.).
10+
11+
Instead, we now use a `FontRegistry` which automatically tracks which `Font`s are loaded and allows to query them by font weight, style and other factors.
12+
You can now simply specify an asset path where your fonts are stored and they will all be loaded and used inside of BBCode!
13+
14+
```rs
15+
// Load the fonts inside of assets/fonts
16+
BbcodePlugin::new().with_fonts("fonts")
17+
```
18+
19+
Then inside of `BbcodeSettings`, you just specify the font family, size and color of the text to use by default:
20+
21+
```rs
22+
BbcodeSettings::new("Fira Sans", 40., Color::WHITE)
23+
```
24+
25+
Additionally, the new `font` tag allows you to change the font family for parts of the text:
26+
27+
```txt
28+
[font="JetBrains Mono"]new font family[/font]
29+
```
30+
31+
### Named Colors
32+
33+
The `color`/`c` tag now also supports named colors, e.g. `[c=primary]text[/c]`.
34+
The color values are specified in the new `ColorMap` resource.
35+
36+
Changing a value in the color map resource will dynamically update all occurrences of this color in your app!
37+
38+
### Dynamic Text Editing
39+
40+
Until this point, you could dynamically change the text in your app by changing `Bbcode.content`.
41+
However, this adds a performance overhead as the entire markup needs to be parsed again and the UI hierarchy reconstructed.
42+
43+
Instead, you can now register marker components:
44+
45+
```rs
46+
#[derive(Component, Clone)]
47+
struct TimeMarker;
48+
49+
BbcodeSettings::new("Fira Sans", 40., Color::WHITE)
50+
// Register the marker component
51+
.with_marker("time", TimeMarker)
52+
```
53+
54+
And then use it with the new `m` tag:
55+
56+
```txt
57+
Time passed: [m=time]0.0[/m]
58+
```
59+
60+
Finally, you can use queries to efficiently update the text:
61+
62+
```rs
63+
fn update_text(time: Res<Time>, mut query: Query<&mut Text, With<TimeMarker>>) {
64+
for mut text in query.iter_mut() {
65+
text.sections[0].value = format!("{:.0}", time.elapsed_seconds());
66+
}
67+
```
68+
69+
## Migration Guide
70+
71+
The `BbcodePlugin` now has a constructor and allows you to load an entire folder of fonts:
72+
73+
```rs
74+
// Load the fonts inside of assets/fonts
75+
BbcodePlugin::new().with_fonts("fonts")
76+
```
77+
78+
In the `BbcodeSettings` you now specify the font family, size and color of the default text:
79+
80+
```rs
81+
BbcodeSettings::new("Fira Sans", 40., Color::WHITE)
82+
```
83+
84+
## v0.1.0
85+
86+
The initial release!
87+
88+
Supports basic BBCode formatting with bold, italic and colored text.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_bbcode"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
description = "Use BBCode-formatted text inside of Bevy."
66
readme = "README.md"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Rich text support in Bevy using a custom [BBCode](https://en.wikipedia.org/wiki/
66

77
| `bevy` version | `bevy_mod_bbcode` version |
88
| -------------- | ------------------------- |
9-
| `0.14` | `0.1` |
9+
| `0.14` | `0.1` - `0.2` |
1010

1111
## Installation
1212

0 commit comments

Comments
 (0)