Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1bbd5b4

Browse files
committed
SteamApp Edit Feature 90%
1 parent baed8b9 commit 1bbd5b4

10 files changed

Lines changed: 340 additions & 41 deletions

File tree

src/ST.Client.Desktop.Avalonia/Application/Converters/StringFormatConverter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public class StringFormatConverter : IValueConverter, IMultiValueConverter
4949
return str.Format(para);
5050
}
5151
}
52+
else
53+
{
54+
return str.Format(string.Empty);
55+
}
5256
return str;
5357
}
5458

src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/GameListPage.axaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,29 +237,29 @@
237237
</ui:CommandBarButton>
238238

239239
<ui:CommandBarSeparator/>
240-
240+
241241
<ui:CommandBarButton
242242
Command="{Binding SaveEditedAppInfoCommand}"
243-
ToolTip.Tip="保存游戏编辑后信息到Steam"
244-
Label="保存编辑信息">
243+
ToolTip.Tip="{ReflectionBinding $self.Label}"
244+
Label="{ReflectionBinding Path=Res.GameList_EditedAppsSaveManger,Mode=OneWay,Source={x:Static resx:R.Current}}">
245245
<ui:CommandBarButton.Icon>
246-
<ui:SymbolIcon Symbol="SaveLocal" FontSize="26"/>
246+
<ui:PathIcon Data="{StaticResource DocumentEditDrawing}"/>
247247
</ui:CommandBarButton.Icon>
248248
</ui:CommandBarButton>
249249

250250
<ui:CommandBarButton
251251
IsVisible="{x:Static sys:OperatingSystem2.IsWindows}"
252252
Command="{Binding IdleAppCommand}"
253-
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_IdleGamesManger,Mode=OneWay,Source={x:Static resx:R.Current}}"
253+
ToolTip.Tip="{ReflectionBinding $self.Label}"
254254
Label="{ReflectionBinding Path=Res.GameList_IdleGamesManger,Mode=OneWay,Source={x:Static resx:R.Current}}">
255255
<ui:CommandBarButton.Icon>
256256
<ui:PathIcon Data="{StaticResource TopSpeedDrawing}"/>
257257
</ui:CommandBarButton.Icon>
258258
</ui:CommandBarButton>
259-
259+
260260
<ui:CommandBarButton
261261
Command="{Binding SteamShutdownCommand}"
262-
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_SteamShutdown,Mode=OneWay,Source={x:Static resx:R.Current}}"
262+
ToolTip.Tip="{ReflectionBinding $self.Label}"
263263
Label="{ReflectionBinding Path=Res.GameList_SteamShutdown,Mode=OneWay,Source={x:Static resx:R.Current}}">
264264
<ui:CommandBarButton.Icon>
265265
<ui:PathIcon Data="{StaticResource ClockArrowDownloadDrawing}"/>
@@ -269,17 +269,15 @@
269269
</ui:CommandBar.PrimaryCommands>
270270
<ui:CommandBar.SecondaryCommands>
271271

272-
<ui:CommandBarToggleButton
273-
IsChecked="{Binding Source={x:Static ms:GameLibrarySettings.IsAutoAFKApps},Path=Value, Mode=TwoWay}"
274-
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_AutoAFK,Mode=OneWay,Source={x:Static resx:R.Current}}"
275-
Label="{ReflectionBinding Path=Res.GameList_AutoAFK,Mode=OneWay,Source={x:Static resx:R.Current}}">
272+
<ui:CommandBarToggleButton IsChecked="{Binding Source={x:Static ms:GameLibrarySettings.IsAutoAFKApps},Path=Value, Mode=TwoWay}"
273+
ToolTip.Tip="{ReflectionBinding $self.Label}"
274+
Label="{ReflectionBinding Path=Res.GameList_AutoAFK,Mode=OneWay,Source={x:Static resx:R.Current}}">
276275
</ui:CommandBarToggleButton>
277276

278277
<ui:CommandBarSeparator/>
279278

