Example #1
0
        public void UpdateLiteralEditor()
        {
            int index = literalIndex;

            literalIndex = -1;
            if (literalUI != null)
            {
                literalUI.Deactivate();
                RemoveChild(literalUI);
            }
            if (LiteralTarget == null)
            {
                return;
            }
            Main.UIScaleMatrix.Decompose(out Vector3 scale, out Quaternion ignore, out Vector3 ignore2);
            GlyphItemSlot  slot            = itemSlots[index];
            LiteralElement actionLiteralUI = literalUI = new LiteralElement(scale.X * 0.75f)
            {
                Left = { Pixels = slot.Left.Pixels },
                Top  =
                {
                    Pixels = slot.Top.Pixels - slot.Height.Pixels / 2
                }
            };

            //actionLiteralUI.Top.Pixels = this.Top.Pixels - actionLiteralUI.Height.Pixels*1.25f;
            actionLiteralUI.setValue = LiteralTarget.SetLiteral;
            actionLiteralUI.getValue = LiteralTarget.GetLiteral;
            actionLiteralUI.value    = LiteralTarget.GetLiteral();
            actionLiteralUI.Activate();
            Append(actionLiteralUI);
            LiteralTarget = null;
        }
Example #2
0
        public override void OnInitialize()
        {
            int l = 1;

            if (drive != null)
            {
                if (drive.Actions == null)
                {
                    drive.Actions = new List <ActionItem>()
                    {
                    }
                }
                ;
                l += drive.Actions.Count;
            }
            if (maxSize > 0 && l > maxSize)
            {
                l = maxSize;
            }
            Main.UIScaleMatrix.Decompose(out Vector3 scale, out Quaternion ignore, out Vector3 ignore2);
            ActionItem current;
            int        layers = 0;
            int        xPos   = 0;

            for (int i = 0; i < l; i++)
            {
                currIndex = i;
                if (drive.Readonly && drive.Actions.Count <= i)
                {
                    break;
                }
                if (i >= itemSlots.Count)
                {
                    itemSlots.Add(null);
                }
                current      = drive.Actions.Count > i?drive.Actions[i]:null;
                itemSlots[i] = new GlyphItemSlot(scale: 0.75f, context: drive.Readonly ? ItemSlot.Context.CraftingMaterial : ItemSlot.Context.InventoryItem,
                                                 colorContext: drive.Readonly ? ItemSlot.Context.TrashItem : ItemSlot.Context.CraftingMaterial)
                {
                    Left          = { Pixels = (float)((Main.screenWidth * 0.05) + (xPos++ *40 * scale.X)) },
                    Top           = { Pixels = (float)((Main.screenHeight * 0.4) + (layers * 40 * scale.Y)) },
                    ValidItemFunc = item => item.IsAir || (!item.IsAir && (item.modItem is ActionItem)),
                    index         = i
                };
                if (xPos * 40 * scale.X > Main.screenWidth * 0.4)
                {
                    xPos = 0;
                    layers++;
                }
                if (drive != null)
                {
                    if (current != null)
                    {
                        itemSlots[i].item = current?.item ?? Jailbreak.CreateNew(current).item;
                    }
                }
                Append(itemSlots[i]);
                if (current == null)
                {
                    break;
                }
            }
        }