Пример #1
0
        private void ProcessMap(string filename)
        {
            Logger.Info("Processing map: " + filename);

            string outputfilename = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + "_altered" + Path.GetExtension(filename);

            if (cbOverwrite.Checked)
            {
                outputfilename = filename;
            }

            MapFileTool mapTool = new MapFileTool(filename, outputfilename, selectedConversionProfile.Filename, false);

            if (mapTool.Initialized)
            {
                mapTool.ConvertTileData();
                mapTool.ConvertOverlayData();
                mapTool.ConvertObjectData();
                mapTool.ConvertSectionData();
                mapTool.ConvertTheaterData();
                mapTool.Save();
            }

            WriteLogMessage("");
        }
Пример #2
0
        static void Main(string[] args)
        {
            options = new OptionSet
            {
                { "h|?|help", "Show help", v => settings.ShowHelp = true },
                { "i|infile=", "Input file.", v => settings.FileInput = v },
                { "o|outfile=", "Output file.", v => settings.FileOutput = v },
                { "l|list", "List theater data based on input theater config file.", v => settings.List = true },
                { "p|profilefile=", "Conversion profile file. This also enables the conversion logic.", v => settings.FileConfig = v },
                { "g|log", "If set, writes a log to a file in program directory.", v => settings.WriteLogFile = true },
                { "d|debug", "If set, shows debug-level logging in console window.", v => settings.ShowDebugLogging = true }
            };
            try
            {
                options.Parse(args);
            }
            catch (Exception e)
            {
                ConsoleColor defcolor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Encountered an error while parsing command-line arguments. Message: " + e.Message);
                Console.ForegroundColor = defcolor;
                ShowHelp();
                return;
            }
            InitLogger();

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
#endif
            bool error = false;

            if (settings.ShowHelp)
            {
                ShowHelp();
                return;
            }

            if (string.IsNullOrEmpty(settings.FileConfig) && !settings.List)
            {
                Logger.Error("Not enough arguments. Must provide either -l or -p.");
                ShowHelp();
                return;
            }
            else if (settings.List)
            {
                Logger.Info("Mode set (-l): List Tile Data.");
            }
            else
            {
                Logger.Info("Mode set (-p): Apply Conversion Profile.");
            }

            if (string.IsNullOrEmpty(settings.FileInput))
            {
                Logger.Error("No valid input file specified.");
                ShowHelp();
                error = true;
            }
            else if (!string.IsNullOrEmpty(settings.FileInput) && !File.Exists(settings.FileInput))
            {
                Logger.Error("Specified input file does not exist.");
                ShowHelp();
                error = true;
            }

            if (error)
            {
                return;
            }
            else
            {
                Logger.Info("Input file path OK.");
            }

            if (string.IsNullOrEmpty(settings.FileOutput))
            {
                Logger.Warn("No output file specified. Saving output to input file.");
                if (settings.List)
                {
                    settings.FileOutput = Path.ChangeExtension(settings.FileInput, ".txt");
                }
                else
                {
                    settings.FileOutput = settings.FileInput;
                }
            }
            else
            {
                Logger.Info("Output file path OK.");
            }

            MapFileTool mapTool = new MapFileTool(settings.FileInput, settings.FileOutput, settings.FileConfig, settings.List);

            if (mapTool.Initialized)
            {
                Logger.Info("MapTool initialized.");
            }
            else
            {
                Logger.Error("MapTool could not be initialized.");
                return;
            }

            if (settings.List)
            {
                mapTool.ListTileSetData();
                return;
            }
            else
            {
                mapTool.ConvertTileData();
                mapTool.ConvertOverlayData();
                mapTool.ConvertObjectData();
                mapTool.ConvertSectionData();
                mapTool.ConvertTheaterData();
            }

            mapTool.Save();
        }