Exemplo n.º 1
0
        private void manageGameInstancesMenuItem_Click(object sender, EventArgs e)
        {
            var old_instance = Instance.CurrentInstance;
            var result       = new ManageGameInstancesDialog(!actuallyVisible, currentUser).ShowDialog();

            if (result == DialogResult.OK && !Equals(old_instance, Instance.CurrentInstance))
            {
                ManageMods.ModGrid.ClearSelection();
                CurrentInstanceUpdated(true);
            }
        }
Exemplo n.º 2
0
        private bool InstancePromptAtStart()
        {
            Hide();
            var result = new ManageGameInstancesDialog(!actuallyVisible, currentUser).ShowDialog();

            if (result != DialogResult.OK)
            {
                Application.Exit();
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        private void manageGameInstancesMenuItem_Click(object sender, EventArgs e)
        {
            var old_instance = CurrentInstance;
            var result       = new ManageGameInstancesDialog(!actuallyVisible, currentUser).ShowDialog();

            if (result == DialogResult.OK && !Equals(old_instance, CurrentInstance))
            {
                try
                {
                    ManageMods.ModGrid.ClearSelection();
                    CurrentInstanceUpdated(true);
                }
                catch (RegistryInUseKraken kraken)
                {
                    // Couldn't get the lock, revert to previous instance
                    errorDialog.ShowErrorDialog(kraken.ToString());
                    manager.CurrentInstance = old_instance;
                    CurrentInstanceUpdated(false);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Open an file dialog to search for a KSP instance, like in <code>ManageKspInstances</code>.
        /// </summary>
        private void buttonInstancePathSelection_Click(object sender, EventArgs e)
        {
            // Create a new FileDialog object
            OpenFileDialog instanceDialog = new OpenFileDialog()
            {
                AddExtension     = false,
                CheckFileExists  = false,
                CheckPathExists  = false,
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = ManageGameInstancesDialog.GameFolderFilter(manager),
                Multiselect      = false
            };

            // Show the FileDialog and let the user search for the KSP directory.
            if (instanceDialog.ShowDialog() != DialogResult.OK || !File.Exists(instanceDialog.FileName))
            {
                return;
            }

            // Write the path to the textbox
            textBoxClonePath.Text = Path.GetDirectoryName(instanceDialog.FileName);
        }
Exemplo n.º 5
0
        public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
        {
            log.Info("Starting the GUI");
            commandLineArgs = cmdlineArgs;

            Configuration.IConfiguration mainConfig = ServiceLocator.Container.Resolve <Configuration.IConfiguration>();

            // If the language is not set yet in the config, try to save the current language.
            // If it isn't supported, it'll still be null afterwards. Doesn't matter, .NET handles the resource selection.
            // Once the user chooses a language in the settings, the string will be no longer null, and we can change
            // CKAN's language here before any GUI components are initialized.
            if (string.IsNullOrEmpty(mainConfig.Language))
            {
                string runtimeLanguage = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag;
                mainConfig.Language = runtimeLanguage;
            }
            else
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(mainConfig.Language);
            }

            InitializeComponent();

            Instance = this;

            currentUser = new GUIUser(this, this.Wait);
            manager     = mgr ?? new GameInstanceManager(currentUser);

            controlFactory = new ControlFactory();

            // React when the user clicks a tag or filter link in mod info
            ModInfo.OnChangeFilter += ManageMods.Filter;

            // Replace mono's broken, ugly toolstrip renderer
            if (Platform.IsMono)
            {
                menuStrip1.Renderer = new FlatToolStripRenderer();
                fileToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                settingsToolStripMenuItem.DropDown.Renderer = new FlatToolStripRenderer();
                helpToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                minimizedContextMenuStrip.Renderer          = new FlatToolStripRenderer();
            }

            // Initialize all user interaction dialogs.
            RecreateDialogs();

            // We want to check if our current instance is null first,
            // as it may have already been set by a command-line option.
            if (CurrentInstance == null && manager.GetPreferredInstance() == null)
            {
                Hide();

                var result = new ManageGameInstancesDialog(!actuallyVisible, currentUser).ShowDialog();
                if (result == DialogResult.Cancel || result == DialogResult.Abort)
                {
                    Application.Exit();
                    return;
                }
            }

            configuration = GUIConfiguration.LoadOrCreateConfiguration
                            (
                Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml")
                            );

            // Check if there is any other instances already running.
            // This is not entirely necessary, but we can show a nicer error message this way.
            try
            {
#pragma warning disable 219
                var lockedReg = RegistryManager.Instance(CurrentInstance).registry;
#pragma warning restore 219
            }
            catch (RegistryInUseKraken kraken)
            {
                errorDialog.ShowErrorDialog(kraken.ToString());
                return;
            }

            tabController = new TabController(MainTabControl);
            tabController.ShowTab("ManageModsTabPage");

            if (!showConsole)
            {
                Util.HideConsoleWindow();
            }

            // Disable the modinfo controls until a mod has been choosen. This has an effect if the modlist is empty.
            ActiveModInfo = null;

            // WinForms on Mac OS X has a nasty bug where the UI thread hogs the CPU,
            // making our download speeds really slow unless you move the mouse while
            // downloading. Yielding periodically addresses that.
            // https://bugzilla.novell.com/show_bug.cgi?id=663433
            if (Platform.IsMac)
            {
                var timer = new Timer {
                    Interval = 2
                };
                timer.Tick += (sender, e) => { Thread.Yield(); };
                timer.Start();
            }

            // Set the window name and class for X11
            if (Platform.IsX11)
            {
                HandleCreated += (sender, e) => X11.SetWMClass("CKAN", "CKAN", Handle);
            }

            Application.Run(this);

            var registry = RegistryManager.Instance(Manager.CurrentInstance);
            registry?.Dispose();
        }