From 3eeb893bc4738234f486731bc2d21c60918c6721 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Mon, 15 Feb 2021 20:52:58 +0100 Subject: [PATCH] Disabled overlay setting, only supported in experimental build. Started adding more options. --- GoldbergGUI.Core/Models/GoldbergModel.cs | 176 +++++++++++++++++++ GoldbergGUI.Core/Services/GoldbergService.cs | 29 ++- GoldbergGUI.WPF/Views/MainView.xaml | 2 +- 3 files changed, 203 insertions(+), 4 deletions(-) diff --git a/GoldbergGUI.Core/Models/GoldbergModel.cs b/GoldbergGUI.Core/Models/GoldbergModel.cs index 1906781..32e8227 100644 --- a/GoldbergGUI.Core/Models/GoldbergModel.cs +++ b/GoldbergGUI.Core/Models/GoldbergModel.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace GoldbergGUI.Core.Models { @@ -7,13 +9,187 @@ namespace GoldbergGUI.Core.Models public string AccountName { get; set; } public long UserSteamId { get; set; } public string Language { get; set; } + public List CustomBroadcastIps { get; set; } } public class GoldbergConfiguration { public int AppId { get; set; } public List DlcList { get; set; } + + public List Depots { get; set; } + + public List SubscribedGroups { get; set; } + + public Dictionary AppPaths { get; set; } + + public List Achievements { get; set; } + + public List Items { get; set; } + + public List Leaderboards { get; set; } + + public List Stats { get; set; } + + // Add controller setting here! public bool Offline { get; set; } public bool DisableNetworking { get; set; } public bool DisableOverlay { get; set; } + + public GoldbergGlobalConfiguration OverwrittenGlobalConfiguration { get; set; } + } + + public class Achievement + { + [JsonPropertyName("description")] + public string Description { get; set; } + + [JsonPropertyName("displayName")] + public string DisplayName { get; set; } + + [JsonPropertyName("hidden")] + public string Hidden { get; set; } + + [JsonPropertyName("icon")] + public string Icon { get; set; } + + [JsonPropertyName("icongray")] + public string IconGray { get; set; } + + [JsonPropertyName("name")] + public string Name { get; set; } + } + + public class Item + { + [JsonPropertyName("Timestamp")] + public DateTimeOffset Timestamp { get; set; } + + [JsonPropertyName("modified")] + public string Modified { get; set; } + + [JsonPropertyName("date_created")] + public string DateCreated { get; set; } + + [JsonPropertyName("type")] + public string Type { get; set; } + + [JsonPropertyName("display_type")] + public string DisplayType { get; set; } + + [JsonPropertyName("name")] + public string Name { get; set; } + + [JsonPropertyName("bundle")] + public string Bundle { get; set; } + + [JsonPropertyName("description")] + public string Description { get; set; } + + [JsonPropertyName("background_color")] + public string BackgroundColor { get; set; } + + [JsonPropertyName("icon_url")] + public Uri IconUrl { get; set; } + + [JsonPropertyName("icon_url_large")] + public Uri IconUrlLarge { get; set; } + + [JsonPropertyName("name_color")] + public string NameColor { get; set; } + + [JsonPropertyName("tradable")] + // [JsonConverter(typeof(PurpleParseStringConverter))] + public bool Tradable { get; set; } + + [JsonPropertyName("marketable")] + // [JsonConverter(typeof(PurpleParseStringConverter))] + public bool Marketable { get; set; } + + [JsonPropertyName("commodity")] + // [JsonConverter(typeof(PurpleParseStringConverter))] + public bool Commodity { get; set; } + + [JsonPropertyName("drop_interval")] + // [JsonConverter(typeof(FluffyParseStringConverter))] + public long DropInterval { get; set; } + + [JsonPropertyName("drop_max_per_window")] + // [JsonConverter(typeof(FluffyParseStringConverter))] + public long DropMaxPerWindow { get; set; } + + [JsonPropertyName("workshopid")] + // [JsonConverter(typeof(FluffyParseStringConverter))] + public long Workshopid { get; set; } + + [JsonPropertyName("tw_unique_to_own")] + // [JsonConverter(typeof(PurpleParseStringConverter))] + public bool TwUniqueToOwn { get; set; } + + [JsonPropertyName("item_quality")] + // [JsonConverter(typeof(FluffyParseStringConverter))] + public long ItemQuality { get; set; } + + [JsonPropertyName("tw_price")] + public string TwPrice { get; set; } + + [JsonPropertyName("tw_type")] + public string TwType { get; set; } + + [JsonPropertyName("tw_client_visible")] + // [JsonConverter(typeof(FluffyParseStringConverter))] + public long TwClientVisible { get; set; } + + [JsonPropertyName("tw_icon_small")] + public string TwIconSmall { get; set; } + + [JsonPropertyName("tw_icon_large")] + public string TwIconLarge { get; set; } + + [JsonPropertyName("tw_description")] + public string TwDescription { get; set; } + + [JsonPropertyName("tw_client_name")] + public string TwClientName { get; set; } + + [JsonPropertyName("tw_client_type")] + public string TwClientType { get; set; } + + [JsonPropertyName("tw_rarity")] + public string TwRarity { get; set; } + } + + public class Leaderboard + { + public string Name { get; set; } + public SortMethod SortMethodSetting { get; set; } + public DisplayType DisplayTypeSetting { get; set; } + + public enum SortMethod + { + None, + Ascending, + Descending + } + public enum DisplayType + { + None, + Numeric, + TimeSeconds, + TimeMilliseconds + } + } + + public class Stat + { + public string Name { get; set; } + public StatType StatTypeSetting { get; set; } + public string Value { get; set; } + + public enum StatType + { + Int, + Float, + AvgRate + } } } \ No newline at end of file diff --git a/GoldbergGUI.Core/Services/GoldbergService.cs b/GoldbergGUI.Core/Services/GoldbergService.cs index e99e86a..2bd56b2 100644 --- a/GoldbergGUI.Core/Services/GoldbergService.cs +++ b/GoldbergGUI.Core/Services/GoldbergService.cs @@ -46,6 +46,7 @@ namespace GoldbergGUI.Core.Services private readonly string _accountNamePath = Path.Combine(GlobalSettingsPath, "settings/account_name.txt"); private readonly string _userSteamIdPath = Path.Combine(GlobalSettingsPath, "settings/user_steam_id.txt"); private readonly string _languagePath = Path.Combine(GlobalSettingsPath, "settings/language.txt"); + private readonly string _customBroadcastIpsPath = Path.Combine(GlobalSettingsPath, "settings/custom_broadcasts.txt"); private readonly List _interfaceNames = new List { @@ -92,20 +93,27 @@ namespace GoldbergGUI.Core.Services var accountName = "Account name..."; long steamId = -1; var language = DefaultLanguage; + var customBroadcastIps = new List(); await Task.Run(() => { if (File.Exists(_accountNamePath)) accountName = File.ReadLines(_accountNamePath).First().Trim(); if (File.Exists(_userSteamIdPath) && !long.TryParse(File.ReadLines(_userSteamIdPath).First().Trim(), out steamId) && steamId < 76561197960265729 && steamId > 76561202255233023) + { _log.Error("Invalid User Steam ID!"); + } if (File.Exists(_languagePath)) language = File.ReadLines(_languagePath).First().Trim(); + if (File.Exists(_customBroadcastIpsPath)) + customBroadcastIps.AddRange( + File.ReadLines(_customBroadcastIpsPath).Select(line => line.Trim())); }).ConfigureAwait(false); return new GoldbergGlobalConfiguration { AccountName = accountName, UserSteamId = steamId, - Language = language + Language = language, + CustomBroadcastIps = customBroadcastIps }; } @@ -114,7 +122,9 @@ namespace GoldbergGUI.Core.Services var accountName = c.AccountName; var userSteamId = c.UserSteamId; var language = c.Language; + var customBroadcastIps = c.CustomBroadcastIps; _log.Info("Setting global settings..."); + // Account Name if (accountName != null && accountName != "Account name...") { _log.Info("Setting account name..."); @@ -125,7 +135,7 @@ namespace GoldbergGUI.Core.Services _log.Info("Invalid account name! Skipping..."); await File.WriteAllTextAsync(_accountNamePath, "Goldberg").ConfigureAwait(false); } - + // User SteamID if (userSteamId >= 76561197960265729 && userSteamId <= 76561202255233023) { _log.Info("Setting user Steam ID..."); @@ -136,7 +146,7 @@ namespace GoldbergGUI.Core.Services _log.Info("Invalid user Steam ID! Skipping..."); await Task.Run(() => File.Delete(_userSteamIdPath)).ConfigureAwait(false); } - + // Language if (language != null) { _log.Info("Setting language..."); @@ -147,6 +157,19 @@ namespace GoldbergGUI.Core.Services _log.Info("Invalid language! Skipping..."); await File.WriteAllTextAsync(_languagePath, DefaultLanguage).ConfigureAwait(false); } + // Custom Broadcast IPs + if (customBroadcastIps.Count > 0) + { + _log.Info("Setting custom broadcast IPs..."); + var result = + customBroadcastIps.Aggregate("", (current, address) => $"{current}{address}\n"); + await File.WriteAllTextAsync(_customBroadcastIpsPath, result).ConfigureAwait(false); + } + else + { + _log.Info("Empty list of custom broadcast IPs! Skipping..."); + await Task.Run(() => File.Delete(_customBroadcastIpsPath)).ConfigureAwait(false); + } } // If first time, call GenerateInterfaces diff --git a/GoldbergGUI.WPF/Views/MainView.xaml b/GoldbergGUI.WPF/Views/MainView.xaml index 62094dc..fd3cc34 100644 --- a/GoldbergGUI.WPF/Views/MainView.xaml +++ b/GoldbergGUI.WPF/Views/MainView.xaml @@ -84,7 +84,7 @@ - +