using LinePutScript; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace VPet_Simulator.Windows { public class Setting : LpsDocument { public Setting(string lps) : base(lps) { } public void Save() { File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", ToString()); } //public Size WindowsSize //{ // get // { // var line = FindLine("windowssize"); // if (line == null) // return new Size(1366, 799); // var strs = line.GetInfos(); // if (int.TryParse(strs[0], out int x)) // x = 1366; // if (int.TryParse(strs[0], out int y)) // y = 799; // return new Size(x, y); // } // set // { // FindorAddLine("windowssize").info = $"{value.Width},{value.Height}"; // } //} private double zoomlevel = 0; public double ZoomLevel { get { if(zoomlevel == 0) { var line = FindLine("zoomlevel"); if (line == null) zoomlevel = 0.5; else { zoomlevel = line.InfoToDouble; if (zoomlevel < 0.1 || zoomlevel > 8) { zoomlevel = 0.5; } } } return zoomlevel; } set { FindorAddLine("zoomlevel").InfoToDouble = value; zoomlevel = value; } } public bool IsFullScreen { get => FindLine("fullscreen") != null; set { if (value) FindorAddLine("fullscreen"); else RemoveAll("fullscreen"); } } /// /// 是否启用数据收集 //TODO:判断游戏是否是原版的 /// public bool Diagnosis { get => !this["diagnosis"].GetBool("disable"); set => this["diagnosis"].SetBool("disable", !value); } /// /// 是将图片储存到内存 /// public bool StoreInMemory { get => this["set"].GetBool("storemem"); set => this["set"].SetBool("storemem", value); } /// /// 数据收集频率 /// public int DiagnosisInterval { get => Math.Max(this["diagnosis"].GetInt("interval", 14), 7); set => this["diagnosis"].SetInt("interval", value); } /// /// 自动保存频率 /// public int AutoSaveInterval { get => Math.Max(GetInt("autosave", 7), 0); set => SetInt("autosave", value); } /// /// 是否置于顶层 /// public bool TopMost { get => !GetBool("topmost"); set => SetBool("topmost", !value); } /// /// 数据收集是否被禁止(当日) /// public bool DiagnosisDayEnable = true; public string Font { get => GetString("font", "OPPOSans R"); set => this[(gstr)"font"] = value; } public string Theme { get { var line = FindLine("theme"); if (line == null) return "default"; return line.Info; } set { FindorAddLine("theme").Info = value; } } public bool IsBanMod(string ModName) { var line = FindLine("banmod"); if (line == null) return false; return line.Find(ModName.ToLower()) != null; } public bool IsPassMOD(string ModName) { var line = FindLine("passmod"); if (line == null) return false; return line.Find(ModName.ToLower()) != null; } public void BanMod(string ModName) { if (string.IsNullOrWhiteSpace(ModName)) return; FindorAddLine("banmod").AddorReplaceSub(new Sub(ModName.ToLower())); } public void BanModRemove(string ModName) { FindorAddLine("banmod").Remove(ModName.ToLower()); } public void PassMod(string ModName) { FindorAddLine("passmod").AddorReplaceSub(new Sub(ModName.ToLower())); } public void PassModRemove(string ModName) { FindorAddLine("passmod").Remove(ModName.ToLower()); } /// /// 按多久视为长按 单位毫秒 /// public int PressLength { get => this["windows"].GetInt("presslength", 500); set => this["windows"].SetInt("presslength", value); } } }