Esempio n. 1
0
        private static bool CanBrowseAndDownload(object parameter)
        {
            // Since user will browse, we won't know a priori if ECS ROM is needed.
            var canExecute = ConfigurationCommandGroup.AreRequiredEmulatorPathsValid(false);

            return(canExecute);
        }
Esempio n. 2
0
        private static void OnLaunch(object parameter)
        {
            var programDescription = GetProgramDescription(parameter);

            if (CanLaunch(programDescription))
            {
                if (!Properties.Settings.Default.AllowMultipleInstances && Emulator.Instances().Any())
                {
                    INTV.Shared.View.OSMessageBox.Show(Resources.Strings.JzIntvAlreadyRunning, Resources.Strings.LaunchInJzIntvCommand_Failed_Title);
                    return;
                }
                var programName = Resources.Strings.UnknownROM;
                try
                {
                    programName = programDescription.Name;
                    var options    = GetCommandLineOptionsForRom(programDescription);
                    var romPath    = programDescription.Rom.RomPath;
                    var jzIntvPath = ConfigurationCommandGroup.ResolvePathSetting(JzIntvLauncherConfiguration.Instance.EmulatorPath);
                    var jzIntv     = new Emulator(jzIntvPath, LaunchInJzIntvErrorHandler);
                    var process    = RunExternalProgram.CreateProcess(jzIntv.Path);
                    jzIntv.Launch(process, options, programDescription);
                }
                catch (Exception e)
                {
                    var message = string.Format(Resources.Strings.UnableToLaunchJzIntv_Error_Message_Format, programName, e.Message);
                    INTV.Shared.View.OSMessageBox.Show(message, Resources.Strings.UnableToLaunchJzIntv_Error_Title);
                }
            }
        }
Esempio n. 3
0
        private static bool CanLaunch(object parameter)
        {
            var program   = GetProgramDescription(parameter);
            var canLaunch = program != null;

            if (canLaunch)
            {
                canLaunch = (program.Rom != null) && program.Rom.IsValid && ConfigurationCommandGroup.AreRequiredEmulatorPathsValid(program.Features.Ecs == EcsFeatures.Requires);
            }
            return(canLaunch);
        }
Esempio n. 4
0
        private static void OnShowCommandLine(object parameter)
        {
            var programDescription = GetProgramDescription(parameter);

            if (CanLaunch(programDescription))
            {
                var title   = string.Format(Resources.Strings.ShowJzIntvCommandLineCommand_DialogTitle_Format, programDescription.Name);
                var message = string.Format(Resources.Strings.ShowJzIntvCommandLineCommand_DialogMessage_Format, programDescription.Name);
                var dialog  = ReportDialog.Create(title, message);
                dialog.ShowSendEmailButton = false;
                var options     = GetCommandLineOptionsForRom(programDescription);
                var jzIntvPath  = ConfigurationCommandGroup.ResolvePathSetting(JzIntvLauncherConfiguration.Instance.EmulatorPath);
                var commandLine = jzIntvPath + ' ' + options.BuildCommandLineArguments(programDescription.Rom.RomPath, false);
                dialog.ReportText = string.Format(Resources.Strings.ShowJzIntvCommandLineCommand_CommandLineMessage_Format, programDescription.Name, commandLine);
                dialog.ShowDialog(Resources.Strings.ReportErrorDialogButtonText);
            }
        }
Esempio n. 5
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);
        }