/* * public void WriteInputs() { * using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { * for (int i = 0; i < inputs.Count; i++) { * InputRecord record = inputs[i]; * byte[] data = Encoding.ASCII.GetBytes(record.ToString() + "\r\n"); * fs.Write(data, 0, data.Length); * } * fs.Close(); * } * } */ public bool ReadFile(string filePath = "Celeste.tas", int startLine = 0, int endLine = int.MaxValue, int studioLine = 0) { try { if (filePath == "Celeste.tas" && startLine == 0) { inputs.Clear(); fastForwards.Clear(); if (!File.Exists(filePath)) { return(false); } } int subLine = 0; using (StreamReader sr = new StreamReader(filePath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (filePath == "Celeste.tas") { studioLine++; } subLine++; if (subLine < startLine) { continue; } if (subLine > endLine) { break; } if (InputCommands.TryExecuteCommand(this, line, studioLine)) { return(true); } InputRecord input = new InputRecord(studioLine, line); if (input.FastForward) { fastForwards.Add(input); if (inputs.Count > 0) { inputs[inputs.Count - 1].ForceBreak = input.ForceBreak; inputs[inputs.Count - 1].FastForward = true; } } else if (input.Frames != 0) { inputs.Add(input); } } } return(true); } catch { return(false); } }
public static void ExecuteCommand(string[] command) { string[] args = InputCommands.TrimArray(command, 1); string commandID = command[0].ToLower(); if (commandID == "load" || commandID == "hard" || commandID == "rmx2") { LoadCommand(commandID, args); } else { Engine.Commands.ExecuteCommand(commandID, args); } }