Esempio n. 1
0
        public void TryCompile_DialogWindow_ShouldReturnTrue()
        {
            string input =
                $"[dlg {GenerateTestIdentifier()} {GenerateTestIdentifier()}][f 0 5 0xFFFF][f 3 77 0xffff][f 222 222 -1][x 8223 39755]jasdhjdhquyqwy2893y38973290188290804759856273y3dhjakbdnbx zx dkjaughwuidhkadjiyquwd9u892y3gahsdkjqbwhgua../,/.,.,/..,/.,';;';';';';!!!!!=-=-=-=\\\\  \n\\!@##@#$%^&***()_+:[e][e]-80253895639258310-11239057825257389";

            var compiler = new MessageScriptCompiler(FormatVersion.Version1BigEndian);

            Assert.IsTrue(compiler.TryCompile(input, out var script));
        }
Esempio n. 2
0
        /// <summary>
        /// Compiles the Message script returns true if it is compiled succesfully
        /// </summary>
        private static bool TryDoMessageScriptCompilation()
        {
            // Compile source
            Logger.ConsoleInfo("Compiling MessageScript...");

            var version = GetMessageScriptFormatVersion();

            if (version == AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Detect)
            {
                Logger.ConsoleError("Invalid MessageScript file format");
                return(false);
            }

            var compiler = new MessageScriptCompiler(GetMessageScriptFormatVersion(), MessageScriptEncoding);

            compiler.AddListener(Listener);

            if (LibraryName != null)
            {
                var library = LibraryLookup.GetLibrary(LibraryName);

                if (library == null)
                {
                    Logger.ConsoleError("Invalid library name specified");
                    return(false);
                }

                compiler.Library = library;
            }

            bool          success = false;
            MessageScript script  = null;

            try
            {
                success = compiler.TryCompile(File.OpenText(InputFilePath), out script);
            }
            catch (UnsupportedCharacterException e)
            {
                Logger.ConsoleError($"Character '{e.Character}' not supported by encoding '{e.EncodingName}'");
            }

            if (!success)
            {
                Logger.ConsoleError("One or more errors occured during compilation!");
                return(false);
            }

            // Write binary
            Logger.ConsoleInfo("Writing binary to file...");
            if (!TryPerformAction("An error occured while saving the file.", () => script.ToFile(OutputFilePath)))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        private static bool TryDoMessageScriptCompilation()
        {
            // Compile source
            Logger.Info("Compiling MessageScript...");

            var version = GetMessageScriptFormatVersion();

            if (version == AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Detect)
            {
                Logger.Error("Invalid MessageScript file format");
                return(false);
            }

            var encoding = GetEncoding();
            var compiler = new MessageScriptCompiler(GetMessageScriptFormatVersion(), encoding);

            compiler.AddListener(Listener);

            if (LibraryName != null)
            {
                var library = LibraryLookup.GetLibrary(LibraryName);

                if (library == null)
                {
                    Logger.Error("Invalid library name specified");
                    return(false);
                }

                compiler.Library = library;
            }

            if (!compiler.TryCompile(File.OpenText(InputFilePath), out var script))
            {
                Logger.Error("One or more errors occured during compilation!");
                return(false);
            }

            // Write binary
            Logger.Info("Writing binary to file...");
            if (!TryPerformAction("An error occured while saving the file.", () => script.ToFile(OutputFilePath)))
            {
                return(false);
            }

            return(true);
        }