Пример #1
0
        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");
            }
        }
Пример #2
0
        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");
                }
            }
        }