Skip to content

Commit 0425673

Browse files
committed
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`.
1 parent 16feb9a commit 0425673

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

crates/bevy_ecs/src/schedule/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,10 @@ mod tests {
564564
let mut world = World::new();
565565
let mut schedule = Schedule::new();
566566

567-
schedule.set_build_settings(
568-
ScheduleBuildSettings::new().with_hierarchy_detection(LogLevel::Error),
569-
);
567+
schedule.set_build_settings(ScheduleBuildSettings {
568+
hierarchy_detection: LogLevel::Error,
569+
..Default::default()
570+
});
570571

571572
// Add `A`.
572573
schedule.configure_set(TestSet::A);
@@ -636,9 +637,10 @@ mod tests {
636637
let mut world = World::new();
637638
let mut schedule = Schedule::new();
638639

639-
schedule.set_build_settings(
640-
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Error),
641-
);
640+
schedule.set_build_settings(ScheduleBuildSettings {
641+
ambiguity_detection: LogLevel::Error,
642+
..Default::default()
643+
});
642644

643645
schedule.add_systems((res_ref, res_mut));
644646
let result = schedule.initialize(&mut world);

crates/bevy_ecs/src/schedule/schedule.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,10 +1333,14 @@ impl ScheduleGraph {
13331333
// methods for reporting errors
13341334
impl ScheduleGraph {
13351335
fn get_node_name(&self, id: &NodeId) -> String {
1336-
match id {
1336+
let mut name = match id {
13371337
NodeId::System(_) => self.systems[id.index()].get().unwrap().name().to_string(),
13381338
NodeId::Set(_) => self.system_sets[id.index()].name(),
1339+
};
1340+
if self.settings.use_shortnames {
1341+
name = bevy_utils::get_short_name(&name);
13391342
}
1343+
name
13401344
}
13411345

13421346
fn get_node_kind(id: &NodeId) -> &'static str {
@@ -1519,8 +1523,15 @@ pub enum LogLevel {
15191523
/// Specifies miscellaneous settings for schedule construction.
15201524
#[derive(Clone, Debug)]
15211525
pub struct ScheduleBuildSettings {
1522-
ambiguity_detection: LogLevel,
1523-
hierarchy_detection: LogLevel,
1526+
/// Determines whether the presence of ambiguities (systems with conflicting access but indeterminate order)
1527+
/// is only logged or also results in an [`Ambiguity`](ScheduleBuildError::Ambiguity) error.
1528+
pub ambiguity_detection: LogLevel,
1529+
/// Determines whether the presence of redundant edges in the hierarchy of system sets is only
1530+
/// logged or also results in a [`HierarchyRedundancy`](ScheduleBuildError::HierarchyRedundancy)
1531+
/// error.
1532+
pub hierarchy_detection: LogLevel,
1533+
/// If set to true, node names will be shortened instead of the fully qualified type path.
1534+
pub use_shortnames: bool,
15241535
}
15251536

15261537
impl Default for ScheduleBuildSettings {
@@ -1534,21 +1545,7 @@ impl ScheduleBuildSettings {
15341545
Self {
15351546
ambiguity_detection: LogLevel::Ignore,
15361547
hierarchy_detection: LogLevel::Warn,
1548+
use_shortnames: false,
15371549
}
15381550
}
1539-
1540-
/// Determines whether the presence of ambiguities (systems with conflicting access but indeterminate order)
1541-
/// is only logged or also results in an [`Ambiguity`](ScheduleBuildError::Ambiguity) error.
1542-
pub fn with_ambiguity_detection(mut self, level: LogLevel) -> Self {
1543-
self.ambiguity_detection = level;
1544-
self
1545-
}
1546-
1547-
/// Determines whether the presence of redundant edges in the hierarchy of system sets is only
1548-
/// logged or also results in a [`HierarchyRedundancy`](ScheduleBuildError::HierarchyRedundancy)
1549-
/// error.
1550-
pub fn with_hierarchy_detection(mut self, level: LogLevel) -> Self {
1551-
self.hierarchy_detection = level;
1552-
self
1553-
}
15541551
}

examples/ecs/nondeterministic_system_order.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ fn main() {
2121
App::new()
2222
// We can modify the reporting strategy for system execution order ambiguities on a per-schedule basis
2323
.edit_schedule(CoreSchedule::Main, |schedule| {
24-
schedule.set_build_settings(
25-
ScheduleBuildSettings::new().with_ambiguity_detection(LogLevel::Warn),
26-
);
24+
schedule.set_build_settings(ScheduleBuildSettings {
25+
ambiguity_detection: LogLevel::Warn,
26+
..default()
27+
});
2728
})
2829
.init_resource::<A>()
2930
.init_resource::<B>()

0 commit comments

Comments
 (0)