Example #1
0
    // Token: 0x060004F7 RID: 1271 RVA: 0x00029510 File Offset: 0x00027710
    private void Awake()
    {
        Hud.m_instance = this;
        this.m_pieceSelectionWindow.SetActive(false);
        this.m_loadingScreen.gameObject.SetActive(false);
        this.m_statusEffectTemplate.gameObject.SetActive(false);
        this.m_eventBar.SetActive(false);
        this.m_gpRoot.gameObject.SetActive(false);
        this.m_betaText.SetActive(false);
        UIInputHandler closePieceSelectionButton = this.m_closePieceSelectionButton;

        closePieceSelectionButton.m_onLeftClick = (Action <UIInputHandler>)Delegate.Combine(closePieceSelectionButton.m_onLeftClick, new Action <UIInputHandler>(this.OnClosePieceSelection));
        UIInputHandler closePieceSelectionButton2 = this.m_closePieceSelectionButton;

        closePieceSelectionButton2.m_onRightClick = (Action <UIInputHandler>)Delegate.Combine(closePieceSelectionButton2.m_onRightClick, new Action <UIInputHandler>(this.OnClosePieceSelection));
        if (SteamManager.APP_ID == 1223920U)
        {
            this.m_betaText.SetActive(true);
        }
        foreach (GameObject gameObject in this.m_pieceCategoryTabs)
        {
            this.m_buildCategoryNames.Add(gameObject.transform.Find("Text").GetComponent <Text>().text);
            UIInputHandler component = gameObject.GetComponent <UIInputHandler>();
            component.m_onLeftDown = (Action <UIInputHandler>)Delegate.Combine(component.m_onLeftDown, new Action <UIInputHandler>(this.OnLeftClickCategory));
        }
    }
Example #2
0
        private static void RepairClickedItem(InventoryGrid grid, UIInputHandler element, Inventory inventory)
        {
            Vector2i buttonPos = Traverse.Create(grid).Method("GetButtonPos", new object[] { element.gameObject }).GetValue <Vector2i>();

            ItemDrop.ItemData itemData = inventory.GetItemAt(buttonPos.x, buttonPos.y);

            if (itemData == null)
            {
                return;
            }

            if (Traverse.Create(InventoryGui.instance).Method("CanRepair", new object[] { itemData }).GetValue <bool>())
            {
                CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
                itemData.m_durability = itemData.GetMaxDurability();
                if (currentCraftingStation)
                {
                    currentCraftingStation.m_repairItemDoneEffects.Create(currentCraftingStation.transform.position, Quaternion.identity, null, 1f);
                }
                Player.m_localPlayer.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_repaired", new string[]
                {
                    itemData.m_shared.m_name
                }), 0, null);
            }
        }
Example #3
0
        private static bool Minimap_OnMapMiddleClick(UIInputHandler handler, Minimap __instance, float ___m_removeRadius, float ___m_largeZoom)
        {
            Vector3 pos = ScreenToWorldPoint(__instance, Input.mousePosition);

            if (Settings.ShareIndividualPin.Value)
            {
                if (Settings.ShareIndividualPinRequireKey.Value)
                {
                    bool validKey = Enum.TryParse(Settings.ShareIndividualPinKey.Value, out KeyCode key);
                    if (!validKey || !Input.GetKey(key))
                    {
                        return(true);
                    }
                }

                Minimap.PinData closestPin = GetClosestPin(__instance, pos, ___m_removeRadius * (___m_largeZoom * 2f));
                if (closestPin != null)
                {
                    Plugin.SendPin(closestPin, closestPin.m_name);

                    Plugin.AddString($"Shared {closestPin.m_name}");
                    return(Settings.ShowPingWhenSharingIndividualPin.Value);
                }
            }

            return(true);
        }
Example #4
0
 // Token: 0x0600050D RID: 1293 RVA: 0x0002A82B File Offset: 0x00028A2B
 private void OnRightClickPiece(UIInputHandler ih)
 {
     if (this.IsQuickPieceSelectEnabled())
     {
         this.SelectPiece(ih);
         Hud.HidePieceSelection();
     }
 }
