示例#1
0
    private void RefreshProgressItem(AgeTransform item, string text, int index)
    {
        AgePrimitiveLabel component = item.GetComponent <AgePrimitiveLabel>();

        component.Text = text;
        item.Alpha     = 1f - 0.2f * (float)index;
    }
示例#2
0
    public void DisplayCost(AgePrimitiveLabel costLabel)
    {
        string text = string.Empty;

        text           = GuiFormater.FormatInstantCost(this.Term.EmpireWhichProposes, this.EmpirePointCost, DepartmentOfTheTreasury.Resources.EmpirePoint, false, 0);
        costLabel.Text = text;
    }
示例#3
0
 private void AnimateFIDSChange(AgePrimitiveLabel control, AgePrimitiveLabel modifier, float delta)
 {
     modifier.Text      = GuiFormater.FormatGui(delta, false, true, true, 1);
     modifier.TintColor = ((delta < 0f) ? Color.red : Color.green);
     control.AgeTransform.StartAllModifiers(true, false);
     modifier.AgeTransform.StartAllModifiers(true, false);
 }
        private void CreateModList(AgePrimitiveLabel label)
        {
            Debug.Log("Attempting to create modlist!");
            Debug.Log("Label has position: " + label.transform.position);
            GameObject o = (GameObject)GameObject.Instantiate(label.gameObject, new Vector3(0, 0, 0), Quaternion.identity);

            o.transform.parent = label.gameObject.transform.parent;

            AgePrimitiveLabel l2 = o.GetComponent <AgePrimitiveLabel>();

            l2.Alignement = AgeTextAnchor.UpperLeft;
            string text = "ModList:\n";

            foreach (ScadMod mod in ModList)
            {
                text += "- " + mod.name + " - " + mod.Version + "\n";
            }

            Debug.Log("Label has alignment: " + label.Alignement + " new label has alignment: " + l2.Alignement);
            Debug.Log("Label has 2d pos: " + label.Get2DPosition() + " new label has 2d pos: " + l2.Get2DPosition());
            Debug.Log("Label has agetransform: (" + label.AgeTransform.X + ", " + label.AgeTransform.Y + ", " + label.AgeTransform.Z + ")");
            Debug.Log("new label has agetransform: (" + l2.AgeTransform.X + ", " + l2.AgeTransform.Y + ", " + l2.AgeTransform.Z + ")");
            Debug.Log("Label pos vs new label pos: " + label.AgeTransform.Position.position + ", " + l2.AgeTransform.Position.position);

            l2.Text = text;
            Debug.Log("ModList Text: " + l2.Text);
            o.SetActive(true);
        }
