Пример #1
0
        private void WindowFunction(int id)
        {
            GUI.DragWindow(new Rect(0, 0, m_rect.width - 35, 23));
            if (GUI.Button(new Rect(m_rect.width - 30, 2, 30, 20), "X"))
            {
                ShowMenu = false;
                return;
            }

            GUILayout.BeginArea(new Rect(5, 20, m_rect.width - 10, m_rect.height - 15));

            GUILayout.Space(20);

            if (SelectedEnchant != null)
            {
                if (GUILayout.Button("< Back to Enchantments"))
                {
                    SelectedEnchant = null;
                }
                GUILayout.Label("Selected Enchant: <b><color=orange>" + SelectedEnchant.Name + "</color></b>");
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Selected Slot: " + SelectedSlot.ToString(), GUILayout.Width(m_rect.width - 70));
            if (GUILayout.Button("<", GUILayout.Width(25)))
            {
                SetEnum(ref SelectedSlot, -1);
            }
            if (GUILayout.Button(">", GUILayout.Width(25)))
            {
                SetEnum(ref SelectedSlot, 1);
            }
            GUILayout.EndHorizontal();

            var character = CharacterManager.Instance.GetFirstLocalCharacter();

            if (character)
            {
                var equipment = (Equipment)character.Inventory.GetEquippedItem(SelectedSlot);

                if (equipment)
                {
                    GUILayout.Label("<b>Equipped:</b> <color=orange>" + equipment.Name + "</color>");

                    if (equipment.IsEnchanted)
                    {
                        GUI.color = Color.red;
                        var enchant = equipment.GetComponentInChildren <Enchantment>();
                        if (GUILayout.Button("Remove Enchantment (" + enchant.Name + ")"))
                        {
                            enchant.UnapplyEnchantment();
                            var ids = (List <int>)At.GetValue(typeof(Equipment), equipment, "m_enchantmentIDs");
                            ids.Clear();
                            At.Call(typeof(Equipment), equipment, "RefreshEnchantmentModifiers", null, new object[0]);
                        }
                    }
                    else if (SelectedEnchant != null)
                    {
                        GUI.color = Color.green;
                        if (GUILayout.Button("Apply Selected Enchant"))
                        {
                            equipment.AddEnchantment(SelectedEnchant.PresetID, false);
                        }
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Color.red;
                    GUILayout.Label("No item equipped in " + SelectedSlot.ToString() + " slot!");
                }
            }
            GUI.color = Color.white;

            if (SelectedEnchant == null)
            {
                GUILayout.Label("Enter an Enchantment ID to search for...");
                SearchText = GUILayout.TextField(SearchText);

                GUILayout.BeginVertical(GUI.skin.box);
                scroll = GUILayout.BeginScrollView(scroll);
                var search = SearchText.ToLower();
                foreach (var entry in m_cachedEnchantments)
                {
                    if (search == "" || entry.Key.ToLower().Contains(search))
                    {
                        if (GUILayout.Button(entry.Key))
                        {
                            SelectedEnchant = entry.Value;
                        }
                    }
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
            }

            GUILayout.EndArea();
        }