Exemplo n.º 1
0
        private Texture GenerateMenuBackground()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            int       texWidth  = 128;
            int       texHeight = 128;
            FLRunner  runner    = new FLRunner(CLAPI.MainThread, "resources/kernel");
            FLProgram prog      = runner.Run("assets/filter/game/menubg.fl", texWidth, texHeight);
            //Interpreter i = new Interpreter(Clapi.MainThread, "assets/filter/game/menubg.fl", DataTypes.Uchar1,
            //    Clapi.CreateEmpty<byte>(Clapi.MainThread, texWidth * texHeight * 4, MemoryFlag.ReadWrite), texWidth,
            //    texHeight, 1, 4, "assets/kernel/", true);

            //do
            //{
            //    i.Step();
            //} while (!i.Terminated);

            Texture tex = TextureLoader.ParameterToTexture(texWidth, texHeight, "MenugBG");

            TextureLoader.Update(CLAPI.MainThread, tex, prog.GetActiveBuffer(false).Buffer);
            Logger.Log(DebugChannel.Log, "Time for Menu Background(ms): " + sw.ElapsedMilliseconds, 10);
            sw.Stop();
            prog.FreeResources();
            return(tex);
        }
Exemplo n.º 2
0
        public override void Unpack(string targetDir, string name, Stream stream, IProgressIndicator progressIndicator)
        {
            progressIndicator?.SetProgress($"[{UnpackerName}]Loading FL Program: {name}", 1, 3);
            SerializableFLProgram prog = FLSerializer.LoadProgram(stream, runner.InstructionSet);

            progressIndicator?.SetProgress($"[{UnpackerName}]Running FL Program: {name}", 2, 3);
            FLProgram p = runner.Run(prog, 512, 512, 1);

            string filePath = Path.Combine(
                targetDir,
                name.Replace("/", "\\").StartsWith("\\")
                                               ? name.Replace("/", "\\").Substring(1)
                                               : name.Replace("/", "\\")
                );

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            filePath = filePath.Remove(filePath.Length - 3, 3) + "png";

            progressIndicator?.SetProgress(
                $"[{UnpackerName}]Writing FL Program Output: {Path.GetFileNameWithoutExtension(name)}",
                3,
                3
                );
            Bitmap bmp = new Bitmap(512, 512);

            CLAPI.UpdateBitmap(runner.Instance, bmp, p.GetActiveBuffer(false).Buffer);
            bmp.Save(filePath);
            stream.Close();
            p.FreeResources();
            progressIndicator?.Dispose();
        }
Exemplo n.º 3
0
        public override void Unpack(string targetDir, string name, Stream stream, IProgressIndicator progressIndicator)
        {
            progressIndicator?.SetProgress($"[{UnpackerName}]Loading FL Program: {name}", 1, 3);
            FLProgram p = null;

            try
            {
                SerializableFLProgram prog = runner.Parser.Process(
                    new FLParserInput(
                        name,
                        new StreamReader(stream)
                        .ReadToEnd().Split('\n')
                        .Select(x => x.Trim()).ToArray(),
                        true
                        )
                    );

                progressIndicator?.SetProgress($"[{UnpackerName}]Running FL Program: {name}", 2, 3);


                p = runner.Build(prog);
                if (p.HasMain)
                {
                    runner.Run(p, 512, 512, 1);

                    string filePath = Path.Combine(
                        targetDir,
                        name.Replace("/", "\\").StartsWith("\\")
                                                       ? name.Replace("/", "\\").Substring(1)
                                                       : name.Replace("/", "\\")
                        );
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                    filePath = filePath.Remove(filePath.Length - 2, 2) + "png";

                    progressIndicator?.SetProgress(
                        $"[{UnpackerName}]Writing FL Program Output: {Path.GetFileNameWithoutExtension(name)}",
                        3,
                        3
                        );
                    Bitmap bmp = new Bitmap(512, 512);
                    CLAPI.UpdateBitmap(runner.Instance, bmp, p.GetActiveBuffer(false).Buffer);
                    bmp.Save(filePath);
                }
            }
            catch (Exception)
            {
            }

            stream.Close();
            p?.FreeResources();
            progressIndicator?.Dispose();
        }