VPet/VPet.Solution/Models/SettingEditor/InteractiveSettingModel.cs

312 lines
8.0 KiB
C#
Raw Normal View History

2023-12-30 14:54:49 +00:00
using HKW.HKWUtils.Observable;
2024-01-11 16:28:22 +00:00
using System.Collections.ObjectModel;
2024-01-12 14:17:50 +00:00
using System.ComponentModel;
2023-12-27 15:34:06 +00:00
using VPet_Simulator.Core;
2024-01-07 14:57:27 +00:00
namespace VPet.Solution.Models.SettingEditor;
2023-12-27 15:34:06 +00:00
2023-12-30 14:54:49 +00:00
public class InteractiveSettingModel : ObservableClass<InteractiveSettingModel>
2023-12-27 15:34:06 +00:00
{
2024-01-11 16:28:22 +00:00
// NOTE: 这玩意其实在存档里 而不是设置里
//#region PetName
//private string _petName;
///// <summary>
///// 宠物名称
///// </summary>
//[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetName))]
//public string PetName
//{
// get => _petName;
// set => SetProperty(ref _petName, value);
//}
//#endregion
#region VoiceVolume
2023-12-27 15:34:06 +00:00
private double _voiceVolume;
/// <summary>
/// 播放声音大小
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.VoiceVolume))]
2023-12-27 15:34:06 +00:00
public double VoiceVolume
{
get => _voiceVolume;
set => SetProperty(ref _voiceVolume, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-13 14:05:28 +00:00
#region EnableFunction
private bool _enableFunction;
/// <summary>
/// 启用计算等数据功能
/// </summary>
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.EnableFunction))]
public bool EnableFunction
{
get => _enableFunction;
set => SetProperty(ref _enableFunction, value);
}
#endregion
2024-01-11 16:28:22 +00:00
#region CalFunState
2023-12-27 15:34:06 +00:00
private GameSave.ModeType _calFunState;
/// <summary>
/// 非计算模式下默认模式
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.CalFunState))]
2023-12-27 15:34:06 +00:00
public GameSave.ModeType CalFunState
{
get => _calFunState;
set => SetProperty(ref _calFunState, value);
}
2024-01-11 16:28:22 +00:00
public ObservableCollection<GameSave.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(GameSave.ModeType)).Cast<GameSave.ModeType>());
#endregion
#region LastCacheDate
2023-12-27 15:34:06 +00:00
private DateTime _lastCacheDate;
/// <summary>
/// 上次清理缓存日期
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.LastCacheDate))]
2023-12-27 15:34:06 +00:00
public DateTime LastCacheDate
{
get => _lastCacheDate;
set => SetProperty(ref _lastCacheDate, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region SaveTimes
2023-12-27 15:34:06 +00:00
private int _saveTimes;
/// <summary>
/// 储存顺序次数
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SaveTimes))]
2023-12-27 15:34:06 +00:00
public int SaveTimes
{
get => _saveTimes;
set => SetProperty(ref _saveTimes, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region PressLength
2023-12-27 15:34:06 +00:00
private int _pressLength;
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PressLength))]
2023-12-27 15:34:06 +00:00
public int PressLength
{
get => _pressLength;
set => SetProperty(ref _pressLength, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region InteractionCycle
2023-12-27 15:34:06 +00:00
private int _interactionCycle;
/// <summary>
/// 互动周期
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.InteractionCycle))]
2023-12-27 15:34:06 +00:00
public int InteractionCycle
{
get => _interactionCycle;
set => SetProperty(ref _interactionCycle, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region LogicInterval
2023-12-27 15:34:06 +00:00
private double _logicInterval;
/// <summary>
/// 计算间隔 (秒)
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.LogicInterval))]
2023-12-27 15:34:06 +00:00
public double LogicInterval
{
get => _logicInterval;
set => SetProperty(ref _logicInterval, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region AllowMove
2023-12-27 15:34:06 +00:00
private bool _allowMove;
/// <summary>
/// 允许移动事件
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AllowMove))]
2023-12-27 15:34:06 +00:00
public bool AllowMove
{
get => _allowMove;
set => SetProperty(ref _allowMove, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region SmartMove
2023-12-27 15:34:06 +00:00
private bool _smartMove;
/// <summary>
/// 智能移动
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SmartMove))]
2023-12-27 15:34:06 +00:00
public bool SmartMove
{
get => _smartMove;
set => SetProperty(ref _smartMove, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region SmartMoveInterval
2024-01-12 14:17:50 +00:00
private int _smartMoveInterval = 0;
2023-12-27 15:34:06 +00:00
/// <summary>
/// 智能移动周期 (秒)
/// </summary>
2024-01-12 14:17:50 +00:00
[DefaultValue(1)]
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.SmartMoveInterval))]
2024-01-12 13:34:53 +00:00
[ReflectionPropertyConverter(typeof(SecondToMinuteConverter))]
2023-12-27 15:34:06 +00:00
public int SmartMoveInterval
{
get => _smartMoveInterval;
set => SetProperty(ref _smartMoveInterval, value);
}
2024-01-12 14:17:50 +00:00
public static ObservableCollection<int> SmartMoveIntervals { get; } =
2024-01-12 13:34:53 +00:00
new() { 1, 2, 5, 10, 20, 30, 40, 50, 60 };
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region PetGraph
2023-12-27 15:34:06 +00:00
private string _petGraph;
/// <summary>
/// 桌宠选择内容
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.PetGraph))]
2023-12-27 15:34:06 +00:00
public string PetGraph
{
get => _petGraph;
set => SetProperty(ref _petGraph, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region MusicCatch
2024-01-12 14:17:50 +00:00
private int _musicCatch;
2023-12-27 15:34:06 +00:00
/// <summary>
/// 当实时播放音量达到该值时运行音乐动作
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MusicCatch))]
2024-01-12 14:17:50 +00:00
[ReflectionPropertyConverter(typeof(DoubleToInt32Converter))]
public int MusicCatch
2023-12-27 15:34:06 +00:00
{
get => _musicCatch;
set => SetProperty(ref _musicCatch, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region MusicMax
2024-01-12 14:17:50 +00:00
private int _musicMax;
2023-12-27 15:34:06 +00:00
/// <summary>
/// 当实时播放音量达到该值时运行特殊音乐动作
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MusicMax))]
2024-01-12 14:17:50 +00:00
[ReflectionPropertyConverter(typeof(DoubleToInt32Converter))]
public int MusicMax
2023-12-27 15:34:06 +00:00
{
get => _musicMax;
set => SetProperty(ref _musicMax, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region AutoBuy
2023-12-27 15:34:06 +00:00
private bool _autoBuy;
2024-01-12 13:34:53 +00:00
// TODO 加入 AutoBuy
2023-12-27 15:34:06 +00:00
/// <summary>
/// 允许桌宠自动购买食品
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AutoBuy))]
2023-12-27 15:34:06 +00:00
public bool AutoBuy
{
get => _autoBuy;
set => SetProperty(ref _autoBuy, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region AutoGift
2023-12-27 15:34:06 +00:00
private bool _autoGift;
2024-01-12 13:34:53 +00:00
// TODO 加入 AutoGift
2023-12-27 15:34:06 +00:00
/// <summary>
/// 允许桌宠自动购买礼物
/// </summary>
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.AutoGift))]
2023-12-27 15:34:06 +00:00
public bool AutoGift
{
get => _autoGift;
set => SetProperty(ref _autoGift, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
2024-01-11 16:28:22 +00:00
#region MoveAreaDefault
2023-12-27 15:34:06 +00:00
private bool _moveAreaDefault;
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MoveAreaDefault))]
2023-12-27 15:34:06 +00:00
public bool MoveAreaDefault
{
get => _moveAreaDefault;
set => SetProperty(ref _moveAreaDefault, value);
}
2024-01-11 16:28:22 +00:00
#endregion
#region MoveArea
2023-12-27 15:34:06 +00:00
private System.Drawing.Rectangle _moveArea;
2024-01-11 16:28:22 +00:00
[ReflectionProperty(nameof(VPet_Simulator.Windows.Interface.Setting.MoveArea))]
2023-12-27 15:34:06 +00:00
public System.Drawing.Rectangle MoveArea
{
get => _moveArea;
set => SetProperty(ref _moveArea, value);
}
2024-01-11 16:28:22 +00:00
#endregion
2023-12-27 15:34:06 +00:00
}
2024-01-12 13:34:53 +00:00
public class SecondToMinuteConverter : ReflectionConverterBase<int, int>
{
public override int Convert(int sourceValue)
{
2024-01-12 14:17:50 +00:00
return sourceValue * 60;
}
public override int ConvertBack(int targetValue)
{
if (targetValue == 30)
2024-01-12 13:34:53 +00:00
return 1;
else
2024-01-12 14:17:50 +00:00
return targetValue / 60;
}
}
public class DoubleToInt32Converter : ReflectionConverterBase<int, double>
{
public override double Convert(int sourceValue)
{
return sourceValue;
2024-01-12 13:34:53 +00:00
}
2024-01-12 14:17:50 +00:00
public override int ConvertBack(double targetValue)
2024-01-12 13:34:53 +00:00
{
2024-01-12 14:17:50 +00:00
return System.Convert.ToInt32(targetValue);
2024-01-12 13:34:53 +00:00
}
}