Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
83987a6
尝试修复靠边的多屏幕兼容问题
YIYuNCU Feb 23, 2026
378881e
修复拼写错误,添加切换主屏幕相关代码
YIYuNCU Apr 26, 2026
543a8d8
引入自动切换屏幕功能,添加设置项(未添加设置UI)
YIYuNCU Apr 26, 2026
8b8bdc3
Potential fix for pull request finding
LorisYounger Apr 29, 2026
594bb48
Potential fix for pull request finding
LorisYounger Apr 29, 2026
8cb7a48
Merge pull request #544 from LorisYounger/main
LorisYounger May 20, 2026
c1a40fb
添加自动切换屏幕功能(自动开启)
YIYuNCU May 24, 2026
a4c87c6
Merge branch 'dev-靠边检测' of https://github.com/LorisYounger/VPet into …
YIYuNCU May 24, 2026
faacf86
fix AutoChangeWindow
LorisYounger May 24, 2026
9bf10c2
Merge branch 'dev-靠边检测' of https://github.com/LorisYounger/VPet into …
LorisYounger May 24, 2026
f0aca0b
Potential fix for pull request finding
LorisYounger May 24, 2026
abcd3e6
Potential fix for pull request finding
LorisYounger May 24, 2026
c06955f
Merge branch 'dev-靠边检测' of https://github.com/LorisYounger/VPet into …
LorisYounger May 24, 2026
361e0f3
fix: add non-breaking defaults for IController screen APIs
Copilot May 24, 2026
448e9f3
Normalize left side-hide Y delta by ZoomRatio
Copilot May 27, 2026
d8e8495
修复换算问题?
YIYuNCU May 27, 2026
79594ae
修复多余变量定义
YIYuNCU May 27, 2026
11d6f2c
修复多余变量定义
YIYuNCU May 27, 2026
38e5027
修复设置无法正常读取问题
YIYuNCU May 27, 2026
5b7046b
修复错误改动
YIYuNCU May 27, 2026
6224dc3
修复屏幕下部位置优化过多的问题
YIYuNCU May 27, 2026
405d7b6
修复设置读取错误问题
YIYuNCU May 27, 2026
062bdb5
增加兼容代码
YIYuNCU May 27, 2026
ce419a1
增加兼容代码
YIYuNCU May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions VPet-Simulator.Core/Display/MainLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,12 @@ public void EventTimer_Elapsed()
/// <returns>是否成功进入侧边隐藏模式</returns>
private bool MoveSideHideCheck()
{
if(Core.Controller.IfInActivateScreen() == false && Core.Controller.AutoChangeWindow)
Comment thread
LorisYounger marked this conversation as resolved.
Outdated
{
Core.Controller.SetNowScreenActivate();
}
//判断是否靠边,如果靠边就进入侧边隐藏模式
if (Core.Controller.GetWindowsDistanceLeft() < -50 * Core.Controller.ZoomRatio)
if (Core.Controller.GetWindowsDistanceLeft() < -50 * Core.Controller.ZoomRatio && (Core.Controller.IfInActivateScreen() || Core.Controller.GetWindowsDistanceLeft() > -110 * Core.Controller.ZoomRatio))
{
//检查下是否有SideLoad
if (Core.Graph.FindName(GraphType.SideHide_Left_Main) != null)
Expand All @@ -552,7 +556,7 @@ private bool MoveSideHideCheck()
Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio, 0);
}
}
else if (Core.Controller.GetWindowsDistanceRight() < -50 * Core.Controller.ZoomRatio)
else if (Core.Controller.GetWindowsDistanceRight() < -50 * Core.Controller.ZoomRatio && (Core.Controller.IfInActivateScreen() || Core.Controller.GetWindowsDistanceRight() > -110 * Core.Controller.ZoomRatio))
{
if (Core.Graph.FindName(GraphType.SideHide_Right_Main) != null)
{
Expand Down
14 changes: 14 additions & 0 deletions VPet-Simulator.Core/Handle/IController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public interface IController
/// 获取桌宠距离下方的位置
/// </summary>
double GetWindowsDistanceDown();
/// <summary>
/// 获取桌宠所在屏幕是否为活动屏幕
/// </summary>
/// <returns></returns>
bool IfInActivateScreen();
Comment thread
YIYuNCU marked this conversation as resolved.
Outdated
/// <summary>
/// 将当前屏幕设置为活动屏幕(如果桌宠在多个屏幕上则以主要屏幕为准)
/// </summary>
void SetNowScreenActivate();
Comment thread
YIYuNCU marked this conversation as resolved.
Outdated
///// <summary>
///// 窗体宽度
///// </summary>
Expand Down Expand Up @@ -72,5 +81,10 @@ public interface IController
/// 是否启用边缘重新定位
/// </summary>
bool RePostionActive { get; set; }

/// <summary>
/// 是否自动切换活动屏幕
/// </summary>
bool AutoChangeWindow { get; }
}
}
61 changes: 60 additions & 1 deletion VPet-Simulator.Windows/Function/MWController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using VPet_Simulator.Core;

