mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-22 01:16:17 +08:00
SteamApp Edit Save
This commit is contained in:
@@ -217,7 +217,7 @@
|
||||
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_ResizeAppLogo,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
Label="{ReflectionBinding Path=Res.GameList_ResizeAppLogo,Mode=OneWay,Source={x:Static resx:R.Current}}">
|
||||
<ui:CommandBarButton.Styles>
|
||||
<Style Selector="ui|CommandBarButton:flyout /template/ ui|SymbolIcon#SubItemChevron">
|
||||
<Style Selector="ui|CommandBarButton:flyout /template/ ui|FontIcon#SubItemChevron">
|
||||
<Setter Property="IsVisible" Value="False"/>
|
||||
</Style>
|
||||
</ui:CommandBarButton.Styles>
|
||||
|
||||
@@ -140,7 +140,9 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
if (OperatingSystem2.IsWindows)
|
||||
{
|
||||
#pragma warning disable CA1416 // 验证平台兼容性
|
||||
platformService.StartAsInvoker(SteamProgramPath, arguments);
|
||||
#pragma warning restore CA1416 // 验证平台兼容性
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -507,6 +509,32 @@ namespace System.Application.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存修改后的游戏数据到steam本地客户端缓存文件
|
||||
/// </summary>
|
||||
public bool SaveAppInfosToSteam()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AppInfoPath) && !File.Exists(AppInfoPath))
|
||||
return false;
|
||||
|
||||
using (BinaryWriter binaryWriter = new (new MemoryStream()))
|
||||
{
|
||||
binaryWriter.Write(MagicNumber);
|
||||
binaryWriter.Write(univeseNumber);
|
||||
foreach (SteamApp app in SteamConnectService.Current.SteamApps.Items)
|
||||
{
|
||||
app.Write(binaryWriter);
|
||||
}
|
||||
binaryWriter.Write(0);
|
||||
using (FileStream fileStream = File.Open(AppInfoPath, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
binaryWriter.BaseStream.Position = 0L;
|
||||
binaryWriter.BaseStream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public uint[] GetInstalledAppIds()
|
||||
{
|
||||
return GetDownloadingAppList().Where(x => x.IsInstalled).Select(x => x.AppId).ToArray();
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Application.SteamApiUrls;
|
||||
|
||||
@@ -543,6 +545,64 @@ namespace System.Application.Models
|
||||
return app;
|
||||
}
|
||||
|
||||
public void Write(BinaryWriter writer)
|
||||
{
|
||||
this.ClearCachedProps();
|
||||
SteamAppPropertyTable propertyTable = new SteamAppPropertyTable(this._properties);
|
||||
SteamAppPropertyTable? propertyValue = propertyTable.GetPropertyValue<SteamAppPropertyTable>(null, NodeAppInfo, NodeCommon);
|
||||
if (propertyValue != null)
|
||||
{
|
||||
string? text = Name;
|
||||
if (text != null)
|
||||
{
|
||||
SteamAppPropertyTable? propertyValue2 = propertyValue.GetPropertyValue<SteamAppPropertyTable>(null, "name_localized");
|
||||
if (propertyValue2 != null)
|
||||
{
|
||||
propertyTable.SetPropertyValue(SteamAppPropertyType.Table, propertyValue2, NodeAppInfo, "steam_edit", "base_name_localized");
|
||||
propertyValue.RemoveProperty("name_localized");
|
||||
}
|
||||
propertyTable.SetPropertyValue(SteamAppPropertyType.String, text, NodeAppInfo, "steam_edit", "base_name");
|
||||
//if (SteamData.UseCompleted && this.IsCompleted)
|
||||
//{
|
||||
// text += SteamData.CompletedSuffix;
|
||||
//}
|
||||
propertyValue.SetPropertyValue("name", SteamAppPropertyType.String, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("SteamApp Write Error", $"AppInfo {AppId:X8} has null name!");
|
||||
}
|
||||
string? text2 = propertyValue.GetPropertyValue<string>("type", "game");
|
||||
if (text2 != null)
|
||||
{
|
||||
propertyTable.SetPropertyValue(SteamAppPropertyType.String, text2, NodeAppInfo, "steam_edit", "base_type");
|
||||
//if (SteamData.UseHidden && this.IsHidden)
|
||||
//{
|
||||
// text2 = "hidden_" + text2;
|
||||
//}
|
||||
propertyValue.SetPropertyValue("type", SteamAppPropertyType.String, text2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("SteamApp Write Error", $"AppInfo {AppId:X8} has null type!");
|
||||
}
|
||||
}
|
||||
string s = propertyTable.ToString();
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(s);
|
||||
byte[] buffer = SHA1.Create().ComputeHash(bytes);
|
||||
writer.Write(this.AppId);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream()))
|
||||
{
|
||||
binaryWriter.Write(this._stuffBeforeHash);
|
||||
binaryWriter.Write(buffer);
|
||||
binaryWriter.Write(this._changeNumber);
|
||||
SteamAppPropertyHelper.Write(binaryWriter, propertyTable);
|
||||
MemoryStream memoryStream = (MemoryStream)binaryWriter.BaseStream;
|
||||
writer.Write((int)memoryStream.Length);
|
||||
writer.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsBitSet(int b, int pos)
|
||||
{
|
||||
return (b & (1 << pos)) != 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace System.Application.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 已正常权限启动进程
|
||||
/// 以正常权限启动进程
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Reference in New Issue
Block a user