// Creates a new instance of the Decoder object and loads the decompressed SC files. private void LoadSc(string fileName, string textureFile) { _scFile = new ScFile(fileName, textureFile); _scFile.Load(); //var scfile = ScFile.Load(fileName, ScFormatVersion.Version7); treeView1.Nodes.Clear(); pictureBox1.Image = null; label1.Text = null; saveToolStripMenuItem.Visible = true; reloadToolStripMenuItem.Visible = true; exportAllShapeToolStripMenuItem.Visible = true; exportAllChunkToolStripMenuItem.Visible = true; exportAllAnimationToolStripMenuItem.Visible = true; compressionToolStripMenuItem.Visible = true; addTextureToolStripMenuItem.Visible = true; RefreshMenu(); treeView1.Populate(_scFile.GetTextures()); treeView1.Populate(_scFile.GetExports()); treeView1.Populate(_scFile.GetShapes()); treeView1.Populate(_scFile.GetMovieClips()); }
public override void Load(ref ScFile file, Stream stream) { using (var reader = new BinaryReader(stream, Encoding.UTF8, true)) { var shapeCount = reader.ReadUInt16(); // a1 + 8 var movieClipCount = reader.ReadUInt16(); // a1 + 12 var textureCount = reader.ReadUInt16(); // a1 + 16 var textFieldCount = reader.ReadUInt16(); // a1 + 24 var matrixCount = reader.ReadUInt16(); // a1 + 28 var colorTransformCount = reader.ReadUInt16(); // a1 + 32 // 5 useless bytes, not even used by Supercell reader.ReadByte(); // 1 octet reader.ReadUInt16(); // 2 octets reader.ReadUInt16(); // 2 octets var exportCount = reader.ReadUInt16(); var exports = new List <Export>(exportCount); // Reading the exports Ids. for (int i = 0; i < exportCount; i++) { var export = new Export(file); var exportId = reader.ReadUInt16(); export._id = exportId; exports.Add(export); } // Reading the export names. for (int i = 0; i < exportCount; i++) { var export = exports[i]; var exportNameLen = reader.ReadByte(); var exportName = Encoding.UTF8.GetString(reader.ReadBytes(exportNameLen)); export._name = exportName; } do { var typeId = reader.ReadByte(); var length = reader.ReadInt32(); var bytes = reader.ReadBytes(length); if (typeId == 0) { break; } }while (true); } }
static void ProcessFile(string filePath) { var rootItem = new ScFile(); using (var reader = new StreamReader(filePath)) //using (var writer = new StreamWriter (filePath)) { //string text = reader.ReadLine(); var item = new ScBaseField(); var ready = false; while (!ready) { string text = reader.ReadLine(); switch (text) { case ItemHeader: break; case VersionHeader: rootItem.Fields.Add(item); item = new ScVersion(); break; case FieldHeader: rootItem.Fields.Add(item); item = new ScField(); break; case null: rootItem.Fields.Add(item); ready = true; break; default: item.Values.Add(text); break; } } } //var np = filePath.Replace(@"C:\temp\test\tds", @"C:\temp\test1\tds"); using (var writer = new StreamWriter(filePath)) { foreach (var field in rootItem.Fields) { writer.Write(field.GetText()); } } }
// Creates a new instance of the Decoder object and loads the decompressed SC files. private void LoadSc(string fileName, string textureFile) { _scFile = new ScFile(fileName, textureFile); _scFile.Load(); //var scfile = ScFile.Load(fileName, ScFormatVersion.Version7); treeView1.Nodes.Clear(); pictureBox1.Image = null; label1.Text = null; RefreshMenu(); treeView1.Populate(_scFile.GetExports()); treeView1.Populate(_scFile.GetShapes()); treeView1.Populate(_scFile.GetTextures()); treeView1.Populate(_scFile.GetMovieClips()); }
private void LZMACRToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult warning = MessageBox.Show( "After the SC file has been compressed, the tool will clear all previous data to prevent reading errors.\nContinue?", "Beware!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (warning == DialogResult.Yes) { using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.Filter = "Supercell Graphics (SC) | *.sc"; dlg.FileName = GetFileName(_scFile.GetInfoFileName()); dlg.OverwritePrompt = false; dlg.CreatePrompt = false; if (dlg.ShowDialog() == DialogResult.OK) { Lzma.CompressCR(_scFile.GetInfoFileName(), dlg.FileName); dlg.Title = "Please enter texture file location"; dlg.Filter = "Supercell Texture (SC) | *_tex.sc"; dlg.FileName = GetFileName(_scFile.GetTextureFileName()); if (dlg.ShowDialog() == DialogResult.OK) { Lzma.CompressCR(_scFile.GetTextureFileName(), dlg.FileName); } } } saveToolStripMenuItem.Visible = false; reloadToolStripMenuItem.Visible = false; exportAllShapeToolStripMenuItem.Visible = false; exportAllChunkToolStripMenuItem.Visible = false; exportAllAnimationToolStripMenuItem.Visible = false; compressionToolStripMenuItem.Visible = false; addTextureToolStripMenuItem.Visible = false; treeView1.Nodes.Clear(); pictureBox1.Image = null; label1.Text = null; _scFile = null; } }
public Export(ScFile scFile) : base(scFile) { // Space }