Skip to content

Commit

Permalink
Fixed issue that Diablo window could not be found.
Browse files Browse the repository at this point in the history
Fixed issue that filenames for Mobalytics builds were too long.
  • Loading branch information
josdemmers committed Jun 15, 2024
1 parent cbafccc commit 29f3779
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion D4Companion.Services/BuildsManagerMobalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ public void DownloadMobalyticsBuild(string buildUrl)
ConvertBuildVariants(mobalyticsBuild);

// Save
string fileName = mobalyticsBuild.Id.Length > 100 ? mobalyticsBuild.Id.Substring(mobalyticsBuild.Id.Length - 100) : mobalyticsBuild.Id;
Directory.CreateDirectory(@".\Builds\Mobalytics");
using (FileStream stream = File.Create(@$".\Builds\Mobalytics\{mobalyticsBuild.Id}.json"))
using (FileStream stream = File.Create(@$".\Builds\Mobalytics\{fileName}.json"))
{
var options = new JsonSerializerOptions { WriteIndented = true };
JsonSerializer.Serialize(stream, mobalyticsBuild, options);
Expand Down
8 changes: 5 additions & 3 deletions D4Companion.Services/ScreenCaptureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private void UpdateScreen()
processes = Process.GetProcessesByName("firefox");
foreach (Process p in processes)
{
windowHandle = p.MainWindowHandle;
if (p.MainWindowTitle.StartsWith("Screenshot"))
{
windowHandle = p.MainWindowHandle;
break;
}
}
Expand All @@ -169,9 +169,10 @@ private void UpdateScreen()
processes = Process.GetProcessesByName("Diablo IV");
foreach (Process p in processes)
{
// Note: Always set windowHandle, extra check for windows title depends on language.
windowHandle = p.MainWindowHandle;
if (p.MainWindowTitle.StartsWith("Diablo IV"))
{
windowHandle = p.MainWindowHandle;
break;
}
}
Expand All @@ -180,9 +181,9 @@ private void UpdateScreen()
processesGeForceNOW = Process.GetProcessesByName("GeForceNOW");
foreach (Process p in processesGeForceNOW)
{
windowHandle = p.MainWindowHandle;
if (p.MainWindowTitle.Contains("Diablo"))
{
windowHandle = p.MainWindowHandle;
break;
}
}
Expand Down Expand Up @@ -223,6 +224,7 @@ private void UpdateScreen()
else
{
_logger.LogWarning($"{MethodBase.GetCurrentMethod()?.Name}: Invalid windowHandle. Diablo IV processes found: {processes.Length}. Retry in 10 seconds.");
_logger.LogWarning($"{MethodBase.GetCurrentMethod()?.Name}: Invalid windowHandle. Diablo IV (GeForceNOW) processes found: {processesGeForceNOW.Length}. Retry in 10 seconds.");
_delayUpdateScreen = ScreenCaptureConstants.DelayError;
}
}
Expand Down
4 changes: 2 additions & 2 deletions D4Companion/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<FileVersion>3.6.3.0</FileVersion>
<Version>3.6.3.0</Version>
<FileVersion>3.6.4.0</FileVersion>
<Version>3.6.4.0</Version>
<Copyright>Copyright © 2024</Copyright>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
Expand Down

0 comments on commit 29f3779

Please sign in to comment.