Example #1
0
        public JzIntvSettingsPageViewModel()
        {
            _emulatorPath = JzIntvLauncherConfiguration.Instance.EmulatorPath;
            _execRomPath  = Properties.Settings.Default.ExecRomPath;
            _gromRomPath  = Properties.Settings.Default.GromRomPath;
            _ecsRomPath   = Properties.Settings.Default.EcsRomPath;

            _defaultKeyboardConfigPath = Properties.Settings.Default.DefaultKeyboardConfigPath;
            _initialKeyboardMap        = KeyboardMapHelpers.FromSettingString(Properties.Settings.Default.InitialKeyboardMap);
            var maps = new[] { KeyboardMap.Default, KeyboardMap.LeftControllerOnly, KeyboardMap.EcsKeyboard };

            AvailableKeyboardMaps         = new ObservableCollection <KeyboardMapViewModel>(maps.Select(m => new KeyboardMapViewModel(m)));
            _selectedKeyboardMapViewModel = AvailableKeyboardMaps.First(m => m.KeyboardMap == _initialKeyboardMap);

            _jzIntvJoystick0Config = Properties.Settings.Default.Joystick0Config;
            _jzIntvJoystick1Config = Properties.Settings.Default.Joystick1Config;
            _jzIntvJoystick2Config = Properties.Settings.Default.Joystick2Config;
            _jzIntvJoystick3Config = Properties.Settings.Default.Joystick3Config;

            _jzIntvCgc0ConfigPath = Properties.Settings.Default.ClassicGameController0ConfigPath;
            _jzIntvCgc1ConfigPath = Properties.Settings.Default.ClassicGameController1ConfigPath;

            var resolutions = Enum.GetValues(typeof(DisplayResolution)).Cast <DisplayResolution>().Distinct();

            AvailableDisplayResolutions = new ObservableCollection <DisplayResolutionViewModel>(resolutions.Select(r => new DisplayResolutionViewModel(r)));
            var resolutionFromSettings = DisplayResolutionHelpers.FromLongCommandLineArgumentString(Properties.Settings.Default.DisplaySize);

            _selectedDisplayResolutionViewModel = AvailableDisplayResolutions.First(r => r.Resolution == resolutionFromSettings);
            _jzIntvDisplaySize = _selectedDisplayResolutionViewModel.DisplayResolution;

            var displayModes = Enum.GetValues(typeof(DisplayMode)).Cast <DisplayMode>().Distinct();

            AvailableDisplayModes = new ObservableCollection <DisplayModeViewModel>(displayModes.Select(m => new DisplayModeViewModel(m)));
            var modeFromSettings = DisplayModeHelpers.FromSettingString(Properties.Settings.Default.DisplayMode);

            _selectedDisplayModeViewModel = AvailableDisplayModes.First(m => m.DisplayMode == modeFromSettings);
            _jzIntvDisplayMode            = _selectedDisplayModeViewModel.Mode;

            _enableIntellivoice = EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableIntellivoice);
            _enableEcs          = EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableEcs);
            _enableJlp          = EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableJlp);

            _commandLineMode = CommandLineModeHelpers.FromSettingsString(Properties.Settings.Default.CommandLineMode);

            if ((_lastSelectedPageIndex < 0) && !ConfigurationCommandGroup.AreRequiredEmulatorPathsValid(false))
            {
                _lastSelectedPageIndex = 1;
            }

            _status = Commands.ConfigurationCommandGroup.GetConfigurationStatus(true);
            UpdateStatusColor();

            Properties.Settings.Default.PropertyChanged += HandleEmulatorSettingsChanged;
        }
