private static void BuildQuickSlotGrid(InventoryGui inventoryGui)
            {
                var pos = EquipmentAndQuickSlots.HasAuga ? new Vector2(3, -108) : new Vector2(3, -160);

                BuildInventoryGrid(ref QuickSlotGrid, "QuickSlotGrid", pos, new Vector2((74 * EquipmentAndQuickSlots.QuickSlotCount) + 10, 90), inventoryGui);
            }
Example #2
0
 public virtual void OnCraftPressed(InventoryGui instance)
 {
 }
Example #3
0
            static void Postfix(InventoryGui __instance)
            {
                Vector3 mousePos = Input.mousePosition;

                if (!modEnabled.Value)
                {
                    lastMousePos = mousePos;
                    return;
                }


                if (inventoryPosition.Value.x == 9999 && inventoryPosition.Value.y == 9999)
                {
                    inventoryPosition.Value = __instance.m_player.anchorMin;
                }

                __instance.m_player.anchorMin  = inventoryPosition.Value;
                __instance.m_player.anchorMax  = inventoryPosition.Value;
                __instance.m_player.localScale = new Vector3(inventoryScale.Value, inventoryScale.Value, 1);

                if (chestInventoryPosition.Value.x == 9999 || chestInventoryPosition.Value.y == 9999)
                {
                    chestInventoryPosition.Value = __instance.m_container.anchorMin;
                }

                __instance.m_container.anchorMin  = chestInventoryPosition.Value;
                __instance.m_container.anchorMax  = chestInventoryPosition.Value;
                __instance.m_container.localScale = new Vector3(chestInventoryScale.Value, chestInventoryScale.Value, 1);

                if (craftingPanelPosition.Value.x == 9999 || craftingPanelPosition.Value.y == 9999)
                {
                    craftingPanelPosition.Value = __instance.m_player.parent.Find("Crafting").GetComponent <RectTransform>().anchorMin;
                }

                __instance.m_player.parent.Find("Crafting").GetComponent <RectTransform>().anchorMin  = craftingPanelPosition.Value;
                __instance.m_player.parent.Find("Crafting").GetComponent <RectTransform>().anchorMax  = craftingPanelPosition.Value;
                __instance.m_player.parent.Find("Crafting").GetComponent <RectTransform>().localScale = new Vector3(craftingPanelScale.Value, craftingPanelScale.Value, 1);

                if (infoPanelPosition.Value.x == 9999 || infoPanelPosition.Value.y == 9999)
                {
                    infoPanelPosition.Value = __instance.m_infoPanel.GetComponent <RectTransform>().anchorMin;
                }

                __instance.m_infoPanel.GetComponent <RectTransform>().anchorMin  = infoPanelPosition.Value;
                __instance.m_infoPanel.GetComponent <RectTransform>().anchorMax  = infoPanelPosition.Value;
                __instance.m_infoPanel.GetComponent <RectTransform>().localScale = new Vector3(infoPanelScale.Value, infoPanelScale.Value, 1);

                if (lastMousePos == Vector3.zero)
                {
                    lastMousePos = mousePos;
                }


                PointerEventData eventData = new PointerEventData(EventSystem.current)
                {
                    position = lastMousePos
                };

                if (CheckKeyHeld(modKeyOne.Value) && CheckKeyHeld(modKeyTwo.Value) && lastMousePos != mousePos)
                {
                    List <RaycastResult> raycastResults = new List <RaycastResult>();
                    EventSystem.current.RaycastAll(eventData, raycastResults);

                    foreach (RaycastResult rcr in raycastResults)
                    {
                        if (rcr.gameObject.layer == LayerMask.NameToLayer("UI") && rcr.gameObject.name == "Bkg")
                        {
                            if (IsDragging(rcr, "Player"))
                            {
                                inventoryPosition.Value += new Vector2((mousePos.x - lastMousePos.x) / Screen.width, (mousePos.y - lastMousePos.y) / Screen.height);
                            }
                            if (IsDragging(rcr, "Container"))
                            {
                                chestInventoryPosition.Value += new Vector2((mousePos.x - lastMousePos.x) / Screen.width, (mousePos.y - lastMousePos.y) / Screen.height);
                            }
                            if (IsDragging(rcr, "Crafting"))
                            {
                                craftingPanelPosition.Value += new Vector2((mousePos.x - lastMousePos.x) / Screen.width, (mousePos.y - lastMousePos.y) / Screen.height);
                            }
                            if (IsDragging(rcr, "Info"))
                            {
                                infoPanelPosition.Value += new Vector2((mousePos.x - lastMousePos.x) / Screen.width, (mousePos.y - lastMousePos.y) / Screen.height);
                            }
                        }
                    }
                }
                else
                {
                    currentlyDragging = "";
                }

                lastMousePos = mousePos;
            }
        public static void Postfix(GameCamera __instance, ref float ___m_distance, ref float ___m_zoomSens)
        {
            if (!isEnabled.Value || GameCamera.InFreeFly())
            {
                return;
            }

            Player localPlayer = Player.m_localPlayer;

            if (!localPlayer)
            {
                return;
            }

            checkInteriorChange(localPlayer);
            ___m_zoomSens = cameraZoomSensitivity.Value;

            // Separate camera distances for different scenarios.
            if (canChangeCameraDistance)
            {
                if (cameraDistanceInteriorsEnabled.Value && playerInInterior)
                {
                    targetDistance = cameraDistanceInteriors.Value;
                }
                else if (cameraDistanceShelterEnabled.Value && playerInShelter)
                {
                    targetDistance = cameraDistanceShelter.Value;
                }
                else if (cameraDistanceBoatEnabled.Value && characterControlledShip)
                {
                    targetDistance = cameraDistanceBoat.Value;
                }
                else if (cameraDistanceBoatEnabled.Value && characterStoppedShipControl)
                {
                    targetDistance = cameraDistance.Value;
                }
                else if (cameraDistanceExteriorsEnabled.Value && (!playerInShelter && !playerInInterior))
                {
                    targetDistance = cameraDistance.Value;
                }

                canChangeCameraDistance = false;
            }

            if (smoothZoomEnabled.Value)
            {
                // Disable the games default zooming in and out. Otherwise, the distance will flicker.
                ___m_zoomSens = 0;

                if ((Chat.instance && Chat.instance.HasFocus() || (Console.IsVisible() || InventoryGui.IsVisible()) || (StoreGui.IsVisible() || Menu.IsVisible() || (Minimap.IsOpen() || localPlayer.InCutscene())) ? 0 : (!localPlayer.InPlaceMode() ? 1 : 0)) != 0)
                {
                    float minDistance = __instance.m_minDistance;
                    float maxDistance = localPlayer.GetControlledShip() != null ? cameraMaxDistanceBoat.Value : cameraMaxDistance.Value;

                    float prevTargetDistance = targetDistance;
                    targetDistance -= Input.GetAxis("Mouse ScrollWheel") * cameraZoomSensitivity.Value;
                    targetDistance  = Mathf.Clamp(targetDistance, minDistance, maxDistance);

                    // Reset time when player changes zoom distance (scrollwheel)
                    if (prevTargetDistance != targetDistance)
                    {
                        timePos = 0;
                    }
                }

                targetDistanceHasBeenReached = checkLerpDuration(timePos);

                if (!targetDistanceHasBeenReached)
                {
                    timePos += Time.deltaTime;
                    moveToNewCameraDistance(timePos / timeDuration, ref ___m_distance);
                }
            }
        }
Example #5
0
 public virtual void UpdateCraftingPanel(InventoryGui instance, bool focusView)
 {
 }
