private void ReadDecorations(Stream saveData) { var decorationsReader = new DecorationsReader(saveData); foreach (DecorationsSaveSlotInfo decorationInfo in decorationsReader.Read()) { PrintBaseSaveData(decorationInfo); Console.WriteLine(); Console.WriteLine($"{decorationInfo.Decorations.Count} decorations"); foreach (KeyValuePair <uint, uint> decoKeyValue in decorationInfo.Decorations.OrderBy(kv => MasterData.FindJewelInfoByItemId(kv.Key).Name)) { Console.WriteLine($" {MasterData.FindJewelInfoByItemId(decoKeyValue.Key).Name}: x{decoKeyValue.Value}"); } PrintSeparator('-'); } }
private async void ComboBoxSteamUsers_SelectedValueChanged(object sender, EventArgs e) { comboBoxCharacters.DataSource = null; if (comboBoxSteamUsers.SelectedIndex == -1) { return; } var saveFileFullPath = comboBoxSteamUsers.SelectedValue.ToString(); // Decrypt the save data. using Stream inputStream = File.OpenRead(saveFileFullPath); byte[] buffer = new byte[inputStream.Length]; await inputStream.ReadAsync(buffer, 0, buffer.Length, CancellationToken.None); await new Crypto().DecryptAsync(buffer); var saveData = new MemoryStream(buffer); // Load the decorations info. var decorationsReader = new DecorationsReader(saveData); var decorationsSaveSlots = decorationsReader.Read().ToList(); comboBoxCharacters.DisplayMember = "Name"; comboBoxCharacters.ValueMember = "Decorations"; comboBoxCharacters.DataSource = decorationsSaveSlots; // Auto-select the remembered character or the first available character. if (decorationsSaveSlots.Any()) { int indexToSelect = -1; if (LastUsedCharacterName != null) { indexToSelect = decorationsSaveSlots .FindIndex(saveSlot => saveSlot.Name == LastUsedCharacterName); } comboBoxCharacters.SelectedIndex = indexToSelect >= 0 ? indexToSelect : 0; } LastUsedCharacterName = null; }
private async Task <IList <DecorationsSaveSlotInfo> > ReadSaveData(SaveDataInfo saveDataInfo) { var ms = new MemoryStream(); using (Stream inputStream = File.OpenRead(saveDataInfo.SaveDataFullFilename)) { await Crypto.DecryptAsync(inputStream, ms, CancellationToken.None); } using (var reader = new DecorationsReader(ms)) { var list = new List <DecorationsSaveSlotInfo>(); foreach (DecorationsSaveSlotInfo info in reader.Read()) { info.SetSaveDataInfo(saveDataInfo); list.Add(info); } return(list); } }