Ejemplo n.º 1
0
 public void OnUnitToggle(GameObject obj)
 {
     if (Input.GetKey(KeyCode.Mouse0))
     {
         AgeControlToggle   component = obj.GetComponent <AgeControlToggle>();
         List <UnitGuiItem> children  = this.UnitsTable.GetChildren <UnitGuiItem>(true);
         for (int i = 0; i < children.Count; i++)
         {
             bool flag = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
             if (children[i].UnitToggle == component)
             {
                 if (!flag)
                 {
                     children[i].UnitToggle.State = true;
                 }
             }
             else if (!flag)
             {
                 children[i].UnitToggle.State = false;
             }
         }
         this.ComputeSelection();
         if (this.parent != null)
         {
             this.parent.SendMessage("OnUnitToggle");
             return;
         }
     }
     else
     {
         this.OnELCPRightClick(obj);
     }
 }
Ejemplo n.º 2
0
    private void OnSwitchScoreFilterCB(GameObject gameObject)
    {
        AgeControlToggle component = gameObject.GetComponent <AgeControlToggle>();

        this.CurrentScoreDefinition = (component.OnSwitchDataObject as GameScoreDefinition);
        for (int i = 0; i < this.ScoreFiltersTable.GetChildren().Count; i++)
        {
            ScoreFilterToggle component2 = this.ScoreFiltersTable.GetChildren()[i].GetComponent <ScoreFilterToggle>();
            component2.Toggle.State = (component2.Toggle == component);
        }
        this.RefreshScores();
    }
Ejemplo n.º 3
0
    private void OnActivateDlcCB(GameObject obj)
    {
        AgeControlToggle component    = obj.GetComponent <AgeControlToggle>();
        StaticString     staticString = component.OnSwitchData;

        if (!StaticString.IsNullOrEmpty(staticString) && this.downloadableContentActivationState.ContainsKey(staticString))
        {
            this.downloadableContentActivationState[staticString] = component.State;
            this.modified           = true;
            this.ApplyButton.Enable = true;
        }
    }
 private void ResetToggle(AgeControlToggle t)
 {
     foreach (ScadMod m in mods)
     {
         foreach (BepInExSettingsPacket p in VisibleWrappers)
         {
             if (t.name.Equals(Util.GetName(m, p) + "_Toggle"))
             {
                 t.State = (bool)DefaultWrappers[m][p];
             }
         }
     }
 }
    private void OnHeroToggle(GameObject obj)
    {
        AgeControlToggle component = obj.GetComponent <AgeControlToggle>();
        List <HeroCard>  children  = this.HeroesTable.GetChildren <HeroCard>(true);

        for (int i = 0; i < children.Count; i++)
        {
            children[i].HeroToggle.State = (children[i].HeroToggle == component);
            if (children[i].HeroToggle == component)
            {
                this.CurrentHero = children[i].Hero;
            }
        }
        this.RefreshButtons();
    }
Ejemplo n.º 6
0
    private void OnPopulationControlCB(GameObject obj)
    {
        AgeControlToggle component = obj.GetComponent <AgeControlToggle>();

        if (component.State)
        {
            if (!this.CityWorkersPanel.IsVisible)
            {
                this.CityWorkersPanel.Show(new object[0]);
            }
            else
            {
                this.CityWorkersPanel.RefreshContent();
            }
        }
        else if (this.CityWorkersPanel.IsVisible)
        {
            this.CityWorkersPanel.Hide(false);
        }
        this.BackgroundPopulation.Visible = !component.State;
        this.TotalValuesTable.Visible     = !component.State;
    }