示例#5
0
    public static void FormatVersionAndMod(AgePrimitiveLabel currentModInfoLabel, AgePrimitiveLabel versionLabel)
    {
        if (currentModInfoLabel != null)
        {
            currentModInfoLabel.Text = "%ModDefaultTitle";
        }
        if (versionLabel != null)
        {
            versionLabel.Text = Amplitude.Unity.Framework.Application.Name.ToString() + " " + Amplitude.Unity.Framework.Application.Version.ToString();
            string a;
            if (global::Application.ResolveChineseLanguage(out a))
            {
                if (a == "schinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%SChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
                else if (a == "tchinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%TChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
            }
        }
        IRuntimeService service = Services.GetService <IRuntimeService>();

        if (service != null && service.Runtime != null)
        {
            RuntimeModule runtimeModule  = service.Runtime.RuntimeModules.FirstOrDefault((RuntimeModule module) => module.Type == RuntimeModuleType.Standalone);
            RuntimeModule runtimeModule2 = service.Runtime.RuntimeModules.FirstOrDefault((RuntimeModule module) => module.Type == RuntimeModuleType.Conversion);
            RuntimeModule runtimeModule3;
            if (runtimeModule2 != null)
            {
                runtimeModule3 = runtimeModule2;
            }
            else
            {
                Diagnostics.Assert(runtimeModule != null);
                runtimeModule3 = runtimeModule;
                if (service != null && service.VanillaModuleName == runtimeModule.Name)
                {
                    runtimeModule3 = null;
                }
            }
            if (runtimeModule3 != null && !string.IsNullOrEmpty(runtimeModule3.Title))
            {
                if (currentModInfoLabel != null)
                {
                    currentModInfoLabel.Text = string.Format(AgeLocalizer.Instance.LocalizeString("%ModActiveFormat"), runtimeModule3.Title);
                }
                if (versionLabel != null)
                {
                    string text = AgeLocalizer.Instance.LocalizeStringDefaults("%GameMenuModificationFormat", "$Modification $Version").Replace("$Modification", runtimeModule3.Title).Replace("$Version", runtimeModule3.Version.ToString("V{0}.{1}.{2}"));
                    if (!string.IsNullOrEmpty(text))
                    {
                        versionLabel.Text = versionLabel.Text + "\n" + text;
                    }
                }
            }
        }
    }
示例#6
0
    public static void TruncateString(string src, AgePrimitiveLabel label, out string dest, char truncateChar)
    {
        float width = label.AgeTransform.Width;

        if (width == 0f)
        {
            width = label.AgeTransform.Width;
        }
        AgeUtils.TruncateString(src, label.Font, width, out dest, truncateChar, label.ForceCaps);
    }
 private void OnSliderDragged()
 {
     // Find the slider that was dragged and update it.
     foreach (AgeControlSlider s in sliders)
     {
         AgePrimitiveLabel valueLabel = s.transform.parent.parent.FindChild("30-Value").GetComponent <AgePrimitiveLabel>();
         if (!s.CurrentValue.ToString().Equals(valueLabel.Text))
         {
             valueLabel.Text = s.CurrentValue.ToString();
         }
     }
 }
示例#8
0
    private void SetupGuiFactionTrait(AgeTransform tableItem, GuiFactionTrait guiFactionTrait, int index)
    {
        AgePrimitiveLabel component = tableItem.GetComponent <AgePrimitiveLabel>();

        if (component != null)
        {
            component.Text = guiFactionTrait.IconAndTitle;
        }
        if (tableItem.AgeTooltip != null)
        {
            guiFactionTrait.GenerateTooltip(tableItem.AgeTooltip, this.SelectedGuiFaction.Faction.Affinity);
        }
    }
示例#9
0
    public static void TruncateStringWithSuffix(string src, string suffix, AgePrimitiveLabel label, float maxWidth, out string dest, char truncateChar, bool forcedCaps = false)
    {
        dest = src;
        AgeUtils.CleanLine(dest + suffix, ref AgeUtils.line);
        float num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false);

        while (num > maxWidth && AgeUtils.line.Length > 1)
        {
            dest = dest.Substring(0, dest.Length - 2) + truncateChar;
            AgeUtils.CleanLine(dest + suffix, ref AgeUtils.line);
            num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false);
        }
        dest += suffix;
    }
示例#10
0
 private void Set_FortressOwnerIcon(global::Empire empire, global::Empire playerEmpire)
 {
     this.Empire       = empire;
     this.PlayerEmpire = playerEmpire;
     if (this.Empire != null)
     {
         if (!this.IsKnownByEmpirePlayer)
         {
             this.EmpireLabel.Text = GuiEmpire.Colorize(this.Empire, "???");
         }
         else
         {
             this.EmpireLabel.Text = GuiEmpire.Colorize(this.Empire, GuiEmpire.GetFactionSymbolString(this.Empire, this.PlayerEmpire));
         }
     }
     else
     {
         this.EmpireLabel.Text = string.Empty;
         AgePrimitiveLabel empireLabel = this.EmpireLabel;
         empireLabel.Text += 'Ẑ';
     }
 }
