public void LoadCommands(int selectedIndex) { if (doneRewritingScene) { doneLoadingSceneParams = false; commandListBox.Items.Clear(); commandGroupBox.Text = "Commands - Scene " + (sceneListBox.SelectedIndex + 1); for (int i = 0; i < thisCutscene.scenes[sceneListBox.SelectedIndex].commandCount; i++) { NewerCommand currentCommand = thisCutscene.scenes[sceneListBox.SelectedIndex].commands[i]; string[] commandName = { "Play SFX " + currentCommand.param2 + " after " + currentCommand.param1 + " frames", "Play Looping Sound " + currentCommand.param3 + " after " + currentCommand.param2 + " frames on handle " + currentCommand.param1, "Stop Looping Sound after " + currentCommand.param2 + " frames on handle " + currentCommand.param1 + ", fading for " + currentCommand.param3 + " frames" }; commandListBox.Items.Add(commandName[currentCommand.commandID - 1]); } widescreenCheckBox.Checked = Convert.ToBoolean(thisCutscene.scenes[sceneListBox.SelectedIndex].widescreenFlag); filenameTextBox.Text = thisCutscene.scenes[sceneListBox.SelectedIndex].filename; commandListBox.SelectedIndex = ((thisCutscene.scenes[sceneListBox.SelectedIndex].commandCount == 0) ? -1 : selectedIndex); doneLoadingSceneParams = true; } }
private void moveDownCommandButton_Click(object sender, EventArgs e) { if (commandListBox.SelectedIndex < ((int)thisCutscene.scenes[sceneListBox.SelectedIndex].commandCount - 1)) { NewerCommand commandToMove = thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex]; thisCutscene.scenes[sceneListBox.SelectedIndex].commands.RemoveAt(commandListBox.SelectedIndex); thisCutscene.scenes[sceneListBox.SelectedIndex].commands.Insert(commandListBox.SelectedIndex + 1, commandToMove); LoadCommands(commandListBox.SelectedIndex + 1); } }
private void addCommandButton_Click(object sender, EventArgs e) { AddCommand a = new AddCommand(); DialogResult dialogresult = a.ShowDialog(); if (dialogresult == DialogResult.OK) { a.Close(); NewerCommand newCommand = new NewerCommand(); newCommand.commandID = a.commandID; thisCutscene.scenes[sceneListBox.SelectedIndex].commands.Add(newCommand); thisCutscene.scenes[sceneListBox.SelectedIndex].commandCount++; LoadCommands((int)thisCutscene.scenes[sceneListBox.SelectedIndex].commandCount - 1); } }
public void LoadParams() { if (doneRewritingCommand) { doneLoadingParams = false; NewerCommand currentCommand = thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex]; param1NumUpDown.Value = currentCommand.param1; param2NumUpDown.Value = currentCommand.param2; param2NumUpDown.Visible = Convert.ToBoolean(currentCommand.commandID != 1); param3NumUpDown.Value = ((currentCommand.commandID == 1) ? currentCommand.param2 : currentCommand.param3); param1Label.Text = (currentCommand.commandID > 1) ? "Handle ID:" : "Delay:"; param2Label.Text = (currentCommand.commandID > 1) ? "Delay:" : ""; param3Label.Text = (currentCommand.commandID < 3) ? "Sound ID:" : "Fade Frame Count:"; doneLoadingParams = true; } }
private void paramNumUpDown_ValueChanged(object sender, EventArgs e) { if (doneLoadingParams) { doneRewritingCommand = false; NewerCommand currentCommand = thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex]; thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex].param1 = (uint)param1NumUpDown.Value; thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex].param2 = (currentCommand.commandID == 1) ? (uint)param3NumUpDown.Value : (uint)param2NumUpDown.Value; thisCutscene.scenes[sceneListBox.SelectedIndex].commands[commandListBox.SelectedIndex].param3 = (uint)param3NumUpDown.Value; string[] commandName = { "Play SFX " + currentCommand.param2 + " after " + currentCommand.param1 + " frames", "Play Looping Sound " + currentCommand.param3 + " after " + currentCommand.param2 + " frames on handle " + currentCommand.param1, "Stop Looping Sound after " + currentCommand.param2 + " frames on handle " + currentCommand.param1 + ", fading for " + currentCommand.param3 + " frames" }; commandListBox.Items[commandListBox.SelectedIndex] = commandName[currentCommand.commandID - 1]; doneRewritingCommand = true; } }
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); } } }