Example #5
0
 static bool Prefix(InventoryGrid __instance, UIInputHandler element, Inventory ___m_inventory)
 {
     if (modEnabled.Value && AedenthornUtils.CheckKeyHeld(modKey.Value) && !leftClick.Value && InventoryGui.instance)
     {
         RepairClickedItem(__instance, element, ___m_inventory);
         return(false);
     }
     return(true);
 }
Example #6
0
 private void Start()
 {
     uiInputHandler = FindObjectOfType <UIInputHandler>();
     uiInputHandler.OnScrollUp.AddListener(OnUp);
     uiInputHandler.OnScrollDown.AddListener(OnDown);
     uiInputHandler.OnScrollLeft.AddListener(OnLeft);
     uiInputHandler.OnScrollRight.AddListener(OnRight);
     uiInputHandler.OnSelectOption.AddListener(OnSelect);
 }
Example #7
0
    // Token: 0x0600050E RID: 1294 RVA: 0x0002A844 File Offset: 0x00028A44
    private void OnHoverPiece(UIInputHandler ih)
    {
        Vector2Int selectedGrid = this.GetSelectedGrid(ih);

        if (selectedGrid.x != -1)
        {
            this.m_hoveredPiece = Player.m_localPlayer.GetPiece(selectedGrid);
        }
    }
Example #8
0
    // Token: 0x06000512 RID: 1298 RVA: 0x0002A8F0 File Offset: 0x00028AF0
    private void SelectPiece(UIInputHandler ih)
    {
        Vector2Int selectedGrid = this.GetSelectedGrid(ih);

        if (selectedGrid.x != -1)
        {
            Player.m_localPlayer.SetSelectedPiece(selectedGrid);
            this.m_selectItemEffect.Create(base.transform.position, Quaternion.identity, null, 1f);
        }
    }
Example #9
0
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this);
            return;
        }

        Instance = this;
    }
Example #10
0
    private void Start()
    {
        InputActionMap UIActionMap    = UIAsset.FindActionMap(inputUIMapName);
        UIInputHandler uIInputHandler = new UIInputHandler(UIActionMap);

        InputActionMap         PlayerMovementMap          = PlayerAsset.FindActionMap(inputPlayerMovementMapName);
        TestPlayerInputManager playerMovementInputHandler = new TestPlayerInputManager(PlayerMovementMap);

        defaultMovement = new DefaultMovement(rigidbodyToMove);
    }
Example #11
0
            private static IEnumerable <GameObject> CreateItemTiles(GameObject elementPrefab, RectTransform itemListRoot, float tileWidth, float tileBaseSize)
            {
                var itemTiles = new List <GameObject>();

                if (Player.m_localPlayer == null)
                {
                    return(itemTiles);
                }
                float num         = 0f;
                int   columnCount = 0;
                int   rowCount    = 0;
                int   xMargin     = 0;
                int   yMargin     = -10;

                foreach (var component in GetFilteredItemList().OrderBy(i => i.m_itemData.m_shared.m_itemType))
                {
                    GameObject gameObject = Instantiate(elementPrefab, itemListRoot);

                    gameObject.SetActive(value: true);
                    RectTransform rectTransform = gameObject.transform as RectTransform;
                    rectTransform.anchoredPosition = new Vector2(columnCount == 0 ? xMargin : (float)columnCount * tileWidth, rowCount == 0 ? yMargin : (float)rowCount * (0f - tileWidth));
                    num = Mathf.Min(num, rectTransform.anchoredPosition.y - tileWidth);
                    string text2 = Localization.instance.Localize(component.m_itemData.m_shared.m_name);
                    if (text2.EndsWith(" trophy"))
                    {
                        text2 = text2.Remove(text2.Length - 7);
                    }
                    rectTransform.Find("icon_bkg/icon").GetComponent <Image>().sprite = component.m_itemData.GetIcon();
                    rectTransform.Find("name").GetComponent <Text>().text             = text2;
                    rectTransform.Find("description").GetComponent <Text>().text      = GetLootStateString(component);

                    gameObject.AddComponent <UIInputHandler>();
                    UIInputHandler componentInChildren = gameObject.GetComponent <UIInputHandler>();
                    componentInChildren.m_onLeftDown = (Action <UIInputHandler>)Delegate.Combine(componentInChildren.m_onLeftDown, new Action <UIInputHandler>((handler) =>
                    {
                        component.m_autoPickup = !component.m_autoPickup;
                        rectTransform.Find("description").GetComponent <Text>().text = GetLootStateString(component);
                    }));

                    itemTiles.Add(gameObject);
                    //Debug.Log($"Added item:{component.name} at {rectTransform.anchoredPosition.x}, {rectTransform.anchoredPosition.y}");
                    columnCount++;
                    if ((columnCount + 1) * tileWidth > itemListRoot.rect.width)
                    {
                        columnCount = 0;
                        rowCount++;
                    }
                }

                float size = Mathf.Max(tileBaseSize, 0f - num);

                itemListRoot.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size);

                return(itemTiles);
            }
