Merge pull request #2789 from bidifx/lobby

update player list in lobby gracefully for better user experience
This commit is contained in:
Chris Forbes
2013-03-19 12:26:51 -07:00
4 changed files with 93 additions and 17 deletions

View File

@@ -41,6 +41,11 @@ namespace OpenRA.Widgets
widget.ContentHeight = Math.Max(widget.ContentHeight, pos.Y + widget.ItemSpacing + w.Bounds.Height);
}
public void AdjustChildren()
{
}
}
}

View File

@@ -21,8 +21,18 @@ namespace OpenRA.Widgets
if (widget.Children.Count == 0)
widget.ContentHeight = widget.ItemSpacing;
w.Bounds.Y += widget.ContentHeight;
w.Bounds.Y = widget.ContentHeight;
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
}
public void AdjustChildren()
{
widget.ContentHeight = widget.ItemSpacing;
foreach (var w in widget.Children)
{
w.Bounds.Y = widget.ContentHeight;
widget.ContentHeight += w.Bounds.Height + widget.ItemSpacing;
}
}
}
}

View File

@@ -14,7 +14,7 @@ using OpenRA.Graphics;
namespace OpenRA.Widgets
{
public interface ILayout { void AdjustChild(Widget w); }
public interface ILayout { void AdjustChild(Widget w); void AdjustChildren(); }
public class ScrollPanelWidget : Widget
{
@@ -50,6 +50,25 @@ namespace OpenRA.Widgets
base.AddChild(child);
}
public override void RemoveChild(Widget child)
{
base.RemoveChild(child);
Layout.AdjustChildren();
Scroll(0);
}
public void ReplaceChild(Widget oldChild, Widget newChild)
{
oldChild.Removed();
newChild.Parent = this;
Children[Children.IndexOf(oldChild)] = newChild;
Layout.AdjustChildren();
Scroll(0);
}
public override void DrawOuter()
{
if (!IsVisible())