Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Program.args = args;
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            ElementList.InitElements();
            VectorType.Instance.ResolveElements();
            Lobby.HeroSettingCollection.Init();
            Lobby.ModeSettingCollection.Init();

            if (!args.Contains("--langserver"))
            {
                Log.Write(LogLevel.Normal, "Overwatch Script To Workshop " + VERSION);
            }

            Log.LogLevel = LogLevel.Normal;
            if (args.Contains("-verbose"))
            {
                Log.LogLevel = LogLevel.Verbose;
            }
            if (args.Contains("-quiet"))
            {
                Log.LogLevel = LogLevel.Quiet;
            }

            if (args.Contains("--langserver"))
            {
                Log.LogLevel = LogLevel.Quiet;
                DeltintegerLanguageServer.Run();
            }
            else if (args.Contains("--generatealphabet"))
            {
                Console.Write("Output folder: ");
                string folder = Console.ReadLine();
                Deltin.Deltinteger.Models.Letter.Generate(folder);
            }
            else if (args.Contains("--editor"))
            {
                string pathfindEditorScript = Extras.CombinePathWithDotNotation(null, "!PathfindEditor.del");

                if (!File.Exists(pathfindEditorScript))
                {
                    Log.Write(LogLevel.Normal, "The PathfindEditor.del module is missing!");
                }
                else
                {
                    Script(pathfindEditorScript);
                }
            }
            else if (args.ElementAtOrDefault(0) == "--i18n")
            {
                I18n.GenerateI18n.Generate(args);
            }
            else if (args.ElementAtOrDefault(0) == "--i18nlink")
            {
                I18n.GenerateI18n.GenerateKeyLink();
            }
            else if (args.ElementAtOrDefault(0) == "--wiki")
            {
                var wiki = WorkshopWiki.Wiki.GetWiki();
                if (wiki != null)
                {
                    Console.Write("Output file: ");
                    string outputPath = Console.ReadLine();
                    wiki.ToXML(outputPath);
                }
            }
            else if (args.ElementAtOrDefault(0) == "--schema")
            {
                Deltin.Deltinteger.Lobby.Ruleset.GenerateSchema();
            }
            else if (args.ElementAtOrDefault(0) == "--maps")
            {
                Deltin.Deltinteger.Lobby.LobbyMap.GetMaps(args[1], args[2], args[3]);
            }
            else if (args.ElementAtOrDefault(0) == "--function-table")
            {
                NameTable.MakeNameTable();
            }
            else
            {
                string script = args.ElementAtOrDefault(0);

                if (script != null && File.Exists(script))
                {
                    #if DEBUG == false
                    try
                    {
                    #endif

                    string ext = Path.GetExtension(script).ToLower();
                    if (ext == ".csv")
                    {
                        PathMap map = PathMap.ImportFromCSVFile(script, new ConsolePathmapErrorHandler(new Log("Pathmap")));
                        if (map != null)
                        {
                            string result = map.ExportAsXML();
                            string output = Path.ChangeExtension(script, "pathmap");
                            using (FileStream fs = File.Create(output))
                            {
                                Byte[] info = Encoding.Unicode.GetBytes(result);
                                fs.Write(info, 0, info.Length);
                            }
                            Log.Write(LogLevel.Normal, "Created pathmap file at '" + output + "'.");
                        }
                    }
                    else if (ext == ".pathmap")
                    {
                        Editor.FromPathmapFile(script);
                    }
                    else
                    {
                        Script(script);
                    }

                    #if DEBUG == false
                }
                catch (Exception ex)
                {
                    Log.Write(LogLevel.Normal, "Internal exception.");
                    Log.Write(LogLevel.Normal, ex.ToString());
                }
                    #endif
                }
                else
                {
                    Log.Write(LogLevel.Normal, $"Could not find the file '{script}'.");
                    Log.Write(LogLevel.Normal, $"Drag and drop a script over the executable to parse.");
                }
            }

            Finished();
        }