Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docs/development/Roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ Updated 2026-11-04 against main after the v4.7.3 release (`5dfe728`). This bring

| 问题 | 现状 | 做法 |
| --- | --- | --- |
| 热应用提示说得太肯定 | 按键发送成功且文件未被改写,就显示“加载器已重新读取”(`MainWindow.HotReload.cs` 的 `HotReload.ReloadSent`);游戏没有响应 F10 时,结果也一样 | 改成“已发送 F10,请到游戏里确认”,中英文都改 |
| 界面没说明 Mod 按键不能在这里改 | 按键绑定只读、要改需编辑 INI,这些只写在文档里;状态槽位也没说明它不包含按键 | Shortcuts 页直接提示,并加“打开所在 INI”按钮;状态槽位说明它只保存参数值 |
| 浮窗快捷键容易漏点“应用” | 下拉框选择后不生效,也没有未应用提示 | 选择后立即生效,或在未应用时给出提示 |
| 热应用提示说得太肯定 | 按键发送成功且文件未被改写,就显示“加载器已重新读取”(`MainWindow.HotReload.cs` 的 `HotReload.ReloadSent`);游戏没有响应 F10 时,结果也一样 | 改成“已发送 F10,请到游戏里确认”,中英文都改。**已完成**(4.6.2,`8b1f447`;俄语随 4.7.3 加入时也是这个说法) |
| 界面没说明 Mod 按键不能在这里改 | 按键绑定只读、要改需编辑 INI,这些只写在文档里;状态槽位也没说明它不包含按键 | Shortcuts 页直接提示,并加“打开所在 INI”按钮;状态槽位说明它只保存参数值。**已完成**(4.6.2,`8b1f447`);J5 起“显示 INI 文件”在按键绑定标题行的“…”菜单里 |
| 浮窗快捷键容易漏点“应用” | 下拉框选择后不生效,也没有未应用提示 | 选择后立即生效,或在未应用时给出提示。下拉框在 4.6.2 已改为立即生效;J5 去掉了剩下的“应用”按钮,改成“全局快捷键”开关 |

“在管理器内改 Mod 按键”不列入:等确认用户需求后再评估。它要写入 Mod 自身的 INI,必须备份和回滚,还要处理 Mod 更新后改动被覆盖的问题。

Expand Down
23 changes: 23 additions & 0 deletions docs/development/UI-Structure-Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ J0 结果(2026-11-04,分支 `claude/ui-j0-prep`):

“预设是否对应某个仓库”的判断移到 `RepositoryPresetMatching`,和路径的状态一起补了单元测试。仪表盘的统计、扫描、仓库卡片的数据仍由窗口计算,因为它们用到在线页的分类信息和工作区已加载的角色。

#### J5 牵连清单(快捷键页和浮窗)

快捷键页在 `MainWindow.xaml` 里只有一个空容器(`ShortcutsScrollViewer` > `ShortcutPaneContent`),整页由 `MainWindow.ShortcutPanel.cs`(1249 行)在代码里搭建,控件存在窗口字段里(约 40 个)。浮窗 `ShortcutOverlayWindow` 本身不调用窗口,但它的内容(`BuildShortcutOverlayContent`)也由窗口搭建,按钮直接调窗口方法,而且和页面共用同一组控件和状态。页面的设置栏有六块是别的 partial 文件往里加的。

