Skip to content

Commit 7995715

Browse files
authored
Merge pull request #46 from CleanCut/more-improvements
More improvements
2 parents b9c61cc + 2c52fd3 commit 7995715

File tree

11 files changed

+31
-28
lines changed

11 files changed

+31
-28
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<!-- next-header -->
22
## [Unreleased] - ReleaseDate
33

4+
### Improved
5+
6+
- Dropped the lazy_static, log, and env_logger dependencies.
7+
8+
### BREAKING CHANGES
9+
10+
Yes, I know I shouldn't be releasing breaking changes in a patch release...but no one should be using any 5.x versions until I start teaching classes with it publicly...so I'm going to break it until I start teaching with 5.x.
11+
12+
- Updated font loading to be rooted in `assets/` instead of `assets/font/`
13+
414
## [5.0.4] - 2022-05-09
515

616
### Improved
@@ -10,8 +20,6 @@
1020

1121
### BREAKING CHANGES
1222

13-
Yes, I know I shouldn't be releasing breaking changes in a patch release...but no one should be using any 5.x versions until I start teaching classes with it publicly...so I'm going to break it until I start teaching with 5.x.
14-
1523
- Renamed the music file extensions to `.ogg` since [bevy doesn't support that file extension yet](https://github.com/bevyengine/bevy/pull/4703) -- this means the asset pack is now different.
1624

1725
## [5.0.3] - 2022-04-29

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ bevy = { version = "0.7.0", default-features = false, features = [
3434
"vorbis",
3535
] }
3636
bevy_prototype_lyon = "0.5"
37-
lazy_static = "1.4"
38-
log = "0.4"
3937
ron = "0.7"
4038
serde = { version = "1.0", features = [ "derive" ] }
4139

4240
[dev-dependencies]
43-
env_logger = "0.9"
4441
rand = "0.8"
4542

4643
[[example]]

examples/music.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
"engine.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);",
2121
);
2222
msg2.translation.y = -50.0;
23-
msg2.font = "FiraMono-Medium.ttf".to_string();
23+
msg2.font = "font/FiraMono-Medium.ttf".to_string();
2424

2525
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
2626

examples/sfx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
"engine.audio_manager.play_sfx(SfxPreset::Jingle1, 1.0);",
2121
);
2222
msg2.translation.y = -50.0;
23-
msg2.font = "FiraMono-Medium.ttf".to_string();
23+
msg2.font = "font/FiraMono-Medium.ttf".to_string();
2424

2525
game.audio_manager.play_sfx(SfxPreset::Jingle1, 1.0);
2626

examples/sound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
"engine.audio_manager.play_sfx(\"sfx/congratulations.ogg\", 1.0);",
2121
);
2222
msg2.translation.y = -100.0;
23-
msg2.font = "FiraMono-Medium.ttf".to_string();
23+
msg2.font = "font/FiraMono-Medium.ttf".to_string();
2424

2525
game.audio_manager.play_sfx("sfx/congratulations.ogg", 1.0);
2626

examples/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let mut game = Game::new();
1313
let fps = game.add_text("fps", "FPS: ");
1414
fps.translation = Vec2::new(0.0, 250.0);
15-
fps.font = "FiraMono-Medium.ttf".to_string();
15+
fps.font = "font/FiraMono-Medium.ttf".to_string();
1616
fps.font_size = 60.0;
1717

