public GUITextBlock(Rectangle rect, string text, Color?color, Color?textColor, Alignment textAlignment = Alignment.Left, string style = null, GUIComponent parent = null, bool wrap = false) : this(rect, text, color, textColor, Alignment.TopLeft, textAlignment, style, parent, wrap) { }
private GUIComponent CreateColorField(ISerializableEntity entity, SerializableProperty property, Color value, int yPos, GUIComponent parent) { var label = new GUITextBlock(new Rectangle(0, yPos, 0, 18), property.Name, "", Alignment.TopLeft, Alignment.Left, parent, false, GUI.SmallFont); label.ToolTip = property.GetAttribute <Editable>().ToolTip; var colorBoxBack = new GUIFrame(new Rectangle(110 - 1, yPos - 1, 25 + 2, 18 + 2), Color.Black, Alignment.TopLeft, null, parent); var colorBox = new GUIFrame(new Rectangle(110, yPos, 25, 18), value, Alignment.TopLeft, null, parent); for (int i = 0; i < 4; i++) { new GUITextBlock(new Rectangle(140 + i * 70, yPos, 100, 18), colorComponentLabels[i], "", Alignment.TopLeft, Alignment.CenterLeft, parent, false, GUI.SmallFont); GUINumberInput numberInput = new GUINumberInput(new Rectangle(160 + i * 70, yPos, 45, 18), "", GUINumberInput.NumberType.Float, Alignment.Left, parent); numberInput.MinValueFloat = 0.0f; numberInput.MaxValueFloat = 1.0f; if (i == 0) { numberInput.FloatValue = value.R / 255.0f; } else if (i == 1) { numberInput.FloatValue = value.G / 255.0f; } else if (i == 2) { numberInput.FloatValue = value.B / 255.0f; } else { numberInput.FloatValue = value.A / 255.0f; } numberInput.Font = GUI.SmallFont; int comp = i; numberInput.OnValueChanged += (numInput) => { Color newVal = (Color)property.GetValue(); if (comp == 0) { newVal.R = (byte)(numInput.FloatValue * 255); } else if (comp == 1) { newVal.G = (byte)(numInput.FloatValue * 255); } else if (comp == 2) { newVal.B = (byte)(numInput.FloatValue * 255); } else { newVal.A = (byte)(numInput.FloatValue * 255); } if (property.TrySetValue(newVal)) { TrySendNetworkUpdate(entity, property); colorBox.Color = newVal; } }; } return(label); }
public CampaignSetupUI(bool isMultiplayer, GUIComponent newGameContainer, GUIComponent loadGameContainer, IEnumerable <SubmarineInfo> submarines, IEnumerable <string> saveFiles = null) { this.isMultiplayer = isMultiplayer; this.newGameContainer = newGameContainer; this.loadGameContainer = loadGameContainer; var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = isMultiplayer ? 0.0f : 0.02f }; var leftColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)) { Stretch = true, RelativeSpacing = 0.015f }; var rightColumn = new GUILayoutGroup(new RectTransform(isMultiplayer ? Vector2.Zero : new Vector2(1.5f, 1.0f), columnContainer.RectTransform)) { Stretch = true, RelativeSpacing = 0.015f }; columnContainer.Recalculate(); // New game left side new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SaveName"), font: GUI.SubHeadingFont); saveNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, string.Empty) { textFilterFunction = (string str) => { return(ToolBox.RemoveInvalidFileNameChars(str)); } }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("MapSeed"), font: GUI.SubHeadingFont); seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, ToolBox.RandomSeed(8)); if (!isMultiplayer) { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SelectedSub"), font: GUI.SubHeadingFont); var moddedDropdown = new GUIDropDown(new RectTransform(new Vector2(1f, 0.02f), leftColumn.RectTransform), "", 3); moddedDropdown.AddItem(TextManager.Get("clientpermission.all"), CategoryFilter.All); moddedDropdown.AddItem(TextManager.Get("servertag.modded.false"), CategoryFilter.Vanilla); moddedDropdown.AddItem(TextManager.Get("customrank"), CategoryFilter.Custom); moddedDropdown.Select(0); var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), isHorizontal: true) { Stretch = true }; subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform)) { ScrollBarVisible = true }; var searchTitle = new GUITextBlock(new RectTransform(new Vector2(0.001f, 1.0f), filterContainer.RectTransform), TextManager.Get("serverlog.filter"), textAlignment: Alignment.CenterLeft, font: GUI.Font); var searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 1.0f), filterContainer.RectTransform, Anchor.CenterRight), font: GUI.Font, createClearButton: true); filterContainer.RectTransform.MinSize = searchBox.RectTransform.MinSize; searchBox.OnSelected += (sender, userdata) => { searchTitle.Visible = false; }; searchBox.OnDeselected += (sender, userdata) => { searchTitle.Visible = true; }; searchBox.OnTextChanged += (textBox, text) => { FilterSubs(subList, text); return(true); }; moddedDropdown.OnSelected = (component, data) => { searchBox.Text = string.Empty; subFilter = (CategoryFilter)data; UpdateSubList(SubmarineInfo.SavedSubmarines); return(true); }; subList.OnSelected = OnSubSelected; } else // Spacing to fix the multiplayer campaign setup layout { CreateMultiplayerCampaignSubList(leftColumn.RectTransform); //spacing //new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), leftColumn.RectTransform), style: null); } // New game right side subPreviewContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform)) { Stretch = true }; var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.12f), (isMultiplayer ? leftColumn : rightColumn).RectTransform) { MaxSize = new Point(int.MaxValue, 60) }, childAnchor: Anchor.TopRight); if (!isMultiplayer) { buttonContainer.IgnoreLayoutGroups = true; } StartButton = new GUIButton(new RectTransform(new Vector2(0.45f, 1f), buttonContainer.RectTransform, Anchor.BottomRight) { MaxSize = new Point(350, 60) }, TextManager.Get("StartCampaignButton")) { OnClicked = (GUIButton btn, object userData) => { if (string.IsNullOrWhiteSpace(saveNameBox.Text)) { saveNameBox.Flash(GUI.Style.Red); return(false); } SubmarineInfo selectedSub = null; if (!isMultiplayer) { if (!(subList.SelectedData is SubmarineInfo)) { return(false); } selectedSub = subList.SelectedData as SubmarineInfo; } else { if (GameMain.NetLobbyScreen.SelectedSub == null) { return(false); } selectedSub = GameMain.NetLobbyScreen.SelectedSub; } if (selectedSub.SubmarineClass == SubmarineClass.Undefined) { new GUIMessageBox(TextManager.Get("error"), TextManager.Get("undefinedsubmarineselected")); return(false); } if (string.IsNullOrEmpty(selectedSub.MD5Hash.Hash)) { ((GUITextBlock)subList.SelectedComponent).TextColor = Color.DarkRed * 0.8f; subList.SelectedComponent.CanBeFocused = false; subList.Deselect(); return(false); } string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text); bool hasRequiredContentPackages = selectedSub.RequiredContentPackagesInstalled; if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages) { if (!hasRequiredContentPackages) { var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"), TextManager.GetWithVariable("ContentPackageMismatchWarning", "[requiredcontentpackages]", string.Join(", ", selectedSub.RequiredContentPackages)), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked = msgBox.Close; msgBox.Buttons[0].OnClicked += (button, obj) => { if (GUIMessageBox.MessageBoxes.Count == 0) { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); if (isMultiplayer) { CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup"); } } return(true); }; msgBox.Buttons[1].OnClicked = msgBox.Close; } if (selectedSub.HasTag(SubmarineTag.Shuttle)) { var msgBox = new GUIMessageBox(TextManager.Get("ShuttleSelected"), TextManager.Get("ShuttleWarning"), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked = (button, obj) => { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); if (isMultiplayer) { CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup"); } return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked = msgBox.Close; return(false); } } else { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); if (isMultiplayer) { CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup"); } } return(true); } }; if (!isMultiplayer) { var disclaimerBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.8f), rightColumn.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(5) }, style: "GUINotificationButton") { IgnoreLayoutGroups = true, OnClicked = (btn, userdata) => { GameMain.Instance.ShowCampaignDisclaimer(); return(true); } }; disclaimerBtn.RectTransform.MaxSize = new Point((int)(30 * GUI.Scale)); } columnContainer.Recalculate(); leftColumn.Recalculate(); rightColumn.Recalculate(); if (submarines != null) { UpdateSubList(submarines); } UpdateLoadMenu(saveFiles); }
//private GUIComponent editingHUD; public SerializableEntityEditor(ISerializableEntity entity, bool inGame, GUIComponent parent, bool showName) : base("") { List <SerializableProperty> editableProperties = inGame ? SerializableProperty.GetProperties <InGameEditable>(entity) : SerializableProperty.GetProperties <Editable>(entity); if (parent != null) { parent.AddChild(this); } if (showName) { new GUITextBlock(new Rectangle(0, 0, 100, 20), entity.Name, "", Alignment.TopLeft, Alignment.TopLeft, this, false, GUI.Font); } int y = showName ? 30 : 10, padding = 10; foreach (var property in editableProperties) { //int boxHeight = 18; //var editable = property.Attributes.OfType<Editable>().FirstOrDefault(); //if (editable != null) boxHeight = (int)(Math.Ceiling(editable.MaxLength / 40.0f) * 18.0f); object value = property.GetValue(); GUIComponent propertyField = null; if (value is bool) { propertyField = CreateBoolField(entity, property, (bool)value, y, this); } else if (value.GetType().IsEnum) { propertyField = CreateEnumField(entity, property, value, y, this); } else if (value is string) { propertyField = CreateStringField(entity, property, (string)value, y, this); } else if (value is int) { propertyField = CreateIntField(entity, property, (int)value, y, this); } else if (value is float) { propertyField = CreateFloatField(entity, property, (float)value, y, this); } else if (value is Vector2) { propertyField = CreateVector2Field(entity, property, (Vector2)value, y, this); } else if (value is Vector3) { propertyField = CreateVector3Field(entity, property, (Vector3)value, y, this); } else if (value is Vector4) { propertyField = CreateVector4Field(entity, property, (Vector4)value, y, this); } else if (value is Color) { propertyField = CreateColorField(entity, property, (Color)value, y, this); } else if (value is Rectangle) { propertyField = CreateRectangleField(entity, property, (Rectangle)value, y, this); } if (propertyField != null) { y += propertyField.Rect.Height + padding; } } if (children.Count > 0) { SetDimensions(new Point(Rect.Width, children.Last().Rect.Bottom - Rect.Y + 10), false); } else { SetDimensions(new Point(Rect.Width, 0), false); } if (parent is GUIListBox) { ((GUIListBox)parent).UpdateScrollBarSize(); } }
private GUIComponent CreateEnumField(ISerializableEntity entity, SerializableProperty property, object value, int yPos, GUIComponent parent) { var label = new GUITextBlock(new Rectangle(0, yPos, 0, 18), property.Name, "", Alignment.TopLeft, Alignment.Left, parent, false, GUI.SmallFont); label.ToolTip = property.GetAttribute <Editable>().ToolTip; GUIDropDown enumDropDown = new GUIDropDown(new Rectangle(180, yPos, 0, 18), "", "", Alignment.TopLeft, parent); enumDropDown.ToolTip = property.GetAttribute <Editable>().ToolTip; foreach (object enumValue in Enum.GetValues(value.GetType())) { var enumTextBlock = new GUITextBlock(new Rectangle(0, 0, 200, 25), enumValue.ToString(), "", enumDropDown); enumTextBlock.UserData = enumValue; } enumDropDown.OnSelected += (selected, val) => { if (property.TrySetValue(val)) { TrySendNetworkUpdate(entity, property); } return(true); }; enumDropDown.SelectItem(value); return(enumDropDown); }
public SubEditorScreen() { cam = new Camera(); //cam.Translate(new Vector2(-10.0f, 50.0f)); selectedTab = -1; topPanel = new GUIFrame(new Rectangle(0, 0, 0, 35), "GUIFrameTop"); topPanel.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); hullVolumeFrame = new GUIFrame(new Rectangle(145, 26, 280, 70), "", topPanel); hullVolumeFrame.Visible = false; hullVolumeFrame.Padding = new Vector4(3.0f, 3.0f, 3.0f, 3.0f); GUITextBlock totalHullVolume = new GUITextBlock(new Rectangle(0, 0, 0, 20), "", "", hullVolumeFrame, GUI.SmallFont); totalHullVolume.TextGetter = GetTotalHullVolume; GUITextBlock selectedHullVolume = new GUITextBlock(new Rectangle(0, 30, 0, 20), "", "", hullVolumeFrame, GUI.SmallFont); selectedHullVolume.TextGetter = GetSelectedHullVolume; var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", "", topPanel); button.OnClicked = (GUIButton btn, object data) => { saveFrame = null; selectedTab = -1; CreateLoadScreen(); return(true); }; button = new GUIButton(new Rectangle(80, 0, 70, 20), "Save", "", topPanel); button.OnClicked = (GUIButton btn, object data) => { loadFrame = null; selectedTab = -1; CreateSaveScreen(); return(true); }; var nameLabel = new GUITextBlock(new Rectangle(170, 0, 150, 20), "", "", Alignment.TopLeft, Alignment.CenterLeft, topPanel, false, GUI.LargeFont); nameLabel.TextGetter = GetSubName; linkedSubBox = new GUIDropDown(new Rectangle(750, 0, 200, 20), "Add submarine", "", topPanel); linkedSubBox.ToolTip = "Places another submarine into the current submarine file. " + "Can be used for adding things such as smaller vessels, " + "escape pods or detachable sections into the main submarine."; foreach (Submarine sub in Submarine.SavedSubmarines) { linkedSubBox.AddItem(sub.Name, sub); } linkedSubBox.OnSelected += SelectLinkedSub; leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft"); leftPanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); GUITextBlock itemCount = new GUITextBlock(new Rectangle(0, 30, 0, 20), "", "", leftPanel); itemCount.TextGetter = GetItemCount; GUITextBlock structureCount = new GUITextBlock(new Rectangle(0, 50, 0, 20), "", "", leftPanel); structureCount.TextGetter = GetStructureCount; GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length]; int width = 400, height = 400; int y = 90; int i = 0; foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory))) { var catButton = new GUIButton(new Rectangle(0, y, 0, 20), category.ToString(), Alignment.Left, "", leftPanel); catButton.UserData = i; catButton.OnClicked = SelectTab; y += 25; GUItabs[i] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), ""); GUItabs[i].Padding = new Vector4(10.0f, 30.0f, 10.0f, 20.0f); new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, GUItabs[i], false, GUI.SmallFont); GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), null, null, Alignment.TopRight, Alignment.CenterLeft, "", GUItabs[i]); searchBox.Font = GUI.SmallFont; searchBox.OnTextChanged = FilterMessages; var clearButton = new GUIButton(new Rectangle(0, 0, 15, 15), "x", Alignment.TopRight, "", GUItabs[i]); clearButton.OnClicked = ClearFilter; clearButton.UserData = searchBox; GUIListBox itemList = new GUIListBox(new Rectangle(0, 20, 0, 0), Color.White * 0.7f, "", GUItabs[i]); itemList.OnSelected = SelectPrefab; itemList.CheckSelected = MapEntityPrefab.GetSelected; foreach (MapEntityPrefab ep in MapEntityPrefab.List) { if (!ep.Category.HasFlag(category)) { continue; } GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, "ListBoxElement", itemList); frame.UserData = ep; frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); GUITextBlock textBlock = new GUITextBlock( new Rectangle(40, 0, 0, 25), ep.Name, "", Alignment.Top, Alignment.CenterLeft, frame); textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); if (!string.IsNullOrWhiteSpace(ep.Description)) { textBlock.ToolTip = ep.Description; } if (ep.sprite != null) { GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.CenterLeft, frame); img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f); img.Color = ep.SpriteColor; } } itemList.children.Sort((i1, i2) => (i1.UserData as MapEntityPrefab).Name.CompareTo((i2.UserData as MapEntityPrefab).Name)); i++; } y += 10; button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, "", leftPanel); button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring."; button.OnClicked = ToggleCharacterMode; y += 25; button = new GUIButton(new Rectangle(0, y, 0, 20), "Wiring mode", Alignment.Left, "", leftPanel); //button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring."; button.OnClicked = ToggleWiringMode; y += 35; button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, "", leftPanel); button.ToolTip = "AI controlled crew members require waypoints to navigate around the sub."; button.OnClicked = GenerateWaypoints; y += 30; new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", "", leftPanel); var tickBox = new GUITickBox(new Rectangle(0, y + 20, 20, 20), "Waypoints", Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return(true); }; tickBox.Selected = true; tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), "Spawnpoints", Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return(true); }; tickBox.Selected = true; tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), "Links", Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Item.ShowLinks = !Item.ShowLinks; return(true); }; tickBox.Selected = true; tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), "Hulls", Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Hull.ShowHulls = !Hull.ShowHulls; return(true); }; tickBox.Selected = true; tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), "Gaps", Alignment.TopLeft, leftPanel); tickBox.OnSelected = (GUITickBox obj) => { Gap.ShowGaps = !Gap.ShowGaps; return(true); }; tickBox.Selected = true; y += 150; if (y < GameMain.GraphicsHeight - 100) { new GUITextBlock(new Rectangle(0, y, 0, 15), "Previously used:", "", leftPanel); previouslyUsedList = new GUIListBox(new Rectangle(0, y + 20, 0, Math.Min(GameMain.GraphicsHeight - y - 80, 150)), "", leftPanel); previouslyUsedList.OnSelected = SelectPrefab; } }
public void Select(int childIndex, bool force = false, bool autoScroll = true) { if (childIndex >= Content.CountChildren || childIndex < 0) { return; } GUIComponent child = Content.GetChild(childIndex); bool wasSelected = true; if (OnSelected != null) { wasSelected = force || OnSelected(child, child.UserData); } if (!wasSelected) { return; } if (SelectMultiple) { if (selected.Contains(child)) { selected.Remove(child); } else { selected.Add(child); } } else { selected.Clear(); selected.Add(child); } // Ensure that the selected element is visible. This may not be the case, if the selection is run from code. (e.g. if we have two list boxes that are synced) // TODO: This method only works when moving one item up/down (e.g. when using the up and down arrows) if (autoScroll) { if (ScrollBar.IsHorizontal) { if (child.Rect.X < MouseRect.X) { //child outside the left edge of the frame -> move left ScrollBar.BarScroll -= (float)(MouseRect.X - child.Rect.X) / (totalSize - Content.Rect.Width); } else if (child.Rect.Right > MouseRect.Right) { //child outside the right edge of the frame -> move right ScrollBar.BarScroll += (float)(child.Rect.Right - MouseRect.Right) / (totalSize - Content.Rect.Width); } } else { if (child.Rect.Y < MouseRect.Y) { //child above the top of the frame -> move up ScrollBar.BarScroll -= (float)(MouseRect.Y - child.Rect.Y) / (totalSize - Content.Rect.Height); } else if (child.Rect.Bottom > MouseRect.Bottom) { //child below the bottom of the frame -> move down ScrollBar.BarScroll += (float)(child.Rect.Bottom - MouseRect.Bottom) / (totalSize - Content.Rect.Height); } } } // If one of the children is the subscriber, we don't want to register, because it will unregister the child. if (RectTransform.GetAllChildren().None(rt => rt.GUIComponent == GUI.KeyboardDispatcher.Subscriber)) { Selected = true; GUI.KeyboardDispatcher.Subscriber = this; } }
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam) { if (GUI.DisableHUD) { return; } character.CharacterHealth.Alignment = Alignment.Right; if (GameMain.GameSession?.CrewManager != null) { orderIndicatorCount.Clear(); foreach (Pair <Order, float> timedOrder in GameMain.GameSession.CrewManager.ActiveOrders) { DrawOrderIndicator(spriteBatch, cam, character, timedOrder.First, MathHelper.Clamp(timedOrder.Second / 10.0f, 0.2f, 1.0f)); } if (character.CurrentOrder != null) { DrawOrderIndicator(spriteBatch, cam, character, character.CurrentOrder, 1.0f); } } foreach (Character.ObjectiveEntity objectiveEntity in character.ActiveObjectiveEntities) { DrawObjectiveIndicator(spriteBatch, cam, character, objectiveEntity, 1.0f); } foreach (Item brokenItem in brokenItems) { if (brokenItem.NonInteractable) { continue; } float dist = Vector2.Distance(character.WorldPosition, brokenItem.WorldPosition); Vector2 drawPos = brokenItem.DrawPosition; float alpha = Math.Min((1000.0f - dist) / 1000.0f * 2.0f, 1.0f); if (alpha <= 0.0f) { continue; } GUI.DrawIndicator(spriteBatch, drawPos, cam, 100.0f, GUI.BrokenIcon, Color.Lerp(GUI.Style.Red, GUI.Style.Orange * 0.5f, brokenItem.Condition / brokenItem.MaxCondition) * alpha); } if (!character.IsIncapacitated && character.Stun <= 0.0f && !IsCampaignInterfaceOpen && (!character.IsKeyDown(InputType.Aim) || character.SelectedItems.Any(it => it?.GetComponent <Sprayer>() == null))) { if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected) { DrawCharacterHoverTexts(spriteBatch, cam, character); } if (character.FocusedItem != null) { if (focusedItem != character.FocusedItem) { focusedItemOverlayTimer = Math.Min(1.0f, focusedItemOverlayTimer); shouldRecreateHudTexts = true; } focusedItem = character.FocusedItem; } if (focusedItem != null && focusedItemOverlayTimer > ItemOverlayDelay) { Vector2 circlePos = cam.WorldToScreen(focusedItem.DrawPosition); float circleSize = Math.Max(focusedItem.Rect.Width, focusedItem.Rect.Height) * 1.5f; circleSize = MathHelper.Clamp(circleSize, 45.0f, 100.0f) * Math.Min((focusedItemOverlayTimer - 1.0f) * 5.0f, 1.0f); if (circleSize > 0.0f) { Vector2 scale = new Vector2(circleSize / GUI.Style.FocusIndicator.FrameSize.X); GUI.Style.FocusIndicator.Draw(spriteBatch, (int)((focusedItemOverlayTimer - 1.0f) * GUI.Style.FocusIndicator.FrameCount * 3.0f), circlePos, Color.LightBlue * 0.3f, origin: GUI.Style.FocusIndicator.FrameSize.ToVector2() / 2, rotate: (float)Timing.TotalTime, scale: scale); } if (!GUI.DisableItemHighlights && !Inventory.DraggingItemToWorld) { bool shiftDown = PlayerInput.KeyDown(Keys.LeftShift) || PlayerInput.KeyDown(Keys.RightShift); if (shouldRecreateHudTexts || heldDownShiftWhenGotHudTexts != shiftDown) { shouldRecreateHudTexts = true; heldDownShiftWhenGotHudTexts = shiftDown; } var hudTexts = focusedItem.GetHUDTexts(character, shouldRecreateHudTexts); shouldRecreateHudTexts = false; int dir = Math.Sign(focusedItem.WorldPosition.X - character.WorldPosition.X); Vector2 textSize = GUI.Font.MeasureString(focusedItem.Name); Vector2 largeTextSize = GUI.SubHeadingFont.MeasureString(focusedItem.Name); Vector2 startPos = cam.WorldToScreen(focusedItem.DrawPosition); startPos.Y -= (hudTexts.Count + 1) * textSize.Y; if (focusedItem.Sprite != null) { startPos.X += (int)(circleSize * 0.4f * dir); startPos.Y -= (int)(circleSize * 0.4f); } Vector2 textPos = startPos; if (dir == -1) { textPos.X -= largeTextSize.X; } float alpha = MathHelper.Clamp((focusedItemOverlayTimer - ItemOverlayDelay) * 2.0f, 0.0f, 1.0f); GUI.DrawString(spriteBatch, textPos, focusedItem.Name, GUI.Style.TextColor * alpha, Color.Black * alpha * 0.7f, 2, font: GUI.SubHeadingFont); startPos.X += dir * 10.0f * GUI.Scale; textPos.X += dir * 10.0f * GUI.Scale; textPos.Y += largeTextSize.Y; foreach (ColoredText coloredText in hudTexts) { if (dir == -1) { textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X); } GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color * alpha, Color.Black * alpha * 0.7f, 2, GUI.SmallFont); textPos.Y += textSize.Y; } } } foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values) { progressBar.Draw(spriteBatch, cam); } foreach (Character npc in Character.CharacterList) { if (npc.CampaignInteractionType == CampaignMode.InteractionType.None || npc.Submarine != character.Submarine || npc.IsDead || npc.IsIncapacitated) { continue; } var iconStyle = GUI.Style.GetComponentStyle("CampaignInteractionIcon." + npc.CampaignInteractionType); GUI.DrawIndicator(spriteBatch, npc.WorldPosition, cam, 500.0f, iconStyle.GetDefaultSprite(), iconStyle.Color); } } if (character.SelectedConstruction != null && (character.CanInteractWith(Character.Controlled.SelectedConstruction) || Screen.Selected == GameMain.SubEditorScreen)) { character.SelectedConstruction.DrawHUD(spriteBatch, cam, Character.Controlled); } if (Character.Controlled.Inventory != null) { foreach (Item item in Character.Controlled.Inventory.Items) { if (item == null) { continue; } if (Character.Controlled.HasEquippedItem(item)) { item.DrawHUD(spriteBatch, cam, Character.Controlled); } } } if (IsCampaignInterfaceOpen) { return; } if (character.Inventory != null) { for (int i = 0; i < character.Inventory.Items.Length - 1; i++) { var item = character.Inventory.Items[i]; if (item == null || character.Inventory.SlotTypes[i] == InvSlotType.Any) { continue; } foreach (ItemComponent ic in item.Components) { if (ic.DrawHudWhenEquipped) { ic.DrawHUD(spriteBatch, character); } } } } bool mouseOnPortrait = false; if (character.Stun <= 0.1f && !character.IsDead) { if (CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null) { if (character.Info != null && !character.ShouldLockHud()) { character.Info.DrawBackground(spriteBatch); character.Info.DrawJobIcon(spriteBatch, new Rectangle( (int)(HUDLayoutSettings.BottomRightInfoArea.X + HUDLayoutSettings.BottomRightInfoArea.Width * 0.05f), (int)(HUDLayoutSettings.BottomRightInfoArea.Y + HUDLayoutSettings.BottomRightInfoArea.Height * 0.1f), (int)(HUDLayoutSettings.BottomRightInfoArea.Width / 2), (int)(HUDLayoutSettings.BottomRightInfoArea.Height * 0.7f))); character.Info.DrawPortrait(spriteBatch, HUDLayoutSettings.PortraitArea.Location.ToVector2(), new Vector2(-12 * GUI.Scale, 4 * GUI.Scale), targetWidth: HUDLayoutSettings.PortraitArea.Width, true); } mouseOnPortrait = HUDLayoutSettings.BottomRightInfoArea.Contains(PlayerInput.MousePosition) && !character.ShouldLockHud(); if (mouseOnPortrait) { GUI.UIGlow.Draw(spriteBatch, HUDLayoutSettings.BottomRightInfoArea, GUI.Style.Green * 0.5f); } } if (ShouldDrawInventory(character)) { character.Inventory.Locked = character == Character.Controlled && LockInventory(character); character.Inventory.DrawOwn(spriteBatch); character.Inventory.CurrentLayout = CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null ? CharacterInventory.Layout.Default : CharacterInventory.Layout.Right; } } if (!character.IsIncapacitated && character.Stun <= 0.0f) { if (character.IsHumanoid && character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) { if (character.SelectedCharacter.CanInventoryBeAccessed) { character.SelectedCharacter.Inventory.Locked = false; character.SelectedCharacter.Inventory.CurrentLayout = CharacterInventory.Layout.Left; character.SelectedCharacter.Inventory.DrawOwn(spriteBatch); } if (CharacterHealth.OpenHealthWindow == character.SelectedCharacter.CharacterHealth) { character.SelectedCharacter.CharacterHealth.Alignment = Alignment.Left; character.SelectedCharacter.CharacterHealth.DrawStatusHUD(spriteBatch); } } else if (character.Inventory != null) { //character.Inventory.CurrentLayout = (CharacterHealth.OpenHealthWindow == null) ? Alignment.Center : Alignment.Left; } } if (mouseOnPortrait) { GUIComponent.DrawToolTip( spriteBatch, character.Info?.Job == null ? character.DisplayName : character.DisplayName + " (" + character.Info.Job.Name + ")", HUDLayoutSettings.PortraitArea); } }
public GUIButton(Rectangle rect, string text, Alignment alignment, string style, GUIComponent parent = null) : this(rect, text, null, alignment, style, parent) { }
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam) { if (GUI.DisableHUD) { return; } character.CharacterHealth.Alignment = Alignment.Right; if (GameMain.GameSession?.CrewManager != null) { orderIndicatorCount.Clear(); foreach (Pair <Order, float> timedOrder in GameMain.GameSession.CrewManager.ActiveOrders) { DrawOrderIndicator(spriteBatch, cam, character, timedOrder.First, MathHelper.Clamp(timedOrder.Second / 10.0f, 0.2f, 1.0f)); } if (character.CurrentOrder != null) { DrawOrderIndicator(spriteBatch, cam, character, character.CurrentOrder, 1.0f); } } foreach (Character.ObjectiveEntity objectiveEntity in character.ActiveObjectiveEntities) { DrawObjectiveIndicator(spriteBatch, cam, character, objectiveEntity, 1.0f); } foreach (Item brokenItem in brokenItems) { float dist = Vector2.Distance(character.WorldPosition, brokenItem.WorldPosition); Vector2 drawPos = brokenItem.DrawPosition; float alpha = Math.Min((1000.0f - dist) / 1000.0f * 2.0f, 1.0f); if (alpha <= 0.0f) { continue; } GUI.DrawIndicator(spriteBatch, drawPos, cam, 100.0f, GUI.BrokenIcon, Color.Lerp(Color.DarkRed, Color.Orange * 0.5f, brokenItem.Condition / brokenItem.MaxCondition) * alpha); } if (!character.IsUnconscious && character.Stun <= 0.0f) { if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected) { Vector2 startPos = character.DrawPosition + (character.FocusedCharacter.DrawPosition - character.DrawPosition) * 0.7f; startPos = cam.WorldToScreen(startPos); string focusName = character.FocusedCharacter.DisplayName; if (character.FocusedCharacter.Info != null) { focusName = character.FocusedCharacter.Info.DisplayName; } Vector2 textPos = startPos; Vector2 offset = GUI.Font.MeasureString(focusName); textPos -= new Vector2(offset.X / 2, offset.Y); Color nameColor = Color.White; if (character.TeamID != character.FocusedCharacter.TeamID) { nameColor = character.FocusedCharacter.TeamID == Character.TeamType.FriendlyNPC ? Color.SkyBlue : Color.Red; } GUI.DrawString(spriteBatch, textPos, focusName, nameColor, Color.Black * 0.7f, 2); textPos.Y += offset.Y; if (character.FocusedCharacter.CanInventoryBeAccessed) { GUI.DrawString(spriteBatch, textPos, GetCachedHudText("GrabHint", GameMain.Config.KeyBind(InputType.Grab).ToString()), Color.LightGreen, Color.Black, 2, GUI.SmallFont); textPos.Y += offset.Y; } if (character.FocusedCharacter.CharacterHealth.UseHealthWindow) { GUI.DrawString(spriteBatch, textPos, GetCachedHudText("HealHint", GameMain.Config.KeyBind(InputType.Health).ToString()), Color.LightGreen, Color.Black, 2, GUI.SmallFont); textPos.Y += offset.Y; } if (!string.IsNullOrEmpty(character.FocusedCharacter.customInteractHUDText)) { GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.customInteractHUDText, Color.LightGreen, Color.Black, 2, GUI.SmallFont); textPos.Y += offset.Y; } } float circleSize = 1.0f; if (character.FocusedItem != null) { if (focusedItem != character.FocusedItem) { focusedItemOverlayTimer = Math.Min(1.0f, focusedItemOverlayTimer); } focusedItem = character.FocusedItem; } if (focusedItem != null && focusedItemOverlayTimer > ItemOverlayDelay) { Vector2 circlePos = cam.WorldToScreen(focusedItem.DrawPosition); circleSize = Math.Max(focusedItem.Rect.Width, focusedItem.Rect.Height) * 1.5f; circleSize = MathHelper.Clamp(circleSize, 45.0f, 100.0f) * Math.Min((focusedItemOverlayTimer - 1.0f) * 5.0f, 1.0f); if (circleSize > 0.0f) { Vector2 scale = new Vector2(circleSize / GUI.Style.FocusIndicator.FrameSize.X); GUI.Style.FocusIndicator.Draw(spriteBatch, (int)((focusedItemOverlayTimer - 1.0f) * GUI.Style.FocusIndicator.FrameCount * 3.0f), circlePos, Color.LightBlue * 0.3f, origin: GUI.Style.FocusIndicator.FrameSize.ToVector2() / 2, rotate: (float)Timing.TotalTime, scale: scale); } if (!GUI.DisableItemHighlights && !Inventory.DraggingItemToWorld) { var hudTexts = focusedItem.GetHUDTexts(character); int dir = Math.Sign(focusedItem.WorldPosition.X - character.WorldPosition.X); Vector2 offset = GUI.Font.MeasureString(focusedItem.Name); Vector2 startPos = cam.WorldToScreen(focusedItem.DrawPosition); startPos.Y -= (hudTexts.Count + 1) * offset.Y; if (focusedItem.Sprite != null) { startPos.X += (int)(circleSize * 0.4f * dir); startPos.Y -= (int)(circleSize * 0.4f); } Vector2 textPos = startPos; if (dir == -1) { textPos.X -= offset.X; } float alpha = MathHelper.Clamp((focusedItemOverlayTimer - ItemOverlayDelay) * 2.0f, 0.0f, 1.0f); GUI.DrawString(spriteBatch, textPos, focusedItem.Name, Color.White * alpha, Color.Black * alpha * 0.7f, 2); textPos.Y += offset.Y; foreach (ColoredText coloredText in hudTexts) { if (dir == -1) { textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X); } GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color * alpha, Color.Black * alpha * 0.7f, 2, GUI.SmallFont); textPos.Y += offset.Y; } } } foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values) { progressBar.Draw(spriteBatch, cam); } } if (character.SelectedConstruction != null && (character.CanInteractWith(Character.Controlled.SelectedConstruction) || Screen.Selected == GameMain.SubEditorScreen)) { character.SelectedConstruction.DrawHUD(spriteBatch, cam, Character.Controlled); } if (character.Inventory != null) { for (int i = 0; i < character.Inventory.Items.Length - 1; i++) { var item = character.Inventory.Items[i]; if (item == null || character.Inventory.SlotTypes[i] == InvSlotType.Any) { continue; } foreach (ItemComponent ic in item.Components) { if (ic.DrawHudWhenEquipped) { ic.DrawHUD(spriteBatch, character); } } } } bool drawPortraitToolTip = false; if (character.Stun <= 0.1f && !character.IsDead) { if (CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null) { if (character.Info != null) { character.Info.DrawPortrait(spriteBatch, HUDLayoutSettings.PortraitArea.Location.ToVector2(), targetWidth: HUDLayoutSettings.PortraitArea.Width); } drawPortraitToolTip = HUDLayoutSettings.PortraitArea.Contains(PlayerInput.MousePosition); } if (character.Inventory != null && !character.LockHands) { character.Inventory.Locked = (character.SelectedConstruction?.GetComponent <Controller>()?.User == character); character.Inventory.DrawOwn(spriteBatch); character.Inventory.CurrentLayout = CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null ? CharacterInventory.Layout.Default : CharacterInventory.Layout.Right; } } if (!character.IsUnconscious && character.Stun <= 0.0f) { if (character.IsHumanoid && character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) { if (character.SelectedCharacter.CanInventoryBeAccessed) { ///character.Inventory.CurrentLayout = Alignment.Left; character.SelectedCharacter.Inventory.CurrentLayout = CharacterInventory.Layout.Left; character.SelectedCharacter.Inventory.DrawOwn(spriteBatch); } else { //character.Inventory.CurrentLayout = (CharacterHealth.OpenHealthWindow == null) ? Alignment.Center : Alignment.Left; } if (CharacterHealth.OpenHealthWindow == character.SelectedCharacter.CharacterHealth) { character.SelectedCharacter.CharacterHealth.Alignment = Alignment.Left; character.SelectedCharacter.CharacterHealth.DrawStatusHUD(spriteBatch); } } else if (character.Inventory != null) { //character.Inventory.CurrentLayout = (CharacterHealth.OpenHealthWindow == null) ? Alignment.Center : Alignment.Left; } } if (drawPortraitToolTip) { GUIComponent.DrawToolTip( spriteBatch, character.Info?.Job == null ? character.DisplayName : character.Name + " (" + character.Info.Job.Name + ")", HUDLayoutSettings.PortraitArea); } }
private SubmarinePreview(SubmarineInfo subInfo) { camera = new Camera(); submarineInfo = subInfo; spriteRecorder = new SpriteRecorder(); isDisposed = false; loadTask = null; hullCollections = new Dictionary <string, HullCollection>(); doors = new List <Door>(); previewFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null); new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, previewFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker"); new GUIButton(new RectTransform(Vector2.One, previewFrame.RectTransform), "", style: null) { OnClicked = (btn, obj) => { Dispose(); return(false); } }; var innerFrame = new GUIFrame(new RectTransform(Vector2.One * 0.9f, previewFrame.RectTransform, Anchor.Center)); int innerPadding = GUI.IntScale(100f); var innerPadded = new GUIFrame(new RectTransform(new Point(innerFrame.Rect.Width - innerPadding, innerFrame.Rect.Height - innerPadding), previewFrame.RectTransform, Anchor.Center), style: null) { OutlineColor = Color.Black, OutlineThickness = 2 }; GUITextBlock titleText = null; GUIListBox specsContainer = null; new GUICustomComponent(new RectTransform(Vector2.One, innerPadded.RectTransform, Anchor.Center), (spriteBatch, component) => { camera.UpdateTransform(interpolate: true, updateListener: false); Rectangle drawRect = new Rectangle(component.Rect.X + 1, component.Rect.Y + 1, component.Rect.Width - 2, component.Rect.Height - 2); RenderSubmarine(spriteBatch, drawRect); }, (deltaTime, component) => { bool isMouseOnComponent = GUI.MouseOn == component; camera.MoveCamera(deltaTime, allowZoom: isMouseOnComponent, followSub: false); if (isMouseOnComponent && (PlayerInput.MidButtonHeld() || PlayerInput.LeftButtonHeld())) { Vector2 moveSpeed = PlayerInput.MouseSpeed * (float)deltaTime * 60.0f / camera.Zoom; moveSpeed.X = -moveSpeed.X; camera.Position += moveSpeed; } if (titleText != null && specsContainer != null) { specsContainer.Visible = GUI.IsMouseOn(titleText); } }); var topContainer = new GUIFrame(new RectTransform(new Vector2(1f, 0.07f), innerPadded.RectTransform, Anchor.TopLeft), style: null) { Color = Color.Black * 0.65f }; var topLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.97f, 5f / 7f), topContainer.RectTransform, Anchor.Center), isHorizontal: true, childAnchor: Anchor.CenterLeft); titleText = new GUITextBlock(new RectTransform(new Vector2(0.95f, 1f), topLayout.RectTransform), subInfo.DisplayName, font: GUI.LargeFont); new GUIButton(new RectTransform(new Vector2(0.05f, 1f), topLayout.RectTransform), TextManager.Get("Close")) { OnClicked = (btn, obj) => { Dispose(); return(false); } }; specsContainer = new GUIListBox(new RectTransform(new Vector2(0.4f, 1f), innerPadded.RectTransform, Anchor.TopLeft) { RelativeOffset = new Vector2(0.015f, 0.07f) }) { Color = Color.Black * 0.65f, ScrollBarEnabled = false, ScrollBarVisible = false, Spacing = 5 }; subInfo.CreateSpecsWindow(specsContainer, GUI.Font, includeTitle: false, includeDescription: true); int width = specsContainer.Rect.Width; void recalculateSpecsContainerHeight() { int totalSize = 0; var children = specsContainer.Content.Children.Where(c => c.Visible); foreach (GUIComponent child in children) { totalSize += child.Rect.Height; } totalSize += specsContainer.Content.CountChildren * specsContainer.Spacing; if (specsContainer.PadBottom) { GUIComponent last = specsContainer.Content.Children.LastOrDefault(); if (last != null) { totalSize += specsContainer.Rect.Height - last.Rect.Height; } } specsContainer.RectTransform.Resize(new Point(width, totalSize), true); specsContainer.RecalculateChildren(); } //hell recalculateSpecsContainerHeight(); specsContainer.Content.GetAllChildren <GUITextBlock>().ForEach(c => { var firstChild = c.Children.FirstOrDefault() as GUITextBlock; if (firstChild != null) { firstChild.CalculateHeightFromText(); firstChild.SetTextPos(); c.RectTransform.MinSize = new Point(0, firstChild.Rect.Height); } c.CalculateHeightFromText(); c.SetTextPos(); }); recalculateSpecsContainerHeight(); GeneratePreviewMeshes(); }
public GUITextBlock(Rectangle rect, string text, string style, Alignment alignment = Alignment.TopLeft, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null, bool wrap = false, ScalableFont font = null) : base(style) { this.Font = font == null ? GUI.Font : font; this.rect = rect; this.text = text; this.alignment = alignment; this.padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); this.textAlignment = textAlignment; if (parent != null) { parent.AddChild(this); } this.Wrap = wrap; SetTextPos(); TextScale = 1.0f; if (rect.Height == 0 && !string.IsNullOrEmpty(Text)) { this.rect.Height = (int)Font.MeasureString(wrappedText).Y; } }
public GUITextBlock(Rectangle rect, string text, Color?color, Color?textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, string style = null, GUIComponent parent = null, bool wrap = false, ScalableFont font = null) : this(rect, text, style, alignment, textAlignment, parent, wrap, font) { if (color != null) { this.color = (Color)color; } if (textColor != null) { this.textColor = (Color)textColor; } }
protected override void UpdateDimensions(GUIComponent parent = null) { base.UpdateDimensions(parent); SetTextPos(); }
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 != null) { foreach (Mission mission in startLocation.SelectedMissions) { if (mission.Locations[0] == mission.Locations[1] || mission.Locations.Contains(campaignMode?.Map.SelectedLocation)) { missionsToDisplay.Add(mission); } } } 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, 1.0f), missionContentHorizontal.RectTransform)) { AbsoluteSpacing = GUI.IntScale(5) }; missionContentHorizontal.Recalculate(); 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 }; } } var missionDescription = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), missionMessage, wrap: true, parseRichText: true); int reward = displayedMission.GetReward(Submarine.MainSub); if (selectedMissions.Contains(displayedMission) && displayedMission.Completed && reward > 0) { string rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", reward)); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), displayedMission.GetMissionRewardText(Submarine.MainSub), 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"); } foreach (GUIComponent child in missionTextContent.Children) { child.RectTransform.IsFixedSize = true; } missionTextContent.RectTransform.MinSize = new Point(0, missionTextContent.Children.Sum(c => c.Rect.Height + missionTextContent.AbsoluteSpacing)); missionContentHorizontal.RectTransform.MinSize = new Point(0, (int)(missionTextContent.Rect.Height / missionTextContent.RectTransform.RelativeSize.Y)); } 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); }
public GUIButton(Rectangle rect, string text, Color?color, string style, GUIComponent parent = null) : this(rect, text, color, (Alignment.Left | Alignment.Top), style, parent) { }
private GUIFrame CreateReputationElement(GUIComponent parent, string name, float reputation, float normalizedReputation, float initialReputation, string shortDescription, string fullDescription, Sprite icon, Sprite backgroundPortrait, Color iconColor) { var factionFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), parent.RectTransform), style: null); if (backgroundPortrait != null) { new GUICustomComponent(new RectTransform(Vector2.One, factionFrame.RectTransform), onDraw: (sb, customComponent) => { backgroundPortrait.Draw(sb, customComponent.Rect.Center.ToVector2(), customComponent.Color, backgroundPortrait.size / 2, scale: customComponent.Rect.Width / backgroundPortrait.size.X); }) { HideElementsOutsideFrame = true, IgnoreLayoutGroups = true, Color = iconColor * 0.2f }; } var factionInfoHorizontal = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), factionFrame.RectTransform, Anchor.Center), childAnchor: Anchor.CenterLeft, isHorizontal: true) { AbsoluteSpacing = GUI.IntScale(5), Stretch = true }; var factionTextContent = new GUILayoutGroup(new RectTransform(Vector2.One, factionInfoHorizontal.RectTransform)) { AbsoluteSpacing = GUI.IntScale(10), Stretch = true }; var factionIcon = new GUIImage(new RectTransform(new Point((int)(factionInfoHorizontal.Rect.Height * 0.7f)), factionInfoHorizontal.RectTransform, scaleBasis: ScaleBasis.Smallest), icon, scaleToFit: true) { Color = iconColor }; factionInfoHorizontal.Recalculate(); var header = new GUITextBlock(new RectTransform(new Point(factionTextContent.Rect.Width, GUI.IntScale(40)), factionTextContent.RectTransform), name, font: GUI.SubHeadingFont) { Padding = Vector4.Zero, UserData = "header" }; header.RectTransform.IsFixedSize = true; var sliderHolder = new GUILayoutGroup(new RectTransform(new Point((int)(factionTextContent.Rect.Width * 0.8f), GUI.IntScale(20.0f)), factionTextContent.RectTransform), childAnchor: Anchor.CenterLeft, isHorizontal: true) { RelativeSpacing = 0.05f, Stretch = true }; sliderHolder.RectTransform.IsFixedSize = true; factionTextContent.Recalculate(); new GUICustomComponent(new RectTransform(new Vector2(0.8f, 1.0f), sliderHolder.RectTransform), onDraw: (sb, customComponent) => DrawReputationBar(sb, customComponent.Rect, normalizedReputation)); string reputationText = Reputation.GetFormattedReputationText(normalizedReputation, reputation, addColorTags: true); int reputationChange = (int)Math.Round(reputation - initialReputation); if (Math.Abs(reputationChange) > 0) { string changeText = $"{(reputationChange > 0 ? "+" : "") + reputationChange}"; string colorStr = XMLExtensions.ColorToString(reputationChange > 0 ? GUI.Style.Green : GUI.Style.Red); var rtData = RichTextData.GetRichTextData($"{reputationText} (‖color:{colorStr}‖{changeText}‖color:end‖)", out string sanitizedText); new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), sliderHolder.RectTransform), rtData, sanitizedText, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont); } else { new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), sliderHolder.RectTransform), reputationText, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont, parseRichText: true); } //spacing new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), factionTextContent.RectTransform) { MinSize = new Point(0, GUI.IntScale(5)) }, style: null); var factionDescription = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.6f), factionTextContent.RectTransform), shortDescription, font: GUI.SmallFont, wrap: true) { UserData = "description", Padding = Vector4.Zero }; if (shortDescription != fullDescription && !string.IsNullOrEmpty(fullDescription)) { factionDescription.ToolTip = fullDescription; } //spacing new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), factionTextContent.RectTransform) { MinSize = new Point(0, GUI.IntScale(5)) }, style: null); factionInfoHorizontal.Recalculate(); factionTextContent.Recalculate(); return(factionFrame); }
public GUIButton(Rectangle rect, string text, Color?color, Alignment alignment, string style = "", GUIComponent parent = null) : this(rect, text, color, alignment, Alignment.Center, style, parent) { }
private void RepositionChildren() { var children = Content.Children; int x = 0, y = 0; if (ScrollBar.BarSize < 1.0f) { if (ScrollBar.IsHorizontal) { x -= (int)((totalSize - Content.Rect.Width) * ScrollBar.BarScroll); } else { y -= (int)((totalSize - Content.Rect.Height) * ScrollBar.BarScroll); } } for (int i = 0; i < Content.CountChildren; i++) { GUIComponent child = Content.GetChild(i); if (!child.Visible) { continue; } if (RectTransform != null) { if (child.RectTransform.AbsoluteOffset.X != x || child.RectTransform.AbsoluteOffset.Y != y) { child.RectTransform.AbsoluteOffset = new Point(x, y); } } if (useGridLayout) { if (ScrollBar.IsHorizontal) { if (y + child.Rect.Height + Spacing > Content.Rect.Height) { y = 0; x += child.Rect.Width + Spacing; if (child.RectTransform.AbsoluteOffset.X != x || child.RectTransform.AbsoluteOffset.Y != y) { child.RectTransform.AbsoluteOffset = new Point(x, y); } y += child.Rect.Height + Spacing; } else { y += child.Rect.Height + Spacing; } } else { if (x + child.Rect.Width + Spacing > Content.Rect.Width) { x = 0; y += child.Rect.Height + Spacing; if (child.RectTransform.AbsoluteOffset.X != x || child.RectTransform.AbsoluteOffset.Y != y) { child.RectTransform.AbsoluteOffset = new Point(x, y); } x += child.Rect.Width + Spacing; } else { x += child.Rect.Width + Spacing; } } } else { if (ScrollBar.IsHorizontal) { x += child.Rect.Width + Spacing; } else { y += child.Rect.Height + Spacing; } } } }
public GUIButton(Rectangle rect, string text, Color?color, Alignment alignment, Alignment textAlignment, string style = "", GUIComponent parent = null) : base(style) { this.rect = rect; if (color != null) { this.color = (Color)color; } this.alignment = alignment; if (parent != null) { parent.AddChild(this); } frame = new GUIFrame(Rectangle.Empty, style, this); GUI.Style.Apply(frame, style == "" ? "GUIButton" : style); textBlock = new GUITextBlock(Rectangle.Empty, text, Color.Transparent, (this.style == null) ? Color.Black : this.style.textColor, textAlignment, null, this); GUI.Style.Apply(textBlock, style, this); Enabled = true; }
private GUIComponent CreateBoolField(ISerializableEntity entity, SerializableProperty property, bool value, int yPos, GUIComponent parent) { GUITickBox propertyTickBox = new GUITickBox(new Rectangle(10, yPos, 18, 18), property.Name, Alignment.Left, parent); propertyTickBox.Font = GUI.SmallFont; propertyTickBox.Selected = value; propertyTickBox.ToolTip = property.GetAttribute <Editable>().ToolTip; propertyTickBox.OnSelected = (tickBox) => { if (property.TrySetValue(tickBox.Selected)) { TrySendNetworkUpdate(entity, property); } return(true); }; return(propertyTickBox); }
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam) { if (statusIcons == null) { statusIcons = new Sprite("Content/UI/statusIcons.png", Vector2.Zero); } if (noiseOverlay == null) { noiseOverlay = new Sprite("Content/UI/noise.png", Vector2.Zero); } if (damageOverlay == null) { damageOverlay = new Sprite("Content/UI/damageOverlay.png", Vector2.Zero); } if (GUI.DisableHUD) { return; } if (character.Inventory != null) { for (int i = 0; i < character.Inventory.Items.Length - 1; i++) { var item = character.Inventory.Items[i]; if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any) { continue; } foreach (ItemComponent ic in item.components) { if (ic.DrawHudWhenEquipped) { ic.DrawHUD(spriteBatch, character); } } } } DrawStatusIcons(spriteBatch, character); if (!character.IsUnconscious && character.Stun <= 0.0f) { if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f) { character.Inventory.DrawOffset = Vector2.Zero; character.Inventory.DrawOwn(spriteBatch); } if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) { character.SelectedCharacter.Inventory.DrawOffset = new Vector2(320.0f, 0.0f); character.SelectedCharacter.Inventory.DrawOwn(spriteBatch); if (cprButton == null) { cprButton = new GUIButton( new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -30), new Point(130, 20)), "Perform CPR", ""); cprButton.OnClicked = (button, userData) => { if (Character.Controlled == null || Character.Controlled.SelectedCharacter == null) { return(false); } Character.Controlled.AnimController.Anim = (Character.Controlled.AnimController.Anim == AnimController.Animation.CPR) ? AnimController.Animation.None : AnimController.Animation.CPR; foreach (Limb limb in Character.Controlled.SelectedCharacter.AnimController.Limbs) { limb.pullJoint.Enabled = false; } if (GameMain.Client != null) { GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Repair }); } return(true); }; } //cprButton.Visible = character.GetSkillLevel("Medical") > 20.0f; if (cprButton.Visible) { cprButton.Draw(spriteBatch); } } if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected) { Vector2 startPos = character.DrawPosition + (character.FocusedCharacter.DrawPosition - character.DrawPosition) * 0.7f; startPos = cam.WorldToScreen(startPos); Vector2 textPos = startPos; textPos -= new Vector2(GUI.Font.MeasureString(character.FocusedCharacter.Info.Name).X / 2, 20); GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.Info.Name, Color.White, Color.Black, 2); } else if (character.SelectedCharacter == null && character.FocusedItem != null && character.SelectedConstruction == null) { var hudTexts = character.FocusedItem.GetHUDTexts(character); Vector2 startPos = new Vector2((int)(GameMain.GraphicsWidth / 2.0f), GameMain.GraphicsHeight); startPos.Y -= 50 + hudTexts.Count * 25; Vector2 textPos = startPos; textPos -= new Vector2((int)GUI.Font.MeasureString(character.FocusedItem.Name).X / 2, 20); GUI.DrawString(spriteBatch, textPos, character.FocusedItem.Name, Color.White, Color.Black * 0.7f, 2); textPos.Y += 30.0f; foreach (ColoredText coloredText in hudTexts) { textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X / 2); GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color, Color.Black * 0.7f, 2, GUI.SmallFont); textPos.Y += 25; } } foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values) { progressBar.Draw(spriteBatch, cam); } } if (Screen.Selected == GameMain.SubEditorScreen) { return; } if (character.IsUnconscious || (character.Oxygen < 80.0f && !character.IsDead)) { Vector2 offset = Rand.Vector(noiseOverlay.size.X); offset.X = Math.Abs(offset.X); offset.Y = Math.Abs(offset.Y); float alpha = character.IsUnconscious ? 1.0f : Math.Min((80.0f - character.Oxygen) / 50.0f, 0.8f); noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset, Vector2.Zero, Color.White * alpha); } else { if (suicideButton != null) { suicideButton.Visible = false; } } if (damageOverlayTimer > 0.0f) { damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayTimer, Vector2.Zero, 0.0f, new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y)); } if (character.IsUnconscious && !character.IsDead) { if (suicideButton == null) { suicideButton = new GUIButton( new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), "Give in", ""); suicideButton.ToolTip = GameMain.NetworkMember == null ? "The character can no longer be revived if you give in." : "Let go of your character and enter spectator mode (other players will no longer be able to revive you)"; suicideButton.OnClicked = (button, userData) => { GUIComponent.ForceMouseOn(null); if (Character.Controlled != null) { if (GameMain.Client != null) { GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Status }); } else { Character.Controlled.Kill(Character.Controlled.CauseOfDeath); Character.Controlled = null; } } return(true); }; } suicideButton.Visible = true; suicideButton.Draw(spriteBatch); } }
private GUIComponent CreateFloatField(ISerializableEntity entity, SerializableProperty property, float value, int yPos, GUIComponent parent) { var label = new GUITextBlock(new Rectangle(0, yPos, 0, 18), property.Name, "", Alignment.TopLeft, Alignment.Left, parent, false, GUI.SmallFont); label.ToolTip = property.GetAttribute <Editable>().ToolTip; GUINumberInput numberInput = new GUINumberInput(new Rectangle(180, yPos, 0, 18), "", GUINumberInput.NumberType.Float, Alignment.Left, parent); numberInput.ToolTip = property.GetAttribute <Editable>().ToolTip; numberInput.Font = GUI.SmallFont; var editableAttribute = property.GetAttribute <Editable>(); numberInput.MinValueFloat = editableAttribute.MinValueFloat; numberInput.MaxValueFloat = editableAttribute.MaxValueFloat; numberInput.FloatValue = value; numberInput.OnValueChanged += (numInput) => { if (property.TrySetValue(numInput.FloatValue)) { TrySendNetworkUpdate(entity, property); } }; return(numberInput); }
public override void Select() { base.Select(); GameMain.DebugDraw = true; cam = new Camera(); GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, GameMain.GraphicsHeight), ""); GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, "", GUIpanel); physicsButton.OnClicked += TogglePhysics; new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", "", GUIpanel); limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, "", GUIpanel); limbList.OnSelected = SelectLimb; new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", "", GUIpanel); jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, "", GUIpanel); while (Character.CharacterList.Count > 1) { Character.CharacterList.First().Remove(); } if (Character.CharacterList.Count == 1) { if (editingCharacter != Character.CharacterList[0]) { UpdateLimbLists(Character.CharacterList[0]); } editingCharacter = Character.CharacterList[0]; Vector2 camPos = editingCharacter.AnimController.Limbs[0].body.SimPosition; camPos = ConvertUnits.ToDisplayUnits(camPos); camPos.Y = -camPos.Y; cam.TargetPos = camPos; if (physicsEnabled) { editingCharacter.Control(1.0f, cam); } else { cam.TargetPos = Vector2.Zero; } } textures = new List <Texture2D>(); texturePaths = new List <string>(); foreach (Limb limb in editingCharacter.AnimController.Limbs) { if (limb.sprite == null || texturePaths.Contains(limb.sprite.FilePath)) { continue; } textures.Add(limb.sprite.Texture); texturePaths.Add(limb.sprite.FilePath); } }
private GUIComponent CreateStringField(ISerializableEntity entity, SerializableProperty property, string value, int yPos, GUIComponent parent) { int boxHeight = 18; var editable = property.GetAttribute <Editable>(); boxHeight = (int)(Math.Ceiling(editable.MaxLength / 40.0f) * boxHeight); var label = new GUITextBlock(new Rectangle(0, yPos, 0, 18), property.Name, "", Alignment.TopLeft, Alignment.Left, parent, false, GUI.SmallFont); label.ToolTip = property.GetAttribute <Editable>().ToolTip; GUITextBox propertyBox = new GUITextBox(new Rectangle(0, yPos, 250, boxHeight), Alignment.Right, "", parent); propertyBox.ToolTip = editable.ToolTip; propertyBox.Font = GUI.SmallFont; propertyBox.Text = value; propertyBox.OnEnterPressed = (textBox, text) => { if (property.TrySetValue(text)) { TrySendNetworkUpdate(entity, property); textBox.Text = (string)property.GetValue(); textBox.Deselect(); } return(true); }; return(propertyBox); }
public CampaignSetupUI(bool isMultiplayer, GUIComponent newGameContainer, GUIComponent loadGameContainer) { this.isMultiplayer = isMultiplayer; this.newGameContainer = newGameContainer; this.loadGameContainer = loadGameContainer; var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f }; var leftColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)) { Stretch = true, RelativeSpacing = 0.02f }; var rightColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)) { RelativeSpacing = 0.02f }; // New game left side new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), leftColumn.RectTransform), TextManager.Get("SelectedSub") + ":", textAlignment: Alignment.BottomLeft); subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform)); UpdateSubList(); // New game right side new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), TextManager.Get("SaveName") + ":", textAlignment: Alignment.BottomLeft); saveNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), string.Empty); new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), TextManager.Get("MapSeed") + ":", textAlignment: Alignment.BottomLeft); seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), ToolBox.RandomSeed(8)); if (!isMultiplayer) { new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), "Tutorial active" + ":", textAlignment: Alignment.BottomLeft); contextualTutorialBox = new GUITickBox(new RectTransform(new Point(30, 30), rightColumn.RectTransform), string.Empty); UpdateTutorialSelection(); } var startButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.13f), rightColumn.RectTransform, Anchor.BottomRight), TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge") { IgnoreLayoutGroups = true, OnClicked = (GUIButton btn, object userData) => { if (string.IsNullOrWhiteSpace(saveNameBox.Text)) { saveNameBox.Flash(Color.Red); return(false); } Submarine selectedSub = subList.SelectedData as Submarine; if (selectedSub == null) { return(false); } if (string.IsNullOrEmpty(selectedSub.MD5Hash.Hash)) { ((GUITextBlock)subList.SelectedComponent).TextColor = Color.DarkRed * 0.8f; subList.SelectedComponent.CanBeFocused = false; subList.Deselect(); return(false); } string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text); bool hasRequiredContentPackages = selectedSub.RequiredContentPackages.All(cp => GameMain.SelectedPackages.Any(cp2 => cp2.Name == cp)); if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages) { if (!hasRequiredContentPackages) { var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"), TextManager.Get("ContentPackageMismatchWarning") .Replace("[requiredcontentpackages]", string.Join(", ", selectedSub.RequiredContentPackages)), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked = msgBox.Close; msgBox.Buttons[0].OnClicked += (button, obj) => { if (GUIMessageBox.MessageBoxes.Count == 0) { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); } return(true); }; msgBox.Buttons[1].OnClicked = msgBox.Close; } if (selectedSub.HasTag(SubmarineTag.Shuttle)) { var msgBox = new GUIMessageBox(TextManager.Get("ShuttleSelected"), TextManager.Get("ShuttleWarning"), new string[] { TextManager.Get("Yes"), TextManager.Get("No") }); msgBox.Buttons[0].OnClicked = (button, obj) => { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); return(true); }; msgBox.Buttons[0].OnClicked += msgBox.Close; msgBox.Buttons[1].OnClicked = msgBox.Close; return(false); } } else { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); } return(true); } }; UpdateLoadMenu(); }
private GUIComponent CreateRectangleField(ISerializableEntity entity, SerializableProperty property, Rectangle value, int yPos, GUIComponent parent) { var label = new GUITextBlock(new Rectangle(0, yPos, 0, 18), property.Name, "", Alignment.TopLeft, Alignment.Left, parent, false, GUI.SmallFont); label.ToolTip = property.GetAttribute <Editable>().ToolTip; for (int i = 0; i < 4; i++) { new GUITextBlock(new Rectangle(140 + i * 70, yPos, 100, 18), rectComponentLabels[i], "", Alignment.TopLeft, Alignment.CenterLeft, parent, false, GUI.SmallFont); GUINumberInput numberInput = new GUINumberInput(new Rectangle(160 + i * 70, yPos, 45, 18), "", GUINumberInput.NumberType.Int, Alignment.Left, parent); numberInput.Font = GUI.SmallFont; if (i == 0) { numberInput.IntValue = value.X; } else if (i == 1) { numberInput.IntValue = value.Y; } else if (i == 2) { numberInput.IntValue = value.Width; } else { numberInput.IntValue = value.Height; } int comp = i; numberInput.OnValueChanged += (numInput) => { Rectangle newVal = (Rectangle)property.GetValue(); if (comp == 0) { newVal.X = numInput.IntValue; } else if (comp == 1) { newVal.Y = numInput.IntValue; } else if (comp == 2) { newVal.Width = numInput.IntValue; } else { newVal.Height = numInput.IntValue; } if (property.TrySetValue(newVal)) { TrySendNetworkUpdate(entity, property); } }; } return(label); }
public void CreateReputationInfoPanel(GUIComponent parent, CampaignMode campaignMode) { GUIListBox reputationList = new GUIListBox(new RectTransform(Vector2.One, parent.RectTransform)) { Padding = new Vector4(4, 10, 0, 0) * GUI.Scale }; reputationList.ContentBackground.Color = Color.Transparent; if (startLocation.Type.HasOutpost && startLocation.Reputation != null) { var iconStyle = GUI.Style.GetComponentStyle("LocationReputationIcon"); var locationFrame = 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); CreatePathUnlockElement(locationFrame, null, startLocation); } 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)."); } var factionFrame = 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); CreatePathUnlockElement(factionFrame, faction, null); } 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); } foreach (GUIComponent child in reputationList.Content.Children) { var headerElement = child.FindChild("header", recursive: true) as GUITextBlock; var descriptionElement = child.FindChild("description", recursive: true) as GUITextBlock; descriptionElement.RectTransform.NonScaledSize = new Point(descriptionElement.Rect.Width, (int)maxDescriptionHeight); descriptionElement.RectTransform.IsFixedSize = true; child.RectTransform.NonScaledSize = new Point(child.Rect.Width, headerElement.Rect.Height + descriptionElement.RectTransform.Parent.Children.Sum(c => c.Rect.Height + ((GUILayoutGroup)descriptionElement.Parent).AbsoluteSpacing)); } void CreatePathUnlockElement(GUIComponent reputationFrame, Faction faction, Location location) { if (GameMain.GameSession?.Campaign?.Map != null) { foreach (LocationConnection connection in GameMain.GameSession.Campaign.Map.Connections) { if (!connection.Locked || (!connection.Locations[0].Discovered && !connection.Locations[1].Discovered)) { continue; } var gateLocation = connection.Locations[0].IsGateBetweenBiomes ? connection.Locations[0] : connection.Locations[1]; var unlockEvent = EventSet.PrefabList.Find(ep => ep.UnlockPathEvent && ep.BiomeIdentifier == gateLocation.LevelData.Biome.Identifier) ?? EventSet.PrefabList.Find(ep => ep.UnlockPathEvent && string.IsNullOrEmpty(ep.BiomeIdentifier)); if (unlockEvent == null) { continue; } if (string.IsNullOrEmpty(unlockEvent.UnlockPathFaction) || unlockEvent.UnlockPathFaction.Equals("location", StringComparison.OrdinalIgnoreCase)) { if (location == null || gateLocation != location) { continue; } } else { if (faction == null || !faction.Prefab.Identifier.Equals(unlockEvent.UnlockPathFaction, StringComparison.OrdinalIgnoreCase)) { continue; } } if (unlockEvent != null) { Reputation unlockReputation = gateLocation.Reputation; Faction unlockFaction = null; if (!string.IsNullOrEmpty(unlockEvent.UnlockPathFaction)) { unlockFaction = GameMain.GameSession.Campaign.Factions.Find(f => f.Prefab.Identifier.Equals(unlockEvent.UnlockPathFaction, StringComparison.OrdinalIgnoreCase)); unlockReputation = unlockFaction?.Reputation; } float normalizedUnlockReputation = MathUtils.InverseLerp(unlockReputation.MinReputation, unlockReputation.MaxReputation, unlockEvent.UnlockPathReputation); string unlockText = TextManager.GetWithVariables( "lockedpathreputationrequirement", new string[] { "[reputation]", "[biomename]" }, new string[] { Reputation.GetFormattedReputationText(normalizedUnlockReputation, unlockEvent.UnlockPathReputation, addColorTags: true), $"‖color:gui.orange‖{connection.LevelData.Biome.DisplayName}‖end‖" }); var unlockInfoPanel = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.0f), reputationFrame.RectTransform, Anchor.BottomCenter) { MinSize = new Point(0, GUI.IntScale(30)), AbsoluteOffset = new Point(0, GUI.IntScale(3)) }, unlockText, style: "GUIButtonRound", textAlignment: Alignment.Center, textColor: GUI.Style.TextColor, parseRichText: true); unlockInfoPanel.Color = Color.Lerp(unlockInfoPanel.Color, Color.Black, 0.8f); if (unlockInfoPanel.TextSize.X > unlockInfoPanel.Rect.Width * 0.7f) { unlockInfoPanel.Font = GUI.SmallFont; } } } } } }
private bool SelectSaveFile(GUIComponent component, object obj) { string fileName = (string)obj; if (isMultiplayer) { loadGameButton.Enabled = true; deleteMpSaveButton.Visible = deleteMpSaveButton.Enabled = GameMain.Client.IsServerOwner; deleteMpSaveButton.Enabled = GameMain.GameSession?.SavePath != fileName; if (deleteMpSaveButton.Visible) { deleteMpSaveButton.UserData = obj as string; } return(true); } XDocument doc = SaveUtil.LoadGameSessionDoc(fileName); if (doc?.Root == null) { DebugConsole.ThrowError("Error loading save file \"" + fileName + "\". The file may be corrupted."); return(false); } loadGameButton.Enabled = SaveUtil.IsSaveFileCompatible(doc); RemoveSaveFrame(); string subName = doc.Root.GetAttributeString("submarine", ""); string saveTime = doc.Root.GetAttributeString("savetime", "unknown"); if (long.TryParse(saveTime, out long unixTime)) { DateTime time = ToolBox.Epoch.ToDateTime(unixTime); saveTime = time.ToString(); } string mapseed = doc.Root.GetAttributeString("mapseed", "unknown"); var saveFileFrame = new GUIFrame(new RectTransform(new Vector2(0.45f, 0.6f), loadGameContainer.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, 0.1f) }, style: "InnerFrame") { UserData = "savefileframe" }; new GUITextBlock(new RectTransform(new Vector2(1, 0.2f), saveFileFrame.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0, 0.05f) }, Path.GetFileNameWithoutExtension(fileName), font: GUI.LargeFont, textAlignment: Alignment.Center); var layoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.5f), saveFileFrame.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0, 0.1f) }); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("Submarine")} : {subName}", font: GUI.SmallFont); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("LastSaved")} : {saveTime}", font: GUI.SmallFont); new GUITextBlock(new RectTransform(new Vector2(1, 0), layoutGroup.RectTransform), $"{TextManager.Get("MapSeed")} : {mapseed}", font: GUI.SmallFont); new GUIButton(new RectTransform(new Vector2(0.4f, 0.15f), saveFileFrame.RectTransform, Anchor.BottomCenter) { RelativeOffset = new Vector2(0, 0.1f) }, TextManager.Get("Delete"), style: "GUIButtonSmall") { UserData = fileName, OnClicked = DeleteSave }; return(true); }
public GUITextBlock(Rectangle rect, string text, string style, GUIComponent parent = null, bool wrap = false) : this(rect, text, style, Alignment.TopLeft, Alignment.TopLeft, parent, wrap) { }