Ejemplo n.º 7
0
 public void OnELCPRightClick(GameObject obj)
 {
     if (!this.IsOtherEmpire)
     {
         AgeControlToggle   component = obj.GetComponent <AgeControlToggle>();
         List <UnitGuiItem> children  = this.UnitsTable.GetChildren <UnitGuiItem>(true);
         int j;
         int i;
         for (i = 0; i < children.Count; i = j + 1)
         {
             if (children[i].UnitToggle == component && children[i].GuiUnit.UnitDesign != null && this.departmentOfDefense.AvailableUnitDesigns.Find((UnitDesign unitDesign) => unitDesign.Model == children[i].GuiUnit.UnitDesign.Model) != null)
             {
                 base.GuiService.GetGuiPanel <UnitDesignModalPanel>().CreateMode = false;
                 base.GuiService.GetGuiPanel <UnitDesignModalPanel>().Show(new object[]
                 {
                     children[i].GuiUnit.UnitDesign
                 });
             }
             j = i;
         }
     }
 }
        internal void CreateToggle(ScadMod m, BepInExSettingsPacket w)
        {
            // I believe the Old Object's parent is a special display component that contains both text and the toggle button
            Debug.Log("Creating Toggle with name: " + Util.GetName(m, w));
            DynData <OptionsPanel> d      = new DynData <OptionsPanel>(optionsPanel);
            GameObject             oldObj = d.Get <AgeControlToggle>("vSyncToggle").transform.parent.gameObject;
            // oldObj is now the group object!

            GameObject toggleGroup = (GameObject)GameObject.Instantiate(oldObj);

            toggleGroup.name = Util.GetName(m, w);
            toggleGroup.transform.SetParent(modSettingsTable.transform);
            Debug.Log("Toggle Group Object Created!");

            Transform toggle = toggleGroup.transform.GetChild(2);

            toggle.gameObject.name = Util.GetName(m, w) + "_Toggle";
            AgeControlToggle toggleControl = toggle.GetComponent <AgeControlToggle>();

            toggleControl.State = ((ConfigWrapper <bool>)w.Wrapper).Value;
            toggle.GetComponent <AgeTooltip>().Content = Util.GetName(m, w);

            Transform label = toggleGroup.transform.GetChild(1);

            label.gameObject.name = Util.GetName(m, w) + "_Label";
            label.GetComponent <AgePrimitiveLabel>().Text = Util.GetName(m, w);

            toggleGroup.GetComponent <AgeTransform>().PixelMarginTop = VisibleWrappers.Count * (settingSpacing + toggleGroup.GetComponent <AgeTransform>().Height);
            Debug.Log("VisibleFields Count: " + VisibleWrappers.Count);
            toggleControl.OnSwitchMethod = "OnTogglePressed";
            toggleControl.OnSwitchObject = transform.gameObject;
            Debug.Log("Switch - Method: " + toggleControl.OnSwitchMethod + " GameObject: " + toggleControl.OnSwitchObject);


            VisibleWrappers.Add(w);
            toggles.Add(toggleControl);
        }
