Exemple #1
0
        private static void CommonSetupTasks(UXFactory uxFactory, int credits, int materials, int contraband, int crystals, int eventPoints, bool locked, string lockedText, string costGroupStr, string creditName, string materialName, string contrabandName, string crystalName, string eventPointsName, string reputationName, string costElementStr, int clampWidth)
        {
            if (uxFactory == null)
            {
                return;
            }
            UXElement element = uxFactory.GetElement <UXElement>(costGroupStr);
            bool      flag    = credits != 0 || materials != 0 || contraband != 0 || crystals != 0 || eventPoints != 0 || !string.IsNullOrEmpty(lockedText);

            element.Visible = flag;
            if (flag)
            {
                UXSprite optionalElement  = uxFactory.GetOptionalElement <UXSprite>(creditName);
                UXSprite optionalElement2 = uxFactory.GetOptionalElement <UXSprite>(materialName);
                UXSprite optionalElement3 = uxFactory.GetOptionalElement <UXSprite>(contrabandName);
                UXSprite optionalElement4 = uxFactory.GetOptionalElement <UXSprite>(crystalName);
                UXSprite optionalElement5 = uxFactory.GetOptionalElement <UXSprite>(eventPointsName);
                UXSprite optionalElement6 = uxFactory.GetOptionalElement <UXSprite>(reputationName);
                UXUtils.HideIcon(optionalElement6);
                UXSprite icon = null;
                int      associatedIconWidth = 0;
                if (!uxFactory.HasElement <UXLabel>(costElementStr))
                {
                    Service.Logger.Error("UXFactory missing needed label: " + costElementStr);
                    return;
                }
                UXLabel element2 = uxFactory.GetElement <UXLabel>(costElementStr);
                element2.Root.GetComponent <UILabel>().overflowMethod = UILabel.Overflow.ResizeFreely;
                Lang lang = Service.Lang;
                if (credits != 0)
                {
                    if (optionalElement != null)
                    {
                        associatedIconWidth = optionalElement.GetUIWidget.width;
                        UXUtils.ShowIcon(optionalElement);
                        icon = optionalElement;
                    }
                    UXUtils.HideIcon(optionalElement2);
                    UXUtils.HideIcon(optionalElement3);
                    UXUtils.HideIcon(optionalElement4);
                    UXUtils.HideIcon(optionalElement5);
                    element2.Text = lang.ThousandsSeparated(credits);
                }
                else if (materials != 0)
                {
                    if (optionalElement2 != null)
                    {
                        associatedIconWidth = optionalElement2.GetUIWidget.width;
                        UXUtils.ShowIcon(optionalElement2);
                        icon = optionalElement2;
                    }
                    UXUtils.HideIcon(optionalElement);
                    UXUtils.HideIcon(optionalElement3);
                    UXUtils.HideIcon(optionalElement4);
                    UXUtils.HideIcon(optionalElement5);
                    element2.Text = lang.ThousandsSeparated(materials);
                }
                else if (contraband != 0)
                {
                    if (optionalElement3 != null)
                    {
                        associatedIconWidth = optionalElement3.GetUIWidget.width;
                        UXUtils.ShowIcon(optionalElement3);
                        icon = optionalElement3;
                    }
                    UXUtils.HideIcon(optionalElement);
                    UXUtils.HideIcon(optionalElement2);
                    UXUtils.HideIcon(optionalElement4);
                    UXUtils.HideIcon(optionalElement5);
                    element2.Text = lang.ThousandsSeparated(contraband);
                }
                else if (crystals != 0)
                {
                    if (optionalElement4 != null)
                    {
                        associatedIconWidth = optionalElement4.GetUIWidget.width;
                        UXUtils.ShowIcon(optionalElement4);
                        icon = optionalElement4;
                    }
                    UXUtils.HideIcon(optionalElement);
                    UXUtils.HideIcon(optionalElement2);
                    UXUtils.HideIcon(optionalElement3);
                    UXUtils.HideIcon(optionalElement5);
                    element2.Text = lang.ThousandsSeparated(crystals);
                }
                else if (eventPoints != 0)
                {
                    if (optionalElement5 != null)
                    {
                        associatedIconWidth = optionalElement5.GetUIWidget.width;
                        UXUtils.ShowIcon(optionalElement5);
                        icon = optionalElement5;
                    }
                    UXUtils.HideIcon(optionalElement);
                    UXUtils.HideIcon(optionalElement2);
                    UXUtils.HideIcon(optionalElement3);
                    UXUtils.HideIcon(optionalElement4);
                    element2.Text = lang.ThousandsSeparated(eventPoints);
                }
                else
                {
                    Vector3 localPosition = element2.LocalPosition;
                    UXUtils.HideIconMinX(optionalElement, ref localPosition);
                    UXUtils.HideIconMinX(optionalElement2, ref localPosition);
                    UXUtils.HideIconMinX(optionalElement3, ref localPosition);
                    UXUtils.HideIconMinX(optionalElement4, ref localPosition);
                    UXUtils.HideIconMinX(optionalElement5, ref localPosition);
                    element2.Text          = lockedText;
                    element2.TextColor     = UXUtils.GetCostColor(element2, false, true);
                    element2.LocalPosition = localPosition;
                }
                UXUtils.UpdateCostColor(element2, icon, credits, materials, contraband, crystals, eventPoints, locked);
                UXUtils.ClampUILabelWidth(element2, clampWidth, associatedIconWidth);
                UXUtils.CostGroupSetup(element);
            }
        }