Example #1
0
        public static void AddTaxControls()
        {
            if (isTaxControlsNotCreated())
            {
                UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");
                if (economyContainer != null)
                {
                    UIPanel taxesPanel = economyContainer.Find <UIPanel>("Taxes");
                    if (taxesPanel != null)
                    {
                        UITaxSetPanel taxSetPanel1 = taxesPanel.AddUIComponent <UITaxSetPanel>();
                        taxSetPanel1.name     = "taxSetPanel1";
                        taxSetPanel1.position = new Vector3(10, -40);
                        taxSetPanel1.TaxValuesStorageIndex = 0;

                        UITaxSetPanel taxSetPanel2 = taxesPanel.AddUIComponent <UITaxSetPanel>();
                        taxSetPanel2.name     = "taxSetPanel2";
                        taxSetPanel2.position = new Vector3(10, -140);
                        taxSetPanel2.TaxValuesStorageIndex = 1;

                        UITaxSetPanel taxSetPanel3 = taxesPanel.AddUIComponent <UITaxSetPanel>();
                        taxSetPanel3.name     = "taxSetPanel3";
                        taxSetPanel3.position = new Vector3(10, -240);
                        taxSetPanel3.TaxValuesStorageIndex = 2;
                    }
                }
            }
        }
        private static void removeControls()
        {
            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel budgetPanel = economyContainer.Find <UIPanel>("Budget");
                if (budgetPanel != null)
                {
                    AutobudgetObjectsContainer c = Singleton <AutobudgetManager> .instance.container;

                    foreach (AutobudgetBase obj in c.AllAutobudgetObjects)
                    {
                        UIPanel container = budgetPanel.Find <UIPanel>(obj.GetEconomyPanelContainerName());
                        if (container != null)
                        {
                            UIPanel budgetItem = container.Find <UIPanel>(obj.GetBudgetItemName());
                            if (budgetItem != null)
                            {
                                string controlName = AutobudgetItemPanel.GetControlNameFromItemName(obj.GetBudgetItemName());
                                AutobudgetItemPanel autobudgetItemControl = budgetItem.Find <AutobudgetItemPanel>(controlName);
                                if (autobudgetItemControl != null)
                                {
                                    budgetItem.RemoveUIComponent(autobudgetItemControl);
                                    Component.Destroy(autobudgetItemControl);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        //private bool isInitialized = false;
        //private TaxMultiplierPanel taxMultiplierPanel = null;

        public void Init()
        {
            if (isTaxControlsNotCreated())
            {
                UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");
                if (economyContainer != null)
                {
                    UIPanel taxesPanel = economyContainer.Find <UIPanel>("Taxes");
                    if (taxesPanel != null)
                    {
                        //GameObject obj = new GameObject("TaxMultiplierPanel");
                        //obj.transform.parent = UIView.GetAView().cachedTransform;
                        TaxMultiplierPanel taxMultiplierPanel = taxesPanel.AddUIComponent <TaxMultiplierPanel>();
                        taxMultiplierPanel.name     = "TaxMultiplierPanel";
                        taxMultiplierPanel.position = new Vector3(10, -475);
                    }
                }
            }

            //if (isInitialized) return;

            //UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find<UITabContainer>("EconomyContainer");
            //if (economyContainer != null)
            //{
            //    UIPanel taxesPanel = economyContainer.Find<UIPanel>("Taxes");

            //    if (taxesPanel != null)
            //    {
            //        taxesPanel.eventVisibilityChanged += BudgetPanel_eventVisibilityChanged;
            //        isInitialized = true;
            //    }
            //}
        }
        private static UIPanel getBudgetPanel()
        {
            if (ToolsModifierControl.economyPanel != null)
            {
                UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");
                if (economyContainer != null)
                {
                    return(economyContainer.Find <UIPanel>("Budget"));
                }
            }

            return(null);
        }
Example #5
0
        private static bool isTaxControlsNotCreated()
        {
            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel taxesPanel = economyContainer.Find <UIPanel>("Taxes");
                if (taxesPanel != null)
                {
                    return(taxesPanel.Find <UITaxSetPanel>("taxSetPanel1") == null);
                }
            }

            return(true);
        }
        private static bool isAutobudgetItemControlsCreated()
        {
            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel budgetPanel = economyContainer.Find <UIPanel>("Budget");
                if (budgetPanel != null)
                {
                    AutobudgetBase obj         = Singleton <AutobudgetManager> .instance.container.AllAutobudgetObjects[0];
                    string         controlName = AutobudgetItemPanel.GetControlNameFromItemName(obj.GetBudgetItemName());
                    if (budgetPanel.Find <UIPanel>(controlName) != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public static void Init()
        {
            if (isInitialized)
            {
                return;
            }

            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel budgetPanel = economyContainer.Find <UIPanel>("Budget");

                if (budgetPanel != null)
                {
                    budgetPanel.eventVisibilityChanged += BudgetPanel_eventVisibilityChanged;
                    isInitialized = true;
                }
            }
        }
        public static void ResetUI()
        {
            if (!isInitialized)
            {
                return;
            }

            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel budgetPanel = economyContainer.Find <UIPanel>("Budget");

                if (budgetPanel != null)
                {
                    budgetPanel.eventVisibilityChanged -= BudgetPanel_eventVisibilityChanged;
                    isInitialized = false;
                }
            }

            removeControls();
        }
        private static void createControls()
        {
            UITabContainer economyContainer = ToolsModifierControl.economyPanel.component.Find <UITabContainer>("EconomyContainer");

            if (economyContainer != null)
            {
                UIPanel budgetPanel = economyContainer.Find <UIPanel>("Budget");
                if (budgetPanel != null)
                {
                    AutobudgetObjectsContainer c = Singleton <AutobudgetManager> .instance.container;

                    foreach (AutobudgetBase obj in c.AllAutobudgetObjects)
                    {
                        UIPanel container = budgetPanel.Find <UIPanel>(obj.GetEconomyPanelContainerName());
                        if (container != null)
                        {
                            UIPanel budgetItem = container.Find <UIPanel>(obj.GetBudgetItemName());
                            if (budgetItem != null)
                            {
                                AutobudgetItemPanel autobudgetPanel = budgetItem.AddUIComponent <AutobudgetItemPanel>();
                                autobudgetPanel.SetName(obj.GetBudgetItemName());
                                autobudgetPanel.isChecked = obj.Enabled;
                                autobudgetPanel.SetCheckCallback(delegate(bool isChecked)
                                {
                                    if (!freezeUI)
                                    {
                                        obj.Enabled = isChecked;
                                        Mod.UpdateUI();
                                    }
                                });
                            }
                        }
                    }
                }
            }
        }