Example #6
0
        //In game menyn
        private void InGameMenu()
        {
            bool   continueCode = false;
            string option;
            bool   error        = false;
            string errorMsg     = default;
            int    saveReminder = default;

            do
            {
                //If the player has killed the dragon player will be over 20 strength.
                //so the check is for if player is back on lvl1 but strength is > 20,
                //then you have finished the game
                if (player.Level == 1 && player.KilledCreatures > 5)
                {
                    Print.ClearAllScreen();
                    Print.EnemyPrint("Ending dragon");
                    Console.SetCursorPosition(left, top);
                    Print.Yellow("You made it til the end, the dragon is defeted. You´re a hero!");
                    top++;
                    Console.SetCursorPosition(left, top);
                    Print.Yellow($"Killed enemies: {player.KilledCreatures}");
                    Console.ReadKey();
                    continueCode = true;
                }
                //if player is alive
                else
                {
                    if (player.Alive)
                    {
                        Print.ClearAllScreen();
                        //Front logo on menu screen
                        Print.EnemyPrint("Ending dragon");
                        player.PrintCurrentPlayerStatus();
                        top  = 13;
                        left = 45;
                        for (int i = 0; i < inGameMenuOptions.Length; i++)
                        {
                            Console.SetCursorPosition(left, top);
                            Console.WriteLine($"{i + 1}. {inGameMenuOptions[i]}");
                            top++;
                        }
                        //Reminder for the player to save
                        if (saveReminder >= 5 && saveReminder < 10)
                        {
                            Console.SetCursorPosition(left, top - 7);
                            Print.Yellow("Don´t forget to save your progress!");
                        }
                        else if (saveReminder >= 10)
                        {
                            saveReminder = default;
                        }

                        //Error message is printed out (if there are any)
                        if (error)
                        {
                            Console.SetCursorPosition(left, top + 2);
                            Print.Red(errorMsg);
                            errorMsg = default;
                        }
                        Console.SetCursorPosition(left, top + 1);
                        Console.Write("Choose your option> ");
                        Console.CursorVisible = true;
                        option = Console.ReadLine();
                        Console.CursorVisible = false;
                        var sounds = _menuObject.SoundList();
                        AudioPlaybackEngine sound = new AudioPlaybackEngine();
                        sound.PlaySound(sounds[1]);
                        Thread.Sleep(700);
                        sound.Dispose();
                        switch (option)
                        {
                        case "1":
                            //Go explore
                            error = false;
                            Thread.Sleep(500);
                            Explore explore = new Explore();
                            menuMusic.PauseSound();
                            explore.GoAdventure(player, _menuObject);
                            //If you died, play game over sound.
                            if (!player.Alive)
                            {
                                continueCode = true;
                                var listsound            = _menuObject.SoundList();
                                AudioPlaybackEngine dead = new AudioPlaybackEngine();
                                dead.PlaySound(listsound[12]);
                                Print.PlayerStatsPrint(player);
                            }
                            //else resume menu music and increse reminder counter
                            else
                            {
                                menuMusic.ResumeSound();
                                saveReminder++;
                            }
                            break;

                        case "2":
                            InventoryGui inventory = new InventoryGui();
                            inventory.InventoryMenu(player, _menuObject);

                            break;

                        case "3":
                            //Go shop
                            menuMusic.PauseSound();
                            var soundList = _menuObject.SoundList();
                            AudioPlaybackEngine shopMusic = new AudioPlaybackEngine();
                            shopMusic.PlaySound(soundList[2]);

                            Shop theShop = new Shop(_menuObject, player);
                            theShop.GoIn(player);
                            //shop is the sound for the shop that´s disposing
                            shopMusic.Dispose();
                            menuMusic.ResumeSound();
                            error = false;
                            saveReminder++;
                            break;

                        case "4":
                            //Save your game
                            errorMsg     = FileHandling.SavePlayerToFile(playerList);
                            error        = true;
                            saveReminder = 0;
                            break;

                        case "5":
                            //Exit game
                            Thread.Sleep(500);
                            Environment.Exit(0);
                            break;

                        default:
                            //If anything else is pressed, errormessage is set.
                            error    = true;
                            errorMsg = "Wrong menu choice";
                            break;
                        }
                    }

                    else
                    {
                        continueCode = true;
                    }
                }
            } while (!continueCode);
        }
        public static bool SetupRequirement(
            InventoryGui __instance,
            Transform elementRoot,
            ItemDrop item,
            int amount,
            Player player)
        {
            var icon       = elementRoot.transform.Find("res_icon").GetComponent <Image>();
            var nameText   = elementRoot.transform.Find("res_name").GetComponent <Text>();
            var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>();
            var tooltip    = elementRoot.GetComponent <UITooltip>();

            if (item != null)
            {
                icon.gameObject.SetActive(true);
                nameText.gameObject.SetActive(true);
                amountText.gameObject.SetActive(true);
                if (item.m_itemData.IsMagicCraftingMaterial())
                {
                    var rarity = item.m_itemData.GetCraftingMaterialRarity();
                    icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)];
                }
                else
                {
                    icon.sprite = item.m_itemData.GetIcon();
                }
                icon.color = Color.white;

                var bgIconTransform = icon.transform.parent.Find("bgIcon");
                if (item.m_itemData.UseMagicBackground())
                {
                    if (bgIconTransform == null)
                    {
                        bgIconTransform      = GameObject.Instantiate(icon, icon.transform.parent, true).transform;
                        bgIconTransform.name = "bgIcon";
                        bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex());
                    }

                    bgIconTransform.gameObject.SetActive(true);
                    var bgIcon = bgIconTransform.GetComponent <Image>();
                    bgIcon.sprite = EpicLoot.GetMagicItemBgSprite();
                    bgIcon.color  = item.m_itemData.GetRarityColor();
                }
                else if (bgIconTransform != null)
                {
                    bgIconTransform.gameObject.SetActive(false);
                }

                tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name);
                nameText.text  = Localization.instance.Localize(item.m_itemData.m_shared.m_name);
                if (amount <= 0)
                {
                    InventoryGui.HideRequirement(elementRoot);
                    return(false);
                }
                amountText.text = amount.ToString();

                var currentAmount = player.GetInventory().CountItems(item.m_itemData.m_shared.m_name);
                if (currentAmount < amount)
                {
                    amountText.color = Mathf.Sin(Time.time * 10.0f) > 0.0f ? Color.red : Color.white;
                }
                else
                {
                    amountText.color = Color.white;
                }
            }
            else
            {
                var bgIconTransform = icon.transform.parent.Find("bgIcon");
                if (bgIconTransform != null)
                {
                    bgIconTransform.gameObject.SetActive(false);
                }
            }
            return(true);
        }
