using System;
using System.IO;
namespace Omegasis.SaveAnywhere
{
/// Provides methods for reading and writing the config file.
internal class ConfigUtilities
{
/*********
** Properties
*********/
/// The full path to the mod folder.
private readonly string ModPath;
/*********
** Accessors
*********/
/// The key which saves the game.
public string KeyBinding { get; private set; } = "K";
/*********
** Public methods
*********/
/// Construct an instance.
/// The full path to the mod folder.
public ConfigUtilities(string modPath)
{
this.ModPath = modPath;
}
/// Load the configuration settings.
public void LoadConfig()
{
string path = Path.Combine(this.ModPath, "Save_Anywhere_Config.txt");
if (!File.Exists(path))
this.KeyBinding = "K";
else
{
string[] text = File.ReadAllLines(path);
this.KeyBinding = Convert.ToString(text[3]);
}
}
/// Save the configuration settings.
public void WriteConfig()
{
string path = Path.Combine(this.ModPath, "Save_Anywhere_Config.txt");
string[] text = new string[20];
text[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings.";
text[1] = "====================================================================================";
text[2] = "Key binding for saving anywhere. Press this key to save anywhere!";
text[3] = this.KeyBinding;
File.WriteAllLines(path, text);
}
}
}