Ejemplo n.º 9
0
 public override void RefreshContent()
 {
     if (Services.GetService <IDownloadableContentService>().IsShared(DownloadableContent16.ReadOnlyName) && this.editableUnitDesign.UnitBodyDefinition.Tags.Contains(DownloadableContent16.TagSeafaring))
     {
         this.ForgeTitle.Text = "%ArsenalPanelTitle";
     }
     else
     {
         this.ForgeTitle.Text = "%ForgePanelTitle";
     }
     this.filter = ForgePanel.ItemCategory.Default;
     for (int i = 0; i < this.FilterTable.GetChildren().Count; i++)
     {
         AgeControlToggle ageControlToggle = this.filterToggles[i];
         if (ageControlToggle.State)
         {
             this.filter |= this.filtersByToggle[ageControlToggle];
         }
     }
     this.filteredItems.Clear();
     this.itemEnableState.Clear();
     if (this.editableUnitDesign != null)
     {
         foreach (ItemDefinition itemDefinition in this.allItems)
         {
             if (!itemDefinition.Hidden)
             {
                 this.failuresFlags.Clear();
                 DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.editableUnitDesign.GetSimulationObject(), itemDefinition, ref this.failuresFlags, new string[]
                 {
                     ConstructionFlags.Prerequisite
                 });
                 if (!this.failuresFlags.Contains(ConstructionFlags.Discard))
                 {
                     bool flag  = this.failuresFlags.Count > 0;
                     bool flag2 = false;
                     int  j     = 0;
                     while (j < itemDefinition.Descriptors.Length)
                     {
                         if (itemDefinition.Descriptors[j].Type == "ItemCategory")
                         {
                             if ((this.filter & ForgePanel.ItemCategory.Weapon) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Weapon);
                             }
                             if (!flag2 && (this.filter & ForgePanel.ItemCategory.Armor) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Armor);
                             }
                             if (!flag2 && (this.filter & ForgePanel.ItemCategory.Accessory) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Accessory);
                                 break;
                             }
                             break;
                         }
                         else
                         {
                             j++;
                         }
                     }
                     if (flag2 && !this.ShowMissingResourceToggle.State)
                     {
                         for (int k = 0; k < itemDefinition.Descriptors.Length; k++)
                         {
                             if (itemDefinition.Descriptors[k].Type == "ItemMaterial")
                             {
                                 this.resourceName = itemDefinition.Descriptors[k].Name;
                                 this.resourceName = this.resourceName.Remove(0, "ItemMaterial".Length);
                                 float num;
                                 if (!this.departmentOfTheTreasury.TryGetResourceStockValue(this.Empire.SimulationObject, this.resourceName, out num, true))
                                 {
                                     num = 1f;
                                 }
                                 if (num < 1f)
                                 {
                                     flag2 = false;
                                 }
                             }
                         }
                     }
                     if (flag2 && !this.ShowObsoleteToggle.State && !itemDefinition.Tags.Contains("NeverObsolete"))
                     {
                         string itemType = string.Empty;
                         string text     = string.Empty;
                         string strA     = string.Empty;
                         itemType = itemDefinition.SubCategory;
                         for (int l = 0; l < itemDefinition.Descriptors.Length; l++)
                         {
                             if (itemDefinition.Descriptors[l].Type == "ItemTier")
                             {
                                 strA = itemDefinition.Descriptors[l].Name;
                             }
                             if (itemDefinition.Descriptors[l].Type == "ItemMaterial")
                             {
                                 text = itemDefinition.Descriptors[l].Name;
                             }
                         }
                         int m = 0;
                         while (m < this.HighestItemTiers.Count)
                         {
                             if (this.HighestItemTiers[m].MatchesTypeAndRessource(itemType, text))
                             {
                                 if (string.Compare(strA, this.HighestItemTiers[m].Tier) < 0)
                                 {
                                     flag2 = false;
                                     break;
                                 }
                                 break;
                             }
                             else
                             {
                                 m++;
                             }
                         }
                     }
                     if (flag2)
                     {
                         this.filteredItems.Add(itemDefinition);
                         this.itemEnableState.Add(!flag);
                     }
                 }
             }
         }
     }
     this.ForgeItemTable.Height = 0f;
     this.ForgeItemTable.ReserveChildren(this.filteredItems.Count, this.ForgeItemPrefab, "Item");
     this.ForgeItemTable.RefreshChildrenIList <ItemDefinition>(this.filteredItems, this.refreshForgeItemDelegate, true, false);
     this.ForgeItemTable.ArrangeChildren();
     base.RefreshContent();
 }
