Skip to content

Commit

Permalink
Dev mode logging disable
Browse files Browse the repository at this point in the history
  • Loading branch information
makscee committed Jul 26, 2024
1 parent d896f42 commit 5321554
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ impl Representation {
}
self.unpack_children(world);
let entity = *self.material_entities.first().unwrap();
debug!("unpack material {} {entity:?}", self.material);
if is_dev_mode() {
debug!("unpack material {} {entity:?}", self.material);
}
entity
}
fn unpack_children(&mut self, world: &mut World) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn main() {
RunMode::ArchiveDownload => GameState::GameArchiveDownload,
RunMode::ArchiveUpload => GameState::GameArchiveUpload,
};
load_client_settings();
GameState::set_target(target);
let default_plugins = DefaultPlugins.set(LogPlugin {
level: bevy::log::Level::DEBUG,
Expand Down Expand Up @@ -127,7 +128,6 @@ fn setup(world: &mut World) {
if let Some(ctx) = egui_context(world) {
egui_extras::install_image_loaders(&ctx);
}
load_client_settings();
}

fn update(time: Res<Time>) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/camera.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bevy::{
core_pipeline::core_2d::Camera2dBundle,
ecs::system::Commands,
render::{
camera::{OrthographicProjection, ScalingMode},
view::InheritedVisibility,
Expand Down
3 changes: 3 additions & 0 deletions src/resources/client_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub fn load_client_settings() {
pub fn client_settings() -> &'static ClientSettings {
CLIENT_SETTINGS.get().unwrap()
}
pub fn is_dev_mode() -> bool {
client_settings().dev_mode
}

impl Default for ClientSettings {
fn default() -> Self {
Expand Down
5 changes: 4 additions & 1 deletion src/resources/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ impl Context {
}

pub fn log(&self, main: Option<Cstr>) {
if !is_dev_mode() {
return;
}
let mut s = main.unwrap_or_default();
for (i, layer) in self.layers.iter().enumerate() {
s.push(layer.cstr());
if i != self.layers.len() - 1 {
s.push(" -> ".cstr());
}
}
s.info()
s.debug()
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub enum Event {

impl Event {
pub fn send_with_context(self, mut context: Context, world: &mut World) -> Self {
debug!("{} {}", "Send event".dimmed(), self.cstr());
if client_settings().dev_mode {
debug!("{} {}", "Send event".dimmed(), self.cstr());
}
context.set_event(self.clone());
ActionPlugin::register_event(self.clone(), world);
let units = match &self {
Expand Down

0 comments on commit 5321554

Please sign in to comment.