示例#1
0
        // Shenanigans
        public static string RetroSystemAbsolutePath(this PathEntryCollection collection, IGameInfo game)
        {
            var name = game.FilesystemSafeName();

            name = Path.GetDirectoryName(name);
            if (string.IsNullOrEmpty(name))
            {
                name = game.FilesystemSafeName();
            }

            var pathEntry = collection[game.System, "System"]
                            ?? collection[game.System, "Base"];

            return(Path.Combine(collection.AbsolutePathFor(pathEntry.Path, game.System), name));
        }
示例#2
0
        public static void SaveAsFile(this Bitmap bitmap, IGameInfo game, string suffix, string systemId, PathEntryCollection paths, IWin32Window owner)
        {
            using var sfd = new SaveFileDialog
                  {
                      FileName         = $"{game.FilesystemSafeName()}-{suffix}",
                      InitialDirectory = paths.ScreenshotAbsolutePathFor(systemId),
                      Filter           = FilesystemFilterSet.Screenshots.ToString(),
                      RestoreDirectory = true
                  };

            var result = sfd.ShowHawkDialog(owner);

            if (result != DialogResult.OK)
            {
                return;
            }

            var         file = new FileInfo(sfd.FileName);
            ImageFormat i;
            string      extension = file.Extension.ToUpper();

            switch (extension)
            {
            default:
            case ".PNG":
                i = ImageFormat.Png;
                break;

            case ".BMP":
                i = ImageFormat.Bmp;
                break;
            }

            bitmap.Save(file.FullName, i);
        }
示例#3
0
        public static void SaveAsFile(this Bitmap bitmap, IGameInfo game, string suffix, string systemId, PathEntryCollection paths, IDialogParent parent)
        {
            using var sfd = new SaveFileDialog
                  {
                      FileName         = $"{game.FilesystemSafeName()}-{suffix}",
                      InitialDirectory = paths.ScreenshotAbsolutePathFor(systemId),
                      Filter           = FilesystemFilterSet.Screenshots.ToString(),
                      RestoreDirectory = true
                  };

            if (parent.ShowDialogWithTempMute(sfd) != DialogResult.OK)
            {
                return;
            }

            var         file      = new FileInfo(sfd.FileName);
            string      extension = file.Extension.ToUpper();
            ImageFormat i         = extension switch
            {
                ".BMP" => ImageFormat.Bmp,
                _ => ImageFormat.Png,
            };

            bitmap.Save(file.FullName, i);
        }
示例#4
0
        // Shenanigans
        public static string RetroSaveRamAbsolutePath(this PathEntryCollection collection, IGameInfo game)
        {
            var name = game.FilesystemSafeName();

            name = Path.GetDirectoryName(name);
            if (name == "")
            {
                name = game.FilesystemSafeName();
            }

            name ??= "";

            var pathEntry = collection[game.System, "Save RAM"]
                            ?? collection[game.System, "Base"];

            return(Path.Combine(collection.AbsolutePathFor(pathEntry.Path, game.System), name));
        }
示例#5
0
        public void Run()
        {
            var ofd = new OpenFileDialog
            {
                FileName         = $"{_game.FilesystemSafeName()}.syncless.txt",
                InitialDirectory = _avAbsolutePath
            };

            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            _mSynclessConfigFile = ofd.FileName;

            //---- this is pretty crappy:
            var lines = File.ReadAllLines(_mSynclessConfigFile);

            string framesDir = "";

            foreach (var line in lines)
            {
                int    idx   = line.IndexOf('=');
                string key   = line.Substring(0, idx);
                string value = line.Substring(idx + 1, line.Length - (idx + 1));
                if (key == "framesdir")
                {
                    framesDir = value;
                }
            }

            _mFramesDirectory = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(_mSynclessConfigFile)), framesDir);

            // scan frames directory
            int frame = 1;             // hacky! skip frame 0, because we have a problem with dumping that frame somehow

            for (;;)
            {
                GetPaths(frame, out var png, out var wav);
                if (!File.Exists(png) || !File.Exists(wav))
                {
                    break;
                }

                _mFrameInfos.Add(new FrameInfo
                {
                    PngPath = png,
                    WavPath = wav
                });

                frame++;
            }

            ShowDialog();
        }