Ejemplo n.º 10
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        this.filter = CityOptionsPanel.OptionCategory.Default;
        for (int i = 0; i < this.FilterTable.GetChildren().Count; i++)
        {
            AgeControlToggle ageControlToggle = this.filterToggles[i];
            if (ageControlToggle.State)
            {
                this.filter |= this.filtersByToggle[ageControlToggle];
            }
        }
        DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>();
        IEnumerable <DepartmentOfIndustry.ConstructibleElement> availableConstructibleElementsAsEnumerable = agency.ConstructibleElementDatabase.GetAvailableConstructibleElementsAsEnumerable(new StaticString[0]);

        this.filteredElement.Clear();
        foreach (DepartmentOfIndustry.ConstructibleElement constructibleElement in availableConstructibleElementsAsEnumerable)
        {
            CityOptionsPanel.OptionCategory optionCategory = CityOptionsPanel.OptionCategory.Buildings;
            if (!(constructibleElement.Category == CampConstructibleActionDefinition.ReadOnlyCategory))
            {
                if (constructibleElement.Category == CityImprovementDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Buildings;
                }
                else if (constructibleElement.Category == CityConstructibleActionDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Buildings;
                }
                else if (constructibleElement.Category == CityImprovementDefinition.ReadOnlyNationalCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Buildings;
                }
                else if (constructibleElement.Category == DistrictImprovementDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Expand;
                }
                else if (constructibleElement.Category == PointOfInterestImprovementDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Expand;
                }
                else if (constructibleElement.Category == UnitDesign.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Unit;
                    if (constructibleElement is UnitDesign && (constructibleElement as UnitDesign).Hidden)
                    {
                        continue;
                    }
                }
                else if (constructibleElement.Category == BoosterGeneratorDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Booster;
                }
                else if (constructibleElement.Category == ConstructibleDistrictDefinition.ReadOnlyCategory)
                {
                    optionCategory = CityOptionsPanel.OptionCategory.Expand;
                }
                if ((optionCategory & this.filter) != CityOptionsPanel.OptionCategory.Default)
                {
                    this.lastFailureFlags.Clear();
                    agency.GetConstructibleState(this.City, constructibleElement, ref this.lastFailureFlags);
                    DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.City, constructibleElement, ref this.lastFailureFlags, new string[]
                    {
                        ConstructionFlags.Disable,
                        ConstructionFlags.Discard
                    });
                    if (!this.lastFailureFlags.Contains(ConstructionFlags.Discard))
                    {
                        if (!this.lastFailureFlags.Contains(ConstructionFlags.Disable) && !this.AuthorizeExpand && optionCategory == CityOptionsPanel.OptionCategory.Expand)
                        {
                            this.lastFailureFlags.Add(ConstructionFlags.Disable);
                        }
                        if (this.City.IsInfected)
                        {
                            Diagnostics.Assert(this.City.LastNonInfectedOwner != null);
                            if (StaticString.IsNullOrEmpty(constructibleElement.SubCategory) || !constructibleElement.SubCategory.Equals(DepartmentOfTheInterior.InfectionAllowedSubcategory))
                            {
                                continue;
                            }
                            if (constructibleElement is CityConstructibleActionDefinition)
                            {
                                CityConstructibleActionDefinition cityConstructibleActionDefinition = constructibleElement as CityConstructibleActionDefinition;
                                if (cityConstructibleActionDefinition.Action.Name == "IntegrateFaction" && (string.IsNullOrEmpty(cityConstructibleActionDefinition.InfectedAffinityConstraint) || !cityConstructibleActionDefinition.InfectedAffinityConstraint.Equals(this.city.LastNonInfectedOwner.Faction.Affinity.Name) || this.City.LastNonInfectedOwner.Faction.GetIntegrationDescriptorsCount() <= 0 || this.departmentOfPlanificationAndDevelopment.HasIntegratedFaction(this.City.LastNonInfectedOwner.Faction)))
                                {
                                    continue;
                                }
                            }
                        }
                        if (constructibleElement is CityConstructibleActionDefinition && (constructibleElement as CityConstructibleActionDefinition).Action.Name == "PurgeTheLand")
                        {
                            bool flag = false;
                            PointOfInterest[] pointOfInterests = this.City.Region.PointOfInterests;
                            for (int j = 0; j < pointOfInterests.Length; j++)
                            {
                                if (pointOfInterests[j].CreepingNodeGUID != GameEntityGUID.Zero)
                                {
                                    IGameEntity gameEntity = null;
                                    if (this.gameEntityRepositoryService.TryGetValue(pointOfInterests[j].CreepingNodeGUID, out gameEntity))
                                    {
                                        CreepingNode creepingNode = gameEntity as CreepingNode;
                                        if (creepingNode != null && creepingNode.Empire.Index != this.City.Empire.Index && !this.departmentOfForeignAffairs.IsFriend(creepingNode.Empire))
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!flag)
                            {
                                continue;
                            }
                        }
                        if (constructibleElement is PointOfInterestImprovementDefinition)
                        {
                            this.CheckPointOfInterestImprovementPrerequisites((PointOfInterestImprovementDefinition)constructibleElement, ref this.lastFailureFlags);
                            if (this.lastFailureFlags.Contains(ConstructionFlags.Discard))
                            {
                                continue;
                            }
                        }
                        this.filteredElement.Add(new CityOptionsPanel.ProductionConstruction(constructibleElement, this.playerControllerRepository.ActivePlayerController.Empire as global::Empire, this.guiSubCategorySorting, this.lastFailureFlags.ToArray()));
                    }
                }
            }
        }
        this.filteredElement.Sort();
        this.OptionsTable.Height = this.optionsTableMinHeight;
        this.OptionsTable.ReserveChildren(this.filteredElement.Count, this.ConstructibleItemPrefab, "Option");
        this.OptionsTable.RefreshChildrenIList <CityOptionsPanel.ProductionConstruction>(this.filteredElement, this.constructibleItemRefreshDelegate, true, false);
        this.OptionsTable.ArrangeChildren();
        this.OptionsScrollview.OnPositionRecomputed();
        this.OptionsTable.Enable = (!this.IsOtherEmpire && this.interactionsAllowed);
    }