public SinglePlayerCampaign(GameModePreset preset, object param) : base(preset, param) { int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center) { Font = GUI.SmallFont, OnClicked = (btn, userdata) => { TryEndRound(GetLeavingSub()); return(true); } }; foreach (JobPrefab jobPrefab in JobPrefab.List) { for (int i = 0; i < jobPrefab.InitialCount; i++) { CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanConfigFile, "", jobPrefab)); } } ContextualTutorial = Tutorial.Tutorials.Find(t => t is ContextualTutorial) as ContextualTutorial; if (ContextualTutorial.Selected) // Selected when starting a new game -> initialize { ContextualTutorial.Initialize(); } }
public ChatBox(GUIComponent parent, bool isSinglePlayer) { this.isSinglePlayer = isSinglePlayer; if (radioIcon == null) { radioIcon = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(527, 952, 38, 52), null); radioIcon.Origin = radioIcon.size / 2; } screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); int toggleButtonWidth = (int)(30 * GUI.Scale); guiFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ChatBoxArea, parent.RectTransform), style: null); chatBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.9f), guiFrame.RectTransform), style: "ChatBox"); toggleButton = new GUIButton(new RectTransform(new Point(toggleButtonWidth, HUDLayoutSettings.ChatBoxArea.Height), parent.RectTransform), style: "UIToggleButton"); toggleButton.OnClicked += (GUIButton btn, object userdata) => { toggleOpen = !toggleOpen; foreach (GUIComponent child in btn.Children) { child.SpriteEffects = toggleOpen == (HUDLayoutSettings.ChatBoxAlignment == Alignment.Right) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } return(true); }; inputBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), guiFrame.RectTransform, Anchor.BottomCenter), style: "ChatTextBox") { Font = GUI.SmallFont, MaxTextLength = ChatMessage.MaxLength }; radioButton = new GUIButton(new RectTransform(new Vector2(0.1f, 2.0f), inputBox.RectTransform, HUDLayoutSettings.ChatBoxAlignment == Alignment.Right ? Anchor.BottomRight : Anchor.BottomLeft, HUDLayoutSettings.ChatBoxAlignment == Alignment.Right ? Pivot.TopRight : Pivot.TopLeft), style: null); new GUIImage(new RectTransform(Vector2.One, radioButton.RectTransform), radioIcon, scaleToFit: true); radioButton.OnClicked = (GUIButton btn, object userData) => { if (inputBox.Selected) { inputBox.Text = ""; inputBox.Deselect(); } else { inputBox.Select(); var radioItem = Character.Controlled?.Inventory?.Items.FirstOrDefault(i => i?.GetComponent <WifiComponent>() != null); if (radioItem != null && Character.Controlled.HasEquippedItem(radioItem) && radioItem.GetComponent <WifiComponent>().CanTransmit()) { inputBox.Text = "r; "; } } return(true); }; }
partial void InitProjSpecific() { var buttonContainer = new GUILayoutGroup(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ButtonAreaTop, GUICanvas.Instance), isHorizontal: true, childAnchor: Anchor.CenterRight) { CanBeFocused = false }; int buttonHeight = (int)(GUI.Scale * 40); int buttonWidth = GUI.IntScale(450); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle((GameMain.GraphicsWidth / 2) - (buttonWidth / 2), HUDLayoutSettings.ButtonAreaTop.Center.Y - (buttonHeight / 2), buttonWidth, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center, style: "EndRoundButton") { Pulse = true, TextBlock = { Shadow = true, AutoScaleHorizontal = true }, OnClicked = (btn, userdata) => { var availableTransition = GetAvailableTransition(out _, out _); if (Character.Controlled != null && availableTransition == TransitionType.ReturnToPreviousLocation && Character.Controlled?.Submarine == Level.Loaded?.StartOutpost) { GameMain.Client.RequestStartRound(); } else if (Character.Controlled != null && availableTransition == TransitionType.ProgressToNextLocation && Character.Controlled?.Submarine == Level.Loaded?.EndOutpost) { GameMain.Client.RequestStartRound(); } else { ShowCampaignUI = true; if (CampaignUI == null) { InitCampaignUI(); } CampaignUI.SelectTab(InteractionType.Map); } return(true); } }; buttonContainer.Recalculate(); }
private void InitUI() { int buttonHeight = (int)(GUI.Scale * 40); int buttonWidth = GUI.IntScale(450); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle((GameMain.GraphicsWidth / 2) - (buttonWidth / 2), HUDLayoutSettings.ButtonAreaTop.Center.Y - (buttonHeight / 2), buttonWidth, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center, style: "EndRoundButton") { Pulse = true, TextBlock = { Shadow = true, AutoScaleHorizontal = true }, OnClicked = (btn, userdata) => { var availableTransition = GetAvailableTransition(out _, out _); if (Character.Controlled != null && availableTransition == TransitionType.ReturnToPreviousLocation && Character.Controlled?.Submarine == Level.Loaded?.StartOutpost) { TryEndRound(); } else if (Character.Controlled != null && availableTransition == TransitionType.ProgressToNextLocation && Character.Controlled?.Submarine == Level.Loaded?.EndOutpost) { TryEndRound(); } else { ShowCampaignUI = true; CampaignUI.SelectTab(InteractionType.Map); } return(true); } }; campaignUIContainer = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black); CampaignUI = new CampaignUI(this, campaignUIContainer) { StartRound = () => { TryEndRound(); } }; }
public SinglePlayerCampaign(GameModePreset preset, object param) : base(preset, param) { int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center) { Font = GUI.SmallFont, OnClicked = (btn, userdata) => { TryEndRound(GetLeavingSub()); return(true); } }; foreach (JobPrefab jobPrefab in JobPrefab.List.Values) { for (int i = 0; i < jobPrefab.InitialCount; i++) { CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanSpeciesName, "", jobPrefab)); } } }
public SinglePlayerCampaign(GameModePreset preset, object param) : base(preset, param) { int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f); endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance), TextManager.Get("EndRound"), textAlignment: Alignment.Center) { Font = GUI.SmallFont, OnClicked = TryEndRound }; foreach (JobPrefab jobPrefab in JobPrefab.List) { for (int i = 0; i < jobPrefab.InitialCount; i++) { CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanConfigFile, "", Gender.None, jobPrefab)); } } }
public ChatBox(GUIComponent parent, bool isSinglePlayer) { this.IsSinglePlayer = isSinglePlayer; if (radioIcon == null) { radioIcon = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(527, 952, 38, 52), null); radioIcon.Origin = radioIcon.size / 2; } screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); int toggleButtonWidth = (int)(30 * GUI.Scale); GUIFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ChatBoxArea, parent.RectTransform), style: null); var chatBoxHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), GUIFrame.RectTransform), style: "ChatBox"); chatBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.95f), chatBoxHolder.RectTransform, Anchor.CenterRight), style: null); ToggleButton = new GUIButton(new RectTransform(new Point(toggleButtonWidth, HUDLayoutSettings.ChatBoxArea.Height), parent.RectTransform), style: "UIToggleButton"); ToggleButton.OnClicked += (GUIButton btn, object userdata) => { ToggleOpen = !ToggleOpen; return(true); }; InputBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), GUIFrame.RectTransform, Anchor.BottomCenter), style: "ChatTextBox") { Font = GUI.SmallFont, MaxTextLength = ChatMessage.MaxLength }; InputBox.OnDeselected += (gui, Keys) => { gui.Text = ""; }; ToggleOpen = GameMain.Config.ChatOpen; }
public ChatBox(GUIComponent parent, bool isSinglePlayer) { this.IsSinglePlayer = isSinglePlayer; if (radioIcon == null) { radioIcon = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(527, 952, 38, 52), null); radioIcon.Origin = radioIcon.size / 2; } screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); int toggleButtonWidth = (int)(30 * GUI.Scale); GUIFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ChatBoxArea, parent.RectTransform), style: null); var chatBoxHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.875f), GUIFrame.RectTransform), style: "ChatBox"); chatBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.95f), chatBoxHolder.RectTransform, Anchor.CenterRight), style: null); ToggleButton = new GUIButton(new RectTransform(new Point(toggleButtonWidth, HUDLayoutSettings.ChatBoxArea.Height), parent.RectTransform), style: "UIToggleButton"); ToggleButton.OnClicked += (GUIButton btn, object userdata) => { ToggleOpen = !ToggleOpen; return(true); }; InputBox = new GUITextBox(new RectTransform(new Vector2(0.925f, 0.125f), GUIFrame.RectTransform, Anchor.BottomLeft), style: "ChatTextBox") { Font = GUI.SmallFont, MaxTextLength = ChatMessage.MaxLength }; InputBox.OnDeselected += (gui, Keys) => { //gui.Text = ""; }; var chatSendButton = new GUIButton(new RectTransform(new Vector2(0.075f, 0.125f), GUIFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.0f, -0.01f) }, ">"); chatSendButton.OnClicked += (GUIButton btn, object userdata) => { InputBox.OnEnterPressed(InputBox, InputBox.Text); return(true); }; showNewMessagesButton = new GUIButton(new RectTransform(new Vector2(1f, 0.125f), GUIFrame.RectTransform, Anchor.BottomCenter) { RelativeOffset = new Vector2(0.0f, -0.125f) }, TextManager.Get("chat.shownewmessages")); showNewMessagesButton.OnClicked += (GUIButton btn, object userdata) => { chatBox.ScrollBar.BarScrollValue = 1f; showNewMessagesButton.Visible = false; return(true); }; showNewMessagesButton.Visible = false; ToggleOpen = GameMain.Config.ChatOpen; }
private void CreateTopLeftButtons() { if (topLeftButtonGroup != null) { topLeftButtonGroup.RectTransform.Parent = null; topLeftButtonGroup = null; crewListButton = commandButton = tabMenuButton = null; } topLeftButtonGroup = new GUILayoutGroup(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ButtonAreaTop, GUI.Canvas), isHorizontal: true, childAnchor: Anchor.CenterLeft) { AbsoluteSpacing = HUDLayoutSettings.Padding, CanBeFocused = false }; topLeftButtonGroup.RectTransform.ParentChanged += (_) => { GameMain.Instance.ResolutionChanged -= CreateTopLeftButtons; }; int buttonHeight = GUI.IntScale(40); Vector2 buttonSpriteSize = GUI.Style.GetComponentStyle("CrewListToggleButton").GetDefaultSprite().size; int buttonWidth = (int)((buttonHeight / buttonSpriteSize.Y) * buttonSpriteSize.X); Point buttonSize = new Point(buttonWidth, buttonHeight); crewListButton = new GUIButton(new RectTransform(buttonSize, parent: topLeftButtonGroup.RectTransform), style: "CrewListToggleButton") { ToolTip = TextManager.GetWithVariable("hudbutton.crewlist", "[key]", GameMain.Config.KeyBindText(InputType.CrewOrders)), OnClicked = (GUIButton btn, object userdata) => { if (CrewManager == null) { return(false); } CrewManager.IsCrewMenuOpen = !CrewManager.IsCrewMenuOpen; return(true); } }; commandButton = new GUIButton(new RectTransform(buttonSize, parent: topLeftButtonGroup.RectTransform), style: "CommandButton") { ToolTip = TextManager.GetWithVariable("hudbutton.commandinterface", "[key]", GameMain.Config.KeyBindText(InputType.Command)), OnClicked = (button, userData) => { if (CrewManager == null) { return(false); } CrewManager.ToggleCommandUI(); return(true); } }; tabMenuButton = new GUIButton(new RectTransform(buttonSize, parent: topLeftButtonGroup.RectTransform), style: "TabMenuButton") { ToolTip = TextManager.GetWithVariable("hudbutton.tabmenu", "[key]", GameMain.Config.KeyBindText(InputType.InfoTab)), OnClicked = (button, userData) => ToggleTabMenu() }; talentPointNotification = CreateTalentIconNotification(tabMenuButton); GameMain.Instance.ResolutionChanged += CreateTopLeftButtons; respawnInfoFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), parent: topLeftButtonGroup.RectTransform) { MaxSize = new Point(HUDLayoutSettings.ButtonAreaTop.Width / 3, int.MaxValue) }, style: null) { Visible = false }; respawnInfoText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), respawnInfoFrame.RectTransform), "", wrap: true); respawnButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), respawnInfoFrame.RectTransform, Anchor.CenterRight), isHorizontal: true, childAnchor: Anchor.CenterLeft) { AbsoluteSpacing = HUDLayoutSettings.Padding, Stretch = true }; respawnTickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, respawnButtonContainer.RectTransform, Anchor.Center), TextManager.Get("respawnquestionpromptrespawn")) { ToolTip = TextManager.Get("respawnquestionprompt"), OnSelected = (tickbox) => { GameMain.Client?.SendRespawnPromptResponse(waitForNextRoundRespawn: !tickbox.Selected); return(true); } }; }
private void CreateVotingGUI() { createdForResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); if (frame != null) { frame.Parent.RemoveChild(frame); } frame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.VotingArea, GameMain.Client.InGameHUD.RectTransform), style: ""); int padding = HUDLayoutSettings.Padding * 2; int spacing = HUDLayoutSettings.Padding; int yOffset = padding; int paddedWidth = frame.Rect.Width - padding * 2; votingTextBlock = new GUITextBlock(new RectTransform(new Point(paddedWidth, 0), frame.RectTransform), votingOnTextData, votingOnText, wrap: true); votingTextBlock.RectTransform.NonScaledSize = votingTextBlock.RectTransform.MinSize = votingTextBlock.RectTransform.MaxSize = new Point(votingTextBlock.Rect.Width, votingTextBlock.Rect.Height); votingTextBlock.RectTransform.IsFixedSize = true; votingTextBlock.RectTransform.AbsoluteOffset = new Point(padding, yOffset); yOffset += votingTextBlock.Rect.Height + spacing; voteCounter = new GUITextBlock(new RectTransform(new Point(paddedWidth, 0), frame.RectTransform), "(0/0)", GUI.Style.Green, textAlignment: Alignment.Center); voteCounter.RectTransform.NonScaledSize = voteCounter.RectTransform.MinSize = voteCounter.RectTransform.MaxSize = new Point(voteCounter.Rect.Width, voteCounter.Rect.Height); voteCounter.RectTransform.IsFixedSize = true; voteCounter.RectTransform.AbsoluteOffset = new Point(padding, yOffset); yOffset += voteCounter.Rect.Height + spacing; votingTimer = new GUIProgressBar(new RectTransform(new Point(paddedWidth, Math.Max(spacing, 8)), frame.RectTransform) { AbsoluteOffset = new Point(padding, yOffset) }, HUDLayoutSettings.Padding); votingTimer.RectTransform.IsFixedSize = true; yOffset += votingTimer.Rect.Height + spacing; int buttonWidth = (int)(paddedWidth * 0.3f); yesVoteButton = new GUIButton(new RectTransform(new Point(buttonWidth, 0), frame.RectTransform) { AbsoluteOffset = new Point((int)(frame.Rect.Width / 2f - buttonWidth - spacing), yOffset) }, TextManager.Get("yes")) { OnClicked = (applyButton, obj) => { SetGUIToVotedState(2); GameMain.Client.Vote(currentVoteType, 2); return(true); } }; noVoteButton = new GUIButton(new RectTransform(new Point(buttonWidth, 0), frame.RectTransform) { AbsoluteOffset = new Point(yesVoteButton.RectTransform.AbsoluteOffset.X + yesVoteButton.Rect.Width + padding, yOffset) }, TextManager.Get("no")) { OnClicked = (applyButton, obj) => { SetGUIToVotedState(1); GameMain.Client.Vote(currentVoteType, 1); return(true); } }; votedTextBlock = new GUITextBlock(new RectTransform(new Point(paddedWidth, yesVoteButton.Rect.Height), frame.RectTransform), string.Empty, textAlignment: Alignment.Center); votedTextBlock.RectTransform.IsFixedSize = true; votedTextBlock.RectTransform.AbsoluteOffset = new Point(padding, yOffset); votedTextBlock.Visible = false; yOffset += yesVoteButton.Rect.Height; frame.RectTransform.NonScaledSize = new Point(frame.Rect.Width, yOffset + padding); }