Exemplo n.º 1
0
        private TSetting GetSyncSettings <TEmulator, TSetting>()
            where TSetting : class, new()
            where TEmulator : IEmulator
        {
            object fromCore = null;
            var    settable = new SettingsAdapter(_emulator);

            if (settable.HasSyncSettings)
            {
                fromCore = settable.GetSyncSettings();
            }

            return(fromCore as TSetting
                   ?? _config.GetCoreSyncSettings <TEmulator, TSetting>()
                   ?? new TSetting());             // guaranteed to give sensible defaults
        }
Exemplo n.º 2
0
        private TSetting GetSyncSettings <TEmulator, TSetting>()
            where TSetting : class, new()
            where TEmulator : IEmulator
        {
            // should we complain if we get a successful object from the config file, but it is the wrong type?
            object fromCore = null;
            var    settable = new SettingsAdapter(_emulator);

            if (settable.HasSyncSettings)
            {
                fromCore = settable.GetSyncSettings();
            }

            return(fromCore as TSetting
                   ?? _config.GetCoreSyncSettings <TEmulator>() as TSetting
                   ?? new TSetting());             // guaranteed to give sensible defaults
        }
Exemplo n.º 3
0
        private GenericCoreConfig(
            IMainFormForConfig mainForm,
            bool isMovieActive,
            bool ignoreSettings     = false,
            bool ignoreSyncSettings = false)
        {
            InitializeComponent();
            _mainForm = mainForm;

            var settable = new SettingsAdapter(_mainForm.Emulator);

            if (settable.HasSettings && !ignoreSettings)
            {
                _s = settable.GetSettings();
            }

            if (settable.HasSyncSettings && !ignoreSyncSettings)
            {
                _ss = settable.GetSyncSettings();
            }

            if (_s != null)
            {
                propertyGrid1.SelectedObject = _s;
                propertyGrid1.AdjustDescriptionHeightToFit();
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage1);
            }

            if (_ss != null)
            {
                propertyGrid2.SelectedObject = _ss;
                propertyGrid2.AdjustDescriptionHeightToFit();
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage2);
            }

            if (isMovieActive)
            {
                propertyGrid2.Enabled = false;                 // disable changes to sync setting when movie, so as not to confuse user
            }
        }
Exemplo n.º 4
0
        private GenericCoreConfig(MainForm mainForm, bool ignoreSettings = false, bool ignoreSyncSettings = false)
        {
            _mainForm = mainForm;
            InitializeComponent();

            var settable = new SettingsAdapter(Global.Emulator);

            if (settable.HasSettings && !ignoreSettings)
            {
                _s = settable.GetSettings();
            }

            if (settable.HasSyncSettings && !ignoreSyncSettings)
            {
                _ss = settable.GetSyncSettings();
            }

            if (_s != null)
            {
                propertyGrid1.SelectedObject = _s;
                ChangeDescriptionHeight(propertyGrid1);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage1);
            }

            if (_ss != null)
            {
                propertyGrid2.SelectedObject = _ss;
                ChangeDescriptionHeight(propertyGrid2);
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage2);
            }

            if (Global.MovieSession.Movie.IsActive())
            {
                propertyGrid2.Enabled = false;                 // disable changes to sync setting when movie, so as not to confuse user
            }
        }