280-
<ui:CommandBarButton
281-
Command="{Binding HideAppCommand}"
282-
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_HideGameManger,Mode=OneWay,Source={x:Static resx:R.Current}}"
279+
<ui:CommandBarButton Command="{Binding HideAppCommand}"
280+
ToolTip.Tip="{ReflectionBinding $self.Label}"
283281
Label="{ReflectionBinding Path=Res.GameList_HideGameManger,Mode=OneWay,Source={x:Static resx:R.Current}}">
284282
<ui:CommandBarButton.Icon>
285283
<ui:PathIcon Data="{StaticResource EyeHideDrawing}"/>

src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/GameListPage/EditAppInfoWindow.axaml

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
xmlns:controls="clr-namespace:System.Application.UI.Views.Controls"
1212
xmlns:ms="using:System.Application.Settings"
1313
xmlns:ui="using:FluentAvalonia.UI.Controls"
14+
xmlns:col="using:System.Collections"
15+
xmlns:sys="using:System"
1416
xmlns:gif="using:AvaloniaGif"
1517
x:Name="u"
1618
Background="Transparent"
@@ -81,17 +83,22 @@
8183
<DockPanel>
8284
<TextBlock Text="{ReflectionBinding Path=Res.DiskUsage,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
8385
<TextBlock Classes="right"
84-
Text="{ReflectionBinding App.SizeOnDisk,Converter={StaticResource StringFormatConverter},ConverterParameter=size}"/>
86+
Text="{Binding App.SizeOnDisk,Converter={StaticResource StringFormatConverter},ConverterParameter=size}"/>
8587
</DockPanel>
8688
</Border>
8789

8890
<Border Classes="Item" IsVisible="{Binding App.IsInstalled}">
8991
<DockPanel>
9092
<TextBlock Text="{ReflectionBinding Path=Res.InstalledPath,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
91-
<TextBlock Classes="right"
92-
Text="{ReflectionBinding App.InstalledDir}"/>
93-
<!--<Button Classes="Hyperlink"
94-
Content="{ReflectionBinding App.InstalledDir}"/>-->
93+
<Button Classes="plain"
94+
HorizontalAlignment="Right"
95+
ToolTip.Tip="{ReflectionBinding Path=Res.Settings_General_BrowseCustomFolder,Mode=OneWay,Source={x:Static resx:R.Current},Converter={StaticResource StringFormatConverter},ConverterParameter={x:Null}}"
96+
Command="{ReflectionBinding OpenFolder}"
97+
CommandParameter="{Binding App.InstalledDir}">
98+
<TextBlock Text="{Binding App.InstalledDir}"
99+
TextAlignment="Right"
100+
TextWrapping="WrapWithOverflow"/>
101+
</Button>
95102
</DockPanel>
96103
</Border>
97104

@@ -295,9 +302,13 @@
295302
<Label Content="{ReflectionBinding Path=Res.SupportSystem,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
296303
<ui:ComboBox IsEditable="True"
297304
Text="{Binding Platform,Mode=TwoWay}">
298-
<ui:ComboBoxItem Content="windows"/>
299-
<ui:ComboBoxItem Content="linux"/>
300-
<ui:ComboBoxItem Content="macos"/>
305+
<ui:ComboBox.Items>
306+
<col:ArrayList>
307+
<sys:String>windows</sys:String>
308+
<sys:String>linux</sys:String>
309+
<sys:String>macos</sys:String>
310+
</col:ArrayList>
311+
</ui:ComboBox.Items>
301312
</ui:ComboBox>
302313
</DockPanel>
303314

@@ -346,6 +357,69 @@
346357

347358
</TabItem>
348359

