Пример #1
0
    private void UpdateBackgroundImage()
    {
        if (this.BackgroundImage == null)
        {
            return;
        }
        if (this.SelectedEmpire == null)
        {
            this.BackgroundImage.Image = null;
            return;
        }
        GuiEmpire guiEmpire = new GuiEmpire(this.SelectedEmpire);

        this.BackgroundImage.Image = guiEmpire.GetImageTexture(global::GuiPanel.IconSize.NegotiationLarge, base.Empire);
    }
Пример #2
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        if (this.Fortress == null)
        {
            return;
        }
        if (this.Fortress.Occupant != null)
        {
            GuiEmpire guiEmpire = new GuiEmpire(this.Fortress.Occupant);
            this.OwningEmpireImage.Image = guiEmpire.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, this.playerControllerRepositoryService.ActivePlayerController.Empire as global::Empire);
        }
        string text = string.Empty;

        this.NextStockpileLabel.AgeTransform.Visible = false;
        this.WeatherControlGroup.Visible             = false;
        GuiElement guiElement;

        if (base.GuiService.GuiPanelHelper.TryGetGuiElement(this.Fortress.PointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName, out guiElement))
        {
            if (this.Fortress.Orientation == Fortress.CardinalOrientation.Center)
            {
                text = AgeLocalizer.Instance.LocalizeString(guiElement.Title);
            }
            else
            {
                text = AgeLocalizer.Instance.LocalizeString("%FortressGeolocalizedNameFormat").Replace("$FortressName", AgeLocalizer.Instance.LocalizeString(guiElement.Title));
                text = text.Replace("$FortressPosition", AgeLocalizer.Instance.LocalizeString("%" + this.Fortress.Orientation.ToString() + "GeolocalizationTitle"));
            }
            this.CitadelTitle.Text = text;
            if (this.CitadelTitle.AgeTransform.AgeTooltip != null)
            {
                this.CitadelTitle.AgeTransform.AgeTooltip.Class      = Fortress.Facility;
                this.CitadelTitle.AgeTransform.AgeTooltip.Content    = guiElement.Name;
                this.CitadelTitle.AgeTransform.AgeTooltip.ClientData = this.Fortress.PointOfInterest.PointOfInterestImprovement;
            }
            Texture2D image;
            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.CitadelImage.Image = image;
                this.CitadelImage.AgeTransform.AgeTooltip.Copy(this.CitadelTitle.AgeTransform.AgeTooltip);
            }
        }
        else
        {
            this.CitadelTitle.Text = this.Fortress.PointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName;
        }
        List <PointOfInterest> facilities = this.Fortress.Facilities;

        for (int i = 0; i < facilities.Count; i++)
        {
            if (facilities[i].SimulationObject.Tags.Contains(Fortress.UniqueFacilityNames.StockPile1) || facilities[i].SimulationObject.Tags.Contains(Fortress.UniqueFacilityNames.StockPile2) || facilities[i].SimulationObject.Tags.Contains(Fortress.UniqueFacilityNames.StockPile3))
            {
                this.NextStockpileLabel.AgeTransform.Visible = true;
                int num;
                if (this.Fortress.Region.NavalEmpire.GetAgency <PirateCouncil>().Stockpiles.TryGetValue(facilities[i].GUID, out num))
                {
                    if (num > 1)
                    {
                        this.NextStockpileLabel.Text = AgeLocalizer.Instance.LocalizeString("%FortressInfoNextStockpileGenerationFormatPlural").Replace("$Timer", num.ToString());
                    }
                    else
                    {
                        this.NextStockpileLabel.Text = AgeLocalizer.Instance.LocalizeString("%FortressInfoNextStockpileGenerationFormatSingle").Replace("$Timer", num.ToString());
                    }
                }
                else
                {
                    this.NextStockpileLabel.Text = AgeLocalizer.Instance.LocalizeString("%FortressInfoNextStockpileGenerationFormatPlural").Replace("$Timer", "???");
                }
            }
            if (facilities[i].SimulationObject.Tags.Contains(Fortress.UniqueFacilityNames.WeatherControl) && this.weatherService != null)
            {
                this.WeatherControlGroup.Visible = true;
                List <string> list  = new List <string>();
                List <string> list2 = new List <string>();
                list.Add("%FortressInfoWeatherControlNoPresetTitle");
                list2.Add("%FortressInfoWeatherControlNoPresetDescription");
                bool   flag = this.weatherService.WeatherControlCooldown <= 0 || this.weatherService.WeatherControlStartTurn == (base.Game as global::Game).Turn + 1;
                int    weatherControlTurnDurationFor = this.weatherService.GetWeatherControlTurnDurationFor(this.fortress.Occupant);
                string newValue = string.Empty;
                for (int j = 0; j < this.presetNames.Count; j++)
                {
                    GuiElement guiElement2;
                    if (base.GuiService.GuiPanelHelper.TryGetGuiElement("Weather" + this.presetNames[j], out guiElement2))
                    {
                        list.Add(guiElement2.Title);
                        if (!flag)
                        {
                            newValue = (weatherControlTurnDurationFor - ((base.Game as global::Game).Turn + 1 - this.weatherService.WeatherControlStartTurn)).ToString();
                        }
                        else
                        {
                            newValue = weatherControlTurnDurationFor.ToString();
                        }
                        list2.Add(AgeLocalizer.Instance.LocalizeString(guiElement2.Description).Replace("$Timer", newValue));
                    }
                }
                this.WeatherControlDroplist.ItemTable    = list.ToArray();
                this.WeatherControlDroplist.TooltipTable = list2.ToArray();
                if (this.presetNames.Contains(this.weatherService.PresetName))
                {
                    this.WeatherControlDroplist.SelectedItem = this.presetNames.IndexOf(this.weatherService.PresetName) + 1;
                }
                else
                {
                    this.WeatherControlDroplist.SelectedItem = 0;
                }
                if (flag)
                {
                    this.WeatherControlLabel.Text = "%FortressInfoWeatherControlUseTitle";
                    this.WeatherControlLabel.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%FortressInfoWeatherControlUseDescription").Replace("$Timer", weatherControlTurnDurationFor.ToString());
                    this.WeatherControlDroplist.AgeTransform.Enable          = true;
                }
                else if (this.weatherService.WeatherControlCooldown > 0)
                {
                    this.WeatherControlDroplist.AgeTransform.Enable = false;
                    this.WeatherControlLabel.Text = AgeLocalizer.Instance.LocalizeString("%FortressInfoWeatherControlEndOfCooldownFormatSingle").Replace("$Timer", this.weatherService.WeatherControlCooldown.ToString());
                    this.WeatherControlLabel.AgeTransform.AgeTooltip.Content = "%FortressInfoWeatherControlEndOfCooldownDescription";
                    if (this.weatherService.WeatherControlCooldown > 1)
                    {
                        this.WeatherControlLabel.Text = AgeLocalizer.Instance.LocalizeString("%FortressInfoWeatherControlEndOfCooldownFormatPlural").Replace("$Timer", this.weatherService.WeatherControlCooldown.ToString());
                    }
                }
            }
        }
        for (int k = 0; k < this.typesFIDS.Count; k++)
        {
            if (k < this.valuesFIDS.Count)
            {
                this.valuesFIDS[k].AgeTransform.Alpha = 1f;
                this.valuesFIDS[k].AgeTransform.ResetAllModifiers(true, false);
                float propertyValue = this.Fortress.GetPropertyValue(this.typesFIDS[k]);
                this.valuesFIDS[k].Text = GuiFormater.FormatGui(propertyValue, false, false, false, 0);
            }
        }
        this.PlayerEmpire = (this.PlayerController.Empire as global::Empire);
        this.FacilitiesTable.ReserveChildren(facilities.Count, this.FacilityOccurencePrefab, Fortress.Facility);
        this.FacilitiesTable.RefreshChildrenIList <PointOfInterest>(facilities, this.updateFacilityDelegate, false, false);
    }
