feat: Custom resolutions
This commit is contained in:
parent
a215cce554
commit
85333dda4c
2
.gitignore
vendored
2
.gitignore
vendored
@ -363,4 +363,4 @@ MigrationBackup/
|
||||
FodyWeavers.xsd
|
||||
|
||||
# Ignore game data
|
||||
lib/Assembly-CSharp.dll
|
||||
lib/*.dll
|
52
CustomResolution.cs
Normal file
52
CustomResolution.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
21
Plugin.cs
21
Plugin.cs
@ -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!");
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user