360+
<TabItem Header="{ReflectionBinding Path=Res.SaveFile,Mode=OneWay,Source={x:Static resx:R.Current}}"
361+
IsVisible="{Binding App.IsCloudArchive}">
362+
<ScrollViewer>
363+
<StackPanel Classes="Settings">
364+
<Border Classes="Item">
365+
<StackPanel Spacing="5">
366+
<DockPanel>
367+
<Label Content="{ReflectionBinding Path=Res.CloudSaveFileSize,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
368+
<TextBlock Classes="right"
369+
Text="{ReflectionBinding App.CloudQuota,Converter={StaticResource StringFormatConverter},ConverterParameter=size}"/>
370+
</DockPanel>
371+
<DockPanel>
372+
<Label Content="{ReflectionBinding Path=Res.CloudMaxnumFiles,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
373+
<TextBlock Classes="right"
374+
Text="{Binding App.CloudMaxnumFiles}"/>
375+
</DockPanel>
376+
</StackPanel>
377+
</Border>
378+
379+
<ItemsRepeater Items="{Binding App.SaveFiles}">
380+
<ItemsRepeater.Layout>
381+
<StackLayout Orientation="Vertical" Spacing="10"/>
382+
</ItemsRepeater.Layout>
383+
<ItemsRepeater.ItemTemplate>
384+
<DataTemplate DataType="{x:Type models:SteamAppSaveFile}">
385+
<Border Classes="Item">
386+
<StackPanel Spacing="5">
387+
<DockPanel>
388+
<Label Content="Root"/>
389+
<TextBlock Classes="right" Text="{Binding Root}"/>
390+
</DockPanel>
391+
<DockPanel>
392+
<Label Content="Path"/>
393+
<TextBlock Classes="right" Text="{Binding Path}"/>
394+
</DockPanel>
395+
<DockPanel>
396+
<Label Content="Pattern"/>
397+
<TextBlock Classes="right" Text="{Binding Pattern}"/>
398+
</DockPanel>
399+
<DockPanel>
400+
<Label Content="{ReflectionBinding Path=Res.DirPath,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
401+
<Button Classes="plain"
402+
HorizontalContentAlignment="Stretch"
403+
HorizontalAlignment="Right"
404+
ToolTip.Tip="{ReflectionBinding Path=Res.Settings_General_BrowseCustomFolder,Mode=OneWay,Source={x:Static resx:R.Current},Converter={StaticResource StringFormatConverter},ConverterParameter={x:Null}}"
405+
Command="{ReflectionBinding #u.DataContext.OpenFolder}"
406+
CommandParameter="{Binding FormatDirPath}">
407+
<TextBlock Text="{Binding FormatDirPath}"
408+
TextAlignment="Right"
409+
HorizontalAlignment="Stretch"
410+
TextWrapping="WrapWithOverflow"/>
411+
</Button>
412+
</DockPanel>
413+
</StackPanel>
414+
</Border>
415+
</DataTemplate>
416+
</ItemsRepeater.ItemTemplate>
417+
</ItemsRepeater>
418+
</StackPanel>
419+
</ScrollViewer>
420+
421+
</TabItem>
422+
349423
<!--<TabItem Header="DLC">
350424
351425

src/ST.Client.Desktop.Windows/Services/Implementation/SteamServiceImpl.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,19 @@ public List<SteamUser> GetRememberUserList()
174174
SteamID = i.PersonaName?.ToString(),
175175
PersonaName = i.PersonaName?.ToString(),
176176
RememberPassword = Convert.ToBoolean(Convert.ToInt64(i.RememberPassword?.ToString())),
177-
Timestamp = Convert.ToInt64(i.Timestamp?.ToString())
178177
};
179-
user.LastLoginTime = user.Timestamp.ToDateTimeS();
180178

181179
// 老版本 Steam 数据 小写 mostrecent 支持
182180
user.MostRecent = i.mostrecent != null ?
183181
Convert.ToBoolean(Convert.ToByte(i.mostrecent.ToString())) :
184182
Convert.ToBoolean(Convert.ToByte(i.MostRecent.ToString()));
185183

