List <UnisonRefs> type_ref_list;//they are used to universally reference a tag depending on the type of tagRef /// <summary> /// constructor to intialize stuff /// </summary> /// <param name="file"></param> /// <param name="type"></param> public Resyncer(string file, string type) { directory = DATA_READ.ReadDirectory_from_file_location(file); resync_type = type; XmlDocument xd = new XmlDocument(); xd.Load(file); compile_list = new List <injectRefs>(); scneario_list = new List <string>(); type_ref_list = new List <UnisonRefs>(); foreach (XmlNode Xn in xd.SelectNodes("config/tag")) { injectRefs temp = new injectRefs(); temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber); temp.new_datum = -1; temp.file_name = Xn.SelectSingleNode("name").InnerText; temp.type = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name); scneario_list.Add(Xn.SelectSingleNode("scenario").InnerText); //lets add the tag to the list compile_list.Add(temp); } sync(); }
public Rebase_meta(string file) { InitializeComponent(); XmlDocument xd = new XmlDocument(); xd.Load(file); compile_list = new List <injectRefs>(); directory = DATA_READ.ReadDirectory_from_file_location(file); int new_index = 0x3BA4;//new datum_indexes starting from 0x3BA4 foreach (XmlNode Xn in xd.SelectNodes("config/tag")) { injectRefs temp = new injectRefs(); temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber); temp.new_datum = new_index++; temp.file_name = Xn.SelectSingleNode("name").InnerText; temp.type = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name); //lets add the tag to the list compile_list.Add(temp); } }
List <UnisonRefs> type_ref_list;//they are used to universally reference a tag depending on the type of tagRef public Rebase_meta(string file) { InitializeComponent(); XmlDocument xd = new XmlDocument(); xd.Load(file); compile_list = new List <injectRefs>(); tag_scenarios = new List <string>(); type_ref_list = new List <UnisonRefs>(); directory = DATA_READ.ReadDirectory_from_file_location(file); int new_index = 0x3BA4;//new datum_indexes starting from 0x3BA4 foreach (XmlNode Xn in xd.SelectNodes("config/tag")) { injectRefs temp = new injectRefs(); temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber); temp.new_datum = new_index++; temp.file_name = Xn.SelectSingleNode("name").InnerText; temp.type = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name); tag_scenarios.Add(Xn.SelectSingleNode("scenario").InnerText); //lets add the tag to the list compile_list.Add(temp); } //now lets fill the unison List List <string> blacklisted_type = new List <string>(); foreach (injectRefs inj_temp in compile_list) { if (!blacklisted_type.Contains(inj_temp.type)) { bool any_occurence = false; for (int i = 0; i < type_ref_list.Count(); i++) { UnisonRefs uni_temp = type_ref_list[i]; if (uni_temp.type == inj_temp.type) { any_occurence = true; blacklisted_type.Add(inj_temp.type); type_ref_list.Remove(uni_temp); } } if (!any_occurence) { UnisonRefs my_temp_ref = new UnisonRefs(); my_temp_ref.type = inj_temp.type; my_temp_ref.new_datum = inj_temp.new_datum; my_temp_ref.file_name = inj_temp.file_name; type_ref_list.Add(my_temp_ref); } } } }
private void Extract_Click(object sender, EventArgs e) { string log = "\nEXTRACTION LOG : ";//or log string rel_path = SID_list[extraction_list[0].datum_index] + "." + extraction_list[0].type; XmlTextWriter xw = new XmlTextWriter(textBox1.Text + "\\" + DATA_READ.Read_File_from_file_location(rel_path) + ".xml", Encoding.UTF8); xw.Formatting = Formatting.Indented; xw.WriteStartElement("config"); if (textBox1.Text.Length > 0) { for (int i = 0; i < extraction_list.Count; i++) { tagRef temp_tagref = extraction_list[i]; int datum = temp_tagref.datum_index; string type = temp_tagref.type; if (datum != -1) { if (!extracted_list.Contains(datum)) { if (File.Exists(Application.StartupPath + "\\plugins\\" + type + ".xml")) { if (SID_list.ContainsKey(datum)) { meta obj = new meta(datum, SID_list[datum], map_stream); obj.Rebase_meta(0x0); if (checkBox1.Checked) { obj.Null_StringID(); } if (radioButton1.Checked == true) { //add recursivity extraction_list.AddRange(obj.Get_all_tag_refs()); } byte[] data = obj.Generate_meta_file(); string path = textBox1.Text + "\\" + obj.Get_Path() + "." + obj.Get_Type(); string directory = DATA_READ.ReadDirectory_from_file_location(path); //lets create our directory System.IO.Directory.CreateDirectory(directory); //create our file StreamWriter sw = new StreamWriter(path); sw.BaseStream.Write(data, 0, obj.Get_Total_size()); sw.Dispose(); //write to configuration xml xw.WriteStartElement("tag"); xw.WriteStartElement("name"); xw.WriteString(obj.Get_Path() + "." + type); //writing in the inner most level ie,name xw.WriteEndElement(); //name level xw.WriteStartElement("datum"); xw.WriteString(datum.ToString("X")); //writing in the inner most level ie here,datum xw.WriteEndElement(); //datum level xw.WriteEndElement(); //tag level //at least mention this in the logs log += "\nExtracted meta " + datum.ToString("X") + " to " + path; //add it to the extracted list extracted_list.Add(datum); } else { log += "\nCouldnot find stringID to datum_index " + datum.ToString("X"); } } else { log += "\nPlugin " + type + ".xml doesnt exist"; extracted_list.Add(datum); } } } } //close the config field and close the xml handle xw.WriteEndElement(); xw.Dispose(); //Log box LogBox lb = new LogBox(log); lb.Show(); //wprk is now done so lets close this stupid box this.Close(); } else { MessageBox.Show("At least Select the Directory", "Error"); } }
private void DumpShadersToolStripMenuItem_Click(object sender, EventArgs e) { { if (map_loaded) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.ShowNewFolderButton = true; MessageBox.Show("Select a directory to export the shader dump. Preferably an empty folder."); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string tags_directory = fbd.SelectedPath; StreamWriter log = new StreamWriter(tags_directory + '\\' + map_name.Substring(map_name.LastIndexOf('\\') + 1) + ".shader_log"); foreach (TreeNode element in treeView1.Nodes["shad"].Nodes) { int table_ref = Int32.Parse(element.Name); int datum = DATA_READ.ReadINT_LE(table_ref + 4, map_stream); int mem_off = DATA_READ.ReadINT_LE(table_ref + 8, map_stream); int size = DATA_READ.ReadINT_LE(table_ref + 0xc, map_stream); meta meta_obj = new meta(datum, SID_list[datum], map_stream); meta_obj.Rebase_meta(0x0); if (meta_obj.Get_Total_size() != 0) { byte[] meta_data = meta_obj.Generate_meta_file(); string text_path = tags_directory + '\\' + SID_list[datum] + ".txt"; //lets create our directory System.IO.Directory.CreateDirectory(DATA_READ.ReadDirectory_from_file_location(text_path)); StreamWriter sw = new StreamWriter(text_path); //supoosing each shad contains only one Post process block element int PPB_off = DATA_READ.ReadINT_LE(0x24, meta_data); int stem_datum = DATA_READ.ReadINT_LE(PPB_off, meta_data); int bitmap_count = DATA_READ.ReadINT_LE(PPB_off + 0x4, meta_data); int bitmapB_off = DATA_READ.ReadINT_LE(PPB_off + 0x8, meta_data); //write the stemp path string out_temp; if (stem_datum != 0 && stem_datum != -1) { if (SID_list.TryGetValue(stem_datum, out out_temp)) { sw.WriteLine(SID_list[stem_datum]); } else { sw.WriteLine("---"); } } for (int i = 0; i < bitmap_count; i++) { int bitm_datum = DATA_READ.ReadINT_LE(bitmapB_off + i * 0xC, meta_data); if (bitm_datum != 0 && bitm_datum != -1) { if (SID_list.TryGetValue(bitm_datum, out out_temp)) { if (SID_list[bitm_datum] == "") { sw.WriteLine(" "); } else { sw.WriteLine(SID_list[bitm_datum]); } } else { sw.WriteLine("---"); } } else { sw.WriteLine(" "); } } log.WriteLine(SID_list[datum] + ".txt"); sw.Close(); } else { log.WriteLine("---"); } } log.Close(); MessageBox.Show("Extraction Complete"); } } else { MessageBox.Show("Load a map first"); } } }