Skip to content

Commit fe80d30

Browse files
committed
Add support for GamingDeviceType, kill OnlinePreferences
1 parent 86410d4 commit fe80d30

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

ArchiSteamFarm/Steam/Bot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,7 @@ private async void OnConnected(SteamClient.ConnectedCallback callback) {
28572857
CellID = ASF.GlobalDatabase?.CellID,
28582858
ChatMode = SteamUser.ChatMode.NewSteamChat,
28592859
ClientLanguage = CultureInfo.CurrentCulture.ToSteamClientLanguage(),
2860-
IsSteamDeck = BotConfig.OnlinePreferences.HasFlag(BotConfig.EOnlinePreferences.IsSteamDeck),
2860+
GamingDeviceType = BotConfig.GamingDeviceType,
28612861
LoginID = LoginID,
28622862
ShouldRememberPassword = BotConfig.UseLoginKeys,
28632863
UIMode = BotConfig.UserInterfaceMode,

ArchiSteamFarm/Steam/Storage/BotConfig.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ public sealed class BotConfig {
6666
[PublicAPI]
6767
public const EFarmingPreferences DefaultFarmingPreferences = EFarmingPreferences.None;
6868

69+
[PublicAPI]
70+
public const EGamingDeviceType DefaultGamingDeviceType = EGamingDeviceType.StandardPC;
71+
6972
[PublicAPI]
7073
public const byte DefaultHoursUntilCardDrops = 3;
7174

7275
[PublicAPI]
7376
public const EPersonaStateFlag DefaultOnlineFlags = 0;
7477

78+
// TODO: Remove me
79+
[Obsolete("Will be removed in the next stable release")]
7580
[PublicAPI]
7681
public const EOnlinePreferences DefaultOnlinePreferences = EOnlinePreferences.None;
7782

@@ -229,6 +234,10 @@ public WebProxy? WebProxy {
229234
[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "This is optional, supportive attribute, we don't care if it gets trimmed or not")]
230235
public ImmutableList<uint> GamesPlayedWhileIdle { get; init; } = DefaultGamesPlayedWhileIdle;
231236

237+
// TODO: Change set to init
238+
[JsonInclude]
239+
public EGamingDeviceType GamingDeviceType { get; internal set; } = DefaultGamingDeviceType;
240+
232241
[JsonInclude]
233242
[Range(byte.MinValue, byte.MaxValue)]
234243
public byte HoursUntilCardDrops { get; init; } = DefaultHoursUntilCardDrops;
@@ -244,7 +253,9 @@ public WebProxy? WebProxy {
244253
[JsonInclude]
245254
public EPersonaStateFlag OnlineFlags { get; init; } = DefaultOnlineFlags;
246255

256+
// TODO: Remove me
247257
[JsonInclude]
258+
[Obsolete("Will be removed in the next stable release")]
248259
public EOnlinePreferences OnlinePreferences { get; init; } = DefaultOnlinePreferences;
249260

250261
[JsonInclude]
@@ -403,6 +414,9 @@ public BotConfig() { }
403414
[UsedImplicitly]
404415
public bool ShouldSerializeGamesPlayedWhileIdle() => !Saving || ((GamesPlayedWhileIdle != DefaultGamesPlayedWhileIdle) && !GamesPlayedWhileIdle.SequenceEqual(DefaultGamesPlayedWhileIdle));
405416

417+
[UsedImplicitly]
418+
public bool ShouldSerializeGamingDeviceType() => !Saving || (GamingDeviceType != DefaultGamingDeviceType);
419+
406420
[UsedImplicitly]
407421
public bool ShouldSerializeHoursUntilCardDrops() => !Saving || (HoursUntilCardDrops != DefaultHoursUntilCardDrops);
408422

@@ -415,8 +429,10 @@ public BotConfig() { }
415429
[UsedImplicitly]
416430
public bool ShouldSerializeOnlineFlags() => !Saving || (OnlineFlags != DefaultOnlineFlags);
417431

432+
#pragma warning disable CA1822 // TODO: Remove me
418433
[UsedImplicitly]
419-
public bool ShouldSerializeOnlinePreferences() => !Saving || (OnlinePreferences != DefaultOnlinePreferences);
434+
public bool ShouldSerializeOnlinePreferences() => false;
435+
#pragma warning restore CA1822 // TODO: Remove me
420436

421437
[UsedImplicitly]
422438
public bool ShouldSerializeOnlineStatus() => !Saving || (OnlineStatus != DefaultOnlineStatus);
@@ -514,6 +530,10 @@ public static async Task<bool> Write(string filePath, BotConfig botConfig) {
514530
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(GamesPlayedWhileIdle), $"{nameof(GamesPlayedWhileIdle.Count)} {GamesPlayedWhileIdle.Count} > {ArchiHandler.MaxGamesPlayedConcurrently}"));
515531
}
516532

533+
if (GamingDeviceType == EGamingDeviceType.Unknown || !Enum.IsDefined(GamingDeviceType)) {
534+
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(GamingDeviceType), GamingDeviceType));
535+
}
536+
517537
foreach (EAssetType lootableType in LootableTypes.Where(static lootableType => !Enum.IsDefined(lootableType))) {
518538
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(LootableTypes), lootableType));
519539
}
@@ -548,10 +568,16 @@ public static async Task<bool> Write(string filePath, BotConfig botConfig) {
548568
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OnlineFlags), OnlineFlags));
549569
}
550570

571+
#pragma warning disable CS0618 // TODO: Remove me
551572
if (OnlinePreferences > EOnlinePreferences.All) {
552573
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OnlinePreferences), OnlinePreferences));
553574
}
554575

576+
if (OnlinePreferences.HasFlag(EOnlinePreferences.IsSteamDeck)) {
577+
GamingDeviceType = EGamingDeviceType.SteamDeck;
578+
}
579+
#pragma warning restore CS0618 // TODO: Remove me
580+
555581
if (!Enum.IsDefined(OnlineStatus)) {
556582
return (false, Strings.FormatErrorConfigPropertyInvalid(nameof(OnlineStatus), OnlineStatus));
557583
}
@@ -736,6 +762,7 @@ public enum EFarmingPreferences : ushort {
736762
}
737763

738764
[Flags]
765+
[Obsolete("Will be removed in the next stable release")]
739766
[PublicAPI]
740767
public enum EOnlinePreferences : byte {
741768
None = 0,

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
1818
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
1919
<PackageVersion Include="Scalar.AspNetCore" Version="2.6.9" />
20-
<PackageVersion Include="SteamKit2" Version="3.3.0" />
20+
<PackageVersion Include="SteamKit2" Version="3.3.1" />
2121
<PackageVersion Include="System.Composition" Version="9.0.8" />
2222
<PackageVersion Include="System.Composition.AttributedModel" Version="9.0.8" />
2323
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />

0 commit comments

Comments
 (0)