Ejemplo n.º 1
0
        public void Run(EntryModel entry)
        {
            _currentEntry = entry;
            _lastRanEntry = _entries.GetLastRan();

            if (_lastRanEntry == null)
            {
                _logger.LogInfo("No version was ever ran. Running this and setting it as main version.");

                _lastRanEntry = _currentEntry;
                SwitchFiles();

                _entries.MarkLastRan(_currentEntry);
                _registryService.Update(_currentEntry);
                _entries.SaveEntries();

                LaunchGame();
            }
            else if (_lastRanEntry.Platform.EqualsIgnoreCase(_currentEntry.Platform) &&
                     _lastRanEntry.Path.EqualsIgnoreCase(_currentEntry.Path) &&
                     _lastRanEntry.IsExpansion == _currentEntry.IsExpansion)
            {
                _logger.LogInfo("Running the same version, no change needed.");

                // Will be using the CurrentEntry in this situation since even though the
                // current entry is equal to the last ran entry, the launch flags may differ
                _lastRanEntry = _currentEntry;

                // The user can launch two different entries that are identical (Except for flags since
                // you may have different flags for the same platform) without switching files completely.
                LaunchGame();
            }
            else
            {
                _logger.LogInfo("A different version has been selected. Switching.");

                // If there is an existing process running, do not allow a switch.
                // Only identical versions can be launched.
                if (_processManager.AreProcessesRunning)
                {
                    MessageBox.Show("Another process related to another game mode/version is running.");
                    return;
                }

                SwitchFiles();
                _entries.SwapLastRan(_lastRanEntry, _currentEntry);
                _lastRanEntry = _currentEntry;
                _registryService.Update(_currentEntry);
                _entries.SaveEntries();

                LaunchGame();
            }
        }