Example #12
0
    // Token: 0x0600052F RID: 1327 RVA: 0x0002BE94 File Offset: 0x0002A094
    private void OnRightClick(UIInputHandler element)
    {
        GameObject gameObject = element.gameObject;
        Vector2i   buttonPos  = this.GetButtonPos(gameObject);

        ItemDrop.ItemData itemAt = this.m_inventory.GetItemAt(buttonPos.x, buttonPos.y);
        if (this.m_onRightClick != null)
        {
            this.m_onRightClick(this, itemAt, buttonPos);
        }
    }
Example #13
0
 // Token: 0x0600050B RID: 1291 RVA: 0x0002A7DC File Offset: 0x000289DC
 private void OnLeftClickCategory(UIInputHandler ih)
 {
     for (int i = 0; i < this.m_pieceCategoryTabs.Length; i++)
     {
         if (this.m_pieceCategoryTabs[i] == ih.gameObject)
         {
             Player.m_localPlayer.SetBuildCategory(i);
             return;
         }
     }
 }
Example #14
0
 static bool Prefix(Minimap __instance, UIInputHandler handler)
 {
     if (isTPmode)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        private void Start()
        {
            currentRow    = 0;
            currentColumn = 0;

            UIInputHandler uiInputHandler = UIInputHandler.Instance;

            uiInputHandler.OnScrollLeft.AddListener(OnLeft);
            uiInputHandler.OnScrollRight.AddListener(OnRight);
            uiInputHandler.OnScrollUp.AddListener(OnUp);
            uiInputHandler.OnScrollDown.AddListener(OnDown);
            uiInputHandler.OnSelectOption.AddListener(OnSelect);

            HighlightCurrentElement();
        }
Example #16
0
        private void CreateCategoryTabs()
        {
            // Only touch categories when new ones were added
            if (!PieceCategories.Any())
            {
                return;
            }

            // Get the GUI elements
            GameObject root = Hud.instance.m_pieceCategoryRoot;

            if (root.GetComponent <RectMask2D>() == null)
            {
                root.AddComponent <RectMask2D>();
                root.SetWidth(PieceCategorySize);

                Transform border = root.transform.Find("TabBorder");
                border?.SetParent(root.transform.parent, true);
            }

            List <string>     newNames = new List <string>(Hud.instance.m_buildCategoryNames);
            List <GameObject> newTabs  = new List <GameObject>(Hud.instance.m_pieceCategoryTabs);

            // Append tabs and their names to the GUI for every custom category not already added
            foreach (var category in PieceCategories)
            {
                if (!newNames.Contains(category.Key))
                {
                    GameObject newTab = Object.Instantiate(Hud.instance.m_pieceCategoryTabs[0], root.transform);
                    newTab.name = category.Key;
                    UIInputHandler handler = newTab.GetOrAddComponent <UIInputHandler>();
                    handler.m_onLeftDown += Hud.instance.OnLeftClickCategory;

                    char[] forbiddenCharsArray = LocalizationManager.ForbiddenChars.ToCharArray();
                    string tokenCategory       = string.Concat(category.Key.ToLower().Split(forbiddenCharsArray));
                    string tokenName           = $"jotunn_cat_{tokenCategory}";
                    LocalizationManager.Instance.JotunnLocalization.AddTranslation(tokenName, category.Key);

                    newNames.Add(LocalizationManager.Instance.TryTranslate(tokenName));
                    newTabs.Add(newTab);
                }
            }

            // Replace the HUD arrays
            Hud.instance.m_buildCategoryNames = newNames.ToList();
            Hud.instance.m_pieceCategoryTabs  = newTabs.ToArray();
        }
Example #17
0
    // Token: 0x06000511 RID: 1297 RVA: 0x0002A890 File Offset: 0x00028A90
    private Vector2Int GetSelectedGrid(UIInputHandler ih)
    {
        int num  = 10;
        int num2 = 5;

        for (int i = 0; i < num2; i++)
        {
            for (int j = 0; j < num; j++)
            {
                int index = i * num + j;
                if (this.m_pieceIcons[index].m_go == ih.gameObject)
                {
                    return(new Vector2Int(j, i));
                }
            }
        }
        return(new Vector2Int(-1, -1));
    }
Example #18
0
    // Token: 0x06000530 RID: 1328 RVA: 0x0002BEE0 File Offset: 0x0002A0E0
    private void OnLeftClick(UIInputHandler clickHandler)
    {
        GameObject gameObject = clickHandler.gameObject;
        Vector2i   buttonPos  = this.GetButtonPos(gameObject);

        ItemDrop.ItemData      itemAt = this.m_inventory.GetItemAt(buttonPos.x, buttonPos.y);
        InventoryGrid.Modifier arg    = InventoryGrid.Modifier.Select;
        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            arg = InventoryGrid.Modifier.Split;
        }
        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
        {
            arg = InventoryGrid.Modifier.Move;
        }
        if (this.m_onSelected != null)
        {
            this.m_onSelected(this, itemAt, buttonPos, arg);
        }
    }
        static bool Prefix(InventoryGrid __instance, UIInputHandler clickHandler)
        {
            GameObject gameObject = clickHandler.gameObject;
            Vector2i   buttonPos  = InventoryGridStubs.GetButtonPos(__instance, gameObject);

            ItemDrop.ItemData itemAt = m_inventoryRef(__instance).GetItemAt(buttonPos.x, buttonPos.y);

            if (!Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt))
            {
                return(true);
            }

            if (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
            {
                return(true);
            }

            m_inventoryRef(__instance).RemoveItem(itemAt);
            return(false);
        }
            public static bool Prefix(ref Hud __instance, ref Player player, ref Vector2Int selectedNr,
                                      ref Piece.PieceCategory category, ref bool updateAllBuildStatuses)
            {
                if (BuildExpansionMod.isEnabled.Value)
                {
                    List <Piece> buildPieces = player.GetBuildPieces();
                    int          columns     = BuildExpansionMod.newGridWidth.Value;
                    calculatedRows = (buildPieces.Count / columns) + 1;
                    if (buildPieces.Count <= 1)
                    {
                        calculatedRows = 1;
                        columns        = 1;
                    }
                    category = (Piece.PieceCategory) 5;
                    if (needRefresh || __instance.m_pieceIcons.Count(x => x.m_go.activeSelf) != buildPieces.Count)
                    {
                        BuildExpansionMod.buildFilterLogger.LogDebug($"\npieceIcons: {__instance.m_pieceIcons.Count(x => x.m_go.activeSelf)}\nBuild pieces: {buildPieces.Count}");
                        BuildExpansionMod.buildFilterLogger.LogDebug($"\nRows: {calculatedRows}\nColumns: {columns}");
                        __instance.m_pieceListRoot.sizeDelta = new Vector2((int)(__instance.m_pieceIconSpacing * BuildExpansionMod.newGridWidth.Value), (int)(__instance.m_pieceIconSpacing * calculatedRows) + 16);
                        foreach (Hud.PieceIconData pieceIconData in __instance.m_pieceIcons)
                        {
                            UnityEngine.Object.Destroy(pieceIconData.m_go);
                        }
                        __instance.m_pieceIcons.Clear();
                        for (int yaxis = 0; yaxis < calculatedRows; yaxis++)
                        {
                            for (int xaxis = 0; xaxis < columns; xaxis++)
                            {
                                int index = yaxis * columns + xaxis;

                                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(__instance.m_pieceIconPrefab, __instance.m_pieceListRoot);
                                (gameObject.transform as RectTransform).anchorMin        = new Vector2(0, 1);
                                (gameObject.transform as RectTransform).anchorMax        = new Vector2(0, 1);
                                (gameObject.transform as RectTransform).pivot            = new Vector2(0, 1);
                                (gameObject.transform as RectTransform).anchoredPosition = Vector2.zero;
                                (gameObject.transform as RectTransform).localPosition    = new Vector2(xaxis * __instance.m_pieceIconSpacing, -16 + (-yaxis) * __instance.m_pieceIconSpacing);
                                Hud.PieceIconData templatePieceData = new Hud.PieceIconData();
                                templatePieceData.m_go         = gameObject;
                                templatePieceData.m_tooltip    = gameObject.GetComponent <UITooltip>();
                                templatePieceData.m_icon       = gameObject.transform.Find("icon").GetComponent <Image>();
                                templatePieceData.m_marker     = gameObject.transform.Find("selected").gameObject;
                                templatePieceData.m_upgrade    = gameObject.transform.Find("upgrade").gameObject;
                                templatePieceData.m_icon.color = new Color(1f, 0f, 1f, 0f);
                                UIInputHandler templateHandler = gameObject.GetComponent <UIInputHandler>();
                                templateHandler.m_onLeftDown = (Action <UIInputHandler>)Delegate.Combine(
                                    templateHandler.m_onLeftDown, new Action <UIInputHandler>(__instance.OnLeftClickPiece));
                                templateHandler.m_onRightDown = (Action <UIInputHandler>)Delegate.Combine(
                                    templateHandler.m_onRightDown, new Action <UIInputHandler>(__instance.OnRightClickPiece));
                                templateHandler.m_onPointerEnter = (Action <UIInputHandler>)Delegate.Combine(
                                    templateHandler.m_onPointerEnter, new Action <UIInputHandler>(__instance.OnHoverPiece));
                                templateHandler.m_onPointerExit = (Action <UIInputHandler>)Delegate.Combine(
                                    templateHandler.m_onPointerExit, new Action <UIInputHandler>(__instance.OnHoverPieceExit));
                                templatePieceData.m_marker.SetActive(new Vector2Int(xaxis, yaxis) == selectedNr);
                                if (index < buildPieces.Count)
                                {
                                    Piece piece = buildPieces[index];
                                    templatePieceData.m_icon.sprite    = piece.m_icon;
                                    templatePieceData.m_icon.enabled   = true;
                                    templatePieceData.m_tooltip.m_text = piece.m_name;
                                    templatePieceData.m_upgrade.SetActive(piece.m_isUpgrade);
                                    templatePieceData.m_go.SetActive(true);
                                }
                                else
                                {
                                    templatePieceData.m_icon.enabled   = false;
                                    templatePieceData.m_tooltip.m_text = "";
                                    templatePieceData.m_upgrade.SetActive(false);
                                    templatePieceData.m_go.SetActive(false);
                                }
                                BuildExpansionMod.buildFilterLogger.LogDebug($"\nPiece name: {templatePieceData.m_tooltip.m_text}" +
                                                                             $"\nPiece icon: {templatePieceData.m_icon.enabled}" +
                                                                             $"\nPiece index: {index}" +
                                                                             $"\nPiece x: {xaxis}" +
                                                                             $"\nPiece y: {yaxis}");
                                __instance.m_pieceIcons.Add(templatePieceData);
                            }
                        }
                        if (needRefresh)
                        {
                            needRefresh = false;
                        }
                    }
                    for (int yaxis = 0; yaxis < calculatedRows; yaxis++)
                    {
                        for (int xaxis = 0; xaxis < columns; xaxis++)
                        {
                            int index = yaxis * columns + xaxis;
                            __instance.m_pieceIcons[index].m_marker.SetActive(new Vector2Int(xaxis, yaxis) == selectedNr);
                        }
                    }
                    __instance.UpdatePieceBuildStatus(buildPieces, player);
                    if (updateAllBuildStatuses)
                    {
                        __instance.UpdatePieceBuildStatusAll(buildPieces, player);
                    }
                    if (__instance.m_lastPieceCategory != category)
                    {
                        __instance.m_lastPieceCategory = category;
                        __instance.m_pieceBarPosX      = __instance.m_pieceBarTargetPosX;
                        __instance.UpdatePieceBuildStatusAll(buildPieces, player);
                    }
                    return(false);
                }
                return(true);
            }
