mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
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
3 changed files with 27 additions and 27 deletions
|
@ -564,9 +564,10 @@ mod tests {
|
|||
let mut world = World::new();
|
||||
let mut schedule = Schedule::new();
|
||||
|
||||
schedule.set_build_settings(
|
||||
ScheduleBuildSettings::new().with_hierarchy_detection(LogLevel::Error),
|
||||
);
|
||||
schedule.set_build_settings(ScheduleBuildSettings {
|
||||
hierarchy_detection: LogLevel::Error,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// Add `A`.
|
||||
schedule.configure_set(TestSet::A);
|
||||
|
@ -636,9 +637,10 @@ mod tests {
|
|||
let mut world = World::new();
|
||||
let mut schedule = Schedule::new();
|
||||
|
||||
schedule.set_build_settings(
|
||||
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Error),
|
||||
);
|
||||
schedule.set_build_settings(ScheduleBuildSettings {
|
||||
ambiguity_detection: LogLevel::Error,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
schedule.add_systems((res_ref, res_mut));
|
||||
let result = schedule.initialize(&mut world);
|
||||
|
|
|
@ -1333,10 +1333,14 @@ impl ScheduleGraph {
|
|||
// methods for reporting errors
|
||||
impl ScheduleGraph {
|
||||
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::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 {
|
||||
|
@ -1519,8 +1523,15 @@ pub enum LogLevel {
|
|||
/// Specifies miscellaneous settings for schedule construction.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ScheduleBuildSettings {
|
||||
ambiguity_detection: LogLevel,
|
||||
hierarchy_detection: LogLevel,
|
||||
/// 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 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 {
|
||||
|
@ -1534,21 +1545,7 @@ impl ScheduleBuildSettings {
|
|||
Self {
|
||||
ambiguity_detection: LogLevel::Ignore,
|
||||
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()
|
||||
// We can modify the reporting strategy for system execution order ambiguities on a per-schedule basis
|
||||
.edit_schedule(CoreSchedule::Main, |schedule| {
|
||||
schedule.set_build_settings(
|
||||
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Warn),
|
||||
);
|
||||
schedule.set_build_settings(ScheduleBuildSettings {
|
||||
ambiguity_detection: LogLevel::Warn,
|
||||
..default()
|
||||
});
|
||||
})
|
||||
.init_resource::<A>()
|
||||
.init_resource::<B>()
|
||||
|
|
Loading…
Reference in a new issue