@@ -37,7 +37,9 @@ fn main() {
3737 . add_systems (
3838 Update ,
3939 (
40- // Updates the Model if the user changed the name via text input
40+ // Updates the Model if the user changed the name via text input.
41+ // This is a Controller system, and is not an Observer because of
42+ // the way the text input widget is designed.
4143 on_changed_editable_text,
4244 // Updates the View after any Model changes
4345 refresh_character. run_if ( resource_exists_and :: < Character > ( |character| {
@@ -54,9 +56,9 @@ fn setup(mut commands: Commands, character: Res<Character>) {
5456 Camera2d ,
5557
5658 // This scene will serve as one half of our "View"
57- // and all of the "Controller" in our MVC design.
59+ // and most of the "Controller" in our MVC design.
5860 // The user interacts with UI widgets, which are processed by the "Controller"
59- // via observers and other systems. The observers and systems update the
61+ // via observers and systems. The observers and systems update the
6062 // state and also update the look of the UI widgets
6163 // (i.e. changing text color of a selected option, inserting an X).
6264 ui( & character) ,
@@ -330,6 +332,7 @@ fn age_slider(character: &Character) -> impl Scene {
330332 position_type: PositionType :: Absolute ,
331333 left: px( 0 )
332334 // Shortened by the slider thumb's width on the right side.
335+ // This means that it is 200px in width.
333336 right: px( 20 ) ,
334337 top: px( 0 ) ,
335338 bottom: px( 0 ) ,
@@ -643,6 +646,8 @@ fn refresh_character(
643646 let ( mut already_updated_name_age, mut already_updated_sprite, mut already_updated_hat) =
644647 ( false , false , false ) ;
645648 for changed_field in character. changed_fields . iter ( ) . copied ( ) {
649+ // First, find the correct child to despawn
650+ // Then, add an updated child.
646651 match changed_field {
647652 ChangedField :: Name | ChangedField :: Age if !already_updated_name_age => {
648653 for ( child, _, _, is_name_and_age) in children
0 commit comments