summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ConsoleApp/ConsoleApp.pidbbin0 -> 10847 bytes
-rw-r--r--ConsoleApp/Main.cs8
-rw-r--r--ConsoleApp/TextureCommands.cs49
3 files changed, 56 insertions, 1 deletions
diff --git a/ConsoleApp/ConsoleApp.pidb b/ConsoleApp/ConsoleApp.pidb
new file mode 100644
index 0000000..0683120
--- /dev/null
+++ b/ConsoleApp/ConsoleApp.pidb
Binary files differ
diff --git a/ConsoleApp/Main.cs b/ConsoleApp/Main.cs
index 9a180f6..56f2a8d 100644
--- a/ConsoleApp/Main.cs
+++ b/ConsoleApp/Main.cs
@@ -15,9 +15,16 @@ namespace ConsoleApp {
CommandLookup.Add("export-obj", new ExportObjCommand());
CommandLookup.Add("export-collada", new ExportColladaCommand());
CommandLookup.Add("export-textures", new ExportTexturesCommand());
+ CommandLookup.Add("replace-image", new ReplaceImageCommand());
}
public static void Main(string[] args) {
+ // Debugging BS
+ //args = new string[] { "list", "/home/me/Dropbox/NEWERsmbw/bigbrick/big_renga_block.brres" };
+ //System.IO.Directory.SetCurrentDirectory("/home/me/Games/Newer/CGround");
+ //args = new string[] { "export-collada", "regular.brres", "large.dae", "circle_ground_L" };
+
+
Console.WriteLine("NW4RTools by Treeki");
Console.WriteLine();
@@ -82,4 +89,3 @@ namespace ConsoleApp {
}
}
}
-
diff --git a/ConsoleApp/TextureCommands.cs b/ConsoleApp/TextureCommands.cs
index 3fad0c7..834b32e 100644
--- a/ConsoleApp/TextureCommands.cs
+++ b/ConsoleApp/TextureCommands.cs
@@ -71,5 +71,54 @@ namespace ConsoleApp {
+ " texture-names is a list of textures. if not specified, every texture is exported.";
}
}
+
+
+ public class ReplaceImageCommand : ResFileCommand {
+ public ReplaceImageCommand() : base("replace image used for a texture") {
+ }
+
+ protected override void OperateOnFile(string[] args) {
+ if (args.Length != 2) {
+ Console.WriteLine("invalid syntax.\n" + GetHelp(null));
+ return;
+ }
+
+ var texDict = TargetFile.GetTextureGroup();
+ if (texDict == null || texDict.Count == 0) {
+ Console.WriteLine("this file has no textures.");
+ return;
+ }
+
+ if (!texDict.ContainsKey(args[0])) {
+ Console.WriteLine("the specified texture [{0}] does not exist", args[0]);
+ return;
+ }
+
+ var texture = texDict[args[0]];
+ Console.WriteLine("texture {0}: {1} image(s)", args[0], texture.Images.Length);
+
+ System.Drawing.Bitmap bitmap;
+
+ try {
+ bitmap = new System.Drawing.Bitmap(args[1]);
+ } catch (Exception ex) {
+ Console.WriteLine("error reading image [{0}]:", args[1]);
+ Console.WriteLine(ex.ToString());
+ return;
+ }
+
+ texture.Images[0] = bitmap;
+ Console.WriteLine("replaced");
+
+ SaveFile();
+ }
+
+ public override string GetHelp(string[] args) {
+ return "syntax: replace-image <brres-filename> <texture-name> <image-filename>\n"
+ + " replaces the image used by a texture.\n\n"
+ + " texture-name is the affected texture.\n"
+ + " image-filename is the image to replace it with (preferably a PNG).";
+ }
+ }
}