1
0
mirror of synced 2024-11-12 01:00:48 +01:00

feat: Custom resolutions

This commit is contained in:
Repflez 2022-01-27 12:18:27 -07:00
parent a215cce554
commit 85333dda4c
4 changed files with 78 additions and 1 deletions

2
.gitignore vendored
View File

@ -363,4 +363,4 @@ MigrationBackup/
FodyWeavers.xsd
# Ignore game data
lib/Assembly-CSharp.dll
lib/*.dll

52
CustomResolution.cs Normal file
View File

@ -0,0 +1,52 @@
using HarmonyLib;
using UnityEngine;
namespace TaikoModStuff
{
internal class CustomResolution
{
// Skip the original method, we're doing magic here
[HarmonyPatch(typeof(FocusManager), "SetScreenType")]
[HarmonyPrefix]
static bool Prefix()
{
return false;
}
[HarmonyPatch(typeof(FocusManager), "SetScreenType")]
[HarmonyPrefix]
static void setCustomResolution(int type)
{
int width = 1920;
int height = 1080;
int framerate = Plugin.configCustomFramerate.Value;
if (Plugin.configCustomWindowedWidth.Value > 0) {
width = Plugin.configCustomWindowedWidth.Value;
// Set custom height if the width is set first
if (Plugin.configCustomWindowedHeight.Value > 0) {
height = Plugin.configCustomWindowedHeight.Value;
}
}
switch (type) {
case 1: // Borderless
Screen.fullScreen = true;
Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow, framerate);
break;
case 2: // Windowed
Screen.fullScreen = false;
Screen.SetResolution(width, height, FullScreenMode.Windowed, framerate);
break;
default: // Fullscreen
Screen.fullScreen = true;
Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow, framerate);
break;
}
// TODO: Fix this
Traverse.CreateWithType("FocusManager").Field("m_typeScreenMode").SetValue((DataConst.ScreenModeType)type);
}
}
}

View File

@ -9,6 +9,11 @@ namespace TaikoModStuff
{
public static ConfigEntry<bool> configForceFontChange;
public static ConfigEntry<int> configCustomWindowedWidth;
public static ConfigEntry<int> configCustomWindowedHeight;
public static ConfigEntry<int> configCustomFramerate;
private void Awake()
{
// Add configurations
@ -17,8 +22,24 @@ namespace TaikoModStuff
false,
"Force the game font to the JP font");
configCustomWindowedWidth = Config.Bind("General.Resolution",
"CustomWidth",
1920,
"Custom width to use. Set to 0 to disable setting the custom resolution");
configCustomWindowedHeight = Config.Bind("General.Resolution",
"CustomHeight",
1080,
"Custom height to use");
configCustomFramerate = Config.Bind("General.Framerate",
"CustomFramerate",
60,
"Custom framerate. Use with caution");
var instance = new Harmony(PluginInfo.PLUGIN_NAME);
instance.PatchAll(typeof(FontChanger));
instance.PatchAll(typeof(CustomResolution));
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");

View File

@ -25,5 +25,9 @@
<HintPath>lib\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>lib\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
</Project>