实装 GraphicsSettings

This commit is contained in:
Hakoyu 2023-12-27 23:34:06 +08:00
parent 75799da51a
commit 2f13b8b0d1
7 changed files with 529 additions and 62 deletions

View File

@ -0,0 +1,162 @@
using System.ComponentModel;
using System.Windows;
namespace VPet.Solution.Models;
public class GraphicsSettingsModel : ObservableClass<SettingsModel>
{
private double _zoomLevel = 1;
/// <summary>
/// 缩放倍率
/// </summary>
[DefaultValue(1)]
public double ZoomLevel
{
get => _zoomLevel;
set => SetProperty(ref _zoomLevel, value);
}
private int _resolution = 1000;
/// <summary>
/// 桌宠图形渲染的分辨率,越高图形越清晰
/// </summary>
[DefaultValue(1000)]
public int Resolution
{
get => _resolution;
set => SetProperty(ref _resolution, value);
}
private bool _isBiggerScreen;
/// <summary>
/// 是否为更大的屏幕
/// </summary>
public bool IsBiggerScreen
{
get => _isBiggerScreen;
set => SetProperty(ref _isBiggerScreen, value);
}
private bool _topMost;
/// <summary>
/// 是否置于顶层
/// </summary>
public bool TopMost
{
get => _topMost;
set => SetProperty(ref _topMost, value);
}
private bool _hitThrough;
/// <summary>
/// 是否鼠标穿透
/// </summary>
public bool HitThrough
{
get => _hitThrough;
set => SetProperty(ref _hitThrough, value);
}
private string _language;
/// <summary>
/// 语言
/// </summary>
public string Language
{
get => _language;
set => SetProperty(ref _language, value);
}
private string _font;
/// <summary>
/// 字体
/// </summary>
public string Font
{
get => _font;
set => SetProperty(ref _font, value);
}
private string _theme;
/// <summary>
/// 主题
/// </summary>
public string Theme
{
get => _theme;
set => SetProperty(ref _theme, value);
}
private bool _startUPBoot;
/// <summary>
/// 开机启动
/// </summary>
public bool StartUPBoot
{
get => _startUPBoot;
set => SetProperty(ref _startUPBoot, value);
}
private bool _startUPBootSteam;
/// <summary>
/// 开机启动 Steam
/// </summary>
public bool StartUPBootSteam
{
get => _startUPBootSteam;
set => SetProperty(ref _startUPBootSteam, value);
}
private bool _startRecordLast = true;
/// <summary>
/// 是否记录游戏退出位置
/// </summary>
[DefaultValue(true)]
public bool StartRecordLast
{
get => _startRecordLast;
set => SetProperty(ref _startRecordLast, value);
}
//private Point _startRecordLastPoint;
///// <summary>
///// 记录上次退出位置
///// </summary>
//public Point StartRecordLastPoint
//{
// get => _startRecordLastPoint;
// set => SetProperty(ref _startRecordLastPoint, value);
//}
private ObservablePoint<double> _startRecordPoint;
/// <summary>
/// 设置中桌宠启动的位置
/// </summary>
public ObservablePoint<double> StartRecordPoint
{
get => _startRecordPoint;
set => SetProperty(ref _startRecordPoint, value);
}
private bool _hideFromTaskControl;
/// <summary>
/// 在任务切换器(Alt+Tab)中隐藏窗口
/// </summary>
public bool HideFromTaskControl
{
get => _hideFromTaskControl;
set => SetProperty(ref _hideFromTaskControl, value);
}
}

View File

