@@ -25,7 +25,6 @@ protected Timeline () { }
2525
2626
2727 public TMP_Dropdown dataSourceDropdown ;
28- //public TMP_Dropdown timelineStatusDropdown;
2928 public TMP_Text timelineStatusText ;
3029 public TMP_Text timelineVizDateTimeText ;
3130 public Button startButton ;
@@ -49,7 +48,14 @@ public enum TimelineStatus {
4948 [ Tooltip ( "Time since a data request made active" ) ]
5049 public int waitingForDataProgress ;
5150
52- public int totalEvents ;
51+ public int totalEventCount ;
52+
53+ [ Serializable ]
54+ public enum DataSource {
55+ local ,
56+ live
57+ }
58+ public DataSource dataSource ;
5359
5460
5561 // BUFFER
@@ -133,6 +139,8 @@ private void Awake ()
133139 {
134140 //// populate options in the status dropdown
135141 //Dropdown_PopulateStatus ();
142+
143+ //dataSource = (DataSource)dataSourceDropdown.value;
136144 }
137145
138146 private void Start ( )
@@ -158,29 +166,15 @@ private void Start ()
158166 // // add options to list
159167 // timelineStatusDropdown.AddOptions (options);
160168 //}
161- ///**
162- // * Called from UI to update the game status
163- // */
164- //public void Dropdown_Listener (int _status)
165- //{
166- // // call in-game logic, cast as Enum
167- // SetTimelineStatus ((TimelineStatus)_status, true);
168- //}
169-
170169
171170
172171 /**
173- * Called from game to update the status
172+ * Called from UI to update the data source
174173 */
175- public void SetTimelineStatus ( TimelineStatus _status , bool fromUI = false )
174+ public void OnChangeDataSourceDropdown ( int _status )
176175 {
177- //Debug.Log ("Timeline.SetTimelineStatus() status = " + status + ", _status = " + _status);
178-
179- // update status var
180- status = _status ;
181-
182- // if the call (note, original status) came from within the game then show in UI
183- if ( ! fromUI ) timelineStatusText . text = _status . ToString ( ) ;
176+ // cast as Enum
177+ dataSource = ( DataSource ) _status ;
184178 }
185179
186180
@@ -230,13 +224,34 @@ void SetStartBtnText (string txt, bool interact)
230224 /////////////////////////////////////////////////////////////
231225
232226
227+ /**
228+ * Called from game and buttons to update the status
229+ */
230+ public void SetTimelineStatus ( TimelineStatus _status , bool fromUI = false )
231+ {
232+ //Debug.Log ("Timeline.SetTimelineStatus() status = " + status + ", _status = " + _status);
233+
234+ // update status var
235+ status = _status ;
236+
237+ // if the call (note, original status) came from within the game then show in UI
238+ if ( ! fromUI ) timelineStatusText . text = _status . ToString ( ) ;
239+ }
240+
233241 /**
234242 * (stops and then) starts the buffer loop
235243 */
236244 public void StartBufferLoop ( )
237245 {
238246 Debug . Log ( "Timeline.StartBufferLoop()" ) ;
239247
248+ // update buffer max based on source
249+ if ( dataSource == DataSource . local ) {
250+ bufferCountMax = 1000 ;
251+ } else if ( dataSource == DataSource . local ) {
252+ bufferCountMax = 50 ;
253+ }
254+
240255 // if coroutine running
241256 if ( bufferCoroutine != null ) StopCoroutine ( bufferCoroutine ) ;
242257 // start buffer, attempt to get new data
@@ -416,14 +431,15 @@ IEnumerator BufferLoop ()
416431
417432 else if ( status == TimelineStatus . bufferEmpty ) {
418433
419- // local
420- if ( dataSourceDropdown . value == 0 ) {
421- // set to handle end of buffer
434+ // LOCAL
435+ if ( dataSource == DataSource . local ) {
436+ // we are using prepackaged data archive so move history back to buffer
422437 SetTimelineStatus ( TimelineStatus . moveHistory ) ;
423438 }
424- // live
425- else if ( dataSourceDropdown . value == 1 ) {
426- // get new data
439+ // LIVE
440+ else if ( dataSource == DataSource . live ) {
441+ // attempt to get new data
442+
427443 }
428444
429445 }
@@ -439,11 +455,10 @@ IEnumerator BufferLoop ()
439455
440456 }
441457
442-
458+ // update counts
443459 UpdateCounts ( ) ;
444-
445460 // after checking condition
446- if ( bufferCount > 0 ) {
461+ if ( totalEventCount > 0 ) {
447462 // display
448463 UpdateTimelineLogs ( ) ;
449464 }
@@ -517,9 +532,9 @@ IEnumerator HistoryLoop ()
517532 if ( historyCount > 0 ) {
518533 // after update, sort ascending
519534 history . Sort ( ( x , y ) => x . createdAt . CompareTo ( y . createdAt ) ) ;
520- // display
521- UpdateTimelineLogs ( ) ;
522535 }
536+ // display
537+ UpdateTimelineLogs ( ) ;
523538
524539
525540 // log feed item
@@ -561,15 +576,15 @@ void UpdateTimelineLogs ()
561576 int safety = 0 ;
562577 foreach ( var feed in buffer ) {
563578 bufferString += feed . eventType + ". " + feed . createdAt + " - " + feed . username + "<br>" ;
564- if ( ++ safety > bufferCountMax ) {
579+ if ( ++ safety > bufferCount || safety > totalEventCount ) {
565580 Debug . Log ( "Safety first!" ) ;
566581 break ;
567582 }
568583 }
569584 safety = 0 ;
570585 foreach ( var feed in history ) {
571586 historyString += feed . eventType + ". " + feed . createdAt + " - " + feed . username + "<br>" ;
572- if ( ++ safety > bufferCountMax ) {
587+ if ( ++ safety > historyCount || safety > totalEventCount ) {
573588 Debug . Log ( "Safety first!" ) ;
574589 break ;
575590 }
@@ -594,7 +609,7 @@ void UpdateCounts ()
594609 {
595610 bufferCount = buffer . Count ;
596611 historyCount = history . Count ;
597- totalEvents = buffer . Count + history . Count ;
612+ totalEventCount = buffer . Count + history . Count ;
598613 }
599614
600615 public void UpdateScroll ( )
0 commit comments