diff --git a/src/Magpie.App/App.idl b/src/Magpie.App/App.idl index c7058f01..aa683571 100644 --- a/src/Magpie.App/App.idl +++ b/src/Magpie.App/App.idl @@ -43,6 +43,7 @@ namespace Magpie.App { enum ShortcutAction { Scale, Overlay, + Is3DGameMode, COUNT_OR_NONE }; diff --git a/src/Magpie.App/AppSettings.cpp b/src/Magpie.App/AppSettings.cpp index 8eb94b25..6b67c11f 100644 --- a/src/Magpie.App/AppSettings.cpp +++ b/src/Magpie.App/AppSettings.cpp @@ -499,6 +499,8 @@ bool AppSettings::_Save(const _AppSettingsData& data) noexcept { writer.Uint(EncodeShortcut(data._shortcuts[(size_t)ShortcutAction::Scale])); writer.Key("overlay"); writer.Uint(EncodeShortcut(data._shortcuts[(size_t)ShortcutAction::Overlay])); + writer.Key("3DGameMode"); + writer.Uint(EncodeShortcut(data._shortcuts[(size_t)ShortcutAction::Is3DGameMode])); writer.EndObject(); writer.Key("autoRestore"); @@ -654,6 +656,11 @@ void AppSettings::_LoadSettings(const rapidjson::GenericObjectvalue.IsUint()) { DecodeShortcut(overlayNode->value.GetUint(), _shortcuts[(size_t)ShortcutAction::Overlay]); } + + auto is3DGameModeNode = shortcutsObj.FindMember("3DGameMode"); + if (is3DGameModeNode != shortcutsObj.MemberEnd() && is3DGameModeNode->value.IsUint()) { + DecodeShortcut(is3DGameModeNode->value.GetUint(), _shortcuts[(size_t)ShortcutAction::Is3DGameMode]); + } } JsonHelper::ReadBool(root, "autoRestore", _isAutoRestore); @@ -771,6 +778,10 @@ bool AppSettings::_LoadProfile( JsonHelper::ReadString(profileObj, "launcherPath", profile.launcherPath); JsonHelper::ReadBool(profileObj, "autoScale", profile.isAutoScale); JsonHelper::ReadString(profileObj, "launchParameters", profile.launchParameters); + + if (!application.isPackaged) { + _SetTruePath(profile); + } } JsonHelper::ReadInt(profileObj, "scalingMode", profile.scalingMode); @@ -874,6 +885,37 @@ bool AppSettings::_LoadProfile( return true; } +fire_and_forget AppSettings::_SetTruePath(Profile& profile) const { + HANDLE handle = CreateFile( + profile.pathRule.c_str(), + GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL + ); + + if (handle == INVALID_HANDLE_VALUE) { + co_return; + } + + TCHAR path[MAX_PATH]; + DWORD length = GetFinalPathNameByHandle( + handle, + path, + MAX_PATH, + 0 + ); + + if (length > 0) { + // Skip `\\?\` prefix + profile.truePath = &path[4]; + } + + CloseHandle(handle); +} + bool AppSettings::_SetDefaultShortcuts() noexcept { bool changed = false; @@ -895,6 +937,15 @@ bool AppSettings::_SetDefaultShortcuts() noexcept { changed = true; } + Shortcut& is3DGameModeShortcut = _shortcuts[(size_t)ShortcutAction::Is3DGameMode]; + if (is3DGameModeShortcut.IsEmpty()) { + is3DGameModeShortcut.win = true; + is3DGameModeShortcut.shift = true; + is3DGameModeShortcut.code = 'E'; + + changed = true; + } + return changed; } diff --git a/src/Magpie.App/AppSettings.h b/src/Magpie.App/AppSettings.h index c05a982f..d8a58292 100644 --- a/src/Magpie.App/AppSettings.h +++ b/src/Magpie.App/AppSettings.h @@ -305,6 +305,7 @@ class AppSettings : private _AppSettingsData { Profile& profile, bool isDefault = false ) const noexcept; + fire_and_forget _SetTruePath(ProfileApplication& application) const; bool _SetDefaultShortcuts() noexcept; void _SetDefaultScalingModes() noexcept; diff --git a/src/Magpie.App/HomePage.xaml b/src/Magpie.App/HomePage.xaml index daf54f3a..d86fd0d7 100644 --- a/src/Magpie.App/HomePage.xaml +++ b/src/Magpie.App/HomePage.xaml @@ -1,45 +1,45 @@ + 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:local="using:Magpie.App" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" + mc:Ignorable="d"> + x:Uid="Home_PageFrame"> + HorizontalAlignment="Stretch" + ChildrenTransitions="{StaticResource SettingsCardsAnimations}" + Spacing="{StaticResource SettingsGroupSpacing}"> + Title="{x:Bind ViewModel.UpdateCardTitle, Mode=OneWay}" + x:Load="{x:Bind ViewModel.ShowUpdateCard, Mode=OneWay}" + IsOpen="{x:Bind ViewModel.ShowUpdateCard, Mode=TwoWay}" + Severity="Informational"> + Spacing="8"> + IsChecked="{x:Bind ViewModel.IsAutoCheckForUpdates, Mode=TwoWay}"/> + HorizontalSpacing="8" + Orientation="Horizontal" + VerticalSpacing="6">