@@ -39,9 +39,8 @@ public Clock(int StartTime=0, string EventsFile = "::", string ConfigFile = "::"
3939 // StartTimer();
4040 }
4141
42- const string Version = "v0.1" ;
43- const string TimeFormat = @"mm\:ss" ;
44- const string DefaultStatusBar = Version + " - github.com/LumKitty" ;
42+ //const string TimeFormat = @"mm\:ss";
43+ const string DefaultStatusBar = Shared . Version + " - github.com/LumKitty" ;
4544 string _ConfigFile ;
4645 Color TextBackgroundColor ;
4746 private List < TimerEvent > TimerEvents = new ( ) ;
@@ -61,7 +60,7 @@ private void SaveConfig() {
6160 new JProperty ( "Height" , this . Height ) ,
6261 new JProperty ( "VNyanURL" , Shared . VNyanURL ) ,
6362 new JProperty ( "MixItUpURL" , Shared . MixItUpURL ) ,
64- new JProperty ( "MixItUpPlatform" , Shared . MixItUpPlatform )
63+ new JProperty ( "MixItUpPlatform" , Shared . DefaultMixItUpPlatform . ToString ( ) )
6564 ) ;
6665 File . WriteAllText ( _ConfigFile , Config . ToString ( ) ) ;
6766 }
@@ -94,7 +93,7 @@ private void LoadConfig() {
9493 lblCountdown . Font = font ;
9594 Shared . VNyanURL = Config . VNyanURL ;
9695 Shared . MixItUpURL = Config . MixItUpURL ;
97- Shared . MixItUpPlatform = Config . MixItUpPlatform ;
96+ Shared . DefaultMixItUpPlatform = Shared . GetMiuPlatform ( Config . MixItUpPlatform . ToString ( ) , MIUPlatforms . Twitch ) ;
9897 } else {
9998 Font font = lblCountdown . Font ;
10099 fontDialog . Font = font ;
@@ -104,7 +103,7 @@ private void LoadConfig() {
104103 SetTextAlignment ( 0 ) ;
105104 Shared . VNyanURL = "ws://localhost:8000/vnyan" ;
106105 Shared . MixItUpURL = "http://localhost:8911/api/v2" ;
107- Shared . MixItUpPlatform = "twitch" ;
106+ Shared . DefaultMixItUpPlatform = MIUPlatforms . Twitch ;
108107 if ( MessageBox . Show ( "This appears to be the first time you have run this program. Would you like to view the instructions" , "Welcome" , MessageBoxButtons . YesNo ) == DialogResult . Yes ) {
109108 Process myProcess = new Process ( ) ;
110109 myProcess . StartInfo . UseShellExecute = true ;
@@ -141,21 +140,19 @@ private async Task ConnectMixItUp() {
141140 if ( Shared . InitMIU ( Shared . MixItUpURL ) ) {
142141 lblMixItUp . BackColor = Color . Green ;
143142 Shared . MixItUpConnected = true ;
144- UpdateMiuTimerEvents ( ref TimerEvents ) ;
143+ // UpdateMiuTimerEvents(ref TimerEvents);
145144 } else {
146145 lblMixItUp . BackColor = Color . Red ;
147146 Shared . MixItUpConnected = false ;
148147 }
149148 } while ( ! Shared . MixItUpConnected ) ;
150149 }
151150
152- private void UpdateMiuTimerEvents ( ref List < TimerEvent > timerEvents ) {
153- foreach ( TimerEvent timerEvent in timerEvents ) {
154- if ( ( timerEvent . EventType == EventType . MixItUp ) && ( timerEvent . MiuCmdID == "" ) ) {
155- timerEvent . UpdateMiuCmdId ( ) ;
156- }
151+ /*private void UpdateMiuTimerEvents(ref List<TimerEvent> timerEvents) {
152+ foreach (MIUEvent timerEvent in timerEvents.OfType<MIUEvent>().ToList() ) {
153+ timerEvent.UpdateMiuCmdId();
157154 }
158- }
155+ }*/
159156
160157 private void Connect ( ) {
161158 if ( Shared . VNyanURL . Length > 0 ) {
@@ -238,7 +235,7 @@ public void StartCountdown(int CountdownTime) {
238235 }
239236
240237 private void UpdateClock ( int SecondsToGo ) {
241- lblCountdown . Text = TimeSpan . FromSeconds ( SecondsToGo ) . ToString ( TimeFormat ) ;
238+ lblCountdown . Text = TimeSpan . FromSeconds ( SecondsToGo ) . ToString ( Shared . TimeFormat ) ;
242239 }
243240 private void UpdateClock ( string SecondsToGo ) {
244241 int Seconds ;
@@ -255,33 +252,40 @@ private void timer1_Tick(object sender, EventArgs e) {
255252 SecondsToGo -- ;
256253 UpdateClock ( SecondsToGo ) ;
257254
258- toolStripProgressBar1 . Value = toolStripProgressBar1 . Maximum - SecondsToGo ;
259- for ( n = 0 ; n < TimerEvents . Count ; n ++ ) {
260- if ( ( TimerEvents [ n ] . Time . TotalSeconds < SecondsToGo ) && ! TimerEvents [ n ] . HasFired ) {
261- StatusLabel = "Next Event in " + ( SecondsToGo - TimerEvents [ n ] . Time . TotalSeconds ) + "s: " + TimerEvents [ n ] . Time . ToString ( TimeFormat ) + " (" + TimerEvents [ n ] . EventType + ") " + TimerEvents [ n ] . Payload ;
262- i = n + 1 ;
263- while ( i < TimerEvents . Count && TimerEvents [ i ] . Time . TotalSeconds == TimerEvents [ n ] . Time . TotalSeconds ) {
264- if ( ! TimerEvents [ i ] . HasFired ) { ExtraSimultaneousEvents ++ ; }
265- i ++ ;
266- }
267- if ( ExtraSimultaneousEvents > 0 ) {
268- StatusLabel += " +" + ExtraSimultaneousEvents . ToString ( ) ;
269- }
270- break ;
271- } else if ( ( TimerEvents [ n ] . Time . TotalSeconds == SecondsToGo ) && ! TimerEvents [ n ] . HasFired ) {
272- i = n ;
273- StatusLabel = "Firing event:" ;
274- while ( i < TimerEvents . Count && TimerEvents [ i ] . Time . TotalSeconds == SecondsToGo ) {
275- if ( ! TimerEvents [ i ] . HasFired ) {
276- StatusLabel += " (" + TimerEvents [ i ] . EventType + ") " + TimerEvents [ i ] . Payload ;
277- if ( ! TimerEvents [ i ] . Refire ) { TimerEvents [ i ] . HasFired = true ; }
278- TimerEvents [ i ] . Fire ( ) ;
255+ n = toolStripProgressBar1 . Maximum - SecondsToGo ;
256+ if ( n < 0 ) {
257+ toolStripProgressBar1 . Value = 0 ;
258+ } else {
259+ toolStripProgressBar1 . Value = n ;
260+ }
261+ for ( n = 0 ; n < TimerEvents . Count ; n ++ ) {
262+ if ( TimerEvents [ n ] . Enabled ) {
263+ if ( ( TimerEvents [ n ] . Time . TotalSeconds < SecondsToGo ) && ! TimerEvents [ n ] . HasFired ) {
264+ StatusLabel = "Next Event in " + ( SecondsToGo - TimerEvents [ n ] . Time . TotalSeconds ) + "s: " + TimerEvents [ n ] . Time . ToString ( Shared . TimeFormat ) + " (" + TimerEvents [ n ] . EventType + ") " + TimerEvents [ n ] . Payload ;
265+ i = n + 1 ;
266+ while ( i < TimerEvents . Count && TimerEvents [ i ] . Time . TotalSeconds == TimerEvents [ n ] . Time . TotalSeconds ) {
267+ if ( ! TimerEvents [ i ] . HasFired ) { ExtraSimultaneousEvents ++ ; }
268+ i ++ ;
269+ }
270+ if ( ExtraSimultaneousEvents > 0 ) {
271+ StatusLabel += " +" + ExtraSimultaneousEvents . ToString ( ) ;
272+ }
273+ break ;
274+ } else if ( ( TimerEvents [ n ] . Time . TotalSeconds == SecondsToGo ) && ! TimerEvents [ n ] . HasFired ) {
275+ i = n ;
276+ StatusLabel = "Firing event:" ;
277+ while ( i < TimerEvents . Count && TimerEvents [ i ] . Time . TotalSeconds == SecondsToGo ) {
278+ if ( ! TimerEvents [ i ] . HasFired ) {
279+ StatusLabel += " (" + TimerEvents [ i ] . EventType + ") " + TimerEvents [ i ] . Payload ;
280+ if ( ! TimerEvents [ i ] . Refire ) { TimerEvents [ i ] . HasFired = true ; }
281+ TimerEvents [ i ] . Fire ( ) ;
282+ }
283+ i ++ ;
284+ }
285+ break ;
279286 }
280- i ++ ;
281287 }
282- break ;
283288 }
284- }
285289 lblNextEvent . Text = StatusLabel ;
286290 if ( SecondsToGo <= 0 ) {
287291 timer1 . Stop ( ) ;
0 commit comments