| 位置 | 做什么 | 打算改成 |
| --- | --- | --- |
| `ShortcutPanel.cs` | 搭建整页(标题、工具栏、绑定卡片、设置栏)、排布、扫描 INI、发送按键、浮窗内容、全局热键、权限提示、以管理员身份重启 | 页面控件进 `Pages/ShortcutsPage`;扫描、发送、热键、重启留在窗口或服务,经 `ShortcutPageViewModel` 和请求事件交互 |
| 页面和浮窗共用的控件 | 浮窗的 Mod 下拉框把选择转给页面的 `_shortcutModPicker`;浮窗的“输入”开关改页面的 `_shortcutEnabledToggle`;浮窗读页面的目标窗口和状态行;两个透明度滑块互相同步 | 共用状态进 ViewModel:Mod 列表和当前 Mod、目标窗口、`InputEnabled`、`StatusText`、`OverlayOpacity`;页面和浮窗都只绑定 ViewModel |
| `HotReload.cs`、`PresetPreviews.cs`、`ShortcutCapture.cs`、`ShortcutPresets.cs`、`OverlayAppearance.cs`(共 5 个文件,约 20 处) | 写页面的状态行 `_shortcutStatus.Text`,读页面选中的 Mod 和目标窗口 | 改写 `ShortcutPageViewModel.StatusText`、读 ViewModel |
| 同上加 `PersistentSlots.cs`(约 20 处) | `RefreshShortcutOverlay(...)` 刷新浮窗 | 浮窗接口的 `Refresh(bindingsChanged)` |
| `OverlayAppearance.cs`、`OverlayAutoContrast.cs`、`HotReload.cs`、`PresetPreviews.cs`、`SlotCapture.cs`、`CharacterFollow.cs` | 各自往设置栏里加一块控件(外观预设、元素透明度、文字颜色、自动对比度、状态槽位热切换、预设预览、槽位截图区域、角色跟随),控件的事件直接改窗口字段并保存配置 | 设置进 ViewModel(每项一个属性),页面用 `SettingsCard`/`SettingsExpander` 显示;窗口监听属性变化后照旧应用到浮窗并保存 |
| `AppearanceEvents.cs` | 换语言时整页和浮窗重建;换主题时清掉绑定卡片缓存 | 页面自己在 `LanguageChanged`、`ThemeChanged` 里重写文字;浮窗经接口重建 |
| `Shell.cs`、`PageLayout.cs` | 第一次打开时 `BuildShortcutPane` 和刷新;`AttachPageLayout(ShortcutsScrollViewer, UpdateShortcutsLayout)`;关窗口时 `CloseShortcutPanel` | 快捷键页直接是 `ShortcutsPage`,页面按自己的尺寸排布;关闭仍在窗口 |
| `Configuration.cs` | 读写快捷键和浮窗的 15 项设置 | 读写 ViewModel |
| 全局热键(`ShortcutPanelHotkey`) | 窗口注册,按下时 `ToggleShortcutOverlay`;页面的两个下拉框改热键 | 留在窗口;页面改 ViewModel 的热键属性,窗口尝试注册,失败时把属性改回 |
| 托盘 | 不碰快捷键页和浮窗 | 不变,留在外壳 |

不属于这一页的:`ShortcutBindings.cs`(710 行)是 Mod 工作区“快捷键”标签页的编辑器,J7 随工作区一起移。

浮窗接口(打算):`IShortcutOverlay`,窗口和页面只通过它打开、隐藏、切换、刷新浮窗和查询是否可见、是否点击穿透;浮窗内容改为单独的类,它需要的操作(发送绑定、切换状态槽位、保存预设、从磁盘刷新、选 Mod、开关输入)由 `IShortcutOverlayActions` 提供,窗口实现这个接口。

范围:上面这些合计约 3100 行、10 个文件,比阶段表里估的 M 大。

### J8. 对话框与资源

- 每种对话框一个类(`Dialogs/` 下),由 `DialogService` 统一设置 `XamlRoot` 并保证同一时间只有一个对话框。
Expand Down
17 changes: 0 additions & 17 deletions src/IntegratedModManager.Core/Layout/ShortcutsLayoutPolicy.cs

This file was deleted.

28 changes: 28 additions & 0 deletions src/IntegratedModManager.Core/Shortcuts/ShortcutKeyCaps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace IntegratedModManager.Core.Shortcuts;

