2022-01-27 20:18:27 +01:00
|
|
|
|
using HarmonyLib;
|
2022-01-27 22:45:13 +01:00
|
|
|
|
using OnlineManager;
|
|
|
|
|
using System;
|
2022-01-27 20:18:27 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TaikoModStuff
|
|
|
|
|
{
|
|
|
|
|
internal class CustomResolution
|
|
|
|
|
{
|
2022-01-27 22:45:13 +01:00
|
|
|
|
// Skip the original method, we're doing magic here
|
|
|
|
|
[HarmonyPatch(typeof(FocusManager), "OnApplicationFocus")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static bool PrefixFocus()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-27 20:18:27 +01:00
|
|
|
|
// Skip the original method, we're doing magic here
|
|
|
|
|
[HarmonyPatch(typeof(FocusManager), "SetScreenType")]
|
|
|
|
|
[HarmonyPrefix]
|
2022-01-27 22:45:13 +01:00
|
|
|
|
static bool PrefixScreenType()
|
2022-01-27 20:18:27 +01:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-27 22:45:13 +01:00
|
|
|
|
[HarmonyPatch(typeof(FocusManager), "OnApplicationFocus")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static void setCustomFocus(bool focusStatus)
|
|
|
|
|
{
|
|
|
|
|
if (focusStatus)
|
|
|
|
|
{
|
|
|
|
|
Traverse focusManager = Traverse.CreateWithType("FocusManager");
|
|
|
|
|
DataConst.ScreenModeType m_typeScreenMode = focusManager.Field<DataConst.ScreenModeType>("m_typeScreenMode").Value;
|
|
|
|
|
int width = 1920;
|
|
|
|
|
int height = 1080;
|
|
|
|
|
int framerate = Plugin.configCustomFramerate.Value;
|
|
|
|
|
|
|
|
|
|
// Namco does typos
|
|
|
|
|
int hegiht = focusManager.Field<int>("hegiht").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 ((int)m_typeScreenMode)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySceneManager.CurrentSceneName == "RankedMatch")
|
|
|
|
|
{
|
|
|
|
|
TaikoSingletonMonoBehaviour<XboxLiveOnlineManager>.Instance.GetNetworkTimeOnApplicationFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-27 20:18:27 +01:00
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-27 22:45:13 +01:00
|
|
|
|
Traverse.CreateWithType("FocusManager").Method("setScreenModeType", new Type[] { typeof(DataConst.ScreenModeType) }, new object[] { (DataConst.ScreenModeType)type }).ToString();
|
2022-01-27 20:18:27 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|