Example #1
0
        // contructor
        public ConfigImport()
        {
            // populate config info from database
            _Paths = Paths.GetPaths();
            _ConfigNetplaySettings = ConfigNetplaySettings.GetNetplay();
            _ConfigServerSettings  = new ConfigServerSettings(); // ConfigServerSettings.GetServer(100);

            _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000);

            _ConfigGbSettings         = ConfigBaseSettings.GetConfig(2000000001);
            _ConfigGbaSettings        = ConfigBaseSettings.GetConfig(2000000002);
            _ConfigLynxSettings       = ConfigBaseSettings.GetConfig(2000000003);
            _ConfigMdSettings         = ConfigBaseSettings.GetConfig(2000000004);
            _ConfigGgSettings         = ConfigBaseSettings.GetConfig(2000000005);
            _ConfigNgpSettings        = ConfigBaseSettings.GetConfig(2000000006);
            _ConfigPceSettings        = ConfigBaseSettings.GetConfig(2000000007);
            _ConfigPcfxSettings       = ConfigBaseSettings.GetConfig(2000000008);
            _ConfigPsxSettings        = ConfigBaseSettings.GetConfig(2000000009);
            _ConfigSmsSettings        = ConfigBaseSettings.GetConfig(2000000010);
            _ConfigNesSettings        = ConfigBaseSettings.GetConfig(2000000011);
            _ConfigSnesSettings       = ConfigBaseSettings.GetConfig(2000000012);
            _ConfigSsSettings         = ConfigBaseSettings.GetConfig(2000000013);
            _ConfigVbSettings         = ConfigBaseSettings.GetConfig(2000000014);
            _ConfigWswanSettings      = ConfigBaseSettings.GetConfig(2000000015);
            _ConfigSnes_faustSettings = ConfigBaseSettings.GetConfig(2000000016);
            _ConfigPce_fastSettings   = ConfigBaseSettings.GetConfig(2000000017);
        }
        // contructor
        public ConfigImport()
        {
            // populate config info from database
            _Paths = Paths.GetPaths();
            _ConfigNetplaySettings    = ConfigNetplaySettings.GetNetplay();
            _ConfigServerSettings     = new ConfigServerSettings(); // ConfigServerSettings.GetServer(100);
            _ConfigBaseSettings       = ConfigBaseSettings.GetConfig(2000000000);
            _ConfigGbSettings         = ConfigBaseSettings.GetConfig(2000000001);
            _ConfigGbaSettings        = ConfigBaseSettings.GetConfig(2000000002);
            _ConfigLynxSettings       = ConfigBaseSettings.GetConfig(2000000003);
            _ConfigMdSettings         = ConfigBaseSettings.GetConfig(2000000004);
            _ConfigGgSettings         = ConfigBaseSettings.GetConfig(2000000005);
            _ConfigNgpSettings        = ConfigBaseSettings.GetConfig(2000000006);
            _ConfigPceSettings        = ConfigBaseSettings.GetConfig(2000000007);
            _ConfigPcfxSettings       = ConfigBaseSettings.GetConfig(2000000008);
            _ConfigPsxSettings        = ConfigBaseSettings.GetConfig(2000000009);
            _ConfigSmsSettings        = ConfigBaseSettings.GetConfig(2000000010);
            _ConfigNesSettings        = ConfigBaseSettings.GetConfig(2000000011);
            _ConfigSnesSettings       = ConfigBaseSettings.GetConfig(2000000012);
            _ConfigSsSettings         = ConfigBaseSettings.GetConfig(2000000013);
            _ConfigVbSettings         = ConfigBaseSettings.GetConfig(2000000014);
            _ConfigWswanSettings      = ConfigBaseSettings.GetConfig(2000000015);
            _ConfigSnes_faustSettings = ConfigBaseSettings.GetConfig(2000000016);
            _ConfigPce_fastSettings   = ConfigBaseSettings.GetConfig(2000000017);

            if (VersionChecker.Instance.CurrentMedVerDesc.MajorINT > 0)
            {
                MednafenConfigName = @"mednafen.cfg";
            }
            else
            {
                MednafenConfigName = @"\mednafen-09x.cfg";
            }
        }
Example #3
0
        // constructor
        public SettingsHandler()
        {
            VH = new SettingsVisualHandler();
            AllSettingsPanels = VH.AllSettingPanels;

            /* Load all settings from database */
            // Paths Table
            Paths = Paths.GetPaths();
            // Global Settings Table
            GSettings = GlobalSettings.GetGlobals();
            // Config Table
            ConfigSettings = ConfigBaseSettings.GetConfig(2000000000);
            // Netplay Table
            NPSettings = ConfigNetplaySettings.GetNetplay();
            // Servers Table
            ServerSettings = ConfigServerSettings.GetServers();
        }