Example #8
0
            static void Postfix(InventoryGui __instance, ref List <ItemDrop.ItemData> ___m_tempWornItems)
            {
                if (!modEnabled.Value)
                {
                    return;
                }

                if (!___m_tempWornItems.Any())
                {
                    return;
                }

                List <RepairItemData> freeRepairs      = new List <RepairItemData>();
                List <RepairItemData> enoughRepairs    = new List <RepairItemData>();
                List <RepairItemData> notEnoughRepairs = new List <RepairItemData>();
                List <RepairItemData> unableRepairs    = new List <RepairItemData>();
                List <string>         outstring        = new List <string>();

                foreach (ItemDrop.ItemData item in ___m_tempWornItems)
                {
                    if (!Traverse.Create(__instance).Method("CanRepair", new object[] { item }).GetValue <bool>())
                    {
                        unableRepairs.Add(new RepairItemData(item));
                        continue;
                    }
                    Recipe recipe = RepairRecipe(item);
                    if (recipe == null)
                    {
                        freeRepairs.Add(new RepairItemData(item));
                        continue;
                    }
                    List <string> reqstring = new List <string>();
                    foreach (Piece.Requirement req in recipe.m_resources)
                    {
                        if (req.GetAmount(item.m_quality) == 0)
                        {
                            continue;
                        }
                        reqstring.Add($"{req.GetAmount(item.m_quality)}/{Player.m_localPlayer.GetInventory().CountItems(req.m_resItem.m_itemData.m_shared.m_name)} {Localization.instance.Localize(req.m_resItem.m_itemData.m_shared.m_name)}");
                    }
                    if (!Traverse.Create(Player.m_localPlayer).Method("HaveRequirements", new object[] { recipe.m_resources, false, 1 }).GetValue <bool>())
                    {
                        notEnoughRepairs.Add(new RepairItemData(item, reqstring));
                    }
                    else
                    {
                        enoughRepairs.Add(new RepairItemData(item, reqstring));
                    }
                }
                orderedWornItems = new List <ItemDrop.ItemData>();
                foreach (RepairItemData rid in freeRepairs)
                {
                    outstring.Add($"<color=#{hasEnoughTooltipColor.Value}>{Localization.instance.Localize(rid.item.m_shared.m_name)}: Free</color>");
                    orderedWornItems.Add(rid.item);
                }
                foreach (RepairItemData rid in enoughRepairs)
                {
                    outstring.Add($"<color=#{hasEnoughTooltipColor.Value}>{Localization.instance.Localize(rid.item.m_shared.m_name)}: {string.Join(", ", rid.reqstring)}</color>");
                    orderedWornItems.Add(rid.item);
                }
                foreach (RepairItemData rid in notEnoughRepairs)
                {
                    outstring.Add($"<color=#{notEnoughTooltipColor.Value}>{Localization.instance.Localize(rid.item.m_shared.m_name)}: {string.Join(", ", rid.reqstring)}</color>");
                    orderedWornItems.Add(rid.item);
                }
                foreach (RepairItemData rid in unableRepairs)
                {
                    orderedWornItems.Add(rid.item);
                }
                ___m_tempWornItems = new List <ItemDrop.ItemData>(orderedWornItems);

                if (!showAllRepairsInToolTip.Value)
                {
                    return;
                }

                UITooltip  tt = (UITooltip)typeof(UITooltip).GetField("m_current", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                GameObject go = (GameObject)typeof(UITooltip).GetField("m_tooltip", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

                if (go == null || tt.transform.name != "RepairButton")
                {
                    return;
                }

                Utils.FindChild(go.transform, "Text").GetComponent <Text>().supportRichText = true;
                Utils.FindChild(go.transform, "Text").GetComponent <Text>().alignment       = TextAnchor.LowerCenter;
                Utils.FindChild(go.transform, "Text").GetComponent <Text>().text            = $"<b><color=#{titleTooltipColor.Value}>{Localization.instance.Localize("$inventory_repairbutton")}</color></b>\r\n" + string.Join("\r\n", outstring);
            }
Example #9
0
        private void Update()
        {
            if (!modEnabled.Value || !Player.m_localPlayer || !InventoryGui.IsVisible() || (!Player.m_localPlayer.GetCurrentCraftingStation() && !Player.m_localPlayer.NoCostCheat()))
            {
                lastCategoryIndex = 0;
                UpdateDropDown(false);
                return;
            }
            if (!InventoryGui.instance.InCraftTab())
            {
                UpdateDropDown(false);
                return;
            }

            bool hover = false;

            Vector3 mousePos = Input.mousePosition;

            if (lastMousePos == Vector3.zero)
            {
                lastMousePos = mousePos;
            }

            PointerEventData eventData = new PointerEventData(EventSystem.current)
            {
                position = lastMousePos
            };

            List <RaycastResult> raycastResults = new List <RaycastResult>();

            EventSystem.current.RaycastAll(eventData, raycastResults);
            foreach (RaycastResult rcr in raycastResults)
            {
                if (rcr.gameObject.layer == LayerMask.NameToLayer("UI"))
                {
                    if (rcr.gameObject.name == "Craft")
                    {
                        hover = true;
                        if (tabCraftPressed == 0)
                        {
                            if (useScrollWheel.Value && AedenthornUtils.CheckKeyHeld(scrollModKey.Value, false) && Input.mouseScrollDelta.y != 0)
                            {
                                SwitchFilter(Input.mouseScrollDelta.y < 0);
                            }
                            if (showMenu.Value)
                            {
                                UpdateDropDown(true);
                            }
                        }
                    }
                    else if (dropDownList.Contains(rcr.gameObject))
                    {
                        hover = true;
                    }
                }
            }

            if (!hover)
            {
                if (tabCraftPressed > 0)
                {
                    tabCraftPressed--;
                }
                UpdateDropDown(false);
            }

            if (AedenthornUtils.CheckKeyDown(prevHotKey.Value))
            {
                SwitchFilter(false);
            }
            else if (AedenthornUtils.CheckKeyDown(nextHotKey.Value))
            {
                SwitchFilter(true);
            }

            lastMousePos = Input.mousePosition;
        }
Example #10
0
        public static void Postfix(InventoryGui __instance)
        {
            var recipeDesc = __instance.m_recipeDecription;

            if (EpicLoot.UseScrollingCraftDescription.Value && recipeDesc.GetComponent <ContentSizeFitter>() == null)
            {
                var contentSizeFitter = recipeDesc.gameObject.AddComponent <ContentSizeFitter>();
                contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;

                recipeDesc.resizeTextForBestFit           = false;
                recipeDesc.fontSize                       = 18;
                recipeDesc.rectTransform.anchorMin        = new Vector2(0, 1);
                recipeDesc.rectTransform.anchorMax        = new Vector2(1, 1); // pin top, stretch horiz
                recipeDesc.rectTransform.pivot            = new Vector2(0, 1);
                recipeDesc.horizontalOverflow             = HorizontalWrapMode.Wrap;
                recipeDesc.rectTransform.anchoredPosition = new Vector2(4, 4);
                recipeDesc.raycastTarget                  = false;

                var scrollRectGO = new GameObject("ScrollView", typeof(RectTransform), typeof(ScrollRect), typeof(Image));
                scrollRectGO.transform.SetParent(__instance.m_recipeDecription.transform.parent, false);
                scrollRectGO.transform.SetSiblingIndex(0);
                var rt = scrollRectGO.transform as RectTransform;
                rt.anchorMin        = new Vector2(0, 1);
                rt.anchorMax        = new Vector2(0, 1);
                rt.pivot            = new Vector2(0, 1);
                rt.anchoredPosition = new Vector2(11, -74);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 330);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 300);
                scrollRectGO.GetComponent <Image>().color = new Color(0, 0, 0, 0.2f);

                var viewport = new GameObject("Viewport", typeof(RectTransform), typeof(RectMask2D));
                viewport.transform.SetParent(scrollRectGO.transform, false);
                var vrt = viewport.transform as RectTransform;
                vrt.anchorMin = new Vector2(0, 0);
                vrt.anchorMax = new Vector2(1, 1);
                vrt.sizeDelta = new Vector2(0, 0);
                recipeDesc.transform.SetParent(vrt, false);

                var scrollRect = scrollRectGO.GetComponent <ScrollRect>();
                scrollRect.viewport   = vrt;
                scrollRect.content    = recipeDesc.rectTransform;
                scrollRect.horizontal = false;
                scrollRect.vertical   = true;
                scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide;
                scrollRect.scrollSensitivity           = 30;
                scrollRect.inertia      = false;
                scrollRect.movementType = ScrollRect.MovementType.Clamped;
                scrollRect.onValueChanged.RemoveAllListeners();

                var newScrollbar = Object.Instantiate(__instance.m_recipeListScroll, scrollRectGO.transform);
                newScrollbar.size = 0.4f;
                scrollRect.onValueChanged.AddListener((_) => newScrollbar.size = 0.4f);
                scrollRect.verticalScrollbar = newScrollbar;
            }

            if (__instance.InCraftTab() &&
                __instance.m_selectedRecipe.Key != null &&
                __instance.m_selectedRecipe.Key.m_item.m_itemData.IsMagicCraftingMaterial())
            {
                var localizedName = Localization.instance.Localize(__instance.m_selectedRecipe.Key.m_item.m_itemData.GetDecoratedName());
                if (__instance.m_selectedRecipe.Key.m_amount > 1)
                {
                    localizedName = localizedName + " x" + __instance.m_selectedRecipe.Key.m_amount;
                }
                __instance.m_recipeName.text = localizedName;

                __instance.m_recipeIcon.sprite = __instance.m_selectedRecipe.Key.m_item.m_itemData.GetIcon();
                __instance.m_variantButton.gameObject.SetActive(false);
            }

            if (__instance.InCraftTab() || __instance.InUpradeTab())
            {
                Image bgImage = null;

                var magicItemBG = __instance.m_recipeIcon.transform.parent.Find("MagicItemBG");
                if (magicItemBG != null)
                {
                    bgImage = magicItemBG.GetComponent <Image>();
                }
                else
                {
                    bgImage      = Object.Instantiate(__instance.m_recipeIcon, __instance.m_recipeIcon.transform.parent, true);
                    bgImage.name = "MagicItemBG";
                    bgImage.transform.SetSiblingIndex(__instance.m_recipeIcon.transform.GetSiblingIndex());
                    bgImage.sprite = EpicLoot.GetMagicItemBgSprite();
                }

                var item = __instance.InCraftTab() ? __instance.m_selectedRecipe.Key?.m_item?.m_itemData : __instance.m_selectedRecipe.Value;
                if (item != null && item.UseMagicBackground())
                {
                    bgImage.enabled = item.UseMagicBackground();
                    bgImage.color   = item.GetRarityColor();

                    __instance.m_recipeName.text = Localization.instance.Localize(item.GetDecoratedName());
                }
                else
                {
                    bgImage.enabled = false;
                }
            }

            if (__instance.InUpradeTab() && __instance.m_selectedRecipe.Value != null)
            {
                var newQuality = Mathf.Min(__instance.m_selectedRecipe.Value.m_quality + 1, __instance.m_selectedRecipe.Value.m_shared.m_maxQuality);
                var tooltip    = ItemDrop.ItemData.GetTooltip(__instance.m_selectedRecipe.Value, newQuality, true);
                __instance.m_recipeDecription.text = Localization.instance.Localize(tooltip);
            }
        }
