Skip to content

Commit

Permalink
Added KKS_Fix_CameraMaskResize - Fix lut color mask in maker not resi…
Browse files Browse the repository at this point in the history
…zing when resolution changes
  • Loading branch information
ManlyMarco committed Jun 2, 2021
1 parent 36413b0 commit cda670c
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
10 changes: 10 additions & 0 deletions IllusionFixes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS_Fix_SettingsVerifier",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS_Fix_ManifestCorrector", "src\KKS_Fix_ManifestCorrector\KKS_Fix_ManifestCorrector.csproj", "{2A4BAD8C-B5C8-440D-87AA-BBA45D52DCC9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Fix_CameraMaskResize", "Fix_CameraMaskResize", "{C4C9D0BB-F62D-4CB8-B854-66811D91DDDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS_Fix_CameraMaskResize", "src\KKS_Fix_CameraMaskResize\KKS_Fix_CameraMaskResize.csproj", "{00E09FD0-9862-41B3-BD2C-7094A16C97F7}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Common\Common.projitems*{00e09fd0-9862-41b3-bd2c-7094a16c97f7}*SharedItemsImports = 4
src\Common\Common.projitems*{020992e5-0e49-4b83-a3ce-c5eb990edda7}*SharedItemsImports = 4
src\Core_Fix_InvalidSceneFileProtection\Core_Fix_InvalidSceneFileProtection.projitems*{020992e5-0e49-4b83-a3ce-c5eb990edda7}*SharedItemsImports = 4
src\Common\Common.projitems*{0218b7ff-4cc3-4c9a-8a91-f8db31084499}*SharedItemsImports = 4
Expand Down Expand Up @@ -733,6 +738,10 @@ Global
{2A4BAD8C-B5C8-440D-87AA-BBA45D52DCC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A4BAD8C-B5C8-440D-87AA-BBA45D52DCC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A4BAD8C-B5C8-440D-87AA-BBA45D52DCC9}.Release|Any CPU.Build.0 = Release|Any CPU
{00E09FD0-9862-41B3-BD2C-7094A16C97F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E09FD0-9862-41B3-BD2C-7094A16C97F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E09FD0-9862-41B3-BD2C-7094A16C97F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E09FD0-9862-41B3-BD2C-7094A16C97F7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -819,6 +828,7 @@ Global
{1B72F174-4CCB-4A7F-B406-3940A025E126} = {79E75B3B-B01C-4D21-8C4A-F4C94418A2C1}
{741BE318-D645-406C-AC01-E6FB29A5C0AF} = {A1C7C084-38B0-48BD-90C6-572EB94001AB}
{2A4BAD8C-B5C8-440D-87AA-BBA45D52DCC9} = {3E501D49-3E6E-4C9C-8575-52F719A1A5CC}
{00E09FD0-9862-41B3-BD2C-7094A16C97F7} = {C4C9D0BB-F62D-4CB8-B854-66811D91DDDB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3F10C8B-FD6C-43DA-94B4-1D9688BBE11B}
Expand Down
48 changes: 48 additions & 0 deletions src/KKS_Fix_CameraMaskResize/CameraMaskResizeFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using BepInEx;
using BepInEx.Logging;
using Common;
using HarmonyLib;
using UnityEngine;

namespace IllusionFixes
{
[BepInProcess(Constants.GameProcessName)]
[BepInPlugin(GUID, PluginName, Constants.PluginsVersion)]
public class CameraMaskResizeFix : BaseUnityPlugin //todo add an EC version
{
public const string GUID = "Fix_CameraMaskResize";
public const string PluginName = "Fix camera color mask not resizing";
internal static new ManualLogSource Logger;

private void Awake()
{
Logger = base.Logger;

Harmony.CreateAndPatchAll(typeof(Hooks), GUID);
}

internal static class Hooks
{
private static int _lastWidth;

[HarmonyPrefix]
[HarmonyPatch(typeof(CameraEffectorColorMask), nameof(CameraEffectorColorMask.Update))]
internal static void LoadCharaFbxDataAsync(CameraEffectorColorMask __instance)
{
var width = Screen.width;
if (_lastWidth != width)
{
if (_lastWidth != 0) // First run assume the size is correct
{
Logger.LogDebug($"Adjusting CameraEffectorColorMask targetTexture size because screen width changed from {_lastWidth} to {width}");
var newRt = new RenderTexture(width, Screen.height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
Destroy(__instance.myCamera.targetTexture);
__instance.myCamera.targetTexture = newRt;
__instance.amplifyColorEffect.MaskTexture = newRt;
}
_lastWidth = width;
}
}
}
}
}
89 changes: 89 additions & 0 deletions src/KKS_Fix_CameraMaskResize/KKS_Fix_CameraMaskResize.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{00E09FD0-9862-41B3-BD2C-7094A16C97F7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IllusionFixes</RootNamespace>
<AssemblyName>KKS_Fix_CameraMaskResize</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\BepInEx\plugins\IllusionFixes\</OutputPath>
<DefineConstants>TRACE;DEBUG;KKS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>embedded</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\BepInEx\plugins\IllusionFixes\</OutputPath>
<DefineConstants>TRACE;KKS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.3.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\lib\net35\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\lib\net46\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx, Version=5.4.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.BepInEx.5.4.8\lib\net35\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.Harmony, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\lib\net35\BepInEx.Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sirenix.Serialization, Version=2.1.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\Sirenix.Serialization.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CameraMaskResizeFix.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\Common\Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\build\IllusionLibs.BepInEx.Harmony.targets" Condition="Exists('..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\build\IllusionLibs.BepInEx.Harmony.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\build\IllusionLibs.BepInEx.Harmony.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\build\IllusionLibs.BepInEx.Harmony.targets'))" />
<Error Condition="!Exists('..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets'))" />
<Error Condition="!Exists('..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets'))" />
</Target>
<Import Project="..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets" Condition="Exists('..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets')" />
<Import Project="..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets" Condition="Exists('..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets')" />
</Project>
5 changes: 5 additions & 0 deletions src/KKS_Fix_CameraMaskResize/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Reflection;

[assembly: AssemblyTitle(IllusionFixes.CameraMaskResizeFix.GUID)]
[assembly: AssemblyProduct(IllusionFixes.CameraMaskResizeFix.GUID)]
[assembly: AssemblyDescription(IllusionFixes.CameraMaskResizeFix.PluginName)]
8 changes: 8 additions & 0 deletions src/KKS_Fix_CameraMaskResize/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="IllusionLibs.BepInEx" version="5.4.8" targetFramework="net46" />
<package id="IllusionLibs.BepInEx.Harmony" version="2.3.2" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.Assembly-CSharp" version="2021.5.28" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule" version="2019.4.9" targetFramework="net46" />
<package id="ScreenshotManager.KoikatsuSunshine" version="16.3.1" targetFramework="net46" developmentDependency="true" />
</packages>

0 comments on commit cda670c

Please sign in to comment.