예제 #1
0
        public static ICollection <SwitchableFile> GetSwitchableFiles()
        {
            List <SwitchableFile> switchableFiles = new List <SwitchableFile>();

            SwitchableFile soundpack = new SwitchableFile();

            soundpack.CustomFileArg     = "customsounddir";
            soundpack.DefaultCustomFile = "SoundPacksCustom";
            soundpack.DefaultTempFile   = "SoundPacksOriginal";
            soundpack.Name               = Soundpacks;
            soundpack.NormalFile         = "SoundPacks";
            soundpack.TempFileArg        = "tempsounddir";
            soundpack.WhetherToSwitchArg = "soundswitch";
            soundpack.FileType           = FileType.Directory;

            switchableFiles.Add(soundpack);

            SwitchableFile audioXml = new SwitchableFile();

            audioXml = new SwitchableFile();
            audioXml.CustomFileArg     = "customaudioxml";
            audioXml.DefaultCustomFile = "customaudio.xml";
            audioXml.DefaultTempFile   = "originalaudio.xml";
            audioXml.Name               = AudioXml;
            audioXml.NormalFile         = "audio.xml";
            audioXml.TempFileArg        = "tempaudioxml";
            audioXml.WhetherToSwitchArg = "audioxmlswitch";
            audioXml.FileType           = FileType.RegularFile;

            switchableFiles.Add(audioXml);

            return(switchableFiles);
        }
예제 #2
0
        }                                                                  // options in StartupSettings must be nullable to indicate preference for the default

        public StartupSettings()
        {
            SwitchableFiles = new Dictionary <string, SwitchableFile>();
            SwitchFile      = new Dictionary <string, bool?>();
            ICollection <SwitchableFile> switchableFiles = SwitchableFile.GetSwitchableFiles();

            foreach (SwitchableFile switchableFile in switchableFiles)
            {
                SwitchableFiles.Add(switchableFile.Name, switchableFile);
                SwitchFile.Add(switchableFile.Name, null);
            }
        }
예제 #3
0
        private StartupSettings GetCurrentSettings()
        {
            StartupSettings settings = new StartupSettings();

            if (m_parsedArgs.Settings.DfoDir != null)
            {
                settings.DfoDir = DfoDir;
            }

            foreach (IUiSwitchableFile uiBoundFile in SwitchableFiles.Values)
            {
                SwitchableFile switchableFile = new SwitchableFile(uiBoundFile);
                if (m_parsedArgs.Settings.SwitchableFiles[switchableFile.Name].CustomFile == null)
                {
                    // Custom file was not specified on commmand-line and there is no UI, so the user wants
                    // the default.
                    switchableFile.CustomFile = null;
                }
                if (m_parsedArgs.Settings.SwitchableFiles[switchableFile.Name].TempFile == null)
                {
                    // ditto
                    switchableFile.TempFile = null;
                }

                settings.SwitchableFiles[switchableFile.Name] = switchableFile;
                settings.SwitchFile[switchableFile.Name]      = switchableFile.Switch;
            }

            settings.ClosePopup       = ClosePopup;
            settings.LaunchWindowed   = LaunchWindowed;
            settings.Password         = Password;
            settings.RememberUsername = RememberMe;
            settings.Username         = Username;
            settings.GameWindowWidth  = GameWindowStartingWidth;
            settings.GameWindowHeight = GameWindowStartingHeight;

            return(settings);
        }
예제 #4
0
파일: MainForm.cs 프로젝트: TeoTwawki/DFOCP
        private StartupSettings GetCurrentSettings()
        {
            StartupSettings settings = new StartupSettings();

            if ( m_parsedArgs.Settings.DfoDir != null )
            {
                settings.DfoDir = DfoDir;
            }

            foreach ( IUiSwitchableFile uiBoundFile in SwitchableFiles.Values )
            {
                SwitchableFile switchableFile = new SwitchableFile( uiBoundFile );
                if ( m_parsedArgs.Settings.SwitchableFiles[ switchableFile.Name ].CustomFile == null )
                {
                    // Custom file was not specified on commmand-line and there is no UI, so the user wants
                    // the default.
                    switchableFile.CustomFile = null;
                }
                if ( m_parsedArgs.Settings.SwitchableFiles[ switchableFile.Name ].TempFile == null )
                {
                    // ditto
                    switchableFile.TempFile = null;
                }

                settings.SwitchableFiles[ switchableFile.Name ] = switchableFile;
                settings.SwitchFile[ switchableFile.Name ] = switchableFile.Switch;
            }

            settings.ClosePopup = ClosePopup;
            settings.LaunchWindowed = LaunchWindowed;
            settings.Password = Password;
            settings.RememberUsername = RememberMe;
            settings.Username = Username;
            settings.GameWindowWidth = GameWindowStartingWidth;
            settings.GameWindowHeight = GameWindowStartingHeight;

            return settings;
        }
예제 #5
0
        public static ICollection<SwitchableFile> GetSwitchableFiles()
        {
            List<SwitchableFile> switchableFiles = new List<SwitchableFile>();

            SwitchableFile soundpack = new SwitchableFile();
            soundpack.CustomFileArg = "customsounddir";
            soundpack.DefaultCustomFile = "SoundPacksCustom";
            soundpack.DefaultTempFile = "SoundPacksOriginal";
            soundpack.Name = Soundpacks;
            soundpack.NormalFile = "SoundPacks";
            soundpack.TempFileArg = "tempsounddir";
            soundpack.WhetherToSwitchArg = "soundswitch";
            soundpack.FileType = FileType.Directory;

            switchableFiles.Add( soundpack );

            SwitchableFile audioXml = new SwitchableFile();
            audioXml = new SwitchableFile();
            audioXml.CustomFileArg = "customaudioxml";
            audioXml.DefaultCustomFile = "customaudio.xml";
            audioXml.DefaultTempFile = "originalaudio.xml";
            audioXml.Name = AudioXml;
            audioXml.NormalFile = "audio.xml";
            audioXml.TempFileArg = "tempaudioxml";
            audioXml.WhetherToSwitchArg = "audioxmlswitch";
            audioXml.FileType = FileType.RegularFile;

            switchableFiles.Add( audioXml );

            return switchableFiles;
        }
