Cleanup ScheduleBuildSettings (#7721)
# Objective Fix #7440. Fix #7441. ## Solution * Remove builder functions on `ScheduleBuildSettings` in favor of public fields, move docs to the fields. * Add `use_shortnames` and use it in `get_node_name` to feed it through `bevy_utils::get_short_name`.
This commit is contained in:
parent
16feb9acb7
commit
04256735f6
@ -564,9 +564,10 @@ mod tests {
|
|||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
let mut schedule = Schedule::new();
|
let mut schedule = Schedule::new();
|
||||||
|
|
||||||
schedule.set_build_settings(
|
schedule.set_build_settings(ScheduleBuildSettings {
|
||||||
ScheduleBuildSettings::new().with_hierarchy_detection(LogLevel::Error),
|
hierarchy_detection: LogLevel::Error,
|
||||||
);
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
// Add `A`.
|
// Add `A`.
|
||||||
schedule.configure_set(TestSet::A);
|
schedule.configure_set(TestSet::A);
|
||||||
@ -636,9 +637,10 @@ mod tests {
|
|||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
let mut schedule = Schedule::new();
|
let mut schedule = Schedule::new();
|
||||||
|
|
||||||
schedule.set_build_settings(
|
schedule.set_build_settings(ScheduleBuildSettings {
|
||||||
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Error),
|
ambiguity_detection: LogLevel::Error,
|
||||||
);
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
schedule.add_systems((res_ref, res_mut));
|
schedule.add_systems((res_ref, res_mut));
|
||||||
let result = schedule.initialize(&mut world);
|
let result = schedule.initialize(&mut world);
|
||||||
|
@ -1333,10 +1333,14 @@ impl ScheduleGraph {
|
|||||||
// methods for reporting errors
|
// methods for reporting errors
|
||||||
impl ScheduleGraph {
|
impl ScheduleGraph {
|
||||||
fn get_node_name(&self, id: &NodeId) -> String {
|
fn get_node_name(&self, id: &NodeId) -> String {
|
||||||
match id {
|
let mut name = match id {
|
||||||
NodeId::System(_) => self.systems[id.index()].get().unwrap().name().to_string(),
|
NodeId::System(_) => self.systems[id.index()].get().unwrap().name().to_string(),
|
||||||
NodeId::Set(_) => self.system_sets[id.index()].name(),
|
NodeId::Set(_) => self.system_sets[id.index()].name(),
|
||||||
|
};
|
||||||
|
if self.settings.use_shortnames {
|
||||||
|
name = bevy_utils::get_short_name(&name);
|
||||||
}
|
}
|
||||||
|
name
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_node_kind(id: &NodeId) -> &'static str {
|
fn get_node_kind(id: &NodeId) -> &'static str {
|
||||||
@ -1519,8 +1523,15 @@ pub enum LogLevel {
|
|||||||
/// Specifies miscellaneous settings for schedule construction.
|
/// Specifies miscellaneous settings for schedule construction.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ScheduleBuildSettings {
|
pub struct ScheduleBuildSettings {
|
||||||
ambiguity_detection: LogLevel,
|
/// Determines whether the presence of ambiguities (systems with conflicting access but indeterminate order)
|
||||||
hierarchy_detection: LogLevel,
|
/// is only logged or also results in an [`Ambiguity`](ScheduleBuildError::Ambiguity) error.
|
||||||
|
pub ambiguity_detection: LogLevel,
|
||||||
|
/// Determines whether the presence of redundant edges in the hierarchy of system sets is only
|
||||||
|
/// logged or also results in a [`HierarchyRedundancy`](ScheduleBuildError::HierarchyRedundancy)
|
||||||
|
/// error.
|
||||||
|
pub hierarchy_detection: LogLevel,
|
||||||
|
/// If set to true, node names will be shortened instead of the fully qualified type path.
|
||||||
|
pub use_shortnames: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ScheduleBuildSettings {
|
impl Default for ScheduleBuildSettings {
|
||||||
@ -1534,21 +1545,7 @@ impl ScheduleBuildSettings {
|
|||||||
Self {
|
Self {
|
||||||
ambiguity_detection: LogLevel::Ignore,
|
ambiguity_detection: LogLevel::Ignore,
|
||||||
hierarchy_detection: LogLevel::Warn,
|
hierarchy_detection: LogLevel::Warn,
|
||||||
|
use_shortnames: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines whether the presence of ambiguities (systems with conflicting access but indeterminate order)
|
|
||||||
/// is only logged or also results in an [`Ambiguity`](ScheduleBuildError::Ambiguity) error.
|
|
||||||
pub fn with_ambiguity_detection(mut self, level: LogLevel) -> Self {
|
|
||||||
self.ambiguity_detection = level;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determines whether the presence of redundant edges in the hierarchy of system sets is only
|
|
||||||
/// logged or also results in a [`HierarchyRedundancy`](ScheduleBuildError::HierarchyRedundancy)
|
|
||||||
/// error.
|
|
||||||
pub fn with_hierarchy_detection(mut self, level: LogLevel) -> Self {
|
|
||||||
self.hierarchy_detection = level;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@ fn main() {
|
|||||||
App::new()
|
App::new()
|
||||||
// We can modify the reporting strategy for system execution order ambiguities on a per-schedule basis
|
// We can modify the reporting strategy for system execution order ambiguities on a per-schedule basis
|
||||||
.edit_schedule(CoreSchedule::Main, |schedule| {
|
.edit_schedule(CoreSchedule::Main, |schedule| {
|
||||||
schedule.set_build_settings(
|
schedule.set_build_settings(ScheduleBuildSettings {
|
||||||
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Warn),
|
ambiguity_detection: LogLevel::Warn,
|
||||||
);
|
..default()
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.init_resource::<A>()
|
.init_resource::<A>()
|
||||||
.init_resource::<B>()
|
.init_resource::<B>()
|
||||||
|
Loading…
Reference in New Issue
Block a user