public void LoadFileAt(string filePath) { dataGridView1.Visible = true; byteView1.Visible = false; try { currentSavingPath = filePath; SetUnsavedChanges(false); tableEditor = new TableHandler(dataGridView1, new AssetWriter(filePath, true, true, null, null), listView1) { mode = TableHandlerMode.HeaderList }; saveToolStripMenuItem.Enabled = true; saveAsToolStripMenuItem.Enabled = true; tableEditor.FillOutTree(); tableEditor.Load(); UAGPalette.RefreshTheme(this); int failedCategoryCount = 0; List <string> unknownTypes = new List <string>(); foreach (Category cat in tableEditor.asset.data.categories) { if (cat is RawCategory) { failedCategoryCount++; } if (cat is NormalCategory usNormal) { foreach (PropertyData dat in usNormal.Data) { if (dat is UnknownPropertyData && !string.IsNullOrEmpty(dat.Type) && !unknownTypes.Contains(dat.Type)) { unknownTypes.Add(dat.Type); } } } } if (failedCategoryCount > 0) { MessageBox.Show("Failed to parse " + failedCategoryCount + " categories!", "Uh oh!"); } if (unknownTypes.Count > 0) { MessageBox.Show("Encountered " + unknownTypes.Count + " unknown property types:\n" + string.Join(", ", unknownTypes), "Uh oh!"); } if (!tableEditor.asset.VerifyParsing()) { MessageBox.Show("Failed to verify parsing! You may not be able to load this file in-game if modified.", "Uh oh!"); } } catch (Exception ex) { currentSavingPath = ""; SetUnsavedChanges(false); tableEditor = null; saveToolStripMenuItem.Enabled = false; saveAsToolStripMenuItem.Enabled = false; listView1.Nodes.Clear(); dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); UAGPalette.RefreshTheme(this); switch (ex) { case IOException _: MessageBox.Show("Failed to open this file!", "Uh oh!"); break; case FormatException formatEx: MessageBox.Show("Failed to parse this file!\n" + formatEx.GetType() + ": " + formatEx.Message, "Uh oh!"); break; default: MessageBox.Show("Encountered an unknown error when trying to open this file!\n" + ex.GetType() + ": " + ex.Message, "Uh oh!"); break; } } }
private void Form1_Load(object sender, EventArgs e) { UAGPalette.RefreshTheme(this); }