Example #1
0
 // Logs lots of information about a given AgeTransform (in order to resolve issues with alignment)
 public static void LogVariousAgeTransformInfo(AgeTransform trans)
 {
     Debug.Log("========================================== LOG FOR: " + trans.name + " ==========================================");
     Debug.Log("Anchored: " + trans.Anchored);
     Debug.Log("Attach Bottom: " + trans.AttachBottom);
     Debug.Log("Attach Left: " + trans.AttachLeft);
     Debug.Log("Attach Right: " + trans.AttachRight);
     Debug.Log("Attach Top: " + trans.AttachTop);
     Debug.Log("AutoResizeHeight: " + trans.AutoResizeHeight);
     Debug.Log("AutoResizeWidth: " + trans.AutoResizeWidth);
     Debug.Log("ChildHeight: " + trans.ChildHeight);
     Debug.Log("ChildWidth: " + trans.ChildWidth);
     Debug.Log("ChildComparer: " + trans.ChildrenComparer);
     Debug.Log("FixedSize: " + trans.FixedSize);
     trans.ComputeGlobalPosition(out Rect temp);
     Debug.Log("GlobalPosition: " + temp);
     Debug.Log("DirtyPosition: " + trans.DirtyPosition);
     Debug.Log("RenderedPosition: " + trans.GetRenderedPosition());
     Debug.Log("HasModifiers: " + trans.HasModifiers);
     Debug.Log("Height: " + trans.Height);
     Debug.Log("HorizontalMargin: " + trans.HorizontalMargin);
     Debug.Log("HorizontalSpacing: " + trans.HorizontalSpacing);
     Debug.Log("ModifiersRunning: " + trans.ModifiersRunning);
     Debug.Log("NoOverroll: " + trans.NoOverroll);
     Debug.Log("Percent Bottom: " + trans.PercentBottom);
     Debug.Log("Percent Left: " + trans.PercentLeft);
     Debug.Log("Percent Right: " + trans.PercentRight);
     Debug.Log("Percent Top: " + trans.PercentTop);
     Debug.Log("PivotMode: " + trans.PivotMode);
     Debug.Log("PivotOffset: " + trans.PivotOffset);
     Debug.Log("PixelMarginBottom: " + trans.PixelMarginBottom);
     Debug.Log("PixelMarginLeft: " + trans.PixelMarginLeft);
     Debug.Log("PixelMarginRight: " + trans.PixelMarginRight);
     Debug.Log("PixelMarginTop: " + trans.PixelMarginTop);
     Debug.Log("PixelOffsetBottom: " + trans.PixelOffsetBottom);
     Debug.Log("PixelOffsetLeft: " + trans.PixelOffsetLeft);
     Debug.Log("PixelOffsetRight: " + trans.PixelOffsetRight);
     Debug.Log("PixelOffsetTop: " + trans.PixelOffsetTop);
     Debug.Log("Position: " + trans.Position);
     Debug.Log("PropagateDirty: " + trans.PropagateDirty);
     Debug.Log("TableArrangement: " + trans.TableArrangement);
     Debug.Log("Tag: " + trans.tag);
     Debug.Log("TiltAngle: " + trans.TiltAngle);
     Debug.Log("UniformScale: " + trans.UniformScale);
     Debug.Log("VerticalMargin: " + trans.VerticalMargin);
     Debug.Log("VerticalSpacing: " + trans.VerticalSpacing);
     Debug.Log("Visible: " + trans.Visible);
     Debug.Log("Width: " + trans.Width);
     Debug.Log("X: " + trans.X);
     Debug.Log("Y: " + trans.Y);
     Debug.Log("Z: " + trans.Z);
     Debug.Log("Children Count: " + trans.GetChildren().Count);
     foreach (AgeTransform t in trans.GetChildren())
     {
         Debug.Log("- " + t.transform);
     }
     Debug.Log("====================================================================================");
 }
    protected override IEnumerator OnLoadGame()
    {
        yield return(base.OnLoadGame());

        this.playerControllerRepository = base.Game.Services.GetService <IPlayerControllerRepositoryService>();
        this.valuesFIDS = new List <AgePrimitiveLabel>();
        this.typesFIDS  = new List <StaticString>();
        this.typesFIDS.Add(SimulationProperties.DistrictFood);
        this.typesFIDS.Add(SimulationProperties.DistrictIndustry);
        this.typesFIDS.Add(SimulationProperties.DistrictScience);
        this.typesFIDS.Add(SimulationProperties.DistrictDust);
        this.typesFIDS.Add(SimulationProperties.DistrictCityPoint);
        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            GuiElement guiElement;
            base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement);
            if (guiElement != null)
            {
                ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement;
                if (i < this.TotalValuesTable.GetChildren().Count)
                {
                    AgeTransform element = this.TotalValuesTable.GetChildren()[i];
                    for (int j = 0; j < element.GetChildren().Count; j++)
                    {
                        AgeTransform child = element.GetChildren()[j];
                        if (child.name == "1Symbol")
                        {
                            Texture2D texture;
                            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out texture))
                            {
                                child.GetComponent <AgePrimitiveImage>().Image     = texture;
                                child.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color;
                            }
                        }
                        else if (child.name == "2Value")
                        {
                            this.valuesFIDS.Add(child.GetComponent <AgePrimitiveLabel>());
                            child.GetComponent <AgePrimitiveLabel>().TintColor = extendedGuiElement.Color;
                        }
                    }
                }
            }
        }
        Diagnostics.Assert(this.typesFIDS.Count == this.valuesFIDS.Count, "CREEPING NODE INFO PANEL : Invalid number of value FIDS");
        for (int k = 0; k < this.valuesFIDS.Count; k++)
        {
            if (this.valuesFIDS[k].AgeTransform.AgeTooltip == null)
            {
                break;
            }
            this.valuesFIDS[k].AgeTransform.AgeTooltip.Class      = "FIDS";
            this.valuesFIDS[k].AgeTransform.AgeTooltip.Content    = this.typesFIDS[k];
            this.valuesFIDS[k].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(this.typesFIDS[k], this.typesFIDS[k], null);
        }
        yield break;
    }
    public void Bind(Fortress fortress)
    {
        GuiElement guiElement = null;

        this.Fortress = fortress;
        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement, this.Fortress.Occupant.Faction.Name);
            if (guiElement != null)
            {
                ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement;
                if (i < this.TotalValuesTable.GetChildren().Count)
                {
                    AgeTransform ageTransform = this.TotalValuesTable.GetChildren()[i];
                    for (int j = 0; j < ageTransform.GetChildren().Count; j++)
                    {
                        AgeTooltip component = ageTransform.GetComponent <AgeTooltip>();
                        if (component != null)
                        {
                            component.Class   = "Simple";
                            component.Content = extendedGuiElement.Description;
                        }
                        AgeTransform ageTransform2 = ageTransform.GetChildren()[j];
                        if (ageTransform2.name == "1Symbol")
                        {
                            Texture2D image;
                            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
                            {
                                ageTransform2.GetComponent <AgePrimitiveImage>().Image     = image;
                                ageTransform2.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color;
                            }
                            break;
                        }
                    }
                }
            }
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.valuesFIDS[i].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.Fortress;
            }
        }
        IGameService service = Services.GetService <IGameService>();

        this.PlayerController       = service.Game.Services.GetService <IPlayerControllerRepositoryService>().ActivePlayerController;
        this.updateFacilityDelegate = new AgeTransform.RefreshTableItem <PointOfInterest>(this.UpdateFacility);
    }
