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

Upgrade dependencies and migrate to Bevy 0.14 #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ readme = "Readme.md"
keywords = ["bevy", "debug", "overlay", "message"]
categories = ["game-development", "development-tools"]
repository = "https://github.com/nicopap/bevy-debug-text-overlay"
version = "8.1.0"
version = "14.0.0"
edition = "2021"

[features]
default = ["debug"]
debug = ["bevy/bevy_render", "bevy/bevy_asset", "bevy/bevy_ui", "bevy/bevy_text", "bevy/bevy_core_pipeline", "bevy/default_font"]

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy = { version = "0.14", default-features = false }

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"bevy_render", "x11", "bevy_core_pipeline", "bevy_asset", "bevy_sprite"
] }
# bevy-inspector-egui = { version = "0.8" }

[package.metadata.release]
pre-release-replacements = [
{search="\\| 0.13 \\| [0-9.]* \\|",replace="| 0.13 | {{version}} |",file="Readme.md"},
{search="\\| 0.14 \\| [0-9.]* \\|",replace="| 0.14 | {{version}} |",file="Readme.md"},
{search="bevy-debug-text-overlay = \\{ version = \"[0-9.]*\"",replace="bevy-debug-text-overlay = { version = \"{{version}}\"",file="Readme.md"},
{search="bevy-debug-text-overlay = \"[0-9.]*\"",replace="bevy-debug-text-overlay = \"{{version}}\"",file="Readme.md"},
]
11 changes: 8 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ println-debugger, you will love this crate when working with bevy!

```toml
[dependencies]
bevy-debug-text-overlay = "8.1.0"
bevy-debug-text-overlay = "14.0.0"
```

