public void SelectLocation(Location location, LocationConnection connection) { missionTickBoxes.Clear(); missionRewardTexts.Clear(); locationInfoPanel.ClearChildren(); //don't select the map panel if we're looking at some other tab if (selectedTab == CampaignMode.InteractionType.Map) { SelectTab(CampaignMode.InteractionType.Map); locationInfoPanel.Visible = location != null; } Location prevSelectedLocation = selectedLocation; float prevMissionListScroll = missionList?.BarScroll ?? 0.0f; selectedLocation = location; if (location == null) { return; } int padding = GUI.IntScale(20); var content = new GUILayoutGroup(new RectTransform(locationInfoPanel.Rect.Size - new Point(padding * 2), locationInfoPanel.RectTransform, Anchor.Center), childAnchor: Anchor.TopRight) { Stretch = true, RelativeSpacing = 0.02f, }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), location.Name, font: GUI.LargeFont) { AutoScaleHorizontal = true }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), location.Type.Name, font: GUI.SubHeadingFont); Sprite portrait = location.Type.GetPortrait(location.PortraitId); portrait.EnsureLazyLoaded(); var portraitContainer = new GUICustomComponent(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform), onDraw: (sb, customComponent) => { portrait.Draw(sb, customComponent.Rect.Center.ToVector2(), Color.Gray, portrait.size / 2, scale: Math.Max(customComponent.Rect.Width / portrait.size.X, customComponent.Rect.Height / portrait.size.Y)); }) { HideElementsOutsideFrame = true }; var textContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), portraitContainer.RectTransform, Anchor.Center)) { RelativeSpacing = 0.05f }; if (connection?.LevelData != null) { var biomeLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), TextManager.Get("Biome", fallBackTag: "location"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft); new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), biomeLabel.RectTransform), connection.Biome.DisplayName, textAlignment: Alignment.CenterRight); var difficultyLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), TextManager.Get("LevelDifficulty"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft); new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), difficultyLabel.RectTransform), ((int)connection.LevelData.Difficulty) + " %", textAlignment: Alignment.CenterRight); if (connection.LevelData.HasBeaconStation) { var beaconStationContent = new GUILayoutGroup(new RectTransform(biomeLabel.RectTransform.NonScaledSize, textContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft); string style = connection.LevelData.IsBeaconActive ? "BeaconStationActive" : "BeaconStationInactive"; var icon = new GUIImage(new RectTransform(new Point((int)(beaconStationContent.Rect.Height * 1.2f)), beaconStationContent.RectTransform), style, scaleToFit: true) { Color = MapGenerationParams.Instance.IndicatorColor, HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f), ToolTip = TextManager.Get(connection.LevelData.IsBeaconActive ? "BeaconStationActiveTooltip" : "BeaconStationInactiveTooltip") }; new GUITextBlock(new RectTransform(Vector2.One, beaconStationContent.RectTransform), TextManager.Get("submarinetype.beaconstation", fallBackTag: "beaconstationsonarlabel"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft) { Padding = Vector4.Zero, ToolTip = icon.ToolTip }; } if (connection.LevelData.HasHuntingGrounds) { var huntingGroundsContent = new GUILayoutGroup(new RectTransform(biomeLabel.RectTransform.NonScaledSize, textContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft); var icon = new GUIImage(new RectTransform(new Point((int)(huntingGroundsContent.Rect.Height * 1.5f)), huntingGroundsContent.RectTransform), "HuntingGrounds", scaleToFit: true) { Color = MapGenerationParams.Instance.IndicatorColor, HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f), ToolTip = TextManager.Get("HuntingGroundsTooltip") }; new GUITextBlock(new RectTransform(Vector2.One, huntingGroundsContent.RectTransform), TextManager.Get("missionname.huntinggrounds"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft) { Padding = Vector4.Zero, ToolTip = icon.ToolTip }; } } missionList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.4f), content.RectTransform)) { Spacing = (int)(5 * GUI.yScale) }; missionList.OnSelected = (GUIComponent selected, object userdata) => { var tickBox = selected.FindChild(c => c is GUITickBox, recursive: true) as GUITickBox; if (GUI.MouseOn == tickBox) { return(false); } if (tickBox != null) { if (Campaign.AllowedToManageCampaign() && tickBox.Enabled) { tickBox.Selected = !tickBox.Selected; } } return(true); }; SelectedLevel = connection?.LevelData; Location currentDisplayLocation = Campaign.GetCurrentDisplayLocation(); if (connection != null && connection.Locations.Contains(currentDisplayLocation)) { List <Mission> availableMissions = currentDisplayLocation.GetMissionsInConnection(connection).ToList(); if (!availableMissions.Contains(null)) { availableMissions.Insert(0, null); } missionList.Content.ClearChildren(); foreach (Mission mission in availableMissions) { var missionPanel = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), missionList.Content.RectTransform), style: null) { UserData = mission }; var missionTextContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), missionPanel.RectTransform, Anchor.Center)) { Stretch = true, CanBeFocused = true, AbsoluteSpacing = GUI.IntScale(5) }; var missionName = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission?.Name ?? TextManager.Get("NoMission"), font: GUI.SubHeadingFont, wrap: true); // missionName.RectTransform.MinSize = new Point(0, (int)(missionName.Rect.Height * 1.5f)); if (mission != null) { var tickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterLeft, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.X, 0) }, label: string.Empty) { UserData = mission, Selected = Campaign.Map.CurrentLocation?.SelectedMissions.Contains(mission) ?? false }; tickBox.RectTransform.MinSize = new Point(tickBox.Rect.Height, 0); tickBox.RectTransform.IsFixedSize = true; tickBox.Enabled = Campaign.AllowedToManageCampaign(); tickBox.OnSelected += (GUITickBox tb) => { if (!Campaign.AllowedToManageCampaign()) { return(false); } if (tb.Selected) { Campaign.Map.CurrentLocation.SelectMission(mission); } else { Campaign.Map.CurrentLocation.DeselectMission(mission); } foreach (GUITextBlock rewardText in missionRewardTexts) { Mission otherMission = rewardText.UserData as Mission; rewardText.SetRichText(otherMission.GetMissionRewardText(Submarine.MainSub)); } UpdateMaxMissions(connection.OtherLocation(currentDisplayLocation)); if ((Campaign is MultiPlayerCampaign multiPlayerCampaign) && !multiPlayerCampaign.SuppressStateSending && Campaign.AllowedToManageCampaign()) { GameMain.Client?.SendCampaignState(); } return(true); }; missionTickBoxes.Add(tickBox); GUILayoutGroup difficultyIndicatorGroup = null; if (mission.Difficulty.HasValue) { difficultyIndicatorGroup = new GUILayoutGroup(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterRight, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.Z, 0) }, isHorizontal: true, childAnchor: Anchor.CenterRight) { AbsoluteSpacing = 1, UserData = "difficulty" }; var difficultyColor = mission.GetDifficultyColor(); for (int i = 0; i < mission.Difficulty; i++) { new GUIImage(new RectTransform(Vector2.One, difficultyIndicatorGroup.RectTransform, scaleBasis: ScaleBasis.Smallest) { IsFixedSize = true }, "DifficultyIndicator", scaleToFit: true) { Color = difficultyColor, SelectedColor = difficultyColor, HoverColor = difficultyColor }; } } float extraPadding = 0;// 0.8f * tickBox.Rect.Width; float extraZPadding = difficultyIndicatorGroup != null ? mission.Difficulty.Value * (difficultyIndicatorGroup.Children.First().Rect.Width + difficultyIndicatorGroup.AbsoluteSpacing) : 0; missionName.Padding = new Vector4(missionName.Padding.X + tickBox.Rect.Width * 1.2f + extraPadding, missionName.Padding.Y, missionName.Padding.Z + extraZPadding + extraPadding, missionName.Padding.W); missionName.CalculateHeightFromText(); //spacing new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform) { MinSize = new Point(0, GUI.IntScale(10)) }, style: null); var rewardText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(Submarine.MainSub), wrap: true, parseRichText: true) { UserData = mission }; missionRewardTexts.Add(rewardText); string reputationText = mission.GetReputationRewardText(mission.Locations[0]); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), reputationText, wrap: true, parseRichText: true); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.Description, wrap: true, parseRichText: true); } missionPanel.RectTransform.MinSize = new Point(0, (int)(missionTextContent.Children.Sum(c => c.Rect.Height + missionTextContent.AbsoluteSpacing) / missionTextContent.RectTransform.RelativeSize.Y) + GUI.IntScale(0)); foreach (GUIComponent child in missionTextContent.Children) { if (child is GUITextBlock textBlock) { textBlock.Color = textBlock.SelectedColor = textBlock.HoverColor = Color.Transparent; textBlock.SelectedTextColor = textBlock.HoverTextColor = textBlock.TextColor; } } missionPanel.OnAddedToGUIUpdateList = (c) => { missionTextContent.Children.ForEach(child => child.State = c.State); if (missionTextContent.FindChild("difficulty", recursive: true) is GUILayoutGroup group) { group.State = c.State; } }; if (mission != availableMissions.Last()) { new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), missionList.Content.RectTransform), style: "HorizontalLine") { CanBeFocused = false }; } } if (prevSelectedLocation == selectedLocation) { missionList.BarScroll = prevMissionListScroll; missionList.UpdateDimensions(); missionList.UpdateScrollBarSize(); } } var destination = connection.OtherLocation(currentDisplayLocation); UpdateMaxMissions(destination); var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), isHorizontal: true); new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), buttonArea.RectTransform), "", font: GUI.Style.SubHeadingFont) { TextGetter = () => { return(TextManager.AddPunctuation(':', TextManager.Get("Missions"), $"{Campaign.NumberOfMissionsAtLocation(destination)}/{Campaign.Settings.MaxMissionCount}")); } }; StartButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform), TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge") { OnClicked = (GUIButton btn, object obj) => { if (missionList.Content.FindChild(c => c is GUITickBox tickBox && tickBox.Selected, recursive: true) == null && missionList.Content.Children.Any(c => c.UserData is Mission)) { var noMissionVerification = new GUIMessageBox(string.Empty, TextManager.Get("nomissionprompt"), new string[] { TextManager.Get("yes"), TextManager.Get("no") }); noMissionVerification.Buttons[0].OnClicked = (btn, userdata) => { StartRound?.Invoke(); noMissionVerification.Close(); return(true); }; noMissionVerification.Buttons[1].OnClicked = noMissionVerification.Close; }
private void SelectSubmarine(SubmarineInfo info, Rectangle backgroundRect) { #if !DEBUG if (selectedSubmarine == info) { return; } #endif specsFrame.Content.ClearChildren(); selectedSubmarine = info; if (info != null) { bool owned = GameMain.GameSession.IsSubmarineOwned(info); if (owned) { confirmButton.Text = deliveryFee > 0 ? deliveryText : switchText; confirmButton.OnClicked = (button, userData) => { ShowTransferPrompt(); return(true); }; } else { confirmButton.Text = purchaseAndSwitchText; confirmButton.OnClicked = (button, userData) => { ShowBuyPrompt(false); return(true); }; confirmButtonAlt.Text = purchaseOnlyText; confirmButtonAlt.OnClicked = (button, userData) => { ShowBuyPrompt(true); return(true); }; } SetConfirmButtonState(selectedSubmarine.Name != CurrentOrPendingSubmarine().Name); selectedSubmarineIndicator.RectTransform.NonScaledSize = backgroundRect.Size; selectedSubmarineIndicator.RectTransform.AbsoluteOffset = new Point(backgroundRect.Left - submarineHorizontalGroup.Rect.Left, 0); Sprite previewImage = GetPreviewImage(info); listBackground.Sprite = previewImage; listBackground.SetCrop(true); ScalableFont font = GUI.Font; info.CreateSpecsWindow(specsFrame, font); descriptionTextBlock.Text = info.Description; descriptionTextBlock.CalculateHeightFromText(); } else { listBackground.Sprite = null; listBackground.SetCrop(false); descriptionTextBlock.Text = string.Empty; selectedSubmarineIndicator.RectTransform.NonScaledSize = Point.Zero; SetConfirmButtonState(false); } }
public GUIFrame CreateSummaryFrame(GameSession gameSession, string endMessage, List <TraitorMissionResult> traitorResults, CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None) { bool singleplayer = GameMain.NetworkMember == null; bool gameOver = gameSession.GameMode.IsSinglePlayer ? gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsIncapacitated) : gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsIncapacitated || c.IsBot); if (!singleplayer) { SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround"; SoundPlayer.OverrideMusicDuration = 18.0f; } GUIFrame background = new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, GUI.Canvas, Anchor.Center), style: "GUIBackgroundBlocker") { UserData = this }; List <GUIComponent> rightPanels = new List <GUIComponent>(); int minWidth = 400, minHeight = 350; int padding = GUI.IntScale(25.0f); //crew panel ------------------------------------------------------------------------------- GUIFrame crewFrame = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.55f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight))); GUIFrame crewFrameInner = new GUIFrame(new RectTransform(new Point(crewFrame.Rect.Width - padding * 2, crewFrame.Rect.Height - padding * 2), crewFrame.RectTransform, Anchor.Center), style: "InnerFrame"); var crewContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), crewFrameInner.RectTransform, Anchor.Center)) { Stretch = true }; var crewHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), crewContent.RectTransform), TextManager.Get("crew"), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); crewHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(crewHeader.Rect.Height * 2.0f)); CreateCrewList(crewContent, gameSession.CrewManager.GetCharacterInfos().Where(c => c.TeamID != Character.TeamType.Team2)); //another crew frame for the 2nd team in combat missions if (gameSession.Mission is CombatMission) { crewHeader.Text = CombatMission.GetTeamName(Character.TeamType.Team1); GUIFrame crewFrame2 = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.55f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight))); rightPanels.Add(crewFrame2); GUIFrame crewFrameInner2 = new GUIFrame(new RectTransform(new Point(crewFrame2.Rect.Width - padding * 2, crewFrame2.Rect.Height - padding * 2), crewFrame2.RectTransform, Anchor.Center), style: "InnerFrame"); var crewContent2 = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), crewFrameInner2.RectTransform, Anchor.Center)) { Stretch = true }; var crewHeader2 = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), crewContent2.RectTransform), CombatMission.GetTeamName(Character.TeamType.Team2), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); crewHeader2.RectTransform.MinSize = new Point(0, GUI.IntScale(crewHeader2.Rect.Height * 2.0f)); CreateCrewList(crewContent2, gameSession.CrewManager.GetCharacterInfos().Where(c => c.TeamID == Character.TeamType.Team2)); } //header ------------------------------------------------------------------------------- string headerText = GetHeaderText(gameOver, transitionType); GUITextBlock headerTextBlock = null; if (!string.IsNullOrEmpty(headerText)) { headerTextBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), crewFrame.RectTransform, Anchor.TopLeft, Pivot.BottomLeft), headerText, textAlignment: Alignment.BottomLeft, font: GUI.LargeFont, wrap: true); } //traitor panel ------------------------------------------------------------------------------- if (traitorResults != null && traitorResults.Any()) { GUIFrame traitorframe = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: crewFrame.RectTransform.MinSize)); rightPanels.Add(traitorframe); GUIFrame traitorframeInner = new GUIFrame(new RectTransform(new Point(traitorframe.Rect.Width - padding * 2, traitorframe.Rect.Height - padding * 2), traitorframe.RectTransform, Anchor.Center), style: "InnerFrame"); var traitorContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), traitorframeInner.RectTransform, Anchor.Center)) { Stretch = true }; var traitorHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), traitorContent.RectTransform), TextManager.Get("traitors"), font: GUI.SubHeadingFont); traitorHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(traitorHeader.Rect.Height * 2.0f)); GUIListBox listBox = CreateCrewList(traitorContent, traitorResults.SelectMany(tr => tr.Characters.Select(c => c.Info))); foreach (var traitorResult in traitorResults) { var traitorMission = TraitorMissionPrefab.List.Find(t => t.Identifier == traitorResult.MissionIdentifier); if (traitorMission == null) { continue; } //spacing new GUIFrame(new RectTransform(new Point(listBox.Content.Rect.Width, GUI.IntScale(25)), listBox.Content.RectTransform), style: null); var traitorResultHorizontal = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), listBox.Content.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true) { RelativeSpacing = 0.05f, Stretch = true }; new GUIImage(new RectTransform(new Point(traitorResultHorizontal.Rect.Height), traitorResultHorizontal.RectTransform), traitorMission.Icon, scaleToFit: true) { Color = traitorMission.IconColor }; string traitorMessage = TextManager.GetServerMessage(traitorResult.EndMessage); if (!string.IsNullOrEmpty(traitorMessage)) { var textContent = new GUILayoutGroup(new RectTransform(Vector2.One, traitorResultHorizontal.RectTransform)) { RelativeSpacing = 0.025f }; var traitorStatusText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), TextManager.Get(traitorResult.Success ? "missioncompleted" : "missionfailed"), textColor: traitorResult.Success ? GUI.Style.Green : GUI.Style.Red, font: GUI.SubHeadingFont); var traitorMissionInfo = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), traitorMessage, font: GUI.SmallFont, wrap: true); traitorResultHorizontal.Recalculate(); traitorStatusText.CalculateHeightFromText(); traitorMissionInfo.CalculateHeightFromText(); traitorStatusText.RectTransform.MinSize = new Point(0, traitorStatusText.Rect.Height); traitorMissionInfo.RectTransform.MinSize = new Point(0, traitorMissionInfo.Rect.Height); textContent.RectTransform.MaxSize = new Point(int.MaxValue, (int)((traitorStatusText.Rect.Height + traitorMissionInfo.Rect.Height) * 1.2f)); traitorResultHorizontal.RectTransform.MinSize = new Point(0, traitorStatusText.RectTransform.MinSize.Y + traitorMissionInfo.RectTransform.MinSize.Y); } } } //reputation panel ------------------------------------------------------------------------------- if (gameMode is CampaignMode campaignMode) { GUIFrame reputationframe = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: crewFrame.RectTransform.MinSize)); rightPanels.Add(reputationframe); GUIFrame reputationframeInner = new GUIFrame(new RectTransform(new Point(reputationframe.Rect.Width - padding * 2, reputationframe.Rect.Height - padding * 2), reputationframe.RectTransform, Anchor.Center), style: "InnerFrame"); var reputationContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), reputationframeInner.RectTransform, Anchor.Center)) { Stretch = true }; var reputationHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), reputationContent.RectTransform), TextManager.Get("reputation"), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); reputationHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(reputationHeader.Rect.Height * 2.0f)); GUIListBox reputationList = new GUIListBox(new RectTransform(Vector2.One, reputationContent.RectTransform)) { Padding = new Vector4(2, 5, 0, 0) }; reputationList.ContentBackground.Color = Color.Transparent; if (startLocation.Type.HasOutpost && startLocation.Reputation != null) { var iconStyle = GUI.Style.GetComponentStyle("LocationReputationIcon"); CreateReputationElement( reputationList.Content, startLocation.Name, startLocation.Reputation.Value, startLocation.Reputation.NormalizedValue, initialLocationReputation, startLocation.Type.Name, "", iconStyle?.GetDefaultSprite(), startLocation.Type.GetPortrait(0), iconStyle?.Color ?? Color.White); } foreach (Faction faction in campaignMode.Factions) { float initialReputation = faction.Reputation.Value; if (initialFactionReputations.ContainsKey(faction)) { initialReputation = initialFactionReputations[faction]; } else { DebugConsole.AddWarning($"Could not determine reputation change for faction \"{faction.Prefab.Name}\" (faction was not present at the start of the round)."); } CreateReputationElement( reputationList.Content, faction.Prefab.Name, faction.Reputation.Value, faction.Reputation.NormalizedValue, initialReputation, faction.Prefab.ShortDescription, faction.Prefab.Description, faction.Prefab.Icon, faction.Prefab.BackgroundPortrait, faction.Prefab.IconColor); } float otherElementHeight = 0.0f; float maxDescriptionHeight = 0.0f; foreach (GUIComponent child in reputationList.Content.Children) { var descriptionElement = child.FindChild("description", recursive: true) as GUITextBlock; maxDescriptionHeight = Math.Max(maxDescriptionHeight, descriptionElement.TextSize.Y * 1.1f); otherElementHeight = Math.Max(otherElementHeight, descriptionElement.Parent.Rect.Height - descriptionElement.TextSize.Y); } foreach (GUIComponent child in reputationList.Content.Children) { var descriptionElement = child.FindChild("description", recursive: true) as GUITextBlock; descriptionElement.RectTransform.MaxSize = new Point(int.MaxValue, (int)(maxDescriptionHeight)); child.RectTransform.MaxSize = new Point(int.MaxValue, (int)((maxDescriptionHeight + otherElementHeight) * 1.2f)); (descriptionElement?.Parent as GUILayoutGroup).Recalculate(); } } //mission panel ------------------------------------------------------------------------------- GUIFrame missionframe = new GUIFrame(new RectTransform(new Vector2(0.39f, 0.22f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight / 4))); GUIFrame missionframeInner = new GUIFrame(new RectTransform(new Point(missionframe.Rect.Width - padding * 2, missionframe.Rect.Height - padding * 2), missionframe.RectTransform, Anchor.Center), style: "InnerFrame"); var missionContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), missionframeInner.RectTransform, Anchor.Center)) { RelativeSpacing = 0.05f, Stretch = true }; if (!string.IsNullOrWhiteSpace(endMessage)) { var endText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionContent.RectTransform), TextManager.GetServerMessage(endMessage), wrap: true); endText.RectTransform.MinSize = new Point(0, endText.Rect.Height); var line = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.1f), missionContent.RectTransform), style: "HorizontalLine"); line.RectTransform.NonScaledSize = new Point(line.Rect.Width, GUI.IntScale(5.0f)); } var missionContentHorizontal = new GUILayoutGroup(new RectTransform(Vector2.One, missionContent.RectTransform), childAnchor: Anchor.TopLeft, isHorizontal: true) { RelativeSpacing = 0.025f, Stretch = true }; Mission displayedMission = selectedMission ?? startLocation.SelectedMission; string missionMessage = ""; GUIImage missionIcon; if (displayedMission != null) { missionMessage = displayedMission == selectedMission ? displayedMission.Completed ? displayedMission.SuccessMessage : displayedMission.FailureMessage : displayedMission.Description; missionIcon = new GUIImage(new RectTransform(new Point(missionContentHorizontal.Rect.Height), missionContentHorizontal.RectTransform), displayedMission.Prefab.Icon, scaleToFit: true) { Color = displayedMission.Prefab.IconColor }; if (displayedMission == selectedMission) { new GUIImage(new RectTransform(Vector2.One, missionIcon.RectTransform), displayedMission.Completed ? "MissionCompletedIcon" : "MissionFailedIcon", scaleToFit: true); } } else { missionIcon = new GUIImage(new RectTransform(new Point(missionContentHorizontal.Rect.Height), missionContentHorizontal.RectTransform), style: "NoMissionIcon", scaleToFit: true); } var missionTextContent = new GUILayoutGroup(new RectTransform(Vector2.One, missionContentHorizontal.RectTransform)) { RelativeSpacing = 0.05f }; missionContentHorizontal.Recalculate(); missionContent.Recalculate(); missionIcon.RectTransform.MinSize = new Point(0, missionContentHorizontal.Rect.Height); missionTextContent.RectTransform.MaxSize = new Point(int.MaxValue, missionIcon.Rect.Width); GUITextBlock missionDescription = null; if (displayedMission == null) { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), TextManager.Get("nomission"), font: GUI.LargeFont); } else { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), TextManager.AddPunctuation(':', TextManager.Get("Mission"), displayedMission.Name), font: GUI.SubHeadingFont); missionDescription = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), missionMessage, wrap: true); if (displayedMission == selectedMission && displayedMission.Completed) { string rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", displayedMission.Reward)); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), TextManager.GetWithVariable("MissionReward", "[reward]", rewardText)); } } ButtonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), missionContent.RectTransform, Anchor.BottomCenter), isHorizontal: true, childAnchor: Anchor.BottomRight) { IgnoreLayoutGroups = true, RelativeSpacing = 0.025f }; ContinueButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), ButtonArea.RectTransform), TextManager.Get("Close")); ButtonArea.RectTransform.NonScaledSize = new Point(ButtonArea.Rect.Width, ContinueButton.Rect.Height); ButtonArea.RectTransform.IsFixedSize = true; missionContent.Recalculate(); //description overlapping with the buttons -> switch to small font if (missionDescription != null && missionDescription.Rect.Y + missionDescription.TextSize.Y > ButtonArea.Rect.Y) { missionDescription.Font = GUI.Style.SmallFont; //still overlapping -> shorten the text if (missionDescription.Rect.Y + missionDescription.TextSize.Y > ButtonArea.Rect.Y && missionDescription.WrappedText.Contains('\n')) { missionDescription.ToolTip = missionDescription.Text; missionDescription.Text = missionDescription.WrappedText.Split('\n').First() + "..."; } } // set layout ------------------------------------------------------------------- int panelSpacing = GUI.IntScale(20); int totalHeight = crewFrame.Rect.Height + panelSpacing + missionframe.Rect.Height; int totalWidth = crewFrame.Rect.Width; crewFrame.RectTransform.AbsoluteOffset = new Point(0, (GameMain.GraphicsHeight - totalHeight) / 2); missionframe.RectTransform.AbsoluteOffset = new Point(0, crewFrame.Rect.Bottom + panelSpacing); if (rightPanels.Any()) { totalWidth = crewFrame.Rect.Width * 2 + panelSpacing; if (headerTextBlock != null) { headerTextBlock.RectTransform.MinSize = new Point(totalWidth, 0); } crewFrame.RectTransform.AbsoluteOffset = new Point(-(crewFrame.Rect.Width + panelSpacing) / 2, crewFrame.RectTransform.AbsoluteOffset.Y); foreach (var rightPanel in rightPanels) { rightPanel.RectTransform.AbsoluteOffset = new Point((rightPanel.Rect.Width + panelSpacing) / 2, crewFrame.RectTransform.AbsoluteOffset.Y); } } Frame = background; return(background); }
private void CreateGUI() { createdForResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); GUILayoutGroup content; GuiFrame = new GUIFrame(new RectTransform(new Vector2(0.75f, 0.7f), parent, Anchor.TopCenter, Pivot.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.02f) }); selectionIndicatorThickness = HUDLayoutSettings.Padding / 2; GUIFrame background = new GUIFrame(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center), color: Color.Black * 0.9f) { CanBeFocused = false }; content = new GUILayoutGroup(new RectTransform(new Point(background.Rect.Width - HUDLayoutSettings.Padding * 4, background.Rect.Height - HUDLayoutSettings.Padding * 4), background.RectTransform, Anchor.Center)) { AbsoluteSpacing = (int)(HUDLayoutSettings.Padding * 1.5f) }; GUITextBlock header = new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), content.RectTransform), transferService ? TextManager.Get("switchsubmarineheader") : TextManager.GetWithVariable("outpostshipyard", "[location]", GameMain.GameSession.Map.CurrentLocation.Name), font: GUI.LargeFont); header.CalculateHeightFromText(0, true); GUITextBlock credits = new GUITextBlock(new RectTransform(Vector2.One, header.RectTransform), "", font: GUI.SubHeadingFont, textAlignment: Alignment.CenterRight) { TextGetter = CampaignUI.GetMoney }; new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), content.RectTransform), style: "HorizontalLine"); GUILayoutGroup submarineContentGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.4f), content.RectTransform)) { AbsoluteSpacing = HUDLayoutSettings.Padding, Stretch = true }; submarineHorizontalGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.9f), submarineContentGroup.RectTransform)) { IsHorizontal = true, AbsoluteSpacing = HUDLayoutSettings.Padding, Stretch = true }; submarineControlsGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.1f), submarineContentGroup.RectTransform), true, Anchor.TopCenter); GUILayoutGroup infoFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.4f), content.RectTransform)) { IsHorizontal = true, Stretch = true, AbsoluteSpacing = HUDLayoutSettings.Padding }; new GUIFrame(new RectTransform(Vector2.One, infoFrame.RectTransform), style: null, new Color(8, 13, 19)) { IgnoreLayoutGroups = true }; listBackground = new GUIImage(new RectTransform(new Vector2(0.59f, 1f), infoFrame.RectTransform, Anchor.CenterRight), style: null, true) { IgnoreLayoutGroups = true }; new GUIListBox(new RectTransform(Vector2.One, infoFrame.RectTransform)) { IgnoreLayoutGroups = true, CanBeFocused = false }; specsFrame = new GUIListBox(new RectTransform(new Vector2(0.39f, 1f), infoFrame.RectTransform), style: null) { Spacing = GUI.IntScale(5), Padding = new Vector4(HUDLayoutSettings.Padding / 2f, HUDLayoutSettings.Padding, 0, 0) }; new GUIFrame(new RectTransform(new Vector2(0.02f, 0.8f), infoFrame.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.1f) }, style: "VerticalLine"); GUIListBox descriptionFrame = new GUIListBox(new RectTransform(new Vector2(0.59f, 1f), infoFrame.RectTransform), style: null) { Padding = new Vector4(HUDLayoutSettings.Padding / 2f, HUDLayoutSettings.Padding * 1.5f, HUDLayoutSettings.Padding * 1.5f, HUDLayoutSettings.Padding / 2f) }; descriptionTextBlock = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionFrame.Content.RectTransform), string.Empty, font: GUI.Font, wrap: true) { CanBeFocused = false }; GUILayoutGroup buttonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.075f), content.RectTransform), childAnchor: Anchor.CenterRight) { IsHorizontal = true, AbsoluteSpacing = HUDLayoutSettings.Padding }; if (closeAction != null) { GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), TextManager.Get("Close"), style: "GUIButtonFreeScale") { OnClicked = (button, userData) => { closeAction(); return(true); } }; } if (purchaseService) { confirmButtonAlt = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), purchaseOnlyText, style: "GUIButtonFreeScale"); } confirmButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), purchaseService ? purchaseAndSwitchText : deliveryFee > 0 ? deliveryText : switchText, style: "GUIButtonFreeScale"); SetConfirmButtonState(false); pageIndicatorHolder = new GUIFrame(new RectTransform(new Vector2(1f, 1.5f), submarineControlsGroup.RectTransform), style: null); pageIndicator = GUI.Style.GetComponentStyle("GUIPageIndicator").GetDefaultSprite(); UpdatePaging(); for (int i = 0; i < submarineDisplays.Length; i++) { SubmarineDisplayContent submarineDisplayElement = new SubmarineDisplayContent(); submarineDisplayElement.background = new GUIFrame(new RectTransform(new Vector2(1f / submarinesPerPage, 1f), submarineHorizontalGroup.RectTransform), style: null, new Color(8, 13, 19)); submarineDisplayElement.submarineImage = new GUIImage(new RectTransform(new Vector2(0.8f, 1f), submarineDisplayElement.background.RectTransform, Anchor.Center), null, true); submarineDisplayElement.middleTextBlock = new GUITextBlock(new RectTransform(new Vector2(0.8f, 1f), submarineDisplayElement.background.RectTransform, Anchor.Center), string.Empty, textAlignment: Alignment.Center); submarineDisplayElement.submarineName = new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), submarineDisplayElement.background.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, HUDLayoutSettings.Padding) }, string.Empty, textAlignment: Alignment.Center, font: GUI.SubHeadingFont); submarineDisplayElement.submarineClass = new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), submarineDisplayElement.background.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, HUDLayoutSettings.Padding + (int)GUI.Font.MeasureString(submarineDisplayElement.submarineName.Text).Y) }, string.Empty, textAlignment: Alignment.Center); submarineDisplayElement.submarineFee = new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), submarineDisplayElement.background.RectTransform, Anchor.BottomCenter, Pivot.BottomCenter) { AbsoluteOffset = new Point(0, HUDLayoutSettings.Padding) }, string.Empty, textAlignment: Alignment.Center, font: GUI.SubHeadingFont); submarineDisplayElement.selectSubmarineButton = new GUIButton(new RectTransform(Vector2.One, submarineDisplayElement.background.RectTransform), style: null); submarineDisplays[i] = submarineDisplayElement; } selectedSubmarineIndicator = new GUICustomComponent(new RectTransform(Point.Zero, submarineHorizontalGroup.RectTransform), onDraw: (sb, component) => DrawSubmarineIndicator(sb, component.Rect)) { IgnoreLayoutGroups = true, CanBeFocused = false }; }
public GUIFrame CreateSummaryFrame(GameSession gameSession, string endMessage, List <TraitorMissionResult> traitorResults, CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None) { bool singleplayer = GameMain.NetworkMember == null; bool gameOver = gameSession.GameMode.IsSinglePlayer ? gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsIncapacitated) : gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsIncapacitated || c.IsBot); if (!singleplayer) { SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround"; SoundPlayer.OverrideMusicDuration = 18.0f; } GUIFrame background = new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, GUI.Canvas, Anchor.Center), style: "GUIBackgroundBlocker") { UserData = this }; List <GUIComponent> rightPanels = new List <GUIComponent>(); int minWidth = 400, minHeight = 350; int padding = GUI.IntScale(25.0f); //crew panel ------------------------------------------------------------------------------- GUIFrame crewFrame = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.45f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight))); GUIFrame crewFrameInner = new GUIFrame(new RectTransform(new Point(crewFrame.Rect.Width - padding * 2, crewFrame.Rect.Height - padding * 2), crewFrame.RectTransform, Anchor.Center), style: "InnerFrame"); var crewContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), crewFrameInner.RectTransform, Anchor.Center)) { Stretch = true }; var crewHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), crewContent.RectTransform), TextManager.Get("crew"), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); crewHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(crewHeader.Rect.Height * 2.0f)); CreateCrewList(crewContent, gameSession.CrewManager.GetCharacterInfos().Where(c => c.TeamID != CharacterTeamType.Team2)); //another crew frame for the 2nd team in combat missions if (gameSession.Missions.Any(m => m is CombatMission)) { crewHeader.Text = CombatMission.GetTeamName(CharacterTeamType.Team1); GUIFrame crewFrame2 = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.45f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight))); rightPanels.Add(crewFrame2); GUIFrame crewFrameInner2 = new GUIFrame(new RectTransform(new Point(crewFrame2.Rect.Width - padding * 2, crewFrame2.Rect.Height - padding * 2), crewFrame2.RectTransform, Anchor.Center), style: "InnerFrame"); var crewContent2 = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), crewFrameInner2.RectTransform, Anchor.Center)) { Stretch = true }; var crewHeader2 = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), crewContent2.RectTransform), CombatMission.GetTeamName(CharacterTeamType.Team2), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); crewHeader2.RectTransform.MinSize = new Point(0, GUI.IntScale(crewHeader2.Rect.Height * 2.0f)); CreateCrewList(crewContent2, gameSession.CrewManager.GetCharacterInfos().Where(c => c.TeamID == CharacterTeamType.Team2)); } //header ------------------------------------------------------------------------------- string headerText = GetHeaderText(gameOver, transitionType); GUITextBlock headerTextBlock = null; if (!string.IsNullOrEmpty(headerText)) { headerTextBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), crewFrame.RectTransform, Anchor.TopLeft, Pivot.BottomLeft), headerText, textAlignment: Alignment.BottomLeft, font: GUI.LargeFont, wrap: true); } //traitor panel ------------------------------------------------------------------------------- if (traitorResults != null && traitorResults.Any()) { GUIFrame traitorframe = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: crewFrame.RectTransform.MinSize)); rightPanels.Add(traitorframe); GUIFrame traitorframeInner = new GUIFrame(new RectTransform(new Point(traitorframe.Rect.Width - padding * 2, traitorframe.Rect.Height - padding * 2), traitorframe.RectTransform, Anchor.Center), style: "InnerFrame"); var traitorContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), traitorframeInner.RectTransform, Anchor.Center)) { Stretch = true }; var traitorHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), traitorContent.RectTransform), TextManager.Get("traitors"), font: GUI.SubHeadingFont); traitorHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(traitorHeader.Rect.Height * 2.0f)); GUIListBox listBox = CreateCrewList(traitorContent, traitorResults.SelectMany(tr => tr.Characters.Select(c => c.Info))); foreach (var traitorResult in traitorResults) { var traitorMission = TraitorMissionPrefab.List.Find(t => t.Identifier == traitorResult.MissionIdentifier); if (traitorMission == null) { continue; } //spacing new GUIFrame(new RectTransform(new Point(listBox.Content.Rect.Width, GUI.IntScale(25)), listBox.Content.RectTransform), style: null); var traitorResultHorizontal = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), listBox.Content.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true) { RelativeSpacing = 0.05f, Stretch = true }; new GUIImage(new RectTransform(new Point(traitorResultHorizontal.Rect.Height), traitorResultHorizontal.RectTransform), traitorMission.Icon, scaleToFit: true) { Color = traitorMission.IconColor }; string traitorMessage = TextManager.GetServerMessage(traitorResult.EndMessage); if (!string.IsNullOrEmpty(traitorMessage)) { var textContent = new GUILayoutGroup(new RectTransform(Vector2.One, traitorResultHorizontal.RectTransform)) { RelativeSpacing = 0.025f }; var traitorStatusText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), TextManager.Get(traitorResult.Success ? "missioncompleted" : "missionfailed"), textColor: traitorResult.Success ? GUI.Style.Green : GUI.Style.Red, font: GUI.SubHeadingFont); var traitorMissionInfo = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform), traitorMessage, font: GUI.SmallFont, wrap: true); traitorResultHorizontal.Recalculate(); traitorStatusText.CalculateHeightFromText(); traitorMissionInfo.CalculateHeightFromText(); traitorStatusText.RectTransform.MinSize = new Point(0, traitorStatusText.Rect.Height); traitorMissionInfo.RectTransform.MinSize = new Point(0, traitorMissionInfo.Rect.Height); textContent.RectTransform.MaxSize = new Point(int.MaxValue, (int)((traitorStatusText.Rect.Height + traitorMissionInfo.Rect.Height) * 1.2f)); traitorResultHorizontal.RectTransform.MinSize = new Point(0, traitorStatusText.RectTransform.MinSize.Y + traitorMissionInfo.RectTransform.MinSize.Y); } } } //reputation panel ------------------------------------------------------------------------------- var campaignMode = gameMode as CampaignMode; if (campaignMode != null) { GUIFrame reputationframe = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: crewFrame.RectTransform.MinSize)); rightPanels.Add(reputationframe); GUIFrame reputationframeInner = new GUIFrame(new RectTransform(new Point(reputationframe.Rect.Width - padding * 2, reputationframe.Rect.Height - padding * 2), reputationframe.RectTransform, Anchor.Center), style: "InnerFrame"); var reputationContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), reputationframeInner.RectTransform, Anchor.Center)) { Stretch = true }; var reputationHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), reputationContent.RectTransform), TextManager.Get("reputation"), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); reputationHeader.RectTransform.MinSize = new Point(0, GUI.IntScale(reputationHeader.Rect.Height * 2.0f)); CreateReputationInfoPanel(reputationContent, campaignMode); } //mission panel ------------------------------------------------------------------------------- GUIFrame missionframe = new GUIFrame(new RectTransform(new Vector2(0.39f, 0.3f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight / 4))); GUILayoutGroup missionFrameContent = new GUILayoutGroup(new RectTransform(new Point(missionframe.Rect.Width - padding * 2, missionframe.Rect.Height - padding * 2), missionframe.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.05f }; GUIFrame missionframeInner = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), missionFrameContent.RectTransform, Anchor.Center), style: "InnerFrame"); var missionContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.93f), missionframeInner.RectTransform, Anchor.Center)) { Stretch = true }; List <Mission> missionsToDisplay = new List <Mission>(selectedMissions); if (!selectedMissions.Any() && startLocation?.SelectedMission != null) { if (startLocation.SelectedMission.Locations[0] == startLocation.SelectedMission.Locations[1] || startLocation.SelectedMission.Locations.Contains(campaignMode?.Map.SelectedLocation)) { missionsToDisplay.Add(startLocation.SelectedMission); } } if (missionsToDisplay.Any()) { var missionHeader = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionContent.RectTransform), TextManager.Get(missionsToDisplay.Count > 1 ? "Missions" : "Mission"), textAlignment: Alignment.TopLeft, font: GUI.SubHeadingFont); missionHeader.RectTransform.MinSize = new Point(0, (int)(missionHeader.Rect.Height * 1.2f)); } GUIListBox missionList = new GUIListBox(new RectTransform(Vector2.One, missionContent.RectTransform, Anchor.Center)) { Padding = new Vector4(4, 10, 0, 0) * GUI.Scale }; missionList.ContentBackground.Color = Color.Transparent; ButtonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), missionFrameContent.RectTransform, Anchor.BottomCenter), isHorizontal: true, childAnchor: Anchor.BottomRight) { RelativeSpacing = 0.025f }; missionFrameContent.Recalculate(); missionContent.Recalculate(); if (!string.IsNullOrWhiteSpace(endMessage)) { var endText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionList.Content.RectTransform), TextManager.GetServerMessage(endMessage), wrap: true) { CanBeFocused = false }; endText.RectTransform.MinSize = new Point(0, endText.Rect.Height); var line = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.1f), missionList.Content.RectTransform), style: "HorizontalLine"); line.RectTransform.NonScaledSize = new Point(line.Rect.Width, GUI.IntScale(5.0f)); } foreach (Mission displayedMission in missionsToDisplay) { var missionContentHorizontal = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.8f), missionList.Content.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true) { RelativeSpacing = 0.025f, Stretch = true }; string missionMessage = selectedMissions.Contains(displayedMission) ? displayedMission.Completed ? displayedMission.SuccessMessage : displayedMission.FailureMessage : displayedMission.Description; GUIImage missionIcon = new GUIImage(new RectTransform(new Point((int)(missionContentHorizontal.Rect.Height)), missionContentHorizontal.RectTransform), displayedMission.Prefab.Icon, scaleToFit: true) { Color = displayedMission.Prefab.IconColor, HoverColor = displayedMission.Prefab.IconColor, SelectedColor = displayedMission.Prefab.IconColor }; missionIcon.RectTransform.MinSize = new Point((int)(missionContentHorizontal.Rect.Height * 0.9f)); if (selectedMissions.Contains(displayedMission)) { new GUIImage(new RectTransform(Vector2.One, missionIcon.RectTransform), displayedMission.Completed ? "MissionCompletedIcon" : "MissionFailedIcon", scaleToFit: true); } var missionTextContent = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.8f), missionContentHorizontal.RectTransform)) { RelativeSpacing = 0.05f }; var missionNameTextBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), displayedMission.Name, font: GUI.SubHeadingFont); if (displayedMission.Difficulty.HasValue) { var groupSize = missionNameTextBlock.Rect.Size; groupSize.X -= (int)(missionNameTextBlock.Padding.X + missionNameTextBlock.Padding.Z); var indicatorGroup = new GUILayoutGroup(new RectTransform(groupSize, missionTextContent.RectTransform) { AbsoluteOffset = new Point((int)missionNameTextBlock.Padding.X, 0) }, isHorizontal: true, childAnchor: Anchor.CenterLeft) { AbsoluteSpacing = 1 }; var difficultyColor = displayedMission.GetDifficultyColor(); for (int i = 0; i < displayedMission.Difficulty; i++) { new GUIImage(new RectTransform(Vector2.One, indicatorGroup.RectTransform, scaleBasis: ScaleBasis.Smallest) { IsFixedSize = true }, "DifficultyIndicator", scaleToFit: true) { CanBeFocused = false, Color = difficultyColor }; } } new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), missionMessage, wrap: true, parseRichText: true); if (selectedMissions.Contains(displayedMission) && displayedMission.Completed && displayedMission.Reward > 0) { string rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", displayedMission.Reward)); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), displayedMission.GetMissionRewardText(), parseRichText: true); } if (displayedMission != missionsToDisplay.Last()) { var spacing = new GUIFrame(new RectTransform(new Vector2(1.0f, 1.0f), missionList.Content.RectTransform) { MaxSize = new Point(int.MaxValue, GUI.IntScale(15)) }, style: null); new GUIFrame(new RectTransform(new Vector2(0.8f, 1.0f), spacing.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.1f, 0.0f) }, "HorizontalLine"); } } if (!missionsToDisplay.Any()) { var missionContentHorizontal = new GUILayoutGroup(new RectTransform(Vector2.One, missionList.Content.RectTransform), childAnchor: Anchor.TopLeft, isHorizontal: true) { RelativeSpacing = 0.025f, Stretch = true }; GUIImage missionIcon = new GUIImage(new RectTransform(new Point((int)(missionContentHorizontal.Rect.Height * 0.7f)), missionContentHorizontal.RectTransform), style: "NoMissionIcon", scaleToFit: true); missionIcon.RectTransform.MinSize = new Point((int)(missionContentHorizontal.Rect.Height * 0.7f)); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionContentHorizontal.RectTransform), TextManager.Get("nomission"), font: GUI.LargeFont); } /*missionContentHorizontal.Recalculate(); * missionContent.Recalculate(); * missionIcon.RectTransform.MinSize = new Point(0, missionContentHorizontal.Rect.Height); * missionTextContent.RectTransform.MaxSize = new Point(int.MaxValue, missionIcon.Rect.Width);*/ ContinueButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), ButtonArea.RectTransform), TextManager.Get("Close")); ButtonArea.RectTransform.NonScaledSize = new Point(ButtonArea.Rect.Width, ContinueButton.Rect.Height); ButtonArea.RectTransform.IsFixedSize = true; missionFrameContent.Recalculate(); // set layout ------------------------------------------------------------------- int panelSpacing = GUI.IntScale(20); int totalHeight = crewFrame.Rect.Height + panelSpacing + missionframe.Rect.Height; int totalWidth = crewFrame.Rect.Width; crewFrame.RectTransform.AbsoluteOffset = new Point(0, (GameMain.GraphicsHeight - totalHeight) / 2); missionframe.RectTransform.AbsoluteOffset = new Point(0, crewFrame.Rect.Bottom + panelSpacing); if (rightPanels.Any()) { totalWidth = crewFrame.Rect.Width * 2 + panelSpacing; if (headerTextBlock != null) { headerTextBlock.RectTransform.MinSize = new Point(totalWidth, 0); } crewFrame.RectTransform.AbsoluteOffset = new Point(-(crewFrame.Rect.Width + panelSpacing) / 2, crewFrame.RectTransform.AbsoluteOffset.Y); foreach (var rightPanel in rightPanels) { rightPanel.RectTransform.AbsoluteOffset = new Point((rightPanel.Rect.Width + panelSpacing) / 2, crewFrame.RectTransform.AbsoluteOffset.Y); } } Frame = background; return(background); }