Example #4
0
        public void SaveToDatabase()
        {
            ConfigBaseSettings.SetConfig(_ConfigGbaSettings);
            ConfigBaseSettings.SetConfig(_ConfigGbSettings);
            ConfigBaseSettings.SetConfig(_ConfigGgSettings);
            ConfigBaseSettings.SetConfig(_ConfigLynxSettings);
            ConfigBaseSettings.SetConfig(_ConfigMdSettings);
            ConfigBaseSettings.SetConfig(_ConfigNesSettings);
            ConfigBaseSettings.SetConfig(_ConfigNgpSettings);
            ConfigBaseSettings.SetConfig(_ConfigPceSettings);
            ConfigBaseSettings.SetConfig(_ConfigPce_fastSettings);
            ConfigBaseSettings.SetConfig(_ConfigPcfxSettings);
            ConfigBaseSettings.SetConfig(_ConfigPsxSettings);
            ConfigBaseSettings.SetConfig(_ConfigSmsSettings);
            ConfigBaseSettings.SetConfig(_ConfigSnesSettings);
            ConfigBaseSettings.SetConfig(_ConfigSnes_faustSettings);
            ConfigBaseSettings.SetConfig(_ConfigSsSettings);
            ConfigBaseSettings.SetConfig(_ConfigVbSettings);
            ConfigBaseSettings.SetConfig(_ConfigWswanSettings);

            ConfigNetplaySettings.SetNetplay(_ConfigNetplaySettings);

            ConfigServerSettings.SaveToDatabase(_ConfigServerSettings);
        }
