mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-09 00:34:14 +08:00
fix: 修复地图遮罩关闭时UI状态未正确重置的问题 #2940
当关闭地图遮罩功能时,确保所有挂起的计算任务被清理,并重置UI状态到初始值。同时修复了在配置禁用时UI状态未同步更新的问题。
This commit is contained in:
@@ -87,14 +87,25 @@ public class MapMaskTrigger : ITaskTrigger
|
||||
// 关闭时隐藏UI
|
||||
if (!IsEnabled)
|
||||
{
|
||||
var pendingBigMapCompute = Interlocked.Exchange(ref _pendingBigMapCompute, null);
|
||||
pendingBigMapCompute?.Dispose();
|
||||
var pendingMiniMapCompute = Interlocked.Exchange(ref _pendingMiniMapCompute, null);
|
||||
pendingMiniMapCompute?.Dispose();
|
||||
|
||||
Interlocked.Exchange(ref _pendingUiUpdate, null);
|
||||
|
||||
UIDispatcherHelper.BeginInvoke(() =>
|
||||
{
|
||||
if (MaskWindow.InstanceNullable() != null)
|
||||
{
|
||||
if (MaskWindow.Instance().DataContext is MaskWindowViewModel vm)
|
||||
var window = MaskWindow.Instance();
|
||||
if (window.DataContext is MaskWindowViewModel vm)
|
||||
{
|
||||
vm.IsInBigMapUi = false;
|
||||
}
|
||||
|
||||
window.PointsCanvasControl.UpdateViewport(0, 0, 0, 0);
|
||||
window.MiniMapPointsCanvasControl.UpdateViewport(0, 0, 0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -396,6 +407,19 @@ public class MapMaskTrigger : ITaskTrigger
|
||||
if (update != null)
|
||||
{
|
||||
var window = MaskWindow.Instance();
|
||||
if (!_config.Enabled)
|
||||
{
|
||||
if (window.DataContext is MaskWindowViewModel vmWhenDisabled)
|
||||
{
|
||||
vmWhenDisabled.IsInBigMapUi = false;
|
||||
}
|
||||
|
||||
window.PointsCanvasControl.UpdateViewport(0, 0, 0, 0);
|
||||
window.MiniMapPointsCanvasControl.UpdateViewport(0, 0, 0, 0);
|
||||
Interlocked.Exchange(ref _uiApplyScheduled, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (update.IsInBigMapUi is { } isInBigMapUi && window.DataContext is MaskWindowViewModel vm)
|
||||
{
|
||||
vm.IsInBigMapUi = isInBigMapUi;
|
||||
|
||||
Reference in New Issue
Block a user