Remove obsoleted dropdown & label code

This commit is contained in:
Paul Chote
2011-05-22 17:42:01 +12:00
parent d029b1ff6f
commit 325fd509b0
3 changed files with 1 additions and 71 deletions

View File

@@ -84,66 +84,6 @@ namespace OpenRA.Widgets
Widget.RootWidget.AddChild(panel);
}
[Obsolete] public static void ShowDropPanel(Widget w, Widget panel, IEnumerable<Widget> dismissAfter, Func<bool> onDismiss)
{
// Mask to prevent any clicks from being sent to other widgets
var fullscreenMask = new ContainerWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
Widget.RootWidget.AddChild(fullscreenMask);
Action HideDropDown = () =>
{
Widget.RootWidget.RemoveChild(fullscreenMask);
Widget.RootWidget.RemoveChild(panel);
};
HideDropDown += () => Game.BeforeGameStart -= HideDropDown;
Game.BeforeGameStart += HideDropDown;
fullscreenMask.OnMouseDown = mi =>
{
if (onDismiss()) HideDropDown();
return true;
};
fullscreenMask.OnMouseUp = mi => true;
var oldBounds = panel.Bounds;
panel.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, oldBounds.Width, oldBounds.Height);
panel.OnMouseUp = mi => true;
foreach (var ww in dismissAfter)
{
var origMouseUp = ww.OnMouseUp;
ww.OnMouseUp = mi => { var result = origMouseUp(mi); if (onDismiss()) HideDropDown(); return result; };
}
Widget.RootWidget.AddChild(panel);
}
[Obsolete] public static void ShowDropDown<T>(Widget w, IEnumerable<T> ts, Func<T, int, LabelWidget> ft)
{
var dropDown = new ScrollPanelWidget();
dropDown.Bounds = new Rectangle(w.RenderOrigin.X, w.RenderOrigin.Y + w.Bounds.Height, w.Bounds.Width, 100);
dropDown.ItemSpacing = 1;
List<LabelWidget> items = new List<LabelWidget>();
List<Widget> dismissAfter = new List<Widget>();
foreach (var t in ts)
{
var ww = ft(t, dropDown.Bounds.Width - dropDown.ScrollbarWidth);
dismissAfter.Add(ww);
ww.OnMouseMove = mi => items.Do(lw =>
{
lw.Background = null; ww.Background = "dialog2";
});
dropDown.AddChild(ww);
items.Add(ww);
}
dropDown.Bounds.Height = Math.Min(150, dropDown.ContentHeight);
ShowDropPanel(w, dropDown, dismissAfter, () => true);
}
public void ShowDropDown<T>(string panelTemplate, int height, List<T> options, Func<T, ScrollItemWidget, ScrollItemWidget> setupItem)
{
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", Bounds.Width }};

View File

@@ -19,7 +19,6 @@ namespace OpenRA.Widgets
public enum TextAlign { Left, Center, Right }
public enum TextVAlign { Top, Middle, Bottom }
public string Text = null;
[Obsolete] public string Background = null;
public TextAlign Align = TextAlign.Left;
public TextVAlign VAlign = TextVAlign.Middle;
public string Font = "Regular";
@@ -28,13 +27,11 @@ namespace OpenRA.Widgets
public Color ContrastColor = Color.Black;
public bool WordWrap = false;
public Func<string> GetText;
[Obsolete] public Func<string> GetBackground;
public LabelWidget()
: base()
{
GetText = () => Text;
GetBackground = () => Background;
}
protected LabelWidget(LabelWidget other)
@@ -48,16 +45,10 @@ namespace OpenRA.Widgets
ContrastColor = other.ContrastColor;
WordWrap = other.WordWrap;
GetText = other.GetText;
GetBackground = other.GetBackground;
}
public override void DrawInner()
{
var bg = GetBackground();
if (bg != null)
WidgetUtils.DrawPanel(bg, RenderBounds );
{
SpriteFont font = Game.Renderer.Fonts[Font];
var text = GetText();
if (text == null)

View File

@@ -127,7 +127,6 @@ Background@JOINSERVER_BG:
Y:PARENT_BOTTOM / 2 - HEIGHT
Width:150
Height:30
Background:dialog4
Text:Fetching games...
Align:Center
Container@SERVER_INFO: