示例#1
0
        private void ctlWindowHeight_Leave(object sender, EventArgs e)
        {
            // Update the slider (and indirectly, the width textbox)
            int newHeight;

            if (int.TryParse(ctlWindowHeight.Text, out newHeight))
            {
                int  width;
                bool widthSuccess = int.TryParse(ctlWindowWidth.Text, out width);

                int newWidth = 0;
                if (widthSuccess && DfoLauncher.GetHeightFromWidth(width) == newHeight)
                {
                    newWidth = width;
                }
                else
                {
                    newWidth = DfoLauncher.GetWidthFromHeight(newHeight);
                }

                newWidth = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum);

                ctlWindowSizeSlider.Value = newWidth;

                // Set the text to a canonical text for the width
                ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value).ToString();
            }
            else
            {
                // invalid input, reset text to the slider value
                ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value).ToString();
            }
        }
示例#2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="args"></param>
		/// <exception cref="Ndesk.Options.OptionException">Badly-formatted arguments</exception>
		public CommandLineArgs( string[] args )
		{
			if ( args.Length == 0 )
			{
				Gui = true;
			}
			else
			{
				Gui = false;
			}

			ShowHelp = false;
			ShowVersion = false;

			OptionSet optionSet = GetOptionSet();

			optionSet.Parse( args );

			// Set width or height if the user only explicitly set one. This prevents width from being
			// specified on command-line and height being specified in saved settings
			if ( Settings.GameWindowWidth != null && Settings.GameWindowHeight == null )
			{
				Settings.GameWindowHeight = DfoLauncher.GetHeightFromWidth( Settings.GameWindowWidth.Value );
			}
			else if ( Settings.GameWindowWidth == null && Settings.GameWindowHeight != null )
			{
				Settings.GameWindowWidth = DfoLauncher.GetWidthFromHeight( Settings.GameWindowHeight.Value );
			}
		}
示例#3
0
        private void ctlWindowHeight_TextChanged(object sender, EventArgs e)
        {
            m_heightBeingEdited = true;
            // Update the width textbox
            int newHeight;

            if (int.TryParse(ctlWindowHeight.Text, out newHeight))
            {
                //GameWindowStartingWidth = GetWidthFromHeight( newHeight );
                if (!m_widthBeingEdited)
                {
                    int  width;
                    bool widthSuccess = int.TryParse(ctlWindowWidth.Text, out width);
                    if (!widthSuccess || DfoLauncher.GetHeightFromWidth(width) != newHeight)
                    {
                        ctlWindowWidth.Text = DfoLauncher.GetWidthFromHeight(newHeight).ToString();

                        // Update the slider
                        int newWidth;
                        if (int.TryParse(ctlWindowWidth.Text, out newWidth))
                        {
                            newWidth = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum);
                            ctlWindowSizeSlider.Value = newWidth;
                        }
                    }
                }
            }
            m_heightBeingEdited = false;
        }
示例#4
0
        private void ctlMainForm_Load(object sender, EventArgs e)
        {
            Logging.Log.Debug("Loading main window.");

            Rectangle primaryScreenSize = Screen.PrimaryScreen.Bounds;

            Logging.Log.DebugFormat("Primary screen size is {0}x{1}",
                                    primaryScreenSize.Width, primaryScreenSize.Height);

            int maxWidth = Math.Min(primaryScreenSize.Width, DfoLauncher.GetWidthFromHeight(primaryScreenSize.Height));

            ctlWindowSizeSlider.Minimum = DfoLauncher.DefaultGameWindowWidth;
            ctlWindowSizeSlider.Maximum = Math.Max(maxWidth, DfoLauncher.DefaultGameWindowWidth);

            Logging.Log.DebugFormat("Allowable game window width: {0}-{1}",
                                    ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum);

            // Initialize window size UI
            ctlWindowSizeSlider_ValueChanged(ctlWindowSizeSlider, EventArgs.Empty);

            // Bind switchable files to checkboxes
            IDictionary <string, CheckBox> switchableFileCheckboxes = GetSwitchableCheckboxes();

            foreach (ISwitchableFile switchableFile in m_parsedArgs.Settings.SwitchableFiles.Values)
            {
                if (switchableFileCheckboxes.ContainsKey(switchableFile.Name))
                {
                    SwitchableFiles.Add(switchableFile.Name,
                                        new CheckboxSwitchableFile(switchableFileCheckboxes[switchableFile.Name],
                                                                   switchableFile));
                }
                else
                {
                    // Hmmm...No UI binding for a switchable file. Add it as a switchable file and let
                    // setting/command-line behavior take effect.
                    SwitchableFiles.Add(switchableFile.Name, new PlainUiSwitchableFile(switchableFile));
                }
            }

            m_savedSettings = SettingsLoader.Load();
            ApplySettingsAndArguments();

            FixSwitchableFilesIfNeeded();

            ctlUsername.Select();
            Logging.Log.Debug("Main window loaded.");
        }
示例#5
0
        private void ctlWindowWidth_TextChanged(object sender, EventArgs e)
        {
            m_widthBeingEdited = true;
            // Update the height textbox
            int newWidth;

            if (int.TryParse(ctlWindowWidth.Text, out newWidth))
            {
                //GameWindowStartingWidth = newWidth;
                if (!m_heightBeingEdited)
                {
                    ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(newWidth).ToString();

                    // Update the slider
                    //newWidth = newWidth.Clamp( ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum );
                    ctlWindowSizeSlider.Value = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum);
                }
            }

            m_widthBeingEdited = false;
        }
示例#6
0
        private void ctlWindowSizeSlider_ValueChanged(object sender, EventArgs e)
        {
            if (!m_widthBeingEdited && !m_heightBeingEdited)
            {
                int  newWidth = ctlWindowSizeSlider.Value;
                int  widthFromTextbox;
                bool textboxHasInt = int.TryParse(ctlWindowWidth.Text, out widthFromTextbox);
                if (!textboxHasInt || widthFromTextbox != newWidth)
                {
                    ctlWindowWidth.Text = newWidth.ToString();
                }

                int newHeight = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value);
                int heightFromTextbox;
                textboxHasInt = int.TryParse(ctlWindowHeight.Text, out heightFromTextbox);
                if (!textboxHasInt || heightFromTextbox != newHeight)
                {
                    ctlWindowHeight.Text = newHeight.ToString();
                }
            }
        }
示例#7
0
 /// <summary>
 /// Autodetects the DFO directory and sets DfoDir.
 /// </summary>
 /// <exception cref="System.IO.IOException">The DFO directory could not be detected.</exception>
 private void AutoDetectDfoDir()
 {
     DfoDir = DfoLauncher.AutoDetectGameDir(Game.DFO);
 }
示例#8
0
 /// <summary>
 /// Tries to figure out where the game directory for the game currently selected is and sets
 /// <c>GameDir</c> to it.
 /// </summary>
 /// <exception cref="System.IO.IOException">The game directory could not be detected.</exception>
 public void AutoDetectGameDir()
 {
     GameDir = DfoLauncher.AutoDetectGameDir(GameToLaunch);
 }