2021-04-23 21:08:37 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-04-25 02:07:37 +02:00
|
|
|
using System.IO;
|
2021-04-23 21:08:37 +02:00
|
|
|
|
|
|
|
|
namespace EvilSatellites
|
|
|
|
|
{
|
|
|
|
|
public static class GameSettings
|
|
|
|
|
{
|
2021-04-25 02:57:04 +02:00
|
|
|
public static string SettingsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/EvilSatellites";
|
2021-04-25 02:07:37 +02:00
|
|
|
public static string SettingsFile = SettingsDirectory + "/settings.dat";
|
2021-04-23 21:08:37 +02:00
|
|
|
public static bool PreferSAPI = true;
|
2021-04-24 14:34:15 +02:00
|
|
|
public static bool UseForceFeedback = true;
|
2021-04-24 23:31:43 +02:00
|
|
|
public static bool EnableAI = true;
|
2021-04-25 02:07:37 +02:00
|
|
|
|
|
|
|
|
public static void SaveSettings()
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(SettingsDirectory))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(SettingsDirectory);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var file = new BinaryWriter(File.Open(SettingsFile, FileMode.Create));
|
|
|
|
|
file.Write(PreferSAPI);
|
|
|
|
|
file.Write(UseForceFeedback);
|
|
|
|
|
file.Write(EnableAI);
|
|
|
|
|
file.Close();
|
|
|
|
|
} catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
DavyKager.Tolk.Output("Error saving settings: " + e.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ReadSettings()
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(SettingsDirectory))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!File.Exists(SettingsFile))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var file = new BinaryReader(File.OpenRead(SettingsFile));
|
|
|
|
|
PreferSAPI = file.ReadBoolean();
|
|
|
|
|
UseForceFeedback = file.ReadBoolean();
|
|
|
|
|
EnableAI = file.ReadBoolean();
|
|
|
|
|
file.Close();
|
|
|
|
|
} catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-04-23 21:08:37 +02:00
|
|
|
}
|
|
|
|
|
}
|