forked from julianperrott/WowClassicGrindBot
-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoreTests: Added Test_MinimapNodeFinder
- Loading branch information
Showing
5 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
|
||
using Core; | ||
|
||
using Game; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
#pragma warning disable 0162 | ||
#pragma warning disable 8618 | ||
|
||
#nullable enable | ||
|
||
namespace CoreTests | ||
{ | ||
internal sealed class Test_MinimapNodeFinder : IDisposable | ||
{ | ||
private const bool saveImage = false; | ||
private const bool LogEachUpdate = false; | ||
|
||
private readonly ILogger logger; | ||
|
||
private readonly WowProcess wowProcess; | ||
private readonly WowScreen wowScreen; | ||
|
||
private readonly MinimapNodeFinder minimapNodeFinder; | ||
|
||
private readonly Stopwatch stopwatch = new(); | ||
|
||
public Test_MinimapNodeFinder(ILogger logger) | ||
{ | ||
this.logger = logger; | ||
|
||
wowProcess = new(); | ||
wowScreen = new(logger, wowProcess); | ||
|
||
minimapNodeFinder = new(logger, wowScreen); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
wowScreen.Dispose(); | ||
wowProcess.Dispose(); | ||
} | ||
|
||
public void Execute() | ||
{ | ||
if (LogEachUpdate) | ||
stopwatch.Restart(); | ||
|
||
wowScreen.UpdateMinimapBitmap(); | ||
|
||
if (LogEachUpdate) | ||
logger.LogInformation($"Capture: {stopwatch.ElapsedMilliseconds}ms"); | ||
|
||
if (LogEachUpdate) | ||
stopwatch.Restart(); | ||
|
||
minimapNodeFinder.Update(); | ||
|
||
if (LogEachUpdate) | ||
logger.LogInformation($"Update: {stopwatch.ElapsedMilliseconds}ms"); | ||
|
||
if (saveImage) | ||
{ | ||
SaveImage(); | ||
} | ||
} | ||
|
||
private void SaveImage() | ||
{ | ||
wowScreen.MiniMapBitmap.Save("minimap.png"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters