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

Update to Bevy 0.14 #29

Merged
merged 1 commit into from
Aug 16, 2024
Merged
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ builtin-parser = ["dep:logos"]

[dependencies]
# This crate by itself doesn't use any bevy features, but `bevy_egui` (dep) uses "bevy_asset".
bevy = { version = "0.13.0", default-features = false, features = [] }
bevy_egui = "0.27.0"
bevy = { version = "0.14.0", default-features = false, features = [] }
bevy_egui = "0.28.0"
chrono = "0.4.31"
tracing-log = "0.2.0"
tracing-subscriber = "0.3.18"
Expand All @@ -35,7 +35,7 @@ logos = { version = "0.14.0", optional = true }
fuzzy-matcher = { version = "0.3.7", optional = true }

[dev-dependencies]
bevy = "0.13.0"
bevy = "0.14.0"


[target.'cfg(target_os = "android")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::borrow::Cow;
use std::ops::Range;

use bevy::ecs::system::Command;
use bevy::ecs::world::Command;
use bevy::prelude::*;

/// The command parser currently being used by the dev console.
Expand Down
42 changes: 26 additions & 16 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,19 @@ pub trait ToColor32 {
}
impl ToColor32 for Color {
fn to_color32(&self) -> Color32 {
let [r, g, b, a] = self.as_rgba_u8();
let Srgba {
red,
green,
blue,
alpha,
} = self.to_srgba();

Color32::from_rgba_unmultiplied(r, g, b, a)
Color32::from_rgba_unmultiplied(
(red * 255.0) as u8,
(green * 255.0) as u8,
(blue * 255.0) as u8,
(alpha * 255.0) as u8,
)
}
}

Expand All @@ -86,24 +96,24 @@ impl ConsoleTheme {
/// Atom's iconic One Dark theme.
pub const ONE_DARK: Self = Self {
font: FontId::monospace(14.0),
dark: Color::rgb(0.42, 0.44, 0.48),
text_color: Color::rgb(0.67, 0.7, 0.75),
error: Color::rgb(0.91, 0.46, 0.5),
warning: Color::rgb(0.82, 0.56, 0.32),
info: Color::rgb(0.55, 0.76, 0.4),
debug: Color::rgb(0.29, 0.65, 0.94),
trace: Color::rgb(0.78, 0.45, 0.89),
dark: Color::srgb(0.42, 0.44, 0.48),
text_color: Color::srgb(0.67, 0.7, 0.75),
error: Color::srgb(0.91, 0.46, 0.5),
warning: Color::srgb(0.82, 0.56, 0.32),
info: Color::srgb(0.55, 0.76, 0.4),
debug: Color::srgb(0.29, 0.65, 0.94),
trace: Color::srgb(0.78, 0.45, 0.89),
};
/// High contrast theme, might help some people.
pub const HIGH_CONTRAST: Self = Self {
font: FontId::monospace(14.0),
dark: Color::rgb(0.5, 0.5, 0.5),
text_color: Color::rgb(1.0, 1.0, 1.0),
error: Color::rgb(1.0, 0.0, 0.0),
warning: Color::rgb(1.0, 1.0, 0.0),
info: Color::rgb(0.0, 1.0, 0.0),
debug: Color::rgb(0.25, 0.25, 1.0),
trace: Color::rgb(1.0, 0.0, 1.0),
dark: Color::srgb(0.5, 0.5, 0.5),
text_color: Color::srgb(1.0, 1.0, 1.0),
error: Color::srgb(1.0, 0.0, 0.0),
warning: Color::srgb(1.0, 1.0, 0.0),
info: Color::srgb(0.0, 1.0, 0.0),
debug: Color::srgb(0.25, 0.25, 1.0),
trace: Color::srgb(1.0, 0.0, 1.0),
};

/// Returns a [`Color32`] based on the `level`
Expand Down
62 changes: 34 additions & 28 deletions src/ui/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,41 @@ pub fn completions(
}
}
}
egui::popup_below_widget(ui, text_edit_complete_id, &text_edit.response, |ui| {
ui.vertical(|ui| {
for (
i,
CompletionSuggestion {
suggestion,
highlighted_indices,
},
) in completions.iter().take(6).enumerate()
{
let mut layout = egui::text::LayoutJob::default();
for (i, _) in suggestion.char_indices() {
layout.append(
&suggestion[i..=i],
0.0,
if highlighted_indices.contains(&i) {
config.theme.format_bold()
} else {
config.theme.format_text()
},
);
}
let res = ui.label(layout);
if i == state.selected_completion {
res.highlight();
egui::popup_below_widget(
ui,
text_edit_complete_id,
&text_edit.response,
egui::PopupCloseBehavior::CloseOnClickOutside,
|ui| {
ui.vertical(|ui| {
for (
i,
CompletionSuggestion {
suggestion,
highlighted_indices,
},
) in completions.iter().take(6).enumerate()
{
let mut layout = egui::text::LayoutJob::default();
for (i, _) in suggestion.char_indices() {
layout.append(
&suggestion[i..=i],
0.0,
if highlighted_indices.contains(&i) {
config.theme.format_bold()
} else {
config.theme.format_text()
},
);
}
let res = ui.label(layout);
if i == state.selected_completion {
res.highlight();
}
}
}
})
});
})
},
);
}

/// Also consumes the up and down arrow keys.
Expand Down