@@ -176,49 +176,65 @@ private void Start ()
176176 /////////////////////////////////////////////////////////////
177177
178178
179-
179+ string startBtnAction = "Start" ;
180180
181181 /**
182182 * Called from the UI button to start / stop
183183 */
184184 public void OnStartBtnClick ( )
185185 {
186- // immediately disable both
187- SetStartBtnText ( " --- " , false ) ;
188- DataManager . Instance . EnableEndpointDropdown ( false ) ;
186+ // 1. startBtnAction == "Start" - stopped
187+ // button enabled = true
188+ // dropdowns enabled = true
189+ if ( startBtnAction . Equals ( "Start" ) ) {
190+ // disable both
191+ SetStartBtnText ( "---" , false ) ;
192+ DataManager . Instance . EnableDataDropdowns ( false ) ;
193+
194+ // set status
195+ SetTimelineStatus ( TimelineStatus . start ) ;
196+ // start loop
197+ StartBufferLoop ( ) ;
198+ }
199+
200+ // 2. startBtnAction == "Stop" - in play mode
201+ // button enabled = true
202+ // dropdowns enabled = false
203+ else if ( startBtnAction . Equals ( "Stop" ) ) {
204+ // set status
205+ SetTimelineStatus ( TimelineStatus . inactive ) ;
189206
190- // if currently active (user has clicked "stop")
191- if ( status == TimelineStatus . active ) {
192- SetStartBtnText ( " --- " , false ) ;
193207 // stop everything
194208 StopBufferLoop ( ) ;
195209 StopHistoryLoop ( ) ;
196- // set status
197- SetTimelineStatus ( TimelineStatus . inactive ) ;
198- // update btn text and make interactable
199- SetStartBtnText ( "Start" , true ) ;
200- // should let them select
201- DataManager . Instance . EnableEndpointDropdown ( true ) ;
202210 // if there are players active
203211 if ( PlayerManager . Instance . playerCount > 0 ) {
204- // then add them
212+ // then remove them
205213 EventManager . TriggerEvent ( "RemoveAllPlayers" ) ;
206214 }
215+
216+ // enable both
217+ SetStartBtnText ( "Start" , true ) ;
218+ DataManager . Instance . EnableDataDropdowns ( true ) ;
207219 }
208- // if not active (user clicked "Start")
220+
221+ // 3. startBtnAction == "---" - busy doing something
222+ // button enabled = false
223+ // dropdowns enabled = false
209224 else {
210- // set status
211- SetTimelineStatus ( TimelineStatus . start ) ;
212- // start loop
213- StartBufferLoop ( ) ;
225+
214226 }
227+
228+
229+
215230 UpdateCounts ( ) ;
216231 UpdateTimelineLogs ( ) ;
217232 }
218233
219234 void SetStartBtnText ( string txt , bool interact )
220235 {
221- startButtonText . text = txt ;
236+ startBtnAction = txt ;
237+ startButtonText . text = startBtnAction ;
222238 startButton . interactable = interact ;
223239 }
224240
@@ -326,9 +342,9 @@ void UpdateWaitingProgress (int _status)
326342 // show status
327343 waitingForDataProgressText . text = " -- " ;
328344 // disable button until data arrives
329- SetStartBtnText ( " --- " , false ) ;
345+ SetStartBtnText ( "---" , false ) ;
330346 // disable
331- DataManager . Instance . EnableEndpointDropdown ( false ) ;
347+ DataManager . Instance . EnableDataDropdowns ( false ) ;
332348 }
333349 // still waiting
334350 else if ( _status == 1 ) {
@@ -346,21 +362,19 @@ void UpdateWaitingProgress (int _status)
346362 //waitingForDataProgressText.text = " -- ";
347363
348364 UpdateCounts ( ) ;
349- // update btn text and disable
365+ // show Stop button and disable dropdowns
350366 SetStartBtnText ( "Stop" , true ) ;
351- // disable
352- DataManager . Instance . EnableEndpointDropdown ( false ) ;
353-
367+ DataManager . Instance . EnableDataDropdowns ( false ) ;
354368 }
355369 // finished - fail - NO DATA
356370 else if ( _status == 3 ) {
357371 // mark finished flag true
358372 waitingForDataFinished = true ;
359373 UpdateCounts ( ) ;
360- // update btn text and make interactable
361- SetStartBtnText ( "START" , true ) ;
362- // should let them select
363- DataManager . Instance . EnableEndpointDropdown ( true ) ;
374+
375+ // show Start button and enable dropdowns
376+ SetStartBtnText ( "Start" , true ) ;
377+ DataManager . Instance . EnableDataDropdowns ( true ) ;
364378 }
365379
366380
0 commit comments