private static void ConvertPictures(bool writeThumbnails) { Picture picture = new Picture(); picture.SetZoom(4, 2); XmlDocument doc = new XmlDocument(); XmlElement picturesNode = doc.CreateElement("pictures"); doc.AppendChild(picturesNode); for (int i = 0; i < 256; i++) { string id = "" + i; string fileName = Path.Combine(srcPath, "picture" + id + ".agp"); if (File.Exists(fileName)) { Console.WriteLine("Converting " + fileName); picture.Load(fileName, id); if (writeThumbnails) picture.SaveThumb(Path.Combine(dstPath, "thumb" + id + ".jpg"), 64, 34); picture.SavePriorityLayers(dstPath); XmlElement pictureNode = picture.GetGoaXml().DocumentElement; picturesNode.AppendChild(doc.ImportNode(pictureNode, true)); pictureCount++; } } if (pictureCount > 0) { Console.WriteLine("Saving pictures.xml file"); doc.Save(Path.Combine(dstPath, "pictures.xml")); } }
private static void ConvertPictures(bool writeThumbnails) { Picture picture = new Picture(); picture.SetZoom(4, 2); XmlDocument doc = new XmlDocument(); XmlElement picturesNode = doc.CreateElement("pictures"); doc.AppendChild(picturesNode); for (int i = 0; i < 256; i++) { string id = "" + i; string fileName = Path.Combine(srcPath, "picture" + id + ".agp"); if (File.Exists(fileName)) { Console.WriteLine("Converting " + fileName); picture.Load(fileName, id); if (writeThumbnails) { picture.SaveThumb(Path.Combine(dstPath, "thumb" + id + ".jpg"), 64, 34); } picture.SavePriorityLayers(dstPath); XmlElement pictureNode = picture.GetGoaXml().DocumentElement; picturesNode.AppendChild(doc.ImportNode(pictureNode, true)); pictureCount++; } } if (pictureCount > 0) { Console.WriteLine("Saving pictures.xml file"); doc.Save(Path.Combine(dstPath, "pictures.xml")); } }
static void Main(string[] args) { dir = new DirectoryInfo("."); string wordsFile = Path.Combine(dir.FullName, "words.xml"); if (File.Exists(wordsFile)) { words.Load(wordsFile); hasWordReplacements = true; } if (debug) { Picture picture = new Picture(); string fileName = Path.Combine(srcPath, "picture13.agp"); picture.Load(fileName, "13"); picture.SaveControlAsPng(Path.Combine(dstPath, "13.png")); string map = picture.GetJsxControlMap(); Picture jsxPic = new Picture(); jsxPic.InitValues(); int y = 0; int x = 0; int color = 4; int count = 0; for (int i=0; i<map.Length; i++) { char c = map[i]; int pos = Picture.JSX.IndexOf(c); switch (pos) { case (16 * 5 + 4): count += 160; break; case (16 * 5 + 3): count += 128; break; case (16 * 5 + 2): count += 64; break; case (16 * 5 + 1): count += 32; break; case (16 * 5 + 0): count += 16; break; default: double d = pos / 5; count += (int)Math.Floor(d); color = pos % 5; for (int run = x + count; x < run; x++) jsxPic.SetPixel(x, y, color); count = 0; if (x == 160) { x = 0; y += 1; } break; } } jsxPic.SavePictureAsPng(Path.Combine(dstPath, "jsx.png")); //ConvertPictures(true); //ConvertViews(); //OptimizeJs = false; //ConvertLogics(); //WriteJavascriptFile(); Console.WriteLine("Debug done."); } else { Console.WriteLine("AgiConvert - AGI source converter to web usuable format."); Console.WriteLine("Usage: agiconvert.exe [srcpath] [destinationpath] [GAMEID] [-p] [-v] [-l] [-j]"); Console.WriteLine(" where -p, -v, -l and -j enable pictures, views, logics and game.js file respectively."); Console.WriteLine(" Note that -j operator requires -p and -v operators to have created xml files already."); srcPath = dir.FullName; dstPath = dir.FullName; if (args.Length > 0) { srcPath = args[0]; if (!Directory.Exists(srcPath)) srcPath = Path.Combine(dir.FullName, args[0]); if (!Directory.Exists(srcPath)) { Console.WriteLine("Source path does not exist."); return; } } if (args.Length > 1) { dstPath = args[1]; if (!Directory.Exists(dstPath)) dstPath = Path.Combine(dir.FullName, args[1]); if (!Directory.Exists(dstPath)) { Console.WriteLine("Destination path does not exist."); return; } } if (args.Length > 2) { gameId = args[2]; if (gameId.StartsWith("-")) { Console.WriteLine("No GAMEID given, please specify an id like SQ, SQ2, PQ, LLLLL, ..."); return; } } StringCollection argCol = new StringCollection(); argCol.AddRange(args); bool convertPictures = argCol.Contains("-p"); bool convertViews = argCol.Contains("-v"); ; bool convertLogics = argCol.Contains("-l"); ; bool writeJavascript = argCol.Contains("-j"); ; bool writeThumbnails = argCol.Contains("-t"); ; OptimizeJs = argCol.Contains("-o"); if (writeThumbnails) convertPictures = true; if (convertPictures) ConvertPictures(writeThumbnails); if (convertViews) ConvertViews(); if (convertLogics) ConvertLogics(); if (writeJavascript) WriteJavascriptFile(); if (!convertPictures && !convertViews && !convertLogics && !writeJavascript) Console.WriteLine("Nothing to do! No command line actions (-p, -v -l or -j) were given."); } if (pictureCount > 0 || viewCount > 0 || logicCount > 0) Console.WriteLine(String.Format("Done converting {0} pictures, {1} views and {2} logics.", pictureCount, viewCount, logicCount)); if (debug) Console.ReadLine(); }
static void Main(string[] args) { dir = new DirectoryInfo("."); string wordsFile = Path.Combine(dir.FullName, "words.xml"); if (File.Exists(wordsFile)) { words.Load(wordsFile); hasWordReplacements = true; } if (debug) { Picture picture = new Picture(); string fileName = Path.Combine(srcPath, "picture13.agp"); picture.Load(fileName, "13"); picture.SaveControlAsPng(Path.Combine(dstPath, "13.png")); string map = picture.GetJsxControlMap(); Picture jsxPic = new Picture(); jsxPic.InitValues(); int y = 0; int x = 0; int color = 4; int count = 0; for (int i = 0; i < map.Length; i++) { char c = map[i]; int pos = Picture.JSX.IndexOf(c); switch (pos) { case (16 * 5 + 4): count += 160; break; case (16 * 5 + 3): count += 128; break; case (16 * 5 + 2): count += 64; break; case (16 * 5 + 1): count += 32; break; case (16 * 5 + 0): count += 16; break; default: double d = pos / 5; count += (int)Math.Floor(d); color = pos % 5; for (int run = x + count; x < run; x++) { jsxPic.SetPixel(x, y, color); } count = 0; if (x == 160) { x = 0; y += 1; } break; } } jsxPic.SavePictureAsPng(Path.Combine(dstPath, "jsx.png")); //ConvertPictures(true); //ConvertViews(); //OptimizeJs = false; //ConvertLogics(); //WriteJavascriptFile(); Console.WriteLine("Debug done."); } else { Console.WriteLine("AgiConvert - AGI source converter to web usuable format."); Console.WriteLine("Usage: agiconvert.exe [srcpath] [destinationpath] [GAMEID] [-p] [-v] [-l] [-j]"); Console.WriteLine(" where -p, -v, -l and -j enable pictures, views, logics and game.js file respectively."); Console.WriteLine(" Note that -j operator requires -p and -v operators to have created xml files already."); srcPath = dir.FullName; dstPath = dir.FullName; if (args.Length > 0) { srcPath = args[0]; if (!Directory.Exists(srcPath)) { srcPath = Path.Combine(dir.FullName, args[0]); } if (!Directory.Exists(srcPath)) { Console.WriteLine("Source path does not exist."); return; } } if (args.Length > 1) { dstPath = args[1]; if (!Directory.Exists(dstPath)) { dstPath = Path.Combine(dir.FullName, args[1]); } if (!Directory.Exists(dstPath)) { Console.WriteLine("Destination path does not exist."); return; } } if (args.Length > 2) { gameId = args[2]; if (gameId.StartsWith("-")) { Console.WriteLine("No GAMEID given, please specify an id like SQ, SQ2, PQ, LLLLL, ..."); return; } } StringCollection argCol = new StringCollection(); argCol.AddRange(args); bool convertPictures = argCol.Contains("-p"); bool convertViews = argCol.Contains("-v");; bool convertLogics = argCol.Contains("-l");; bool writeJavascript = argCol.Contains("-j");; bool writeThumbnails = argCol.Contains("-t");; OptimizeJs = argCol.Contains("-o"); if (writeThumbnails) { convertPictures = true; } if (convertPictures) { ConvertPictures(writeThumbnails); } if (convertViews) { ConvertViews(); } if (convertLogics) { ConvertLogics(); } if (writeJavascript) { WriteJavascriptFile(); } if (!convertPictures && !convertViews && !convertLogics && !writeJavascript) { Console.WriteLine("Nothing to do! No command line actions (-p, -v -l or -j) were given."); } } if (pictureCount > 0 || viewCount > 0 || logicCount > 0) { Console.WriteLine(String.Format("Done converting {0} pictures, {1} views and {2} logics.", pictureCount, viewCount, logicCount)); } if (debug) { Console.ReadLine(); } }