示例#11
0
    public static void FormatVersionAndModulePlaylist(AgeControlButton buttonLastPlaylist, AgePrimitiveLabel currentModulePlaylistLabel, AgePrimitiveLabel versionLabel)
    {
        if (currentModulePlaylistLabel != null)
        {
            currentModulePlaylistLabel.Text = "%ModDefaultTitle";
            currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = string.Empty;
        }
        if (buttonLastPlaylist != null)
        {
            buttonLastPlaylist.AgeTransform.Enable = false;
        }
        if (versionLabel != null)
        {
            versionLabel.Text = Amplitude.Unity.Framework.Application.Name.ToString() + " " + Amplitude.Unity.Framework.Application.Version.ToString();
            string a;
            if (global::Application.ResolveChineseLanguage(out a))
            {
                if (a == "schinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%SChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
                else if (a == "tchinese")
                {
                    versionLabel.Text = AgeLocalizer.Instance.LocalizeString("%TChineseApplicationName") + " " + Amplitude.Unity.Framework.Application.Version.ToString();
                }
            }
            versionLabel.AgeTransform.AgeTooltip.Content = string.Empty;
        }
        Amplitude.Unity.Gui.IGuiService service = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        IRuntimeService service2       = Services.GetService <IRuntimeService>();
        ModulePlaylist  modulePlaylist = Services.GetService <IRuntimeModulePlaylistService>().CurrentModulePlaylist;

        if (modulePlaylist != null && modulePlaylist.Name == "VanillaModulePlaylist")
        {
            modulePlaylist = null;
        }
        if (modulePlaylist != null && modulePlaylist.Configuration.Length == 1 && modulePlaylist.Configuration[0].ModuleName == service2.VanillaModuleName)
        {
            modulePlaylist = null;
        }
        if (modulePlaylist == null)
        {
            string empty  = string.Empty;
            string empty2 = string.Empty;
            if (Amplitude.Unity.Framework.Application.Registry.TryGetValue(global::Application.Registers.LastModulePlaylistActivated, out empty) && Amplitude.Unity.Framework.Application.Registry.TryGetValue(global::Application.Registers.LastModulePlaylistActivatedUrl, out empty2) && empty != "VanillaModulePlaylist")
            {
                if (buttonLastPlaylist != null)
                {
                    buttonLastPlaylist.AgeTransform.Enable = true;
                }
                if (currentModulePlaylistLabel != null)
                {
                    GuiElement guiElement;
                    if (service.GuiPanelHelper.TryGetGuiElement(empty, out guiElement))
                    {
                        currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistTitle").Replace("$PlaylistName", AgeLocalizer.Instance.LocalizeString(guiElement.Title));
                    }
                    else
                    {
                        currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistTitle").Replace("$PlaylistName", empty);
                    }
                    ModulePlaylist modulePlaylist2 = new ModulePlaylist(empty, string.Empty, null, ModulePlaylist.ParseConfigurationUrl(empty2));
                    modulePlaylist2.RepairPlaylistIfInvalid();
                    string newValue = string.Join("\n - ", MenuMainScreen.GetPlaylistModuleTitles(modulePlaylist2));
                    currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = AgeLocalizer.Instance.LocalizeString("%OutgameLastPlaylistDescription").Replace("$ModuleNames", newValue);
                    return;
                }
            }
        }
        else if (service2 != null && service2.Runtime != null)
        {
            modulePlaylist.RepairPlaylistIfInvalid();
            string newValue2 = modulePlaylist.Name;
            if (modulePlaylist.IsAnonymous)
            {
                newValue2 = AgeLocalizer.Instance.LocalizeString("%AnonymousActiveModulePlaylist");
            }
            string content = string.Join("\n", MenuMainScreen.GetPlaylistModuleTitles(modulePlaylist));
            if (currentModulePlaylistLabel != null)
            {
                currentModulePlaylistLabel.Text = AgeLocalizer.Instance.LocalizeString("%ModPlaylistActiveFormat").Replace("$Playlist", newValue2);
                currentModulePlaylistLabel.GetComponentInParent <AgeTooltip>().Content = content;
            }
            if (versionLabel != null)
            {
                string text = AgeLocalizer.Instance.LocalizeString("%GameMenuPlaylistFormat").Replace("$Playlist", newValue2);
                if (!string.IsNullOrEmpty(text))
                {
                    versionLabel.Text = versionLabel.Text + "\n" + text;
                    versionLabel.AgeTransform.AgeTooltip.Content = content;
                }
            }
        }
    }
示例#12
0
 public static void TruncateStringWithSuffix(string src, string suffix, AgePrimitiveLabel label, out string dest, char truncateChar)
 {
     AgeUtils.TruncateStringWithSuffix(src, suffix, label, label.AgeTransform.Width, out dest, truncateChar, label.ForceCaps);
 }
示例#13
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        this.Description.AgeTransform.Height = 0f;
        this.Description.Text = string.Empty;
        if (this.content.StartsWith("%"))
        {
            this.Description.Text = this.content;
        }
        else if (this.technologyOnly && this.context is MultipleConstructibleTooltipData)
        {
            GuiElement guiElement;
            if (base.GuiService.GuiPanelHelper.TryGetGuiElement((this.context as MultipleConstructibleTooltipData).TechnologyDefinition.Name, out guiElement))
            {
                this.Description.Text = guiElement.Description;
            }
        }
        else if (this.context is IDescriptionFeatureProvider)
        {
            this.Description.Text = (this.context as IDescriptionFeatureProvider).Description;
        }
        else
        {
            IGuiEntity guiEntity = this.context as IGuiEntity;
            GuiElement guiElement2;
            if (this.context != null && guiEntity != null && guiEntity.Gui != null)
            {
                this.Description.Text = guiEntity.Gui.Description;
            }
            else if (base.GuiService.GuiPanelHelper.TryGetGuiElement(this.content, out guiElement2))
            {
                this.Description.Text = guiElement2.Description;
            }
            else
            {
                this.Description.Text = this.content;
            }
        }
        if (this.context is CreepingNode || this.context is PointOfInterest || this.context is Village)
        {
            WorldPosition worldPosition;
            if (this.context is PointOfInterest)
            {
                worldPosition = (this.context as PointOfInterest).WorldPosition;
            }
            else if (this.context is CreepingNode)
            {
                worldPosition = (this.context as CreepingNode).WorldPosition;
            }
            else
            {
                worldPosition = (this.context as Village).WorldPosition;
            }
            Region region = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>().GetRegion(worldPosition);
            if (region.IsLand && !region.IsWasteland && region.MinorEmpire != null)
            {
                BarbarianCouncil agency = region.MinorEmpire.GetAgency <BarbarianCouncil>();
                if (agency != null && agency.GetVillageAt(worldPosition) != null)
                {
                    global::IGuiService      service      = Services.GetService <global::IGuiService>();
                    List <EffectDescription> list         = new List <EffectDescription>();
                    MinorFaction             minorFaction = region.MinorEmpire.MinorFaction;
                    if (minorFaction != null)
                    {
                        service.GuiSimulationParser.ParseSimulationDescriptor(minorFaction, list, null, false, false);
                        this.Description.Text = AgeLocalizer.Instance.LocalizeString(this.Description.Text);
                        foreach (EffectDescription effectDescription in list)
                        {
                            if (effectDescription == list[0])
                            {
                                AgePrimitiveLabel description = this.Description;
                                description.Text = description.Text + "\n \n#FFB43F#" + AgeLocalizer.Instance.LocalizeString("%EffectsOnEmpireTitle") + "#REVERT#";
                            }
                            AgePrimitiveLabel description2 = this.Description;
                            description2.Text = description2.Text + "\n" + effectDescription.ToString();
                        }
                    }
                }
            }
        }
        if (!string.IsNullOrEmpty(this.Description.Text))
        {
            this.Description.AgeTransform.Width = this.DefaultWidth - this.Description.AgeTransform.PixelMarginLeft - this.Description.AgeTransform.PixelMarginRight;
            this.Description.ComputeText();
            base.AgeTransform.Height = this.Description.Font.LineHeight * (float)this.Description.TextLines.Count + this.Description.AgeTransform.PixelMarginTop + this.Description.AgeTransform.PixelMarginBottom;
            if (this.Description.TextLines.Count == 1)
            {
                base.AgeTransform.Width = this.Description.AgeTransform.PixelMarginLeft + this.Description.Font.ComputeTextWidth(this.Description.TextLines[0], false, true) + this.Description.AgeTransform.PixelMarginRight;
            }
            else
            {
                base.AgeTransform.Width = this.DefaultWidth;
            }
        }
        yield return(base.OnShow(parameters));

        yield break;
    }
