Пример #1
0
        public override void Draw(SpriteBatch sb)
        {
            base.Draw(sb);

            HologramDefinition def = this.CreateHologramDefinition();

            def.CurrentFrame             = this.CachedHologramDef?.CurrentFrame ?? 0;
            def.CurrentFrameElapsedTicks = this.CachedHologramDef?.CurrentFrameElapsedTicks ?? 0;

            this.CachedHologramDef = def;

            var mouseScr = new Vector2(Main.mouseX + 12, Main.mouseY);

            mouseScr = UIZoomHelpers.ApplyZoomFromScreenCenter(mouseScr, false, true, null, null);
            var mouseWld = mouseScr + Main.screenPosition;

            if (def.AnimateHologram(mouseWld, true))
            {
                try {
                    def.DrawHologram(sb, mouseWld, true);
                } catch (Exception e) {
                    LogHelpers.AlertOnce(e.ToString());
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the recommended element to add content to an "inner" container element of a given menu UI.
        /// </summary>
        /// <param name="uiInnerContainer"></param>
        /// <returns></returns>
        public static UIElement GetMenuContainerInsertPoint(UIElement uiInnerContainer)
        {
            List <UIElement> uiContainerElems;

            if (!ReflectionHelpers.Get(uiInnerContainer, "Elements", out uiContainerElems) ||
                uiContainerElems == null)
            {
                LogHelpers.AlertOnce();
                return(null);
            }

            //Type uiContainerType = uiInnerContainer.GetType();
            //FieldInfo uiContainerElemsField = uiContainerType.GetField( "Elements", BindingFlags.Instance | BindingFlags.NonPublic );
            //List<UIElement> uiContainerElems = (List<UIElement>)uiContainerElemsField.GetValue( uiInnerContainer );

            for (int i = 0; i < uiContainerElems.Count; i++)
            {
                if (uiContainerElems[i] is UIElement &&
                    !(uiContainerElems[i] is UIList) &&
                    !(uiContainerElems[i] is UIScrollbar))
                {
                    return(uiContainerElems[i]);
                }
            }

            LogHelpers.AlertOnce();
            return(null);
        }
Пример #3
0
        ////

        public bool HasSyncedState()
        {
            if (ModHelpersMod.Config.DebugModeNetInfo)
            {
                LogHelpers.AlertOnce("HasSyncedWorldData: " + this.HasSyncedWorldData +
                                     ", HasLoadedOldUID: " + this.HasLoadedOldUID);
            }

            return(this.HasSyncedWorldData && this.HasLoadedOldUID);
        }
Пример #4
0
        /// <summary>
        /// Gets the "outer" container element (the element as positioned on the screen) of a menu's UI class.
        /// </summary>
        /// <param name="ui"></param>
        /// <returns></returns>
        public static UIElement GetMenuContainerOuter(UIState ui)
        {
            UIElement elem;

            if (!ReflectionHelpers.Get(ui, "uIElement", out elem) || elem == null)
            {
                LogHelpers.AlertOnce();
                return(null);
            }

            return(elem);

            //Type uiType = ui.GetType();
            //FieldInfo uiOuterBoxField = uiType.GetField( "uIElement", BindingFlags.Instance | BindingFlags.NonPublic );
            //UIElement uiOuterBox = (UIElement)uiOuterBoxField.GetValue( ui );
            //
            //return uiOuterBox;
        }
Пример #5
0
        /// <summary>
        /// Gets the "inner" container element (contains the UI's components) of a menu's UI class's "outer" container
        /// element.
        /// </summary>
        /// <param name="uiOuterBox"></param>
        /// <returns></returns>
        public static UIElement GetMenuContainerInner(UIElement uiOuterBox)
        {
            List <UIElement> uiOuterBoxElems;

            if (!ReflectionHelpers.Get(uiOuterBox, "Elements", out uiOuterBoxElems) ||
                uiOuterBoxElems == null ||
                uiOuterBoxElems.Count == 0)
            {
                LogHelpers.AlertOnce();
                return(null);
            }

            return(uiOuterBoxElems[0]);

            //Type uiOuterBoxType = uiOuterBox.GetType();
            //FieldInfo uiOuterBoxElemsField = uiOuterBoxType.GetField( "Elements", BindingFlags.Instance | BindingFlags.NonPublic );
            //List<UIElement> uiOuterBoxElems = (List<UIElement>)uiOuterBoxElemsField.GetValue( uiOuterBox );
            //
            //return uiOuterBoxElems[0];
        }
Пример #6
0
        public void LayoutTagButtonsByCategory()
        {
            float           x, y;
            UITagMenuButton tagButton;
            float           top  = this.PositionY + UIModTagsInterface.CategoryPanelHeight;
            float           maxY = UIModTagsInterface.TagsPanelHeight + top - UIResetTagsMenuButton.ButtonHeight - 4;
            IReadOnlyList <ModTagDefinition> tags = this.Manager.MyTags;

            IEnumerable <IGrouping <string, ModTagDefinition> > groups = tags.GroupBy(tagDef => tagDef.Category);

            foreach (IGrouping <string, ModTagDefinition> group in groups)
            {
                x = this.PositionXCenterOffset;
                y = top;

                foreach (ModTagDefinition tagDef in group)
                {
                    if (!this.TagButtons.TryGetValue(tagDef.Tag, out tagButton))
                    {
                        LogHelpers.AlertOnce("Missing tag button " + tagDef.Tag);
                        continue;
                    }

                    tagButton.SetMenuSpacePosition(x, y);

                    tagButton.PutAway();
                    if (group.Key == this.CurrentCategory)
                    {
                        tagButton.TakeOut();
                    }

                    y += UITagMenuButton.ButtonHeight;
                    if (y >= maxY)
                    {
                        y  = this.PositionY + UIModTagsInterface.CategoryPanelHeight;
                        x += UITagMenuButton.ButtonWidth - 2;
                    }
                }
            }
        }