@@ -89,8 +89,14 @@ async def _initialize(self):
89
89
90
90
self .size = self .config ['size' ]
91
91
self ._default_color = [RGBColor (color ) for color in self .config ["default_color" ][0 :self .size ]]
92
- if len (self ._default_color ) < self .size :
93
- self ._default_color += [RGBColor ("white" )] * (self .size - len (self ._default_color ))
92
+
93
+ if (len (self ._default_color )) == 1 :
94
+ self ._default_color = self ._default_color * self .size
95
+ elif len (self ._default_color ) != self .size :
96
+ self .warning_log ("The amount of colors you specified for your text has to be either equal to "
97
+ "the amount of digits in your display or equals 1. Your display has a size of %s and the "
98
+ "amount of colors specified is %s. All display colors will be set to white." , self .size , len (self ._default_color ))
99
+ self ._default_color = [RGBColor ("white" )] * self .size
94
100
95
101
# configure hardware
96
102
try :
@@ -148,11 +154,9 @@ def add_text_entry(self, text, color, flashing, flash_mask, transition, transiti
148
154
149
155
This will replace texts with the same key.
150
156
"""
151
-
152
- if len (color ) == 0 :
157
+ if not color :
153
158
color = self ._current_state .text .get_colors ()
154
159
155
-
156
160
if self .config ['update_method' ] == "stack" :
157
161
158
162
@@ -172,35 +176,19 @@ def add_text_entry(self, text, color, flashing, flash_mask, transition, transiti
172
176
###############################
173
177
174
178
# Handle new and previous text
175
- if self ._previous_text :
176
- previous_text = self ._previous_text
177
- else :
178
- previous_text = ""
179
+ previous_text = self ._previous_text or ""
179
180
self ._previous_text = text # Save the new text as the next previous text
180
181
181
182
# Handle new and previous color
182
- if self ._previous_color :
183
- previous_color = self ._previous_color
184
- else :
185
- previous_color = self ._default_color
183
+ previous_color = self ._previous_color or self ._default_color
186
184
self ._previous_color = color # Save the new color as the next previous color
187
185
188
186
if transition or self ._previous_transition_out :
189
- if transition : #if transition exists, then ignore transition_out of previous text/color
190
- transition_conf = TransitionManager .get_transition (self .size ,
191
- self .config ['integrated_dots' ],
192
- self .config ['integrated_commas' ],
193
- self .config ['use_dots_for_commas' ],
194
- transition )
195
- elif self ._previous_transition_out :
196
- transition_conf = TransitionManager .get_transition (self .size ,
197
- self .config ['integrated_dots' ],
198
- self .config ['integrated_commas' ],
199
- self .config ['use_dots_for_commas' ],
200
- self ._previous_transition_out )
201
- self ._previous_transition_out = None # Once the transistion_out is played removed it that is not played in the next step again
202
- if transition_out : #in case transition_out is set we need to preserve it for the next step but only after the previous transition_out is in this step's config
203
- self ._previous_transition_out = transition_out
187
+ transition_conf = TransitionManager .get_transition (self .size ,
188
+ self .config ['integrated_dots' ],
189
+ self .config ['integrated_commas' ],
190
+ self .config ['use_dots_for_commas' ],
191
+ transition or self ._previous_transition_out )
204
192
205
193
#start transition
206
194
self ._start_transition (transition_conf , previous_text , text ,
@@ -216,6 +204,12 @@ def add_text_entry(self, text, color, flashing, flash_mask, transition, transiti
216
204
color )
217
205
self ._update_display (SegmentDisplayState (text , flashing , flash_mask ))
218
206
207
+ ###############################
208
+ # Once the transistion_out is played, removed it that is not played in the next step again, but in case transition_out is set in the current step
209
+ # then we need to preserve it for the next step but only after the previous step's transition_out is in this step's config (or the transition of the current step)
210
+ ###############################
211
+ self ._previous_transition_out = transition_out or None
212
+
219
213
def add_text (self , text : str , priority : int = 0 , key : str = None ) -> None :
220
214
"""Add text to display stack.
221
215
@@ -225,13 +219,23 @@ def add_text(self, text: str, priority: int = 0, key: str = None) -> None:
225
219
226
220
def remove_text_by_key (self , key : Optional [str ]):
227
221
"""Remove entry from text stack."""
228
- if self .config ['update_method' ] != "stack" :
222
+ if self .config ['update_method' ] == "stack" :
223
+ if key in self ._text_stack :
224
+ del self ._text_stack [key ]
225
+ self ._update_stack ()
226
+ else : # must be update_method replace, send empyt text since no key in that case
229
227
self .add_text_entry ("" , self ._previous_color , FlashingType .NO_FLASH , "" , None , None , 100 , key )
230
- return
231
228
232
- if key in self ._text_stack :
233
- del self ._text_stack [key ]
234
- self ._update_stack ()
229
+
230
+ def clear_segment_display (self , key : Optional [str ]):
231
+ """Clear segment dispaly if context is removed from player."""
232
+
233
+ if self .config ['update_method' ] == "replace" :
234
+ self ._stop_transition ()
235
+ self ._previous_transition_out = None
236
+
237
+ self .remove_text_by_key (key )
238
+
235
239
236
240
# pylint: disable=too-many-arguments
237
241
def _start_transition (self , transition : TransitionBase , current_text : str , new_text : str ,
0 commit comments