34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Godot;
|
|
|
|
public class Utils {
|
|
public static void ToggleFullscreen(bool on, List<string> settings)
|
|
{
|
|
if (IsMobile()) return;
|
|
DisplayServer.WindowSetMode(on ? DisplayServer.WindowMode.Fullscreen : DisplayServer.WindowMode.Maximized);
|
|
|
|
string vsync = settings.ElementAtOrDefault(1) ?? "1";
|
|
ToggleVSync(vsync == "1");
|
|
}
|
|
|
|
public static void ToggleFullscreen(bool on)
|
|
{
|
|
List<string> settings = LoadSettings();
|
|
ToggleFullscreen(on, settings);
|
|
}
|
|
|
|
public static void ToggleVSync(bool on)
|
|
{
|
|
if (!IsMobile()) DisplayServer.WindowSetVsyncMode(on ? DisplayServer.VSyncMode.Enabled : DisplayServer.VSyncMode.Disabled);
|
|
}
|
|
|
|
public static List<string> LoadSettings() {
|
|
string value = BazookaManager.Read(BazookaManager.Settings, "");
|
|
List<string> values = [.. value.Split(':')];
|
|
return values;
|
|
}
|
|
|
|
public static bool IsMobile() => OS.GetName() == "iOS" || OS.GetName() == "Android";
|
|
}
|