184+
user.Timestamp = i.timestamp != null ?
185+
Convert.ToInt64(i.timestamp?.ToString()) :
186+
Convert.ToInt64(i.Timestamp?.ToString());
187+
188+
user.LastLoginTime = user.Timestamp.ToDateTimeS();
189+
186190
user.WantsOfflineMode = i.WantsOfflineMode != null ?
187191
Convert.ToBoolean(Convert.ToByte(i.WantsOfflineMode.ToString())) : false;
188192

@@ -550,6 +554,9 @@ public async Task<bool> SaveAppInfosToSteam()
550554
fileStream.Close();
551555
binaryWriter.Close();
552556

557+
int identificador = GC.GetGeneration(applist);
558+
applist = null;
559+
GC.Collect(identificador, GCCollectionMode.Forced);
553560
}
554561
catch (Exception ex)
555562
{

src/ST.Client/Models/Steam/SteamApp.cs

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ public string? SortAs
146146
// get
147147
// {
148148
// return _properties?.GetPropertyValue<string>(null, NodeAppInfo,
149-
// NodeCommon,
149+
// NodeExtended,
150150
// NodeDeveloper);
151151
// }
152152
// set
153153
// {
154154
// _properties?.SetPropertyValue(SteamAppPropertyType.String, value, NodeAppInfo,
155-
// NodeCommon,
155+
// NodeExtended,
156156
// NodeDeveloper);
157157
// }
158158
//}
@@ -162,13 +162,13 @@ public string? SortAs
162162
// get
163163
// {
164164
// return _properties?.GetPropertyValue<string>(null, NodeAppInfo,
165-
// NodeCommon,
165+
// NodeExtended,
166166
// NodePublisher);
167167
// }
168168
// set
169169
// {
170170
// _properties?.SetPropertyValue(SteamAppPropertyType.String, value, NodeAppInfo,
171-
// NodeCommon,
171+
// NodeExtended,
172172
// NodePublisher);
173173
// }
174174
//}
@@ -191,18 +191,28 @@ public bool SetEditProperty(SteamApp appInfo)
191191
NodeExtended,
192192
NodeDeveloper);
193193

194+
_properties.SetPropertyValue(SteamAppPropertyType.String, appInfo.Developer, NodeAppInfo,
195+
NodeCommon,
196+
"associations", "0", "name");
197+
194198
_properties.SetPropertyValue(SteamAppPropertyType.String, appInfo.Publisher, NodeAppInfo,
195199
NodeExtended,
196200
NodePublisher);
197201

