コード例 #1
0
ファイル: ButtonClick.cs プロジェクト: 0000duck/brawltools
        private void RenderToGIF(Image[] images)
        {
            string outPath = "";

Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                    {
                        Directory.CreateDirectory(outPath);
                    }

                    DirectoryInfo dir   = new DirectoryInfo(outPath);
                    FileInfo[]    files = dir.GetFiles();
                    int           i     = 0;
                    string        name  = "BrawlboxAnimation";
Top:
                    foreach (FileInfo f in files)
                    {
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
            {
                InterpolationEditor.Enabled = true;
            }
            ModelPanel.Enabled = true;
            Enabled            = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
コード例 #2
0
        public void RenderToGIF(Image[] images)
        {
            string outPath = "";
            Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                        Directory.CreateDirectory(outPath);

                    DirectoryInfo dir = new DirectoryInfo(outPath);
                    FileInfo[] files = dir.GetFiles();
                    int i = 0;
                    string name = "Animation";
                Top:
                    foreach (FileInfo f in files)
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();
            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                        break;

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
                InterpolationEditor.Enabled = true;
            ModelPanel.Enabled = true;
            Enabled = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
コード例 #3
0
        public void copyIconsToSelcharacter2()
        {
            string fileToSaveTo = null;

            ResourceNode s2 = null;
            if (common5 != null) {
                s2 = common5.FindChild("sc_selcharacter2_en", false);
            } else if (sc_selmap != null) {
                if (File.Exists("../../menu2/sc_selcharacter2.pac")) {
                    fileToSaveTo = "../../menu2/sc_selcharacter2.pac";
                    s2 = TempFiles.MakeTempNode(fileToSaveTo);
                } else if (File.Exists("../../menu2/sc_selcharacter2_en.pac")) {
                    fileToSaveTo = "../../menu2/sc_selcharacter2_en.pac";
                    s2 = TempFiles.MakeTempNode(fileToSaveTo);
                }
            }

            if (s2 == null) return;

            ResourceNode md0 = s2.FindChild("MenuRule_en/ModelData[0]", false);
            MSBinNode md1 = s2.FindChild("MenuRule_en/MiscData[1]", false) as MSBinNode;
            ResourceNode md80 = sc_selmap.FindChild("MiscData[80]", false);
            if (md0 == null || md80 == null) return;

            Image[] icons = new Image[41];
            Image[] frontstnames = new Image[41];
            for (int i = 1; i < 60; i++) {
                if (i == 32) i = 50;
                int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i);
                string nameSelmap = BestSSS[sssPos].Item2.ToString("D2");
                icons[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node).GetImage(0));
                frontstnames[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapFrontStname." + nameSelmap, false) as TEX0Node).GetImage(0));
            }

            var d = new RandomSelectEditNamesDialog(md1._strings, icons, frontstnames);
            d.Message = "When finished, press OK to continue.";
            if (d.ShowDialog() == DialogResult.OK) {
                for (int i = 0; i < md1._strings.Count; i++) {
                    md1._strings[i] = d[i].ToString();
                }
            } else {
                return;
            }

            using (ProgressWindow w = new ProgressWindow() { CanCancel = false }) {
                w.Begin(0, 60, 0);
                for (int i = 1; i < 60; i++) {
                    if (i == 32) i = 50;

                    int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i);
                    string tempFile1 = TempFiles.Create(".tex0");
                    string tempFile2 = TempFiles.Create(".plt0");
                    string nameSelcharacter2 = i.ToString("D2");
                    string nameSelmap = BestSSS[sssPos].Item2.ToString("D2");
                    TEX0Node iconFrom = md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node;
                    TEX0Node iconTo = md0.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelcharacter2, false) as TEX0Node;
                    var palFrom = md80.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelmap, false);
                    var palTo = md0.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelcharacter2, false);
                    if (iconFrom != null && iconTo != null && palFrom != null && palTo != null) {
                        iconFrom.Export(tempFile1);
                        iconTo.Replace(tempFile1);
                        palFrom.Export(tempFile2);
                        palTo.Replace(tempFile2);
                    }

                    TEX0Node prevbase = md80.FindChild("Textures(NW4R)/MenSelmapPrevbase." + nameSelmap, false) as TEX0Node;
                    TEX0Node stageswitch = md0.FindChild("Textures(NW4R)/MenStageSwitch." + nameSelcharacter2, false) as TEX0Node;
                    if (prevbase != null && stageswitch != null) {
                        Bitmap thumbnail = new Bitmap(112, 56);
                        using (Graphics g = Graphics.FromImage(thumbnail)) {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                            g.DrawImage(prevbase.GetImage(0), 0, -28, 112, 112);
                        }
                        stageswitch.Replace(thumbnail);
                    }

                    w.Update(i);
                }
            }

            if (fileToSaveTo != null) {
                s2.Export(fileToSaveTo);
            }
        }
コード例 #4
0
ファイル: Misc.cs プロジェクト: BrawlCrate/BrawlCrateNext
        private void RenderToGIF(List <Image> images, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            string outPath = "";

            try
            {
                outPath = path;
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }

                DirectoryInfo dir   = new DirectoryInfo(outPath);
                FileInfo[]    files = dir.GetFiles();
                int           i     = 0;
                string        name  = "Animation";
Top:
                foreach (FileInfo f in files)
                {
                    if (f.Name == name + i + ".gif")
                    {
                        i++;
                        goto Top;
                    }
                }

                outPath += "\\" + name + i + ".gif";
            }
            catch
            {
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)PlaybackPanel.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(10);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Count, 0);
                for (int i = 0, count = images.Count; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    //GIF transparency support is pretty poor, flickers a lot
                    //e.SetTransparent(ModelPanel.CurrentViewport.BackgroundColor);

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }

                progress.Finish();
                e.Finish();
            }

            if (MessageBox.Show(this,
                                "Animated GIF successfully saved to \"" + outPath.Replace("\\", "/") + "\".\nOpen the folder now?",
                                "GIF saved", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Process.Start("explorer.exe", path);
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: liddictm/BrawlManagers
        private void exportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FolderDialog.ShowDialog() != DialogResult.OK) {
                return;
            }

            string outdir = FolderDialog.SelectedPath;
            if (Directory.Exists(outdir) && Directory.EnumerateFileSystemEntries(outdir).Any()) {
                var dr = MessageBox.Show("Is it OK to delete everything in " + outdir + "?", "", MessageBoxButtons.OKCancel);
                if (dr != DialogResult.OK) {
                    return;
                }
                Directory.Delete(outdir, true);
            }
            using (ProgressWindow progress = new ProgressWindow((Control)null, "Exporting...", "", true)) {
                progress.Begin(0, listBox1.Items.Count, 0);
                Directory.CreateDirectory(outdir);
                int i = 0;
                foreach (FileInfo f in listBox1.Items) {
                    if (progress.Cancelled) {
                        break;
                    }
                    progress.Update(++i);
                    string thisdir = outdir + "\\" + f.Name.Substring(0, f.Name.LastIndexOf('.'));
                    Directory.CreateDirectory(thisdir);
                    exportStage(f, thisdir);
                }
            }
        }