Example #2
0
        private static IDictionary <CommandLineArgument, object> GetCommandLineOptionsForRom(ProgramDescription programDescription)
        {
            var options           = new Dictionary <CommandLineArgument, object>();
            var forceSetting      = false;
            var commandLineMode   = CommandLineModeHelpers.FromSettingsString(Properties.Settings.Default.CommandLineMode);
            var customCommandLine = commandLineMode == CommandLineMode.Custom;
            var useRomSettingsWithCustomCommandLine = customCommandLine && Properties.Settings.Default.UseROMFeatureSettingsWithCustomCommandLine;

            if (customCommandLine && !string.IsNullOrWhiteSpace(Properties.Settings.Default.CustomCommandLine))
            {
                options[CommandLineArgument.Custom] = Properties.Settings.Default.CustomCommandLine;
            }

            // EXEC ROM argument
            if (!customCommandLine && !string.IsNullOrWhiteSpace(Properties.Settings.Default.ExecRomPath) && ConfigurationCommandGroup.IsExecRomPathvalid(Properties.Settings.Default.ExecRomPath))
            {
                var execPath = ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.ExecRomPath);
                options[CommandLineArgument.ExecPath] = execPath;
            }

            // GROM ROM argument
            if (!customCommandLine && !string.IsNullOrWhiteSpace(Properties.Settings.Default.GromRomPath) && ConfigurationCommandGroup.IsGromRomPathValid(Properties.Settings.Default.GromRomPath))
            {
                var gromPath = ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.GromRomPath);
                options[CommandLineArgument.GromPath] = gromPath;
            }

            // ECS ROM argument
            if (!customCommandLine && !string.IsNullOrWhiteSpace(Properties.Settings.Default.EcsRomPath) && ConfigurationCommandGroup.IsEcsRomPathValid(Properties.Settings.Default.EcsRomPath))
            {
                var ecsPath = ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.EcsRomPath);
                options[CommandLineArgument.EcsPath] = ecsPath;
            }

            // ECS argument
            var enableEcs = false;

            forceSetting = false;
            switch (EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableEcs))
            {
            case EnableFeature.Always:
                if (!customCommandLine)
                {
                    enableEcs = true;
                }
                break;

            case EnableFeature.UseRomSetting:
                enableEcs = programDescription.Features.Ecs > EcsFeatures.Tolerates;
                if (customCommandLine)
                {
                    enableEcs &= useRomSettingsWithCustomCommandLine;
                }
                break;

            case EnableFeature.Never:
                if (!customCommandLine)
                {
                    forceSetting = true;
                }
                break;

            default:
                break;
            }
            if (enableEcs || forceSetting)
            {
                options[CommandLineArgument.EnableEcs] = enableEcs;
            }

            // Intellivoice argument
            var enableIntellivoice = false;

            forceSetting = false;
            switch (EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableIntellivoice))
            {
            case EnableFeature.Always:
                if (!customCommandLine)
                {
                    enableIntellivoice = true;
                }
                break;

            case EnableFeature.UseRomSetting:
                enableIntellivoice = programDescription.Features.Intellivoice > FeatureCompatibility.Tolerates;
                if (customCommandLine)
                {
                    enableIntellivoice &= useRomSettingsWithCustomCommandLine;
                }
                break;

            case EnableFeature.Never:
                if (!customCommandLine)
                {
                    forceSetting = true;
                }
                break;

            default:
                break;
            }
            if (enableIntellivoice || forceSetting)
            {
                options[CommandLineArgument.EnableIntellivoice] = enableIntellivoice;
            }

            // JLP argument
            var enableJlp = false;

            forceSetting = false;
            switch (EnableFeatureHelpers.FromSettingString(Properties.Settings.Default.EnableJlp))
            {
            case EnableFeature.Always:
                if (!customCommandLine)
                {
                    enableJlp = true;
                }
                break;

            case EnableFeature.UseRomSetting:
                enableJlp = programDescription.Features.Jlp > JlpFeatures.Incompatible;
                if (customCommandLine)
                {
                    enableJlp &= useRomSettingsWithCustomCommandLine;
                }
                break;

            case EnableFeature.Never:
            default:
                break;
            }
            if (enableJlp)
            {
                options[CommandLineArgument.Jlp] = enableJlp;
                if (enableJlp && (programDescription.Features.JlpFlashMinimumSaveSectors > 0))
                {
                    var jlpSavegame = System.IO.Path.ChangeExtension(programDescription.Rom.RomPath, ProgramFileKind.SaveData.FileExtension());
                    options[CommandLineArgument.JlpSaveGamePath] = jlpSavegame;
                }
            }

            // Locutus argument
            if (!customCommandLine && (programDescription.Rom.Format == INTV.Core.Model.RomFormat.Luigi))
            {
                options[CommandLineArgument.Locutus] = true;
            }

            // Mute argument
            if (!customCommandLine && Properties.Settings.Default.MuteAudio)
            {
                options[CommandLineArgument.AudioRate] = 0;
            }

            // Display mode and resolution arguments
            if (!customCommandLine)
            {
                var displayMode       = DisplayMode.Default;
                var displayModeString = Properties.Settings.Default.DisplayMode;
                if (!string.IsNullOrWhiteSpace(displayModeString))
                {
                    displayMode = DisplayModeHelpers.FromSettingString(displayModeString);
                    options[CommandLineArgument.Fullscreen] = displayMode;
                }
                if (displayMode != DisplayMode.Fullscreen)
                {
                    var displaySizeString = Properties.Settings.Default.DisplaySize;
                    if (!string.IsNullOrWhiteSpace(displaySizeString))
                    {
                        options[CommandLineArgument.DisplaySize] = DisplayResolutionHelpers.FromLongCommandLineArgumentString(displaySizeString);
                    }
                }
                else
                {
                    var mainScreenInfo = VisualHelpers.GetPrimaryDisplayInfo();
                    var resolution     = string.Format("{0}x{1},{2}bpp", mainScreenInfo.Item1, mainScreenInfo.Item2, mainScreenInfo.Item3);
                    options[CommandLineArgument.DisplaySize] = resolution;
                }
            }

            // Keyboard hackfile argument
            if (!customCommandLine && !string.IsNullOrWhiteSpace(Properties.Settings.Default.DefaultKeyboardConfigPath))
            {
                var hackfile = ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.DefaultKeyboardConfigPath);
                if (ConfigurationCommandGroup.IsPathValid(hackfile))
                {
                    options[CommandLineArgument.KeyboardHackFile] = hackfile;
                }
            }

            // Keyboard map argument
            if (!customCommandLine)
            {
                var keyboardMap = KeyboardMapHelpers.FromSettingString(Properties.Settings.Default.InitialKeyboardMap);
                if (Properties.Settings.Default.UseEcsKeymapForEcsRoms && (programDescription.Features.Ecs > EcsFeatures.Tolerates))
                {
                    keyboardMap = KeyboardMap.EcsKeyboard;
                }
                if (keyboardMap != KeyboardMap.Default)
                {
                    options[CommandLineArgument.KeyboardMap] = keyboardMap;
                }
            }

            // Joystick configuration file arguments
            if (!customCommandLine)
            {
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Joystick0Config))
                {
                    options[CommandLineArgument.Joystick0Configuration] = Properties.Settings.Default.Joystick0Config;
                }
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Joystick1Config))
                {
                    options[CommandLineArgument.Joystick1Configuration] = Properties.Settings.Default.Joystick1Config;
                }
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Joystick2Config))
                {
                    options[CommandLineArgument.Joystick2Configuration] = Properties.Settings.Default.Joystick2Config;
                }
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Joystick3Config))
                {
                    options[CommandLineArgument.Joystick3Configuration] = Properties.Settings.Default.Joystick3Config;
                }
            }

            // Enable mouse argument
            if (!customCommandLine && Properties.Settings.Default.EnableMouse)
            {
                options[CommandLineArgument.EnableMouse] = true;
            }

            // Classic Game Controller configuration arguments
            if (!customCommandLine)
            {
                var cgcPath = string.IsNullOrWhiteSpace(Properties.Settings.Default.ClassicGameController0ConfigPath) ? string.Empty : ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.ClassicGameController0ConfigPath);
                if (ConfigurationCommandGroup.IsPathValid(cgcPath))
                {
                    options[CommandLineArgument.ClassicGameControllerMaster] = cgcPath;
                }
                cgcPath = string.IsNullOrWhiteSpace(Properties.Settings.Default.ClassicGameController1ConfigPath) ? string.Empty : ConfigurationCommandGroup.ResolvePathSetting(Properties.Settings.Default.ClassicGameController1ConfigPath);
                if (ConfigurationCommandGroup.IsPathValid(cgcPath))
                {
                    options[CommandLineArgument.ClassicGameControllerEcs] = cgcPath;
                }
            }

            if (!customCommandLine && (commandLineMode == CommandLineMode.AutomaticWithAdditionalArguments) && !string.IsNullOrWhiteSpace(Properties.Settings.Default.AdditionalCommandLineArguments))
            {
                options[CommandLineArgument.AdditionalArguments] = Properties.Settings.Default.AdditionalCommandLineArguments;
            }

            return(options);
        }