Esempio n. 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);
        }
Esempio n. 2
0
        public SettingEmulatorDialog()
        {
            InitializeComponent();
            config = new ConfigBaseSettings();

            GenerateUI();
        }
Esempio n. 3
0
        public void ImportSystemConfigFromDisk(ProgressDialogController controller, GSystem sys)
        {
            _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000 + sys.systemId);
            if (_ConfigBaseSettings == null)
            {
                // invalid config id
                return;
            }

            string configPath = _Paths.mednafenExe + @"\" + sys.systemCode + ".cfg";
            var    specCfg    = LoadConfigFromDisk(configPath);

            if (specCfg.Count == 0)
            {
                return;
            }
            // data was returned - begin import
            if (controller != null)
            {
                controller.SetMessage("Importing " + sys.systemCode + ".cfg");
            }
            ParseConfigIncoming(specCfg, 2000000000 + sys.systemId);

            // set to enabled
            //_ConfigBaseSettings.isEnabled = true;

            //ConfigBaseSettings.SetConfig(_ConfigBaseSettings);
        }
Esempio n. 4
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);

            if (VersionChecker.Instance.CurrentMedVerDesc.MajorINT > 0)
            {
                MednafenConfigName = @"mednafen.cfg";
            }
            else
            {
                MednafenConfigName = @"\mednafen-09x.cfg";
            }
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        // Methods

        public void ActivateEnabledSystems()
        {
            foreach (RadioButton rb in FilterButtons)
            {
                // if button is enabled in the database then make sure it is enabled in the UI

                string name = rb.Name.Replace("btnConfig", "");
                if (name == "Base")
                {
                    continue;
                }

                int configId = ConfigBaseSettings.GetConfigIdFromButtonName(name);

                // check whether this system is enabled
                if (ConfigBaseSettings.GetConfig(configId).isEnabled == true)
                {
                    rb.IsEnabled = true;
                }
            }
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 public void ImportBaseConfig()
 {
     _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000);
 }
Esempio n. 9
0
 public static void SetPropertyValue(ConfigBaseSettings settings, PropertyInfo p, string type, string value)
 {
 }
Esempio n. 10
0
        // Constructor
        public GameLauncher(int gameId)
        {
            db = new MyDbContext();

            GameId = gameId;

            // get Game object
            Game game = (from g in db.Game
                         where g.gameId == gameId
                         select g).SingleOrDefault();

            ConfigId = game.configId;
            RomPath  = game.gamePath;
            RomName  = game.gameName;

            // get globals
            Global = (from g in db.GlobalSettings
                      where g.settingsId == 1
                      select g).SingleOrDefault();

            SystemId = game.systemId;

            // logic for faust & fast
            if (game.systemId == 12)
            {
                if (Global.enableSnes_faust == true)
                {
                    SystemId = 16;
                    //MessageBoxResult result = MessageBox.Show("FAUST DETECTED");
                }
                else
                {
                    SystemId = game.systemId;
                }
            }
            if (game.systemId == 7 || game.systemId == 18)
            {
                if (Global.enablePce_fast == true)
                {
                    SystemId = 17;
                }
                else
                {
                    SystemId = 7;
                }
            }

            gSystem    = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single();
            SystemCode = gSystem.systemCode;



            RomFolder = GetRomFolder(SystemId, db);

            MednafenFolder = (from m in db.Paths
                              select m.mednafenExe).SingleOrDefault();

            // set the config id
            int actualConfigId = SystemId + 2000000000;

            // take general settings from base config (2000000000) and system specific settings from actual config



            ConfigBaseSettings _config = (from c in db.ConfigBaseSettings
                                          where (c.ConfigId == actualConfigId)
                                          select c).SingleOrDefault();

            List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList();

            SysConfigObject = new List <ConfigObject>();

            foreach (var x in sysConfigObject)
            {
                var  systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode);
                bool isValid = true;
                foreach (var sc in systems)
                {
                    if (x.Key.StartsWith(sc.systemCode + "__"))
                    {
                        isValid = false;
                        break;
                    }
                }
                if (isValid == true)
                {
                    SysConfigObject.Add(x);
                }
            }


            // if option is enabled save system specific config for this system
            if (Global.saveSystemConfigs == true)
            {
                if (SystemCode == "pcecd")
                {
                    SystemCode = "pce";
                }

                SaveSystemConfigToDisk(SystemCode, SysConfigObject);
            }


            // build actual config list
            //ConfObject = new List<ConfigObject>();
            //ConfObject.AddRange(GenConfigObject);
            //ConfObject.AddRange(SysConfigObject);

            /*
             * if (_config.isEnabled == true)
             * {
             *  Config = _config;
             * }
             * else
             * {
             *  Config = (from c in db.ConfigBaseSettings
             *            where c.ConfigId == 2000000000
             *            select c).SingleOrDefault();
             * }
             */


            // get netplay
            Netplay = (from n in db.ConfigNetplaySettings
                       where n.ConfigNPId == 1
                       select n).SingleOrDefault();



            // get server
            Server = (from s in db.ConfigServerSettings
                      where s.ConfigServerId == Global.serverSelected
                      select s).SingleOrDefault();

            // get overide server settings (password and gamekey from custom
            ServerOveride = (from s in db.ConfigServerSettings
                             where s.ConfigServerId == 100
                             select s).SingleOrDefault();
        }