Пример #3
0
    public void RefreshContent(Player player, Empire playerEmpire, IGuiPanelHelper helper)
    {
        GuiEmpire guiEmpire = new GuiEmpire(player.Empire);

        this.EmpireIcon.Image     = guiEmpire.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, playerEmpire);
        this.EmpireIcon.TintColor = guiEmpire.Color;
        AgeUtils.TruncateString(player.LocalizedName, this.EmpireLeader, out this.temp, '.');
        this.EmpireLeader.Text      = this.temp;
        this.EmpireLeader.TintColor = player.Empire.Color;
        float       value       = 0f;
        MajorEmpire majorEmpire = player.Empire as MajorEmpire;

        if (majorEmpire != null)
        {
            Diagnostics.Assert(majorEmpire.GameScores != null);
            GameScore gameScore = null;
            if (majorEmpire.GameScores.TryGetValue(GameScores.Names.GlobalScore, out gameScore))
            {
                value = gameScore.Value;
            }
        }
        bool            flag    = false;
        ISessionService service = Services.GetService <ISessionService>();

        Diagnostics.Assert(service != null && service.Session != null);
        string lobbyData = service.Session.GetLobbyData <string>(EmpireInfo.EmpireInfoAccessibility, "Default");

        switch ((int)Enum.Parse(typeof(EmpireInfo.Accessibility), lobbyData))
        {
        case 0:
            flag = true;
            break;

        case 1:
            if (player.Empire == playerEmpire)
            {
                flag = true;
            }
            else if (playerEmpire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(player.Empire).State.Name == DiplomaticRelationState.Names.Dead)
            {
                flag = true;
            }
            break;

        case 2:
            if (player.Empire == playerEmpire)
            {
                flag = true;
            }
            else
            {
                DepartmentOfIntelligence agency = playerEmpire.GetAgency <DepartmentOfIntelligence>();
                if (agency != null && agency.IsEmpireInfiltrated(player.Empire))
                {
                    flag = true;
                }
                else if (playerEmpire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(player.Empire).State.Name == DiplomaticRelationState.Names.Dead)
                {
                    flag = true;
                }
            }
            break;

        default:
            flag = true;
            break;
        }
        if (flag || !(playerEmpire is MajorEmpire) || (playerEmpire as MajorEmpire).IsEliminated)
        {
            this.EmpireScore.Text = GuiFormater.FormatGui(value, false, false, false, 1);
        }
        else
        {
            this.EmpireScore.Text = "???";
        }
        this.EmpireScore.TintColor = player.Empire.Color;
        if (player.Empire == playerEmpire)
        {
            this.EmpireDiplomacy.Text      = "-";
            this.EmpireDiplomacy.TintColor = player.Empire.Color;
        }
        else
        {
            DepartmentOfForeignAffairs agency2 = playerEmpire.GetAgency <DepartmentOfForeignAffairs>();
            if (agency2 != null)
            {
                DiplomaticRelation diplomaticRelation = agency2.GetDiplomaticRelation(player.Empire);
                GuiElement         guiElement;
                if (helper.TryGetGuiElement(diplomaticRelation.State.Name, out guiElement))
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.EmpireDiplomacy, out this.temp, '.');
                    this.EmpireDiplomacy.Text      = this.temp;
                    this.EmpireDiplomacy.TintColor = player.Empire.Color;
                }
                if (player.Empire.IsControlledByAI)
                {
                    if (diplomaticRelation.State.Name == DiplomaticRelationState.Names.Unknown)
                    {
                        AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.EmpireDiplomacy, out this.temp, '.');
                        this.EmpireLeader.Text = this.temp;
                    }
                    else
                    {
                        AgeUtils.TruncateString(player.Empire.LocalizedName, this.EmpireLeader, out this.temp, '.');
                        this.EmpireLeader.Text = this.temp;
                    }
                }
            }
        }
        string key = string.Empty;

        this.EmpireStatus.Text = string.Empty;
        PlayerHelper.ComputePlayerState(ref player);
        key = string.Format("%PlayerState_{0}", player.State);
        string src = string.Empty;

        if (player.Type == PlayerType.Human && service.Session.SessionMode != SessionMode.Single)
        {
            src = string.Format("{0} ({1:0.}ms)", AgeLocalizer.Instance.LocalizeString(key), player.Latency * 1000.0);
        }
        else
        {
            src = AgeLocalizer.Instance.LocalizeString(key);
        }
        AgeUtils.TruncateString(src, this.EmpireStatus, out this.temp, '.');
        AgePrimitiveLabel empireStatus = this.EmpireStatus;

        empireStatus.Text      = empireStatus.Text + this.temp + "\n";
        this.EmpireStatus.Text = this.EmpireStatus.Text.TrimEnd(new char[]
        {
            '\n'
        });
        this.EmpireStatus.TintColor = player.Empire.Color;
    }