Skip to content

Commit

Permalink
Fix resolution changing on game load with US scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhentar committed Jan 13, 2017
1 parent 0e33b13 commit 09edd41
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Source/UIScaleFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
using Verse;

namespace ZhentarFix.Source
{
[StaticConstructorOnStartup]
class UIScaleFix
{
static UIScaleFix()
{
var assembly = typeof(GameInitData).Assembly;
var debugCellType = assembly.GetType("Verse.BlackScreenFixer");
if (!DoDetour(debugCellType, typeof(UIScaleFix), "Start")) Log.Error("BlackScreenFixer detour failed");
}

private static bool DoDetour(Type rimworld, Type mod, string method)
{
MethodInfo RimWorld_A = rimworld.GetMethod(method, Detours.UniversalBindingFlags);
MethodInfo ModTest_A = mod.GetMethod(method, Detours.UniversalBindingFlags);
if (!Detours.TryDetourFromToInt(RimWorld_A, ModTest_A))
return false;
return true;
}

private void Start()
{
Screen.SetResolution(Screen.width, Screen.height, Screen.fullScreen);
}
}
}
1 change: 1 addition & 0 deletions ZhentarFix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Compile Include="Source\GaydarFix.cs" />
<Compile Include="Source\PawnRotatorFix.cs" />
<Compile Include="Source\Properties\AssemblyInfo.cs" />
<Compile Include="Source\UIScaleFix.cs" />
<Compile Include="Source\Utils.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 09edd41

Please sign in to comment.