Esempio n. 1
0
        private void OnItemChanged()
        {
            reforgeList.Clear();
            if (reforgeSlot.item.IsAir)
            {
                return;
            }

            Item controlItem = reforgeSlot.item.Clone();

            if (!ItemLoader.PreReforge(controlItem))
            {
                return;
            }
            controlItem.netDefaults(reforgeSlot.item.netID);
            controlItem = controlItem.CloneWithModdedDataFrom(reforgeSlot.item);

            UIReforgeLabel reforgeLabel;
            List <byte>    tempSelected = new List <byte>();
            bool           isArmor      = false;

            for (byte i = 1; i < ModPrefix.PrefixCount; i++)
            {
                Item tempItem = controlItem.Clone();

                isArmor = ModCompat.ArmorPrefix(tempItem);
                if (isArmor && !tempItem.accessory)
                {
                    tempItem.accessory = true;
                }

                if (!tempItem.CanApplyPrefix(i))
                {
                    continue;
                }

                tempItem.Prefix(i);
                if (isArmor)
                {
                    ModCompat.ApplyArmorPrefix(tempItem, i);
                }

                if (tempItem.prefix != i)
                {
                    continue;
                }

                reforgeLabel              = new UIReforgeLabel(tempItem);
                reforgeLabel.OnMouseDown += ChoseReforge;
                reforgeLabel.SetPadding(10);
                if (selectedPrefixes.Contains(i))
                {
                    reforgeLabel.selected = true;
                    tempSelected.Add(i);
                }
                reforgeList.Add(reforgeLabel);
            }
            selectedPrefixes = tempSelected;
        }
Esempio n. 2
0
        public override int CompareTo(object obj)
        {
            UIReforgeLabel other        = obj as UIReforgeLabel;
            int            diffSelected = -selected.CompareTo(other.selected);
            int            diffValue    = -shownItem.value.CompareTo(other.shownItem.value);

            return(diffSelected != 0 ? diffSelected : diffValue != 0 ? diffValue : shownItem.prefix.CompareTo(other.shownItem.prefix));
        }
Esempio n. 3
0
        private void ChoseReforge(UIMouseEvent evt, UIElement listeningElement)
        {
            UIReforgeLabel element = ((UIReforgeLabel)listeningElement);

            element.selected = !element.selected;
            if (!selectedPrefixes.Remove(element.shownItem.prefix))
            {
                selectedPrefixes.Add(element.shownItem.prefix);
            }
            reforgeList.UpdateOrder();
            Main.PlaySound(SoundID.MenuTick);
        }