@ -0,0 +1,316 @@
using FastMember;
using HKW.HKWUtils.Observable;
using System.ComponentModel;
using System.Windows;
using VPet.Solution.Properties;
using VPet_Simulator.Core;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.Models;
public class SettingsModel : ObservableClass<SettingsModel>
{
private GraphicsSettingsModel _graphicsSettings;
public GraphicsSettingsModel GraphicsSettings
{
get => _graphicsSettings;
set => SetProperty(ref _graphicsSettings, value);
}
public SettingsModel(Setting setting)
{
GraphicsSettings = LoadGraphicsSettings(setting);
}
private GraphicsSettingsModel LoadGraphicsSettings(Setting setting)
{
var graphicsSettings = new GraphicsSettingsModel();
var sourceAccessor = ObjectAccessor.Create(setting);
var targetAccessor = ObjectAccessor.Create(graphicsSettings);
foreach (var property in typeof(GraphicsSettingsModel).GetProperties())
targetAccessor[property.Name] = sourceAccessor[property.Name];
return graphicsSettings;
}
private double _voiceVolume;
/// <summary>
/// 播放声音大小
/// </summary>
public double VoiceVolume
{
get => _voiceVolume;
set => SetProperty(ref _voiceVolume, value);
}
/// <summary>
/// 数据收集是否被禁止(当日)
/// </summary>
public bool DiagnosisDayEnable { get; } = true;
private bool _diagnosis;
/// <summary>
/// 是否启用数据收集
/// </summary>
public bool Diagnosis
{
get => _diagnosis;
set => SetProperty(ref _diagnosis, value);
}
private GameSave.ModeType _calFunState;
/// <summary>
/// 非计算模式下默认模式
/// </summary>
public GameSave.ModeType CalFunState
{
get => _calFunState;
set => SetProperty(ref _calFunState, value);
}
private int _diagnosisInterval;
/// <summary>
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
get => _diagnosisInterval;
set => SetProperty(ref _diagnosisInterval, value);
}
private int _autoSaveInterval;
/// <summary>
/// 自动保存频率 (min)
/// </summary>
public int AutoSaveInterval
{
get => _autoSaveInterval;
set => SetProperty(ref _autoSaveInterval, value);
}
private int _backupSaveMaxNum;
/// <summary>
/// 备份保存最大数量
/// </summary>
public int BackupSaveMaxNum
{
get => _backupSaveMaxNum;
set => SetProperty(ref _backupSaveMaxNum, value);
}
private bool _petHelper;
/// <summary>
/// 是否显示宠物帮助窗口
/// </summary>
public bool PetHelper
{
get => _petHelper;
set => SetProperty(ref _petHelper, value);
}
private DateTime _lastCacheDate;
/// <summary>
/// 上次清理缓存日期
/// </summary>
public DateTime LastCacheDate
{
get => _lastCacheDate;
set => SetProperty(ref _lastCacheDate, value);
}
private int _saveTimes;
/// <summary>
/// 储存顺序次数
/// </summary>
public int SaveTimes
{
get => _saveTimes;
set => SetProperty(ref _saveTimes, value);
}
private int _pressLength;
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
public int PressLength
{
get => _pressLength;
set => SetProperty(ref _pressLength, value);
}
private int _interactionCycle;
/// <summary>
/// 互动周期
/// </summary>
public int InteractionCycle
{
get => _interactionCycle;
set => SetProperty(ref _interactionCycle, value);
}
private double _logicInterval;
/// <summary>
/// 计算间隔 (秒)
/// </summary>
public double LogicInterval
{
get => _logicInterval;
set => SetProperty(ref _logicInterval, value);
}
private double _petHelpLeft;
/// <summary>
/// 计算间隔
/// </summary>
public double PetHelpLeft
{
get => _petHelpLeft;
set => SetProperty(ref _petHelpLeft, value);
}
private double _petHelpTop;
/// <summary>
/// 计算间隔
/// </summary>
public double PetHelpTop
{
get => _petHelpTop;
set => SetProperty(ref _petHelpTop, value);
}
private bool _allowMove;
/// <summary>
/// 允许移动事件
/// </summary>
public bool AllowMove
{
get => _allowMove;
set => SetProperty(ref _allowMove, value);
}
private bool _smartMove;
/// <summary>
/// 智能移动
/// </summary>
public bool SmartMove
{
get => _smartMove;
set => SetProperty(ref _smartMove, value);
}
private bool _enableFunction;
/// <summary>
/// 启用计算等数据功能
/// </summary>
public bool EnableFunction
{
get => _enableFunction;
set => SetProperty(ref _enableFunction, value);
}
private int _smartMoveInterval;
/// <summary>
/// 智能移动周期 (秒)
/// </summary>
public int SmartMoveInterval
{
get => _smartMoveInterval;
set => SetProperty(ref _smartMoveInterval, value);
}
private bool _messageBarOutside;
/// <summary>
/// 消息框外置
/// </summary>
public bool MessageBarOutside
{
get => _messageBarOutside;
set => SetProperty(ref _messageBarOutside, value);
}
private string _petGraph;
/// <summary>
/// 桌宠选择内容
/// </summary>
public string PetGraph
{
get => _petGraph;
set => SetProperty(ref _petGraph, value);
}
private double _musicCatch;
/// <summary>
/// 当实时播放音量达到该值时运行音乐动作
/// </summary>
public double MusicCatch
{
get => _musicCatch;
set => SetProperty(ref _musicCatch, value);
}
private double _musicMax;
/// <summary>
/// 当实时播放音量达到该值时运行特殊音乐动作
/// </summary>
public double MusicMax
{
get => _musicMax;
set => SetProperty(ref _musicMax, value);
}
private bool _autoBuy;
/// <summary>
/// 允许桌宠自动购买食品
/// </summary>
public bool AutoBuy
{
get => _autoBuy;
set => SetProperty(ref _autoBuy, value);
}
private bool _autoGift;
/// <summary>
/// 允许桌宠自动购买礼物
/// </summary>
public bool AutoGift
{
get => _autoGift;
set => SetProperty(ref _autoGift, value);
}
private bool _moveAreaDefault;
public bool MoveAreaDefault
{
get => _moveAreaDefault;
set => SetProperty(ref _moveAreaDefault, value);
}
private System.Drawing.Rectangle _moveArea;
public System.Drawing.Rectangle MoveArea
{
get => _moveArea;
set => SetProperty(ref _moveArea, value);
}
}

