XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

SpaceEngineersModDev/SpaceEngineersBlueprintEditorInWinUI

现在,可以动态加载游戏目录

b8d965f
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

12 个文件 +174 -11
Modified SpaceEngineersBlueprintEditor/App.xaml.cs +3 -0
@@ -2,6 +2,7 @@
2 2 using SpaceEngineersBlueprintEditor.SpaceEngineersCore;
3 3 using SpaceEngineersBlueprintEditor.Utilities;
4 4 using SpaceEngineersBlueprintEditor.Views;
5 using XFEExtension.NetCore.StringExtension;
5 6
6 7 namespace SpaceEngineersBlueprintEditor;
7 8
@@ -26,6 +27,8 @@ public partial class App : Application
26 27 {
27 28 try
28 29 {
30 if (SystemProfile.GameRootPath.IsNullOrEmpty())
31 SystemProfile.GameRootPath = SpaceEngineersHelper.GetGameRootPath();
29 32 Initializer.Initialize(SpaceEngineersPath.SpaceEngineerContentPath, SpaceEngineersPath.UserGameDataRoot);
30 33 GlobalServiceManager.GetService<IMessageService>()?.ShowMessage("游戏集定义加载完成", "完成", InfoBarSeverity.Success);
31 34 }
Modified SpaceEngineersBlueprintEditor/Implements/Services/NavigationViewService.cs +2 -0
@@ -15,6 +15,8 @@ internal class NavigationViewService : GlobalServiceBase, INavigationViewService
15 15 public object? SelectedItem => navigationView?.SelectedItem;
16 16 public string? Header { get => navigationView?.Header.ToString(); set { if (navigationView is not null) navigationView.Header = value; } }
17 17
18 public NavigationView? NavigationView => navigationView;
19
18 20 [MemberNotNull(nameof(navigationView))]
19 21 public void Initialize(NavigationView view, Frame frame)
20 22 {
Modified SpaceEngineersBlueprintEditor/Interface/Services/INavigationViewService.cs +1 -0
@@ -2,6 +2,7 @@
2 2
3 3 public interface INavigationViewService : IAutoNavigable, IGlobalService
4 4 {
5 NavigationView? NavigationView { get; }
5 6 IAutoNavigationService NavigationService { get; }
6 7 void Initialize(NavigationView navigationView, Frame frame);
7 8 object? SelectedItem { get; }
Modified SpaceEngineersBlueprintEditor/Profiles/CrossVersionProfiles/SystemProfile.cs +14 -1
@@ -1,4 +1,5 @@
1 using SpaceEngineersBlueprintEditor.Utilities;
1 using SpaceEngineersBlueprintEditor.Interface.Services;
2 using SpaceEngineersBlueprintEditor.Utilities;
2 3 using XFEExtension.NetCore.AutoConfig;
3 4
4 5 namespace SpaceEngineersBlueprintEditor.Profiles.CrossVersionProfiles;
@@ -7,7 +8,19 @@ public partial class SystemProfile
7 8 {
8 9 SystemProfile() => ProfilePath = $@"{AppPath.LocalProfile}\{nameof(SystemProfile)}.xpf";
9 10 [ProfileProperty]
11 private string gameRootPath = "";
12 [ProfileProperty]
13 private NavigationViewPaneDisplayMode navigationStyle = NavigationViewPaneDisplayMode.Left;
14 [ProfileProperty]
10 15 private ElementTheme theme = ElementTheme.Default;
11 16
12 17 static partial void SetThemeProperty(ElementTheme value) => AppThemeHelper.ChangeTheme(value);
18 static partial void SetNavigationStyleProperty(NavigationViewPaneDisplayMode value)
19 {
20 if (GlobalServiceManager.GetService<INavigationViewService>() is INavigationViewService navigationViewService && navigationViewService.NavigationView is not null)
21 {
22
23 navigationViewService.NavigationView.PaneDisplayMode = value;
24 }
25 }
13 26 }
Modified SpaceEngineersBlueprintEditor/Strings/en-us/Resources.resw +36 -0
@@ -217,6 +217,38 @@
217 217 <value>Dark</value>
218 218 <comment>深色</comment>
219 219 </data>
220 <data name="SettingPage_AppearanceTitle.Text" xml:space="preserve">
221 <value>Appearance &amp; behavior</value>
222 <comment>外观 &amp; 行为</comment>
223 </data>
224 <data name="SettingPage_NavigationStyle.Header" xml:space="preserve">
225 <value>Navigation style</value>
226 <comment>导航栏样式</comment>
227 </data>
228 <data name="SettingPage_NavigationStyle_Auto.Content" xml:space="preserve">
229 <value>Auto</value>
230 <comment>自动</comment>
231 </data>
232 <data name="SettingPage_NavigationStyle_Left.Content" xml:space="preserve">
233 <value>Left</value>
234 <comment>左侧</comment>
235 </data>
236 <data name="SettingPage_NavigationStyle_Top.Content" xml:space="preserve">
237 <value>Top</value>
238 <comment>置顶</comment>
239 </data>
240 <data name="SettingPage_NavigationStyle_LeftCompact.Content" xml:space="preserve">
241 <value>Left Compact</value>
242 <comment>左侧小组件</comment>
243 </data>
244 <data name="SettingPage_NavigationStyle_LeftMinimal.Content" xml:space="preserve">
245 <value>Left Minimal</value>
246 <comment>左侧收起</comment>
247 </data>
248 <data name="SettingPage_AboutTitle.Text" xml:space="preserve">
249 <value>About</value>
250 <comment>关于</comment>
251 </data>
220 252 <data name="AppShell_ShellMenu_ViewDefinitions.Content" xml:space="preserve">
221 253 <value>Game Definitions</value>
222 254 <comment>游戏定义集</comment>
@@ -233,4 +265,8 @@
233 265 <value>Component Definitions</value>
234 266 <comment>组件定义集</comment>
235 267 </data>
268 <data name="AppShell_ShellMenu_ViewDefinitions_ScenariosDefinitions.Content" xml:space="preserve">
269 <value>Scenarios Definitions</value>
270 <comment>预设存档定义集</comment>
271 </data>
236 272 </root>
Modified SpaceEngineersBlueprintEditor/Utilities/Helpers/SpaceEngineersHelper.cs +36 -1
@@ -1,5 +1,6 @@
1 1 using Microsoft.UI.Dispatching;
2 2 using Microsoft.UI.Xaml.Media.Imaging;
3 using Microsoft.Win32;
3 4 using Sandbox.Definitions;
4 5 using SpaceEngineersBlueprintEditor.Model;
5 6 using SpaceEngineersBlueprintEditor.SpaceEngineersCore;
@@ -20,7 +21,7 @@ public static class SpaceEngineersHelper
20 21 public static IEnumerable<MyCubeBlockDefinition> CubeBlockDefinitions => AllDefinitions.Where(definition => definition is MyCubeBlockDefinition).Cast<MyCubeBlockDefinition>();
21 22 public static IEnumerable<MyComponentDefinition> ComponentDefinitions => AllDefinitions.Where(definition => definition is MyComponentDefinition).Cast<MyComponentDefinition>();
22 23 public static IEnumerable<MyPhysicalItemDefinition> ItemDefinitions => AllDefinitions.Where(definition => definition is MyPhysicalItemDefinition).Cast<MyPhysicalItemDefinition>();
23 public static IEnumerable<MyDlcDefinition> DLCDefinitions => AllDefinitions.Where(definition => definition is MyDlcDefinition).Cast<MyDlcDefinition>();
24 public static IEnumerable<MyScenarioDefinition> ScenarioDefinition => AllDefinitions.Where(definition => definition is MyScenarioDefinition).Cast<MyScenarioDefinition>();
24 25 public static async Task LoadDefinitionViewDataListAsync()
25 26 {
26 27 while (!Initializer.IsDefinitionsLoadComplete) { await Task.Delay(100); }
@@ -36,4 +37,38 @@ public static class SpaceEngineersHelper
36 37 IsLoadComplete = true;
37 38 LoadComplete?.Invoke(null, EventArgs.Empty);
38 39 }
40
41 public static string? GetGameRootPath()
42 {
43 var path = GetGameRootPath(@"C:\", @"D:\", @"E:\", @"F:\", @"G:\", @"H:\", @"I:\", @"J:\", @"K:\", @"L:\", @"M:\", @"N:\", @"O:\", @"P:\", @"Q:\", @"R:\", @"S:\", @"T:\", @"U:\", @"V:\", @"W:\", @"X:\", @"Y:\", @"Z:\");
44 if (path is not null)
45 return path;
46 if ((Environment.Is64BitProcess ? Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 244850", false) : Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 244850", false)) is RegistryKey registryKey && registryKey.GetValue("InstallLocation")?.ToString() is string stringValue && !string.IsNullOrEmpty(stringValue))
47 {
48 return stringValue;
49 }
50 path = GetSteamFilePath();
51 if (!string.IsNullOrEmpty(path))
52 return Path.Combine(path, @"SteamApps\common\SpaceEngineers");
53 return null;
54 }
55
56 public static string? GetGameRootPath(params string[] roots)
57 {
58 foreach (var root in roots)
59 {
60 var targetPath = $@"{root}SteamLibrary\steamapps\common\SpaceEngineers\Bin64\SpaceEngineers.exe";
61 if (File.Exists(targetPath))
62 return $@"{root}SteamLibrary\steamapps\common\SpaceEngineers";
63 }
64 return null;
65 }
66
67 public static string? GetSteamFilePath()
68 {
69 if ((Environment.Is64BitProcess ? Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Valve\Steam", false) : Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Valve\Steam", false)) is RegistryKey registryKey)
70 return registryKey.GetValue("InstallPath")?.ToString();
71 else
72 return null;
73 }
39 74 }
Modified SpaceEngineersBlueprintEditor/Utilities/SpaceEngineersPath.cs +2 -2
@@ -14,6 +14,6 @@ public partial class SpaceEngineersPath
14 14 private static readonly string cloudBlueprints = $@"{BlueprintsRoot}\cloud";
15 15 [AutoPath]
16 16 private static readonly string workshopBlueprints = $@"{BlueprintsRoot}\workshop\temp\Steam";
17 [AutoPath]
18 private static readonly string spaceEngineerContentPath = @"D:\SteamLibrary\steamapps\common\SpaceEngineers\Content";
17 public static string SpaceEngineerContentPath => $@"{SystemProfile.GameRootPath}\Content";
18 public static string SpaceEngineerBinPath => $@"{SystemProfile.GameRootPath}\Bin64";
19 19 }
Modified SpaceEngineersBlueprintEditor/ViewModels/GameDefinitionsViewPageViewModel.cs +1 -0
@@ -95,6 +95,7 @@ public partial class GameDefinitionsViewPageViewModel : ViewModelBase
95 95 "Cubes" => SpaceEngineersHelper.CubeBlockDefinitions.OrderBy(definition => definition.CubeSize),
96 96 "Components" => SpaceEngineersHelper.ComponentDefinitions,
97 97 "Items" => SpaceEngineersHelper.ItemDefinitions,
98 "Scenarios" => SpaceEngineersHelper.ScenarioDefinition,
98 99 _ => throw new NotImplementedException()
99 100 };
100 101
Modified SpaceEngineersBlueprintEditor/Views/AppShellPage.xaml +5 -0
@@ -73,6 +73,11 @@
73 73 <FontIcon Glyph="&#xECA5;"/>
74 74 </NavigationViewItem.Icon>
75 75 </NavigationViewItem>
76 <NavigationViewItem x:Uid="AppShell_ShellMenu_ViewDefinitions_ScenariosDefinitions" add:NavigationAddition.NavigateTo="SpaceEngineersBlueprintEditor.Views.GameDefinitionsViewPage" add:NavigationAddition.NavigateParameter="Scenarios">
77 <NavigationViewItem.Icon>
78 <FontIcon Glyph="&#xE74E;"/>
79 </NavigationViewItem.Icon>
80 </NavigationViewItem>
76 81 </NavigationViewItem.MenuItems>
77 82 </NavigationViewItem>
78 83 </NavigationView.MenuItems>
Modified SpaceEngineersBlueprintEditor/Views/AppShellPage.xaml.cs +49 -6
@@ -23,19 +23,62 @@ public sealed partial class AppShellPage : Page
23 23
24 24 private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
25 25 {
26 appTitleBar.Margin = new Thickness()
26 switch (sender.PaneDisplayMode)
27 27 {
28 Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
29 Top = appTitleBar.Margin.Top,
30 Right = appTitleBar.Margin.Right,
31 Bottom = appTitleBar.Margin.Bottom
32 };
28 case NavigationViewPaneDisplayMode.Auto:
29 navigationView.Margin = new();
30 appTitleBar.Margin = new()
31 {
32 Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
33 Top = appTitleBar.Margin.Top,
34 Right = appTitleBar.Margin.Right,
35 Bottom = appTitleBar.Margin.Bottom
36 };
37 break;
38 case NavigationViewPaneDisplayMode.Left:
39 navigationView.Margin = new();
40 appTitleBar.Margin = new()
41 {
42 Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
43 Top = appTitleBar.Margin.Top,
44 Right = appTitleBar.Margin.Right,
45 Bottom = appTitleBar.Margin.Bottom
46 };
47 break;
48 case NavigationViewPaneDisplayMode.Top:
49 navigationView.Margin = new(0, 48, 0, 0);
50 appTitleBar.Margin = new(16, 0, 0, 0);
51 break;
52 case NavigationViewPaneDisplayMode.LeftCompact:
53 navigationView.Margin = new();
54 appTitleBar.Margin = new()
55 {
56 Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
57 Top = appTitleBar.Margin.Top,
58 Right = appTitleBar.Margin.Right,
59 Bottom = appTitleBar.Margin.Bottom
60 };
61 break;
62 case NavigationViewPaneDisplayMode.LeftMinimal:
63 navigationView.Margin = new();
64 appTitleBar.Margin = new()
65 {
66 Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
67 Top = appTitleBar.Margin.Top,
68 Right = appTitleBar.Margin.Right,
69 Bottom = appTitleBar.Margin.Bottom
70 };
71 break;
72 default:
73 break;
74 }
33 75 }
34 76
35 77 private async void Page_Loaded(object sender, RoutedEventArgs e)
36 78 {
37 79 ViewModel.MessageService.ShowMessage("��Ϸ���弯������...", "���ڼ���");
38 80 AppThemeHelper.ChangeTheme(SystemProfile.Theme);
81 navigationView.PaneDisplayMode = SystemProfile.NavigationStyle;
39 82 SpaceEngineersHelper.LoadComplete += (sender, e) => ViewModel.MessageService.ShowMessage("���弯ͼƬ�������", "���", InfoBarSeverity.Success);
40 83 await SpaceEngineersHelper.LoadDefinitionViewDataListAsync();
41 84 }
Modified SpaceEngineersBlueprintEditor/Views/SettingPage.xaml +24 -1
@@ -9,10 +9,20 @@
9 9 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10 10 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11 11 mc:Ignorable="d">
12
12 <Page.Resources>
13 <Style x:Key="SettingsSectionHeaderTextBlockStyle"
14 BasedOn="{StaticResource BodyStrongTextBlockStyle}"
15 TargetType="TextBlock">
16 <Style.Setters>
17 <Setter Property="Margin" Value="1,30,0,6" />
18 </Style.Setters>
19 </Style>
20 </Page.Resources>
21
13 22 <Grid>
14 23 <ScrollViewer>
15 24 <StackPanel Spacing="4">
25 <TextBlock x:Uid="SettingPage_AppearanceTitle" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
16 26 <toolkit:SettingsCard x:Uid="SettingPage_AppTheme">
17 27 <toolkit:SettingsCard.HeaderIcon>
18 28 <FontIcon Glyph="&#xE790;"/>
@@ -23,6 +33,19 @@
23 33 <ComboBoxItem x:Uid="SettingPage_AppTheme_Default" Tag="Default"/>
24 34 </ComboBox>
25 35 </toolkit:SettingsCard>
36 <toolkit:SettingsCard x:Uid="SettingPage_NavigationStyle">
37 <toolkit:SettingsCard.HeaderIcon>
38 <FontIcon Glyph="&#xEC6C;"/>
39 </toolkit:SettingsCard.HeaderIcon>
40 <ComboBox x:Name="navigationStyleComboBox" Tag="SpaceEngineersBlueprintEditor.Profiles.CrossVersionProfiles.SystemProfile.NavigationStyle">
41 <ComboBoxItem x:Uid="SettingPage_NavigationStyle_Auto" Tag="Auto"/>
42 <ComboBoxItem x:Uid="SettingPage_NavigationStyle_Left" Tag="Left"/>
43 <ComboBoxItem x:Uid="SettingPage_NavigationStyle_Top" Tag="Top"/>
44 <ComboBoxItem x:Uid="SettingPage_NavigationStyle_LeftCompact" Tag="LeftCompact"/>
45 <ComboBoxItem x:Uid="SettingPage_NavigationStyle_LeftMinimal" Tag="LeftMinimal"/>
46 </ComboBox>
47 </toolkit:SettingsCard>
48 <TextBlock x:Uid="SettingPage_AboutTitle" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
26 49 <toolkit:SettingsExpander x:Uid="SettingPage_AppInfo_Expander">
27 50 <toolkit:SettingsExpander.HeaderIcon>
28 51 <ImageIcon Source="/Assets/Images/EditorIcon.png"/>
Modified SpaceEngineersBlueprintEditor/Views/SettingPage.xaml.cs +1 -0
@@ -15,6 +15,7 @@ public sealed partial class SettingPage : Page
15 15 PageManager.AddOrUpdateCurrentPage(Current = this);
16 16 this.InitializeComponent();
17 17 ViewModel.SettingService.AddComboBox(appThemeComboBox, ProfileHelper.GetEnumProfileSaveFunc<ElementTheme>(), ProfileHelper.GetEnumProfileLoadFuncForComboBox());
18 ViewModel.SettingService.AddComboBox(navigationStyleComboBox, ProfileHelper.GetEnumProfileSaveFunc<NavigationViewPaneDisplayMode>(), ProfileHelper.GetEnumProfileLoadFuncForComboBox());
18 19 ViewModel.SettingService.Initialize();
19 20 ViewModel.SettingService.RegisterEvents();
20 21 }