private void moveDownSceneButton_Click(object sender, EventArgs e) { if (sceneListBox.SelectedIndex < (thisCutscene.sceneCount - 1)) { NewerScene sceneToMove = thisCutscene.scenes[sceneListBox.SelectedIndex]; thisCutscene.scenes.RemoveAt(sceneListBox.SelectedIndex); thisCutscene.scenes.Insert(sceneListBox.SelectedIndex + 1, sceneToMove); LoadScenes(sceneListBox.SelectedIndex + 1); } }
public void loadFile(string path, ref List <byte> rawdata) { sceneCount = new uint(); scenes = new List <NewerScene>(); rawdata = new List <byte>(); //Reads the Cutscene file, this little part was done by Lory some months ago for one of my older projects, i reused it for this tool as it works good. Thanks to him ! FileStream rawSave = File.Open(path, FileMode.Open); try { BinaryReader binReader = new BinaryReader(rawSave); byte b = binReader.ReadByte(); while (b != null) { rawdata.Add(b); b = binReader.ReadByte(); } binReader.Close(); } catch (EndOfStreamException e) { Console.WriteLine("reached end of stream"); rawSave.Close(); } //make it a string and an int for future things //make it a string and an int for future things char[] rawstring = Encoding.UTF8.GetString(rawdata.ToArray(), 0, rawdata.ToArray().Length).ToCharArray(); uint[] rawint = new uint[rawdata.ToArray().Length]; for (int i = 0; i < rawdata.ToArray().Length - 1; i++) { rawint[i] = Convert.ToUInt32(rawdata[i].ToString()); } //Checks the header if (rawstring[0] != 'N' || rawstring[1] != 'W' || rawstring[2] != 'c' || rawstring[3] != 's') { MessageBox.Show("Invalid CS File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { //Here the fun starts (or not) int currentOffset = 4; this.sceneCount = getNextInt32(ref currentOffset, rawdata); List <uint> sceneOffsets = new List <uint>(); for (int i = 0; i < this.sceneCount; i++) { sceneOffsets.Add(getNextInt32(ref currentOffset, rawdata)); } foreach (uint sceneOffset in sceneOffsets) { currentOffset = (int)sceneOffset; NewerScene thisScene = new NewerScene(); thisScene.filename = getNextString(getNextInt32(ref currentOffset, rawdata), rawdata); thisScene.widescreenFlag = rawdata[currentOffset++]; currentOffset += 3; thisScene.commandCount = getNextInt32(ref currentOffset, rawdata); for (int i = 0; i < thisScene.commandCount; i++) { NewerCommand thisCommand = new NewerCommand(); thisCommand.commandID = getNextInt32(ref currentOffset, rawdata); thisCommand.param1 = getNextInt32(ref currentOffset, rawdata); thisCommand.param2 = getNextInt32(ref currentOffset, rawdata); if (thisCommand.commandID > 1) { thisCommand.param3 = getNextInt32(ref currentOffset, rawdata); } thisScene.commands.Add(thisCommand); } this.scenes.Add(thisScene); } } }