using System;
using System.IO;

namespace LauncherIcarus.Daemon
{
    public class FileConfig
    {
        private string AccountSetting = nameof(AccountSetting);
        private string LauncherVersionSetting = nameof(LauncherVersionSetting);
        private string RedistInstall = nameof(RedistInstall);
        private string Language = nameof(Language);

        public void SetUsername(string Username) =>
            File.WriteAllText(this.AccountSetting, Username + Environment.NewLine);

        public string GetUsername() => File.Exists(this.AccountSetting)
            ? File.ReadAllText(this.AccountSetting).Replace("\r\n", string.Empty)
            : "";

        public void SetLauncherIsChecked(string text) =>
            File.WriteAllText(this.LauncherVersionSetting, text + Environment.NewLine);

        public string GetLauncherIsChecked() => File.Exists(this.LauncherVersionSetting)
            ? File.ReadAllText(this.LauncherVersionSetting).Replace("\r\n", string.Empty)
            : "FALSE";

        public void SetRedistIsInstaled() => File.WriteAllText(this.RedistInstall, "TRUE");

        public void SetLanguage(string text) => File.WriteAllText(this.Language, text + Environment.NewLine);

        public string GetLanguage() => File.Exists(this.Language)
            ? File.ReadAllText(this.Language).Replace("\r\n", string.Empty)
            : "";
    }
}