202+
_properties.SetPropertyValue(SteamAppPropertyType.String, appInfo.Publisher, NodeAppInfo,
203+
NodeCommon,
204+
"associations", "1", "name");
205+
198206
if (appInfo.LaunchItems.Any_Nullable())
199207
{
200-
var launchTable = _properties.GetPropertyValue<SteamAppPropertyTable>(null, NodeAppInfo, NodeConfig, NodeLaunch);
208+
//var launchTable = _properties.GetPropertyValue<SteamAppPropertyTable>(null, NodeAppInfo, NodeConfig, NodeLaunch);
201209

202-
if (launchTable == null)
203-
{
204-
launchTable = new SteamAppPropertyTable();
205-
}
210+
//if (launchTable == null)
211+
//{
212+
//launchTable = new SteamAppPropertyTable();
213+
//}
214+
215+
var launchTable = new SteamAppPropertyTable();
206216

207217
foreach (var item in appInfo.LaunchItems)
208218
{
@@ -222,7 +232,10 @@ public bool SetEditProperty(SteamApp appInfo)
222232
{
223233
propertyTable.SetPropertyValue("workingdir", SteamAppPropertyType.String, item.WorkingDir);
224234
}
225-
235+
if (!string.IsNullOrEmpty(item.Platform))
236+
{
237+
propertyTable.SetPropertyValue(SteamAppPropertyType.String, item.Platform, NodeConfig, NodePlatforms);
238+
}
226239
launchTable.SetPropertyValue(launchTable.Count.ToString(), SteamAppPropertyType.Table, propertyTable);
227240
}
228241

@@ -280,6 +293,21 @@ public string? CurrentDLSSVersion
280293

281294
public uint ParentId { get; set; }
282295

296+
/// <summary>
297+
/// 是否支持Steam云存档
298+
/// </summary>
299+
public bool IsCloudArchive => CloudQuota > 0;
300+
301+
/// <summary>
302+
/// 云存档字节大小
303+
/// </summary>
304+
public long CloudQuota { get; set; }
305+
306+
/// <summary>
307+
/// 云存档文件数量上限
308+
/// </summary>
309+
public int CloudMaxnumFiles { get; set; }
310+
283311
/// <summary>
284312
/// 最后运行用户SteamId64
285313
/// </summary>
@@ -293,7 +321,7 @@ public string? CurrentDLSSVersion
293321
private long _SizeOnDi;
294322
/// <summary>
295323
/// 占用硬盘字节大小
296-
/// </summary>sk;
324+
/// </summary>
297325
public long SizeOnDisk
298326
{
299327
get => _SizeOnDi;
@@ -331,6 +359,13 @@ public ObservableCollection<SteamAppLaunchItem>? LaunchItems
331359
set => this.RaiseAndSetIfChanged(ref _LaunchItems, value);
332360
}
333361

362+
private ObservableCollection<SteamAppSaveFile>? _SaveFiles;
363+
public ObservableCollection<SteamAppSaveFile>? SaveFiles
364+
{
365+
get => _SaveFiles;
366+
set => this.RaiseAndSetIfChanged(ref _SaveFiles, value);
367+
}
368+
334369
public string? LogoUrl => string.IsNullOrEmpty(Logo) ? null :
335370
string.Format(STEAMAPP_LOGO_URL, AppId, Logo);
336371

@@ -629,7 +664,7 @@ internal bool UpdateDll(LocalDlssDll localDll)
629664
app.Type == SteamAppType.Tool ||
630665
app.Type == SteamAppType.Demo))
631666
{
632-
var launchTable = properties.GetPropertyValue<SteamAppPropertyTable>(null, NodeAppInfo, NodeConfig, NodeLaunch);
667+
var launchTable = properties.GetPropertyValue<SteamAppPropertyTable?>(null, NodeAppInfo, NodeConfig, NodeLaunch);
633668

634669
if (launchTable != null)
635670
{
@@ -651,6 +686,31 @@ select prop.GetValue<SteamAppPropertyTable>())
651686
}
652687
}
653688

689+
app.CloudQuota = properties.GetPropertyValue<int>(0, NodeAppInfo, "ufs", "quota");
690+
app.CloudMaxnumFiles = properties.GetPropertyValue<int>(0, NodeAppInfo, "ufs", "maxnumfiles");
691+
692+
var savefilesTable = properties.GetPropertyValue<SteamAppPropertyTable?>(null, NodeAppInfo, "ufs", "savefiles");
693+
694+
if (savefilesTable != null)
695+
{
696+
var savefiles = from table in (from prop in (from prop in savefilesTable.Properties
697+
where prop.PropertyType == SteamAppPropertyType.Table
698+
select prop).OrderBy((SteamAppProperty prop) => prop.Name, StringComparer.OrdinalIgnoreCase)
699+
select prop.GetValue<SteamAppPropertyTable>())
700+
select new SteamAppSaveFile
701+
(
702+
app.AppId,
703+
table.GetPropertyValue<string?>("root"),
704+
table.GetPropertyValue<string?>("path"),
705+
table.GetPropertyValue<string?>("pattern")
706+
)
707+
{
708+
Recursive = table.GetPropertyValue<bool>(false, "recursive"),
709+
};
710+
711+
app.SaveFiles = new ObservableCollection<SteamAppSaveFile>(savefiles.ToList());
712+
}
713+
654714
//var propertyValue = app._properties.GetPropertyValue<string>("", new string[]
655715
//{
656716
// "appinfo",

0 commit comments

Comments
 (0)