/// <summary> /// Starts a singleplayer mission. /// </summary> /// <param name="scenario">The internal name of the scenario.</param> /// <param name="requiresAddon">True if the mission is for Firestorm / Enhanced Mode.</param> private void LaunchMission(Mission mission) { bool copyMapsToSpawnmapINI = ClientConfiguration.Instance.CopyMissionsToSpawnmapINI; // Gather global flag information var globalFlagInfo = new Dictionary <int, bool>(); if (mission.UsedGlobalVariables.Length > 0) { for (int i = 0; i < mission.UsedGlobalVariables.Length && i < MAX_GLOBAL_COUNT; i++) { string globalFlagName = mission.UsedGlobalVariables[i]; CampaignGlobalVariable globalVariable = CampaignHandler.Instance.GlobalVariables.Find(gv => gv.InternalName == globalFlagName); if (globalVariable != null) { // Global flag values default to disabled/false by default, // so we only need to care about enabled flags if (globalVariableValues[i].SelectedIndex > 0) { string flagIndex = globalVariable.Index.ToString(CultureInfo.InvariantCulture); globalFlagInfo.Add(globalVariable.Index, true); } } } } CampaignHandler.Instance.WriteFilesForMission(mission, trbDifficultySelector.Value, globalFlagInfo); string difficultyName = DifficultyNames[trbDifficultySelector.Value]; UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value; UserINISettings.Instance.SaveSettings(); ((MainMenuDarkeningPanel)Parent).Hide(); discordHandler?.UpdatePresence(mission.GUIName, difficultyName, mission.IconPath, true); GameProcessLogic.GameProcessExited += GameProcessExited_Callback; GameProcessLogic.StartGameProcess(new GameSessionManager( new GameSessionInfo(GameSessionType.SINGLEPLAYER, DateTime.Now.Ticks, mission.InternalName, mission.Side, (DifficultyRank)(trbDifficultySelector.Value + 1), globalFlagInfo, isCheater), WindowManager.AddCallback)); }
/// <summary> /// Configures the preconditions / globals UI for a mission. /// </summary> /// <param name="mission">The mission. Can be null.</param> private void PreconditionUIConfig(Mission mission) { lblPreconditionsHeader.Disable(); for (int i = 0; i < MAX_GLOBAL_COUNT; i++) { globalVariableNames[i].Disable(); globalVariableValues[i].Disable(); } tbMissionDescription.Height = globalVariableValues[0].Bottom - tbMissionDescription.Y; if (mission != null && mission.UsedGlobalVariables.Length > 0) { lblPreconditionsHeader.Enable(); for (int i = 0; i < mission.UsedGlobalVariables.Length && i < MAX_GLOBAL_COUNT; i++) { CampaignGlobalVariable global = CampaignHandler.Instance.GlobalVariables.Find(gv => gv.InternalName == mission.UsedGlobalVariables[i]); globalVariableNames[i].Text = global.UIName; globalVariableNames[i].TextColor = UISettings.ActiveSettings.TextColor; globalVariableNames[i].Enable(); bool disabledSelectable = global.IsDisabledUnlocked || global.DisableOptionFreeUnlock; bool enabledSelectable = global.IsEnabledUnlocked; if (disabledSelectable) { globalVariableValues[i].Items[0].Text = global.UIDisabledOption ?? "No"; } else { globalVariableValues[i].Items[0].Text = "Option not unlocked"; } if (enabledSelectable) { globalVariableValues[i].Items[1].Text = global.UIEnabledOption ?? "Yes"; } else { globalVariableValues[i].Items[1].Text = "Option not unlocked"; } globalVariableValues[i].Items[0].Selectable = disabledSelectable; globalVariableValues[i].Items[1].Selectable = enabledSelectable; globalVariableValues[i].SelectedIndex = 0; if (global.IsEnabledUnlocked) { if (!global.IsDisabledUnlocked || global.EnabledThroughPreviousScenario) { globalVariableValues[i].SelectedIndex = 1; } } if (global.HideIfNotEnabledUnlocked) { globalVariableValues[i].Items[0].Text = "-"; globalVariableValues[i].Items[1].Text = "-"; globalVariableNames[i].Text = "Unknown Condition (not yet unlocked)"; globalVariableNames[i].TextColor = UISettings.ActiveSettings.DisabledItemColor; } globalVariableValues[i].Enable(); } int preconditionsHeaderY = mission.UsedGlobalVariables.Length >= MAX_GLOBAL_COUNT ? globalVariableNames[0].Y : globalVariableNames[mission.UsedGlobalVariables.Length - 1].Y; preconditionsHeaderY -= UIDesignConstants.CONTROL_VERTICAL_MARGIN * 3; lblPreconditionsHeader.Y = preconditionsHeaderY; lblPreconditionsHeader.Enable(); tbMissionDescription.Height = lblPreconditionsHeader.Y - (UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2) - tbMissionDescription.Y; } }