diff --git a/src/Magpie.Core/CursorManager.cpp b/src/Magpie.Core/CursorManager.cpp index ed2c6024f..cd739cc0d 100644 --- a/src/Magpie.Core/CursorManager.cpp +++ b/src/Magpie.Core/CursorManager.cpp @@ -142,7 +142,7 @@ static std::optional HostWndProc(HWND /*hWnd*/, UINT message, WPARAM /* return 0; } - if (!MagApp::Get().GetOptions().IsBreakpointMode()) { + if (!MagApp::Get().GetOptions().IsDebugMode()) { SetWindowPos(MagApp::Get().GetHwndHost(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); } } @@ -661,7 +661,7 @@ void CursorManager::_UpdateCursorClip() { const RECT& srcFrameRect = MagApp::Get().GetFrameSource().GetSrcFrameRect(); - if (!MagApp::Get().GetOptions().IsBreakpointMode() && MagApp::Get().GetOptions().Is3DGameMode()) { + if (!MagApp::Get().GetOptions().IsDebugMode() && MagApp::Get().GetOptions().Is3DGameMode()) { // 开启“在 3D 游戏中限制光标”则每帧都限制一次光标 _curClips = srcFrameRect; ClipCursor(&srcFrameRect); @@ -828,7 +828,7 @@ void CursorManager::_UpdateCursorClip() { } } - if (MagApp::Get().GetOptions().IsBreakpointMode()) { + if (MagApp::Get().GetOptions().IsDebugMode()) { return; } diff --git a/src/Magpie.Core/ImGuiImpl.cpp b/src/Magpie.Core/ImGuiImpl.cpp index ef476cd37..ef689927f 100644 --- a/src/Magpie.Core/ImGuiImpl.cpp +++ b/src/Magpie.Core/ImGuiImpl.cpp @@ -174,7 +174,7 @@ bool ImGuiImpl::Initialize() { } // 断点模式下不注册鼠标钩子,否则调试时鼠标无法使用 - if (!MagApp::Get().GetOptions().IsBreakpointMode() && !MagApp::Get().GetOptions().Is3DGameMode()) { + if (!MagApp::Get().GetOptions().IsDebugMode() && !MagApp::Get().GetOptions().Is3DGameMode()) { _hHookThread = CreateThread(nullptr, 0, ThreadProc, nullptr, 0, &_hookThreadId); if (!_hHookThread) { Logger::Get().Win32Error("创建线程失败"); diff --git a/src/Magpie.Core/MagApp.cpp b/src/Magpie.Core/MagApp.cpp index 58201b3b7..e102044b0 100644 --- a/src/Magpie.Core/MagApp.cpp +++ b/src/Magpie.Core/MagApp.cpp @@ -119,7 +119,7 @@ bool MagApp::Run(HWND hwndSrc, MagOptions&& options, winrt::DispatcherQueue cons return false; } - if (_options.IsDisableDirectFlip() && !_options.IsBreakpointMode()) { + if (_options.IsDisableDirectFlip() && !_options.IsDebugMode()) { // 在此处创建的 DDF 窗口不会立刻显示 if (!_DisableDirectFlip()) { Logger::Get().Error("_DisableDirectFlip 失败"); @@ -303,7 +303,7 @@ bool MagApp::_CreateHostWnd() { } _hwndHost = CreateWindowEx( - (_options.IsBreakpointMode() ? 0 : WS_EX_TOPMOST) | WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, + (_options.IsDebugMode() ? 0 : WS_EX_TOPMOST) | WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, HOST_WINDOW_CLASS_NAME, NULL, // 标题为空,否则会被添加新配置页面列为候选窗口 WS_POPUP, diff --git a/src/Magpie.Core/MagOptions.h b/src/Magpie.Core/MagOptions.h index 5c9c8062c..adf119e56 100644 --- a/src/Magpie.Core/MagOptions.h +++ b/src/Magpie.Core/MagOptions.h @@ -73,7 +73,7 @@ struct EffectOption { struct MagOptions { DEFINE_FLAG_ACCESSOR(IsDisableWindowResizing, MagFlags::DisableWindowResizing, flags) - DEFINE_FLAG_ACCESSOR(IsBreakpointMode, MagFlags::BreakpointMode, flags) + DEFINE_FLAG_ACCESSOR(IsDebugMode, MagFlags::BreakpointMode, flags) DEFINE_FLAG_ACCESSOR(IsDisableEffectCache, MagFlags::DisableEffectCache, flags) DEFINE_FLAG_ACCESSOR(IsSaveEffectSources, MagFlags::SaveEffectSources, flags) DEFINE_FLAG_ACCESSOR(IsWarningsAreErrors, MagFlags::WarningsAreErrors, flags) diff --git a/src/Magpie.Core/Renderer.cpp b/src/Magpie.Core/Renderer.cpp index 3aa641563..20068e7b6 100644 --- a/src/Magpie.Core/Renderer.cpp +++ b/src/Magpie.Core/Renderer.cpp @@ -229,7 +229,7 @@ const EffectDesc& Renderer::GetEffectDesc(uint32_t idx) const noexcept { bool Renderer::_CheckSrcState() { HWND hwndSrc = MagApp::Get().GetHwndSrc(); - if (!MagApp::Get().GetOptions().IsBreakpointMode()) { + if (!MagApp::Get().GetOptions().IsDebugMode()) { HWND hwndForeground = GetForegroundWindow(); // 在 3D 游戏模式下打开游戏内覆盖则全屏窗口可以接收焦点 if (!MagApp::Get().GetOptions().Is3DGameMode() || !IsUIVisiable() || hwndForeground != MagApp::Get().GetHwndHost()) { diff --git a/src/Magpie.UI/AboutPage.xaml b/src/Magpie.UI/AboutPage.xaml index 228284842..f22c7f0d3 100644 --- a/src/Magpie.UI/AboutPage.xaml +++ b/src/Magpie.UI/AboutPage.xaml @@ -29,17 +29,11 @@ - - - - + + - - - - + + diff --git a/src/Magpie.UI/AppSettings.cpp b/src/Magpie.UI/AppSettings.cpp index b6b5fd804..5c9d15fde 100644 --- a/src/Magpie.UI/AppSettings.cpp +++ b/src/Magpie.UI/AppSettings.cpp @@ -498,8 +498,8 @@ bool AppSettings::Save() { writer.Bool(_isAutoRestore); writer.Key("downCount"); writer.Uint(_downCount); - writer.Key("breakpointMode"); - writer.Bool(_isBreakpointMode); + writer.Key("debugMode"); + writer.Bool(_isDebugMode); writer.Key("disableEffectCache"); writer.Bool(_isDisableEffectCache); writer.Key("saveEffectSources"); @@ -700,7 +700,7 @@ bool AppSettings::_LoadSettings(std::string text) { return false; } - if (!LoadBoolSettingItem(root, "breakpointMode", _isBreakpointMode)) { + if (!LoadBoolSettingItem(root, "debugMode", _isDebugMode)) { return false; } if (!LoadBoolSettingItem(root, "disableEffectCache", _isDisableEffectCache)) { diff --git a/src/Magpie.UI/AppSettings.h b/src/Magpie.UI/AppSettings.h index cd5e17a44..32dbcdab4 100644 --- a/src/Magpie.UI/AppSettings.h +++ b/src/Magpie.UI/AppSettings.h @@ -128,12 +128,12 @@ class AppSettings { _downCountChangedEvent.remove(token); } - bool IsBreakpointMode() const noexcept { - return _isBreakpointMode; + bool IsDebugMode() const noexcept { + return _isDebugMode; } - void IsBreakpointMode(bool value) noexcept { - _isBreakpointMode = value; + void IsDebugMode(bool value) noexcept { + _isDebugMode = value; } bool IsDisableEffectCache() const noexcept { @@ -251,7 +251,7 @@ class AppSettings { bool _isShowTrayIcon = true; event> _isShowTrayIconChangedEvent; bool _isAlwaysRunAsElevated = false; - bool _isBreakpointMode = false; + bool _isDebugMode = false; bool _isDisableEffectCache = false; bool _isSaveEffectSources = false; bool _isWarningsAreErrors = false; diff --git a/src/Magpie.UI/HomePage.xaml b/src/Magpie.UI/HomePage.xaml index 1b2da4651..b293a6780 100644 --- a/src/Magpie.UI/HomePage.xaml +++ b/src/Magpie.UI/HomePage.xaml @@ -150,12 +150,10 @@ - - - - + - - - - + diff --git a/src/Magpie.UI/SettingItem.cpp b/src/Magpie.UI/SettingItem.cpp index a8ce6c08b..5e406d4bd 100644 --- a/src/Magpie.UI/SettingItem.cpp +++ b/src/Magpie.UI/SettingItem.cpp @@ -11,6 +11,13 @@ using namespace Windows::UI::Xaml::Data; namespace winrt::Magpie::UI::implementation { +DependencyProperty SettingItem::RawTitleProperty = DependencyProperty::Register( + L"RawTitle", + xaml_typename(), + xaml_typename(), + PropertyMetadata(nullptr, _OnTitleChanged) +); + DependencyProperty SettingItem::TitleProperty = DependencyProperty::Register( L"Title", xaml_typename(), @@ -43,6 +50,14 @@ SettingItem::SettingItem() { InitializeComponent(); } +void SettingItem::RawTitle(IInspectable const& value) { + SetValue(RawTitleProperty, value); +} + +IInspectable SettingItem::RawTitle() const { + return GetValue(RawTitleProperty); +} + void SettingItem::Title(const hstring& value) { SetValue(TitleProperty, box_value(value)); } @@ -51,7 +66,7 @@ hstring SettingItem::Title() const { return GetValue(TitleProperty).as(); } -void SettingItem::Description(IInspectable value) { +void SettingItem::Description(IInspectable const& value) { SetValue(DescriptionProperty, value); } @@ -59,7 +74,7 @@ IInspectable SettingItem::Description() const { return GetValue(DescriptionProperty); } -void SettingItem::Icon(IInspectable value) { +void SettingItem::Icon(IInspectable const& value) { SetValue(IconProperty, value); } @@ -67,7 +82,7 @@ IInspectable SettingItem::Icon() const { return GetValue(IconProperty); } -void SettingItem::ActionContent(IInspectable value) { +void SettingItem::ActionContent(IInspectable const& value) { SetValue(ActionContentProperty, value); } @@ -75,6 +90,12 @@ IInspectable SettingItem::ActionContent() const { return GetValue(ActionContentProperty); } +void SettingItem::_OnRawTitleChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&) { + SettingItem* that = get_self(sender.as>()); + that->_Update(); + that->_propertyChangedEvent(*that, PropertyChangedEventArgs{ L"RawTitle" }); +} + void SettingItem::_OnTitleChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&) { SettingItem* that = get_self(sender.as>()); that->_Update(); @@ -100,6 +121,8 @@ void SettingItem::_OnActionContentChanged(DependencyObject const& sender, Depend } void SettingItem::_Update() { + RawTitlePresenter().Visibility(RawTitle() == nullptr ? Visibility::Collapsed : Visibility::Visible); + TitleTextBlock().Visibility(Title().empty() ? Visibility::Collapsed : Visibility::Visible); DescriptionPresenter().Visibility(Description() == nullptr ? Visibility::Collapsed : Visibility::Visible); IconPresenter().Visibility(Icon() == nullptr ? Visibility::Collapsed : Visibility::Visible); } diff --git a/src/Magpie.UI/SettingItem.h b/src/Magpie.UI/SettingItem.h index fc0ef5374..edcb67d61 100644 --- a/src/Magpie.UI/SettingItem.h +++ b/src/Magpie.UI/SettingItem.h @@ -9,19 +9,23 @@ namespace winrt::Magpie::UI::implementation { struct SettingItem : SettingItemT { SettingItem(); + void RawTitle(IInspectable const& value); + + IInspectable RawTitle() const; + void Title(const hstring& value); hstring Title() const; - void Description(IInspectable value); + void Description(IInspectable const& value); IInspectable Description() const; - void Icon(IInspectable value); + void Icon(IInspectable const& value); IInspectable Icon() const; - void ActionContent(IInspectable value); + void ActionContent(IInspectable const& value); IInspectable ActionContent() const; @@ -31,12 +35,14 @@ struct SettingItem : SettingItemT { event_token PropertyChanged(Data::PropertyChangedEventHandler const& value); void PropertyChanged(event_token const& token); + static DependencyProperty RawTitleProperty; static DependencyProperty TitleProperty; static DependencyProperty DescriptionProperty; static DependencyProperty IconProperty; static DependencyProperty ActionContentProperty; private: + static void _OnRawTitleChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&); static void _OnTitleChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&); static void _OnDescriptionChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&); static void _OnIconChanged(DependencyObject const& sender, DependencyPropertyChangedEventArgs const&); diff --git a/src/Magpie.UI/SettingItem.idl b/src/Magpie.UI/SettingItem.idl index 6ec3668df..d3c24b687 100644 --- a/src/Magpie.UI/SettingItem.idl +++ b/src/Magpie.UI/SettingItem.idl @@ -1,11 +1,13 @@ namespace Magpie.UI { + [Windows.UI.Xaml.Markup.ContentProperty("RawTitle")] [Windows.UI.Xaml.TemplateVisualState("Normal", "CommonStates")] [Windows.UI.Xaml.TemplateVisualState("Disabled", "CommonStates")] runtimeclass SettingItem : Windows.UI.Xaml.Controls.UserControl, [default] Windows.UI.Xaml.Data.INotifyPropertyChanged { SettingItem(); - + + Object RawTitle; String Title; Object Description; Object Icon; diff --git a/src/Magpie.UI/SettingItem.xaml b/src/Magpie.UI/SettingItem.xaml index 1c4f3ec82..db8280a80 100644 --- a/src/Magpie.UI/SettingItem.xaml +++ b/src/Magpie.UI/SettingItem.xaml @@ -48,6 +48,13 @@ Foreground="{ThemeResource CardPrimaryForegroundBrush}" IsTextScaleFactorEnabled="False" /> + + + diff --git a/src/Magpie.UI/SettingsPage.xaml b/src/Magpie.UI/SettingsPage.xaml index 7e6279fb2..cb5fbebe4 100644 --- a/src/Magpie.UI/SettingsPage.xaml +++ b/src/Magpie.UI/SettingsPage.xaml @@ -41,14 +41,17 @@ - - - - - + + + + + + - - - - + + - - - - + + - - - - + + - - - - + + diff --git a/src/Magpie.UI/SettingsViewModel.cpp b/src/Magpie.UI/SettingsViewModel.cpp index b0a74714f..824bd1205 100644 --- a/src/Magpie.UI/SettingsViewModel.cpp +++ b/src/Magpie.UI/SettingsViewModel.cpp @@ -92,7 +92,7 @@ bool SettingsViewModel::IsShowTrayIcon() const noexcept { void SettingsViewModel::IsShowTrayIcon(bool value) noexcept { AppSettings::Get().IsShowTrayIcon(value); - _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsMinimizeAtStartupEnabled")); + _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsShowTrayIcon")); if (_isRunAtStartup) { AutoStartHelper::EnableAutoStart(AppSettings::Get().IsAlwaysRunAsElevated(), nullptr); @@ -132,19 +132,19 @@ void SettingsViewModel::IsInlineParams(bool value) noexcept { _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsInlineParams")); } -bool SettingsViewModel::IsBreakpointMode() const noexcept { - return AppSettings::Get().IsBreakpointMode(); +bool SettingsViewModel::IsDebugMode() const noexcept { + return AppSettings::Get().IsDebugMode(); } -void SettingsViewModel::IsBreakpointMode(bool value) noexcept { +void SettingsViewModel::IsDebugMode(bool value) noexcept { AppSettings& settings = AppSettings::Get(); - if (settings.IsBreakpointMode() == value) { + if (settings.IsDebugMode() == value) { return; } - settings.IsBreakpointMode(value); - _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsBreakpointMode")); + settings.IsDebugMode(value); + _propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsDebugMode")); } bool SettingsViewModel::IsDisableEffectCache() const noexcept { diff --git a/src/Magpie.UI/SettingsViewModel.h b/src/Magpie.UI/SettingsViewModel.h index d3fa2f443..a46332dd4 100644 --- a/src/Magpie.UI/SettingsViewModel.h +++ b/src/Magpie.UI/SettingsViewModel.h @@ -38,8 +38,8 @@ struct SettingsViewModel : SettingsViewModelT { bool IsInlineParams() const noexcept; void IsInlineParams(bool value) noexcept; - bool IsBreakpointMode() const noexcept; - void IsBreakpointMode(bool value) noexcept; + bool IsDebugMode() const noexcept; + void IsDebugMode(bool value) noexcept; bool IsDisableEffectCache() const noexcept; void IsDisableEffectCache(bool value) noexcept; diff --git a/src/Magpie.UI/SettingsViewModel.idl b/src/Magpie.UI/SettingsViewModel.idl index 032eb4c7e..e84638e7a 100644 --- a/src/Magpie.UI/SettingsViewModel.idl +++ b/src/Magpie.UI/SettingsViewModel.idl @@ -13,7 +13,7 @@ namespace Magpie.UI Boolean IsShowTrayIcon; Boolean IsSimulateExclusiveFullscreen; Boolean IsInlineParams; - Boolean IsBreakpointMode; + Boolean IsDebugMode; Boolean IsDisableEffectCache; Boolean IsSaveEffectSources; Boolean IsWarningsAreErrors;