View File

@ -37,6 +37,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FastMember, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FastMember.1.5.0\lib\net461\FastMember.dll</HintPath>
</Reference>
<Reference Include="LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LinePutScript.1.9.2\lib\net462\LinePutScript.dll</HintPath>
</Reference>
@ -72,12 +75,14 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\BoolInverter.cs" />
<Compile Include="Models\GraphicsSettingsModel.cs" />
<Compile Include="Utils\ClearFocus.cs" />
<Compile Include="Utils\ElementHelper.cs" />
<Compile Include="Utils\FindTopParent.cs" />
<Compile Include="ViewModels\CustomizedSettingsPageVM.cs" />
<Compile Include="ViewModels\DiagnosticSettingsPageVM.cs" />
<Compile Include="ViewModels\ModSettingsPageVM.cs" />
<Compile Include="Models\SettingsModel.cs" />
<Compile Include="ViewModels\SystemSettingsPageVM.cs" />
<Compile Include="Views\CustomizedSettingsPage.xaml.cs">
<DependentUpon>CustomizedSettingsPage.xaml</DependentUpon>
@ -226,8 +231,6 @@
<Name>VPet-Simulator.Windows.Interface</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,9 +1,19 @@
using System;
using HKW.HKWUtils.Observable;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
namespace VPet.Solution.ViewModels;
public class GraphicsSettingsPageVM { }
public class GraphicsSettingsPageVM : ObservableClass<GraphicsSettingsPageVM>
{
private GraphicsSettingsModel _graphicsSettings;
public GraphicsSettingsModel GraphicsSettings
{
get => _graphicsSettings;
set => SetProperty(ref _graphicsSettings, value);
}
}

View File

