Esempio n. 1
0
        /// <summary>
        /// Runs the Compiler hopefully asynchronous
        /// </summary>
        public static void Run(string[] args)
        {
            if (args.Length == 0)
            {
                Logger.ConsoleError("No arguments specified!");
                //DisplayUsage(); //this one originally is here to show all the commands to compile/decompile. not needed anymore
                return;
            }



            library = LibraryLookup.GetLibrary(FilePaths.SelectedGamePath());

            // Set up log listener
            Listener.Subscribe(Logger);

            // Log arguments
            Logger.ConsoleTrace($"Arguments: {string.Join(" ", args)}");

            if (!TryParseArguments(args))
            {
                Logger.ConsoleError("Failed to parse arguments!");
                //DisplayUsage();
                return;
            }

            if (LogTrace)
            {
                Listener.Filter |= LogLevel.Trace;
            }


            bool success;

#if !DEBUG
            try
#endif
            {
                if (DoCompile)
                {
                    //if (MessageBox.Show("Do you want to Start game together with the mod?", "Start Game?", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                    //{
                    //    OutputFilePath = Path.Combine(FilePaths.modFolderPath, Path.GetFileNameWithoutExtension(InputFilePath) + ".bf");
                    //}
                    success = TryDoCompilation();
                }
                else if (DoDecompile)
                {
                    success = TryDoDecompilation();
                    //MessageBox.Show(OutputFilePath);
                }
                else if (DoDisassemble)
                {
                    success = TryDoDisassembling();
                }
                else
                {
                    ResetValues();
                    Array.Clear(args, 0, args.Length);
                    Logger.ConsoleError("No compilation, decompilation or disassemble instruction given!");
                    //DisplayUsage();
                    return;
                }
            }
#if !DEBUG
            catch (Exception e)
            {
                //LogException( "Unhandled exception thrown", e );
                success = false;

                if (Debugger.IsAttached)
                {
                    throw;
                }
            }
#endif

            if (success)
            {
                Logger.ConsoleInfo("Task completed successfully!");
                MessageBox.Show("Task completed sucessfully");
            }
            else
            {
                Logger.ConsoleError("One or more errors occured while executing task!");
            }

            ResetValues();
            Array.Clear(args, 0, args.Length);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
Esempio n. 2
0
        /// <summary>
        /// Sets uo the Auto complete option
        /// </summary>
        public void setUpAutoComplete()
        {
            //for the flow script (tbh i just copy pasted this one this is way more time efficent)
            string[] keywords            = { /*Added by me (FLOW script exclusive)*/ "import", /*This part was copy pasted*/ "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "add", "alias", "ascending", "descending", "dynamic", "from", "get", "global", "group", "into", "join", "let", "orderby", "partial", "remove", "select", "set", "value", "var", "where", "yield" };
            string[] methods             = { "Equals()", "GetHashCode()", "GetType()", "ToString()" };
            string[] snippets            = { "if(^)\n{\n;\n}", "if(^)\n{\n;\n}\nelse\n{\n;\n}", "for(^;;)\n{\n;\n}", "while(^)\n{\n;\n}", "do${\n^;\n}while();", "switch(^)\n{\ncase : break;\n}" };
            string[] declarationSnippets =
            {
                "public class ^\n{\n}",     "private class ^\n{\n}",     "internal class ^\n{\n}",
                "public struct ^\n{\n;\n}", "private struct ^\n{\n;\n}", "internal struct ^\n{\n;\n}",
                "public void ^()\n{\n;\n}", "private void ^()\n{\n;\n}", "internal void ^()\n{\n;\n}","protected void ^()\n{\n;\n}",
                "public ^{ get; set; }",    "private ^{ get; set; }",    "internal ^{ get; set; }",   "protected ^{ get; set; }"
            };
            //To add for MSG "scripts" can i call it a script? like is it one?? WTH IS IT IF ITS NOT A SCRIPT

            //if (FilePaths.LibraryPath == null)
            //{
            //    MessageBox.Show("[ERROR] Library Path is set to null");
            //    return;
            //}

            var functionNameList = new List <string>();

            game = FilePaths.SelectedGamePath();
            switch (game)
            {
            case "SMT Digital Devil Saga":
                game = "Digital Devil Saga";     //or dds
                break;

            case "SMT 3 Nocturne":
                game = "Shin Megami Tensei III: Nocturne";     // or smt3
                break;
            }
            var library = LibraryLookup.GetLibrary(game);

            if (library == null)
            {
                MessageBox.Show("[ERROR] Couldn't find library folder please make sure that it is inside of the .exe folder");
                return;
            }
            for (int i = 0; i < library.FlowScriptModules.Count; i++)
            {
                for (int j = 0; j < library.FlowScriptModules[i].Functions.Count; j++)
                {
                    functionNameList.Add(library.FlowScriptModules[i].Functions[j].Name);
                }
            }


            List <AutocompleteItem> items = new List <AutocompleteItem>();

            foreach (var item in functionNameList)
            {
                items.Add(new AutocompleteItem(item)
                {
                    ToolTipTitle = item, ToolTipText = ToolTip(item, library)
                });
            }
            foreach (var item in snippets)
            {
                items.Add(new SnippetAutocompleteItem(item)
                {
                    ImageIndex = 1
                });
            }
            foreach (var item in declarationSnippets)
            {
                items.Add(new DeclarationSnippet(item)
                {
                    ImageIndex = 0
                });
            }
            foreach (var item in methods)
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 2, ToolTipText = "WALUIGIIIIIIIIIIIIII"
                });
            }
            foreach (var item in keywords)
            {
                items.Add(new AutocompleteItem(item)
                {
                });
            }



            items.Add(new InsertSpaceSnippet());
            items.Add(new InsertSpaceSnippet(@"(\w+)([=<>!:]+)(\w+)$"));
            items.Add(new InsertEnterSnippet());

            popupMenu.Items.SetAutocompleteItems(items);
        }