优化和修复BUG
This commit is contained in:
parent
1424fb2de9
commit
b860f5fcc0
|
@ -1,24 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<configSections>
|
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
|
||||||
<section name="RustTools.Assets.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="RustTools.Assets.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
</sectionGroup>
|
|
||||||
</configSections>
|
|
||||||
<userSettings>
|
|
||||||
<RustTools.Assets.Settings>
|
|
||||||
<setting name="设置" serializeAs="String">
|
|
||||||
<value>1</value>
|
|
||||||
</setting>
|
|
||||||
</RustTools.Assets.Settings>
|
|
||||||
<RustTools.Assets.Settings1>
|
|
||||||
<setting name="主题颜色" serializeAs="String">
|
|
||||||
<value>1</value>
|
|
||||||
</setting>
|
|
||||||
<setting name="Mod" serializeAs="String">
|
|
||||||
<value />
|
|
||||||
</setting>
|
|
||||||
</RustTools.Assets.Settings1>
|
|
||||||
</userSettings>
|
|
||||||
</configuration>
|
|
|
@ -106,6 +106,8 @@ public partial class App : Microsoft.UI.Xaml.Application
|
||||||
Build();
|
Build();
|
||||||
|
|
||||||
UnhandledException += App_UnhandledException;
|
UnhandledException += App_UnhandledException;
|
||||||
|
|
||||||
|
|
||||||
var path = ApplicationData.Current.LocalFolder.Path;
|
var path = ApplicationData.Current.LocalFolder.Path;
|
||||||
var v = Path.Combine(path, "CodeTable");
|
var v = Path.Combine(path, "CodeTable");
|
||||||
gj.sc(path);
|
gj.sc(path);
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||||
<PackageReference Include="RestClient" Version="3.1024.23771" />
|
<PackageReference Include="RestClient" Version="3.1024.23771" />
|
||||||
<PackageReference Include="RestSharp" Version="111.4.0" />
|
<PackageReference Include="RestSharp" Version="111.4.0" />
|
||||||
|
<PackageReference Include="squirrel.windows" Version="2.0.1" />
|
||||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||||
<PackageReference Include="WinUIEx" Version="2.3.2" />
|
<PackageReference Include="WinUIEx" Version="2.3.2" />
|
||||||
|
|
||||||
|
|
26
RustTools/Services/BooleanToVisibilityConverter.cs
Normal file
26
RustTools/Services/BooleanToVisibilityConverter.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Data;
|
||||||
|
|
||||||
|
|
||||||
|
namespace RustTools.Services;
|
||||||
|
|
||||||
|
public class BooleanToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
|
||||||
|
return string.IsNullOrEmpty(value.ToString()) ? Visibility.Collapsed: Visibility.Visible;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
if (value is Visibility visibility)
|
||||||
|
{
|
||||||
|
return visibility == Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
x:Class="RustTools.Views.CodeTablePage"
|
x:Class="RustTools.Views.CodeTablePage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:Services="using:RustTools.Services"
|
||||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:datalist="using:RustTools.DataList"
|
xmlns:datalist="using:RustTools.DataList"
|
||||||
|
@ -11,6 +12,9 @@
|
||||||
xmlns:themes="using:RustTools.Themes"
|
xmlns:themes="using:RustTools.Themes"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Page.Resources>
|
||||||
|
<Services:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
|
</Page.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
@ -122,7 +126,8 @@
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Click="List_ButtonIcon_Click"
|
Click="List_ButtonIcon_Click"
|
||||||
Glyph="" />
|
Glyph=""
|
||||||
|
Visibility="{Binding demo, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=''}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
|
|
|
@ -13,14 +13,11 @@
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<!-- 模组 -->
|
<!-- 模组 -->
|
||||||
<DataTemplate x:Key="RwmodItem">
|
<DataTemplate x:Key="RwmodItem">
|
||||||
<Button
|
<Grid Background="{ThemeResource SystemColorWindowColor}" CornerRadius="9">
|
||||||
Background="{ThemeResource SystemColorWindowColor}"
|
|
||||||
Click="Button_Click_RwmodItem"
|
|
||||||
CornerRadius="9">
|
|
||||||
<Grid
|
<Grid
|
||||||
Width="130"
|
Width="130"
|
||||||
Height="160"
|
Height="160"
|
||||||
Padding="9">
|
Padding="9,0,9,9">
|
||||||
<Image
|
<Image
|
||||||
Width="50"
|
Width="50"
|
||||||
Height="50"
|
Height="50"
|
||||||
|
@ -45,22 +42,25 @@
|
||||||
TextWrapping="NoWrap" />
|
TextWrapping="NoWrap" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Button>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<!-- 文件夹 -->
|
<!-- 文件夹 -->
|
||||||
<DataTemplate x:Key="FolderItem">
|
<DataTemplate x:Key="FolderItem">
|
||||||
<Button
|
<Grid
|
||||||
Background="{ThemeResource SystemColorWindowColor}"
|
Background="{ThemeResource SystemColorWindowColor}"
|
||||||
CornerRadius="9"
|
CornerRadius="9"
|
||||||
ToolTipService.ToolTip="{Binding Info}">
|
ToolTipService.ToolTip="{Binding Info}">
|
||||||
<Button.Flyout>
|
<Grid.ContextFlyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuFlyoutItem Text="打开" />
|
<MenuFlyoutItem
|
||||||
|
IsEnabled="False"
|
||||||
|
Text="打开"
|
||||||
|
ToolTipService.ToolTip="制作中···" />
|
||||||
<MenuFlyoutItem Click="Button_Rwmod" Text="打包" />
|
<MenuFlyoutItem Click="Button_Rwmod" Text="打包" />
|
||||||
<MenuFlyoutItem Text="发布" />
|
<MenuFlyoutItem Text="发布" />
|
||||||
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</Button.Flyout>
|
</Grid.ContextFlyout>
|
||||||
<Grid
|
<Grid
|
||||||
Width="130"
|
Width="130"
|
||||||
Height="160"
|
Height="160"
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
TextWrapping="NoWrap" />
|
TextWrapping="NoWrap" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Button>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,12 +107,20 @@
|
||||||
|
|
||||||
<GridView
|
<GridView
|
||||||
x:Name="BasicGridView"
|
x:Name="BasicGridView"
|
||||||
IsItemClickEnabled="False"
|
AllowDrop="True"
|
||||||
|
CanReorderItems="True"
|
||||||
|
DoubleTapped="BasicGridView_DoubleTapped"
|
||||||
|
IsItemClickEnabled="True"
|
||||||
ItemsSource="{x:Bind ViewModel.ListMod}"
|
ItemsSource="{x:Bind ViewModel.ListMod}"
|
||||||
SelectionMode="None">
|
SelectionMode="Single">
|
||||||
<GridView.ItemTemplateSelector>
|
<GridView.ItemTemplateSelector>
|
||||||
<local:MyItemTemplateSelector Template1="{StaticResource RwmodItem}" Template2="{StaticResource FolderItem}" />
|
<local:MyItemTemplateSelector Template1="{StaticResource RwmodItem}" Template2="{StaticResource FolderItem}" />
|
||||||
</GridView.ItemTemplateSelector>
|
</GridView.ItemTemplateSelector>
|
||||||
|
<GridView.ItemContainerStyle>
|
||||||
|
<Style TargetType="GridViewItem">
|
||||||
|
<Setter Property="Margin" Value="6" />
|
||||||
|
</Style>
|
||||||
|
</GridView.ItemContainerStyle>
|
||||||
</GridView>
|
</GridView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@ using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
using Microsoft.UI.Xaml.Media;
|
using Microsoft.UI.Xaml.Media;
|
||||||
|
using Microsoft.VisualBasic.FileIO;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
using RustTools.ViewModels;
|
using RustTools.ViewModels;
|
||||||
|
using SharpCompress.Common;
|
||||||
namespace RustTools.Views;
|
namespace RustTools.Views;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模组碎片
|
/// 模组碎片
|
||||||
|
@ -110,23 +112,29 @@ public sealed partial class ModulePage : Page
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void Button_Delete(object sender, RoutedEventArgs e)
|
private async void Button_Delete(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var menuItem = sender as Control;
|
var menuItem = sender as Control;
|
||||||
gj.sc(menuItem);
|
gj.sc(menuItem);
|
||||||
if (menuItem != null)
|
if (menuItem != null)
|
||||||
{
|
{
|
||||||
if (menuItem.DataContext is DataObject folderItem)
|
if (menuItem.DataContext is DataObject folderItem)
|
||||||
|
{
|
||||||
|
var task = await Dialog.DialogWarnYes("你确定要删除(回收站)" + folderItem.Dri, XamlRoot);
|
||||||
|
if (task == ContentDialogResult.Primary)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(folderItem.Dri))
|
if (Directory.Exists(folderItem.Dri))
|
||||||
{
|
{
|
||||||
// 删除文件夹
|
// 删除文件夹
|
||||||
Directory.Delete(folderItem.Dri, true);
|
//Directory.Delete(folderItem.Dri, true);
|
||||||
|
FileSystem.DeleteDirectory(folderItem.Dri, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||||
}
|
}
|
||||||
else if (File.Exists(folderItem.Dri))
|
else if (File.Exists(folderItem.Dri))
|
||||||
{
|
{
|
||||||
//删除文件
|
//删除文件
|
||||||
File.Delete(folderItem.Dri);
|
//File.Delete(folderItem.Dri);
|
||||||
|
FileSystem.DeleteFile(folderItem.Dri, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ViewModel.ListMod.Remove(folderItem);
|
ViewModel.ListMod.Remove(folderItem);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +148,7 @@ public sealed partial class ModulePage : Page
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
private async void UnzipRwmod(DataObject a)
|
||||||
{
|
{
|
||||||
ContentDialog dialog = new ContentDialog
|
ContentDialog dialog = new ContentDialog
|
||||||
{
|
{
|
||||||
|
@ -152,27 +160,20 @@ public sealed partial class ModulePage : Page
|
||||||
};
|
};
|
||||||
var contentDialogResult = await dialog.ShowAsync();
|
var contentDialogResult = await dialog.ShowAsync();
|
||||||
if (contentDialogResult == ContentDialogResult.Primary)
|
if (contentDialogResult == ContentDialogResult.Primary)
|
||||||
{
|
|
||||||
|
|
||||||
var button = sender as Button;
|
|
||||||
if (button != null)
|
|
||||||
{
|
|
||||||
var container = VisualTreeHelper.GetParent(button) as FrameworkElement;
|
|
||||||
if (container != null && container.DataContext is DataObject dataItem)
|
|
||||||
{
|
{
|
||||||
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
||||||
|
|
||||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(dataItem.Dri);
|
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(a.Dri);
|
||||||
var GetDirectoryName = Path.GetDirectoryName(dataItem.Dri);
|
var GetDirectoryName = Path.GetDirectoryName(a.Dri);
|
||||||
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
||||||
{
|
{
|
||||||
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
||||||
var v = wj.UnzipFile(dataItem.Dri, targetDirectory);
|
var v = wj.UnzipFile(a.Dri, targetDirectory);
|
||||||
gj.sc("解压成功:" + v);
|
gj.sc("解压成功:" + v);
|
||||||
if (checkbox?.IsChecked == true)
|
if (checkbox?.IsChecked == true)
|
||||||
{
|
{
|
||||||
File.Delete(dataItem.Dri);
|
File.Delete(a.Dri);
|
||||||
ViewModel.ListMod.Remove(dataItem);
|
ViewModel.ListMod.Remove(a);
|
||||||
}
|
}
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
|
@ -181,8 +182,6 @@ public sealed partial class ModulePage : Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +248,32 @@ public sealed partial class ModulePage : Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 双击GridView事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private async void BasicGridView_DoubleTapped(object sender, Microsoft.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
var gridView = sender as GridView;
|
||||||
|
var item = (e.OriginalSource as FrameworkElement)?.DataContext;
|
||||||
|
|
||||||
|
if (item != null && gridView != null)
|
||||||
|
{
|
||||||
|
// 这里处理双击事件,例如显示一个消息框
|
||||||
|
// 替换为实际的数据类型
|
||||||
|
if (item is DataObject clickedItem)
|
||||||
|
{
|
||||||
|
// 在这里处理双击项
|
||||||
|
var IsRwmod = clickedItem.IsRwmod; // 假设你的项有一个 Name 属性
|
||||||
|
if (IsRwmod) {
|
||||||
|
UnzipRwmod(clickedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class MyItemTemplateSelector : DataTemplateSelector
|
public class MyItemTemplateSelector : DataTemplateSelector
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,10 +98,14 @@
|
||||||
Style="{ThemeResource BodyTextBlockStyle}" />
|
Style="{ThemeResource BodyTextBlockStyle}" />
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<HyperlinkButton
|
<HyperlinkButton
|
||||||
Margin="0,4,26,0"
|
Margin="{StaticResource SettingsPageHyperlinkButtonMargin}"
|
||||||
Content="开源地址"
|
Content="开源地址"
|
||||||
NavigateUri="https://git.coldmint.top/muqing" />
|
NavigateUri="https://git.coldmint.top/muqing" />
|
||||||
<HyperlinkButton x:Uid="SettingsPage_PrivacyTermsLink" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
|
<HyperlinkButton x:Uid="SettingsPage_PrivacyTermsLink" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
|
||||||
|
<HyperlinkButton
|
||||||
|
Margin="{StaticResource SettingsPageHyperlinkButtonMargin}"
|
||||||
|
Content="创建快捷方式"
|
||||||
|
NavigateUri="https://blog.csdn.net/Tisfy/article/details/132254567" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class Dialog
|
||||||
|
|
||||||
public const string warning = "警告";
|
public const string warning = "警告";
|
||||||
public const string Close = "取消";
|
public const string Close = "取消";
|
||||||
|
public const string Primary = "确定";
|
||||||
public static async Task<ContentDialogResult> DialogWarn(string sub, XamlRoot xamlRoot)
|
public static async Task<ContentDialogResult> DialogWarn(string sub, XamlRoot xamlRoot)
|
||||||
{
|
{
|
||||||
var contentDialog = new ContentDialog()
|
var contentDialog = new ContentDialog()
|
||||||
|
@ -46,4 +47,24 @@ public class Dialog
|
||||||
};
|
};
|
||||||
return await contentDialog.ShowAsync();
|
return await contentDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 带有确定按钮的警告
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sub"></param>
|
||||||
|
/// <param name="xamlRoot"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<ContentDialogResult> DialogWarnYes(string sub, XamlRoot xamlRoot)
|
||||||
|
{
|
||||||
|
var contentDialog = new ContentDialog()
|
||||||
|
{
|
||||||
|
XamlRoot = xamlRoot,
|
||||||
|
Title = warning,
|
||||||
|
Content = sub,
|
||||||
|
CloseButtonText = Close,
|
||||||
|
PrimaryButtonText= Primary,
|
||||||
|
PrimaryButtonStyle= Application.Current.Resources["AccentButtonStyle"] as Style
|
||||||
|
};
|
||||||
|
return await contentDialog.ShowAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
74
RustTools/muqing/IShellLinkW.cs
Normal file
74
RustTools/muqing/IShellLinkW.cs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
[ComImport]
|
||||||
|
[Guid("000214F9-0000-0000-C000-000000000046")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
|
public interface IShellLinkW
|
||||||
|
{
|
||||||
|
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, ref WIN32_FIND_DATAW pfd, uint fFlags);
|
||||||
|
void GetIDList(out IntPtr ppidl);
|
||||||
|
void SetIDList(IntPtr pidl);
|
||||||
|
void GetDescription([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
|
||||||
|
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
||||||
|
void GetWorkingDirectory([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
|
||||||
|
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
|
||||||
|
void GetArguments([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
|
||||||
|
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
|
||||||
|
void GetHotkey(out short pwHotkey);
|
||||||
|
void SetHotkey(short wHotkey);
|
||||||
|
void GetShowCmd(out int piShowCmd);
|
||||||
|
void SetShowCmd(int iShowCmd);
|
||||||
|
void GetIconLocation([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath);
|
||||||
|
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
|
||||||
|
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved);
|
||||||
|
void Resolve(IntPtr hwnd, uint fFlags);
|
||||||
|
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||||
|
public struct WIN32_FIND_DATAW
|
||||||
|
{
|
||||||
|
public uint dwFileAttributes;
|
||||||
|
public FILETIME ftCreationTime;
|
||||||
|
public FILETIME ftLastAccessTime;
|
||||||
|
public FILETIME ftLastWriteTime;
|
||||||
|
public uint nFileSizeHigh;
|
||||||
|
public uint nFileSizeLow;
|
||||||
|
public uint dwReserved0;
|
||||||
|
public uint dwReserved1;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||||
|
public string cFileName;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
|
||||||
|
public string cAlternateFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct FILETIME
|
||||||
|
{
|
||||||
|
public uint dwLowDateTime;
|
||||||
|
public uint dwHighDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ComImport]
|
||||||
|
[Guid("0000010B-0000-0000-C000-000000000046")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
|
public interface IPersistFile
|
||||||
|
{
|
||||||
|
void GetClassID(out Guid pClassID);
|
||||||
|
[PreserveSig]
|
||||||
|
int IsDirty();
|
||||||
|
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode);
|
||||||
|
void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember);
|
||||||
|
void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName);
|
||||||
|
void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ComImport]
|
||||||
|
[Guid("00021401-0000-0000-C000-000000000046")]
|
||||||
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
|
public class ShellLink
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Windows.Storage;
|
using RustTools.muqing;
|
||||||
|
using Windows.Storage;
|
||||||
|
|
||||||
#pragma warning disable CA1050 // 在命名空间中声明类型
|
#pragma warning disable CA1050 // 在命名空间中声明类型
|
||||||
public class IniHelper
|
public class IniHelper
|
||||||
|
|
|
@ -6,21 +6,21 @@ using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
|
/// <summary>
|
||||||
|
/// 模组搜索引擎操作
|
||||||
|
/// </summary>
|
||||||
public class Mod
|
public class Mod
|
||||||
{
|
{
|
||||||
|
|
||||||
//开始计时
|
|
||||||
private static DateTime StartTime;
|
private static DateTime StartTime;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 统计运行耗时
|
/// 结束时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void EndTime()
|
private static void EndTime()
|
||||||
{
|
{
|
||||||
Console.WriteLine("执行时间:" + (DateTime.Now - StartTime).TotalMilliseconds + "ms");
|
Console.WriteLine("结束" + (DateTime.Now - StartTime).TotalMilliseconds + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly bool Isdot = true;//是否排除.开头的文件夹
|
private readonly bool Isdot = true;
|
||||||
//排除的文件夹
|
|
||||||
private readonly List<string> ExcludeFile = new(){
|
private readonly List<string> ExcludeFile = new(){
|
||||||
"Android", "androidword", "Java",
|
"Android", "androidword", "Java",
|
||||||
"Linux", "linuxword", "Mac",
|
"Linux", "linuxword", "Mac",
|
||||||
|
@ -28,12 +28,10 @@ public class Mod
|
||||||
"Genshin Impact Game", "Godot", "Gradle",
|
"Genshin Impact Game", "Godot", "Gradle",
|
||||||
"WeGame", "Mental Omega", "WeGameApps",
|
"WeGame", "Mental Omega", "WeGameApps",
|
||||||
"ramboplayGame", "QQ", "QQWORD","Microsoft SDKs","Creator","editors","AndroidSDK","SDK","Pr","PR","PS","Ps","WE",
|
"ramboplayGame", "QQ", "QQWORD","Microsoft SDKs","Creator","editors","AndroidSDK","SDK","Pr","PR","PS","Ps","WE",
|
||||||
"androidstudioword","鸿图对战平台","xshell7"
|
"androidstudioword","<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>սƽ̨","xshell7"
|
||||||
};
|
};
|
||||||
//游戏位置
|
|
||||||
public string FileDir = string.Empty;
|
public string FileDir = string.Empty;
|
||||||
private readonly ContentDialog? dialog = null;
|
private readonly ContentDialog? dialog = null;
|
||||||
//在MainPage的后台code里面添加这个申明
|
|
||||||
public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal)
|
public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal)
|
||||||
{
|
{
|
||||||
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Priority, () => { action(); });
|
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Priority, () => { action(); });
|
||||||
|
@ -48,20 +46,16 @@ public class Mod
|
||||||
this.xamlRoot = xamlRoot;
|
this.xamlRoot = xamlRoot;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
StartTime = DateTime.Now;
|
StartTime = DateTime.Now;
|
||||||
|
|
||||||
Debug.WriteLine("开始执行文件搜索引擎");
|
|
||||||
//先找steam中的位置
|
|
||||||
steam();
|
steam();
|
||||||
if (FileDir == string.Empty)
|
if (FileDir == string.Empty)
|
||||||
{
|
{
|
||||||
//找不到执行搜索引擎
|
|
||||||
gj.sc("找不到执行搜索引擎");
|
|
||||||
dialog = new ContentDialog()
|
dialog = new ContentDialog()
|
||||||
{
|
{
|
||||||
XamlRoot = xamlRoot,
|
XamlRoot = xamlRoot,
|
||||||
Title = "提示",
|
Title = "提示ʾ",
|
||||||
Content = "搜索中",
|
Content = "搜索中···",
|
||||||
PrimaryButtonText = "关闭"
|
PrimaryButtonText = "取消"
|
||||||
};
|
};
|
||||||
dialog.Closing += Dialog_Closing;
|
dialog.Closing += Dialog_Closing;
|
||||||
|
|
||||||
|
@ -69,8 +63,6 @@ public class Mod
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await init();
|
await init();
|
||||||
// 使用 DispatcherQueue 将 UI 更新委托回 UI 线程
|
|
||||||
|
|
||||||
_dispatcherQueue.TryEnqueue(() =>
|
_dispatcherQueue.TryEnqueue(() =>
|
||||||
{
|
{
|
||||||
dialog.Closing -= Dialog_Closing;
|
dialog.Closing -= Dialog_Closing;
|
||||||
|
@ -78,22 +70,12 @@ public class Mod
|
||||||
action?.Invoke(FileDir);
|
action?.Invoke(FileDir);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//if (IsSearch)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
//var thread = new Thread(init);
|
|
||||||
//thread.Start();
|
|
||||||
//thread.Join();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
action?.Invoke(FileDir);
|
action?.Invoke(FileDir);
|
||||||
}
|
}
|
||||||
//dialog.Closing -= Dialog_Closing;
|
|
||||||
//if (FileDir != string.Empty) {
|
|
||||||
// dialog.Content = FileDir;
|
|
||||||
//}
|
|
||||||
//dialog.Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,23 +94,18 @@ public class Mod
|
||||||
var steamPath = GetSteamInstallPath();
|
var steamPath = GetSteamInstallPath();
|
||||||
if (!string.IsNullOrEmpty(steamPath))
|
if (!string.IsNullOrEmpty(steamPath))
|
||||||
{
|
{
|
||||||
Console.WriteLine("已经找到steam安装位置" + steamPath);
|
|
||||||
var b = Directory.Exists(steamPath + "\\steamapps\\common\\Rusted Warfare");
|
var b = Directory.Exists(steamPath + "\\steamapps\\common\\Rusted Warfare");
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
//结束计时
|
|
||||||
Console.WriteLine("已找到游戏文件路径 " + steamPath + "\\steamapps\\common\\Rusted Warfare");
|
|
||||||
FileDir = steamPath + "\\steamapps\\common\\Rusted Warfare";
|
FileDir = steamPath + "\\steamapps\\common\\Rusted Warfare";
|
||||||
EndTime();
|
EndTime();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("未找到游戏文件路径");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("找不到steam的安装位置");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -139,7 +116,6 @@ public class Mod
|
||||||
foreach (var d in allDrives)
|
foreach (var d in allDrives)
|
||||||
{
|
{
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
// Console.WriteLine(" Drive type: {0}", d.DriveType);
|
|
||||||
if (d.IsReady == true)
|
if (d.IsReady == true)
|
||||||
{
|
{
|
||||||
var name = d.Name;
|
var name = d.Name;
|
||||||
|
@ -147,20 +123,15 @@ public class Mod
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//只要不是C盘
|
|
||||||
if (name.Equals("C:\\"))
|
if (name.Equals("C:\\"))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("在C盘游戏文件路径");
|
|
||||||
FileSearch(name);
|
FileSearch(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.WriteLine("在其他盘中快速找游戏文件路径");
|
|
||||||
// steam\steamapps\common\Rusted Warfare
|
|
||||||
// new FileSearch(name).Search();
|
|
||||||
if (Directory.Exists(name + "/Rusted Warfare"))
|
if (Directory.Exists(name + "/Rusted Warfare"))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("找到游戏文件路径");
|
|
||||||
EndTime();
|
EndTime();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -174,42 +145,28 @@ public class Mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//是否还搜索
|
|
||||||
public bool IsSearch = true;
|
public bool IsSearch = true;
|
||||||
private void FileSearch(string path)
|
private void FileSearch(string path)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("开始遍历文件夹" + path);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 遍历文件夹
|
|
||||||
foreach (var file in Directory.EnumerateDirectories(path))
|
foreach (var file in Directory.EnumerateDirectories(path))
|
||||||
{
|
{
|
||||||
if (!IsSearch)
|
if (!IsSearch)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//排除特殊符号的文件夹
|
|
||||||
// if (file.contains("$"))
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("排除特殊符号开头的文件夹" + file);
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//排除.开头的文件
|
|
||||||
var name = Path.GetFileName(file);
|
var name = Path.GetFileName(file);
|
||||||
if (Isdot && name.StartsWith("."))
|
if (Isdot && name.StartsWith("."))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("排除。开头的文件夹" + file);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//排除掉列表中的文件夹
|
|
||||||
if (ExcludeFile.Contains(name))
|
if (ExcludeFile.Contains(name))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("排除列表中的文件夹" + file);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (name.Equals("Rusted Warfare"))
|
if (name.Equals("Rusted Warfare"))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("找到游戏文件路径" + file);
|
|
||||||
FileDir = file;
|
FileDir = file;
|
||||||
EndTime();
|
EndTime();
|
||||||
break;
|
break;
|
||||||
|
@ -223,12 +180,10 @@ public class Mod
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
// 如果访问被拒绝,跳过该文件夹并记录信息
|
|
||||||
Console.WriteLine($"Access denied for: {path}");
|
Console.WriteLine($"Access denied for: {path}");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// 捕获其他可能的异常
|
|
||||||
Console.WriteLine($"Error accessing directory '{path}': {ex.Message}");
|
Console.WriteLine($"Error accessing directory '{path}': {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +195,6 @@ public class Mod
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(installPath))
|
if (string.IsNullOrEmpty(installPath))
|
||||||
{
|
{
|
||||||
// 如果在当前用户下找不到,再试一下所有用户
|
|
||||||
installPath = GetInstallPathFromKey(@"SOFTWARE\Wow6432Node\Valve\Steam");
|
installPath = GetInstallPathFromKey(@"SOFTWARE\Wow6432Node\Valve\Steam");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +206,7 @@ public class Mod
|
||||||
{
|
{
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
||||||
object path = key.GetValue("InstallPath");
|
var path = key.GetValue("InstallPath");
|
||||||
if (path != null)
|
if (path != null)
|
||||||
{
|
{
|
||||||
return (string)path;
|
return (string)path;
|
||||||
|
@ -260,7 +214,7 @@ public class Mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey))
|
using (var key = Registry.LocalMachine.OpenSubKey(subKey))
|
||||||
{
|
{
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +226,7 @@ public class Mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user