Example #4
0
    protected override IEnumerator OnLoad()
    {
        yield return(base.OnLoad());

        base.UseRefreshLoop = true;
        this.valuesFIDS     = new List <AgePrimitiveLabel>();
        this.deltaFIDS      = new List <AgePrimitiveLabel>();
        this.workersFIDS    = new List <AgePrimitiveLabel>();
        this.previousFIDS   = new List <float>();
        this.typesFIDS      = new List <StaticString>();
        this.typesFIDS.Add(SimulationProperties.NetCityGrowth);
        this.typesFIDS.Add(SimulationProperties.NetCityProduction);
        this.typesFIDS.Add(SimulationProperties.NetCityResearch);
        this.typesFIDS.Add(SimulationProperties.NetCityMoney);
        this.typesFIDS.Add(SimulationProperties.NetCityEmpirePoint);
        this.workerTypes = new List <StaticString>();
        this.workerTypes.Add(SimulationProperties.FoodPopulation);
        this.workerTypes.Add(SimulationProperties.IndustryPopulation);
        this.workerTypes.Add(SimulationProperties.SciencePopulation);
        this.workerTypes.Add(SimulationProperties.DustPopulation);
        this.workerTypes.Add(SimulationProperties.CityPointPopulation);
        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            GuiElement guiElement;
            base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement);
            if (guiElement != null)
            {
                ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement;
                if (i < this.TotalValuesTable.GetChildren().Count)
                {
                    AgeTransform element = this.TotalValuesTable.GetChildren()[i];
                    for (int j = 0; j < element.GetChildren().Count; j++)
                    {
                        AgeTransform child = element.GetChildren()[j];
                        if (child.name == "1Symbol")
                        {
                            Texture2D texture;
                            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out texture))
                            {
                                child.GetComponent <AgePrimitiveImage>().Image     = texture;
                                child.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color;
                            }
                        }
                        else if (child.name == "2Value")
                        {
                            this.valuesFIDS.Add(child.GetComponent <AgePrimitiveLabel>());
                            child.GetComponent <AgePrimitiveLabel>().TintColor = extendedGuiElement.Color;
                        }
                        else if (child.name == "3Modifier")
                        {
                            this.deltaFIDS.Add(child.GetComponent <AgePrimitiveLabel>());
                        }
                        else if (child.name == "5PopulationValue")
                        {
                            this.workersFIDS.Add(child.GetComponent <AgePrimitiveLabel>());
                        }
                    }
                }
            }
            this.previousFIDS.Add(0f);
        }
        Diagnostics.Assert(this.typesFIDS.Count == this.valuesFIDS.Count, "CITY INFO PANEL : Invalid number of value FIDS");
        Diagnostics.Assert(this.deltaFIDS.Count == this.valuesFIDS.Count, "CITY INFO PANEL : Invalid number of delta FIDS");
        this.CityWorkersPanel.Load();
        base.GuiService.GetGuiPanel <CityManagementPanel>().Load();
        for (int k = 0; k < this.valuesFIDS.Count; k++)
        {
            if (this.valuesFIDS[k].AgeTransform.AgeTooltip == null)
            {
                break;
            }
            this.valuesFIDS[k].AgeTransform.AgeTooltip.Class      = "FIDS";
            this.valuesFIDS[k].AgeTransform.AgeTooltip.Content    = this.typesFIDS[k];
            this.valuesFIDS[k].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(this.typesFIDS[k], GuiSimulation.Instance.FIMSTooltipTotal[k], this.City);
        }
        if (this.ApprovalGaugeTooltip.AgeTooltip != null)
        {
            this.ApprovalGaugeTooltip.AgeTooltip.Class      = "FIDS";
            this.ApprovalGaugeTooltip.AgeTooltip.Content    = "none";
            this.ApprovalGaugeTooltip.AgeTooltip.ClientData = new SimulationPropertyTooltipData(SimulationProperties.NetCityApproval, string.Format("{0},{1},!{2}", SimulationProperties.NetCityApproval, SimulationProperties.CityApproval, SimulationProperties.CityApprovalUpkeep), this.City);
        }
        if (this.ApprovalState.AgeTransform.AgeTooltip != null)
        {
            this.ApprovalState.AgeTransform.AgeTooltip.Class      = "Descriptor";
            this.ApprovalState.AgeTransform.AgeTooltip.ClientData = this.City;
        }
        if (this.GaugePopulationTooltip.AgeTooltip != null)
        {
            this.GaugePopulationTooltip.AgeTooltip.Class      = "CityGrowth";
            this.GaugePopulationTooltip.AgeTooltip.Content    = "none";
            this.GaugePopulationTooltip.AgeTooltip.ClientData = new SimulationPropertyTooltipData(SimulationProperties.NetCityGrowth, string.Format("{0},{1},!{2}", SimulationProperties.WorkedFood, SimulationProperties.CityGrowth, SimulationProperties.CityGrowthUpkeep), this.City);
        }
        if (this.PopulationCountGroup != null && this.PopulationCountGroup.AgeTooltip != null)
        {
            this.PopulationCountGroup.AgeTooltip.Class      = "Population";
            this.PopulationCountGroup.AgeTooltip.Content    = "Population";
            this.PopulationCountGroup.AgeTooltip.ClientData = new SimulationPropertyTooltipData(SimulationProperties.Workers, SimulationProperties.Workers, this.City);
        }
        yield break;
    }
