public void ChooseReblaseGame(object param) { string gameId = FilterText; using (var client = new WebClient()) { try { string json = client.DownloadString($"https://api.sibr.dev/chronicler/v1/games/updates?game={gameId}&started=true&count=500"); var opts = new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true }; var result = JsonSerializer.Deserialize <ChroniclerPage>(json, opts); GameUpdates.Clear(); foreach (var cg in result.Data) { cg.Data.timestamp = cg.Timestamp; cg.Data.chroniclerHash = cg.Hash; AddGame(cg.Data); } } catch (Exception ex) { Debugger.Break(); } } }
private async Task LoadUpdates(string updatesFile) { GameUpdates.Clear(); LoadSaveEnabled = false; UpdatesDisabled = true; Mouse.OverrideCursor = Cursors.Wait; await AsyncLoadUpdates(updatesFile); Mouse.OverrideCursor = null; UpdatesDisabled = false; LoadSaveEnabled = true; m_convertCommand.RaiseCanExecuteChanged(); OnPropertyChanged(nameof(FilteredUpdates)); }
internal async Task AsyncLoadUpdates(string file) { try { GameUpdates.SupressNotification = true; m_stopwatch = new Stopwatch(); m_stopwatch.Start(); OnPropertyChanged(nameof(GameUpdatesDelayedCount)); using (StreamReader sr = new StreamReader(file)) { while (!sr.EndOfStream) { string obj = await sr.ReadLineAsync(); Update u = JsonSerializer.Deserialize <Update>(obj, s_diskOptions); foreach (var s in u.Schedule) { if (u.clientMeta != null) { s.timestamp = u.clientMeta.timestamp; } GameUpdates.Add(new GameUpdateVm(s, m_teamLookup)); } if (m_stopwatch.Elapsed > TimeSpan.FromSeconds(COUNT_DELAY)) { OnPropertyChanged(nameof(GameUpdatesDelayedCount)); m_stopwatch.Restart(); } } } m_stopwatch.Stop(); GameUpdates.SupressNotification = false; } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Something invalid happened.", "BLASPHEMY"); } }
// Start is called before the first frame update void Start() { // Reset game statics GameStatics.NewGame = true; GameStatics.LoadedGame = new GameData(); GameStatics.GameGuid = Guid.Empty.ToString(); // Load & Apply Settings // Audio float MasterVolume = PlayerPrefs.GetFloat("MasterVolume", 1); AudioMixer.SetFloat("MasterVolume", Mathf.Log10(MasterVolume) * 20); float MusicVolume = PlayerPrefs.GetFloat("MusicVolume", 0.35f); AudioMixer.SetFloat("MusicVolume", Mathf.Log10(MusicVolume) * 20); float SoundEffectVolume = PlayerPrefs.GetFloat("SoundEffectVolume", 0.5f); AudioMixer.SetFloat("SoundEffectVolume", Mathf.Log10(SoundEffectVolume) * 20); GameUpdates.CheckForUpdates(PopupManager); // Check for game updates DiscordRichPresenceManager.UpdateActivity("Main Menu"); }
internal void AddGame(Game g) { GameUpdates.Add(new GameUpdateVm(g, m_teamLookup)); m_convertCommand.RaiseCanExecuteChanged(); }
internal void ClearUpdates() { GameUpdates.Clear(); m_convertCommand.RaiseCanExecuteChanged(); }