Example #5
0
        public static void InitialSeed()
        {
            // check whether initial seed needs to continue
            bool doSeed = false;

            using (var db = new MyDbContext())
            {
                var se = db.GlobalSettings.FirstOrDefault();
                if (se == null || se.databaseGenerated == false)
                {
                    doSeed = true;
                }
            }

            if (doSeed == true)
            {
                // populate Versions table
                Versions version = Versions.GetVersionDefaults();
                using (var context = new MyDbContext())
                {
                    context.Versions.Add(version);
                    context.SaveChanges();
                }


                // default netplay settings
                ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults();
                using (var context = new MyDbContext())
                {
                    context.ConfigNetplaySettings.Add(npSettings);
                    context.SaveChanges();
                }

                // default ConfigBaseSettings population
                ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults();

                cfbs.ConfigId = 2000000000; // base configuration

                using (var context = new MyDbContext())
                {
                    context.ConfigBaseSettings.Add(cfbs);
                    context.SaveChanges();
                }

                // create system specific configs (set to disabled by default)
                List <GSystem> gamesystems = GSystem.GetSystems();
                using (var gsContext = new MyDbContext())
                {
                    // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID
                    // and setting their systemident to systemid
                    foreach (GSystem System in gamesystems)
                    {
                        int def = 2000000000;
                        ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults();
                        c.ConfigId    = def + System.systemId;
                        c.systemIdent = System.systemId;
                        c.isEnabled   = false;

                        // add to databsae
                        gsContext.ConfigBaseSettings.Add(c);
                        gsContext.SaveChanges();
                    }
                }

                // Populate Servers
                List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults();
                using (var context = new MyDbContext())
                {
                    context.ConfigServerSettings.AddRange(servers);
                    context.SaveChanges();
                }

                // Create General Settings Entry
                GlobalSettings gs = GlobalSettings.GetGlobalDefaults();
                using (var context = new MyDbContext())
                {
                    context.GlobalSettings.Add(gs);
                    context.SaveChanges();
                }

                // create mednanet general entry
                MednaNetSettings ms = MednaNetSettings.GetMednaNetDefaults();
                using (var context = new MyDbContext())
                {
                    context.MednaNetSettings.Add(ms);
                    context.SaveChanges();
                }

                // create Paths entry
                Paths paths = new Paths
                {
                    pathId = 1
                };
                using (var context = new MyDbContext())
                {
                    context.Paths.Add(paths);
                    context.SaveChanges();
                }

                // initial seeding complete. mark GeneralSettings table so that regeneration does not occur
                GlobalSettings set;
                using (var context = new MyDbContext())
                {
                    set = (from a in context.GlobalSettings
                           where a.settingsId == 1
                           select a).FirstOrDefault <GlobalSettings>();
                }

                if (set != null)
                {
                    set.databaseGenerated = true;
                }

                using (var dbCtx = new MyDbContext())
                {
                    dbCtx.Entry(set).State = EntityState.Modified;
                    dbCtx.SaveChanges();
                }
            }
        }
        /// <summary>
        /// Save settings based on settings group
        /// </summary>
        /// <param name="settingGroup"></param>
        public static void SaveSettings(SettingGroup settingGroup)
        {
            MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            switch (settingGroup)
            {
            case SettingGroup.BiosPaths:
                ConfigBaseSettings.SaveBiosPaths();
                break;

            case SettingGroup.GamePaths:
                TextBox tbPathMednafen = (TextBox)mw.FindName("tbPathMednafen");
                TextBox tbPathGb       = (TextBox)mw.FindName("tbPathGb");
                TextBox tbPathGba      = (TextBox)mw.FindName("tbPathGba");
                TextBox tbPathGg       = (TextBox)mw.FindName("tbPathGg");
                TextBox tbPathLynx     = (TextBox)mw.FindName("tbPathLynx");
                TextBox tbPathMd       = (TextBox)mw.FindName("tbPathMd");
                TextBox tbPathNes      = (TextBox)mw.FindName("tbPathNes");
                TextBox tbPathSnes     = (TextBox)mw.FindName("tbPathSnes");
                TextBox tbPathNgp      = (TextBox)mw.FindName("tbPathNgp");
                TextBox tbPathPce      = (TextBox)mw.FindName("tbPathPce");
                TextBox tbPathPcfx     = (TextBox)mw.FindName("tbPathPcfx");
                TextBox tbPathPsx      = (TextBox)mw.FindName("tbPathPsx");
                TextBox tbPathSs       = (TextBox)mw.FindName("tbPathSs");
                TextBox tbPathSms      = (TextBox)mw.FindName("tbPathSms");
                TextBox tbPathVb       = (TextBox)mw.FindName("tbPathVb");
                TextBox tbPathWswan    = (TextBox)mw.FindName("tbPathWswan");
                TextBox tbPathPceCd    = (TextBox)mw.FindName("tbPathPceCd");

                Paths.SavePathSettings(tbPathMednafen, tbPathGb, tbPathGba, tbPathGg, tbPathLynx, tbPathMd, tbPathNes, tbPathSnes, tbPathNgp, tbPathPce, tbPathPcfx, tbPathSms, tbPathVb, tbPathWswan, tbPathPsx, tbPathSs, tbPathPceCd);
                break;

            case SettingGroup.GlobalSettings:
                GlobalSettings gs = GlobalSettings.GetGlobals();

                Slider   slFanrtsPerHost       = (Slider)mw.FindName("slFanrtsPerHost");
                Slider   slScreenshotsPerHost  = (Slider)mw.FindName("slScreenshotsPerHost");
                ComboBox comboImageTooltipSize = (ComboBox)mw.FindName("comboImageTooltipSize");
                ComboBox cbFormatGameTitles    = (ComboBox)mw.FindName("cbFormatGameTitles");

                gs.maxFanarts             = slFanrtsPerHost.Value;
                gs.maxScreenshots         = slScreenshotsPerHost.Value;
                gs.imageToolTipPercentage = Convert.ToDouble(comboImageTooltipSize.SelectedValue, System.Globalization.CultureInfo.InvariantCulture);
                gs.changeTitleCase        = Convert.ToInt32(cbFormatGameTitles.SelectedValue);

                GlobalSettings.SetGlobals(gs);
                break;

            case SettingGroup.MednaNetSettings:
                MednaNetSettings ms = MednaNetSettings.GetGlobals();

                Slider slDiscordChatHistory  = (Slider)mw.FindName("slDiscordChatHistory");
                Slider slApiPollingFrequency = (Slider)mw.FindName("slApiPollingFrequency");

                ms.ChatHistoryInMinutes       = Convert.ToInt32(slDiscordChatHistory.Value, System.Globalization.CultureInfo.InvariantCulture);
                ms.PollTimerIntervalInSeconds = Convert.ToInt32(slApiPollingFrequency.Value, System.Globalization.CultureInfo.InvariantCulture);

                MednaNetSettings.SetGlobals(ms);
                break;

            case SettingGroup.MednafenPaths:
                ConfigBaseSettings.SaveMednafenPaths();
                break;

            case SettingGroup.NetplaySettings:
                TextBox     tbNetplayNick       = (TextBox)mw.FindName("tbNetplayNick");
                Slider      slLocalPlayersValue = (Slider)mw.FindName("slLocalPlayersValue");
                Slider      slConsoleLinesValue = (Slider)mw.FindName("slConsoleLinesValue");
                Slider      slConsoleScaleValue = (Slider)mw.FindName("slConsoleScaleValue");
                RadioButton resOne   = (RadioButton)mw.FindName("resOne");
                RadioButton resTwo   = (RadioButton)mw.FindName("resTwo");
                RadioButton resThree = (RadioButton)mw.FindName("resThree");
                RadioButton resFour  = (RadioButton)mw.FindName("resFour");
                RadioButton resFive  = (RadioButton)mw.FindName("resFive");

                ConfigNetplaySettings.SaveNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive);
                break;

            case SettingGroup.ServerSettings:
                TextBox tbServerDesc = (TextBox)mw.FindName("tbServerDesc");
                TextBox tbHostname   = (TextBox)mw.FindName("tbHostname");
                Slider  slServerPort = (Slider)mw.FindName("slServerPort");
                TextBox tbPassword   = (TextBox)mw.FindName("tbPassword");
                TextBox tbGameKey    = (TextBox)mw.FindName("tbGameKey");

                ConfigServerSettings.SaveCustomServerSettings(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey);
                break;

            default:
                break;
            }
        }
