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;
|
base.Rect = value;
|
||||||
frame.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);
|
if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
|
||||||
|
|
||||||
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||||
spriteBatch.GraphicsDevice.ScissorRectangle = frame.Rect;
|
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, frame.Rect);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int lastVisible = 0;
|
int lastVisible = 0;
|
||||||
for (int i = 0; i < children.Count; i++)
|
for (int i = 0; i < children.Count; i++)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Barotrauma
|
|||||||
int width = 760, height = 400;
|
int width = 760, height = 400;
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", frame);
|
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)
|
if (!singleplayer)
|
||||||
{
|
{
|
||||||
@@ -50,20 +50,49 @@ namespace Barotrauma
|
|||||||
.Replace("[sub]", Submarine.MainSub.Name)
|
.Replace("[sub]", Submarine.MainSub.Name)
|
||||||
.Replace("[location]", progress ? GameMain.GameSession.EndLocation.Name : GameMain.GameSession.StartLocation.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);
|
var infoText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width-20, 0), summaryText, "", null, true);
|
||||||
y += infoText.Rect.Height;
|
infoText.Rect = new Rectangle(0, 0, infoText.Rect.Width, infoText.Rect.Height + 20);
|
||||||
|
listBox.AddChild(infoText);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(endMessage))
|
if (!string.IsNullOrWhiteSpace(endMessage))
|
||||||
{
|
{
|
||||||
var endText = new GUITextBlock(new Rectangle(0, y, 0, 30), endMessage, "", innerFrame, true);
|
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);
|
||||||
y += 30 + endText.Text.Split('\n').Length * 20;
|
listBox.AddChild(endText);
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("RoundSummaryCrewStatus"), "", innerFrame, GUI.LargeFont);
|
if (GameMain.GameSession.Mission != null)
|
||||||
y += 30;
|
{
|
||||||
|
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;
|
int x = 0;
|
||||||
foreach (CharacterInfo characterInfo in gameSession.CrewManager.GetCharacterInfos())
|
foreach (CharacterInfo characterInfo in gameSession.CrewManager.GetCharacterInfos())
|
||||||
@@ -74,7 +103,7 @@ namespace Barotrauma
|
|||||||
continue;
|
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.OutlineColor = Color.Transparent;
|
||||||
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||||
characterFrame.CanBeFocused = false;
|
characterFrame.CanBeFocused = false;
|
||||||
@@ -113,31 +142,6 @@ namespace Barotrauma
|
|||||||
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;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GUIFrame summaryFrame = roundSummary.CreateSummaryFrame(endMessage);
|
GUIFrame summaryFrame = roundSummary.CreateSummaryFrame(endMessage);
|
||||||
GUIMessageBox.MessageBoxes.Add(summaryFrame);
|
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; };
|
okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Remove(summaryFrame); return true; };
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user