1
0
mirror of synced 2025-02-17 10:38:32 +01:00
TaikoModStuff/CustomResolution.cs
2022-01-27 12:18:27 -07:00

53 lines
1.8 KiB
C#

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);
}
}
}