Example #21
0
    // Token: 0x0600052C RID: 1324 RVA: 0x0002B704 File Offset: 0x00029904
    private void UpdateGui(Player player, ItemDrop.ItemData dragItem)
    {
        RectTransform rectTransform = base.transform as RectTransform;
        int           width         = this.m_inventory.GetWidth();
        int           height        = this.m_inventory.GetHeight();

        if (this.m_selected.x >= width - 1)
        {
            this.m_selected.x = width - 1;
        }
        if (this.m_selected.y >= height - 1)
        {
            this.m_selected.y = height - 1;
        }
        if (this.m_width != width || this.m_height != height)
        {
            this.m_width  = width;
            this.m_height = height;
            foreach (InventoryGrid.Element element in this.m_elements)
            {
                UnityEngine.Object.Destroy(element.m_go);
            }
            this.m_elements.Clear();
            Vector2 widgetSize = this.GetWidgetSize();
            Vector2 a          = new Vector2(rectTransform.rect.width / 2f, 0f) - new Vector2(widgetSize.x, 0f) * 0.5f;
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Vector2    b          = new Vector3((float)j * this.m_elementSpace, (float)i * -this.m_elementSpace);
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_elementPrefab, this.m_gridRoot);
                    (gameObject.transform as RectTransform).anchoredPosition = a + b;
                    UIInputHandler componentInChildren = gameObject.GetComponentInChildren <UIInputHandler>();
                    componentInChildren.m_onRightDown = (Action <UIInputHandler>)Delegate.Combine(componentInChildren.m_onRightDown, new Action <UIInputHandler>(this.OnRightClick));
                    componentInChildren.m_onLeftDown  = (Action <UIInputHandler>)Delegate.Combine(componentInChildren.m_onLeftDown, new Action <UIInputHandler>(this.OnLeftClick));
                    Text component = gameObject.transform.Find("binding").GetComponent <Text>();
                    if (player && i == 0)
                    {
                        component.text = (j + 1).ToString();
                    }
                    else
                    {
                        component.enabled = false;
                    }
                    InventoryGrid.Element element2 = new InventoryGrid.Element();
                    element2.m_pos        = new Vector2i(j, i);
                    element2.m_go         = gameObject;
                    element2.m_icon       = gameObject.transform.Find("icon").GetComponent <Image>();
                    element2.m_amount     = gameObject.transform.Find("amount").GetComponent <Text>();
                    element2.m_quality    = gameObject.transform.Find("quality").GetComponent <Text>();
                    element2.m_equiped    = gameObject.transform.Find("equiped").GetComponent <Image>();
                    element2.m_queued     = gameObject.transform.Find("queued").GetComponent <Image>();
                    element2.m_noteleport = gameObject.transform.Find("noteleport").GetComponent <Image>();
                    element2.m_selected   = gameObject.transform.Find("selected").gameObject;
                    element2.m_tooltip    = gameObject.GetComponent <UITooltip>();
                    element2.m_durability = gameObject.transform.Find("durability").GetComponent <GuiBar>();
                    this.m_elements.Add(element2);
                }
            }
        }
        foreach (InventoryGrid.Element element3 in this.m_elements)
        {
            element3.m_used = false;
        }
        bool flag = this.m_uiGroup.IsActive() && ZInput.IsGamepadActive();

        foreach (ItemDrop.ItemData itemData in this.m_inventory.GetAllItems())
        {
            InventoryGrid.Element element4 = this.GetElement(itemData.m_gridPos.x, itemData.m_gridPos.y, width);
            element4.m_used         = true;
            element4.m_icon.enabled = true;
            element4.m_icon.sprite  = itemData.GetIcon();
            element4.m_icon.color   = ((itemData == dragItem) ? Color.grey : Color.white);
            element4.m_durability.gameObject.SetActive(itemData.m_shared.m_useDurability);
            if (itemData.m_shared.m_useDurability)
            {
                if (itemData.m_durability <= 0f)
                {
                    element4.m_durability.SetValue(1f);
                    element4.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                }
                else
                {
                    element4.m_durability.SetValue(itemData.GetDurabilityPercentage());
                    element4.m_durability.ResetColor();
                }
            }
            element4.m_equiped.enabled    = (player && itemData.m_equiped);
            element4.m_queued.enabled     = (player && player.IsItemQueued(itemData));
            element4.m_noteleport.enabled = !itemData.m_shared.m_teleportable;
            if (dragItem == null)
            {
                this.CreateItemTooltip(itemData, element4.m_tooltip);
            }
            element4.m_quality.enabled = (itemData.m_shared.m_maxQuality > 1);
            if (itemData.m_shared.m_maxQuality > 1)
            {
                element4.m_quality.text = itemData.m_quality.ToString();
            }
            element4.m_amount.enabled = (itemData.m_shared.m_maxStackSize > 1);
            if (itemData.m_shared.m_maxStackSize > 1)
            {
                element4.m_amount.text = itemData.m_stack.ToString() + "/" + itemData.m_shared.m_maxStackSize.ToString();
            }
        }
        foreach (InventoryGrid.Element element5 in this.m_elements)
        {
            element5.m_selected.SetActive(flag && element5.m_pos == this.m_selected);
            if (!element5.m_used)
            {
                element5.m_durability.gameObject.SetActive(false);
                element5.m_icon.enabled       = false;
                element5.m_amount.enabled     = false;
                element5.m_quality.enabled    = false;
                element5.m_equiped.enabled    = false;
                element5.m_queued.enabled     = false;
                element5.m_noteleport.enabled = false;
                element5.m_tooltip.m_text     = "";
                element5.m_tooltip.m_topic    = "";
            }
        }
        float size = (float)height * this.m_elementSpace;

        this.m_gridRoot.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size);
    }
