-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BorderlessConfig.cs
50 lines (43 loc) · 1.52 KB
/
BorderlessConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.ComponentModel;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
namespace BorderlessTerraria
{
[Label("$Mods.BorderlessTerraria.Config.Header")]
public class BorderlessConfig : ModConfig
{
public override ConfigScope Mode => ConfigScope.ClientSide;
[Label("$Mods.BorderlessTerraria.Config.BorderlessFullscreen")]
[DefaultValue(true)]
public bool BorderlessFullscreen;
public override void OnLoaded()
{
On.Terraria.Main.BorderedHeight += (orig, height, state) =>
{
if (state) return orig(height, state);
return ModContent.GetInstance<BorderlessConfig>().BorderlessFullscreen ? height : orig(height, state);
};
base.OnLoaded();
Update(BorderlessFullscreen);
}
public override void OnChanged()
{
base.OnChanged();
Update(BorderlessFullscreen);
}
public static void Update(bool borderless)
{
Main.QueueMainThreadAction(() =>
{
Main.SetFullScreen(!borderless);
Main.instance.Window.IsBorderlessEXT = borderless;
if (borderless)
{
Main.SetDisplayMode(Main.displayWidth[Main.numDisplayModes - 1], Main.displayHeight[Main.numDisplayModes - 1], false);
SDL2.SDL.SDL_SetWindowPosition(Main.instance.Window.Handle, 0, 0);
}
});
}
}
}