Esempio n. 1
0
        private void OpenWorkspace(Workspace workspace)
        {
            if (_currentWorkspace != null && workspace.Identifier != _currentWorkspace.Identifier)
            {
                CloseWorkspace();
            }

            _currentWorkspace = workspace;

            Task.Run(() =>
            {
                // TODO: MEGA HACK XD
                ChaosShell.Invoke(@"Import-Module E:\SourceSDK\SourceRun\SourceRun.psd1");
                ChaosShell.Invoke(
                    $"Set-VWorkspace -Path \"{new FileInfo(_currentWorkspace.LoadedPath).Directory?.FullName}\"");

                // No longer required since we've embedded this into process start

                /**
                 * if (_currentWorkspace.SourceGame != null)
                 *  ChaosShellRaw.InvokeScript(
                 *      $"Set-VProject -Path \"{_currentWorkspace.SourceGame.ContentDir}\"");*/
            });

            WorkspaceTab.Visibility     = Visibility.Visible;
            SaveWorkspaceBtn.IsEnabled  = true;
            CloseWorkspaceBtn.IsEnabled = true;
            Title = $"Chaos Launcher - {_currentWorkspace.Name}";

            // Show tools relating to the Source game,
            // only if the user has actually defined one in Workspace Options.
            if (workspace.SourceGame != null)
            {
                EngineBranch.IsEnabled = true;
                Source2Tab.Visibility  = workspace.SourceGame.IsSource2 ? Visibility.Visible : Visibility.Hidden;
                SourceTab.Visibility   = !workspace.SourceGame.IsSource2 ? Visibility.Visible : Visibility.Hidden;
            }

            // Build the workspace file tree
            FileSelector.BuildTree(_currentWorkspace.Folder);

            // Show Perforce version control if P4 is enabled on the workspace.
            P4Group.Visibility = workspace.PerforceEnabled ? Visibility.Visible : Visibility.Hidden;
        }