Example #1
0
    public void RefreshContent(City city, CityOptionsPanel.ProductionConstruction constructibleElementDefinition, int index, GameObject client)
    {
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        UnitDesign unitDesign = constructibleElementDefinition.ConstructibleElement as UnitDesign;
        GuiElement guiElement2;

        if (unitDesign != null)
        {
            this.ConstructibleName.Text   = GuiUnitDesign.GetTruncatedTitle(unitDesign, this.ConstructibleName);
            this.ConstructibleImage.Image = null;
            GuiElement guiElement;
            Texture2D  image;
            if (guiPanelHelper.TryGetGuiElement(unitDesign.UnitBodyDefinitionReference, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.ConstructibleImage.Image = image;
            }
        }
        else if (guiPanelHelper.TryGetGuiElement(constructibleElementDefinition.ConstructibleElement.Name, out guiElement2))
        {
            AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement2.Title), this.ConstructibleName, out this.temp, '.');
            this.ConstructibleName.Text = this.temp;
            Texture2D image2;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement2, global::GuiPanel.IconSize.Small, out image2))
            {
                this.ConstructibleImage.Image = image2;
            }
            else
            {
                this.ConstructibleImage.Image = null;
            }
        }
        else
        {
            this.ConstructibleName.Text   = string.Empty;
            this.ConstructibleImage.Image = null;
        }
        if (this.AgeTransform.AgeTooltip != null)
        {
            this.AgeTransform.AgeTooltip.Class   = constructibleElementDefinition.ConstructibleElement.TooltipClass;
            this.AgeTransform.AgeTooltip.Content = constructibleElementDefinition.ConstructibleElement.Name;
            if (constructibleElementDefinition.ConstructibleElement is BoosterGeneratorDefinition)
            {
                this.AgeTransform.AgeTooltip.ClientData = new BoosterGeneratorTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
            else
            {
                this.AgeTransform.AgeTooltip.ClientData = new ConstructibleTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
        }
        this.ConstructibleButton.OnActivateMethod     = "OnOptionSelect";
        this.ConstructibleButton.OnActivateObject     = client;
        this.ConstructibleButton.OnActivateDataObject = constructibleElementDefinition.ConstructibleElement;
        this.ConstructibleButton.OnMiddleClickMethod  = "OnRightClick";
        this.ConstructibleButton.OnMiddleClickObject  = client;
        this.ConstructibleButton.OnRightClickMethod   = "OnRightClick";
        this.ConstructibleButton.OnRightClickObject   = client;
        this.AgeTransform.Enable = (constructibleElementDefinition.Flags.Length == 0);
    }
Example #2
0
    private void ConstructibleItemRefresh(AgeTransform tableitem, CityOptionsPanel.ProductionConstruction reference, int index)
    {
        ConstructibleGuiItem component = tableitem.GetComponent <ConstructibleGuiItem>();

        if (component.AgeTransform.AgeTooltip != null)
        {
            component.AgeTransform.AgeTooltip.Anchor     = base.AgeTransform;
            component.AgeTransform.AgeTooltip.AnchorMode = AgeTooltipAnchorMode.TOP_CENTER;
        }
        Diagnostics.Assert(component != null);
        if (component != null)
        {
            component.RefreshContent(this.City, reference, index, base.gameObject);
        }
    }