public static T LoadWidget <T>(string id, Widget parent, WidgetArgs args) where T : Widget { var widget = LoadWidget(id, parent, args) as T; if (widget == null) { throw new InvalidOperationException( "Widget {0} is not of type {1}".F(id, typeof(T).Name)); } return(widget); }
public static Widget OpenWindow(string id, WidgetArgs args) { var window = Game.ModData.WidgetLoader.LoadWidget(args, Root, id); if (WindowList.Count > 0) { Root.HideChild(WindowList.Peek()); } WindowList.Push(window); return(window); }
public void PostInit(WidgetArgs args) { if (Logic == null) { return; } args["widget"] = this; LogicObject = Game.modData.ObjectCreator.CreateObject <object>(Logic, args); args.Remove("widget"); }
public void PostInit(WidgetArgs args) { if (!Logic.Any()) { return; } args["widget"] = this; LogicObjects = Logic.Select(l => Game.ModData.ObjectCreator.CreateObject <ChromeLogic>(l, args)) .ToArray(); args.Remove("widget"); }
public override void Initialize(WidgetArgs args) { base.Initialize(args); if (Unit != null && Sequence != null) { var anim = new Animation(worldRenderer.world, Unit, () => Facing); anim.PlayFetchIndex(Sequence, () => Frame); GetAnimation = () => anim; } GetSprite = () => { var anim = GetAnimation(); return(anim != null ? anim.Image : null); }; }
public void PostInit(WidgetArgs args) { if (Logic == null) { return; } args["widget"] = this; LogicObject = Game.modData.ObjectCreator.CreateObject <object>(Logic, args); var iwd = LogicObject as ILogicWithInit; if (iwd != null) { iwd.Init(); } args.Remove("widget"); }
public static Widget LoadWidget(string id, Widget parent, WidgetArgs args) { return(Game.ModData.WidgetLoader.LoadWidget(args, parent, id)); }