Example #11
0
 public static SplitReceiver Create(float max, Slider slider, InventoryGui inventory = null)
 {
     receiver = new SplitReceiver(max, slider, inventory);
     TextInput.instance.RequestText(receiver, $"Enter Amount (1-{max})", max.ToString().Length);
     return(receiver);
 }
Example #12
0
 public static void UpdateCraftingPanel(this InventoryGui instance, bool focus)
 {
     throw new NotImplementedException("Stub");
 }
Example #13
0
            private static void BuildInventoryGrid(ref InventoryGrid grid, string name, Vector2 position, Vector2 size, InventoryGui inventoryGui)
            {
                if (grid != null)
                {
                    Object.Destroy(grid);
                    grid = null;
                }

                if (EAQSPanel == null)
                {
                    if (EquipmentAndQuickSlots.HasAuga)
                    {
                        EAQSPanel = Auga.API.Panel_Create(inventoryGui.m_player, new Vector2(255, 352), "EAQS", false);
                        var rt = (RectTransform)EAQSPanel.transform;
                        rt.anchorMin        = new Vector2(0, 1);
                        rt.anchorMax        = new Vector2(0, 1);
                        rt.anchoredPosition = new Vector2(752, -166);
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 255);
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 352);

                        var paperdolls = Object.Instantiate(EquipmentAndQuickSlots.Paperdolls, EAQSPanel.transform, false);
                        paperdolls.name = "Paperdolls";

                        var divider = Auga.API.Divider_CreateSmall(EAQSPanel.transform, "Divider", 255 - 40);
                        rt = (RectTransform)divider.transform;
                        rt.anchoredPosition = new Vector2(0, -157);
                    }
                    else
                    {
                        EAQSPanel = new GameObject("EAQS", typeof(RectTransform));
                        EAQSPanel.transform.SetParent(inventoryGui.m_player);
                        var rt = (RectTransform)EAQSPanel.transform;
                        rt.anchorMin        = new Vector2(0, 1);
                        rt.anchorMax        = new Vector2(0, 1);
                        rt.anchoredPosition = new Vector2(752, -166);
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 255);
                        rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 352);
                    }
                }

                var go = new GameObject(name, typeof(RectTransform));

                go.transform.SetParent(EAQSPanel.transform, false);

                grid = go.AddComponent <InventoryGrid>();
                var root = new GameObject("Root", typeof(RectTransform));

                root.transform.SetParent(go.transform, false);

                var rect = go.transform as RectTransform;

                rect.anchoredPosition = position;

                grid.m_elementPrefab = inventoryGui.m_playerGrid.m_elementPrefab;
                grid.m_gridRoot      = root.transform as RectTransform;
                grid.m_elementSpace  = inventoryGui.m_playerGrid.m_elementSpace;
                grid.ResetView();

                if (name == "EquipmentSlotGrid")
                {
                    grid.m_onSelected   += OnEquipmentSelected(inventoryGui);
                    grid.m_onRightClick += OnEquipmentRightClicked(inventoryGui);
                }
                else
                {
                    grid.m_onSelected   += OnSelected(inventoryGui);
                    grid.m_onRightClick += OnRightClicked(inventoryGui);
                }

                grid.m_uiGroup = grid.gameObject.AddComponent <UIGroupHandler>();
                grid.m_uiGroup.m_groupPriority = 1;
                grid.m_uiGroup.m_active        = true;

                if (!EquipmentAndQuickSlots.HasAuga)
                {
                    var highlight = new GameObject("SelectedFrame", typeof(RectTransform));
                    highlight.transform.SetParent(go.transform, false);
                    highlight.AddComponent <Image>().color = Color.yellow;
                    var highlightRT = highlight.transform as RectTransform;
                    highlightRT.SetAsFirstSibling();
                    highlightRT.anchoredPosition = new Vector2(0, 0);
                    highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x + 2);
                    highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y + 2);
                    highlightRT.localScale = new Vector3(1, 1, 1);
                    grid.m_uiGroup.m_enableWhenActiveAndGamepad = highlight;

                    var bkg        = inventoryGui.m_player.Find("Bkg").gameObject;
                    var background = Object.Instantiate(bkg, go.transform);
                    background.name = name + "Bkg";
                    var backgroundRT = background.transform as RectTransform;
                    backgroundRT.SetSiblingIndex(1);
                    backgroundRT.anchoredPosition = new Vector2(0, 0);
                    backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x);
                    backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y);
                    backgroundRT.localScale = new Vector3(1, 1, 1);
                }

                var list = inventoryGui.m_uiGroups.ToList();

                list.Insert(2, grid.m_uiGroup);
                inventoryGui.m_uiGroups = list.ToArray();
            }