This bevy plugin is fairly trivial to use. You must:
Expand Down Expand Up @@ -55,7 +55,7 @@ fn screen_print_text(time: Res<Time>) {
let x = (13, 3.4, vec![1,2,3,4,5,6,7,8]);
if at_interval(0.1) {
let last_fps = 1.0 / time.delta_seconds();
screen_print!(col: Color::CYAN, "fps: {last_fps:.0}");
screen_print!(col: Color::AQUA, "fps: {last_fps:.0}");
screen_print!("current time: {current_time:.2}")
}
if at_interval(2.0) {
Expand Down Expand Up @@ -92,7 +92,7 @@ debug = ["bevy-debug-text-overlay/debug"]
default = ["debug"]

# Manually specify features for bevy-debug-text-overlay (omitting "debug")
bevy-debug-text-overlay = { version = "8.1.0", default-features = false }
bevy-debug-text-overlay = { version = "14.0.0", default-features = false }
```

Now when making your release build, you should use
Expand Down Expand Up @@ -141,11 +141,16 @@ I'm welcoming contributions if you have any fixes:
invoked with the crate path
* Do not panic on exceeding 4096 prints per frame, instead log an error
* Use the std `OnceLock` over `lazy_static!`
* `14.0.0`:
* **Breaking**: bump bevy version to `0.14`
* `screen_print!` now accepts `Into<Color>` in compliance with `bevy 0.14` changes


### Version matrix

| bevy | latest supporting version |
|------|--------|
| 0.14 | 14.0.0 |
| 0.13 | 8.1.0 |
| 0.12 | 7.0.0 |
| 0.11 | 6.0.0 |
Expand Down
25 changes: 13 additions & 12 deletions examples/demo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::{prelude::*, window::PrimaryWindow};
use bevy_debug_text_overlay::{screen_print, OverlayPlugin};
use bevy::color::palettes::css;

fn main() {
App::new()
Expand Down Expand Up @@ -39,13 +40,13 @@ fn screen_print_text(time: Res<Time>) {
};
if at_interval(3.123) {
let colors = [
Color::RED,
Color::ORANGE,
Color::YELLOW,
Color::GREEN,
Color::CYAN,
Color::BLUE,
Color::VIOLET,
css::RED,
css::ORANGE,
css::YELLOW,
css::GREEN,
css::AQUA,
css::BLUE,
css::VIOLET,
];
for (i, color) in colors.iter().enumerate() {
screen_print!(push, sec: 1.9384, col: *color, "seven messages each 3 seconds: {i}");
Expand All @@ -62,11 +63,11 @@ fn screen_print_text(time: Res<Time>) {
}
mut_show.field_1 = 34.34234;
if at_interval(12.934) {
let col = Color::RED;
let col = css::RED;
screen_print!(col: col, "every 13: {}, {:?}", show.field_2, show.field_3)
}
if at_interval(4.832) {
let col = Color::PINK;
let col = css::PINK;
screen_print!(sec: 3.2123, col: col, "every 30: {mut_show:?}");
}
if at_interval(0.13243) {
Expand All @@ -90,8 +91,8 @@ fn show_fps(time: Res<Time>, mut deltas: Local<Vec<f32>>, mut ring_ptr: Local<us
if at_interval(2.0) {
let fps = deltas.len() as f32 / deltas.iter().sum::<f32>();
let last_fps = 1.0 / time.delta_seconds();
screen_print!(col: Color::GREEN, "fps: {fps:.0}");
screen_print!(col: Color::CYAN, "last: {last_fps:.0}");
screen_print!(col: css::GREEN, "fps: {fps:.0}");
screen_print!(col: css::AQUA, "last: {last_fps:.0}");
}
}

Expand All @@ -112,7 +113,7 @@ fn show_cursor_position(
let window_size = Vec2::new(window.width(), window.height());
let ndc = (screen_pos / window_size) * 2.0 - Vec2::ONE;
let ndc_to_world =
camera_transform.compute_matrix() * camera.projection_matrix().inverse();
camera_transform.compute_matrix() * camera.clip_from_view().inverse();
let world_pos = ndc_to_world.project_point3(ndc.extend(-1.0));
let world_pos: Vec2 = world_pos.truncate();

Expand Down
15 changes: 9 additions & 6 deletions src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::fmt;
use std::sync::mpsc::{self, Receiver, SyncSender};
use std::sync::{Mutex, OnceLock};

use bevy::color::palettes::css;
use bevy::{prelude::*, utils::HashMap};

use crate::block::Blocks;
Expand Down Expand Up @@ -107,13 +108,13 @@ macro_rules! screen_print {
$crate::screen_print!(@impl push, sec: $timeout, col: None, $text $(, $fmt_args)*);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one needs type too.

Suggested change
$crate::screen_print!(@impl push, sec: $timeout, col: None, $text $(, $fmt_args)*);
$crate::screen_print!(@impl push, sec: $timeout, col: Option::<Srgba>::None, $text $(, $fmt_args)*);

Or None::<Srgba>.

};
(sec: $timeout:expr, $text:expr $(, $fmt_args:expr)*) => {
$crate::screen_print!(@impl sec: $timeout, col: None, $text $(, $fmt_args)*);
$crate::screen_print!(@impl sec: $timeout, col: Option::<Srgba>::None, $text $(, $fmt_args)*);
};
(push, $text:expr $(, $fmt_args:expr)*) => {
$crate::screen_print!(@impl push, sec: 7.0, col: None, $text $(, $fmt_args)*);
$crate::screen_print!(@impl push, sec: 7.0, col: Option::<Srgba>::None, $text $(, $fmt_args)*);
};
($text:expr $(, $fmt_args:expr)*) => {
$crate::screen_print!(@impl sec: 7.0, col: None, $text $(, $fmt_args)*);
$crate::screen_print!(@impl sec: 7.0, col: Option::<Srgba>::None, $text $(, $fmt_args)*);
};
(@impl sec: $timeout:expr, col: $color:expr, $text:expr $(, $fmt_args:expr)*) => {{
use $crate::{InvocationSiteKey, command_channels};
Expand Down Expand Up @@ -174,8 +175,9 @@ impl CommandChannels {
key: InvocationSiteKey,
text: impl FnOnce() -> String,
timeout: f64,
color: Option<Color>,
color: Option<impl Into<Color>>,
) {
let color = color.map(|c| c.into());
let text = format!("{key} {}\n", text());
let cmd = Command::Refresh { text, key, color, timeout };
let sent = self.sender.try_send(cmd).is_ok();
Expand All @@ -188,8 +190,9 @@ impl CommandChannels {
key: InvocationSiteKey,
text: impl FnOnce() -> String,
timeout: f64,
color: Option<Color>,
color: Option<impl Into<Color>>,
) {
let color = color.map(|c| c.into());
let text = format!("{key} {}\n", text());
let cmd = Command::Push { text, color, timeout };
let sent = self.sender.try_send(cmd).is_ok();
Expand Down Expand Up @@ -345,7 +348,7 @@ pub struct OverlayPlugin {
}
impl Default for OverlayPlugin {
fn default() -> Self {
Self { fallback_color: Color::YELLOW, font_size: 13.0 }
Self { fallback_color: css::YELLOW.into(), font_size: 13.0 }
}
}

Expand Down