Example #22
0
 // Token: 0x0600050F RID: 1295 RVA: 0x0002A874 File Offset: 0x00028A74
 private void OnHoverPieceExit(UIInputHandler ih)
 {
     this.m_hoveredPiece = null;
 }
Example #23
0
 // Token: 0x0600050C RID: 1292 RVA: 0x0002A81D File Offset: 0x00028A1D
 private void OnLeftClickPiece(UIInputHandler ih)
 {
     this.SelectPiece(ih);
     Hud.HidePieceSelection();
 }
Example #24
0
 // Token: 0x06000517 RID: 1303 RVA: 0x0002AB27 File Offset: 0x00028D27
 private void OnClosePieceSelection(UIInputHandler ih)
 {
     Hud.HidePieceSelection();
 }
Example #25
0
    // Token: 0x0600050A RID: 1290 RVA: 0x0002A490 File Offset: 0x00028690
    private void UpdatePieceList(Player player, Vector2Int selectedNr, Piece.PieceCategory category, bool updateAllBuildStatuses)
    {
        List <Piece> buildPieces = player.GetBuildPieces();
        int          num         = 10;
        int          num2        = 5;

        if (buildPieces.Count <= 1)
        {
            num  = 1;
            num2 = 1;
        }
        if (this.m_pieceIcons.Count != num * num2)
        {
            foreach (Hud.PieceIconData pieceIconData in this.m_pieceIcons)
            {
                UnityEngine.Object.Destroy(pieceIconData.m_go);
            }
            this.m_pieceIcons.Clear();
            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_pieceIconPrefab, this.m_pieceListRoot);
                    (gameObject.transform as RectTransform).anchoredPosition = new Vector2((float)j * this.m_pieceIconSpacing, (float)(-(float)i) * this.m_pieceIconSpacing);
                    Hud.PieceIconData pieceIconData2 = new Hud.PieceIconData();
                    pieceIconData2.m_go         = gameObject;
                    pieceIconData2.m_tooltip    = gameObject.GetComponent <UITooltip>();
                    pieceIconData2.m_icon       = gameObject.transform.Find("icon").GetComponent <Image>();
                    pieceIconData2.m_marker     = gameObject.transform.Find("selected").gameObject;
                    pieceIconData2.m_upgrade    = gameObject.transform.Find("upgrade").gameObject;
                    pieceIconData2.m_icon.color = new Color(1f, 0f, 1f, 0f);
                    UIInputHandler component = gameObject.GetComponent <UIInputHandler>();
                    component.m_onLeftDown     = (Action <UIInputHandler>)Delegate.Combine(component.m_onLeftDown, new Action <UIInputHandler>(this.OnLeftClickPiece));
                    component.m_onRightDown    = (Action <UIInputHandler>)Delegate.Combine(component.m_onRightDown, new Action <UIInputHandler>(this.OnRightClickPiece));
                    component.m_onPointerEnter = (Action <UIInputHandler>)Delegate.Combine(component.m_onPointerEnter, new Action <UIInputHandler>(this.OnHoverPiece));
                    component.m_onPointerExit  = (Action <UIInputHandler>)Delegate.Combine(component.m_onPointerExit, new Action <UIInputHandler>(this.OnHoverPieceExit));
                    this.m_pieceIcons.Add(pieceIconData2);
                }
            }
        }
        for (int k = 0; k < num2; k++)
        {
            for (int l = 0; l < num; l++)
            {
                int num3 = k * num + l;
                Hud.PieceIconData pieceIconData3 = this.m_pieceIcons[num3];
                pieceIconData3.m_marker.SetActive(new Vector2Int(l, k) == selectedNr);
                if (num3 < buildPieces.Count)
                {
                    Piece piece = buildPieces[num3];
                    pieceIconData3.m_icon.sprite    = piece.m_icon;
                    pieceIconData3.m_icon.enabled   = true;
                    pieceIconData3.m_tooltip.m_text = piece.m_name;
                    pieceIconData3.m_upgrade.SetActive(piece.m_isUpgrade);
                }
                else
                {
                    pieceIconData3.m_icon.enabled   = false;
                    pieceIconData3.m_tooltip.m_text = "";
                    pieceIconData3.m_upgrade.SetActive(false);
                }
            }
        }
        this.UpdatePieceBuildStatus(buildPieces, player);
        if (updateAllBuildStatuses)
        {
            this.UpdatePieceBuildStatusAll(buildPieces, player);
        }
        if (this.m_lastPieceCategory != category)
        {
            this.m_lastPieceCategory = category;
            this.m_pieceBarPosX      = this.m_pieceBarTargetPosX;
            this.UpdatePieceBuildStatusAll(buildPieces, player);
        }
    }