Example #14
0
            private static void BuildEquipmentSlotGrid(InventoryGui inventoryGui)
            {
                var pos = EquipmentAndQuickSlots.HasAuga ? new Vector2(3, 40) : new Vector2(3, 20);

                BuildInventoryGrid(ref EquipmentSlotGrid, "EquipmentSlotGrid", pos, new Vector2(210, 270), inventoryGui);
            }
        public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe          = Recipes[SelectedRecipe];
                var itemData        = recipe.FromItem;
                var rarityColor     = EpicLoot.GetRarityColor(SelectedRarity);
                var rarityColorARGB = EpicLoot.GetRarityColorARGB(SelectedRarity);

                for (var index = 0; index < RarityButtons.Count; index++)
                {
                    var rarityButton     = RarityButtons[index];
                    var rarity           = (ItemRarity)index;
                    var canEnchantRarity = CanEnchantRarity(player, rarity);
                    rarityButton.gameObject.SetActive(canEnchantRarity);
                    rarityButton.interactable = SelectedRarity != rarity;

                    var outline = rarityButton.transform.Find("EnchantOutline").GetComponent <Image>();
                    outline.enabled = !rarityButton.interactable;
                }

                __instance.m_recipeIcon.enabled = true;
                __instance.m_recipeIcon.sprite  = itemData.GetIcon();

                __instance.m_recipeName.enabled = true;
                __instance.m_recipeName.text    = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor));

                __instance.m_recipeDecription.enabled = true;
                __instance.m_recipeDecription.text    = Localization.instance.Localize(GenerateEnchantTooltip(recipe));

                bgImage.color   = rarityColorARGB;
                bgImage.enabled = true;

                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);

                SetupRequirementList(__instance, player, recipe);

                __instance.m_minStationLevelIcon.gameObject.SetActive(false);

                var canCraft = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe, SelectedRarity), false, 1);
                __instance.m_craftButton.interactable = canCraft;
                __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant";
                __instance.m_craftButton.GetComponent <UITooltip>().m_text    = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement");
            }
            else
            {
                bgImage.enabled = false;
                __instance.m_itemCraftType.gameObject.SetActive(false);
                __instance.m_variantButton.gameObject.SetActive(false);
                __instance.m_minStationLevelIcon.gameObject.SetActive(false);
                __instance.m_recipeIcon.enabled       = false;
                __instance.m_recipeName.enabled       = false;
                __instance.m_recipeDecription.enabled = false;
                foreach (var rarityButton in RarityButtons)
                {
                    rarityButton.gameObject.SetActive(false);
                }
                foreach (var req in __instance.m_recipeRequirementList)
                {
                    InventoryGui.HideRequirement(req.transform);
                }

                __instance.m_craftButton.interactable = false;
            }
        }
Example #16
0
            static void Postfix(InventoryGui __instance, ItemDrop.ItemData ___m_dragItem, Inventory ___m_dragInventory, int ___m_dragAmount, ref GameObject ___m_dragGo)
            {
                if (Input.GetKeyDown(m_hotkey.Value) && ___m_dragItem != null && ___m_dragInventory.ContainsItem(___m_dragItem))
                {
                    Dbgl($"Discarding {___m_dragAmount}/{___m_dragItem.m_stack} {___m_dragItem.m_dropPrefab.name}");

                    if (returnResources.Value > 0)
                    {
                        Recipe recipe = ObjectDB.instance.GetRecipe(___m_dragItem);

                        if (recipe != null)
                        {
                            Dbgl($"Recipe stack: {recipe.m_amount} num of stacks: {___m_dragAmount / recipe.m_amount}");
                        }

                        if (recipe != null && ___m_dragAmount / recipe.m_amount > 0)
                        {
                            for (int i = 0; i < ___m_dragAmount / recipe.m_amount; i++)
                            {
                                foreach (Piece.Requirement req in recipe.m_resources)
                                {
                                    int quality = ___m_dragItem.m_quality;
                                    for (int j = quality; j > 0; j--)
                                    {
                                        GameObject        prefab  = ObjectDB.instance.m_items.FirstOrDefault(item => item.GetComponent <ItemDrop>().m_itemData.m_shared.m_name == req.m_resItem.m_itemData.m_shared.m_name);
                                        ItemDrop.ItemData newItem = prefab.GetComponent <ItemDrop>().m_itemData;
                                        int numToAdd = Mathf.RoundToInt(req.GetAmount(j) * returnResources.Value);
                                        Dbgl($"Returning {numToAdd}/{req.GetAmount(j)} {prefab.name}");
                                        while (numToAdd > 0)
                                        {
                                            int stack = Mathf.Min(req.m_resItem.m_itemData.m_shared.m_maxStackSize, numToAdd);
                                            numToAdd -= stack;

                                            if (Player.m_localPlayer.GetInventory().AddItem(prefab.name, stack, req.m_resItem.m_itemData.m_quality, req.m_resItem.m_itemData.m_variant, 0, "") == null)
                                            {
                                                ItemDrop component = Instantiate(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward + Player.m_localPlayer.transform.up, Player.m_localPlayer.transform.rotation).GetComponent <ItemDrop>();
                                                component.m_itemData = newItem.Clone();
                                                component.m_itemData.m_dropPrefab = prefab;
                                                component.m_itemData.m_stack      = stack;
                                                Traverse.Create(component).Method("Save").GetValue();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (___m_dragAmount == ___m_dragItem.m_stack)
                    {
                        Player.m_localPlayer.RemoveFromEquipQueue(___m_dragItem);
                        Player.m_localPlayer.UnequipItem(___m_dragItem, false);
                        ___m_dragInventory.RemoveItem(___m_dragItem);
                    }
                    else
                    {
                        ___m_dragInventory.RemoveItem(___m_dragItem, ___m_dragAmount);
                    }
                    Destroy(___m_dragGo);
                    ___m_dragGo = null;
                    __instance.GetType().GetMethod("UpdateCraftingPanel", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { false });
                }
            }
        public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed)
        {
            base.TryInitialize(inventoryGui, tabIndex, onTabPressed);

            if (RarityButtons.Count == 0)
            {
                var index    = 0;
                var startPos = new Vector2(60, -95);
                foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
                {
                    var rarityColor = EpicLoot.GetRarityColorARGB(rarity);

                    var rarityButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true);
                    rarityButton.gameObject.name = $"{rarity}EnchantButton";
                    rarityButton.gameObject.SetActive(false);
                    rarityButton.onClick = new Button.ButtonClickedEvent();
                    rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity));
                    rarityButton.colors = new ColorBlock()
                    {
                        disabledColor    = Color.white,
                        highlightedColor = Color.white,
                        pressedColor     = Color.white,
                        normalColor      = new Color(0.7f, 0.7f, 0.7f, 1)
                    };
                    rarityButton.spriteState = new SpriteState()
                    {
                        disabledSprite    = rarityButton.spriteState.selectedSprite,
                        selectedSprite    = rarityButton.spriteState.selectedSprite,
                        pressedSprite     = rarityButton.spriteState.pressedSprite,
                        highlightedSprite = rarityButton.spriteState.highlightedSprite
                    };
                    var outlineGO = new GameObject("EnchantOutline", typeof(RectTransform), typeof(Image));
                    var outline   = outlineGO.GetComponent <Image>();
                    outlineGO.transform.SetParent(rarityButton.transform, false);
                    outline.type   = Image.Type.Sliced;
                    outline.sprite = EpicLoot.Assets.SmallButtonEnchantOverlay;
                    outline.rectTransform.anchorMin        = new Vector2(0, 0);
                    outline.rectTransform.anchorMax        = new Vector2(1, 1);
                    outline.rectTransform.anchoredPosition = new Vector2(0, 0);
                    outline.rectTransform.sizeDelta        = new Vector2(0, 0);
                    outline.color   = rarityColor;
                    outline.enabled = true;

                    var buttonTextColor = rarityButton.GetComponent <ButtonTextColor>();
                    buttonTextColor.m_defaultColor   = rarityColor;
                    buttonTextColor.m_defaultColor.a = 0.7f;
                    buttonTextColor.m_disabledColor  = rarityColor;
                    var text = rarityButton.GetComponentInChildren <Text>();
                    text.text  = rarity.ToString();
                    text.color = rarityColor;
                    RarityButtons.Add(rarityButton);
                    var rt = rarityButton.transform as RectTransform;
                    rt.anchoredPosition = startPos + (index * new Vector2(rt.rect.width + 4, 0));
                    index++;
                }
            }

            if (SuccessDialog == null)
            {
                var newDialog = Object.Instantiate(inventoryGui.m_variantDialog, inventoryGui.m_variantDialog.transform.parent);
                SuccessDialog = newDialog.gameObject.AddComponent <CraftSuccessDialog>();
                Object.Destroy(newDialog);
                SuccessDialog.gameObject.name = "CraftingSuccessDialog";

                var background = SuccessDialog.gameObject.transform.Find("VariantFrame") as RectTransform;
                background.gameObject.name = "Frame";
                for (int i = 1; i < background.transform.childCount; ++i)
                {
                    var child = background.transform.GetChild(i);
                    Object.Destroy(child.gameObject);
                }
                background.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 380);
                background.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 550);
                background.anchoredPosition += new Vector2(20, -270);

                SuccessDialog.MagicBG        = Object.Instantiate(inventoryGui.m_recipeIcon, background);
                SuccessDialog.MagicBG.name   = "MagicItemBG";
                SuccessDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite();
                SuccessDialog.MagicBG.color  = Color.white;

                SuccessDialog.NameText    = Object.Instantiate(inventoryGui.m_recipeName, background);
                SuccessDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background);
                SuccessDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110);
                SuccessDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460);
                SuccessDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background);

                var closeButton = SuccessDialog.gameObject.GetComponentInChildren <Button>();
                closeButton.onClick = new Button.ButtonClickedEvent();
                closeButton.onClick.AddListener(SuccessDialog.OnClose);
                closeButton.transform.SetAsLastSibling();
            }
        }