/// <summary>Splits a binding's key text ("Ctrl+Shift+H") into the keys drawn as separate key caps.</summary>
public static class ShortcutKeyCaps
{
/// <summary>The keys in order; a "+" that is a key itself ("Ctrl++") stays one key.</summary>
public static IReadOnlyList<string> Split(string? keys)
{
var caps = new List<string>();
if (string.IsNullOrWhiteSpace(keys)) return caps;
var current = new System.Text.StringBuilder();
foreach (char c in keys.Trim())
{
if (c == '+' && current.Length > 0)
{
caps.Add(current.ToString().Trim());
current.Clear();
}
else
{
current.Append(c);
}
}
if (current.Length > 0) caps.Add(current.ToString().Trim());
caps.RemoveAll(string.IsNullOrEmpty);
return caps;
}
}
30 changes: 30 additions & 0 deletions src/WinUI3/Controls/KeyVisual.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl
x:Class="ModFolderCopier.WinUI.KeyVisual"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
IsTabStop="False">
<!-- Keys drawn as key caps, one per key, like PowerToys (UI-Fluent-Design-Plan.md, "快捷键(J5)"). -->
<ItemsControl x:Name="KeyItems" IsTabStop="False">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Border
MinWidth="28"
Padding="8,2,8,3"
Background="{ThemeResource ControlFillColorSecondaryBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1,1,1,2"
CornerRadius="{ThemeResource ControlCornerRadius}">
<TextBlock
HorizontalAlignment="Center"
Style="{StaticResource BodyStrongTextBlockStyle}"
Text="{x:Bind}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</UserControl>
35 changes: 35 additions & 0 deletions src/WinUI3/Controls/KeyVisual.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using IntegratedModManager.Core.Shortcuts;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Controls;

namespace ModFolderCopier.WinUI;

/// <summary>
/// A key combination drawn as separate key caps ("Ctrl" "Shift" "H"). Narrator reads the whole combination.
/// Stage J5; the Mod workspace's Shortcuts tab can use it too.
/// </summary>
public sealed partial class KeyVisual : UserControl
{
public static readonly DependencyProperty KeysProperty = DependencyProperty.Register(
nameof(Keys), typeof(string), typeof(KeyVisual),
new PropertyMetadata(string.Empty, (sender, _) => ((KeyVisual)sender).OnKeysChanged()));

public KeyVisual()
{
InitializeComponent();
}

/// <summary>The keys joined with "+", as a binding shows them.</summary>
public string Keys
{
get => (string)GetValue(KeysProperty);
set => SetValue(KeysProperty, value);
}

private void OnKeysChanged()
{
KeyItems.ItemsSource = ShortcutKeyCaps.Split(Keys);
AutomationProperties.SetName(this, Keys);
}
}
10 changes: 2 additions & 8 deletions src/WinUI3/MainWindow.AppearanceEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ private void SubscribeToAppearanceEvents()
appearance.ThemeChanged += (_, _) => RenderModSummary();
// Shell: the selected navigation item.
appearance.ThemeChanged += (_, _) => RefreshPrimaryNavigationVisuals();
// Shortcuts: binding cards take their key-cap colours when created; drop them so they are rebuilt.
appearance.ThemeChanged += (_, _) =>
{
UpdateShortcutKeyFocusVisuals();
_mainShortcutControls.Clear();
_mainBindings = [];
RenderShortcutButtons();
};
// Mod workspace: the shortcut editor's key boxes (the Shortcuts page redraws its own cards).
appearance.ThemeChanged += (_, _) => UpdateShortcutKeyFocusVisuals();

appearance.DensityChanged += (_, _) => ApplyShellDensity();
appearance.DensityChanged += (_, _) => ApplyWorkspaceDensity(appearance.IsCompact);
Expand Down
14 changes: 7 additions & 7 deletions src/WinUI3/MainWindow.CharacterFollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void UpdateCharacterFollowSummary()

private string? SelectedShortcutRole()
{
if (_shortcutModPicker?.SelectedItem is not ShortcutModOption mod) return null;
if (_shortcuts.SelectedMod is not ShortcutModOption mod) return null;
return mod.Label.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)[0];
}

Expand Down Expand Up @@ -120,7 +120,7 @@ private void SaveCharacterFollowProfile()