Exemplo n.º 5
0
		GenericCoreConfig(bool ignoresettings, bool ignoresyncsettings)
		{
			InitializeComponent();

			var settable = new SettingsAdapter(Global.Emulator);

			if (settable.HasSettings && !ignoresettings)
				s = settable.GetSettings();
			if (settable.HasSyncSettings && !ignoresyncsettings)
				ss = settable.GetSyncSettings();

			if (s != null)
				propertyGrid1.SelectedObject = s;
			else
				tabControl1.TabPages.Remove(tabPage1);
			if (ss != null)
				propertyGrid2.SelectedObject = ss;
			else
				tabControl1.TabPages.Remove(tabPage2);

			if (Global.MovieSession.Movie.IsActive)
				propertyGrid2.Enabled = false; // disable changes to sync setting when movie, so as not to confuse user
		}
        GenericCoreConfig(bool ignoresettings, bool ignoresyncsettings)
        {
            InitializeComponent();

            var settable = new SettingsAdapter(Global.Emulator);

            if (settable.HasSettings && !ignoresettings)
            {
                s = settable.GetSettings();
            }
            if (settable.HasSyncSettings && !ignoresyncsettings)
            {
                ss = settable.GetSyncSettings();
            }

            if (s != null)
            {
                propertyGrid1.SelectedObject = s;
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage1);
            }
            if (ss != null)
            {
                propertyGrid2.SelectedObject = ss;
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage2);
            }

            if (Global.MovieSession.Movie.IsActive)
            {
                propertyGrid2.Enabled = false;                 // disable changes to sync setting when movie, so as not to confuse user
            }
        }
        // TODO: This doesn't really belong here, but not sure where to put it
        public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
        {
            movie.Author          = author ?? Global.Config.DefaultAuthor;
            movie.EmulatorVersion = VersionInfo.GetEmuVersion();
            movie.SystemID        = Global.Emulator.SystemId;

            var settable = new SettingsAdapter(Global.Emulator);

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

            if (Global.Game != null)
            {
                movie.GameName = PathManager.FilesystemSafeName(Global.Game);
                movie.Hash     = Global.Game.Hash;
                if (Global.Game.FirmwareHash != null)
                {
                    movie.FirmwareHash = Global.Game.FirmwareHash;
                }
            }
            else
            {
                movie.GameName = "NULL";
            }

            if (Global.Emulator.BoardName != null)
            {
                movie.BoardName = Global.Emulator.BoardName;
            }

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

            if (Global.FirmwareManager.RecentlyServed.Any())
            {
                foreach (var firmware in Global.FirmwareManager.RecentlyServed)
                {
                    var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId;

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

            if (Global.Emulator is Gameboy && (Global.Emulator as Gameboy).IsCGBMode())
            {
                movie.HeaderEntries.Add("IsCGBMode", "1");
            }

            if (Global.Emulator is SMS && (Global.Emulator as SMS).IsSG1000)
            {
                movie.HeaderEntries.Add("IsSGMode", "1");
            }

            if (Global.Emulator is GPGX && (Global.Emulator as GPGX).IsSegaCD)
            {
                movie.HeaderEntries.Add("IsSegaCDMode", "1");
            }

            movie.Core = ((CoreAttributes)Attribute
                          .GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttributes)))
                         .CoreName;
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        private static void CommitCoreSettingsToConfig()
        {
            // save settings object
            var t = Global.Emulator.GetType();
            var settable = new SettingsAdapter(Global.Emulator);

            if (settable.HasSettings)
            {
                Global.Config.PutCoreSettings(settable.GetSettings(), t);
            }

            if (settable.HasSyncSettings && !Global.MovieSession.Movie.IsActive)
            {
                // don't trample config with loaded-from-movie settings
                Global.Config.PutCoreSyncSettings(settable.GetSyncSettings(), t);
            }
        }
Exemplo n.º 10
0
		// TODO: This doesn't really belong here, but not sure where to put it
		public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
		{
			movie.Author = author ?? Global.Config.DefaultAuthor;
			movie.EmulatorVersion = VersionInfo.GetEmuVersion();
			movie.SystemID = Global.Emulator.SystemId;

			var settable = new SettingsAdapter(Global.Emulator);
			if (settable.HasSyncSettings)
			{
				movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
			}

			if (Global.Game != null)
			{
				movie.GameName = PathManager.FilesystemSafeName(Global.Game);
				movie.Hash = Global.Game.Hash;
				if (Global.Game.FirmwareHash != null)
				{
					movie.FirmwareHash = Global.Game.FirmwareHash;
				}
			}
			else
			{
				movie.GameName = "NULL";
			}

			if (Global.Emulator.BoardName != null)
			{
				movie.BoardName = Global.Emulator.BoardName;
			}

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

			if (Global.FirmwareManager.RecentlyServed.Any())
			{
				foreach (var firmware in Global.FirmwareManager.RecentlyServed)
				{
					var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId;

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

			}

			if (Global.Emulator is Gameboy && (Global.Emulator as Gameboy).IsCGBMode())
			{
				movie.HeaderEntries.Add("IsCGBMode", "1");
			}

			if (Global.Emulator is SMS && (Global.Emulator as SMS).IsSG1000)
			{
				movie.HeaderEntries.Add("IsSGMode", "1");
			}

			movie.Core = ((CoreAttributes)Attribute
				.GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttributes)))
				.CoreName;
		}
Exemplo n.º 11
0
        // TODO: This doesn't really belong here, but not sure where to put it
        public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
        {
            movie.Author          = author ?? Global.Config.DefaultAuthor;
            movie.EmulatorVersion = VersionInfo.GetEmuVersion();
            movie.SystemID        = Global.Emulator.SystemId;

            var settable = new SettingsAdapter(Global.Emulator);

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

            if (Global.Game != null)
            {
                movie.GameName = Global.Game.Name.FilesystemSafeName();
                movie.Hash     = Global.Game.Hash;
                if (Global.Game.FirmwareHash != null)
                {
                    movie.FirmwareHash = Global.Game.FirmwareHash;
                }
            }
            else
            {
                movie.GameName = "NULL";
            }

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

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

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

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

            if (Global.Emulator is GBHawk && ((GBHawk)Global.Emulator).is_GBC)
            {
                movie.HeaderEntries.Add("IsCGBMode", "1");
            }

            if (Global.Emulator is Gameboy && ((Gameboy)Global.Emulator).IsCGBMode())
            {
                movie.HeaderEntries.Add("IsCGBMode", "1");
            }

            if (Global.Emulator is Gameboy)
            {
                movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
            }

            if (Global.Emulator is SMS && ((SMS)Global.Emulator).IsSG1000)
            {
                movie.HeaderEntries.Add("IsSGMode", "1");
            }

            if (Global.Emulator is SMS && ((SMS)Global.Emulator).IsGameGear)
            {
                movie.HeaderEntries.Add("IsGGMode", "1");
            }

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

            if (Global.Emulator is PicoDrive && Global.Game["32X"])
            {
                movie.HeaderEntries.Add("Is32X", "1");
            }

            if (Global.Emulator is SubNESHawk || Global.Emulator is SubGBHawk)
            {
                movie.HeaderEntries.Add(HeaderKeys.VBlankCount, "0");
            }

            movie.Core = ((CoreAttribute)Attribute
                          .GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttribute)))
                         .CoreName;
        }