namespace VPet_Simulator.Windows
Expand Down Expand Up @@ -93,6 +94,63 @@ public void MoveWindows(double X, double Y)
});
}

public bool IfInActivateScreen()
{
try
{
if (mw.Dispatcher.HasShutdownStarted || mw.Dispatcher.HasShutdownFinished) return false;
}catch { }
return mw.Dispatcher.Invoke(() =>
{

try
{
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(mw).Handle);
var screens = System.Windows.Forms.Screen.AllScreens;
for (int i = 0; i < screens.Length; i++)
{
if (screens[i].DeviceName == screen.DeviceName)
{
if(i == mw.Set.GameScreenIndex)
{
return true;
}
}
}
return false;
}
catch(Exception)
{
return true;
}
});
}

public void SetNowScreenActivate()
{
mw.Dispatcher.Invoke(() =>
{
try
{
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(mw).Handle);
var screens = System.Windows.Forms.Screen.AllScreens;
for (int i = 0; i < screens.Length; i++)
{
if (screens[i].DeviceName == screen.DeviceName)
{
mw.Set.GameScreenIndex = i;
ScreenBorder = new Rectangle(screens[i].Bounds.X, screens[i].Bounds.Y, screens[i].Bounds.Width, screens[i].Bounds.Height);
break;
}
}
}
catch (Exception)
{
mw.Set.GameScreenIndex = 0;
}
});
}

public void ShowSetting()
{
mw.Topmost = false;
Expand Down Expand Up @@ -144,5 +202,6 @@ public bool CheckPosition() => mw.Dispatcher.Invoke(() =>

public int InteractionCycle => mw.Set.InteractionCycle;

public bool AutoChangeWindow => mw.Set.AutoChangeWindow;
}
}
16 changes: 16 additions & 0 deletions VPet-Simulator.Windows/Function/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ public bool EnableFunction
this["gameconfig"].SetBool("nofunction", !value);
}
}
bool autochangewindow;
public bool AutoChangeWindow
{
get => autochangewindow;
set
{
autochangewindow = value;
this["gameconfig"].SetBool("autochangewindow", value);
}
}
/// <summary>
/// 智能移动周期 (秒)
/// </summary>
Expand Down Expand Up @@ -517,6 +527,12 @@ public bool OpacityHitThrough
set => this["gameconfig"].SetBool("opacityhitthrough", !value);
}

public int GameScreenIndex
{
get => this["gameconfig"].GetInt("gamescreenindex", 0);
set => this["gameconfig"].SetInt("gamescreenindex", value);
}

/// <summary>
/// 读写自定义游戏设置(给mod准备的接口)
/// </summary>
Expand Down
42 changes: 41 additions & 1 deletion VPet-Simulator.Windows/MutiPlayer/MPController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using VPet_Simulator.Core;
using System;
using VPet_Simulator.Core;

namespace VPet_Simulator.Windows
{
Expand Down Expand Up @@ -109,5 +110,44 @@ public bool CheckPosition() => mp.Dispatcher.Invoke(() =>

public int InteractionCycle => mw.Set.InteractionCycle;

public bool AutoChangeWindow => mw.Set.AutoChangeWindow;

public bool IfInActivateScreen()
{
try
{
if (mp.Dispatcher.HasShutdownStarted || mp.Dispatcher.HasShutdownFinished) return false;
}
catch { }
return mp.Dispatcher.Invoke(() =>
{

try
{
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(mp).Handle);
var screens = System.Windows.Forms.Screen.AllScreens;
for (int i = 0; i < screens.Length; i++)
{
if (screens[i].DeviceName == screen.DeviceName)
{
if (i == mw.Set.GameScreenIndex)
{
return true;
}
}
}
return false;
}
catch (Exception)
{
return true;
}
});
}

public void SetNowScreenActivate()
{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Comment on lines +148 to +151
}
}
18 changes: 18 additions & 0 deletions VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,24 @@ private void BtnSetMoveArea_DetectScreen_Click(object sender, RoutedEventArgs e)
// 如果无法获取 DPI 信息,回退到未调整的边界
mwCtrl.ScreenBorder = currentScreen.Bounds;
}

try
{
var screens = System.Windows.Forms.Screen.AllScreens;
for (int i = 0; i < screens.Length; i++)
{
if (screens[i].DeviceName == currentScreen.DeviceName)
{
mw.Set.GameScreenIndex = i;
break;
}
}
Comment thread
LorisYounger marked this conversation as resolved.
Outdated
}
catch
{
mw.Set.GameScreenIndex = 0;
}

UpdateMoveAreaText();
}

Expand Down