Skip to content

Commit

Permalink
Misc: Share injection methods between Text & Browser overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Sep 5, 2022
1 parent 1baf226 commit 8d22fcf
Show file tree
Hide file tree
Showing 28 changed files with 233 additions and 722 deletions.
11 changes: 11 additions & 0 deletions osu!StreamCompanion.sln
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "X32ProcessHelper", "plugins
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ingameOverlays", "ingameOverlays", "{7BCF111B-5AC0-4E5F-9C97-B0980C32481F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Overlay.Common", "plugins\IngameOverlays\Overlay.Common\Overlay.Common.csproj", "{9AE2BF2B-BA42-4551-B553-D11039644B05}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -355,6 +357,14 @@ Global
{2CD73747-6AC0-480E-8128-4310DF941A6B}.Debug|x86.ActiveCfg = Debug|Win32
{2CD73747-6AC0-480E-8128-4310DF941A6B}.Release|Any CPU.ActiveCfg = Release|Win32
{2CD73747-6AC0-480E-8128-4310DF941A6B}.Release|x86.ActiveCfg = Release|Win32
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Debug|x86.ActiveCfg = Debug|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Debug|x86.Build.0 = Debug|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Release|Any CPU.Build.0 = Release|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Release|x86.ActiveCfg = Release|Any CPU
{9AE2BF2B-BA42-4551-B553-D11039644B05}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -389,6 +399,7 @@ Global
{82B1293E-ED50-4CE7-9EFF-0F66A63801A1} = {7357CB17-E9D7-493F-BC1B-354F717D7AA3}
{3CA7BE44-68FA-40A9-8809-7BE650EFA335} = {7357CB17-E9D7-493F-BC1B-354F717D7AA3}
{7BCF111B-5AC0-4E5F-9C97-B0980C32481F} = {7357CB17-E9D7-493F-BC1B-354F717D7AA3}
{9AE2BF2B-BA42-4551-B553-D11039644B05} = {7BCF111B-5AC0-4E5F-9C97-B0980C32481F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {90CD718D-2503-4BBC-867D-E8EF9C9DBC77}
Expand Down
12 changes: 2 additions & 10 deletions plugins/IngameOverlays/BrowserOverlay/BrowserIngameOverlay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,17 @@
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>bin\Release_temp\</OutputPath>
</PropertyGroup>
<ItemGroup>
<None Remove="Dlls\X32ProcessOverlayHelper.exe" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StreamCompanionTypes" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<Content Include="Dlls\X32ProcessOverlayHelper.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\StreamCompanion.Common\StreamCompanion.Common.csproj" />
<ProjectReference Include="..\Overlay.Common\Overlay.Common.csproj" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="mkdir &quot;$(TargetDir)\..\$(ConfigurationName)&quot;&#xD;&#xA;mkdir &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot;&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)\BrowserIngameOverlay.dll&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(TargetDir)\BrowserIngameOverlay.pdb&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(TargetDir)\Dlls\X32ProcessOverlayHelper.exe&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\&quot;&#xD;&#xA;&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;mkdir &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\Dlls&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot; &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot; &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\Dlls\&quot;&#xD;&#xA;) ELSE (&#xD;&#xA;mkdir &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\Dlls&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot; &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot; &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\Dlls\&quot;&#xD;&#xA;)" />
<Exec Command="mkdir &quot;$(TargetDir)\..\$(ConfigurationName)&quot;&#xD;&#xA;mkdir &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot;&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)\BrowserIngameOverlay.*&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(TargetDir)\Overlay.Common.*&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\&quot;&#xD;&#xA;copy &quot;$(TargetDir)\Dlls\*&quot; &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\&quot;&#xD;&#xA;&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;mkdir &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\Dlls&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot; &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot; &quot;$(SolutionDir)\build\$(ConfigurationName)\Plugins\Dlls\&quot;&#xD;&#xA;) ELSE (&#xD;&#xA;mkdir &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\Dlls&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\*&quot; &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\&quot;&#xD;&#xA;copy /Y &quot;$(TargetDir)\..\$(ConfigurationName)\Dlls\*&quot; &quot;$(SolutionDir)\build\Release_browserOverlay\Plugins\Dlls\&quot;&#xD;&#xA;)" />
</Target>
</Project>
27 changes: 18 additions & 9 deletions plugins/IngameOverlays/BrowserOverlay/BrowserOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using BrowserOverlay.Loader;
using Newtonsoft.Json;
using Overlay.Common;
using Overlay.Common.Loader;
using StreamCompanion.Common;
using StreamCompanionTypes;
using StreamCompanionTypes.DataTypes;
using StreamCompanionTypes.Enums;
using StreamCompanionTypes.Interfaces;
Expand Down Expand Up @@ -149,16 +149,25 @@ private async Task Initialize()
return;
}

//Check one of the files included in overlay assets
_loaderWatchdog = new LoaderWatchdog(_logger, GetFullDllLocation(_saver))
{
InjectionProgressReporter = new Progress<string>(s => _logger.Log(s, LogLevel.Debug))
};
//_loaderWatchdog.BeforeInjection += async (_, __) => await DownloadAndUnpackOverlay(zipFileLocation, assetsLocation);
_ = _loaderWatchdog.WatchForProcessStart(CancellationToken.None).HandleExceptions();
_loaderWatchdog = new LoaderWatchdog(_logger, GetFullDllLocation(_saver), new Progress<string>(s => _logger.Log(s, LogLevel.Debug)));
_ = _loaderWatchdog.WatchForProcessStart(CancellationToken.None, new Progress<OverlayReport>(HandleOverlayReport)).HandleExceptions();
return;
}

private void HandleOverlayReport(OverlayReport report)
{
const string messageBoxTitle = "StreamCompanion - Browser overlay";
switch (report.ReportType)
{
case ReportType.Information:
MessageBox.Show(report.Message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
case ReportType.Error:
MessageBox.Show(report.Message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
}

private async Task<bool> DownloadAndUnpackOverlay(string zipFileLocation, string assetsLocation)
{
_overlayDownloadForm = new OverlayDownload();
Expand Down
203 changes: 0 additions & 203 deletions plugins/IngameOverlays/BrowserOverlay/Loader/DllInjector.cs

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/IngameOverlays/BrowserOverlay/Loader/InjectionResult.cs

This file was deleted.

Loading

0 comments on commit 8d22fcf

Please sign in to comment.