Exemplo n.º 1
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        if (this.City == null)
        {
            Diagnostics.LogError("Trying to refresh CityManagementPanel while not bound to a city");
            return;
        }
        this.IsOtherEmpire = (this.playerControllerRepository.ActivePlayerController.Empire != this.City.Empire);
        int count = this.City.CityImprovements.Count;
        int num   = Mathf.CeilToInt(this.City.GetPropertyValue(SimulationProperties.CityMoneyUpkeep));

        this.NumberValue.Text = count.ToString();
        this.UpkeepValue.Text = GuiFormater.FormatQuantity((float)num, SimulationProperties.CityMoneyUpkeep, 1);
        ReadOnlyCollection <CityImprovement> cityImprovements = this.City.CityImprovements;

        this.CityImprovementsTable.Height = 0f;
        this.CityImprovementsTable.ReserveChildren(count, this.BuildingPrefab, "Item");
        this.CityImprovementsTable.RefreshChildrenIList <CityImprovement>(cityImprovements, this.refreshCityImprovementDelegate, true, true);
        this.CityImprovementsTable.ArrangeChildren();
        this.CityImprovementsScrollView.OnPositionRecomputed();
        PointOfInterest[] pointOfInterests = this.City.Region.PointOfInterests;
        this.regionBuildings.Clear();
        for (int i = 0; i < pointOfInterests.Length; i++)
        {
            if (pointOfInterests[i].PointOfInterestImprovement != null)
            {
                string a;
                if (pointOfInterests[i].PointOfInterestDefinition.TryGetValue("Type", out a) && a == "Village")
                {
                    if (!pointOfInterests[i].SimulationObject.Tags.Contains("PacifiedVillage"))
                    {
                        goto IL_18D;
                    }
                }
                this.regionBuildings.Add(pointOfInterests[i]);
            }
            IL_18D :;
        }
        this.RegionBuildingsTable.Height = 0f;
        this.RegionBuildingsTable.ReserveChildren(this.regionBuildings.Count, this.BuildingPrefab, "Item");
        this.RegionBuildingsTable.RefreshChildrenIList <PointOfInterest>(this.regionBuildings, this.refreshRegionBuildingDelegate, true, true);
        this.RegionBuildingsTable.ArrangeChildren();
        this.RegionBuildingsScrollView.OnPositionRecomputed();
    }
