private void ParserControl_DoParse <T>(ParserControl parserControl) where T : Segment, new() { parserControl.Enabled = false; parserControl.ParseInputProgress = 0; parserControl.WriteJSONOutputProgress = 0; if (!File.Exists(parserControl.SourceBin)) { MessageBox.Show("Source bin path does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); parserControl.Enabled = true; return; } if (!Directory.Exists(lblOutputFolder.Text)) { MessageBox.Show("Output folder does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); parserControl.Enabled = true; return; } ThreadPool.QueueUserWorkItem(o => { var data = File.ReadAllBytes(parserControl.SourceBin); // Parse the data using (var memoryStream = new MemoryStream(data)) using (var binaryReader = new BinaryReader(memoryStream)) { var outputFolder = lblOutputFolder.Text + "\\" + parserControl.Label + "\\" + "\\JSON\\"; var segment = new T(); parserControl.BeginInvoke((Action)(() => parserControl.ParseInputProgress = 1)); if (segment.Unpack(binaryReader)) { parserControl.BeginInvoke((Action)(() => parserControl.ParseInputProgress = 100)); // Write out the parsed data if (parserControl.WriteJSON) { parserControl.BeginInvoke((Action)(() => parserControl.WriteJSONOutputProgress = 1)); segment.WriteJSONOutput(outputFolder); parserControl.BeginInvoke((Action)(() => parserControl.WriteJSONOutputProgress = 100)); } } } parserControl.BeginInvoke((Action)(() => parserControl.Enabled = true)); }); }
private void ParserControl1_DoParse(ParserControl parserControl) { ParserControl_DoParse <RegionDescExtendedData>(parserControl); }
private void ParserControlB_DoParse(ParserControl parserControl) { ParserControl_DoParse <GameEventDefDB>(parserControl); }
private void ParserControl9_DoParse(ParserControl parserControl) { ParserControl_DoParse <WeenieDefaults>(parserControl); }
private void ParserControlA_DoParse(ParserControl parserControl) { ParserControl_DoParse <MutationFilters>(parserControl); }
private void ParserControl7_DoParse(ParserControl parserControl) { MessageBox.Show("Not implemented."); }
private void ParserControl8_DoParse(ParserControl parserControl) { ParserControl_DoParse <QuestDefDB>(parserControl); }
private void ParserControl6_DoParse(ParserControl parserControl) { ParserControl_DoParse <LandBlockData>(parserControl); }
private void ParserControl5_DoParse(ParserControl parserControl) { ParserControl_DoParse <HousingPortalsTable>(parserControl); }
private void ParserControl4_DoParse(ParserControl parserControl) { ParserControl_DoParse <CraftingTable>(parserControl); }
private void ParserControl3_DoParse(ParserControl parserControl) { ParserControl_DoParse <TreasureTable>(parserControl); }
private void ParserControl2_DoParse(ParserControl parserControl) { ParserControl_DoParse <SpellTableExtendedData>(parserControl); }