示例#14
0
    public void SetupTechnology(global::Empire empire, TechnologyDefinition technologyDefinition, GameObject client)
    {
        this.empire = empire;
        this.TechnologyDefinition = technologyDefinition;
        this.selectionClient      = client;
        if (this.TagsList == null)
        {
            this.TagsList = new List <string>();
        }
        else
        {
            this.TagsList.Clear();
        }
        if (this.empire == null)
        {
            return;
        }
        this.BuildTags();
        if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Quest))
        {
            this.EraLabel.Text = string.Empty;
            AgePrimitiveLabel eraLabel = this.EraLabel;
            eraLabel.Text += (char)this.QuestCharNumber;
        }
        else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Medal))
        {
            this.EraLabel.Text = string.Empty;
            AgePrimitiveLabel eraLabel2 = this.EraLabel;
            eraLabel2.Text += (char)this.MedalCharNumber;
        }
        else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Affinity))
        {
            this.EraLabel.Text = string.Empty;
            AgePrimitiveLabel eraLabel3 = this.EraLabel;
            eraLabel3.Text += GuiEmpire.GetFactionSymbolString(this.empire, this.empire);
        }
        else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock))
        {
            this.EraLabel.Text = string.Empty;
        }
        else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock))
        {
            this.EraLabel.Text = string.Empty;
        }
        else
        {
            int technologyEraNumber = DepartmentOfScience.GetTechnologyEraNumber(technologyDefinition);
            if (technologyEraNumber > 0)
            {
                this.EraLabel.Text = AgeUtils.ToRoman(technologyEraNumber);
            }
            else
            {
                this.EraLabel.Text = "-";
            }
        }
        this.GlowImage.AgeTransform.Visible = false;
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null && service.IsShared(DownloadableContent9.ReadOnlyName) && technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Unique))
        {
            this.GlowImage.AgeTransform.Visible = true;
        }
        if (this.UnlockImage != null)
        {
            this.UnlockImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, global::GuiPanel.IconSize.Small);
        }
        this.CategoryIcon.Image     = DepartmentOfScience.GetCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small);
        this.CategoryFullIcon.Image = this.CategoryIcon.Image;
        if (this.SubCategoryIcon.Image != null)
        {
            this.CategoryIcon.AgeTransform.PixelOffsetLeft     = -this.CategoryIcon.AgeTransform.Width;
            this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -this.CategoryFullIcon.AgeTransform.Width;
        }
        else
        {
            this.CategoryIcon.AgeTransform.PixelOffsetLeft     = -(0.5f * this.CategoryIcon.AgeTransform.Width);
            this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -(0.5f * this.CategoryFullIcon.AgeTransform.Width);
        }
        this.SubCategoryIcon.Image     = DepartmentOfScience.GetSubCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small);
        this.SubCategoryFullIcon.Image = this.SubCategoryIcon.Image;
        DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, this.empire, this.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
        this.InProgressSector.TintColor = this.InProgressColor;
        this.MarkupGroup.Visible        = false;
        DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();

        DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition);
        this.Refresh(empire, technologyState);
    }
