Made round summary scrollable (long summary texts don't overflow anymore), listbox scissorrects work correctly now on nested listboxes
This commit is contained in:
@@ -97,6 +97,9 @@ namespace Barotrauma
|
||||
{
|
||||
base.Rect = value;
|
||||
frame.Rect = value;
|
||||
scrollBar.Rect = scrollBar.IsHorizontal ?
|
||||
new Rectangle(rect.X, rect.Bottom - 20, rect.Width, 20) :
|
||||
new Rectangle(rect.Right - 20, rect.Y, 20, rect.Height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +411,9 @@ namespace Barotrauma
|
||||
if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
|
||||
|
||||
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = frame.Rect;
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, frame.Rect);
|
||||
|
||||
|
||||
|
||||
int lastVisible = 0;
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Barotrauma
|
||||
|
||||
int width = 760, height = 400;
|
||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", frame);
|
||||
|
||||
int y = 0;
|
||||
|
||||
|
||||
GUIListBox listBox = new GUIListBox(new Rectangle(0, 0, 0, height - (int)(30 + innerFrame.Padding.Y + innerFrame.Padding.W)), "", innerFrame);
|
||||
|
||||
if (!singleplayer)
|
||||
{
|
||||
//Game over if everyone dead or didn't progress
|
||||
@@ -50,20 +50,49 @@ namespace Barotrauma
|
||||
.Replace("[sub]", Submarine.MainSub.Name)
|
||||
.Replace("[location]", progress ? GameMain.GameSession.EndLocation.Name : GameMain.GameSession.StartLocation.Name);
|
||||
|
||||
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, "", innerFrame, true);
|
||||
y += infoText.Rect.Height;
|
||||
var infoText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width-20, 0), summaryText, "", null, true);
|
||||
infoText.Rect = new Rectangle(0, 0, infoText.Rect.Width, infoText.Rect.Height + 20);
|
||||
listBox.AddChild(infoText);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(endMessage))
|
||||
{
|
||||
var endText = new GUITextBlock(new Rectangle(0, y, 0, 30), endMessage, "", innerFrame, true);
|
||||
|
||||
y += 30 + endText.Text.Split('\n').Length * 20;
|
||||
var endText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width-20, 0), endMessage, "", null, true);
|
||||
endText.Rect = new Rectangle(0, 0, endText.Rect.Width, endText.Rect.Height + 20);
|
||||
listBox.AddChild(endText);
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("RoundSummaryCrewStatus"), "", innerFrame, GUI.LargeFont);
|
||||
y += 30;
|
||||
if (GameMain.GameSession.Mission != null)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 40), TextManager.Get("Mission") + ": " + GameMain.GameSession.Mission.Name, "", listBox, GUI.LargeFont);
|
||||
|
||||
GUIListBox listBox = new GUIListBox(new Rectangle(0,y,0,90), null, Alignment.TopLeft, "", innerFrame, true);
|
||||
var missionInfo = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width-20, 0),
|
||||
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
|
||||
"", null, true);
|
||||
missionInfo.Rect = new Rectangle(0, 0, missionInfo.Rect.Width, missionInfo.Rect.Height + 20);
|
||||
listBox.AddChild(missionInfo);
|
||||
|
||||
if (GameMain.GameSession.Mission.Completed)
|
||||
{
|
||||
GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
|
||||
}
|
||||
|
||||
if (GameMain.GameSession.Mission.Completed && singleplayer)
|
||||
{
|
||||
var missionReward = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width-20, 0), TextManager.Get("Reward") + ": " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, null);
|
||||
missionReward.Rect = new Rectangle(0, 0, missionReward.Rect.Width, missionReward.Rect.Height + 20);
|
||||
listBox.AddChild(missionReward);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
|
||||
}
|
||||
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 40), TextManager.Get("RoundSummaryCrewStatus"), "", listBox, GUI.LargeFont);
|
||||
|
||||
GUIListBox characterListBox = new GUIListBox(new Rectangle(0, 0, listBox.Rect.Width - 20, 90), null, Alignment.TopLeft, "", null, true);
|
||||
listBox.AddChild(characterListBox);
|
||||
|
||||
int x = 0;
|
||||
foreach (CharacterInfo characterInfo in gameSession.CrewManager.GetCharacterInfos())
|
||||
@@ -74,14 +103,14 @@ namespace Barotrauma
|
||||
continue;
|
||||
}
|
||||
|
||||
var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), Color.Transparent, "", listBox);
|
||||
var characterFrame = new GUIFrame(new Rectangle(x, 0, 170, 70), Color.Transparent, "", characterListBox);
|
||||
characterFrame.OutlineColor = Color.Transparent;
|
||||
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
characterFrame.CanBeFocused = false;
|
||||
|
||||
characterInfo.CreateCharacterFrame(characterFrame,
|
||||
characterInfo.Job != null ? (characterInfo.Name + '\n' + "(" + characterInfo.Job.Name + ")") : characterInfo.Name, null);
|
||||
|
||||
|
||||
string statusText = TextManager.Get("StatusOK");
|
||||
Color statusColor = Color.DarkGreen;
|
||||
|
||||
@@ -110,34 +139,9 @@ namespace Barotrauma
|
||||
Alignment.BottomLeft, Alignment.Center,
|
||||
null, characterFrame, true, GUI.SmallFont);
|
||||
|
||||
x += characterFrame.Rect.Width + 10;
|
||||
x += characterFrame.Rect.Width + 10;
|
||||
}
|
||||
|
||||
y += 120;
|
||||
|
||||
if (GameMain.GameSession.Mission != null)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("Mission") + ": " + GameMain.GameSession.Mission.Name, "", innerFrame, GUI.LargeFont);
|
||||
y += 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
|
||||
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
|
||||
"", innerFrame, true);
|
||||
|
||||
if (GameMain.GameSession.Mission.Completed)
|
||||
{
|
||||
GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
|
||||
}
|
||||
|
||||
if (GameMain.GameSession.Mission.Completed && singleplayer)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), TextManager.Get("Reward") + ": " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Barotrauma
|
||||
{
|
||||
GUIFrame summaryFrame = roundSummary.CreateSummaryFrame(endMessage);
|
||||
GUIMessageBox.MessageBoxes.Add(summaryFrame);
|
||||
var okButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Ok", Alignment.BottomRight, "", summaryFrame.children[0]);
|
||||
var okButton = new GUIButton(new Rectangle(0, 20, 100, 30), "Ok", Alignment.BottomRight, "", summaryFrame.children[0]);
|
||||
okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Remove(summaryFrame); return true; };
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user