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

474 lines
14 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-07-23 20:46:21 +00:00
using System.Collections.ObjectModel;
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-07-23 20:46:21 +00:00
Statistics = new Statistics(this["statistics"].ToList());
2023-08-25 14:49:07 +00:00
autobuy = this["gameconfig"].GetBool("autobuy");
2023-07-23 20:46:21 +00:00
}
public override string ToString()
{
this["statistics"] = new Line("statistics", "", "", Statistics.ToSubs().ToArray());
return base.ToString();
2023-01-08 16:57:10 +00:00
}
2023-06-03 21:51:58 +00:00
/// <summary>
/// 统计数据信息
/// </summary>
2023-07-23 20:46:21 +00:00
public Statistics 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>
2023-08-11 02:47:09 +00:00
/// 是否启用数据收集
2023-01-08 16:57:10 +00:00
/// </summary>
public bool Diagnosis
{
2023-08-11 02:47:09 +00:00
get => this["diagnosis"].GetBool("enable");
set => this["diagnosis"].SetBool("enable", value);
2023-01-08 16:57:10 +00:00
}
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);
}
2023-08-11 02:47:09 +00:00
2023-01-08 16:57:10 +00:00
/// <summary>
2023-01-23 17:31:16 +00:00
/// 自动保存频率 (min)
2023-01-08 16:57:10 +00:00
/// </summary>
public int AutoSaveInterval
{
2023-09-03 11:45:11 +00:00
get => Math.Max(GetInt("autosave", 10), -1);
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
{
2023-09-03 11:45:11 +00:00
get => Math.Max(GetInt("bakupsave", 30), 1);
2023-06-23 13:15:57 +00:00
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-08-09 14:17:28 +00:00
/// <summary>
/// 当前宠物的储存数据
/// </summary>
public ILine PetData => this["petdata"];
2023-01-08 16:57:10 +00:00
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>
2023-07-23 20:46:21 +00:00
/// 计算间隔 (秒)
2023-01-23 17:31:16 +00:00
/// </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-08-10 11:34:11 +00:00
/// <summary>
/// 当实时播放音量达到该值时运行音乐动作
/// </summary>
public double MusicCatch
{
get => this["gameconfig"].GetDouble("musiccatch", 0.3);
set => this["gameconfig"].SetDouble("musiccatch", value);
}
/// <summary>
/// 当实时播放音量达到该值时运行特殊音乐动作
/// </summary>
public double MusicMax
{
get => this["gameconfig"].GetDouble("musicmax", 0.70);
set => this["gameconfig"].SetDouble("musicmax", value);
}
2023-08-12 06:09:20 +00:00
/// <summary>
/// 桌宠图形渲染的分辨率,越高图形越清晰
/// </summary>
public int Resolution
{
get => this["gameconfig"].GetInt("resolution", 500);
set => this["gameconfig"].SetInt("resolution", value);
}
2023-08-23 19:49:16 +00:00
bool autobuy;
/// <summary>
/// 允许桌宠自动购买食品
/// </summary>
public bool AutoBuy
{
get => autobuy;
set
{
autobuy = value;
2023-08-25 14:49:07 +00:00
this["gameconfig"].SetBool("autobuy", value);
2023-08-23 19:49:16 +00:00
}
}
2023-09-05 15:33:08 +00:00
public bool MoveAreaDefault
{
get
{
var line = FindLine("movearea");
if (line == null)
return true;
return line.GetBool("set");
}
set
{
var line = FindorAddLine("movearea");
line.SetBool("set", value);
}
}
public System.Drawing.Rectangle MoveArea
{
get
{
var line = FindLine("movearea");
if (line == null)
return default(System.Drawing.Rectangle);
return new System.Drawing.Rectangle(
line.GetInt("x", 0),
line.GetInt("y", 0),
line.GetInt("w", 114),
line.GetInt("h", 514)
);
}
set
{
var line = FindorAddLine("movearea");
line.SetInt("x", value.X);
line.SetInt("y", value.Y);
line.SetInt("w", value.Width);
line.SetInt("h", value.Height);
}
}
2023-01-08 16:57:10 +00:00
}
}