支持自定义桌宠移动范围

This commit is contained in:
ZouJin 2023-09-11 00:21:39 +08:00
parent ea35d430b1
commit 5f66c61c20
7 changed files with 164 additions and 27 deletions

View File

@ -509,7 +509,7 @@
Padding="1" pu:ButtonHelper.CornerRadius="4"
Background="{DynamicResource SecondaryLight}"
Click="BtnSetMoveArea_Default_Click" Content="{ll:Str 重置为主屏}"
ToolTip="{ll:Str `设置桌宠只在主屏幕进行移动`}" />
ToolTip="{ll:Str '设置桌宠只在主屏幕进行移动'}" />
<Button x:Name="BtnSetMoveArea_DetectScreen" Grid.Row="1" Grid.Column="1"
Margin="5,5,5,5" Padding="1" pu:ButtonHelper.CornerRadius="4"
Background="{DynamicResource SecondaryLight}"

View File

@ -617,7 +617,7 @@ namespace VPet_Simulator.Windows
}
}
private void UpdateMoveAreaText()
public void UpdateMoveAreaText()
{
var mwCtrl = mw.Core.Controller as MWController;
if (mwCtrl.IsPrimaryScreen)
@ -645,32 +645,20 @@ namespace VPet_Simulator.Windows
UpdateMoveAreaText();
}
private static System.Reflection.FieldInfo leftGetter, topGetter;
internal static System.Reflection.FieldInfo leftGetter, topGetter;
private void BtnSetMoveArea_Window_Click(object sender, RoutedEventArgs e)
{
var wma = new winMoveArea(mw);
var mwCtrl = mw.Core.Controller as MWController;
System.Drawing.Rectangle bounds;
if (WindowState == WindowState.Maximized)
if (!mwCtrl.IsPrimaryScreen)
{
// 反射捞一下左上角
if (leftGetter == null) leftGetter = typeof(Window).GetField("_actualLeft", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (topGetter == null) topGetter = typeof(Window).GetField("_actualTop", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var actualLeft = Convert.ToInt32(leftGetter.GetValue(this));
var actualTop = Convert.ToInt32(topGetter.GetValue(this));
bounds = new System.Drawing.Rectangle(
actualLeft, actualTop,
(int)ActualWidth, (int)ActualHeight
);
}
else
{
bounds = new System.Drawing.Rectangle(
(int)Left, (int)Top,
(int)Width, (int)Height
);
}
mwCtrl.ScreenBorder = bounds;
UpdateMoveAreaText();
var rect = mwCtrl.ScreenBorder;
wma.Width = rect.Width;
wma.Height = rect.Height;
wma.Left = rect.X;
wma.Top = rect.Y;
}
wma.ShowDialog();
}
private void hyper_moreInfo(object sender, RoutedEventArgs e)

View File

@ -0,0 +1,42 @@
<pu:WindowX x:Class="VPet_Simulator.Windows.winMoveArea"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" pu:WindowXCaption.Height="0"
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Topmost="True" AllowsTransparency="True"
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" WindowStyle="None" Title="winMoveArea"
Height="450" Width="450" Background="{DynamicResource PrimaryTrans4}" ResizeMode="CanResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height=".3*" />
<RowDefinition Height=".7*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width=".7*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Border Background="{DynamicResource PrimaryTrans4}" PreviewMouseDown="Grid_PreviewMouseDown"
Grid.ColumnSpan="4" Grid.RowSpan="6" BorderBrush="{DynamicResource DARKPrimary}" BorderThickness="4" />
<Viewbox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" PreviewMouseDown="Grid_PreviewMouseDown">
<Label Content="{ll:Str '桌宠移动范围'}" Background="{x:Null}" />
</Viewbox>
<Viewbox Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom"
PreviewMouseDown="Grid_PreviewMouseDown">
<Label Content="{ll:Str '鼠标左键拖动范围\&#13;调整边框调整大小'}" Background="{x:Null}" />
</Viewbox>
<Viewbox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">
<Button Style="{DynamicResource ThemedButtonStyle}" Content="{ll:Str '设置当前范围为移动范围'}" MinWidth="120"
Click="Save_Click" />
</Viewbox>
<Viewbox Grid.Column="3" HorizontalAlignment="Right">
<Button Style="{DynamicResource ThemedButtonStyle}" Content="X" Click="Close_Click" />
</Viewbox>
</Grid>
</pu:WindowX>

View File

@ -0,0 +1,68 @@
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace VPet_Simulator.Windows
{
/// <summary>
/// winMoveArea.xaml 的交互逻辑
/// </summary>
public partial class winMoveArea : WindowX
{
MainWindow mw;
public winMoveArea(MainWindow mw)
{
InitializeComponent();
this.mw = mw;
}
private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void Save_Click(object sender, RoutedEventArgs e)
{
var mwCtrl = mw.Core.Controller as MWController;
System.Drawing.Rectangle bounds;
if (WindowState == WindowState.Maximized)
{
// 反射捞一下左上角
if (winGameSetting.leftGetter == null) winGameSetting.leftGetter = typeof(Window).GetField("_actualLeft", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (winGameSetting.topGetter == null) winGameSetting.topGetter = typeof(Window).GetField("_actualTop", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var actualLeft = Convert.ToInt32(winGameSetting.leftGetter.GetValue(this));
var actualTop = Convert.ToInt32(winGameSetting.topGetter.GetValue(this));
bounds = new System.Drawing.Rectangle(
actualLeft, actualTop,
(int)ActualWidth, (int)ActualHeight
);
}
else
{
bounds = new System.Drawing.Rectangle(
(int)Left, (int)Top,
(int)Width, (int)Height
);
}
mwCtrl.ScreenBorder = bounds;
mw.winSetting.UpdateMoveAreaText();
Close();
}
private void Close_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}

View File

@ -1,4 +1,17 @@
聊天框等相关设置#Chat box and other related settings:|
暂无聊天API, 您可以通过订阅MOD添加#There is no chat API yet, you can add it by subscribing to the mod.:|
打开 {0} 设置#Open {0} Settings:|
恢复#Restore:|
恢复#Restore:|
Mod制作器#Mod Maker:|
当前移动区域:#The current movement area::|
主屏幕#Home Screen:|
重置为主屏#Reset to home screen:|
设置桌宠只在主屏幕进行移动#Set table favor to move only on the home screen:|
设为当前屏幕#Set to current screen:|
设置桌宠只在当前桌宠所在的屏幕范围进行移动#Sets the table favor to move only within the current screen range of the table favor.:|
自定移动范围#Customize range of movement:|
手动设置桌宠可移动范围#Manually set the range of movement for your favorite:|
work#Work:|
桌宠移动范围#Move range of table favor:|
鼠标左键拖动范围\r调整边框调整大小#Left mouse button to drag the range \r adjust the border to adjust the size:|
设置当前范围为移动范围#Set the current range as the moving range:|

View File

@ -1,4 +1,17 @@
聊天框等相关设置#聊天框等相关设置:|
暂无聊天API, 您可以通过订阅MOD添加#暂无聊天API, 您可以通过订阅MOD添加:|
打开 {0} 设置#打开 {0} 设置:|
恢复#恢复:|
恢复#恢复:|
Mod制作器#Mod制作器:|
当前移动区域:#当前移动区域::|
主屏幕#主屏幕:|
重置为主屏#重置为主屏:|
设置桌宠只在主屏幕进行移动#设置桌宠只在主屏幕进行移动:|
设为当前屏幕#设为当前屏幕:|
设置桌宠只在当前桌宠所在的屏幕范围进行移动#设置桌宠只在当前桌宠所在的屏幕范围进行移动:|
自定移动范围#自定移动范围:|
手动设置桌宠可移动范围#手动设置桌宠可移动范围:|
work#work:|
桌宠移动范围#桌宠移动范围:|
鼠标左键拖动范围\r调整边框调整大小#鼠标左键拖动范围\r调整边框调整大小:|
设置当前范围为移动范围#设置当前范围为移动范围:|

View File

@ -1,4 +1,17 @@
聊天框等相关设置#聊天框等相關設定:|
暂无聊天API, 您可以通过订阅MOD添加#暫無聊天API您可以通過訂閱MOD添加:|
打开 {0} 设置#打開{0}設定:|
恢复#恢復|
恢复#恢復:|
Mod制作器#Mod製作器:|
当前移动区域:#當前移動區域::|
主屏幕#主荧幕:|
重置为主屏#重置為主屏:|
设置桌宠只在主屏幕进行移动#設定桌寵只在主荧幕進行移動:|
设为当前屏幕#設為當前荧幕:|
设置桌宠只在当前桌宠所在的屏幕范围进行移动#設定桌寵只在當前桌寵所在的荧幕範圍進行移動:|
自定移动范围#自定移動範圍:|
手动设置桌宠可移动范围#手動設置桌寵可移動範圍:|
work#work:|
桌宠移动范围#桌寵移動範圍:|
鼠标左键拖动范围\r调整边框调整大小#滑鼠左鍵拖動範圍\r調整邊框調整大小:|
设置当前范围为移动范围#設定當前範圍為移動範圍:|