示例#15
0
    public static void TruncateStringWithSubst(string srcKey, string match, string subst, AgePrimitiveLabel label, float maxWidth, out string dest, char truncateChar)
    {
        dest = subst;
        AgeLocalizer.Instance.LocalizeString(srcKey, out AgeUtils.lineString);
        AgeUtils.lineString = AgeUtils.lineString.Replace(match, dest);
        AgeUtils.CleanLine(AgeUtils.lineString, ref AgeUtils.line);
        float num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), label.ForceCaps, false);

        while (num > maxWidth && dest.Length > 1)
        {
            dest = dest.Substring(0, dest.Length - 2) + truncateChar;
            AgeLocalizer.Instance.LocalizeString(srcKey, out AgeUtils.lineString);
            AgeUtils.lineString = AgeUtils.lineString.Replace(match, dest);
            AgeUtils.CleanLine(AgeUtils.lineString, ref AgeUtils.line);
            num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), label.ForceCaps, false);
        }
        dest = AgeUtils.lineString;
    }
    protected override IEnumerator OnShow(params object[] parameters)
    {
        if (this.context == null || !(this.context is CreepingNode))
        {
            base.AgeTransform.Visible = false;
        }
        else
        {
            CreepingNode creepingNode = this.context as CreepingNode;
            this.StatusLabel.Text          = string.Empty;
            base.AgeTransform.Height       = this.StatusLabel.AgeTransform.Height;
            this.DefenseGaugeGroup.Visible = true;
            float life    = creepingNode.Life;
            float maxLife = creepingNode.MaxLife;
            bool  flag    = creepingNode.DismantlingArmy != null;
            float num     = 0f;
            int   num2    = 0;
            float num3    = life;
            float num4    = life;
            if (flag)
            {
                IGameEntity gameEntity;
                if (this.gameEntityRepositoryService.TryGetValue(creepingNode.DismantlingArmyGUID, out gameEntity))
                {
                    Army army = gameEntity as Army;
                    if (army != null)
                    {
                        num = army.GetPropertyValue(SimulationProperties.CreepingNodeDismantlePower);
                    }
                }
                if (num > 0f)
                {
                    num2 = Mathf.CeilToInt(life / num);
                }
                num  *= -1f;
                num3 += num;
                this.DefenseProgress.TintColor = this.DismantlingColor;
                this.StatusLabel.Text          = AgeLocalizer.Instance.LocalizeString("%FeatureDismantleNodeDismantlingStateTitle");
            }
            else
            {
                num = creepingNode.NodeDefinition.GrowthPerTurn;
                if (num > 0f)
                {
                    num2 = Mathf.CeilToInt((maxLife - life) / num);
                }
                num4 += num;
                this.DefenseProgress.TintColor = this.RecoveryColor;
                this.StatusLabel.Text          = AgeLocalizer.Instance.LocalizeString("%FeatureDismantleNodeRecoveringStateTitle");
            }
            AgePrimitiveLabel statusLabel = this.StatusLabel;
            string            text        = statusLabel.Text;
            statusLabel.Text = string.Concat(new string[]
            {
                text,
                " (",
                num2.ToString(),
                AgeLocalizer.Instance.LocalizeString("%TurnSymbol"),
                ")"
            });
            this.DefenseGauge.AgeTransform.PercentRight    = Mathf.Clamp(life / maxLife, 0f, 1f) * 100f;
            this.DefenseProgress.AgeTransform.PercentLeft  = Mathf.Clamp(num3 / maxLife, 0f, 1f) * 100f;
            this.DefenseProgress.AgeTransform.PercentRight = Mathf.Clamp(num4 / maxLife, 0f, 1f) * 100f;
            base.AgeTransform.Height += this.DefenseGaugeGroup.Height;
            if (num3 != maxLife)
            {
                this.DefenseProgress.AgeTransform.Visible = true;
            }
            else
            {
                this.DefenseProgress.AgeTransform.Visible = false;
            }
            if (this.StatusLabel.AgeTransform.PixelMarginTop == this.TitleLabel.AgeTransform.PixelMarginTop)
            {
                this.StatusLabel.AgeTransform.PixelMarginLeft = 2f * this.TitleLabel.AgeTransform.PixelMarginLeft + this.TitleLabel.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.TitleLabel.Text), this.TitleLabel.ForceCaps, false);
            }
        }
        yield return(base.OnShow(parameters));

        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        base.AgeTransform.Visible = (this.StatusLabel.Text != string.Empty && service.IsShared(DownloadableContent20.ReadOnlyName));
        yield break;
    }
