Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void PostInit(WidgetArgs args)
        {
            if (Logic == null)
            {
                return;
            }

            args["widget"] = this;

            LogicObject = Game.modData.ObjectCreator.CreateObject <object>(Logic, args);

            args.Remove("widget");
        }
Beispiel #4
0
        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");
        }
Beispiel #5
0
        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);
            };
        }
Beispiel #6
0
        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");
        }
Beispiel #7
0
 public static Widget LoadWidget(string id, Widget parent, WidgetArgs args)
 {
     return(Game.ModData.WidgetLoader.LoadWidget(args, parent, id));
 }