Example #18
0
        public static RectTransform CreateGameObject(ref InventoryGrid grid, InventoryGui inventoryGui, GameObject parent, string name, GOTypes type, Vector2 size)
        {
            if (grid != null)
            {
                Object.Destroy(grid.gameObject);
                grid = null;
            }

            if (type == GOTypes.HOTKEYS)
            {
                if (!RunicPower.configHotkeysEnabled.Value)
                {
                    return(null);
                }
            }

            // go
            var go = new GameObject(name, typeof(RectTransform));

            go.transform.SetParent(parent.transform, false);

            // hightlight
            var highlight = new GameObject("SelectedFrame", typeof(RectTransform));

            if (type == GOTypes.INVENTORY)
            {
                highlight.transform.SetParent(go.transform, false);
                // highlight.AddComponent<Image>().color = Color.yellow;
                var highlightRT = highlight.transform as RectTransform;
                highlightRT.anchoredPosition = new Vector2(0, 0);
                highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x + 2);
                highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y + 2);
                highlightRT.localScale = new Vector3(1, 1, 1);

                // background
                var bkg        = inventoryGui.m_player.Find("Bkg").gameObject;
                var background = Object.Instantiate(bkg, go.transform);
                background.name = name + "Bkg";
                var backgroundRT = background.transform as RectTransform;
                backgroundRT.anchoredPosition = new Vector2(0, 0);
                backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x);
                backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y);
                backgroundRT.localScale = new Vector3(1, 1, 1);
            }

            // grid
            grid = go.AddComponent <InventoryGrid>();

            grid.name = name + "Grid";
            var root = new GameObject("Root", typeof(RectTransform));

            root.transform.SetParent(go.transform, false);
            grid.m_elementPrefab = inventoryGui.m_playerGrid.m_elementPrefab;
            grid.m_gridRoot      = root.transform as RectTransform;
            grid.m_elementSpace  = inventoryGui.m_playerGrid.m_elementSpace;
            grid.ResetView();

            if (type == GOTypes.INVENTORY)
            {
                grid.m_onSelected   = OnSelected(inventoryGui);
                grid.m_onRightClick = OnRightClicked(inventoryGui);
            }
            else
            {
                grid.m_onSelected   = null;
                grid.m_onRightClick = null;
            }

            grid.m_uiGroup = grid.gameObject.AddComponent <UIGroupHandler>();
            grid.m_uiGroup.m_groupPriority = 1;
            grid.m_uiGroup.m_active        = true;
            grid.m_uiGroup.m_enableWhenActiveAndGamepad = highlight;

            // list
            var list = inventoryGui.m_uiGroups.ToList();

            list.Insert(2, grid.m_uiGroup);
            inventoryGui.m_uiGroups = list.ToArray();

            // rect
            var goRect = go.transform as RectTransform;


            if (type == GOTypes.HOTKEYS)
            {
                var position = new Vector2(RunicPower.configHotkeysOffsetX.Value, RunicPower.configHotkeysOffsetY.Value);
                var cfgScale = RunicPower.configHotkeysScale.Value / 100f;
                var scale    = new Vector3(cfgScale, cfgScale, cfgScale);
                goRect.localScale = scale;

                goRect.anchorMin = new Vector2(0.5f, 0);
                goRect.anchorMax = new Vector2(0.5f, 0);
                goRect.pivot     = new Vector2(0.5f, 0);
                goRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x);
                goRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y);

                position.x -= ((size.x - 107) / 2) * cfgScale;
                goRect.anchoredPosition = position;
            }
            else
            {
                if (RunicPower.configInvBarPosition.Value == RunicPower.InvBarPosition.TOP)
                {
                    var position = new Vector2(1000, 103);
                    goRect.anchoredPosition = position;
                }
                else
                {
                    var cfgScale = RunicPower.configHotkeysScale.Value / 100f;
                    var scale    = new Vector3(cfgScale, cfgScale, cfgScale);
                    goRect.localScale = scale;

                    goRect.anchorMin = new Vector2(0.5f, 0f);
                    goRect.anchorMax = new Vector2(0.5f, 0f);
                    goRect.pivot     = new Vector2(0.5f, 0f);

                    var sizex    = 643f;
                    var sizey    = 88f;
                    var guiscale = GuiScaler.m_largeGuiScale;

                    var x = GuiScaler.m_minWidth / guiscale / 2 - sizex / 2;
                    var y = (GuiScaler.m_minHeight / guiscale + sizey - 410) * -1;

                    var position = new Vector2(x, y);

                    goRect.anchoredPosition = position;
                }
            }

            return(goRect);
        }