示例#17
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;
    }
示例#18
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        Quest quest = this.context as Quest;

        if (quest == null)
        {
            Diagnostics.LogError("Context must be a quest");
            yield break;
        }
        int        num = 0;
        GuiElement guiElement;

        if (base.GuiService.GuiPanelHelper.TryGetGuiElement(quest.Name, out guiElement))
        {
            QuestGuiElement questGuiElement = guiElement as QuestGuiElement;
            this.ObjectiveLabel.AgeTransform.Height = 0f;
            this.ObjectiveLabel.Text = string.Empty;
            if (!this.progressionOnly)
            {
                this.ObjectiveBackground.TintColor = this.DescriptionColor;
                AgePrimitiveLabel objectiveLabel = this.ObjectiveLabel;
                objectiveLabel.Text += AgeLocalizer.Instance.LocalizeString(questGuiElement.Steps[num].Text);
            }
            if (!this.descriptionOnly)
            {
                this.ObjectiveBackground.TintColor = this.ProgressionColor;
                AgePrimitiveLabel objectiveLabel2 = this.ObjectiveLabel;
                objectiveLabel2.Text += quest.GetProgressionString(quest.QuestDefinition.Steps[num].Name);
                if (this.constructibleProgression && quest.QuestState != QuestState.Failed && quest.QuestState != QuestState.Completed)
                {
                    if (this.departmentOfIndustries == null)
                    {
                        IGameService service = Services.GetService <IGameService>();
                        Diagnostics.Assert(service != null && service.Game != null);
                        global::Game game = service.Game as global::Game;
                        this.departmentOfIndustries = new List <DepartmentOfIndustry>();
                        for (int i = 0; i < game.Empires.Length; i++)
                        {
                            global::Empire empire = game.Empires[i];
                            if (empire is MajorEmpire)
                            {
                                DepartmentOfIndustry agency = empire.GetAgency <DepartmentOfIndustry>();
                                if (agency != null)
                                {
                                    this.departmentOfIndustries.Add(agency);
                                }
                            }
                        }
                    }
                    DepartmentOfIndustry.ConstructibleElement constructibleElement = null;
                    if (!this.departmentOfIndustries[0].ConstructibleElementDatabase.TryGetValue(quest.Name.ToString().Replace("Quest", string.Empty), out constructibleElement))
                    {
                        Diagnostics.LogError("Cannot find ConstructibleElement {0}", new object[]
                        {
                            quest.Name.ToString().Replace("Quest", string.Empty)
                        });
                    }
                    else
                    {
                        List <KeyValuePair <float, City> > list = new List <KeyValuePair <float, City> >();
                        KeyValuePair <float, City>         item = default(KeyValuePair <float, City>);
                        for (int j = 0; j < this.departmentOfIndustries.Count; j++)
                        {
                            City         city;
                            Construction construction = this.departmentOfIndustries[j].GetConstruction(constructibleElement, out city);
                            if (construction != null && city != null)
                            {
                                int   num2;
                                float key;
                                float num3;
                                bool  flag;
                                QueueGuiItem.GetConstructionTurnInfos(city, construction, QueueGuiItem.EmptyList, out num2, out key, out num3, out flag);
                                KeyValuePair <float, City> keyValuePair = new KeyValuePair <float, City>(key, city);
                                list.Add(keyValuePair);
                                if (city.Empire.Bits == quest.EmpireBits)
                                {
                                    item = keyValuePair;
                                }
                            }
                        }
                        list.Sort(new Comparison <KeyValuePair <float, City> >(PanelFeatureQuest.ConstructionInProgressInverseSorter));
                        int num4;
                        if (item.Value != null)
                        {
                            num4 = list.IndexOf(item);
                        }
                        else
                        {
                            num4 = list.Count;
                        }
                        if (this.ObjectiveLabel.Text != string.Empty)
                        {
                            AgePrimitiveLabel objectiveLabel3 = this.ObjectiveLabel;
                            objectiveLabel3.Text += "\n";
                        }
                        this.ObjectiveLabel.Text = string.Concat(new object[]
                        {
                            this.ObjectiveLabel.Text,
                            AgeLocalizer.Instance.LocalizeString("%QuestRank"),
                            num4 + 1,
                            "/",
                            this.departmentOfIndustries.Count
                        });
                    }
                }
            }
            if (!string.IsNullOrEmpty(this.ObjectiveLabel.Text))
            {
                this.ObjectiveLabel.AgeTransform.Width = this.DefaultWidth - this.ObjectiveLabel.AgeTransform.PixelMarginLeft - this.ObjectiveLabel.AgeTransform.PixelMarginRight;
                this.ObjectiveLabel.ComputeText();
                this.ObjectiveGroup.Height = this.ObjectiveLabel.Font.LineHeight * (float)this.ObjectiveLabel.TextLines.Count + this.ObjectiveLabel.AgeTransform.PixelMarginTop + this.ObjectiveLabel.AgeTransform.PixelMarginBottom;
                this.ObjectiveBox.Height   = this.ObjectiveGroup.Height + this.ObjectiveGroup.PixelMarginTop + this.ObjectiveGroup.PixelMarginBottom;
            }
            base.AgeTransform.Height = this.ObjectiveBox.Height;
        }
        yield return(base.OnShow(parameters));

        yield break;
    }