@@ -53,7 +53,7 @@ struct InteractableBundle {
53
53
#[ bundle]
54
54
text_bundle : Text2dBundle ,
55
55
selectable : Selectable ,
56
- rainbow : Rainbow ,
56
+ rainbow : ColorChoices ,
57
57
cycle_color_events : Events < CycleColorAction > ,
58
58
add_number_events : Events < AddNumberAction > ,
59
59
}
@@ -79,46 +79,37 @@ impl InteractableBundle {
79
79
..Default :: default ( )
80
80
} ,
81
81
selectable : Selectable ,
82
- rainbow : Rainbow :: Red ,
82
+ rainbow : ColorChoices :: Red ,
83
83
cycle_color_events : Events :: < CycleColorAction > :: default ( ) ,
84
84
add_number_events : Events :: < AddNumberAction > :: default ( ) ,
85
85
}
86
86
}
87
87
}
88
88
89
- enum Rainbow {
89
+ enum ColorChoices {
90
90
Red ,
91
- Orange ,
92
- Yellow ,
93
- Green ,
94
91
Blue ,
95
92
Violet ,
96
93
}
97
94
98
- impl Iterator for Rainbow {
95
+ impl Iterator for ColorChoices {
99
96
type Item = Self ;
100
97
101
- fn next ( & mut self ) -> Option < Rainbow > {
102
- use Rainbow :: * ;
98
+ fn next ( & mut self ) -> Option < ColorChoices > {
99
+ use ColorChoices :: * ;
103
100
Some ( match * self {
104
- Red => Orange ,
105
- Orange => Yellow ,
106
- Yellow => Green ,
107
- Green => Blue ,
101
+ Red => Blue ,
108
102
Blue => Violet ,
109
103
Violet => Red ,
110
104
} )
111
105
}
112
106
}
113
107
114
- impl From < & Rainbow > for Color {
115
- fn from ( rainbow : & Rainbow ) -> Color {
116
- use Rainbow :: * ;
108
+ impl From < & ColorChoices > for Color {
109
+ fn from ( rainbow : & ColorChoices ) -> Color {
110
+ use ColorChoices :: * ;
117
111
match rainbow {
118
112
Red => Color :: RED ,
119
- Orange => Color :: ORANGE ,
120
- Yellow => Color :: YELLOW ,
121
- Green => Color :: GREEN ,
122
113
Blue => Color :: BLUE ,
123
114
Violet => Color :: VIOLET ,
124
115
}
@@ -256,15 +247,15 @@ fn input_dispatch(
256
247
257
248
// FIXME: make this work without duplication using `EventReader<T>` syntax and specialized behavior
258
249
fn cycle_color ( mut query : Query < ( & mut Rainbow , & mut Events < CycleColorAction > ) > ) {
259
- for ( mut rainbow , action_queue) in query. iter_mut ( ) {
250
+ for ( mut color , action_queue) in query. iter_mut ( ) {
260
251
let mut reader = action_queue. get_reader ( ) ;
261
252
for _ in reader. iter ( & action_queue) {
262
- * rainbow = rainbow . next ( ) . unwrap ( ) ;
253
+ * color = color . next ( ) . unwrap ( ) ;
263
254
}
264
255
}
265
256
}
266
257
267
- fn update_text_color ( mut query : Query < ( & mut Text , & Rainbow ) , Changed < Rainbow > > ) {
258
+ fn update_text_color ( mut query : Query < ( & mut Text , & ColorChoices ) , Changed < ColorChoices > > ) {
268
259
for ( mut text, rainbow) in query. iter_mut ( ) {
269
260
text. sections [ 0 ] . style . color = rainbow. into ( ) ;
270
261
}
0 commit comments