Example #19
0
            static void Postfix(InventoryGui __instance, InventoryGrid ___m_playerGrid, Animator ___m_animator)
            {
                if (!modEnabled.Value || !Player.m_localPlayer)
                {
                    return;
                }

                if (addEquipmentRow.Value)
                {
                    Traverse t = Traverse.Create(Player.m_localPlayer);

                    Inventory inv = Player.m_localPlayer.GetInventory();

                    var items = inv.GetAllItems();

                    var helmet  = t.Field("m_helmetItem").GetValue <ItemDrop.ItemData>();
                    var chest   = t.Field("m_chestItem").GetValue <ItemDrop.ItemData>();
                    var legs    = t.Field("m_legItem").GetValue <ItemDrop.ItemData>();
                    var back    = t.Field("m_shoulderItem").GetValue <ItemDrop.ItemData>();
                    var utility = t.Field("m_utilityItem").GetValue <ItemDrop.ItemData>();


                    int width  = inv.GetWidth();
                    int offset = width * (inv.GetHeight() - 1);

                    if (helmet != null)
                    {
                        t.Field("m_helmetItem").GetValue <ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
                    }
                    offset++;

                    if (chest != null)
                    {
                        t.Field("m_chestItem").GetValue <ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
                    }
                    offset++;

                    if (legs != null)
                    {
                        t.Field("m_legItem").GetValue <ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
                    }
                    offset++;

                    if (back != null)
                    {
                        t.Field("m_shoulderItem").GetValue <ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
                    }
                    offset++;

                    if (utility != null)
                    {
                        t.Field("m_utilityItem").GetValue <ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
                    }


                    for (int i = 0; i < items.Count; i++)
                    {
                        //Dbgl($"{items[i].m_gridPos} {inv.GetHeight() - 1},0 {items[i] != helmet}");
                        if (IsAtEquipmentSlot(inv, items[i], out int which))
                        {
                            if ( // in right slot and equipped
                                (which == 0 && items[i] == helmet) ||
                                (which == 1 && items[i] == chest) ||
                                (which == 2 && items[i] == legs) ||
                                (which == 3 && items[i] == back) ||
                                (which == 4 && items[i] == utility)
                                )
                            {
                                continue;
                            }

                            if (which > -1 && items[i].m_shared.m_itemType == typeEnums[which] && equipItems[which] != items[i] && Player.m_localPlayer.EquipItem(items[i], false)) // in right slot and new
                            {
                                continue;
                            }

                            // in wrong slot or unequipped in slot or can't equip
                            Vector2i newPos = (Vector2i)typeof(Inventory).GetMethod("FindEmptySlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(inv, new object[] { true });
                            if (newPos.x < 0 || newPos.y < 0 || newPos.y == inv.GetHeight() - 1)
                            {
                                Player.m_localPlayer.DropItem(inv, items[i], items[i].m_stack);
                            }
                            else
                            {
                                items[i].m_gridPos = newPos;
                                ___m_playerGrid.UpdateInventory(inv, Player.m_localPlayer, null);
                            }
                        }
                    }
                    equipItems = new ItemDrop.ItemData[] { helmet, chest, legs, back, utility };
                }

                if (___m_animator.GetBool("visible"))
                {
                    __instance.m_player.Find("Bkg").GetComponent <RectTransform>().anchorMin = new Vector2(0, (extraRows.Value + (addEquipmentRow.Value && !displayEquipmentRowSeparate.Value ? 1 : 0)) * -0.25f);

                    if (addEquipmentRow.Value)
                    {
                        if (displayEquipmentRowSeparate.Value && __instance.m_player.Find("EquipmentBkg") == null)
                        {
                            Transform bkg = Instantiate(__instance.m_player.Find("Bkg"), __instance.m_player);
                            bkg.SetAsFirstSibling();
                            bkg.name = "EquipmentBkg";
                            bkg.GetComponent <RectTransform>().anchorMin = new Vector2(1, 0);
                            bkg.GetComponent <RectTransform>().anchorMax = new Vector2(1.5f, 1);
                        }
                        else if (!displayEquipmentRowSeparate.Value && __instance.m_player.Find("EquipmentBkg"))
                        {
                            Destroy(__instance.m_player.Find("EquipmentBkg").gameObject);
                        }
                    }
                }
            }
Example #20
0
        public static Action <InventoryGrid, ItemDrop.ItemData, Vector2i, InventoryGrid.Modifier> OnSelected(InventoryGui inventoryGui)
        {
            return((InventoryGrid inventoryGrid, ItemDrop.ItemData item, Vector2i pos, InventoryGrid.Modifier mod) => {
                if (mod == InventoryGrid.Modifier.Move)
                {
                    return;
                }

                var ext = Player.m_localPlayer.ExtendedPlayer(true);
                var ok = true;
                ext.SetSelectingRuneItem(item);
                if (inventoryGui.m_dragItem != null)
                {
                    var rune = inventoryGui.m_dragItem?.GetRuneData();
                    if (rune == null)
                    {
                        Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You can't put a non-rune item on this slot.");
                        ok = false;
                    }
                }
                if (ok)
                {
                    inventoryGui.OnSelectedItem(inventoryGrid, item, pos, mod);
                }
                ext.SetSelectingRuneItem(null);
            });
        }
 private void OnSelectedRecipe(InventoryGui __instance, int index)
 {
     SelectedRecipe = index;
     SetRecipe(__instance, SelectedRecipe, false);
 }
Example #22
0
 public static Action <InventoryGrid, ItemDrop.ItemData, Vector2i> OnRightClicked(InventoryGui inventoryGui)
 {
     return((InventoryGrid inventoryGrid, ItemDrop.ItemData item, Vector2i pos) => {
         var player = Player.m_localPlayer;
         player?.UseRuneFromSpellBar(item);
     });
 }
Example #23
0
 public static bool Prefix(InventoryGui __instance)
 {
     OnTabPressed(TabControllers.FirstOrDefault(x => x.Tab == CraftingTabType.Upgrade));
     return(false);
 }
Example #24
0
        private static void DontShowMinimap_Patch(On.Minimap.orig_SetMapMode orig, Minimap self, int mode)
        {
            if (ConfigUtil.Get <bool>("Map", "showNoMinimap"))
            {
                if ((Chat.instance == null || !Chat.instance.HasFocus()) && !global::Console.IsVisible() && !InventoryGui.IsVisible() && !Minimap.InTextInput())
                {
                    if (ZInput.GetButtonDown("Map") || ZInput.GetButtonDown("JoyMap") || (self.m_mode == Minimap.MapMode.Large &&
                                                                                          (Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyButtonB"))))
                    {
                        if (mode == (int)Minimap.MapMode.Large)
                        {
                            return;
                        }

                        if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.Large))
                        {
                            mode = (int)Minimap.MapMode.None;
                        }
                    }
                    else
                    {
                        if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.None))
                        {
                            mode = (int)Minimap.MapMode.None;
                        }
                    }
                }
            }

            orig(self, mode);
        }
Example #25
0
 public virtual void UpdateRecipe(InventoryGui instance, Player player, float dt, Image bgImage)
 {
 }
Example #26
0
 static void Prefix(InventoryGui __instance)
 {
     __instance.m_splitSlider.gameObject.AddComponent <SliderSelector>();
 }
Example #27
0
 public virtual void DoCrafting(InventoryGui instance, Player player)
 {
 }