1818
let zoom_msg = game.add_text(
@@ -24,10 +24,10 @@ fn main() {
2424

2525
let font_msg = game.add_text(
2626
"font_msg",
27-
"You can choose a font at creation time by providing the filename of a font stored in assets/font.\n\"FiraSans-Bold.ttf\" is the default. \"FiraMono-Medium.ttf\" is also included in the asset pack."
27+
"You can choose a font at creation time by providing the filename of a font stored in assets/.\n\"font/FiraSans-Bold.ttf\" is the default. \"font/FiraMono-Medium.ttf\" is also included in the asset pack."
2828
);
2929
font_msg.font_size = 20.0;
30-
font_msg.font = "FiraMono-Medium.ttf".to_string();
30+
font_msg.font = "font/FiraMono-Medium.ttf".to_string();
3131
font_msg.translation.y = 0.0;
3232

3333
let msg = game.add_text("msg", "Changing the text's translation, rotation, and scale is fast,\n so feel free to do that a lot.");

src/game.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn add_texts(commands: &mut Commands, asset_server: &Res<AssetServer>, engin
203203
let transform = text.bevy_transform();
204204
let font_size = text.font_size;
205205
let text_string = text.value.clone();
206-
let font_path = format!("font/{}", text.font);
206+
let font_path = text.font.clone();
207207
commands.spawn().insert(text).insert_bundle(Text2dBundle {
208208
text: BevyText::with_section(
209209
text_string,
@@ -285,7 +285,6 @@ impl<S: Send + Sync + 'static> Game<S> {
285285
/// more information.
286286
pub fn window_settings(&mut self, window_descriptor: WindowDescriptor) -> &mut Self {
287287
self.window_descriptor = window_descriptor;
288-
log::debug!("window descriptor is: {:?}", self.window_descriptor);
289288
self
290289
}
291290

@@ -472,8 +471,7 @@ fn game_logic_sync<S: Send + Sync + 'static>(
472471
if text.font_size != bevy_text_component.sections[0].style.font_size {
473472
bevy_text_component.sections[0].style.font_size = text.font_size;
474473
}
475-
let font_path = format!("font/{}", text.font);
476-
let font = asset_server.load(font_path.as_str());
474+
let font = asset_server.load(text.font.as_str());
477475
if bevy_text_component.sections[0].style.font != font {
478476
bevy_text_component.sections[0].style.font = font;
479477
}

src/text.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Text {
1616
/// SYNCED: The actual text value you want to display.
1717
pub value: String,
1818
/// CREATION: The font to use when creating this text. Should be a file name of an .otf or
19-
/// .ttf font located within the assets/font folder. Defaults to "FiraSans-Bold.ttf" (included
19+
/// .ttf font located within the assets/font folder. Defaults to "font/FiraSans-Bold.ttf" (included
2020
/// in the default asset pack).
2121
pub font: String,
2222
/// SYNCED: The font size of the text you want to display. WARNING: As font sizes get larger,
@@ -43,7 +43,7 @@ impl Default for Text {
4343
Self {
4444
label: String::default(),
4545
value: String::default(),
46-
font: "FiraSans-Bold.ttf".to_string(),
46+
font: "font/FiraSans-Bold.ttf".to_string(),
4747
font_size: TEXT_DEFAULT_FONT_SIZE,
4848
translation: Vec2::default(),
4949
layer: TEXT_DEFAULT_LAYER,

tutorial/src/160-text-attributes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ If you change the font, then the `Text` will be re-rendered as a new image at th
2020

2121
The asset pack contains two fonts:
2222

23-
- `FiraMono-Medium.ttf`
24-
- `FiraSans-Bold.ttf` (the default font if none is specified)
23+
- `font/FiraMono-Medium.ttf`
24+
- `font/FiraSans-Bold.ttf` (the default font if none is specified)
2525

2626

2727
```rust,ignored
2828
let mono = engine.add_text("mono", "This text is using a monospace font");
29-
mono.font = "FiraMono-Medium.ttf".to_string();
29+
mono.font = "font/FiraMono-Medium.ttf".to_string();
3030
```
3131

32-
To use a custom font, place a valid `otf` or `ttf` file in `assets/font` and set it on your `Text`.
32+
To use a custom font, place a valid `otf` or `ttf` file in `assets/` and set it on your `Text`.
3333

3434
```rust,ignored
35-
// After placing `party.otf` in the `assets/font/` directory...
35+
// After placing `party.otf` in the `assets/` directory...
3636
let party = engine.add_text("party", "Let's Party!");
3737
mono.font = "party.otf".to_string();
3838
```

tutorial/src/205-music.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ One music file may be played at a time. Music always loops repeatedly until exp
44

55
### Play
66

7-
The `play_music` method starts playing looping music. The first parameter should be a `MusicPreset` enum variant or a music file path relative to `assets/audio`. All music from the asset pack have variants present in the `MusicPreset` enum for convenience.
7+
The `play_music` method starts playing looping music. The first parameter should be a `MusicPreset` enum variant or a music file path relative to `assets/`. All music from the asset pack have variants present in the `MusicPreset` enum for convenience.
88

99
The second parameter is the volume, which should be a value between `0.0` (silent) and `1.0` full volume.
1010

1111
```rust,ignored
1212
// using a preset
1313
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
1414
15-
// using a filepath relative to `assets/audio`
16-
game.audio_manager.play_music("music/Classy 8-Bit.ogg", 1.0);
15+
// using a filepath relative to `assets/`
16+
game.audio_manager.play_music("audio/music/Classy 8-Bit.ogg", 1.0);
1717
```
1818

1919
Any music already playing will be stopped to play a new music selection.

0 commit comments

Comments
 (0)