Example #7
0
        public static void InitialSeed()
        {
            // check whether initial seed needs to continue
            bool doSeed = false;

            using (var db = new MyDbContext())
            {
                var se = db.GlobalSettings.FirstOrDefault();
                if (se == null || se.databaseGenerated == false)
                {
                    doSeed = true;
                }
            }

            if (doSeed == true)
            {
                /*
                 * // Create systems
                 * List<GameSystem> gSystems = GameSystem.GetGameSystemDefaults();
                 * using (var context = new MyDbContext())
                 * {
                 *  var gameData = context.GameSystem.AsNoTracking().ToList();
                 *  foreach (var newEntry in gSystems)
                 *  {
                 *      var idLookup = (from e in gameData
                 *                      where e.systemId == newEntry.systemId
                 *                      select e).FirstOrDefault();
                 *
                 *      if (idLookup == null)
                 *      {
                 *          // entry doesnt exist - insert
                 *          context.GameSystem.Add(newEntry);
                 *      }
                 *      else
                 *      {
                 *          // entry exists - update
                 *          context.GameSystem.Update(newEntry);
                 *      }
                 *  }
                 *  context.SaveChanges();
                 * }
                 */

                // populate Versions table
                Versions version = Versions.GetVersionDefaults();
                using (var context = new MyDbContext())
                {
                    context.Versions.Add(version);
                    context.SaveChanges();
                }


                // default netplay settings
                ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults();
                using (var context = new MyDbContext())
                {
                    context.ConfigNetplaySettings.Add(npSettings);
                    context.SaveChanges();
                }

                // default ConfigBaseSettings population
                ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults();

                cfbs.ConfigId = 2000000000; // base configuration

                using (var context = new MyDbContext())
                {
                    context.ConfigBaseSettings.Add(cfbs);
                    context.SaveChanges();
                }

                // create system specific configs (set to disabled by default)
                List <GSystem> gamesystems = GSystem.GetSystems();
                using (var gsContext = new MyDbContext())
                {
                    // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID
                    // and setting their systemident to systemid
                    foreach (GSystem System in gamesystems)
                    {
                        int def = 2000000000;
                        ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults();
                        c.ConfigId    = def + System.systemId;
                        c.systemIdent = System.systemId;
                        c.isEnabled   = false;

                        // add to databsae
                        gsContext.ConfigBaseSettings.Add(c);
                        gsContext.SaveChanges();
                    }
                }

                // Populate Servers
                List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults();
                using (var context = new MyDbContext())
                {
                    context.ConfigServerSettings.AddRange(servers);
                    context.SaveChanges();
                }

                // Create General Settings Entry
                GlobalSettings gs = GlobalSettings.GetGlobalDefaults();
                using (var context = new MyDbContext())
                {
                    context.GlobalSettings.Add(gs);
                    context.SaveChanges();
                }

                // create Paths entry
                Paths paths = new Paths
                {
                    pathId = 1
                };
                using (var context = new MyDbContext())
                {
                    context.Paths.Add(paths);
                    context.SaveChanges();
                }


                //add test rom data

                /*
                 * List<Game> roms = new List<Game>
                 * {
                 * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 3, hidden = false, isFavorite = true },
                 * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 10, hidden = false, isFavorite = false }
                 * };
                 * using (var context = new MyDbContext())
                 * {
                 *
                 *  context.Game.AddRange(roms);
                 *  context.SaveChanges();
                 * }
                 */

                // initial seeding complete. mark GeneralSettings table so that regeneration does not occur
                GlobalSettings set;
                using (var context = new MyDbContext())
                {
                    set = (from a in context.GlobalSettings
                           where a.settingsId == 1
                           select a).FirstOrDefault <GlobalSettings>();
                }

                if (set != null)
                {
                    set.databaseGenerated = true;
                }

                using (var dbCtx = new MyDbContext())
                {
                    dbCtx.Entry(set).State = EntityState.Modified;
                    dbCtx.SaveChanges();
                }
            }
        }
