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

Commit

Permalink
added debug screenshot on right click, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
MgAl2O4 committed Jan 1, 2021
1 parent 4e9169d commit a207f89
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
19 changes: 7 additions & 12 deletions SINoCOLO/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class MainForm : Form
private List<ScannerBase> scanners = new List<ScannerBase>();
private ScreenReader screenReader = new ScreenReader();
private GameLogic gameLogic = new GameLogic();
private Bitmap cachedSourceScreen = null;
private bool hasDetailCtrl = true;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
Expand Down Expand Up @@ -68,11 +69,9 @@ private void Scan()
{
//if (screenReader.GetState() != ScreenReader.EState.WindowTooSmall)
{
#if DEBUG
try { srcScreenshot.Save("source.jpg"); }
catch (Exception ex) { Console.WriteLine("Failed to safe source image! {0}", ex); }
#endif // DEBUG

if (cachedSourceScreen != null) { cachedSourceScreen.Dispose(); }
cachedSourceScreen = srcScreenshot.Clone(new Rectangle(0, 0, srcScreenshot.Width, srcScreenshot.Height), srcScreenshot.PixelFormat);

var forcedSize = screenReader.GetExpectedSize();
var fastBitmap = ScreenshotUtilities.ConvertToFastBitmap(srcScreenshot, forcedSize.Width, forcedSize.Height);
foreach (var scanner in scanners)
Expand Down Expand Up @@ -182,25 +181,21 @@ private void pictureBoxAnalyzed_MouseDown(object sender, MouseEventArgs e)
SendMessage(windowHandle.Handle, WM_LBUTTONDOWN, MK_LBUTTON, (IntPtr)lParam);
}
}
#if DEBUG
else if (e.Button == MouseButtons.Right && screenReader.CanSaveScreenshot())
else if (e.Button == MouseButtons.Right)
{
string orgName = "source.jpg";
if (System.IO.File.Exists(orgName))
if (cachedSourceScreen != null)
{
for (int idx = 1; idx < 1000000; idx++)
{
string testPath = "real-source" + idx + ".jpg";
if (!System.IO.File.Exists(testPath))
{
System.IO.File.Copy(orgName, testPath);
screenReader.OnScreenshotSave();
cachedSourceScreen.Save(testPath);
break;
}
}
}
}
#endif // DEBUG
}

private void buttonDetails_Click(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions SINoCOLO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: AssemblyVersion("8.0.0.0")]
[assembly: AssemblyFileVersion("8.0.0.0")]
37 changes: 37 additions & 0 deletions SINoCOLO/SINoCOLO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,52 @@
<!-- Code to merge the assemblies into one:setup.exe -->
<UsingTask TaskName="ILMerge.MSBuild.Tasks.ILMerge" AssemblyFile="$(SolutionDir)\packages\ILMerge.MSBuild.Tasks.1.0.0.3\tools\ILMerge.MSBuild.Tasks.dll" />
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" />
</GetAssemblyIdentity>
<ItemGroup>
<MergeAsm Include="$(OutputPath)$(TargetFileName)" />
<MergeAsm Include="$(OutputPath)SINoVision.dll" />
<MergeAsm Include="$(OutputPath)System.Drawing.Common.dll" />
</ItemGroup>
<PropertyGroup>
<MergedAssembly>$(ProjectDir)$(OutDir)SINoCOLO.exe</MergedAssembly>
<Pattern>(\d+)</Pattern>
<In>%(myAssemblyInfo.Version)</In>
<MajorVersion>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern)))</MajorVersion>
<ReleaseZipPath>$(SolutionDir)\releases\release-v$(MajorVersion).zip</ReleaseZipPath>
<ReleaseZipTemp>$(SolutionDir)\releases\temp</ReleaseZipTemp>
</PropertyGroup>
<Message Text="ILMerge @(MergeAsm) -&gt; $(MergedAssembly)" Importance="high" />
<ILMerge InputAssemblies="@(MergeAsm)" OutputFile="$(MergedAssembly)" TargetKind="SameAsPrimaryAssembly" />
<MakeDir Directories="$(ReleaseZipTemp)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ReleaseZipTemp)" />
<Delete Files="$(ReleaseZipPath)" />
<ZipDir ZipFileName="$(ReleaseZipPath)" DirectoryName="$(ReleaseZipTemp)" />
<RemoveDir Directories="$(ReleaseZipTemp)" />
<Message Text="Created $(ReleaseZipPath)" Importance="high" />
</Target>
<UsingTask TaskName="ZipDir" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<ZipFileName ParameterType="System.String" Required="true" />
<DirectoryName ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression.FileSystem" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs"><![CDATA[
try
{
Log.LogMessage(string.Format("Zipping Directory {0} to {1}", DirectoryName, ZipFileName));
ZipFile.CreateFromDirectory( DirectoryName, ZipFileName );
return true;
}
catch(Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
]]></Code>
</Task>
</UsingTask>
</Project>

0 comments on commit a207f89

Please sign in to comment.