From ff3c0e1b02f971dd1b43287f3b658d184fafc6fd Mon Sep 17 00:00:00 2001 From: Masusder <59669685+Masusder@users.noreply.github.com> Date: Mon, 10 Aug 2026 18:48:15 +0200 Subject: [PATCH] Export hotkeys --- FModel/MainWindow.xaml.cs | 25 +++ FModel/Settings/UserSettings.cs | 60 ++++++- FModel/ViewModels/TabControlViewModel.cs | 12 +- .../ContextMenus/FileContextMenu.xaml | 105 ++++++++++-- .../{HotkeyTextBox.cs => HotkeyControls.cs} | 60 ++++++- FModel/Views/Resources/Resources.xaml | 30 ++++ FModel/Views/SettingsView.xaml | 149 +++++++++++------- 7 files changed, 367 insertions(+), 74 deletions(-) rename FModel/Views/Resources/Controls/{HotkeyTextBox.cs => HotkeyControls.cs} (62%) diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index 25e82893..2e2a4e5a 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -179,6 +179,22 @@ public partial class MainWindow _ => CategoriesSelector.SelectedIndex }; } + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportData.IsTriggered(e.Key)) + ExportSelected("Save_Data"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportProperties.IsTriggered(e.Key)) + ExportSelected("Save_Properties"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportTextures.IsTriggered(e.Key)) + ExportSelected("Save_Textures"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportModels.IsTriggered(e.Key)) + ExportSelected("Save_Models"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportWorlds.IsTriggered(e.Key)) + ExportSelected("Save_Worlds"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportAnimations.IsTriggered(e.Key)) + ExportSelected("Save_Animations"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportAudio.IsTriggered(e.Key)) + ExportSelected("Save_Audio"); + else if (_applicationView.Status.IsReady && UserSettings.Default.ExportCode.IsTriggered(e.Key)) + ExportSelected("Save_Code"); else if (_applicationView.Status.IsReady && UserSettings.Default.FeaturePreviewNewAssetExplorer && UserSettings.Default.SwitchAssetExplorer.IsTriggered(e.Key)) _applicationView.IsAssetsExplorerVisible = !_applicationView.IsAssetsExplorerVisible; else if (UserSettings.Default.AssetAddTab.IsTriggered(e.Key)) @@ -379,6 +395,15 @@ public partial class MainWindow childFolder.IsSelected = true; } + private void ExportSelected(string trigger) + { + var selectedItems = AssetsListName.SelectedItems.Cast().ToArray(); + if (selectedItems.Length == 0) + return; + + _applicationView.RightClickMenuCommand.Execute(_applicationView, new object[] { trigger, selectedItems }); + } + private CustomPopupPlacement[] OnQueueToastCustomPopupPlacement(Size popupSize, Size targetSize, Point offset) { return diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index d9527db6..3c79a238 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -382,14 +382,14 @@ public sealed class UserSettings : ViewModel set => SetProperty(ref _assetRightTab, value); } - private Hotkey _assetAddTab = new(Key.T, ModifierKeys.Control); + private Hotkey _assetAddTab = new(Key.OemPlus, ModifierKeys.Control); public Hotkey AssetAddTab { get => _assetAddTab; set => SetProperty(ref _assetAddTab, value); } - private Hotkey _assetRemoveTab = new(Key.W, ModifierKeys.Control); + private Hotkey _assetRemoveTab = new(Key.R, ModifierKeys.Control); public Hotkey AssetRemoveTab { get => _assetRemoveTab; @@ -431,6 +431,62 @@ public sealed class UserSettings : ViewModel set => SetProperty(ref _nextAudio, value); } + private Hotkey _exportData = new(Key.D, ModifierKeys.Control); + public Hotkey ExportData + { + get => _exportData; + set => SetProperty(ref _exportData, value); + } + + private Hotkey _exportProperties = new(Key.P, ModifierKeys.Control); + public Hotkey ExportProperties + { + get => _exportProperties; + set => SetProperty(ref _exportProperties, value); + } + + private Hotkey _exportTextures = new(Key.T, ModifierKeys.Control); + public Hotkey ExportTextures + { + get => _exportTextures; + set => SetProperty(ref _exportTextures, value); + } + + private Hotkey _exportModels = new(Key.M, ModifierKeys.Control); + public Hotkey ExportModels + { + get => _exportModels; + set => SetProperty(ref _exportModels, value); + } + + private Hotkey _exportWorlds = new(Key.W, ModifierKeys.Control); + public Hotkey ExportWorlds + { + get => _exportWorlds; + set => SetProperty(ref _exportWorlds, value); + } + + private Hotkey _exportAnimations = new(Key.N, ModifierKeys.Control); + public Hotkey ExportAnimations + { + get => _exportAnimations; + set => SetProperty(ref _exportAnimations, value); + } + + private Hotkey _exportAudio = new(Key.U, ModifierKeys.Control); + public Hotkey ExportAudio + { + get => _exportAudio; + set => SetProperty(ref _exportAudio, value); + } + + private Hotkey _exportCode = new(Key.C, ModifierKeys.Control); + public Hotkey ExportCode + { + get => _exportCode; + set => SetProperty(ref _exportCode, value); + } + private EMeshFormat _meshExportFormat = EMeshFormat.UEFormat; public EMeshFormat MeshExportFormat { diff --git a/FModel/ViewModels/TabControlViewModel.cs b/FModel/ViewModels/TabControlViewModel.cs index ad8abe95..e7728347 100644 --- a/FModel/ViewModels/TabControlViewModel.cs +++ b/FModel/ViewModels/TabControlViewModel.cs @@ -517,8 +517,16 @@ public class TabControlViewModel : ViewModel } public event EventHandler OnTabRemove; - public void GoLeftTab() => SelectedTab = _tabItems.Previous(SelectedTab); - public void GoRightTab() => SelectedTab = _tabItems.Next(SelectedTab); + public void GoLeftTab() + { + if (_tabItems.Count > 0) + SelectedTab = _tabItems.Previous(SelectedTab); + } + public void GoRightTab() + { + if (_tabItems.Count > 0) + SelectedTab = _tabItems.Next(SelectedTab); + } public void RemoveOtherTabs(TabItem tab) { diff --git a/FModel/Views/Resources/Controls/ContextMenus/FileContextMenu.xaml b/FModel/Views/Resources/Controls/ContextMenus/FileContextMenu.xaml index afba4a08..414d4d43 100644 --- a/FModel/Views/Resources/Controls/ContextMenus/FileContextMenu.xaml +++ b/FModel/Views/Resources/Controls/ContextMenus/FileContextMenu.xaml @@ -2,7 +2,62 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI" xmlns:settings="clr-namespace:FModel.Settings" + xmlns:controls="clr-namespace:FModel.Views.Resources.Controls" xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"> + + + + + + + + + + + + + + + + @@ -122,7 +177,9 @@ - + + @@ -159,15 +219,21 @@ - + + - + - + @@ -178,14 +244,20 @@ - - - + + + - + @@ -211,7 +283,10 @@ - + @@ -241,7 +316,10 @@ - + @@ -267,7 +345,10 @@ - + diff --git a/FModel/Views/Resources/Controls/HotkeyTextBox.cs b/FModel/Views/Resources/Controls/HotkeyControls.cs similarity index 62% rename from FModel/Views/Resources/Controls/HotkeyTextBox.cs rename to FModel/Views/Resources/Controls/HotkeyControls.cs index 384e3941..474da0a8 100644 --- a/FModel/Views/Resources/Controls/HotkeyTextBox.cs +++ b/FModel/Views/Resources/Controls/HotkeyControls.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -5,6 +6,63 @@ using FModel.Framework; namespace FModel.Views.Resources.Controls; +public class HotkeySetting : Control +{ + public string Label + { + get => (string) GetValue(LabelProperty); + set => SetValue(LabelProperty, value); + } + + public static readonly DependencyProperty LabelProperty = + DependencyProperty.Register(nameof(Label), typeof(string), typeof(HotkeySetting), new PropertyMetadata(string.Empty)); + + public Hotkey HotKey + { + get => (Hotkey) GetValue(HotKeyProperty); + set => SetValue(HotKeyProperty, value); + } + + public static readonly DependencyProperty HotKeyProperty = + DependencyProperty.Register(nameof(HotKey), typeof(Hotkey), typeof(HotkeySetting), new FrameworkPropertyMetadata(new Hotkey(Key.None), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); +} + +public class HotkeyDisplay : ItemsControl +{ + public Hotkey HotKey + { + get => (Hotkey) GetValue(HotKeyProperty); + set => SetValue(HotKeyProperty, value); + } + + public static readonly DependencyProperty HotKeyProperty = + DependencyProperty.Register(nameof(HotKey), typeof(Hotkey), typeof(HotkeyDisplay), new PropertyMetadata(new Hotkey(Key.None), OnHotKeyChanged)); + + private static void OnHotKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is HotkeyDisplay control) + control.ItemsSource = GetKeys(control.HotKey); + } + + private static IEnumerable GetKeys(Hotkey hotkey) + { + if (hotkey.Modifiers.HasFlag(ModifierKeys.Control)) + yield return "Ctrl"; + + if (hotkey.Modifiers.HasFlag(ModifierKeys.Shift)) + yield return "Shift"; + + if (hotkey.Modifiers.HasFlag(ModifierKeys.Alt)) + yield return "Alt"; + + if (hotkey.Modifiers.HasFlag(ModifierKeys.Windows)) + yield return "Win"; + + if (hotkey.Key != Key.None) + yield return hotkey.Key.ToString(); + } +} + /// /// https://tyrrrz.me/blog/hotkey-editor-control-in-wpf /// @@ -89,4 +147,4 @@ public class HotkeyTextBox : TextBox break; } } -} \ No newline at end of file +} diff --git a/FModel/Views/Resources/Resources.xaml b/FModel/Views/Resources/Resources.xaml index 360c4967..0decd34a 100644 --- a/FModel/Views/Resources/Resources.xaml +++ b/FModel/Views/Resources/Resources.xaml @@ -2285,4 +2285,34 @@ + + diff --git a/FModel/Views/SettingsView.xaml b/FModel/Views/SettingsView.xaml index 96c871d0..be6e8fae 100644 --- a/FModel/Views/SettingsView.xaml +++ b/FModel/Views/SettingsView.xaml @@ -412,71 +412,107 @@ - + + + - - - - - - + - - - - - - - - - + - + + + + - - - - - - - - - - + - + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -549,14 +585,13 @@ ToolTip="Emulate Luaj's permissive parser"> - + - -