示例#6
0
        public static string SaveRamAbsolutePath(this PathEntryCollection collection, IGameInfo game, IMovie movie)
        {
            var name = game.FilesystemSafeName();

            if (movie.IsActive())
            {
                name += $".{Path.GetFileNameWithoutExtension(movie.Filename)}";
            }

            var pathEntry = collection[game.System, "Save RAM"]
                            ?? collection[game.System, "Base"];

            return($"{Path.Combine(collection.AbsolutePathFor(pathEntry.Path, game.System), name)}.SaveRAM");
        }
示例#7
0
        // TODO: This doesn't really belong here, but not sure where to put it
        public static void PopulateWithDefaultHeaderValues(
            this IMovie movie,
            IEmulator emulator,
            IGameInfo game,
            FirmwareManager firmwareManager,
            string author)
        {
            movie.Author                  = author;
            movie.EmulatorVersion         = VersionInfo.GetEmuVersion();
            movie.OriginalEmulatorVersion = VersionInfo.GetEmuVersion();
            movie.SystemID                = emulator.SystemId;

            var settable = new SettingsAdapter(emulator);

            if (settable.HasSyncSettings)
            {
                movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
            }

            if (game.IsNullInstance())
            {
                movie.GameName = "NULL";
            }
            else
            {
                movie.GameName = game.FilesystemSafeName();
                movie.Hash     = game.Hash;
                if (game.FirmwareHash != null)
                {
                    movie.FirmwareHash = game.FirmwareHash;
                }
            }

            if (emulator.HasBoardInfo())
            {
                movie.BoardName = emulator.AsBoardInfo().BoardName;
            }

            if (emulator.HasRegions())
            {
                var region = emulator.AsRegionable().Region;
                if (region == Emulation.Common.DisplayType.PAL)
                {
                    movie.HeaderEntries.Add(HeaderKeys.Pal, "1");
                }
            }

            if (firmwareManager.RecentlyServed.Any())
            {
                foreach (var firmware in firmwareManager.RecentlyServed)
                {
                    var key = $"{firmware.SystemId}_Firmware_{firmware.FirmwareId}";

                    if (!movie.HeaderEntries.ContainsKey(key))
                    {
                        movie.HeaderEntries.Add(key, firmware.Hash);
                    }
                }
            }

            if (emulator is GBHawk gbHawk && gbHawk.IsCGBMode())
            {
                movie.HeaderEntries.Add("IsCGBMode", "1");
            }

            if (emulator is SubGBHawk subgbHawk)
            {
                if (subgbHawk._GBCore.IsCGBMode())
                {
                    movie.HeaderEntries.Add("IsCGBMode", "1");
                }

                movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
            }

            if (emulator is Gameboy gb)
            {
                if (gb.IsCGBMode())
                {
                    movie.HeaderEntries.Add("IsCGBMode", "1");
                }

                movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
            }

            if (emulator is SMS sms)
            {
                if (sms.IsSG1000)
                {
                    movie.HeaderEntries.Add("IsSGMode", "1");
                }

                if (sms.IsGameGear)
                {
                    movie.HeaderEntries.Add("IsGGMode", "1");
                }
            }

            if (emulator is GPGX gpgx && gpgx.IsMegaCD)
            {
                movie.HeaderEntries.Add("IsSegaCDMode", "1");
            }

            if (emulator is PicoDrive pico && pico.Is32XActive)
            {
                movie.HeaderEntries.Add("Is32X", "1");
            }

            if (emulator is SubNESHawk)
            {
                movie.HeaderEntries.Add(HeaderKeys.VBlankCount, "0");
            }

            movie.Core = ((CoreAttribute)Attribute
                          .GetCustomAttribute(emulator.GetType(), typeof(CoreAttribute)))
                         .CoreName;
        }
        // TODO: This doesn't really belong here, but not sure where to put it
        public static void PopulateWithDefaultHeaderValues(
            this IMovie movie,
            IEmulator emulator,
            ISettingsAdapter settable,
            IGameInfo game,
            FirmwareManager firmwareManager,
            string author)
        {
            movie.Author                  = author;
            movie.EmulatorVersion         = VersionInfo.GetEmuVersion();
            movie.OriginalEmulatorVersion = VersionInfo.GetEmuVersion();
            movie.SystemID                = emulator.SystemId;

            if (settable.HasSyncSettings)
            {
                movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
            }

            if (game.IsNullInstance())
            {
                movie.GameName = "NULL";
            }
            else
            {
                movie.GameName = game.FilesystemSafeName();
                movie.Hash     = game.Hash;
                if (game.FirmwareHash != null)
                {
                    movie.FirmwareHash = game.FirmwareHash;
                }
            }

            if (emulator.HasBoardInfo())
            {
                movie.BoardName = emulator.AsBoardInfo().BoardName;
            }

            if (emulator.HasRegions())
            {
                var region = emulator.AsRegionable().Region;
                if (region == DisplayType.PAL)
                {
                    movie.HeaderEntries.Add(HeaderKeys.Pal, "1");
                }
            }

            if (firmwareManager.RecentlyServed.Count != 0)
            {
                foreach (var firmware in firmwareManager.RecentlyServed)
                {
                    var key = firmware.ID.MovieHeaderKey;
                    if (!movie.HeaderEntries.ContainsKey(key))
                    {
                        movie.HeaderEntries.Add(key, firmware.Hash);
                    }
                }
            }

            if (emulator is NDS nds && nds.IsDSi)
            {
                movie.HeaderEntries.Add("IsDSi", "1");

                if (nds.IsDSiWare)
                {
                    movie.HeaderEntries.Add("IsDSiWare", "1");
                }
            }

            if ((emulator is NES nes && nes.IsVS) ||
                (emulator is SubNESHawk subnes && subnes.IsVs))
            {
                movie.HeaderEntries.Add("IsVS", "1");
            }

            if (emulator is IGameboyCommon gb)
            {
                if (gb.IsCGBMode())
                {
                    movie.HeaderEntries.Add(gb.IsCGBDMGMode() ? "IsCGBDMGMode" : "IsCGBMode", "1");
                }
            }

            if (emulator is SMS sms)
            {
                if (sms.IsSG1000)
                {
                    movie.HeaderEntries.Add("IsSGMode", "1");
                }

                if (sms.IsGameGear)
                {
                    movie.HeaderEntries.Add("IsGGMode", "1");
                }
            }

            if (emulator is GPGX gpgx && gpgx.IsMegaCD)
            {
                movie.HeaderEntries.Add("IsSegaCDMode", "1");
            }

            if (emulator is PicoDrive pico && pico.Is32XActive)
            {
                movie.HeaderEntries.Add("Is32X", "1");
            }

            if (emulator is ICycleTiming)
            {
                movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
                movie.HeaderEntries.Add(HeaderKeys.ClockRate, "0");
            }

            movie.Core = emulator.Attributes().CoreName;
        }
示例#9
0
 public static string SuggestedFolder(Config config, IGameInfo game = null)
 {
     return(config.PathEntries.AbsolutePathFor(Path.Combine(
                                                   config.PathEntries["Global", "Macros"].Path,
                                                   game?.FilesystemSafeName()), null));
 }
示例#10
0
 public static string SuggestedFolder(Config config, IGameInfo game)
 {
     return(config.PathEntries.AbsolutePathFor(Path.Combine(
                                                   config.PathEntries[PathEntryCollection.GLOBAL, "Macros"].Path,
                                                   game.FilesystemSafeName()), null));
 }