Example #8
0
        /// <summary>
        /// Save settings based on settings group
        /// </summary>
        /// <param name="settingGroup"></param>
        public static void SaveSettings(SettingGroup settingGroup)
        {
            MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            switch (settingGroup)
            {
            case SettingGroup.BiosPaths:
                ConfigBaseSettings.SaveBiosPaths();
                break;

            case SettingGroup.GamePaths:
                TextBox tbPathMednafen = (TextBox)mw.FindName("tbPathMednafen");
                TextBox tbPathGb       = (TextBox)mw.FindName("tbPathGb");
                TextBox tbPathGba      = (TextBox)mw.FindName("tbPathGba");
                TextBox tbPathGg       = (TextBox)mw.FindName("tbPathGg");
                TextBox tbPathLynx     = (TextBox)mw.FindName("tbPathLynx");
                TextBox tbPathMd       = (TextBox)mw.FindName("tbPathMd");
                TextBox tbPathNes      = (TextBox)mw.FindName("tbPathNes");
                TextBox tbPathSnes     = (TextBox)mw.FindName("tbPathSnes");
                TextBox tbPathNgp      = (TextBox)mw.FindName("tbPathNgp");
                TextBox tbPathPce      = (TextBox)mw.FindName("tbPathPce");
                TextBox tbPathPcfx     = (TextBox)mw.FindName("tbPathPcfx");
                TextBox tbPathSms      = (TextBox)mw.FindName("tbPathSms");
                TextBox tbPathVb       = (TextBox)mw.FindName("tbPathVb");
                TextBox tbPathWswan    = (TextBox)mw.FindName("tbPathWswan");

                Paths.SavePathSettings(tbPathMednafen, tbPathGb, tbPathGba, tbPathGg, tbPathLynx, tbPathMd, tbPathNes, tbPathSnes, tbPathNgp, tbPathPce, tbPathPcfx, tbPathSms, tbPathVb, tbPathWswan);
                break;

            case SettingGroup.GlobalSettings:
                GlobalSettings gs = GlobalSettings.GetGlobals();

                Slider   slFanrtsPerHost       = (Slider)mw.FindName("slFanrtsPerHost");
                Slider   slScreenshotsPerHost  = (Slider)mw.FindName("slScreenshotsPerHost");
                ComboBox comboImageTooltipSize = (ComboBox)mw.FindName("comboImageTooltipSize");

                gs.maxFanarts             = slFanrtsPerHost.Value;
                gs.maxScreenshots         = slScreenshotsPerHost.Value;
                gs.imageToolTipPercentage = Convert.ToDouble(comboImageTooltipSize.SelectedValue);

                GlobalSettings.SetGlobals(gs);
                break;

            case SettingGroup.MednafenPaths:
                ConfigBaseSettings.SaveMednafenPaths();
                break;

            case SettingGroup.NetplaySettings:
                TextBox     tbNetplayNick       = (TextBox)mw.FindName("tbNetplayNick");
                Slider      slLocalPlayersValue = (Slider)mw.FindName("slLocalPlayersValue");
                Slider      slConsoleLinesValue = (Slider)mw.FindName("slConsoleLinesValue");
                Slider      slConsoleScaleValue = (Slider)mw.FindName("slConsoleScaleValue");
                RadioButton resOne   = (RadioButton)mw.FindName("resOne");
                RadioButton resTwo   = (RadioButton)mw.FindName("resTwo");
                RadioButton resThree = (RadioButton)mw.FindName("resThree");
                RadioButton resFour  = (RadioButton)mw.FindName("resFour");
                RadioButton resFive  = (RadioButton)mw.FindName("resFive");

                ConfigNetplaySettings.SaveNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive);
                break;

            case SettingGroup.ServerSettings:
                TextBox tbServerDesc = (TextBox)mw.FindName("tbServerDesc");
                TextBox tbHostname   = (TextBox)mw.FindName("tbHostname");
                Slider  slServerPort = (Slider)mw.FindName("slServerPort");
                TextBox tbPassword   = (TextBox)mw.FindName("tbPassword");
                TextBox tbGameKey    = (TextBox)mw.FindName("tbGameKey");

                ConfigServerSettings.SaveCustomServerSettings(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey);
                break;

            default:
                break;
            }
        }