Exemplo n.º 2
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        base.Empire.Refresh(false);
        DepartmentOfScience     agency  = base.Empire.GetAgency <DepartmentOfScience>();
        DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>();

        this.ComputeCurrentEraNumber();
        this.CurrentEraNumber.Text = AgeUtils.ToRoman(this.currentEraNumber);
        this.ResearchErasTable.RefreshChildrenIList <ResearchEraFrame.TechnologyEra>(this.eras, this.refreshEraDelegate, true, false);
        Construction construction = agency.ResearchQueue.Peek();
        bool         flag         = construction != null;
        float        quantity;

        if (flag)
        {
            quantity = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.Empire.SimulationObject, construction.ConstructibleElement, DepartmentOfTheTreasury.Resources.EmpireResearch);
        }
        else
        {
            quantity = agency.GetResearchPropertyValue(SimulationProperties.TechnologyCost);
        }
        this.TechnologyCostValue.Text = GuiFormater.FormatQuantity(quantity, SimulationProperties.EmpireResearch, 1);
        float quantity2;

        agency2.TryGetNetResourceValue(base.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireResearch, out quantity2, false);
        this.EmpireOutputValue.Text = GuiFormater.FormatQuantity(quantity2, SimulationProperties.EmpireResearch, 0);
        if (flag)
        {
            float num = agency2.ComputeConstructionProgress(base.Empire, construction);
            this.ResearchProgress.Text = Mathf.RoundToInt(num * 100f).ToString() + "%";
            int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction);
            num2 = Mathf.Max(num2, 1);
            if (num2 == 2147483647)
            {
                this.ResearchTurns.Text = GuiFormater.Infinite.ToString();
            }
            else
            {
                this.ResearchTurns.Text = num2.ToString();
            }
            TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition;
            if (technologyDefinition != null)
            {
                this.TechnologyName.Text   = DepartmentOfScience.GetTechnologyTitle(technologyDefinition);
                this.TechnologyImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, GuiPanel.IconSize.Small);
            }
            DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.TechnologyName.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
        }
        else
        {
            this.TechnologyName.Text   = "%ResearchNoneTitle";
            this.TechnologyImage.Image = null;
            this.ResearchProgress.Text = "%ResearchVoidSymbol";
            this.ResearchTurns.Text    = "%ResearchVoidSymbol";
            if (this.TechnologyName.AgeTransform.AgeTooltip != null)
            {
                this.TechnologyName.AgeTransform.AgeTooltip.Class      = string.Empty;
                this.TechnologyName.AgeTransform.AgeTooltip.Content    = string.Empty;
                this.TechnologyName.AgeTransform.AgeTooltip.ClientData = null;
            }
            if (this.TechnologyImage.AgeTransform.AgeTooltip != null)
            {
                this.TechnologyImage.AgeTransform.AgeTooltip.Class      = string.Empty;
                this.TechnologyImage.AgeTransform.AgeTooltip.Content    = string.Empty;
                this.TechnologyImage.AgeTransform.AgeTooltip.ClientData = null;
            }
        }
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1))
        {
            this.TechnologyStatsGroup.Visible = false;
            this.ResearchBuyoutButton.AgeTransform.Visible = true;
            this.ResearchCompletionGroup.Visible           = false;
            this.RefreshBuyout(this.ResearchBuyoutButton);
            return;
        }
        this.TechnologyStatsGroup.Visible = true;
        this.ResearchBuyoutButton.AgeTransform.Visible = false;
        this.ResearchCompletionGroup.Visible           = true;
    }
Exemplo n.º 3
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        float propertyValue = this.City.GetPropertyValue(SimulationProperties.NetCityApproval);

        this.ApprovalGauge.PercentRight = Mathf.Clamp(propertyValue, 0f, 100f);
        this.ApprovalValue.Text         = GuiFormater.FormatGui(propertyValue * 0.01f, true, false, false, 1);
        StaticString descriptorNameFromType = this.City.GetDescriptorNameFromType("ApprovalStatus");
        GuiElement   guiElement;

        if (base.GuiService.GuiPanelHelper.TryGetGuiElement(descriptorNameFromType, out guiElement, this.City.Empire.Faction.Name))
        {
            this.ApprovalState.Text = guiElement.Title;
            ExtendedGuiElement extendedGuiElement = guiElement as ExtendedGuiElement;
            if (extendedGuiElement != null)
            {
                this.ApprovalGauge.AgePrimitive.TintColor = extendedGuiElement.Color;
                this.ApprovalState.TintColor = extendedGuiElement.Color;
            }
        }
        else
        {
            this.ApprovalState.Text = "%ApprovalStatusUnknown";
        }
        if (this.ApprovalState.AgeTransform.AgeTooltip != null)
        {
            this.ApprovalState.AgeTransform.AgeTooltip.Content = descriptorNameFromType.ToString();
        }
        this.RefreshPopulationCount();
        this.RefreshPopulationGrowth();
        int num = Mathf.CeilToInt(this.City.GetPropertyValue(SimulationProperties.CityMoneyUpkeep));

        this.UpkeepValue.Text = GuiFormater.FormatQuantity((float)(-(float)num), SimulationProperties.CityMoneyUpkeep, 1);
        AgeTooltip ageTooltip = this.UpkeepValue.AgeTransform.AgeTooltip;

        ageTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%BuildingsUpkeepFormatDescription"), this.UpkeepValue.Text);
        this.UpkeepIcon1.AgeTooltip.Copy(ageTooltip);
        this.UpkeepIcon2.AgeTooltip.Copy(ageTooltip);
        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            if (i < this.valuesFIDS.Count && i < this.deltaFIDS.Count)
            {
                if (!this.valuesFIDS[i].AgeTransform.ModifiersRunning)
                {
                    this.valuesFIDS[i].AgeTransform.Alpha = 1f;
                    this.valuesFIDS[i].AgeTransform.ResetAllModifiers(true, false);
                    this.deltaFIDS[i].AgeTransform.Alpha = 0f;
                    this.deltaFIDS[i].AgeTransform.ResetAllModifiers(true, false);
                }
                float propertyValue2 = this.City.GetPropertyValue(this.typesFIDS[i]);
                this.valuesFIDS[i].Text = GuiFormater.FormatGui(propertyValue2, false, false, false, 0);
                if (propertyValue2 != this.previousFIDS[i])
                {
                    this.AnimateFIDSChange(this.valuesFIDS[i], this.deltaFIDS[i], propertyValue2 - this.previousFIDS[i]);
                    this.previousFIDS[i] = propertyValue2;
                }
            }
        }
        for (int j = 0; j < this.workerTypes.Count; j++)
        {
            if (j < this.workersFIDS.Count)
            {
                this.workersFIDS[j].Text = this.City.GetPropertyValue(this.workerTypes[j]).ToString();
            }
        }
        if (this.CityWorkersPanel.IsVisible)
        {
            this.CityWorkersPanel.RefreshContent();
        }
        this.RefreshButtons();
    }