Example #28
0
            static void Postfix(Hud __instance)
            {
                if (!modEnabled.Value || Player.m_localPlayer == null || InventoryGui.IsVisible() == true)
                {
                    return;
                }

                float gameScale = GameObject.Find("GUI").GetComponent <CanvasScaler>().scaleFactor;
                int   healthRot = 90 - (healthbarRotation.Value / 90 % 4 * 90);

                Vector3 mousePos = Input.mousePosition;

                if (!modEnabled.Value)
                {
                    lastMousePos = mousePos;
                    return;
                }

                Transform hudRoot = __instance.gameObject.transform.Find("hudroot");

                if (toolbarX.Value == 9999)
                {
                    toolbarX.Value = hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMin.x *Screen.width;
                }
                if (toolbarY.Value == 9999)
                {
                    toolbarY.Value = hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMax.y *Screen.height;
                }

                if (healthbarX.Value == 9999)
                {
                    healthbarX.Value = hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x;
                }
                if (healthbarY.Value == 9999)
                {
                    healthbarY.Value = hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y;
                }

                if (guardianX.Value == 9999)
                {
                    guardianX.Value = hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.x;
                }
                if (guardianY.Value == 9999)
                {
                    guardianY.Value = hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.y;
                }

                if (statusX.Value == 9999)
                {
                    statusX.Value = hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.x;
                }
                if (statusY.Value == 9999)
                {
                    statusY.Value = hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.y;
                }

                if (mapX.Value == 9999)
                {
                    mapX.Value = hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.x;
                }
                if (mapY.Value == 9999)
                {
                    mapY.Value = hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.y;
                }

                hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMax = new Vector2(hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMax.x, toolbarY.Value / Screen.height);
                hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMin = new Vector2(toolbarX.Value / Screen.width, hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMin.y);

                hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition = new Vector2(healthbarX.Value, healthbarY.Value);
                hudRoot.Find("healthpanel").GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, healthRot);
                hudRoot.Find("healthpanel").Find("Health").Find("fast").Find("bar").Find("HealthText").GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -healthRot);
                hudRoot.Find("healthpanel").Find("food0").GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -healthRot);
                hudRoot.Find("healthpanel").Find("food1").GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -healthRot);
                hudRoot.Find("healthpanel").Find("food2").GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, -healthRot);

                hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition = new Vector2(guardianX.Value, guardianY.Value);

                hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition = new Vector2(statusX.Value, statusY.Value);

                hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition = new Vector2(mapX.Value, mapY.Value);

                hudRoot.Find("healthpanel").GetComponent <RectTransform>().localScale           = new Vector3(healthbarScale.Value, healthbarScale.Value, 1);
                hudRoot.Find("GuardianPower").GetComponent <RectTransform>().localScale         = new Vector3(guardianScale.Value, guardianScale.Value, 1);
                hudRoot.Find("StatusEffects").GetComponent <RectTransform>().localScale         = new Vector3(statusScale.Value, statusScale.Value, 1);
                hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().localScale = new Vector3(mapScale.Value, mapScale.Value, 1);


                if (lastMousePos == Vector3.zero)
                {
                    lastMousePos = mousePos;
                }


                if (CheckKeyHeld(modKeyOne.Value) && CheckKeyHeld(modKeyTwo.Value))
                {
                    Rect hotkeyRect = new Rect(
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMin.x *Screen.width + hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchoredPosition.x *gameScale,
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMax.y *Screen.height + hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchoredPosition.y *gameScale - hudRoot.Find("HotKeyBar").GetComponent <HotkeyBar>().m_elementSpace *gameScale *toolbarItemScale.Value *(7 / toolbarItemsPerRow.Value + 1),
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().sizeDelta.x *gameScale *toolbarItemScale.Value *(toolbarItemsPerRow.Value / 8f),
                        hudRoot.Find("HotKeyBar").GetComponent <HotkeyBar>().m_elementSpace *gameScale *toolbarItemScale.Value *(7 / toolbarItemsPerRow.Value + 1)
                        );

                    Rect healthRect = Rect.zero;
                    switch (healthRot)
                    {
                    case 90:     // 0 - good
                        healthRect = new Rect(
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale,
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value
                            );
                        break;

                    case 0:     // 90 - good
                        healthRect = new Rect(
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale,
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value
                            );
                        break;

                    case -90:     // 180
                        healthRect = new Rect(
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value
                            );
                        break;

                    case -180:     // 270
                        healthRect = new Rect(
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                            (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                            hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value
                            );
                        break;
                    }

                    Rect guardianRect = new Rect(
                        (hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.x + hudRoot.Find("GuardianPower").GetComponent <RectTransform>().rect.x *guardianScale.Value) * gameScale,
                        (hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.y + hudRoot.Find("GuardianPower").GetComponent <RectTransform>().rect.y *guardianScale.Value) * gameScale,
                        hudRoot.Find("GuardianPower").GetComponent <RectTransform>().sizeDelta.x *gameScale *guardianScale.Value,
                        hudRoot.Find("GuardianPower").GetComponent <RectTransform>().sizeDelta.y *gameScale *guardianScale.Value
                        );
                    Rect statusRect = new Rect(
                        Screen.width + (hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.x + hudRoot.Find("StatusEffects").GetComponent <RectTransform>().rect.x *statusScale.Value) * gameScale,
                        Screen.height + (hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.y + hudRoot.Find("StatusEffects").GetComponent <RectTransform>().rect.y *statusScale.Value) * gameScale,
                        hudRoot.Find("StatusEffects").GetComponent <RectTransform>().sizeDelta.x *gameScale *statusScale.Value,
                        hudRoot.Find("StatusEffects").GetComponent <RectTransform>().sizeDelta.y *gameScale *statusScale.Value
                        );
                    Rect mapRect = new Rect(
                        (hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.x - hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.x *mapScale.Value) * gameScale + Screen.width,
                        (hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.y - hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.y *mapScale.Value) * gameScale + Screen.height,
                        hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.x *gameScale *mapScale.Value,
                        hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.y *gameScale *mapScale.Value
                        );

                    if (hotkeyRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "HotKeyBar"))
                    {
                        //Dbgl("in hotkeybar");
                        toolbarX.Value   += mousePos.x - lastMousePos.x;
                        toolbarY.Value   += mousePos.y - lastMousePos.y;
                        currentlyDragging = "HotKeyBar";
                    }
                    else if (healthRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "healthpanel"))
                    {
                        //Dbgl("in healthpanel");
                        healthbarX.Value += (mousePos.x - lastMousePos.x) / gameScale;
                        healthbarY.Value += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "healthpanel";
                    }
                    else if (guardianRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "GuardianPower"))
                    {
                        //Dbgl("in guardianPower");
                        guardianX.Value  += (mousePos.x - lastMousePos.x) / gameScale;
                        guardianY.Value  += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "GuardianPower";
                    }
                    else if (mapRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "MiniMap"))
                    {
                        //Dbgl("in MiniMap");
                        mapX.Value       += (mousePos.x - lastMousePos.x) / gameScale;
                        mapY.Value       += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "MiniMap";
                    }
                    else if (statusRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "StatusEffects"))
                    {
                        //Dbgl("in StatusEffects");
                        statusX.Value    += (mousePos.x - lastMousePos.x) / gameScale;
                        statusY.Value    += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "StatusEffects";
                    }
                    else
                    {
                        //Dbgl($"mouse {mousePos}, hotkey rect {hotkeyRect}, health rect {healthRect}, guardian rect {guardianRect}, map rect {mapRect}");
                        //Dbgl($"mouse {mousePos} health rect {healthRect}, status rect {statusRect}");
                        currentlyDragging = "";
                    }
                }
                else
                {
                    currentlyDragging = "";
                }

                lastMousePos = mousePos;
            }
Example #29
0
 public static bool IgnoreKeyPresses(bool extra = false)
 {
     if (!extra)
     {
         return(ZNetScene.instance == null || Player.m_localPlayer == null || Minimap.IsOpen() || Console.IsVisible() || TextInput.IsVisible() || ZNet.instance.InPasswordDialog() || Chat.instance?.HasFocus() == true);
     }
     return(ZNetScene.instance == null || Player.m_localPlayer == null || Minimap.IsOpen() || Console.IsVisible() || TextInput.IsVisible() || ZNet.instance.InPasswordDialog() || Chat.instance?.HasFocus() == true || StoreGui.IsVisible() || InventoryGui.IsVisible() || Menu.IsVisible() || TextViewer.instance || TextViewer.instance.IsVisible());
 }
Example #30
0
 public static bool Prefix(InventoryGui __instance)
 {
     return(__instance.m_activeGroup == __instance.m_uiGroups.Length - 1);
 }