public void LoadStatsOnly(uint seed, object _saveFile, string name) { callbackFunc1 = delegate { return(true); }; var dummyItem = new ItemData(); dummyItem.Header.Seed = seed; activeItem = dummyItem; activeSaveFile = (SaveFileHelper)_saveFile; this.Text = name; var newHeight = this.Height - 190; basicInfoGroupBox.Visible = false; flagsGroupBox.Visible = false; applyButton.Visible = false; detailsTabControl.TabPages.Remove(modInfoTab); if (name == "Player") { quickActionsGroupBox.Visible = false; } else { newHeight += 60; } this.Height = newHeight; statsOnly = true; ReloadData(); this.CenterToParent(); this.ShowDialog(); }
public void LoadFactDialog(Action <string> callback, object _saveFile) { callbackFunc = callback; activeSaveFile = (SaveFileHelper)_saveFile; factTypeBox.SelectedIndex = 0; this.ShowDialog(); }
private void saveChangesButton_Click(object sender, EventArgs e) { var saveWindow = new SaveFileDialog(); saveWindow.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Saved Games\\CD Projekt Red\\Cyberpunk 2077\\"; saveWindow.Filter = "Cyberpunk 2077 Save File|*.dat"; if (saveWindow.ShowDialog() == DialogResult.OK) { if (File.Exists(saveWindow.FileName) && !File.Exists(Path.GetDirectoryName(saveWindow.FileName) + "\\" + Path.GetFileNameWithoutExtension(saveWindow.FileName) + ".old")) { File.Copy(saveWindow.FileName, Path.GetDirectoryName(saveWindow.FileName) + "\\" + Path.GetFileNameWithoutExtension(saveWindow.FileName) + ".old"); } var saveBytes = activeSaveFile.SaveToPCSaveFile(); File.WriteAllBytes(saveWindow.FileName, saveBytes); var parsers = new List <INodeParser>(); parsers.AddRange(new INodeParser[] { new CharacterCustomizationAppearancesParser(), new InventoryParser(), new ItemDataParser(), new FactsDBParser(), new FactsTableParser(), new GameSessionConfigParser(), new ItemDropStorageManagerParser(), new ItemDropStorageParser(), new StatsSystemParser(), new ScriptableSystemsContainerParser() }); activeSaveFile = new SaveFileHelper(parsers); activeSaveFile.LoadPCSaveFile(new MemoryStream(saveBytes)); statusLabel.Text = "File saved."; } }
public void LoadItem(ItemData item, object _saveFile, Func <bool> callback1) { callbackFunc1 = callback1; activeItem = item; activeSaveFile = (SaveFileHelper)_saveFile; ReloadData(); this.ShowDialog(); }
private void saveChangesButton_Click(object sender, EventArgs e) { var saveWindow = new SaveFileDialog(); saveWindow.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Saved Games\\CD Projekt Red\\Cyberpunk 2077\\"; saveWindow.Filter = "Cyberpunk 2077 Save File|*.dat"; if (saveWindow.ShowDialog() == DialogResult.OK) { statusLabel.Text = "Saving changes..."; this.Refresh(); if (File.Exists(saveWindow.FileName) && !File.Exists(Path.GetDirectoryName(saveWindow.FileName) + "\\" + Path.GetFileNameWithoutExtension(saveWindow.FileName) + ".old")) { File.Copy(saveWindow.FileName, Path.GetDirectoryName(saveWindow.FileName) + "\\" + Path.GetFileNameWithoutExtension(saveWindow.FileName) + ".old"); } byte[] saveBytes; if (saveType == 0) { saveBytes = activeSaveFile.SaveToPCSaveFile(); } else { saveBytes = activeSaveFile.SaveToPS4SaveFile(); } var parsers = new List <INodeParser>(); parsers.AddRange(new INodeParser[] { new CharacterCustomizationAppearancesParser(), new InventoryParser(), new ItemDataParser(), new FactsDBParser(), new FactsTableParser(), new GameSessionConfigParser(), new ItemDropStorageManagerParser(), new ItemDropStorageParser(), new StatsSystemParser(), new ScriptableSystemsContainerParser() }); var testFile = new SaveFileHelper(parsers); try { if (saveType == 0) { testFile.LoadPCSaveFile(new MemoryStream(saveBytes)); } else { testFile.LoadPS4SaveFile(new MemoryStream(saveBytes)); } } catch (Exception ex) { statusLabel.Text = "Save cancelled."; File.WriteAllText("error.txt", ex.Message + '\n' + ex.TargetSite + '\n' + ex.StackTrace); MessageBox.Show("Corruption has been detected in the edited save file. No data has been written. Please report this issue on github.com/Deweh/CyberCAT-SimpleGUI with the generated error.txt file."); return; } File.WriteAllBytes(saveWindow.FileName, saveBytes); activeSaveFile = testFile; statusLabel.Text = "File saved."; } }
public void LoadNode(ItemData.ItemModData node, Func <bool> callback, object saveFileObj) { activeNode = node; callbackFunc = callback; activeSaveFile = (SaveFileHelper)saveFileObj; attachmentNameLabel.Text = node.AttachmentSlotTdbId.Name; attachmentIdBox.Text = node.AttachmentSlotTdbId.Raw64.ToString(); if (node.ItemTdbId.GameName.Length > 0) { item1NameLabel.Text = node.ItemTdbId.GameName; } else { item1NameLabel.Text = node.ItemTdbId.Name; } item1IdBox.Text = node.ItemTdbId.Raw64.ToString(); unknownIDBox.Text = node.TdbId2.Raw64.ToString(); unknown1Box.Text = node.Unknown2.ToString(); unknown2Box.Text = node.Unknown3.ToString(); unknown3Box.Text = node.Unknown4.ToString(); unknown4Box.Text = node.UnknownString; object resolvedStats = null; if (Form1.statsSystemEnabled) { resolvedStats = activeSaveFile.GetStatsFromSeed(node.Header.Seed); } if (resolvedStats != null) { resolvedItemLabel.Text = "View Details"; } else { resolvedItemLabel.Enabled = false; } this.Text = node.AttachmentSlotTdbId.Name + " :: " + node.ItemTdbId.Name; this.ShowDialog(); }
private void openSaveButton_Click(object sender, EventArgs e) { var fileWindow = new OpenFileDialog(); fileWindow.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Saved Games\\CD Projekt Red\\Cyberpunk 2077\\"; fileWindow.Filter = "Cyberpunk 2077 Save File|*.dat"; if (fileWindow.ShowDialog() == DialogResult.OK) { loadingSave = true; //Initialize NameResolver & FactResolver dictionaries, build parsers list & load save file NameResolver.UseDictionary(JsonConvert.DeserializeObject <Dictionary <ulong, NameResolver.NameStruct> >(CP2077SaveEditor.Properties.Resources.ItemNames)); FactResolver.UseDictionary(JsonConvert.DeserializeObject <Dictionary <ulong, string> >(CP2077SaveEditor.Properties.Resources.Facts)); var parsers = new List <INodeParser>(); parsers.AddRange(new INodeParser[] { new CharacterCustomizationAppearancesParser(), new InventoryParser(), new ItemDataParser(), new FactsDBParser(), new FactsTableParser(), new GameSessionConfigParser(), new ItemDropStorageManagerParser(), new ItemDropStorageParser(), new StatsSystemParser(), new ScriptableSystemsContainerParser() }); var newSave = new SaveFileHelper(parsers); newSave.LoadPCSaveFile(new MemoryStream(File.ReadAllBytes(fileWindow.FileName))); activeSaveFile = newSave; //Appearance parsing RefreshAppearanceValues(); //Inventory parsing moneyUpDown.Enabled = false; moneyUpDown.Value = 0; containersListBox.Items.Clear(); foreach (Inventory.SubInventory container in activeSaveFile.GetInventoriesContainer().SubInventories) { var containerID = container.InventoryId.ToString(); if (containerID == "1") { containerID = "Player Inventory"; } containersListBox.Items.Add(containerID); } if (containersListBox.Items.Count > 0) { containersListBox.SelectedIndex = 0; } //Facts parsing RefreshFacts(); //These lines may look redundant, but they initialize the factsListView so that the render thread doesn't freeze when selecting the Quest Facts tab for the first time. //Since the render thread will be frozen here anyways while everything loads, it's best to do this here. factsSaveButton.Visible = false; factsPanel.Visible = true; factsPanel.Visible = false; factsSaveButton.Visible = true; //Player stats parsing var profics = activeSaveFile.GetPlayerDevelopmentData().Value.Proficiencies; levelUpDown.Value = profics[Array.FindIndex(profics, x => x.Type == CyberCAT.Core.DumpedEnums.gamedataProficiencyType.Level)].CurrentLevel; streetCredUpDown.Value = profics[Array.FindIndex(profics, x => x.Type == CyberCAT.Core.DumpedEnums.gamedataProficiencyType.StreetCred)].CurrentLevel; var attrs = activeSaveFile.GetPlayerDevelopmentData().Value.Attributes; bodyUpDown.Value = attrs[Array.FindIndex(attrs, x => x.AttributeName == CyberCAT.Core.DumpedEnums.gamedataStatType.Strength)].Value; reflexesUpDown.Value = attrs[Array.FindIndex(attrs, x => x.AttributeName == CyberCAT.Core.DumpedEnums.gamedataStatType.Reflexes)].Value; technicalAbilityUpDown.Value = attrs[Array.FindIndex(attrs, x => x.AttributeName == CyberCAT.Core.DumpedEnums.gamedataStatType.TechnicalAbility)].Value; intelligenceUpDown.Value = attrs[Array.FindIndex(attrs, x => x.AttributeName == CyberCAT.Core.DumpedEnums.gamedataStatType.Intelligence)].Value; coolUpDown.Value = attrs[Array.FindIndex(attrs, x => x.AttributeName == CyberCAT.Core.DumpedEnums.gamedataStatType.Cool)].Value; if (activeSaveFile.GetPlayerDevelopmentData().Value.LifePath == CyberCAT.Core.DumpedEnums.gamedataLifePath.Nomad) { lifePathBox.SelectedIndex = 0; } else if (activeSaveFile.GetPlayerDevelopmentData().Value.LifePath == CyberCAT.Core.DumpedEnums.gamedataLifePath.StreetKid) { lifePathBox.SelectedIndex = 1; } else { lifePathBox.SelectedIndex = 2; } var points = activeSaveFile.GetPlayerDevelopmentData().Value.DevPoints; perkPointsUpDown.Value = points[Array.FindIndex(points, x => x.Type == CyberCAT.Core.DumpedEnums.gamedataDevelopmentPointType.Primary)].Unspent; attrPointsUpDown.Value = points[Array.FindIndex(points, x => x.Type == null)].Unspent; //Update controls loadingSave = false; editorPanel.Enabled = true; optionsPanel.Enabled = true; filePathLabel.Text = Path.GetFileName(Path.GetDirectoryName(fileWindow.FileName)); statusLabel.Text = "Save file loaded."; SwapTab(statsButton, statsPanel); } }
public AppearanceHelper(SaveFileHelper _saveFile) { activeSave = _saveFile; }