From 645df3fde6ff6a8f7b8cc8d0b22789d37b9ba1dc Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 23 Apr 2017 21:06:30 +0300 Subject: [PATCH] Crew command menu and the info menu can't be open at the same time, UI layout tweaking again --- Subsurface/Source/GUI/GUI.cs | 8 ++-- Subsurface/Source/GUI/GUIListBox.cs | 2 +- Subsurface/Source/GameSession/CrewManager.cs | 14 +++--- Subsurface/Source/GameSession/GameSession.cs | 45 +++++++++++++------- Subsurface/Source/Map/MapEntity.cs | 6 +-- 5 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index a55453cc6..fee230dab 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -434,24 +434,24 @@ namespace Barotrauma "FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond, Color.White, Color.Black * 0.5f, 0, SmallFont); - DrawString(spriteBatch, new Vector2(10, 20), + DrawString(spriteBatch, new Vector2(10, 25), "Physics: " + GameMain.World.UpdateTime, Color.White, Color.Black * 0.5f, 0, SmallFont); - DrawString(spriteBatch, new Vector2(10, 30), + DrawString(spriteBatch, new Vector2(10, 40), "Bodies: " + GameMain.World.BodyList.Count + " (" + GameMain.World.BodyList.FindAll(b => b.Awake && b.Enabled).Count + " awake)", Color.White, Color.Black * 0.5f, 0, SmallFont); if (Screen.Selected.Cam != null) { - DrawString(spriteBatch, new Vector2(10, 40), + DrawString(spriteBatch, new Vector2(10, 55), "Camera pos: " + Screen.Selected.Cam.Position.ToPoint(), Color.White, Color.Black * 0.5f, 0, SmallFont); } if (Submarine.MainSub != null) { - DrawString(spriteBatch, new Vector2(10, 50), + DrawString(spriteBatch, new Vector2(10, 70), "Sub pos: " + Submarine.MainSub.Position.ToPoint(), Color.White, Color.Black * 0.5f, 0, SmallFont); } diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs index fcd69bd01..fe83cf11c 100644 --- a/Subsurface/Source/GUI/GUIListBox.cs +++ b/Subsurface/Source/GUI/GUIListBox.cs @@ -150,7 +150,7 @@ namespace Barotrauma scrollBar.IsHorizontal = isHorizontal; - frame = new GUIFrame(Rectangle.Empty, style, this); + frame = new GUIFrame(new Rectangle(0, 0, this.rect.Width, this.rect.Height), style, this); if (style != null) GUI.Style.Apply(frame, style, this); UpdateScrollBarSize(); diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index 627cd719d..cb410e17d 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -19,12 +19,13 @@ namespace Barotrauma private GUIFrame guiFrame; private GUIListBox listBox, orderListBox; - - private bool crewFrameOpen; - //private GUIButton crewButton; - protected GUIFrame crewFrame; - + private CrewCommander commander; + + public CrewCommander CrewCommander + { + get { return commander; } + } public int Money { @@ -143,7 +144,6 @@ namespace Barotrauma { guiFrame.AddToGUIUpdateList(); if (commander.Frame != null) commander.Frame.AddToGUIUpdateList(); - if (crewFrameOpen) crewFrame.AddToGUIUpdateList(); } public void Update(float deltaTime) @@ -166,7 +166,6 @@ namespace Barotrauma } if (commander.Frame != null) commander.Frame.Update(deltaTime); - if (crewFrameOpen) crewFrame.Update(deltaTime); } public void ReviveCharacter(Character revivedCharacter) @@ -337,7 +336,6 @@ namespace Barotrauma else { guiFrame.Draw(spriteBatch); - if (crewFrameOpen) crewFrame.Draw(spriteBatch); } } diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index 4931a2c32..2292cc6f8 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -282,6 +282,11 @@ namespace Barotrauma { if (infoFrame == null) { + if (CrewManager != null && CrewManager.CrewCommander!= null && CrewManager.CrewCommander.IsOpen) + { + CrewManager.CrewCommander.ToggleGUIFrame(); + } + CreateInfoFrame(); SelectInfoFrameTab(null, selectedTab); } @@ -297,27 +302,31 @@ namespace Barotrauma { int width = 600, height = 400; + infoFrame = new GUIFrame( - new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), ""); + Rectangle.Empty, Color.Black * 0.8f, null); + + var innerFrame = new GUIFrame( + new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", infoFrame); - infoFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); + innerFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); - var crewButton = new GUIButton(new Rectangle(0, -30, 100, 20), "Crew", "", infoFrame); + var crewButton = new GUIButton(new Rectangle(0, -30, 100, 20), "Crew", "", innerFrame); crewButton.UserData = InfoFrameTab.Crew; crewButton.OnClicked = SelectInfoFrameTab; - var missionButton = new GUIButton(new Rectangle(100, -30, 100, 20), "Mission", "", infoFrame); + var missionButton = new GUIButton(new Rectangle(100, -30, 100, 20), "Mission", "", innerFrame); missionButton.UserData = InfoFrameTab.Mission; missionButton.OnClicked = SelectInfoFrameTab; if (GameMain.Server != null) { - var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), "Manage players", "", infoFrame); + var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), "Manage players", "", innerFrame); manageButton.UserData = InfoFrameTab.ManagePlayers; manageButton.OnClicked = SelectInfoFrameTab; } - var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Close", Alignment.BottomCenter, "", infoFrame); + var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Close", Alignment.BottomCenter, "", innerFrame); closeButton.OnClicked = ToggleInfoFrame; } @@ -331,13 +340,13 @@ namespace Barotrauma switch (selectedTab) { case InfoFrameTab.Crew: - CrewManager.CreateCrewFrame(CrewManager.characters, infoFrame); + CrewManager.CreateCrewFrame(CrewManager.characters, infoFrame.children[0] as GUIFrame); break; case InfoFrameTab.Mission: - CreateMissionInfo(infoFrame); + CreateMissionInfo(infoFrame.children[0] as GUIFrame); break; case InfoFrameTab.ManagePlayers: - GameMain.Server.ManagePlayersFrame(infoFrame); + GameMain.Server.ManagePlayersFrame(infoFrame.children[0] as GUIFrame); break; } @@ -362,12 +371,10 @@ namespace Barotrauma public void AddToGUIUpdateList() { - if (CrewManager != null) CrewManager.AddToGUIUpdateList(); - - if (gameMode != null) gameMode.AddToGUIUpdateList(); - infoButton.AddToGUIUpdateList(); - + + if (gameMode != null) gameMode.AddToGUIUpdateList(); + if (infoFrame != null) infoFrame.AddToGUIUpdateList(); } @@ -382,7 +389,15 @@ namespace Barotrauma if (gameMode != null) gameMode.Update(deltaTime); if (Mission != null) Mission.Update(deltaTime); - if (infoFrame != null) infoFrame.Update(deltaTime); + if (infoFrame != null) + { + infoFrame.Update(deltaTime); + + if (CrewManager != null && CrewManager.CrewCommander != null && CrewManager.CrewCommander.IsOpen) + { + infoFrame = null; + } + } } public void Draw(SpriteBatch spriteBatch) diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs index 3c0bbd5ca..ff13b61f8 100644 --- a/Subsurface/Source/Map/MapEntity.cs +++ b/Subsurface/Source/Map/MapEntity.cs @@ -656,14 +656,14 @@ namespace Barotrauma highlightedList = highlightedEntities; highlightedListBox = new GUIListBox( - new Rectangle((int)PlayerInput.MousePosition.X+15, (int)PlayerInput.MousePosition.Y+15, 150, highlightedEntities.Count * 15), + new Rectangle((int)PlayerInput.MousePosition.X+15, (int)PlayerInput.MousePosition.Y+15, 150, highlightedEntities.Count * 18 + 5), null, Alignment.TopLeft, "GUIToolTip", null, false); foreach (MapEntity entity in highlightedEntities) { var textBlock = new GUITextBlock( - new Rectangle(0,0,0,15), - ToolBox.LimitString(entity.Name, GUI.SmallFont, 140), "", highlightedListBox, GUI.SmallFont); + new Rectangle(0, 0, highlightedListBox.Rect.Width, 18), + ToolBox.LimitString(entity.Name, GUI.SmallFont, 140), "", Alignment.TopLeft, Alignment.CenterLeft, highlightedListBox, false, GUI.SmallFont); textBlock.UserData = entity; }