@ -1,9 +1,9 @@
using System;
using HKW.HKWUtils.Observable;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.ViewModels;

View File

@ -38,17 +38,15 @@
<pu:Switch
x:Name="TopMostBox"
Grid.Column="1"
d:Checked="TopMostBox_Checked"
d:Unchecked="TopMostBox_Unchecked"
Content="{ll:Str '将桌宠置于顶层'}"
IsChecked="{Binding GraphicsSettings.TopMost}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '将桌宠置于顶层'}" />
<pu:Switch
x:Name="HitThroughBox"
Grid.Column="2"
d:Checked="HitThroughBox_Checked"
d:Unchecked="HitThroughBox_Checked"
Content="{ll:Str '鼠标穿透'}"
IsChecked="{Binding GraphicsSettings.HitThrough}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '鼠标将会穿过桌宠到下方内容,不打扰操作\&#13;该选项'}" />
<pu:Switch
@ -73,7 +71,7 @@
<ComboBox
x:Name="LanguageBox"
Grid.Column="1"
d:SelectionChanged="LanguageBox_SelectionChanged"
SelectedItem="{Binding GraphicsSettings.Language}"
Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid>
<Grid MinHeight="40">
@ -89,9 +87,8 @@
<pu:Switch
x:Name="FullScreenBox"
Grid.Column="1"
d:Checked="FullScreenBox_Check"
d:Unchecked="FullScreenBox_Check"
Content="{ll:Str 支持更大缩放倍率}"
IsChecked="{Binding GraphicsSettings.IsBiggerScreen}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str 解锁缩放限制}" />
</Grid>
@ -109,17 +106,13 @@
<Slider
x:Name="Slider_Zoom"
Grid.Column="1"
Margin="10,0,10,0"
VerticalAlignment="Center"
d:PreviewMouseUp="Slider_Zoom_MouseUp"
IsSnapToTickEnabled="True"
LargeChange=".1"
LargeChange="0.1"
Maximum="3"
Minimum="0.5"
SmallChange="0.05"
Style="{DynamicResource StandardSliderStyle}"
Style="{DynamicResource Slider_BaseStyle}"
TickFrequency="0.05"
Value="1" />
Value="{Binding GraphicsSettings.ZoomLevel}" />
<pu:NumberInput
Grid.Column="2"
Foreground="{DynamicResource DARKPrimaryDarker}"
@ -143,18 +136,14 @@
<Slider
x:Name="Slider_Resolution"
Grid.Column="1"
Margin="10,0,10,0"
VerticalAlignment="Center"
d:PreviewMouseUp="Slider_Resolution_MouseUp"
IsSnapToTickEnabled="True"
LargeChange="50"
Maximum="1920"
Minimum="200"
SmallChange="20"
Style="{DynamicResource StandardSliderStyle}"
SmallChange="10"
Style="{DynamicResource Slider_BaseStyle}"
TickFrequency="10"
ToolTip="{ll:Str '桌宠图形渲染的分辨率,越高图形越清晰\&#13;但是高分辨率会占用更多内存\&#13;重启后生效'}"
Value="1000" />
Value="{Binding GraphicsSettings.Resolution}" />
<pu:NumberInput
Grid.Column="2"
Interval="10"
@ -177,8 +166,8 @@
<ComboBox
x:Name="ThemeBox"
Grid.Column="1"
d:SelectionChanged="ThemeBox_SelectionChanged"
IsEnabled="False"
SelectedItem="{Binding GraphicsSettings.Theme}"
Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid>
<Grid MinHeight="40">
@ -194,8 +183,8 @@
<ComboBox
x:Name="FontBox"
Grid.Column="1"
d:SelectionChanged="FontBox_SelectionChanged"
IsEnabled="False"
SelectedItem="{Binding GraphicsSettings.Font}"
Style="{DynamicResource ComboBox_BaseStyle}" />
</Grid>
<Grid MinHeight="40">
@ -215,35 +204,24 @@
<pu:Switch
x:Name="StartPlace"
Grid.Column="1"
d:Checked="StartPlace_Checked"
d:Unchecked="StartPlace_Checked"
Content="{ll:Str 保存为退出位置}"
IsChecked="True"
IsChecked="{Binding GraphicsSettings.StartRecordLast}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str 游戏退出位置为下次桌宠启动出现的位置}" />
<TextBox
x:Name="TextBoxStartUpX"
Grid.Column="2"
Margin="0,0,5,0"
d:TextChanged="TextBoxStartUp_TextChanged"
pu:IconHelper.Margin="5,0,0,0"
pu:TextBoxHelper.Icon="X"
pu:TextBoxHelper.InputLimit="Digit"
pu:TextBoxHelper.Watermark="{ll:Str X轴}"
Style="{DynamicResource StandardTextBoxStyle}"
ToolTip="{ll:Str X轴}" />
<TextBox
x:Name="TextBoxStartUpY"
Grid.Column="3"
Margin="0,0,5,0"
d:TextChanged="TextBoxStartUp_TextChanged"
pu:IconHelper.Margin="5,0,0,0"
pu:TextBoxHelper.Icon="Y"
pu:TextBoxHelper.InputLimit="Digit"
pu:TextBoxHelper.Watermark="{ll:Str Y轴}"
FontSize="16"
Style="{DynamicResource StandardTextBoxStyle}"
ToolTip="{ll:Str Y轴}" />
<DockPanel Grid.Column="2">
<Label Content="{ll:Str X轴}" Style="{DynamicResource Label_BaseStyle}" />
<pu:NumberInput
x:Name="TextBoxStartUpX"
Style="{DynamicResource NumberInput_BaseStyle}"
Value="{Binding GraphicsSettings.StartRecordPoint.X}" />
</DockPanel>
<DockPanel Grid.Column="3">
<Label Content="{ll:Str Y轴}" Style="{DynamicResource Label_BaseStyle}" />
<pu:NumberInput
x:Name="TextBoxStartUpY"
Style="{DynamicResource NumberInput_BaseStyle}"
Value="{Binding GraphicsSettings.StartRecordPoint.Y}" />
</DockPanel>
<Button
x:Name="BtnStartUpGet"
Grid.Column="4"
@ -284,17 +262,15 @@
<pu:Switch
x:Name="StartUpBox"
Grid.Column="1"
d:Checked="StartUpBox_Checked"
d:Unchecked="StartUpBox_Checked"
Content="{ll:Str 开机启动}"
IsChecked="{Binding GraphicsSettings.StartUPBoot}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '该游戏随着开机启动该程序\&#13;如需卸载游戏\&#13;请关闭该选项'}" />
<pu:Switch
x:Name="StartUpSteamBox"
Grid.Column="2"
d:Checked="StartUpSteamBox_Checked"
d:Unchecked="StartUpSteamBox_Checked"
Content="{ll:Str 从Steam启动}"
IsChecked="{Binding GraphicsSettings.StartUPBootSteam}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '从Steam启动该游戏, 统计时长不能停'}" />
</Grid>
@ -340,9 +316,8 @@
<pu:Switch
x:Name="SwitchHideFromTaskControl"
Grid.Column="1"
d:Checked="SwitchHideFromTaskControl_OnChecked"
d:Unchecked="SwitchHideFromTaskControl_OnChecked"
Content="{ll:Str '在任务切换器中隐藏窗口'}"
IsChecked="{Binding GraphicsSettings.HideFromTaskControl}"
Style="{DynamicResource Switch_BaseStyle}"
ToolTip="{ll:Str '在Alt+Tab中隐藏'}" />
</Grid>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FastMember" version="1.5.0" targetFramework="net462" />
<package id="LinePutScript" version="1.9.2" targetFramework="net462" />
<package id="LinePutScript.Localization.WPF" version="1.0.6" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.2" targetFramework="net462" />