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) { var line = FindLine("zoomlevel"); if (line == null) zoomlevel = 0.5; else { zoomlevel = line.InfoToDouble; if (zoomlevel < 0.1 || zoomlevel > 8) { zoomlevel = 0.5; } } presslength = this["gameconfig"].GetInt("presslength", 500); intercycle = this["gameconfig"].GetInt("intercycle", 200); allowmove = !this["gameconfig"].GetBool("allowmove"); smartmove = this["gameconfig"].GetBool("smartmove"); enablefunction = !this["gameconfig"].GetBool("enablefunction"); } 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 { return zoomlevel; } set { FindorAddLine("zoomlevel").InfoToDouble = value; zoomlevel = value; } } /// /// 是否为更大的屏幕 /// public bool IsBiggerScreen { get => GetBool("bigscreen"); set => SetBool("bigscreen", value); } /// /// 是否启用数据收集 //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", 500), 20000); set => this["diagnosis"].SetInt("interval", value); } /// /// 自动保存频率 (min) /// public int AutoSaveInterval { get => Math.Max(GetInt("autosave", 20), 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()); } private int presslength; private int intercycle; /// /// 按多久视为长按 单位毫秒 /// public int PressLength { get => presslength; set => this["gameconfig"].SetInt("presslength", value); } /// /// 互动周期 /// public int InteractionCycle { get => intercycle; set => this["gameconfig"].SetInt("intercycle", value); } /// /// 计算间隔 /// public double LogicInterval { get => this["gameconfig"].GetDouble("logicinterval", 15); set => this["gameconfig"].SetDouble("logicinterval", value); } bool allowmove; /// /// 允许移动事件 /// public bool AllowMove { get => allowmove; set { allowmove = value; this["gameconfig"].SetBool("allowmove", !value); } } bool smartmove; /// /// 智能移动 /// public bool SmartMove { get => smartmove; set { smartmove = value; this["gameconfig"].SetBool("smartmove", value); } } bool enablefunction; /// /// 启用计算等数据功能 /// public bool EnableFunction { get => enablefunction; set { enablefunction = value; this["gameconfig"].SetBool("function", !value); } } /// /// 智能移动周期 (秒) /// public int SmartMoveInterval { get => this["gameconfig"].GetInt("smartmoveinterval", 20*60); set => this["gameconfig"].SetInt("smartmoveinterval", value); } } }