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

385 lines
11 KiB
C#
Raw Normal View History

2023-01-08 16:57:10 +00:00
using LinePutScript;
2023-06-03 21:51:58 +00:00
using LinePutScript.Dictionary;
2023-01-08 16:57:10 +00:00
using System;
2023-04-03 18:11:12 +00:00
using System.Windows;
using VPet_Simulator.Core;
2023-01-08 16:57:10 +00:00
2023-04-01 15:15:50 +00:00
namespace VPet_Simulator.Windows.Interface
2023-01-08 16:57:10 +00:00
{
2023-05-25 18:44:31 +00:00
/// <summary>
/// 游戏设置
/// </summary>
2023-06-03 21:51:58 +00:00
public class Setting : LPS_D
2023-01-08 16:57:10 +00:00
{
2023-05-25 18:44:31 +00:00
/// <summary>
/// 游戏设置
/// </summary>
2023-01-08 16:57:10 +00:00
public Setting(string lps) : base(lps)
{
2023-01-23 17:31:16 +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;
}
}
presslength = this["gameconfig"].GetInt("presslength", 500);
intercycle = this["gameconfig"].GetInt("intercycle", 200);
2023-01-24 06:56:16 +00:00
allowmove = !this["gameconfig"].GetBool("allowmove");
smartmove = this["gameconfig"].GetBool("smartmove");
2023-06-19 14:44:48 +00:00
enablefunction = !this["gameconfig"].GetBool("nofunction");
2023-06-03 21:51:58 +00:00
Statistics = this["statistics"];
2023-01-08 16:57:10 +00:00
}
2023-06-03 21:51:58 +00:00
/// <summary>
/// 统计数据信息
/// </summary>
public ILine Statistics;
2023-01-08 16:57:10 +00:00
//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;
2023-01-23 17:31:16 +00:00
/// <summary>
/// 缩放倍率
/// </summary>
2023-01-10 10:43:32 +00:00
public double ZoomLevel
2023-01-08 16:57:10 +00:00
{
get
{
2023-01-23 17:31:16 +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-23 17:31:16 +00:00
}
/// <summary>
2023-05-25 17:50:38 +00:00
/// 播放声音大小
/// </summary>
public double VoiceVolume
{
get => GetFloat("voicevolume", 0.5);
set => SetFloat("voicevolume", value);
}
/// <summary>
2023-01-23 17:31:16 +00:00
/// 是否为更大的屏幕
/// </summary>
public bool IsBiggerScreen
2023-01-08 16:57:10 +00:00
{
2023-01-23 17:31:16 +00:00
get => GetBool("bigscreen");
set => SetBool("bigscreen", value);
2023-01-08 16:57:10 +00:00
}
/// <summary>
/// 是否启用数据收集 //TODO:判断游戏是否是原版的
/// </summary>
public bool Diagnosis
{
get => !this["diagnosis"].GetBool("disable");
set => this["diagnosis"].SetBool("disable", !value);
}
2023-01-22 17:33:13 +00:00
///// <summary> //经过测试,储存到内存好处多多,不储存也要占用很多内存,干脆存了吧
///// 是将图片储存到内存
///// </summary>
//public bool StoreInMemory
//{
// get => !this["set"].GetBool("storemem");
// set => this["set"].SetBool("storemem", value);
//}
/// <summary>
/// 非计算模式下默认模式
/// </summary>
public GameSave.ModeType CalFunState
{
get => (GameSave.ModeType)this[(gint)"calfunstate"];
set => this[(gint)"calfunstate"] = (int)value;
}
/// <summary>
2023-01-08 16:57:10 +00:00
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
2023-01-23 17:31:16 +00:00
get => Math.Max(this["diagnosis"].GetInt("interval", 500), 20000);
2023-01-08 16:57:10 +00:00
set => this["diagnosis"].SetInt("interval", value);
}
/// <summary>
2023-01-23 17:31:16 +00:00
/// 自动保存频率 (min)
2023-01-08 16:57:10 +00:00
/// </summary>
public int AutoSaveInterval
{
2023-01-23 17:31:16 +00:00
get => Math.Max(GetInt("autosave", 20), 0);
2023-01-08 16:57:10 +00:00
set => SetInt("autosave", value);
}
/// <summary>
2023-06-23 13:15:57 +00:00
/// 备份保存最大数量
/// </summary>
public int BackupSaveMaxNum
{
get => Math.Max(GetInt("bakupsave", 20), 1);
set => SetInt("bakupsave", 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>
2023-07-03 11:41:16 +00:00
/// 是否显示宠物帮助窗口
/// </summary>
public bool PetHelper
{
get => GetBool("pethelper");
set => SetBool("pethelper", value);
}
/// <summary>
/// 是否鼠标穿透
/// </summary>
public bool HitThrough
{
get => GetBool("hitthrough");
set => SetBool("hitthrough", value);
}
/// <summary>
2023-06-16 03:39:29 +00:00
/// 上次清理缓存日期
/// </summary>
public DateTime LastCacheDate
{
get => GetDateTime("lastcachedate", DateTime.MinValue);
set => SetDateTime("lastcachedate", value);
}
/// <summary>
2023-01-08 16:57:10 +00:00
/// 数据收集是否被禁止(当日)
/// </summary>
public bool DiagnosisDayEnable = true;
2023-07-01 07:46:08 +00:00
/// <summary>
/// 语言
/// </summary>
public string Language
{
get => GetString("language", "null");
set => this[(gstr)"language"] = value;
}
2023-01-08 16:57:10 +00:00
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;
}
}
2023-01-23 17:31:16 +00:00
private int presslength;
private int intercycle;
2023-01-08 16:57:10 +00:00
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
public int PressLength
{
2023-01-23 17:31:16 +00:00
get => presslength;
2023-03-10 14:37:45 +00:00
set
{
presslength = value;
this["gameconfig"].SetInt("presslength", value);
}
2023-01-23 17:31:16 +00:00
}
/// <summary>
/// 互动周期
/// </summary>
public int InteractionCycle
{
get => intercycle;
2023-03-10 14:37:45 +00:00
set
{
intercycle = value;
this["gameconfig"].SetInt("intercycle", value);
}
2023-01-23 17:31:16 +00:00
}
/// <summary>
/// 计算间隔
/// </summary>
public double LogicInterval
{
get => this["gameconfig"].GetDouble("logicinterval", 15);
set => this["gameconfig"].SetDouble("logicinterval", value);
}
2023-07-03 11:41:16 +00:00
/// <summary>
/// 计算间隔
/// </summary>
public double PetHelpLeft
{
get => this["pethelp"].GetFloat("left", 0);
set => this["pethelp"].SetFloat("left", value);
}
/// <summary>
/// 计算间隔
/// </summary>
public double PetHelpTop
{
get => this["pethelp"].GetFloat("top", 0);
set => this["pethelp"].SetFloat("top", value);
}
2023-01-24 06:56:16 +00:00
bool allowmove;
2023-01-23 17:31:16 +00:00
/// <summary>
/// 允许移动事件
/// </summary>
2023-01-24 06:56:16 +00:00
public bool AllowMove
2023-01-23 17:31:16 +00:00
{
2023-01-24 06:56:16 +00:00
get => allowmove;
2023-01-23 17:31:16 +00:00
set
{
2023-01-24 06:56:16 +00:00
allowmove = value;
this["gameconfig"].SetBool("allowmove", !value);
2023-01-23 17:31:16 +00:00
}
}
2023-01-24 06:56:16 +00:00
bool smartmove;
2023-01-23 17:31:16 +00:00
/// <summary>
/// 智能移动
/// </summary>
2023-01-24 06:56:16 +00:00
public bool SmartMove
2023-01-23 17:31:16 +00:00
{
2023-01-24 06:56:16 +00:00
get => smartmove;
2023-01-23 17:31:16 +00:00
set
{
2023-01-24 06:56:16 +00:00
smartmove = value;
this["gameconfig"].SetBool("smartmove", value);
2023-01-23 17:31:16 +00:00
}
}
bool enablefunction;
/// <summary>
2023-01-24 06:56:16 +00:00
/// 启用计算等数据功能
2023-01-23 17:31:16 +00:00
/// </summary>
public bool EnableFunction
{
get => enablefunction;
set
{
enablefunction = value;
2023-06-19 14:44:48 +00:00
this["gameconfig"].SetBool("nofunction", !value);
2023-01-23 17:31:16 +00:00
}
2023-01-08 16:57:10 +00:00
}
2023-01-24 06:56:16 +00:00
/// <summary>
/// 智能移动周期 (秒)
/// </summary>
public int SmartMoveInterval
{
2023-02-17 05:33:46 +00:00
get => this["gameconfig"].GetInt("smartmoveinterval", 20 * 60);
2023-01-24 06:56:16 +00:00
set => this["gameconfig"].SetInt("smartmoveinterval", value);
}
2023-02-17 05:33:46 +00:00
/// <summary>
2023-05-30 16:51:17 +00:00
/// 消息框外置
/// </summary>
public bool MessageBarOutside
{
get => this["gameconfig"].GetBool("msgbarout");
set => this["gameconfig"].SetBool("msgbarout", value);
}
/// <summary>
2023-02-17 05:33:46 +00:00
/// 开机启动
/// </summary>
public bool StartUPBoot
{
get => this["gameconfig"].GetBool("startboot");
set => this["gameconfig"].SetBool("startboot", value);
}
/// <summary>
/// 开机启动 Steam
/// </summary>
public bool StartUPBootSteam
{
get => !this["gameconfig"].GetBool("startbootsteam");
set => this["gameconfig"].SetBool("startbootsteam", !value);
}
2023-02-18 02:46:08 +00:00
/// <summary>
/// 桌宠选择内容
/// </summary>
public string PetGraph
{
get => this["gameconfig"].GetString("petgraph", "默认虚拟桌宠");
set => this["gameconfig"].SetString("petgraph", value);
}
2023-04-03 18:11:12 +00:00
/// <summary>
/// 是否记录游戏退出位置 (默认:是)
/// </summary>
public bool StartRecordLast
{
get => !this["gameconfig"].GetBool("startboot");
set => this["gameconfig"].SetBool("startboot", !value);
}
/// <summary>
/// 记录上次退出位置
/// </summary>
public Point StartRecordLastPoint
{
get
{
var line = FindLine("startrecordlast");
if (line == null)
return new Point();
return new Point(line.GetDouble("x", 0), line.GetDouble("y", 0));
}
set
{
var line = FindorAddLine("startrecordlast");
line.SetDouble("x", value.X);
line.SetDouble("y", value.Y);
}
}
/// <summary>
/// 设置中桌宠启动的位置
/// </summary>
public Point StartRecordPoint
{
get
{
var line = FindLine("startrecord");
if (line == null)
return StartRecordLastPoint;
return new Point(line.GetDouble("x", 0), line.GetDouble("y", 0));
}
set
{
var line = FindorAddLine("startrecord");
line.SetDouble("x", value.X);
line.SetDouble("y", value.Y);
}
}
2023-01-08 16:57:10 +00:00
}
}