private async Task<CharacterFrame> CaptureCharacterReferenceAsync()
{
if (_shortcutTargetPicker?.SelectedItem is not ShortcutTarget target) throw new InvalidOperationException(T("CharacterFollow.SelectAGameWindow"));
if (_shortcuts.SelectedTarget is not ShortcutTarget target) throw new InvalidOperationException(T("CharacterFollow.SelectAGameWindow"));
_shortcutOverlay?.AppWindow.Hide();
if (!ShortcutInputService.FocusTarget(target)) throw new InvalidOperationException(T("CharacterFollow.CouldNotFocusTheGameWindow"));
await Task.Delay(300);
Expand Down Expand Up @@ -192,7 +192,7 @@ private async Task SaveCharacterReferenceAsync()
byte[] feature = CharacterImageMatcher.Extract(frame.Bgra, frame.Width, frame.Height, region);
if (!CharacterImageMatcher.HasDetail(feature)) throw new InvalidOperationException(T("CharacterFollow.TheRegionIsTooUniformOr"));
_characterProfile.Templates[role] = feature;
if (_shortcutModPicker?.SelectedItem is ShortcutModOption selected) _characterPreferredMods[role] = selected.Path;
if (_shortcuts.SelectedMod is ShortcutModOption selected) _characterPreferredMods[role] = selected.Path;
SaveCharacterFollowProfile();
Activate();
_characterFollowStatus!.Text = T("CharacterFollow.SavedReferenceForTotal", role, _characterProfile.Templates.Count);
Expand All @@ -204,7 +204,7 @@ private async Task SaveCharacterReferenceAsync()
private async Task ObserveCharacterAsync()
{
if (_characterCaptureBusy || _onlineWindowClosed || _characterFollowToggle?.IsOn != true
|| _shortcuts.SendInProgress || _shortcutTargetPicker?.SelectedItem is not ShortcutTarget target
|| _shortcuts.SendInProgress || _shortcuts.SelectedTarget is not ShortcutTarget target
|| _characterProfile.Region is not CharacterScreenRegion region) return;
if (!ShortcutInputService.IsTargetForeground(target))
{
Expand All @@ -221,7 +221,7 @@ private async Task ObserveCharacterAsync()
{ _characterMatcher.Reset(); _characterFollowStatus!.Text = T("CharacterFollow.MoveTheOverlayAwayFromThe"); return; }
CharacterFrame frame = await Task.Run(() => CharacterScreenCapture.Capture(target, _services.Language.Current));
if (_onlineWindowClosed || _characterFollowToggle?.IsOn != true) return;
if (_shortcutTargetPicker?.SelectedItem is not ShortcutTarget current
if (_shortcuts.SelectedTarget is not ShortcutTarget current
|| current.Handle != target.Handle || current.StartTicks != target.StartTicks)
{ _characterMatcher.Reset(); return; }
byte[] feature = CharacterImageMatcher.Extract(frame.Bgra, frame.Width, frame.Height, region);
Expand All @@ -230,7 +230,7 @@ private async Task ObserveCharacterAsync()
? T("CharacterFollow.WaitingForStableRecognition", confidence)
: T("CharacterFollow.CurrentCharacter", role, confidence);
if (role is null || role.Equals(SelectedShortcutRole(), StringComparison.OrdinalIgnoreCase)) return;
var candidates = _shortcutModPicker!.ItemsSource as ShortcutModOption[] ?? [];
var candidates = _shortcuts.ModOptions as ShortcutModOption[] ?? [];
var matching = candidates.Where(p => p.Label.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)[0].Equals(role, StringComparison.OrdinalIgnoreCase)).ToArray();
// Only an enabled Mod can react in game; prefer those when the role has any.
var enabled = matching.Where(IsShortcutModDeployed).ToArray();
Expand All @@ -241,7 +241,7 @@ private async Task ObserveCharacterAsync()
_characterFollowStatus.Text = T("CharacterFollow.HasMultipleModsChooseOneManually", role);
if (selected is null) return;
_characterAutoSelecting = true;
try { _shortcutModPicker.SelectedItem = selected; }
try { _shortcuts.SelectedMod = selected; }
finally { _characterAutoSelecting = false; }
}
catch (Exception ex) { _characterMatcher.Reset(); if (!_onlineWindowClosed) _characterFollowStatus!.Text = ex.Message; }
Expand Down
Loading
Loading