From 637b9a875f1a707fb012da8937780e7e14e38fd3 Mon Sep 17 00:00:00 2001 From: MgAl2O4 <51430403+MgAl2O4@users.noreply.github.com> Date: Thu, 11 Feb 2021 21:27:15 -0500 Subject: [PATCH] automatic screenshots when leaving colo combat state unexpectedly --- SINoCOLO/GameLogic.cs | 39 ++++++++++++++++++++++++++++++++++----- SINoCOLO/MainForm.cs | 2 +- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/SINoCOLO/GameLogic.cs b/SINoCOLO/GameLogic.cs index 7182ac3..7ea1625 100644 --- a/SINoCOLO/GameLogic.cs +++ b/SINoCOLO/GameLogic.cs @@ -47,17 +47,17 @@ public enum EUnknownBehavior private float interpActiveFill = 0.0f; private int scanSkipCounter = 0; private int purifySlot = 0; + private int unknownStateScreenshotDelay = 4; private EStoryMode storyMode = EStoryMode.None; private EUnknownBehavior unknownBehavior = EUnknownBehavior.None; private TrackerActionBoost actionBoost = new TrackerActionBoost(); private DateTime lastClickTime; private DateTime lastCombatTime; -#if DEBUG - private DateTime lastScreenshotTime; -#endif // DEBUG + private DateTime unknownStateStartTime; private bool waitingForCombat = false; private bool waitingForCombatReport = false; private bool waitingForEventSummary = false; + private bool useDebugScreenshotOnUnknown = false; private Font overlayFont = new Font(FontFamily.GenericSansSerif, 7.0f); private Color colorPaletteRed = Color.FromArgb(0xff, 0xad, 0xad); @@ -130,6 +130,8 @@ public void OnScan() state = EState.Unknown; OnStateChanged(); + unknownStateStartTime = DateTime.Now; + /*if (prevState == EState.MessageBox) { OnSaveScreenshot?.Invoke(); @@ -155,6 +157,17 @@ public void OnScan() { OnScan_Unknown(); } + + // debug screenshots in unknown state (e.g. colo combat suddenly stopped, probably a demon summon) + if (useDebugScreenshotOnUnknown) + { + var timeSinceEnteringUnknown = DateTime.Now - unknownStateStartTime; + if (timeSinceEnteringUnknown.TotalSeconds > unknownStateScreenshotDelay) + { + useDebugScreenshotOnUnknown = false; + OnSaveScreenshot?.Invoke(); + } + } } } @@ -247,7 +260,14 @@ public void AppendDetails(List lines) state, scanSkipCounter, scanSkipCounter <= 1 ? " (click)" : "")); lines.Add(string.Format("Story:{0}, behavior:{1}, wait(combat:{2}, report:{3})", storyMode, unknownBehavior, waitingForCombat, waitingForCombatReport)); - + if (state == EState.Unknown && useDebugScreenshotOnUnknown) + { + var timeSinceEnteringUnknown = DateTime.Now - unknownStateStartTime; + var timeToScreenshot = unknownStateScreenshotDelay - timeSinceEnteringUnknown.TotalSeconds; + + lines.Add(string.Format("Debug screenshot in:{0:F1}s", timeToScreenshot)); + } + if (cachedDataCombat != null || cachedDataColoCombat != null) { actionBoost.AppendDetails(lines); @@ -290,6 +310,10 @@ private bool OnScan_ColoCombat(ScannerColoCombat.ScreenData screenData) cachedDataColoCombat = screenData; + // ignore that debug screenshots when leaving colo combat state after demon summon finishes + bool canIgnoreDebugScreenshots = (screenData.demonState == ScannerColoCombat.EDemonState.Active); + useDebugScreenshotOnUnknown = !canIgnoreDebugScreenshots; + /*bool canSave = true; if (lastScreenshotTime != null) { @@ -543,6 +567,9 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData) state = EState.ColoPurify; OnStateChanged(); + useDebugScreenshotOnUnknown = false; + cachedDataMessageBox = null; + // when returning to purify state, check if there's burst ready with at least 1 big on screen // enforce longer delay so stuff can spawn back in and be detected if (cachedDataColoPurify != null && @@ -562,7 +589,6 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData) } cachedDataColoPurify = screenData; - cachedDataMessageBox = null; // don't do anything when burst is already active if (screenData.BurstState == ScannerColoPurify.EBurstState.Active) @@ -896,6 +922,7 @@ private bool OnScan_Combat(ScannerCombat.ScreenData screenData) cachedDataColoPurify = null; cachedDataMessageBox = null; waitingForCombat = false; + useDebugScreenshotOnUnknown = false; } cachedDataCombat = screenData; @@ -1054,6 +1081,7 @@ private bool OnScan_TitleScreen(ScannerTitleScreen.ScreenData screenData) scanSkipCounter = 50; // 5s opening delay waitingForCombatReport = false; waitingForCombat = false; + useDebugScreenshotOnUnknown = false; cachedDataCombat = null; cachedDataColoCombat = null; @@ -1101,6 +1129,7 @@ private bool OnScan_Purify(ScannerPurify.ScreenData screenData) waitingForCombat = false; waitingForCombatReport = false; waitingForEventSummary = false; + useDebugScreenshotOnUnknown = false; cachedDataMessageBox = null; purifySlot = randGen.Next(10); diff --git a/SINoCOLO/MainForm.cs b/SINoCOLO/MainForm.cs index 10767a1..b7ad795 100644 --- a/SINoCOLO/MainForm.cs +++ b/SINoCOLO/MainForm.cs @@ -77,7 +77,7 @@ private void GameLogic_OnSaveScreenshot() { for (int idx = 1; idx < 1000000; idx++) { - string testPath = "statcapture-" + idx + ".jpg"; + string testPath = "screenshot-" + idx + ".jpg"; if (!System.IO.File.Exists(testPath)) { cachedSourceScreen.Save(testPath);