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

SpaceEngineersModDev/SpaceEngineersBlueprintEditorInWinUI

完成蓝图查看列表加载

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

代码差异

17 个文件 +150 -30
Modified SpaceEngineersBlueprintEditor/App.xaml.cs +1 -0
@@ -16,6 +16,7 @@ public partial class App : Application
16 16 PageManager.RegisterPage(typeof(BlueprintEditPage));
17 17 PageManager.RegisterPage(typeof(BlueprintsViewPage));
18 18 PageManager.RegisterPage(typeof(SettingPage));
19 Task.Run(BlueprintsManager.LoadBlueprintsAsync);
19 20 }
20 21
21 22 /// <summary>
Added SpaceEngineersBlueprintEditor/Assets/Images/forbidden.svg +1 -0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="-0.75 -0.75 64 64" id="Block-1--Streamline-Plump.svg" height="64" width="64"><desc>Block 1 Streamline Icon: https://streamlinehq.com</desc><g id="block-1--remove-circle-garbage-trash-delete"><path id="Union" fill="#fa8f91" fill-rule="evenodd" d="M58.59375 31.25c0 15.1015625 -12.242187499999998 27.34375 -27.34375 27.34375S3.90625 46.35156249999999 3.90625 31.25 16.148437499999996 3.90625 31.25 3.90625s27.34375 12.242187499999998 27.34375 27.34375ZM40.26940104166666 47.09518229166667C37.609765624999994 48.612369791666666 34.53111979166666 49.479166666666664 31.25 49.479166666666664c-10.067708333333332 0 -18.229166666666664 -8.161458333333332 -18.229166666666664 -18.229166666666664 0 -3.27890625 0.8656249999999999 -6.355598958333333 2.380989583333333 -9.013932291666666 3.761067708333333 4.012369791666667 8.700130208333333 9.232161458333334 12.008984374999999 12.540885416666665 3.345703125 3.3458333333333328 8.742838541666666 8.455989583333333 12.85859375 12.318229166666665Zm6.825390625 -6.825260416666666c-3.8622395833333334 -4.115625 -8.972526041666667 -9.512890625 -12.318359374999998 -12.858723958333334 -3.308723958333333 -3.308723958333333 -8.528515624999999 -8.247916666666665 -12.541015625 -12.008984374999999C24.894010416666667 13.886718749999998 27.97083333333333 13.020833333333332 31.25 13.020833333333332c10.067708333333332 0 18.229166666666664 8.161458333333332 18.229166666666664 18.229166666666664 0 3.2813802083333328 -0.8669270833333332 6.360156249999999 -2.384375 9.019921875Z" clip-rule="evenodd" stroke-width="1.5"></path><path id="Union_2" fill-rule="evenodd" stroke="#b00000" stroke-linecap="round" stroke-linejoin="round" d="M58.59375 31.25c0 15.1015625 -12.242187499999998 27.34375 -27.34375 27.34375S3.90625 46.35156249999999 3.90625 31.25 16.148437499999996 3.90625 31.25 3.90625s27.34375 12.242187499999998 27.34375 27.34375ZM40.26940104166666 47.09518229166667C37.609765624999994 48.612369791666666 34.53111979166666 49.479166666666664 31.25 49.479166666666664c-10.067708333333332 0 -18.229166666666664 -8.161458333333332 -18.229166666666664 -18.229166666666664 0 -3.27890625 0.8656249999999999 -6.355598958333333 2.380989583333333 -9.013932291666666 3.761067708333333 4.012369791666667 8.700130208333333 9.232161458333334 12.008984374999999 12.540885416666665 3.345703125 3.3458333333333328 8.742838541666666 8.455989583333333 12.85859375 12.318229166666665Zm6.825390625 -6.825260416666666c-3.8622395833333334 -4.115625 -8.972526041666667 -9.512890625 -12.318359374999998 -12.858723958333334 -3.308723958333333 -3.308723958333333 -8.528515624999999 -8.247916666666665 -12.541015625 -12.008984374999999C24.894010416666667 13.886718749999998 27.97083333333333 13.020833333333332 31.25 13.020833333333332c10.067708333333332 0 18.229166666666664 8.161458333333332 18.229166666666664 18.229166666666664 0 3.2813802083333328 -0.8669270833333332 6.360156249999999 -2.384375 9.019921875Z" clip-rule="evenodd" stroke-width="1.5"></path></g></svg>
Deleted SpaceEngineersBlueprintEditor/Blueprint.cs +0 -12
@@ -1,12 +0,0 @@
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace SpaceEngineersBlueprintEditor
8 {
9 class Blueprint
10 {
11 }
12 }
Modified SpaceEngineersBlueprintEditor/Implements/Services/NavigationViewService.cs +7 -2
@@ -58,8 +58,13 @@ internal class NavigationViewService : GlobalServiceBase, INavigationViewService
58 58 {
59 59 foreach (var item in menuItems.OfType<NavigationViewItem>())
60 60 {
61 if (item.GetNavigateTo() is string pageName && pageName == pageType.FullName && NavigationService.NavigationStack.Last().Item2 == item.GetNavigationParameter())
62 return item;
61 if (item.GetNavigateTo() is string pageName && pageName == pageType.FullName)
62 {
63 var parameter = NavigationService.NavigationStack.Last().Item2;
64 var itemParameter = item.GetNavigationParameter();
65 if (parameter is string && Equals(parameter, itemParameter) || parameter == itemParameter)
66 return item;
67 }
63 68 var selectedChild = GetSelectedItem(item.MenuItems, pageType);
64 69 if (selectedChild != null)
65 70 return selectedChild;
Added SpaceEngineersBlueprintEditor/Interface/Services/IMessageService.cs +6 -0
@@ -0,0 +1,6 @@
1 namespace SpaceEngineersBlueprintEditor.Interface.Services;
2
3 public interface IMessageService : IGlobalService
4 {
5 void SendMessage(string message);
6 }
Modified SpaceEngineersBlueprintEditor/Interface/Services/INavigationService.cs +1 -1
@@ -1,6 +1,6 @@
1 1 namespace SpaceEngineersBlueprintEditor.Interface.Services;
2 2
3 public interface INavigationService : INavigable
3 public interface INavigationService : INavigable, IGlobalService
4 4 {
5 5 event EventHandler<Type> Navigated;
6 6 bool CanGoBack { get; }
Added SpaceEngineersBlueprintEditor/Model/BlueprintInfo.cs +11 -0
@@ -0,0 +1,11 @@
1 namespace SpaceEngineersBlueprintEditor.Model;
2
3 public class BlueprintInfo(string imagePath, bool hasBlueprint, bool hasImage, string name, string fileSize, string blueprintPath)
4 {
5 public string ImagePath { get; set; } = imagePath;
6 public bool HasBlueprint { get; set; } = hasBlueprint;
7 public bool HasImage { get; set; } = hasImage;
8 public string Name { get; set; } = name;
9 public string FileSize { get; set; } = fileSize;
10 public string BlueprintPath { get; set; } = blueprintPath;
11 }
Added SpaceEngineersBlueprintEditor/Model/BlueprintInfoViewData.cs +12 -0
@@ -0,0 +1,12 @@
1 using Microsoft.UI.Xaml.Media;
2
3 namespace SpaceEngineersBlueprintEditor.Model;
4
5 public class BlueprintInfoViewData(ImageSource? blueprintImage, bool noBlueprint, string name, string fileSize, string filePath)
6 {
7 public ImageSource? BlueprintImage { get; set; } = blueprintImage;
8 public bool NoBlueprint { get; set; } = noBlueprint;
9 public string Name { get; set; } = name;
10 public string FileSize { get; set; } = fileSize;
11 public string FilePath { get; set; } = filePath;
12 }
Modified SpaceEngineersBlueprintEditor/SpaceEngineersBlueprintEditor.csproj +1 -0
@@ -26,6 +26,7 @@
26 26 <None Remove="Assets\Images\EditorIcon300x300.png" />
27 27 <None Remove="Assets\Images\EditorIcon50x50.png" />
28 28 <None Remove="Assets\Images\EditorIcon88x88.png" />
29 <None Remove="Assets\Images\forbidden.svg" />
29 30 <None Remove="Assets\Images\thumb.png" />
30 31 <None Remove="Assets\蓝图编辑器图标.png" />
31 32 <None Remove="Styles\Thickness.xaml" />
Added SpaceEngineersBlueprintEditor/Utilities/BlueprintsManager.cs +34 -0
@@ -0,0 +1,34 @@
1 using Microsoft.UI.Xaml.Media.Imaging;
2 using SpaceEngineersBlueprintEditor.Model;
3 using XFEExtension.NetCore.FileExtension;
4
5 namespace SpaceEngineersBlueprintEditor.Utilities;
6
7 public static class BlueprintsManager
8 {
9 public static List<BlueprintInfo> LocalBlueprints { get; set; } = [];
10 public static List<BlueprintInfo> CloudBlueprints { get; set; } = [];
11 public static List<BlueprintInfo> WorkshopBlueprints { get; set; } = [];
12 public static List<BlueprintInfo> LoadLocalBlueprints() => LoadBlueprintsFrom(SpaceEngineersPath.LocalBlueprints);
13 public static List<BlueprintInfo> LoadCloudBlueprints() => LoadBlueprintsFrom(SpaceEngineersPath.CloudBlueprints);
14 public static List<BlueprintInfo> LoadWorkshopBlueprints() => LoadBlueprintsFrom(SpaceEngineersPath.WorkshopBlueprints);
15 public static List<BlueprintInfo> LoadBlueprintsFrom(string path)
16 {
17 var list = new List<BlueprintInfo>();
18 foreach (var directory in Directory.GetDirectories(path))
19 {
20 var blueprintPath = $@"{directory}\bp.sbc";
21 var imagePath = $@"{directory}\thumb.png";
22 var hasBlueprint = File.Exists(blueprintPath);
23 list.Add(new(imagePath, hasBlueprint, File.Exists(imagePath), Path.GetFileName(directory)!, hasBlueprint ? $"{new FileInfo(blueprintPath).Length.FileSize()}" : string.Empty, blueprintPath));
24 }
25 return list;
26 }
27 public static void LoadBlueprints()
28 {
29 LocalBlueprints = LoadLocalBlueprints();
30 CloudBlueprints = LoadCloudBlueprints();
31 WorkshopBlueprints = LoadWorkshopBlueprints();
32 }
33 public static async Task LoadBlueprintsAsync() => await Task.Run(LoadBlueprints);
34 }
Added SpaceEngineersBlueprintEditor/Utilities/Helpers/Extensions.cs +9 -0
@@ -0,0 +1,9 @@
1 using Microsoft.UI.Xaml.Media.Imaging;
2 using SpaceEngineersBlueprintEditor.Model;
3
4 namespace SpaceEngineersBlueprintEditor.Utilities.Helpers;
5
6 public static class Extensions
7 {
8 public static BlueprintInfoViewData ToBlueprintInfoViewData(this BlueprintInfo blueprintInfo) => new(new BitmapImage(blueprintInfo.HasImage ? new(blueprintInfo.ImagePath) : new Uri("ms-appx:///Assets/Images/BlueprintDrag.png", UriKind.RelativeOrAbsolute)), !blueprintInfo.HasBlueprint, blueprintInfo.Name, blueprintInfo.FileSize, blueprintInfo.BlueprintPath);
9 }
Modified SpaceEngineersBlueprintEditor/Utilities/SpaceEngineersPath.cs +4 -4
@@ -7,11 +7,11 @@ public partial class SpaceEngineersPath
7 7 [AutoPath]
8 8 private static readonly string userGameDataRoot = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\SpaceEngineers";
9 9 [AutoPath]
10 private static readonly string blueprintsRoot = $@"{UserGameDataRoot}/Blueprints";
10 private static readonly string blueprintsRoot = $@"{UserGameDataRoot}\Blueprints";
11 11 [AutoPath]
12 private static readonly string localBlueprints = $@"{BlueprintsRoot}/local";
12 private static readonly string localBlueprints = $@"{BlueprintsRoot}\local";
13 13 [AutoPath]
14 private static readonly string cloudBlueprints = $@"{BlueprintsRoot}/cloud";
14 private static readonly string cloudBlueprints = $@"{BlueprintsRoot}\cloud";
15 15 [AutoPath]
16 private static readonly string workshopBlueprints = $@"{BlueprintsRoot}/workshop/temp/Steam";
16 private static readonly string workshopBlueprints = $@"{BlueprintsRoot}\workshop\temp\Steam";
17 17 }
Modified SpaceEngineersBlueprintEditor/ViewModels/BlueprintEditPageViewModel.cs +6 -6
Modified SpaceEngineersBlueprintEditor/ViewModels/BlueprintsViewPageViewModel.cs +29 -2
Modified SpaceEngineersBlueprintEditor/Views/BlueprintEditPage.xaml +1 -1
Modified SpaceEngineersBlueprintEditor/Views/BlueprintsViewPage.xaml +26 -1
Modified SpaceEngineersBlueprintEditor/Views/SettingPage.xaml +1 -1