86 lines
No EOL
2.4 KiB
C#
86 lines
No EOL
2.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEngine.Analytics;
|
|
|
|
namespace GBSU.Addons;
|
|
public class Helper
|
|
{
|
|
public static string RotationFolderPath = BepInEx.Paths.BepInExRootPath + "/config/GBSU/";
|
|
public static string GameConfigPath = RotationFolderPath + "config.json";
|
|
public static string serverip = null;
|
|
public static int serverport = 5999;
|
|
public static bool hosting = false;
|
|
public static float saved_volume;
|
|
public static void DisableAnalytics()
|
|
{
|
|
// Try disabling analytics https://docs.unity3d.com/ScriptReference/Analytics.Analytics-deviceStatsEnabled.html
|
|
try
|
|
{
|
|
Analytics.enabled = false;
|
|
Analytics.deviceStatsEnabled = false;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Plugin.Log.LogWarning("Failed to disable analytics: " + e.Message);
|
|
}
|
|
}
|
|
public static void CreateRotationFolder()
|
|
{
|
|
try
|
|
{
|
|
Plugin.Log.LogInfo("Creating rotation folder at " + RotationFolderPath);
|
|
Directory.CreateDirectory(RotationFolderPath);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Plugin.Log.LogError("Could not create rotation folder path: " + e.Message);
|
|
}
|
|
}
|
|
public static string FilesInRotationDir()
|
|
{
|
|
// https://stackoverflow.com/a/14877330
|
|
DirectoryInfo d = new(RotationFolderPath);
|
|
FileInfo[] files = d.GetFiles();
|
|
int number = files.Length;
|
|
|
|
// no files?
|
|
if (number == 0)
|
|
{
|
|
return @"No files were found in the directory.";
|
|
}
|
|
else
|
|
{
|
|
string names = "";
|
|
|
|
foreach(FileInfo file in files)
|
|
{
|
|
names = file.Name + " " + names;
|
|
}
|
|
|
|
return $"There are {number} files: {names}";
|
|
}
|
|
}
|
|
|
|
public static void FlipVSync()
|
|
{
|
|
if (QualitySettings.vSyncCount == 0)
|
|
{
|
|
QualitySettings.vSyncCount = 1;
|
|
}
|
|
else
|
|
{
|
|
QualitySettings.vSyncCount = 0;
|
|
}
|
|
}
|
|
|
|
public static void CheckCustomRotationPath()
|
|
{
|
|
// Did the host request to use their own rotation config path?
|
|
if (CommandLineParser.Instance.KeyExists("-maplist"))
|
|
{
|
|
GameConfigPath = CommandLineParser.Instance.GetValueForKey("-maplist");
|
|
Plugin.Log.LogInfo("Set custom rotation config path at " + GameConfigPath);
|
|
}
|
|
}
|
|
} |