Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
automatic screenshots when leaving colo combat state unexpectedly
Browse files Browse the repository at this point in the history
  • Loading branch information
MgAl2O4 committed Feb 12, 2021
1 parent 03a6053 commit 637b9a8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
39 changes: 34 additions & 5 deletions SINoCOLO/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -130,6 +130,8 @@ public void OnScan()
state = EState.Unknown;
OnStateChanged();

unknownStateStartTime = DateTime.Now;

/*if (prevState == EState.MessageBox)
{
OnSaveScreenshot?.Invoke();
Expand All @@ -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();
}
}
}
}

Expand Down Expand Up @@ -247,7 +260,14 @@ public void AppendDetails(List<string> 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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 &&
Expand All @@ -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)
Expand Down Expand Up @@ -896,6 +922,7 @@ private bool OnScan_Combat(ScannerCombat.ScreenData screenData)
cachedDataColoPurify = null;
cachedDataMessageBox = null;
waitingForCombat = false;
useDebugScreenshotOnUnknown = false;
}

cachedDataCombat = screenData;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion SINoCOLO/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 637b9a8

Please sign in to comment.