fix indents everywhere
This commit is contained in:
@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
|
||||
public Func<string> GetText;
|
||||
public Func<bool> IsDisabled = () => false;
|
||||
public Action<MouseInput> OnMouseDown = _ => {};
|
||||
public Action<MouseInput> OnMouseUp = _ => {};
|
||||
public Action<MouseInput> OnMouseUp = _ => {};
|
||||
|
||||
// Equivalent to OnMouseUp, but without an input arg
|
||||
public Action OnClick = () => {};
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
DrawBackground(rb, disabled, Depressed, Widget.MouseOverWidget == this);
|
||||
font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset,
|
||||
disabled ? Color.Gray : Color.White);
|
||||
disabled ? Color.Gray : Color.White);
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new ButtonWidget(this); }
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Widgets
|
||||
public class ChatDisplayWidget : Widget
|
||||
{
|
||||
public readonly int RemoveTime = 0;
|
||||
public readonly bool UseContrast = false;
|
||||
public readonly bool UseContrast = false;
|
||||
|
||||
const int logLength = 9;
|
||||
public string Notification = "";
|
||||
@@ -55,11 +55,11 @@ namespace OpenRA.Widgets
|
||||
inset = font.Measure(owner).X + 10;
|
||||
|
||||
font.DrawTextWithContrast(owner, chatpos,
|
||||
line.Color, Color.Black, UseContrast ? 1 : 0);
|
||||
line.Color, Color.Black, UseContrast ? 1 : 0);
|
||||
}
|
||||
|
||||
font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0),
|
||||
Color.White, Color.Black, UseContrast ? 1 : 0);
|
||||
font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0),
|
||||
Color.White, Color.Black, UseContrast ? 1 : 0);
|
||||
}
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
|
||||
string content = "";
|
||||
bool composing = false;
|
||||
bool teamChat = false;
|
||||
public readonly bool UseContrast = false;
|
||||
public readonly bool UseContrast = false;
|
||||
|
||||
readonly OrderManager orderManager;
|
||||
|
||||
|
||||
@@ -104,27 +104,27 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
public class MaskWidget : Widget
|
||||
{
|
||||
public Action<MouseInput> OnMouseDown = _ => {};
|
||||
{
|
||||
public Action<MouseInput> OnMouseDown = _ => {};
|
||||
public MaskWidget() : base() { }
|
||||
public MaskWidget(MaskWidget other)
|
||||
: base(other)
|
||||
public MaskWidget(MaskWidget other)
|
||||
: base(other)
|
||||
{
|
||||
OnMouseDown = other.OnMouseDown;
|
||||
}
|
||||
|
||||
public override bool HandleMouseInput(MouseInput mi)
|
||||
{
|
||||
if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Up)
|
||||
{
|
||||
if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Up)
|
||||
return false;
|
||||
|
||||
if (mi.Event == MouseInputEvent.Down)
|
||||
OnMouseDown(mi);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new MaskWidget(this); }
|
||||
}
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new MaskWidget(this); }
|
||||
}
|
||||
}
|
||||
@@ -38,16 +38,16 @@ namespace OpenRA.Widgets
|
||||
public override Widget Clone() { return new MapPreviewWidget(this); }
|
||||
|
||||
public override bool HandleMouseInput(MouseInput mi)
|
||||
{
|
||||
{
|
||||
if (IgnoreMouseInput)
|
||||
return base.HandleMouseInput(mi);
|
||||
|
||||
if (mi.Event != MouseInputEvent.Down)
|
||||
return false;
|
||||
|
||||
OnMouseDown(mi);
|
||||
return true;
|
||||
}
|
||||
OnMouseDown(mi);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int2 ConvertToPreview(Map map, int2 point)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
|
||||
|
||||
int k = 0;
|
||||
int k = 0;
|
||||
foreach (var item in PerfHistory.items.Values.ToArray())
|
||||
{
|
||||
int n = 0;
|
||||
@@ -41,19 +41,19 @@ namespace OpenRA.Widgets
|
||||
return b;
|
||||
});
|
||||
|
||||
var u = new float2(rect.Left, rect.Top);
|
||||
var u = new float2(rect.Left, rect.Top);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 5),
|
||||
u + new float2(12, 10 * k + 5),
|
||||
item.c, item.c);
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 5),
|
||||
u + new float2(12, 10 * k + 5),
|
||||
item.c, item.c);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 4),
|
||||
u + new float2(12, 10 * k + 4),
|
||||
item.c, item.c);
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 4),
|
||||
u + new float2(12, 10 * k + 4),
|
||||
item.c, item.c);
|
||||
|
||||
++k;
|
||||
++k;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
|
||||
@@ -105,17 +105,17 @@ namespace OpenRA.Widgets
|
||||
|
||||
if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
|
||||
{
|
||||
var scroll = new float2(0, 0);
|
||||
var scroll = new float2(0, 0);
|
||||
|
||||
// Modified to use the ViewportEdgeScrollStep setting - Gecko
|
||||
if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
|
||||
scroll += new float2(0, -1);
|
||||
if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
|
||||
scroll += new float2(1, 0);
|
||||
if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
|
||||
scroll += new float2(0, 1);
|
||||
if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
|
||||
scroll += new float2(-1, 0);
|
||||
// Modified to use the ViewportEdgeScrollStep setting - Gecko
|
||||
if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
|
||||
scroll += new float2(0, -1);
|
||||
if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
|
||||
scroll += new float2(1, 0);
|
||||
if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
|
||||
scroll += new float2(0, 1);
|
||||
if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
|
||||
scroll += new float2(-1, 0);
|
||||
|
||||
float length = Math.Max(1, scroll.Length);
|
||||
scroll.X = (scroll.X / length) * Game.Settings.Game.ViewportEdgeScrollStep;
|
||||
|
||||
@@ -17,75 +17,75 @@ using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public abstract class Widget
|
||||
{
|
||||
public static Widget RootWidget
|
||||
{
|
||||
get { return rootWidget; }
|
||||
set { rootWidget = value; }
|
||||
}
|
||||
public abstract class Widget
|
||||
{
|
||||
public static Widget RootWidget
|
||||
{
|
||||
get { return rootWidget; }
|
||||
set { rootWidget = value; }
|
||||
}
|
||||
|
||||
static Widget rootWidget = new ContainerWidget();
|
||||
static Widget rootWidget = new ContainerWidget();
|
||||
static Stack<Widget> WindowList = new Stack<Widget>();
|
||||
public static Widget SelectedWidget;
|
||||
public static Widget SelectedWidget;
|
||||
public static Widget MouseOverWidget;
|
||||
|
||||
public static void CloseWindow()
|
||||
{
|
||||
if (WindowList.Count > 0)
|
||||
{
|
||||
if (WindowList.Count > 0)
|
||||
RootWidget.RemoveChild(WindowList.Pop());
|
||||
if (WindowList.Count > 0)
|
||||
rootWidget.AddChild(WindowList.Peek());
|
||||
}
|
||||
if (WindowList.Count > 0)
|
||||
rootWidget.AddChild(WindowList.Peek());
|
||||
}
|
||||
|
||||
public static Widget OpenWindow(string id)
|
||||
{
|
||||
return OpenWindow(id, new WidgetArgs());
|
||||
}
|
||||
public static Widget OpenWindow(string id)
|
||||
{
|
||||
return OpenWindow(id, new WidgetArgs());
|
||||
}
|
||||
|
||||
public static Widget OpenWindow(string id, WidgetArgs args)
|
||||
{
|
||||
var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id);
|
||||
if (WindowList.Count > 0)
|
||||
rootWidget.RemoveChild(WindowList.Peek());
|
||||
WindowList.Push(window);
|
||||
return window;
|
||||
}
|
||||
public static Widget OpenWindow(string id, WidgetArgs args)
|
||||
{
|
||||
var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id);
|
||||
if (WindowList.Count > 0)
|
||||
rootWidget.RemoveChild(WindowList.Peek());
|
||||
WindowList.Push(window);
|
||||
return window;
|
||||
}
|
||||
|
||||
public static Widget LoadWidget(string id, Widget parent, WidgetArgs args)
|
||||
{
|
||||
return Game.modData.WidgetLoader.LoadWidget(args, parent, id);
|
||||
}
|
||||
{
|
||||
return Game.modData.WidgetLoader.LoadWidget(args, parent, id);
|
||||
}
|
||||
|
||||
public static void DoTick()
|
||||
{
|
||||
RootWidget.TickOuter();
|
||||
}
|
||||
public static void DoTick()
|
||||
{
|
||||
RootWidget.TickOuter();
|
||||
}
|
||||
|
||||
public static void DoDraw()
|
||||
{
|
||||
RootWidget.DrawOuter();
|
||||
}
|
||||
public static void DoDraw()
|
||||
{
|
||||
RootWidget.DrawOuter();
|
||||
}
|
||||
|
||||
public static bool DoHandleInput(MouseInput mi)
|
||||
{
|
||||
var wasMouseOver = MouseOverWidget;
|
||||
{
|
||||
var wasMouseOver = MouseOverWidget;
|
||||
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
MouseOverWidget = null;
|
||||
|
||||
bool handled = false;
|
||||
if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi))
|
||||
handled = true;
|
||||
if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi))
|
||||
handled = true;
|
||||
|
||||
if (!handled && RootWidget.HandleMouseInputOuter(mi))
|
||||
handled = true;
|
||||
if (!handled && RootWidget.HandleMouseInputOuter(mi))
|
||||
handled = true;
|
||||
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
{
|
||||
Viewport.LastMousePos = mi.Location;
|
||||
Viewport.TicksSinceLastMove = 0;
|
||||
}
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
{
|
||||
Viewport.LastMousePos = mi.Location;
|
||||
Viewport.TicksSinceLastMove = 0;
|
||||
}
|
||||
|
||||
if (wasMouseOver != MouseOverWidget)
|
||||
{
|
||||
@@ -96,18 +96,18 @@ namespace OpenRA.Widgets
|
||||
MouseOverWidget.MouseEntered();
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public static bool DoHandleKeyPress(KeyInput e)
|
||||
{
|
||||
if (SelectedWidget != null)
|
||||
return SelectedWidget.HandleKeyPressOuter(e);
|
||||
{
|
||||
if (SelectedWidget != null)
|
||||
return SelectedWidget.HandleKeyPressOuter(e);
|
||||
|
||||
if (RootWidget.HandleKeyPressOuter(e))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (RootWidget.HandleKeyPressOuter(e))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ResetAll()
|
||||
{
|
||||
@@ -118,59 +118,59 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
// Info defined in YAML
|
||||
public string Id = null;
|
||||
public string X = "0";
|
||||
public string Y = "0";
|
||||
public string Width = "0";
|
||||
public string Height = "0";
|
||||
public string Logic = null;
|
||||
public string Id = null;
|
||||
public string X = "0";
|
||||
public string Y = "0";
|
||||
public string Width = "0";
|
||||
public string Height = "0";
|
||||
public string Logic = null;
|
||||
public object LogicObject { get; private set; }
|
||||
public bool Visible = true;
|
||||
public bool Visible = true;
|
||||
public bool IgnoreMouseOver;
|
||||
public bool IgnoreChildMouseOver;
|
||||
|
||||
// Calculated internally
|
||||
public Rectangle Bounds;
|
||||
public Widget Parent = null;
|
||||
// Calculated internally
|
||||
public Rectangle Bounds;
|
||||
public Widget Parent = null;
|
||||
public Func<bool> IsVisible;
|
||||
public Widget() { IsVisible = () => Visible; }
|
||||
public readonly List<Widget> Children = new List<Widget>();
|
||||
public Widget() { IsVisible = () => Visible; }
|
||||
public readonly List<Widget> Children = new List<Widget>();
|
||||
|
||||
public Widget(Widget widget)
|
||||
{
|
||||
Id = widget.Id;
|
||||
X = widget.X;
|
||||
Y = widget.Y;
|
||||
Width = widget.Width;
|
||||
Height = widget.Height;
|
||||
Logic = widget.Logic;
|
||||
Visible = widget.Visible;
|
||||
public Widget(Widget widget)
|
||||
{
|
||||
Id = widget.Id;
|
||||
X = widget.X;
|
||||
Y = widget.Y;
|
||||
Width = widget.Width;
|
||||
Height = widget.Height;
|
||||
Logic = widget.Logic;
|
||||
Visible = widget.Visible;
|
||||
|
||||
Bounds = widget.Bounds;
|
||||
Parent = widget.Parent;
|
||||
Bounds = widget.Bounds;
|
||||
Parent = widget.Parent;
|
||||
|
||||
IsVisible = widget.IsVisible;
|
||||
IsVisible = widget.IsVisible;
|
||||
IgnoreChildMouseOver = widget.IgnoreChildMouseOver;
|
||||
|
||||
foreach (var child in widget.Children)
|
||||
AddChild(child.Clone());
|
||||
}
|
||||
foreach (var child in widget.Children)
|
||||
AddChild(child.Clone());
|
||||
}
|
||||
|
||||
public virtual Widget Clone()
|
||||
{
|
||||
throw new InvalidOperationException("Widget type `{0}` is not cloneable.".F(GetType().Name));
|
||||
}
|
||||
public virtual Widget Clone()
|
||||
{
|
||||
throw new InvalidOperationException("Widget type `{0}` is not cloneable.".F(GetType().Name));
|
||||
}
|
||||
|
||||
public virtual int2 RenderOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin;
|
||||
return new int2(Bounds.X, Bounds.Y) + offset;
|
||||
}
|
||||
}
|
||||
public virtual int2 RenderOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin;
|
||||
return new int2(Bounds.X, Bounds.Y) + offset;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int2 ChildOrigin { get { return RenderOrigin; } }
|
||||
public virtual int2 ChildOrigin { get { return RenderOrigin; } }
|
||||
|
||||
public virtual Rectangle RenderBounds
|
||||
{
|
||||
@@ -181,120 +181,120 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Initialize(WidgetArgs args)
|
||||
{
|
||||
// Parse the YAML equations to find the widget bounds
|
||||
var parentBounds = (Parent == null)
|
||||
? new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height)
|
||||
: Parent.Bounds;
|
||||
public virtual void Initialize(WidgetArgs args)
|
||||
{
|
||||
// Parse the YAML equations to find the widget bounds
|
||||
var parentBounds = (Parent == null)
|
||||
? new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height)
|
||||
: Parent.Bounds;
|
||||
|
||||
var substitutions = args.ContainsKey("substitutions") ?
|
||||
new Dictionary<string, int>((Dictionary<string, int>)args["substitutions"]) :
|
||||
new Dictionary<string, int>();
|
||||
|
||||
substitutions.Add("WINDOW_RIGHT", Game.viewport.Width);
|
||||
substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height);
|
||||
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
|
||||
substitutions.Add("PARENT_LEFT", parentBounds.Left);
|
||||
substitutions.Add("PARENT_TOP", parentBounds.Top);
|
||||
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
|
||||
int width = Evaluator.Evaluate(Width, substitutions);
|
||||
int height = Evaluator.Evaluate(Height, substitutions);
|
||||
substitutions.Add("WINDOW_RIGHT", Game.viewport.Width);
|
||||
substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height);
|
||||
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
|
||||
substitutions.Add("PARENT_LEFT", parentBounds.Left);
|
||||
substitutions.Add("PARENT_TOP", parentBounds.Top);
|
||||
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
|
||||
int width = Evaluator.Evaluate(Width, substitutions);
|
||||
int height = Evaluator.Evaluate(Height, substitutions);
|
||||
|
||||
substitutions.Add("WIDTH", width);
|
||||
substitutions.Add("HEIGHT", height);
|
||||
substitutions.Add("WIDTH", width);
|
||||
substitutions.Add("HEIGHT", height);
|
||||
|
||||
Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions),
|
||||
Evaluator.Evaluate(Y, substitutions),
|
||||
width,
|
||||
height);
|
||||
}
|
||||
Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions),
|
||||
Evaluator.Evaluate(Y, substitutions),
|
||||
width,
|
||||
height);
|
||||
}
|
||||
|
||||
public void PostInit(WidgetArgs args)
|
||||
{
|
||||
if (Logic == null)
|
||||
return;
|
||||
public void PostInit(WidgetArgs args)
|
||||
{
|
||||
if (Logic == null)
|
||||
return;
|
||||
|
||||
args["widget"] = this;
|
||||
args["widget"] = this;
|
||||
|
||||
LogicObject = Game.modData.ObjectCreator.CreateObject<object>(Logic, args);
|
||||
var iwd = LogicObject as ILogicWithInit;
|
||||
if (iwd != null)
|
||||
iwd.Init();
|
||||
LogicObject = Game.modData.ObjectCreator.CreateObject<object>(Logic, args);
|
||||
var iwd = LogicObject as ILogicWithInit;
|
||||
if (iwd != null)
|
||||
iwd.Init();
|
||||
|
||||
args.Remove("widget");
|
||||
}
|
||||
args.Remove("widget");
|
||||
}
|
||||
|
||||
public virtual Rectangle EventBounds { get { return RenderBounds; } }
|
||||
public virtual Rectangle GetEventBounds()
|
||||
{
|
||||
return Children
|
||||
.Where(c => c.IsVisible())
|
||||
.Select(c => c.GetEventBounds())
|
||||
.Aggregate(EventBounds, Rectangle.Union);
|
||||
}
|
||||
public virtual Rectangle EventBounds { get { return RenderBounds; } }
|
||||
public virtual Rectangle GetEventBounds()
|
||||
{
|
||||
return Children
|
||||
.Where(c => c.IsVisible())
|
||||
.Select(c => c.GetEventBounds())
|
||||
.Aggregate(EventBounds, Rectangle.Union);
|
||||
}
|
||||
|
||||
public bool Focused { get { return SelectedWidget == this; } }
|
||||
public virtual bool TakeFocus(MouseInput mi)
|
||||
{
|
||||
if (Focused)
|
||||
return true;
|
||||
public bool Focused { get { return SelectedWidget == this; } }
|
||||
public virtual bool TakeFocus(MouseInput mi)
|
||||
{
|
||||
if (Focused)
|
||||
return true;
|
||||
|
||||
if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi))
|
||||
return false;
|
||||
if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi))
|
||||
return false;
|
||||
|
||||
SelectedWidget = this;
|
||||
return true;
|
||||
}
|
||||
SelectedWidget = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove focus from this widget; return false if you don't want to give it up
|
||||
public virtual bool LoseFocus(MouseInput mi)
|
||||
{
|
||||
// Some widgets may need to override focus depending on mouse click
|
||||
return LoseFocus();
|
||||
}
|
||||
// Remove focus from this widget; return false if you don't want to give it up
|
||||
public virtual bool LoseFocus(MouseInput mi)
|
||||
{
|
||||
// Some widgets may need to override focus depending on mouse click
|
||||
return LoseFocus();
|
||||
}
|
||||
|
||||
public virtual bool LoseFocus()
|
||||
{
|
||||
if (SelectedWidget == this)
|
||||
SelectedWidget = null;
|
||||
public virtual bool LoseFocus()
|
||||
{
|
||||
if (SelectedWidget == this)
|
||||
SelectedWidget = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual string GetCursor(int2 pos) { return "default"; }
|
||||
public string GetCursorOuter(int2 pos)
|
||||
{
|
||||
// Is the cursor on top of us?
|
||||
if (!(IsVisible() && GetEventBounds().Contains(pos)))
|
||||
return null;
|
||||
public virtual string GetCursor(int2 pos) { return "default"; }
|
||||
public string GetCursorOuter(int2 pos)
|
||||
{
|
||||
// Is the cursor on top of us?
|
||||
if (!(IsVisible() && GetEventBounds().Contains(pos)))
|
||||
return null;
|
||||
|
||||
// Do any of our children specify a cursor?
|
||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
||||
{
|
||||
var cc = child.GetCursorOuter(pos);
|
||||
if (cc != null)
|
||||
return cc;
|
||||
}
|
||||
// Do any of our children specify a cursor?
|
||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
||||
{
|
||||
var cc = child.GetCursorOuter(pos);
|
||||
if (cc != null)
|
||||
return cc;
|
||||
}
|
||||
|
||||
return EventBounds.Contains(pos) ? GetCursor(pos) : null;
|
||||
}
|
||||
return EventBounds.Contains(pos) ? GetCursor(pos) : null;
|
||||
}
|
||||
|
||||
public virtual void MouseEntered() {}
|
||||
public virtual void MouseExited() {}
|
||||
public virtual bool HandleMouseInput(MouseInput mi) { return false; }
|
||||
|
||||
public bool HandleMouseInputOuter(MouseInput mi)
|
||||
{
|
||||
public bool HandleMouseInputOuter(MouseInput mi)
|
||||
{
|
||||
// Are we able to handle this event?
|
||||
if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location))))
|
||||
return false;
|
||||
if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location))))
|
||||
return false;
|
||||
|
||||
var oldMouseOver = MouseOverWidget;
|
||||
// Send the event to the deepest children first and bubble up if unhandled
|
||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
||||
if (child.HandleMouseInputOuter(mi))
|
||||
return true;
|
||||
// Send the event to the deepest children first and bubble up if unhandled
|
||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
||||
if (child.HandleMouseInputOuter(mi))
|
||||
return true;
|
||||
|
||||
if (IgnoreChildMouseOver)
|
||||
MouseOverWidget = oldMouseOver;
|
||||
@@ -302,58 +302,58 @@ namespace OpenRA.Widgets
|
||||
if (mi.Event == MouseInputEvent.Move && MouseOverWidget == null && !IgnoreMouseOver)
|
||||
MouseOverWidget = this;
|
||||
|
||||
return HandleMouseInput(mi);
|
||||
}
|
||||
return HandleMouseInput(mi);
|
||||
}
|
||||
|
||||
public virtual bool HandleKeyPress(KeyInput e) { return false; }
|
||||
public virtual bool HandleKeyPress(KeyInput e) { return false; }
|
||||
|
||||
public virtual bool HandleKeyPressOuter(KeyInput e)
|
||||
{
|
||||
if (!IsVisible())
|
||||
return false;
|
||||
public virtual bool HandleKeyPressOuter(KeyInput e)
|
||||
{
|
||||
if (!IsVisible())
|
||||
return false;
|
||||
|
||||
// Can any of our children handle this?
|
||||
// Can any of our children handle this?
|
||||
foreach (var child in Children.OfType<Widget>().Reverse())
|
||||
if (child.HandleKeyPressOuter(e))
|
||||
return true;
|
||||
if (child.HandleKeyPressOuter(e))
|
||||
return true;
|
||||
|
||||
// Do any widgety behavior (enter text etc)
|
||||
var handled = HandleKeyPress(e);
|
||||
// Do any widgety behavior (enter text etc)
|
||||
var handled = HandleKeyPress(e);
|
||||
|
||||
return handled;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public virtual void Draw() {}
|
||||
public virtual void Draw() {}
|
||||
|
||||
public virtual void DrawOuter()
|
||||
{
|
||||
if (IsVisible())
|
||||
{
|
||||
Draw();
|
||||
foreach (var child in Children)
|
||||
child.DrawOuter();
|
||||
}
|
||||
}
|
||||
public virtual void DrawOuter()
|
||||
{
|
||||
if (IsVisible())
|
||||
{
|
||||
Draw();
|
||||
foreach (var child in Children)
|
||||
child.DrawOuter();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Tick() {}
|
||||
|
||||
public virtual void TickOuter()
|
||||
{
|
||||
if (IsVisible())
|
||||
public virtual void TickOuter()
|
||||
{
|
||||
if (IsVisible())
|
||||
{
|
||||
Tick();
|
||||
foreach (var child in Children)
|
||||
child.TickOuter();
|
||||
foreach (var child in Children)
|
||||
child.TickOuter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AddChild(Widget child)
|
||||
{
|
||||
child.Parent = this;
|
||||
Children.Add(child);
|
||||
}
|
||||
public virtual void AddChild(Widget child)
|
||||
{
|
||||
child.Parent = this;
|
||||
Children.Add(child);
|
||||
}
|
||||
|
||||
public virtual void RemoveChild(Widget child)
|
||||
public virtual void RemoveChild(Widget child)
|
||||
{
|
||||
Children.Remove(child);
|
||||
child.Removed();
|
||||
@@ -371,36 +371,36 @@ namespace OpenRA.Widgets
|
||||
c.Removed();
|
||||
}
|
||||
|
||||
public Widget GetWidget(string id)
|
||||
{
|
||||
if (this.Id == id)
|
||||
return this;
|
||||
public Widget GetWidget(string id)
|
||||
{
|
||||
if (this.Id == id)
|
||||
return this;
|
||||
|
||||
foreach (var child in Children)
|
||||
{
|
||||
var w = child.GetWidget(id);
|
||||
if (w != null)
|
||||
return w;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
foreach (var child in Children)
|
||||
{
|
||||
var w = child.GetWidget(id);
|
||||
if (w != null)
|
||||
return w;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public T GetWidget<T>(string id) where T : Widget
|
||||
{
|
||||
var widget = GetWidget(id);
|
||||
return (widget != null) ? (T)widget : null;
|
||||
}
|
||||
}
|
||||
public T GetWidget<T>(string id) where T : Widget
|
||||
{
|
||||
var widget = GetWidget(id);
|
||||
return (widget != null) ? (T)widget : null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerWidget : Widget
|
||||
{
|
||||
public ContainerWidget() : base() { IgnoreMouseOver = true; }
|
||||
public ContainerWidget(ContainerWidget other)
|
||||
: base(other) { IgnoreMouseOver = true; }
|
||||
public class ContainerWidget : Widget
|
||||
{
|
||||
public ContainerWidget() : base() { IgnoreMouseOver = true; }
|
||||
public ContainerWidget(ContainerWidget other)
|
||||
: base(other) { IgnoreMouseOver = true; }
|
||||
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
}
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
}
|
||||
|
||||
public class WidgetArgs : Dictionary<string, object>
|
||||
{
|
||||
@@ -411,8 +411,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
// TODO: you should use this anywhere you want to do
|
||||
// something in a logic ctor, but retain debuggability.
|
||||
public interface ILogicWithInit
|
||||
{
|
||||
void Init();
|
||||
}
|
||||
public interface ILogicWithInit
|
||||
{
|
||||
void Init();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,17 +34,17 @@ namespace OpenRA.Widgets
|
||||
public override void Draw()
|
||||
{
|
||||
var selbox = SelectionBox;
|
||||
if (selbox == null)
|
||||
{
|
||||
foreach (var u in SelectActorsInBox(world, dragStart, dragStart))
|
||||
worldRenderer.DrawRollover(u);
|
||||
if (selbox == null)
|
||||
{
|
||||
foreach (var u in SelectActorsInBox(world, dragStart, dragStart))
|
||||
worldRenderer.DrawRollover(u);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Game.Renderer.WorldLineRenderer.DrawRect( selbox.Value.First, selbox.Value.Second, Color.White );
|
||||
foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second))
|
||||
worldRenderer.DrawRollover(u);
|
||||
foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second))
|
||||
worldRenderer.DrawRollover(u);
|
||||
}
|
||||
|
||||
int2 dragStart, dragEnd;
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
static readonly Actor[] NoActors = {};
|
||||
static readonly Actor[] NoActors = {};
|
||||
IEnumerable<Actor> SelectActorsInBox(World world, int2 a, int2 b)
|
||||
{
|
||||
return world.FindUnits(a, b)
|
||||
|
||||
Reference in New Issue
Block a user