예제 #6
0
		public OptionSet GetOptionSet()
		{
			OptionSet optionSet = new OptionSet()
			{
				{ "?|h|help", "Show this message and exit.", argExistence => ShowHelp = (argExistence != null) },
				{ "v|version", "Show version information and exit.", argExistence => ShowVersion = (argExistence != null) },
				{ "gui", "Start the GUI with whatever parameters have been supplied.", argExistence => Gui = (argExistence != null) },
				{ "cli", "Explicitly says you want the command-line version to be used.", argExistence => Gui = !(argExistence != null) },
				{ "u|username="******"Username to use when logging in.", argValue => Settings.Username = argValue },
				{ "p|pw|password="******"Password to use when logging in.", argValue => Settings.Password = argValue },
				{ "closepopup", "Close the popup when the game is done. This is the default.", argExistence => Settings.ClosePopup = (argExistence != null) },
				{ "noclosepopup", "Don't close the popup when the game is done.", argExistence => Settings.ClosePopup = !(argExistence != null) },
				{ "window|windowed", "Launch the game in windowed mode.", argExistence => Settings.LaunchWindowed = (argExistence != null) },
				{ "width=", "Width in pixels to start the game window with.", argValue =>
					{
					int intValue = ParseInt(argValue, "width");
					if(intValue <= 0)
					{
						throw new OptionException("Width must be a positive number.", "width");
					}
					Settings.GameWindowWidth = intValue;
					}
				},
				{ "height=", "Height in pixels to start the game window with.", argValue =>
					{
						int intValue = ParseInt(argValue, "height");
						if(intValue <= 0)
						{
							throw new OptionException("Height must be a positive number.", "height");
						}
						Settings.GameWindowHeight = intValue;
					}
				},
				{ "full", "Don't launch the game in windowed mode. This is the default.", argExistence => Settings.LaunchWindowed = !(argExistence != null) },
				{ "dfodir=", "Directory where DFO is. Defaults to the autodetected DFO directory.",
					argValue => { ThrowIfPathNotValid(argValue, "dfodir"); Settings.DfoDir = argValue; } },
				{ "logcookies", "Log authentication cookies. Only useful for debugging.", argExistence =>
					{
						if(argExistence != null)
						{
							Logging.SensitiveDataToLog |= SensitiveData.LoginCookies;
						}
						else
						{
							Logging.SensitiveDataToLog ^= SensitiveData.LoginCookies;
						}
					}
				},
				{ "logall", "Log all sensitive data, including usernames and passwords. Only useful for debugging.",
					argExistence =>
					{
						if(argExistence != null)
						{
							Logging.SensitiveDataToLog = SensitiveData.All;
						}
						else
						{
							Logging.SensitiveDataToLog = SensitiveData.None;
						}
					}
				},
				{ "<>", argValue => // Default handler - Report unrecognized arguments
					{
						string message = string.Format("Unrecognized command-line argument: {0}", argValue);

						// This little hack is necessary because we don't have a console at this time
						// - we don't know if we're doing the GUI or the CLI yet
						m_messages.Add(message);
					}
				}
			};

			// Add the arguments for all switchable files
			foreach ( SwitchableFile switchableFile in Settings.SwitchableFiles.Values )
			{
				// Cannot use switchableFile.Name in the lambdas because the switchableFile
				// variable has only one instance - so the switch and noswitch arguments
				// for all switchables would actually be bound to the last switchable.
				SwitchableFile switchableFileInstance = switchableFile;
				string switchableName = switchableFile.Name;

				optionSet.Add( string.Format( "{0}", switchableFile.WhetherToSwitchArg ),
					string.Format( "Switch {0}", switchableFile.NormalFile ),
					argExistence => Settings.SwitchFile[ switchableName ] = ( argExistence != null ) );

				optionSet.Add( string.Format( "no{0}", switchableFile.WhetherToSwitchArg ),
					string.Format( "Don't switch {0}", switchableFile.NormalFile ),
					argExistence => Settings.SwitchFile[ switchableName ] = !( argExistence != null ) );

				optionSet.Add( string.Format( "{0}=", switchableFile.CustomFileArg ),
					string.Format( "File or directory to switch {0} with. If a relative path is given, it is relative to dfodir. Defaults to {1}.",
					switchableFile.NormalFile, switchableFile.DefaultCustomFile ),
					 argValue =>
					 {
						 ThrowIfPathNotValid( argValue, switchableFileInstance.CustomFileArg );
						 switchableFileInstance.CustomFile = argValue;
					 } );

				optionSet.Add( string.Format( "{0}=", switchableFile.TempFileArg ),
					string.Format( "File or directory to move {0} to while the game is running if switching it. If a relative path is given, it is relative to dfodir. Defaults to {1}.",
					switchableFile.NormalFile, switchableFile.DefaultTempFile ),
					argValue =>
					{
						ThrowIfPathNotValid( argValue, switchableFileInstance.TempFileArg );
						switchableFileInstance.TempFile = argValue;
					} );
			}

			return optionSet;
		}