Esempio n. 11
0
        // Constructor
        public GameLauncher(int gameId)
        {
            db = new MyDbContext();

            GameId = gameId;

            // get Game object
            Game game = (from g in db.Game
                         where g.gameId == gameId
                         select g).SingleOrDefault();

            ConfigId = game.configId;
            RomPath  = game.gamePath;
            RomName  = game.gameName;

            // get globals
            Global = (from g in db.GlobalSettings
                      where g.settingsId == 1
                      select g).SingleOrDefault();

            SystemId = game.systemId;

            // do PSX sbi check and check whether game file actually exists (as it might have been renamed)
            if (SystemId == 9 && File.Exists(game.gamePath))
            {
                // get all implied files from othe cue/m3u that is in the database
                string       cuePath     = game.gamePath; // this is never relative with disc-based games
                DiscGameFile originalCue = new DiscGameFile(cuePath, 9);

                List <DiscGameFile> imageFiles = new List <DiscGameFile>(); // DiscScan.ParseTrackSheetForImageFiles(new DiscGameFile(cuePath, 9), 9);

                // check whether m3u
                if (originalCue.Extension.ToLower() == ".m3u")
                {
                    // get all cue files
                    var allc = DiscScan.ParseTrackSheet(originalCue, CueType.m3u, SystemId);
                    foreach (var g in allc)
                    {
                        imageFiles.Add(g);
                    }
                }
                else
                {
                    // standard cue file
                    imageFiles.Add(originalCue);
                }

                // iterate through each image and check for serial number
                for (int i = 0; i < imageFiles.Count; i++)
                {
                    string serial = MedDiscUtils.GetPSXSerial(imageFiles[i].FullPath);

                    if (serial == null || serial == "")
                    {
                        continue;
                    }

                    // add serial to imageFiles
                    imageFiles[i].ExtraInfo = serial;
                }

                // if imageFile has only one entry, then this matches originalCue
                if (imageFiles.Count == 1)
                {
                    if (PsxSBI.IsSbiAvailable(imageFiles.First().ExtraInfo) == true)
                    {
                        // sbi is available - check whether sbi already exists
                        string sbipath = imageFiles.First().FullPath.Replace(imageFiles.First().Extension, ".sbi");

                        //if (!File.Exists(imageFiles.First().FolderPath + "\\" + imageFiles.First().FileName.Replace(imageFiles.First().Extension, "") + ".sbi"))

                        if (!File.Exists(sbipath))
                        {
                            var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n",
                                                                         "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO);

                            //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n",
                            //    "SBI Patch Needed - " + imageFiles.First().FileName, MessageBoxButton.YesNo, MessageBoxImage.Question);

                            if (result == MessagePopper.ReturnResult.Affirmative)
                            {
                                // copy sbi file to folder (named the same as the cue file)
                                originalCue.ExtraInfo = imageFiles.First().ExtraInfo;

                                //PsxSBI.InstallSBIFile(originalCue);
                                PsxSBI.InstallSBIFile(imageFiles.First());
                            }
                        }
                    }
                }

                // if imageFiles has multiple entries - it will have come from an m3u file
                if (imageFiles.Count > 1)
                {
                    // create an array of m3u cue files
                    string[] cues = File.ReadAllLines(originalCue.FullPath);

                    // loop through
                    for (int image = 0; image < imageFiles.Count; image++)
                    {
                        if (PsxSBI.IsSbiAvailable(imageFiles[image].ExtraInfo) == true)
                        {
                            // sbi is available - prompt user
                            if (!File.Exists(imageFiles[image].FolderPath + "\\" + imageFiles[image].FileName.Replace(imageFiles[image].Extension, "") + ".sbi"))
                            {
                                var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n",
                                                                             "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO);

                                //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n",
                                //"SBI Patch Needed - " + imageFiles[image].FileName + imageFiles[image].Extension, MessageBoxButton.YesNo, MessageBoxImage.Question);

                                if (result == MessagePopper.ReturnResult.Affirmative)
                                {
                                    // copy sbi file to folder (named the same as the cue file)
                                    DiscGameFile d = new DiscGameFile(cues[image], 9);
                                    d.ExtraInfo = imageFiles[image].ExtraInfo;

                                    PsxSBI.InstallSBIFile(d);
                                }
                            }
                        }
                    }
                }
            }

            // logic for faust & fast
            if (game.systemId == 12)
            {
                if (Global.enableSnes_faust == true)
                {
                    SystemId = 16;
                    //MessageBoxResult result = MessageBox.Show("FAUST DETECTED");
                }
                else
                {
                    SystemId = game.systemId;
                }
            }
            if (game.systemId == 7 || game.systemId == 18)
            {
                if (Global.enablePce_fast == true)
                {
                    SystemId = 17;
                }
                else
                {
                    SystemId = 7;
                }
            }

            gSystem    = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single();
            SystemCode = gSystem.systemCode;



            RomFolder = GetRomFolder(SystemId, db);

            MednafenFolder = (from m in db.Paths
                              select m.mednafenExe).SingleOrDefault();

            // set the config id
            int actualConfigId = SystemId + 2000000000;

            // take general settings from base config (2000000000) and system specific settings from actual config



            ConfigBaseSettings _config = (from c in db.ConfigBaseSettings
                                          where (c.ConfigId == actualConfigId)
                                          select c).SingleOrDefault();

            List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList();

            SysConfigObject = new List <ConfigObject>();

            foreach (var x in sysConfigObject)
            {
                var  systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode);
                bool isValid = true;
                foreach (var sc in systems)
                {
                    if (x.Key.StartsWith(sc.systemCode + "__"))
                    {
                        isValid = false;
                        break;
                    }
                }
                if (isValid == true)
                {
                    SysConfigObject.Add(x);
                }
            }


            // if option is enabled save system specific config for this system
            if (Global.saveSystemConfigs == true)
            {
                if (SystemCode == "pcecd")
                {
                    SystemCode = "pce";
                }

                SaveSystemConfigToDisk(SystemCode, SysConfigObject);
            }


            // build actual config list
            //ConfObject = new List<ConfigObject>();
            //ConfObject.AddRange(GenConfigObject);
            //ConfObject.AddRange(SysConfigObject);

            /*
             * if (_config.isEnabled == true)
             * {
             *  Config = _config;
             * }
             * else
             * {
             *  Config = (from c in db.ConfigBaseSettings
             *            where c.ConfigId == 2000000000
             *            select c).SingleOrDefault();
             * }
             */


            // get netplay
            Netplay = (from n in db.ConfigNetplaySettings
                       where n.ConfigNPId == 1
                       select n).SingleOrDefault();



            // get server
            Server = (from s in db.ConfigServerSettings
                      where s.ConfigServerId == Global.serverSelected
                      select s).SingleOrDefault();

            // get overide server settings (password and gamekey from custom
            ServerOveride = (from s in db.ConfigServerSettings
                             where s.ConfigServerId == 100
                             select s).SingleOrDefault();
        }
Esempio n. 12
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();
                }
            }
        }
Esempio n. 13
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 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;
            }
        }
Esempio n. 14
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();
                }
            }
        }
Esempio n. 15
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;
            }
        }