1- using System . Drawing ;
1+ using System ;
2+ using System . Drawing ;
23using System . IO ;
34using System . Text . RegularExpressions ;
45using BetterOverwatch . Game ;
@@ -85,23 +86,38 @@ public static void ReadRoleRatings(Bitmap frame)
8586 AppData . gameData . currentRatings . tank = tankRating ;
8687 if ( AppData . settings . outputToTextFiles )
8788 {
88- File . WriteAllText ( "tank.txt" , tankRating . ToString ( ) ) ;
89+ try
90+ {
91+ File . WriteAllText ( "tank.txt" , tankRating . ToString ( ) ) ;
92+ Functions . DebugMessage ( $ "Updated tank.txt with '{ tankRating } '") ;
93+ }
94+ catch ( Exception e ) { Functions . DebugMessage ( $ "Failed to update tank.txt : { e . Message } ") ; }
8995 }
9096 }
9197 if ( damageCheck )
9298 {
9399 AppData . gameData . currentRatings . damage = damageRating ;
94100 if ( AppData . settings . outputToTextFiles )
95101 {
96- File . WriteAllText ( "damage.txt" , damageRating . ToString ( ) ) ;
102+ try
103+ {
104+ File . WriteAllText ( "damage.txt" , damageRating . ToString ( ) ) ;
105+ Functions . DebugMessage ( $ "Updated damage.txt with '{ damageRating } '") ;
106+ }
107+ catch ( Exception e ) { Functions . DebugMessage ( $ "Failed to update damage.txt : { e . Message } ") ; }
97108 }
98109 }
99110 if ( supportCheck )
100111 {
101112 AppData . gameData . currentRatings . support = supportRating ;
102113 if ( AppData . settings . outputToTextFiles )
103114 {
104- File . WriteAllText ( "support.txt" , supportRating . ToString ( ) ) ;
115+ try
116+ {
117+ File . WriteAllText ( "support.txt" , supportRating . ToString ( ) ) ;
118+ Functions . DebugMessage ( $ "Updated support.txt with '{ supportRating } '") ;
119+ }
120+ catch ( Exception e ) { Functions . DebugMessage ( $ "Failed to update support.txt : { e . Message } ") ; }
105121 }
106122 }
107123 AppData . successSound . Play ( ) ;
@@ -173,6 +189,7 @@ public static void ReadStats(Bitmap frame)
173189 }
174190 AppData . gameData . stats . Add ( new Stat ( ( int ) AppData . gameData . gameTimer . Elapsed . TotalSeconds , eliminations , damage , objectiveKills , healing , deaths , heroStats ) ) ;
175191 AppData . statsTimer . Restart ( ) ;
192+ Functions . DebugMessage ( $ "Hero stats recorded after { AppData . gameData . gameTimer . Elapsed . TotalSeconds } seconds") ;
176193 }
177194 }
178195 public static void ReadCompetitiveGameEntered ( Bitmap frame )
@@ -214,7 +231,7 @@ public static void ReadMap(Bitmap frame)
214231 {
215232 AppData . gameData . map = mapText ;
216233 AppData . getInfoTimeout . Restart ( ) ;
217- Functions . DebugMessage ( "Recognized map: '" + mapText + " '") ;
234+ Functions . DebugMessage ( $ "Recognized map: '{ mapText } '") ;
218235 }
219236 }
220237 }
@@ -233,7 +250,7 @@ public static void ReadTeamsSkillRating(Bitmap frame)
233250 if ( int . TryParse ( team1Rating , out int rating ) && rating > 999 && rating < 5000 )
234251 {
235252 AppData . gameData . team1Rating = rating ;
236- Functions . DebugMessage ( "Recognized team 1 SR : '" + team1Rating + " '") ;
253+ Functions . DebugMessage ( $ "Recognized team 1 rating : '{ team1Rating } '") ;
237254 }
238255 }
239256 }
@@ -249,7 +266,7 @@ public static void ReadTeamsSkillRating(Bitmap frame)
249266 if ( int . TryParse ( team2Rating , out int rating ) && rating > 999 && rating < 5000 )
250267 {
251268 AppData . gameData . team2Rating = rating ;
252- Functions . DebugMessage ( "Recognized team 2 SR : '" + team2Rating + " '") ;
269+ Functions . DebugMessage ( $ "Recognized team 2 rating : '{ team2Rating } '") ;
253270 }
254271 }
255272 }
@@ -302,6 +319,7 @@ public static bool ReadHeroPlayed(Bitmap frame)
302319 }
303320 AppData . gameData . heroTimer . Restart ( ) ;
304321 AppData . gameData . heroesPlayed . Add ( new HeroPlayed ( Constants . heroList [ h ] . name , ( int ) AppData . gameData . gameTimer . Elapsed . TotalSeconds ) ) ;
322+ Functions . DebugMessage ( $ "Now playing hero { Constants . heroList [ h ] . name } at { AppData . gameData . gameTimer . Elapsed . TotalSeconds } seconds") ;
305323 return true ;
306324 }
307325 }
@@ -310,20 +328,20 @@ public static bool ReadHeroPlayed(Bitmap frame)
310328 }
311329 public static void ReadRoundCompleted ( Bitmap frame )
312330 {
313- string roundCompletedText = Functions . BitmapToText ( frame , 940 , 160 , 290 , 76 ) ;
331+ string roundCompletedText = Functions . BitmapToText ( frame , 940 , 160 , 290 , 80 ) ;
314332
315- if ( ! roundCompletedText . Equals ( string . Empty ) )
333+ if ( roundCompletedText != string . Empty && Functions . CompareStrings ( roundCompletedText , "COMPLETE" ) >= 70 )
316334 {
317- if ( Functions . CompareStrings ( roundCompletedText , "COMPLETED" ) >= 70 )
335+ if ( AppData . gameData . heroesPlayed . Count > 0 )
318336 {
319337 AppData . gameData . heroesPlayed [ AppData . gameData . heroesPlayed . Count - 1 ] . time = ( int ) AppData . gameData . heroTimer . Elapsed . TotalSeconds ;
320- //Vars.gameData.heroesPlayed.Add(new HeroPlayed(Vars.gameData.heroesPlayed[Vars.gameData.heroesPlayed.Count - 1].name, (int)Vars.gameData.gameTimer.Elapsed.TotalSeconds));
321- AppData . gameData . state = State . RoundComplete ;
322- AppData . gameData . heroTimer . Stop ( ) ;
323- AppData . gameData . gameTimer . Stop ( ) ;
324- AppData . getInfoTimeout . Restart ( ) ;
325- Functions . DebugMessage ( $ "Recognized round completed") ;
326338 }
339+ //Vars.gameData.heroesPlayed.Add(new HeroPlayed(Vars.gameData.heroesPlayed[Vars.gameData.heroesPlayed.Count - 1].name, (int)Vars.gameData.gameTimer.Elapsed.TotalSeconds));
340+ AppData . gameData . state = State . RoundComplete ;
341+ AppData . gameData . heroTimer . Stop ( ) ;
342+ AppData . gameData . gameTimer . Stop ( ) ;
343+ AppData . getInfoTimeout . Restart ( ) ;
344+ Functions . DebugMessage ( $ "Recognized round completed") ;
327345 }
328346 }
329347 public static bool ReadRoundStarted ( Bitmap frame )
@@ -412,14 +430,15 @@ public static void ReadPlayerNamesAndRank(Bitmap frame)
412430 playerNameX += 945 ;
413431 playerRankX += 422 ;
414432 }
433+ Functions . DebugMessage ( "Captured player list" ) ;
415434 }
416435 public static bool IsValidGame ( )
417436 {
418- if ( AppData . gameData . timer . Elapsed . TotalSeconds < 300 )
437+ if ( AppData . gameData . timer . Elapsed . TotalSeconds < 300 && ! ScreenCaptureHandler . debug )
419438 {
420439 if ( AppData . gameData . state >= State . Recording )
421440 {
422- Functions . DebugMessage ( "Invalid game" ) ;
441+ Functions . DebugMessage ( $ "Invalid game state= { AppData . gameData . state } gameData.timer= { AppData . gameData . timer . Elapsed . TotalSeconds } ") ;
423442 ScreenCaptureHandler . trayMenu . ChangeTray ( "Ready to record, enter a competitive game to begin" , Resources . Icon_Active ) ;
424443 }
425444 return false ;
0 commit comments