Example #5
0
    public void Bind(City city)
    {
        GuiElement guiElement = null;

        this.City = city;
        this.DepartmentOfScience     = this.City.Empire.GetAgency <DepartmentOfScience>();
        this.DepartmentOfTheTreasury = this.City.Empire.GetAgency <DepartmentOfTheTreasury>();
        base.GuiService.GetGuiPanel <CityManagementPanel>().Bind(this.City);
        this.CityWorkersPanel.Bind(this.City);
        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement, this.City.Empire.Faction.Name);
            if (guiElement != null)
            {
                ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement;
                if (i < this.TotalValuesTable.GetChildren().Count)
                {
                    AgeTransform ageTransform = this.TotalValuesTable.GetChildren()[i];
                    for (int j = 0; j < ageTransform.GetChildren().Count; j++)
                    {
                        AgeTooltip component = ageTransform.GetComponent <AgeTooltip>();
                        if (component != null)
                        {
                            component.Class   = "Simple";
                            component.Content = extendedGuiElement.Description;
                        }
                        AgeTransform ageTransform2 = ageTransform.GetChildren()[j];
                        if (ageTransform2.name == "1Symbol")
                        {
                            Texture2D image;
                            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
                            {
                                ageTransform2.GetComponent <AgePrimitiveImage>().Image     = image;
                                ageTransform2.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color;
                            }
                            break;
                        }
                    }
                }
            }
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.valuesFIDS[i].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.City;
            }
        }
        for (int k = 0; k < this.typesFIDS.Count; k++)
        {
            this.previousFIDS[k] = this.City.GetPropertyValue(this.typesFIDS[k]);
            if (k < this.valuesFIDS.Count)
            {
                this.valuesFIDS[k].Text = GuiFormater.FormatGui(this.previousFIDS[k], false, true, false, 1);
            }
        }
        if (this.ApprovalGaugeTooltip.AgeTooltip != null)
        {
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.ApprovalGaugeTooltip.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.City;
            }
        }
        if (this.ApprovalState.AgeTransform.AgeTooltip != null)
        {
            this.ApprovalState.AgeTransform.AgeTooltip.ClientData = this.City;
        }
        if (this.GaugePopulationTooltip.AgeTooltip != null)
        {
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.GaugePopulationTooltip.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.City;
            }
        }
        if (this.PopulationCountGroup != null && this.PopulationCountGroup.AgeTooltip != null)
        {
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.PopulationCountGroup.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.City;
            }
        }
        CityInfoPanel.ShowHidePopulationBuyoutButton(this.playerControllerRepository.ActivePlayerController.Empire, this.City, this.PopulationBuyoutButton.AgeTransform, this.GaugePopulationBackground, this.NextPopulationTurns.AgeTransform, this.NextPopulationHourglass, this.GaugePopulationTooltip);
        CityInfoPanel.ShowHidePopulationSacrificeButton(this.playerControllerRepository.ActivePlayerController.Empire, this.DepartmentOfScience, this.PopulationSacrificeButton);
    }
    public void Bind(City city)
    {
        if (this.City != null)
        {
            this.Unbind();
        }
        this.City              = city;
        this.Empire            = this.City.Empire;
        this.Empire.Refreshed += this.Simulation_Refreshed;
        this.IsOtherEmpire     = (this.playerControllerRepository.ActivePlayerController.Empire != this.Empire);
        DepartmentOfIndustry agency = this.Empire.GetAgency <DepartmentOfIndustry>();

        this.ConstructionQueue = agency.GetConstructionQueue(this.City);
        base.GuiService.GetGuiPanel <QueueDragPanel>().Bind(this.City);
        base.GuiService.GetGuiPanel <QueueDragPanel>().CancelDrag();
        if (this.ConstructionQueue != null)
        {
            this.constructions = this.ConstructionQueue.PendingConstructions;
            this.ConstructionQueue.CollectionChanged += this.ConstructionQueue_CollectionChanged;
        }
        else
        {
            this.constructions = new List <Construction>().AsReadOnly();
        }
        GuiElement guiElement = null;

        for (int i = 0; i < this.typesFIDS.Count; i++)
        {
            base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement, this.City.Empire.Faction.Name);
            if (guiElement != null)
            {
                ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement;
                if (i < this.TotalValuesTable.GetChildren().Count)
                {
                    AgeTransform ageTransform = this.TotalValuesTable.GetChildren()[i];
                    for (int j = 0; j < ageTransform.GetChildren().Count; j++)
                    {
                        AgeTooltip component = ageTransform.GetComponent <AgeTooltip>();
                        if (component != null)
                        {
                            component.Class   = "Simple";
                            component.Content = extendedGuiElement.Description;
                        }
                        AgeTransform ageTransform2 = ageTransform.GetChildren()[j];
                        if (ageTransform2.name == "1Symbol")
                        {
                            Texture2D image;
                            if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
                            {
                                ageTransform2.GetComponent <AgePrimitiveImage>().Image     = image;
                                ageTransform2.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color;
                            }
                            break;
                        }
                    }
                }
            }
            SimulationPropertyTooltipData simulationPropertyTooltipData = this.valuesFIDS[i].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData;
            if (simulationPropertyTooltipData != null)
            {
                simulationPropertyTooltipData.Context = this.City;
            }
        }
        this.GuiEmpire = new GuiEmpire(this.City.Empire);
        if (this.GuiEmpire != null)
        {
            this.OwnerFactionIconSmall.TintColor = this.GuiEmpire.Color;
            this.OwnerFactionIconSmall.Image     = this.GuiEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoLarge, true);
        }
        this.GuiPreviousEmpire = new GuiEmpire(this.City.LastNonInfectedOwner);
        if (this.GuiPreviousEmpire != null)
        {
            this.IntegratedFactionIconLarge.Image = this.GuiPreviousEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoLarge, true);
            this.LastOwnerCityFactionTitle.Text   = this.GuiPreviousEmpire.Empire.Faction.LocalizedName;
        }
        this.IntegratedFactionIconTooltip.Class                      = "Descriptor";
        this.IntegratedFactionIconTooltip.ClientData                 = this.City.Empire;
        this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Class      = "Descriptor";
        this.IntegratedTraitTitle.AgeTransform.AgeTooltip.ClientData = this.City.Empire;
        Faction faction = this.City.LastNonInfectedOwner.Faction;

        if (faction != null)
        {
            List <string> list = new List <string>();
            foreach (SimulationDescriptor simulationDescriptor in faction.GetIntegrationDescriptors())
            {
                this.IntegratedFactionIconTooltip.Content = simulationDescriptor.Name;
                this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Content = simulationDescriptor.Name;
                if (base.GuiService.GuiPanelHelper.TryGetGuiElement(simulationDescriptor.Name, out guiElement))
                {
                    this.IntegratedTraitTitle.Text = "\\7765\\ " + AgeLocalizer.Instance.LocalizeString(guiElement.Title);
                }
            }
        }
        if (faction.Affinity.Name == this.City.Empire.Faction.Affinity.Name)
        {
            this.IntegratedTraitTitle.Text = "%OCPanelIntegratedFactionSameAffinityTitle";
            this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Class      = string.Empty;
            this.IntegratedTraitTitle.AgeTransform.AgeTooltip.ClientData = null;
            this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Content    = "%OCPanelIntegratedFactionSameAffinityTooltip";
            this.IntegratedFactionIconTooltip.Class      = string.Empty;
            this.IntegratedFactionIconTooltip.ClientData = null;
            this.IntegratedFactionIconTooltip.Content    = "%OCPanelIntegratedFactionSameAffinityTooltip";
        }
        bool enable = false;

        this.ActionToogle.AgeTransform.Enable = enable;
        this.ActionToogle.AgeTransform.Alpha  = ((!this.ActionToogle.AgeTransform.Enable) ? 0.5f : 1f);
        this.ModifierSector.GetComponent <AgePrimitiveSector>().MaxAngle = 0f;
        this.ModifierSector.Reset();
    }