Exemplo n.º 4
0
    public void RefreshContent()
    {
        this.AgeTransform.Enable = true;
        this.AgeTransform.StopSearchingForTooltips = false;
        this.AgeTransform.AgeTooltip.Content       = string.Empty;
        this.ArmySize.TintColor = Color.white;
        this.HeroCard.HeroPortrait.TintColor = Color.white;
        if (this.ArmyNameLabel != null)
        {
            AgeUtils.TruncateString(this.Army.LocalizedName, this.ArmyNameLabel, out this.temp, '.');
            this.ArmyNameLabel.Text = this.temp;
            if (this.Army.IsInEncounter)
            {
                this.ArmyNameLabel.TintColor = this.ColorIfInBattle;
                this.ArmyNameLabel.AgeTransform.AgeTooltip.Content = "%ArmyLockedInBattleDescription";
            }
            else
            {
                this.ArmyNameLabel.TintColor = Color.white;
                this.ArmyNameLabel.AgeTransform.AgeTooltip.Content = string.Empty;
            }
        }
        if (this.HeroCard != null)
        {
            this.HeroCard.RefreshContent(this.isColossusArmy, this.isKaijuArmy);
        }
        if (this.ArmySize != null)
        {
            this.ArmySize.Text = this.Army.CurrentUnitSlot.ToString() + "/" + this.Army.MaximumUnitSlot.ToString();
            AgeTooltip ageTooltip = this.ArmySize.AgeTransform.AgeTooltip;
            if (ageTooltip != null)
            {
                if (this.Army.CurrentUnitSlot > this.Army.MaximumUnitSlot)
                {
                    ageTooltip.Content      = "%ArmyCapacityExceededDescription";
                    this.ArmySize.TintColor = Color.red;
                }
                else
                {
                    ageTooltip.Content = string.Empty;
                }
            }
        }
        if (this.ArmyHPLabel != null)
        {
            float propertyValue  = this.Army.GetPropertyValue(SimulationProperties.Health);
            float propertyValue2 = this.Army.GetPropertyValue(SimulationProperties.MaximumHealth);
            float num            = 0f;
            if (propertyValue2 > 0f)
            {
                num = 100f * (propertyValue / propertyValue2);
            }
            this.ArmyHPGauge.AgeTransform.PercentRight = num;
            if (num >= 75f)
            {
                this.ArmyHPGauge.TintColor = this.FullLifeColor;
            }
            else if (num >= 25f)
            {
                this.ArmyHPGauge.TintColor = this.HalfLifeColor;
            }
            else
            {
                this.ArmyHPGauge.TintColor = this.CriticalLifeColor;
            }
            this.ArmyHPLabel.Text = GuiFormater.FormatGui(Mathf.Floor(propertyValue), false, false, false, 1) + "/" + GuiFormater.FormatGui(Mathf.Floor(propertyValue2), false, false, false, 1);
        }
        if (this.ArmyMovement != null)
        {
            string str  = GuiFormater.FormatGui(this.Army.GetPropertyValue(SimulationProperties.Movement), false, false, false, 1);
            string str2 = GuiFormater.FormatGui(this.Army.GetPropertyValue(SimulationProperties.MaximumMovement), false, false, false, 1);
            this.ArmyMovement.Text = str + "/" + str2;
        }
        if (this.ArmyLocation != null)
        {
            IGameService service = Services.GetService <IGameService>();
            this.ArmyLocation.Text = service.Game.Services.GetService <IWorldPositionningService>().GetRegion(this.Army.WorldPosition).LocalizedName;
        }
        if (this.ArmyUpkeep != null)
        {
            float propertyValue3 = this.Army.GetPropertyValue(SimulationProperties.MilitaryUpkeep);
            this.ArmyUpkeep.Text = GuiFormater.FormatQuantity(-propertyValue3, SimulationProperties.MilitaryUpkeep, 0);
        }
        if (this.HeroCard != null)
        {
            this.HeroCard.AgeTransform.Enable = !this.ReadOnly;
        }
        bool flag;

        if (this.Army.StandardUnits.Count > 0)
        {
            flag = this.Army.StandardUnits.All((Unit unit) => unit.UnitDesign.Tags.Contains(DownloadableContent9.TagColossus));
        }
        else
        {
            flag = false;
        }
        bool flag2 = flag;
        bool flag3;

        if (this.Army.StandardUnits.Count > 0)
        {
            flag3 = this.Army.StandardUnits.Any((Unit unit) => unit.UnitDesign.Tags.Contains(DownloadableContent20.TagKaijuMonster));
        }
        else
        {
            flag3 = false;
        }
        bool flag4 = flag3;

        this.ArmySize.AgeTransform.Visible          = (!flag2 && !flag4);
        this.ColossusArmyLabel.AgeTransform.Visible = flag2;
        if (flag2)
        {
            this.ColossusArmyLabel.Text = "\\7805\\";
            this.ColossusArmyLabel.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyWithColossusDescription");
        }
        this.KaijuArmyLabel.AgeTransform.Visible = flag4;
        if (flag4)
        {
            string text = this.ArmySize.Text;
            this.KaijuArmyLabel.Text = "\\7100\\ " + text;
            this.KaijuArmyLabel.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyWithKaijuMonsterDescription");
        }
        AgeTransform ageTransform = this.ArmyStatusLabel.AgeTransform.GetParent();

        if (this.Army.IsCamouflaged)
        {
            this.ArmyStatusLabel.AgeTransform.Visible = true;
            this.ArmyStatusLabel.Text       = "\\7815\\";
            ageTransform.AgeTooltip.Content = "%ArmyCamouflagedDescription";
        }
        else if (this.Army.IsNaval)
        {
            this.ArmyStatusLabel.AgeTransform.Visible = true;
            this.ArmyStatusLabel.Text       = "\\7825\\";
            ageTransform.AgeTooltip.Content = "%ArmyIsSeafaringDescription";
        }
        else
        {
            this.ArmyStatusLabel.AgeTransform.Visible = false;
            ageTransform.AgeTooltip.Content           = string.Empty;
        }
        this.SelectionToggle.State = false;
    }