diff --git a/UndertaleModCli/CommandOptions.cs b/UndertaleModCli/CommandOptions.cs deleted file mode 100644 index 72f0ff55f..000000000 --- a/UndertaleModCli/CommandOptions.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -namespace UndertaleModCli -{ - //TODO: split these all up into individual files - - /// - /// Cli options for the New command - /// - public class NewOptions - { - /// - /// File path for new data file - /// - public FileInfo Output { get; set; } = new FileInfo("data.win"); - - /// - /// If the existing file path at should be overwritten - /// - public bool Overwrite { get; set; } = false; - - /// - /// Whether to write the new data to Stdout - /// - public bool Stdout { get; set; } - - /// - /// Determines if Cli should print out verbose logs - /// - public bool Verbose { get; set; } = false; - } - - /// - /// Cli options for the Load command - /// - public class LoadOptions - { - /// - /// File path to the data file - /// - public FileInfo Datafile { get; set; } - - /// - /// File paths to the scripts that shall be run - /// - public FileInfo[] Scripts { get; set; } - - /// - /// C# string that shall be executed - /// - public string? Line { get; set; } - - /// - /// File path to where to save the modified data file - /// - public FileInfo? Output { get; set; } - - /// - /// Determines if Cli should be run in interactive mode - /// - public bool Interactive { get; set; } = false; - - /// - /// Determines if Cli should print out verbose logs - /// - public bool Verbose { get; set; } = false; - } - - /// - /// Cli options for the Info command - /// - public class InfoOptions - { - /// - /// File path to the data file - /// - public FileInfo Datafile { get; set; } - - /// - /// Determines if Cli should print out verbose logs - /// - public bool Verbose { get; set; } = false; - } - - /// - /// Cli options for the Dump command - /// - public class DumpOptions - { - /// - /// File path to the data file - /// - public FileInfo Datafile { get; set; } - - /// - /// Directory path to where to dump all contents - /// - public DirectoryInfo? Output { get; set; } - - /// - /// Determines if Cli should print out verbose logs - /// - public bool Verbose { get; set; } = false; - - /// - /// Names of the code entries that should get dumped - /// - public string[] Code { get; set; } - - /// - /// Determines if strings should get dumped. - /// - public bool Strings { get; set; } - - /// - /// Determines if embedded textures should get dumped - /// - public bool Textures { get; set; } - } - - /// - /// Cli options for the Replace command - /// - public class ReplaceOptions - { - /// - /// File path to the data file - /// - public FileInfo Datafile { get; set; } - - /// - /// File path to where to save the modified data file - /// - public FileInfo? Output { get; set; } - - /// - /// Determines if Cli should print out verbose logs - /// - public bool Verbose { get; set; } = false; - - /// - /// Equal separated values of code entry and the file to replace the code entry with. - /// - public string[] Code { get; set; } - - /// - /// Equal separated values of embedded texture and the file to replace the embedded texture with. - /// - public string[] Textures { get; set; } - } -} \ No newline at end of file diff --git a/UndertaleModCli/CommandOptions/DumpOptions.cs b/UndertaleModCli/CommandOptions/DumpOptions.cs new file mode 100644 index 000000000..1388a5bdf --- /dev/null +++ b/UndertaleModCli/CommandOptions/DumpOptions.cs @@ -0,0 +1,40 @@ +using System.IO; + +namespace UndertaleModCli +{ + /// + /// Cli options for the Dump command + /// + public class DumpOptions + { + /// + /// File path to the data file + /// + public FileInfo Datafile { get; set; } + + /// + /// Directory path to where to dump all contents + /// + public DirectoryInfo? Output { get; set; } + + /// + /// Determines if Cli should print out verbose logs + /// + public bool Verbose { get; set; } = false; + + /// + /// Names of the code entries that should get dumped + /// + public string[] Code { get; set; } + + /// + /// Determines if strings should get dumped. + /// + public bool Strings { get; set; } + + /// + /// Determines if embedded textures should get dumped + /// + public bool Textures { get; set; } + } +} \ No newline at end of file diff --git a/UndertaleModCli/CommandOptions/InfoOptions.cs b/UndertaleModCli/CommandOptions/InfoOptions.cs new file mode 100644 index 000000000..c3c32ef7b --- /dev/null +++ b/UndertaleModCli/CommandOptions/InfoOptions.cs @@ -0,0 +1,20 @@ +using System.IO; + +namespace UndertaleModCli +{ + /// + /// Cli options for the Info command + /// + public class InfoOptions + { + /// + /// File path to the data file + /// + public FileInfo Datafile { get; set; } + + /// + /// Determines if Cli should print out verbose logs + /// + public bool Verbose { get; set; } = false; + } +} \ No newline at end of file diff --git a/UndertaleModCli/CommandOptions/LoadOptions.cs b/UndertaleModCli/CommandOptions/LoadOptions.cs new file mode 100644 index 000000000..4da06cbc5 --- /dev/null +++ b/UndertaleModCli/CommandOptions/LoadOptions.cs @@ -0,0 +1,40 @@ +using System.IO; + +namespace UndertaleModCli +{ + /// + /// Cli options for the Load command + /// + public class LoadOptions + { + /// + /// File path to the data file + /// + public FileInfo Datafile { get; set; } + + /// + /// File paths to the scripts that shall be run + /// + public FileInfo[] Scripts { get; set; } + + /// + /// C# string that shall be executed + /// + public string? Line { get; set; } + + /// + /// File path to where to save the modified data file + /// + public FileInfo? Output { get; set; } + + /// + /// Determines if Cli should be run in interactive mode + /// + public bool Interactive { get; set; } = false; + + /// + /// Determines if Cli should print out verbose logs + /// + public bool Verbose { get; set; } = false; + } +} \ No newline at end of file diff --git a/UndertaleModCli/CommandOptions/NewOptions.cs b/UndertaleModCli/CommandOptions/NewOptions.cs new file mode 100644 index 000000000..d4b1a3106 --- /dev/null +++ b/UndertaleModCli/CommandOptions/NewOptions.cs @@ -0,0 +1,30 @@ +using System.IO; + +namespace UndertaleModCli +{ + /// + /// Cli options for the New command + /// + public class NewOptions + { + /// + /// File path for new data file + /// + public FileInfo Output { get; set; } = new FileInfo("data.win"); + + /// + /// If the existing file path at should be overwritten + /// + public bool Overwrite { get; set; } = false; + + /// + /// Whether to write the new data to Stdout + /// + public bool Stdout { get; set; } + + /// + /// Determines if Cli should print out verbose logs + /// + public bool Verbose { get; set; } = false; + } +} \ No newline at end of file diff --git a/UndertaleModCli/CommandOptions/ReplaceOptions.cs b/UndertaleModCli/CommandOptions/ReplaceOptions.cs new file mode 100644 index 000000000..853619c67 --- /dev/null +++ b/UndertaleModCli/CommandOptions/ReplaceOptions.cs @@ -0,0 +1,35 @@ +using System.IO; + +namespace UndertaleModCli +{ + /// + /// Cli options for the Replace command + /// + public class ReplaceOptions + { + /// + /// File path to the data file + /// + public FileInfo Datafile { get; set; } + + /// + /// File path to where to save the modified data file + /// + public FileInfo? Output { get; set; } + + /// + /// Determines if Cli should print out verbose logs + /// + public bool Verbose { get; set; } = false; + + /// + /// Equal separated values of code entry and the file to replace the code entry with. + /// + public string[] Code { get; set; } + + /// + /// Equal separated values of embedded texture and the file to replace the embedded texture with. + /// + public string[] Textures { get; set; } + } +} \ No newline at end of file diff --git a/UndertaleModCli/Program.cs b/UndertaleModCli/Program.cs index df85c2716..e2deb1a94 100644 --- a/UndertaleModCli/Program.cs +++ b/UndertaleModCli/Program.cs @@ -338,7 +338,7 @@ private static int Dump(DumpOptions options) } // If user provided code to dump, dump code - if ((options.Code != null) && (options.Code.Length > 0) && (program.Data.Code.Count > 0)) + if ((options.Code?.Length > 0) && (program.Data.Code.Count > 0)) { // If user wanted to dump everything, do that, otherwise only dump what user provided string[] codeArray; @@ -381,7 +381,7 @@ private static int Replace(ReplaceOptions options) } // If user provided code to replace, replace them - if ((options.Code != null) && (options.Code.Length > 0) && (program.Data.Code.Count > 0)) + if ((options.Code?.Length > 0) && (program.Data.Code.Count > 0)) { // get the values and put them into a dictionary for ease of use Dictionary codeDict = new Dictionary(); @@ -414,7 +414,7 @@ private static int Replace(ReplaceOptions options) } // If user provided texture to replace, replace them - if ((options.Textures != null) && (options.Textures.Length > 0)) + if (options.Textures?.Length > 0) { // get the values and put them into a dictionary for ease of use Dictionary textureDict = new Dictionary(); @@ -579,7 +579,8 @@ private void CliQuickInfo() /// The code entry that should get dumped private void DumpCodeEntry(string codeEntry) { - UndertaleCode? code = Data.Code.FirstOrDefault(c => c.Name.Content == codeEntry); + UndertaleCode code = Data.Code.ByName(codeEntry); + if (code == null) { @@ -643,7 +644,7 @@ private void DumpAllTextures() /// File path which should replace the code entry. private void ReplaceCodeEntryWithFile(string codeEntry, FileInfo fileToReplace) { - UndertaleCode? code = Data.Code.FirstOrDefault(c => c.Name.Content == codeEntry); + UndertaleCode code = Data.Code.ByName(codeEntry); if (code == null) { @@ -664,7 +665,7 @@ private void ReplaceCodeEntryWithFile(string codeEntry, FileInfo fileToReplace) /// File path which should replace the embedded texture. private void ReplaceTextureWithFile(string textureEntry, FileInfo fileToReplace) { - UndertaleEmbeddedTexture? texture = Data.EmbeddedTextures.FirstOrDefault(t => t.Name.Content == textureEntry); + UndertaleEmbeddedTexture texture = Data.EmbeddedTextures.ByName(textureEntry); if (texture == null) {