VPet/VPet-Simulator.Windows/Function/Setting.cs

191 lines
5.3 KiB
C#
Raw Normal View History

2023-01-08 16:57:10 +00:00
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}";
// }
//}
2023-01-10 10:43:32 +00:00
private double zoomlevel = 0;
public double ZoomLevel
2023-01-08 16:57:10 +00:00
{
get
{
2023-01-10 10:43:32 +00:00
if(zoomlevel == 0)
2023-01-08 16:57:10 +00:00
{
2023-01-10 10:43:32 +00:00
var line = FindLine("zoomlevel");
if (line == null)
zoomlevel = 0.5;
else
{
zoomlevel = line.InfoToDouble;
if (zoomlevel < 0.1 || zoomlevel > 8)
{
zoomlevel = 0.5;
}
}
2023-01-08 16:57:10 +00:00
}
2023-01-10 10:43:32 +00:00
return zoomlevel;
2023-01-08 16:57:10 +00:00
}
set
{
2023-01-10 10:43:32 +00:00
FindorAddLine("zoomlevel").InfoToDouble = value;
zoomlevel = value;
2023-01-08 16:57:10 +00:00
}
2023-01-10 10:43:32 +00:00
}
2023-01-08 16:57:10 +00:00
public bool IsFullScreen
{
get => FindLine("fullscreen") != null;
set
{
if (value)
FindorAddLine("fullscreen");
else
RemoveAll("fullscreen");
}
}
/// <summary>
/// 是否启用数据收集 //TODO:判断游戏是否是原版的
/// </summary>
public bool Diagnosis
{
get => !this["diagnosis"].GetBool("disable");
set => this["diagnosis"].SetBool("disable", !value);
}
/// <summary>
/// 是将图片储存到内存
/// </summary>
public bool StoreInMemory
{
get => this["set"].GetBool("storemem");
set => this["set"].SetBool("storemem", value);
}
/// <summary>
2023-01-08 16:57:10 +00:00
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
get => Math.Max(this["diagnosis"].GetInt("interval", 14), 7);
set => this["diagnosis"].SetInt("interval", value);
}
/// <summary>
/// 自动保存频率
/// </summary>
public int AutoSaveInterval
{
get => Math.Max(GetInt("autosave", 7), 0);
set => SetInt("autosave", value);
}
/// <summary>
2023-01-10 10:43:32 +00:00
/// 是否置于顶层
2023-01-08 16:57:10 +00:00
/// </summary>
2023-01-10 10:43:32 +00:00
public bool TopMost
2023-01-08 16:57:10 +00:00
{
2023-01-10 10:43:32 +00:00
get => !GetBool("topmost");
set => SetBool("topmost", !value);
2023-01-08 16:57:10 +00:00
}
/// <summary>
/// 数据收集是否被禁止(当日)
/// </summary>
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());
}
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
public int PressLength
{
get => this["windows"].GetInt("presslength", 500);
set => this["windows"].SetInt("presslength", value);
}
}
}