Crew command menu and the info menu can't be open at the same time, UI layout tweaking again

This commit is contained in:
Regalis
2017-04-23 21:06:30 +03:00
parent 1d41b4958c
commit 645df3fde6
5 changed files with 44 additions and 31 deletions

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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;
}