/// <summary>
        /// Custom extension method that will add a custom panel to a tab, instead of a default panel.
        /// </summary>
        /// <param name="tabstrip">The tab strip.</param>
        /// <param name="text">The tab name.</param>
        /// <param name="buttonTemplate">The button template.</param>
        /// <param name="panelTemplate">The panel template.</param>
        /// <param name="fillText">Should the button be updated with the tab name?</param>
        /// <returns>The added tab button.</returns>
        public static UIButton AddCustomTab(this UITabstrip tabstrip, string text, UIButton buttonTemplate, UIPanel panelTemplate, bool fillText)
        {
            UIButton button = tabstrip.AddUIComponent <UIButton>();

            button.name  = text;
            button.atlas = tabstrip.atlas;
            if (fillText)
            {
                button.text = text;
            }
            button.group = tabstrip;
            if (buttonTemplate != null)
            {
                button.atlas               = buttonTemplate.atlas;
                button.font                = buttonTemplate.font;
                button.autoSize            = buttonTemplate.autoSize;
                button.size                = buttonTemplate.size;
                button.normalBgSprite      = buttonTemplate.normalBgSprite;
                button.disabledBgSprite    = buttonTemplate.disabledBgSprite;
                button.focusedBgSprite     = buttonTemplate.focusedBgSprite;
                button.hoveredBgSprite     = buttonTemplate.hoveredBgSprite;
                button.pressedBgSprite     = buttonTemplate.pressedBgSprite;
                button.normalFgSprite      = buttonTemplate.normalFgSprite;
                button.disabledFgSprite    = buttonTemplate.disabledFgSprite;
                button.focusedFgSprite     = buttonTemplate.focusedFgSprite;
                button.hoveredFgSprite     = buttonTemplate.hoveredFgSprite;
                button.pressedFgSprite     = buttonTemplate.pressedFgSprite;
                button.useDropShadow       = buttonTemplate.useDropShadow;
                button.dropShadowColor     = buttonTemplate.dropShadowColor;
                button.dropShadowOffset    = buttonTemplate.dropShadowOffset;
                button.useOutline          = buttonTemplate.useOutline;
                button.outlineColor        = buttonTemplate.outlineColor;
                button.outlineSize         = buttonTemplate.outlineSize;
                button.useGradient         = buttonTemplate.useGradient;
                button.bottomColor         = buttonTemplate.bottomColor;
                button.textColor           = buttonTemplate.textColor;
                button.horizontalAlignment = buttonTemplate.horizontalAlignment;
                RectOffset textPadding = buttonTemplate.textPadding;
                button.textPadding = new RectOffset(textPadding.left, textPadding.right, textPadding.top, textPadding.bottom);
            }
            if (tabstrip.tabPages != null)
            {
                string  name  = "Tab " + (tabstrip.tabPages.childCount + 1);
                UIPanel panel = GameObject.Instantiate <UIPanel>(panelTemplate);
                tabstrip.tabPages.AttachUIComponent(panel.gameObject);
                panel.name = name;
                if (!string.IsNullOrEmpty(text))
                {
                    panel.name += " - " + text;
                }
                panel.atlas        = tabstrip.tabPages.atlas;
                panel.anchor       = UIAnchorStyle.All;
                panel.clipChildren = true;
                ReflectionUtils.InvokePrivateMethod(tabstrip.tabPages, "ArrangeTabs");
                tabstrip.tabPages.Invalidate();
            }
            ReflectionUtils.InvokePrivateMethod(tabstrip, "ArrangeTabs");
            tabstrip.Invalidate();
            return(button);
        }
        internal void CreateGraphics()
        {
            try {
                var uiView = UIView.GetAView();
                TextureDB.LoadFavCimsTextures();
                Atlas.LoadAtlasIcons();

                ////////////////////////////////////////////////
                ///////////Favorite Button Manu Panel/////////
                ///////////////////////////////////////////////

                //MainMenuPos = UIView.GetAView().FindUIComponent<UITabstrip> ("MainToolstrip");
                MainMenuPos = UIView.Find <UITabstrip> ("MainToolstrip");

                if (MainMenuPos.Find <FavoritesCimsButton>("FavCimsMenuPanel") != null)
                {
                    FavCimsMenuPanel = MainMenuPos.Find <FavoritesCimsButton>("FavCimsMenuPanel");
                }
                else
                {
                    FavCimsMenuPanel = MainMenuPos.AddUIComponent(typeof(FavoritesCimsButton)) as FavoritesCimsButton;
                }

                ////////////////////////////////////////////////
                ////////////////Favorite Panel////////////////
                ///////////////////////////////////////////////

                FullScreenContainer = UIView.Find <UIPanel> ("FullScreenContainer");
                FavCimsPanel        = FullScreenContainer.AddUIComponent <FavoriteCimsMainPanel> ();
                FavCimsPanel.Hide();

                FullScreenContainer.eventMouseDown += delegate {
                    if (!FavCimsPanel.containsMouse)
                    {
                        FavCimsPanel.SendToBack();
                    }
                    else
                    {
                        FavCimsPanel.BringToFront();
                    }
                };

                ////////////////////////////////////////////////
                ////////////Humans Button & Subscribe///////////
                ///////////////////////////////////////////////

                FavCimsHumanPanel = FullScreenContainer.Find <UIPanel> ("(Library) CitizenWorldInfoPanel");

                if (FavCimsHumanPanel != null)
                {
                    if (FavCimsHumanPanel.GetComponentInChildren <AddToFavButton>() != null)
                    {
                        FavStarButton = FavCimsHumanPanel.GetComponentInChildren <AddToFavButton>();
                    }
                    else
                    {
                        FavStarButton = FavCimsHumanPanel.AddUIComponent(typeof(AddToFavButton)) as AddToFavButton;
                    }
                }

                GenerateFamilyDetailsTpl();
            } catch (Exception e) {
                Debug.Error("OnLoad List Error : " + e.ToString());
            }
        }
        internal void CreateGraphics()
        {
            try {

                var uiView = UIView.GetAView();
                TextureDB.LoadFavCimsTextures();
                Atlas.LoadAtlasIcons();

                ////////////////////////////////////////////////
                ///////////Favorite Button Manu Panel/////////
                ///////////////////////////////////////////////

                //MainMenuPos = UIView.GetAView().FindUIComponent<UITabstrip> ("MainToolstrip");
                MainMenuPos = UIView.Find<UITabstrip> ("MainToolstrip");

                if(MainMenuPos.Find<FavoritesCimsButton>("FavCimsMenuPanel") != null) {
                    FavCimsMenuPanel = MainMenuPos.Find<FavoritesCimsButton>("FavCimsMenuPanel");
                }else{
                    FavCimsMenuPanel = MainMenuPos.AddUIComponent(typeof(FavoritesCimsButton)) as FavoritesCimsButton;
                }

                ////////////////////////////////////////////////
                ////////////////Favorite Panel////////////////
                ///////////////////////////////////////////////

                FullScreenContainer = UIView.Find<UIPanel> ("FullScreenContainer");
                FavCimsPanel = FullScreenContainer.AddUIComponent<FavoriteCimsMainPanel> ();
                FavCimsPanel.Hide ();

                FullScreenContainer.eventMouseDown += delegate {
                    if (!FavCimsPanel.containsMouse) {
                        FavCimsPanel.SendToBack ();
                    } else {
                        FavCimsPanel.BringToFront ();
                    }
                };

                ////////////////////////////////////////////////
                ////////////Humans Button & Subscribe///////////
                ///////////////////////////////////////////////

                FavCimsHumanPanel = FullScreenContainer.Find<UIPanel> ("(Library) CitizenWorldInfoPanel");

                if (FavCimsHumanPanel != null) {
                    if(FavCimsHumanPanel.GetComponentInChildren<AddToFavButton>() != null) {
                        FavStarButton = FavCimsHumanPanel.GetComponentInChildren<AddToFavButton>();
                    }else{
                        FavStarButton = FavCimsHumanPanel.AddUIComponent(typeof(AddToFavButton)) as AddToFavButton;
                    }
                }

                GenerateFamilyDetailsTpl();

            } catch (Exception e) {
                Debug.Error ("OnLoad List Error : " + e.ToString ());
            }
        }
Example #4
0
        public void DrawPloppablePanel()
        {
            if (PloppableButton == null)
            {
                ingame     = Resources.FindObjectsOfTypeAll <UITextureAtlas>().FirstOrDefault(a => a.name == "Ingame");
                thumbnails = Resources.FindObjectsOfTypeAll <UITextureAtlas>().FirstOrDefault(a => a.name == "Thumbnails");

                PloppableButton                  = UIView.GetAView().FindUIComponent <UITabstrip>("MainToolstrip").AddUIComponent <UIButton>(); //main button on in game tool strip.
                PloppableButton.size             = new Vector2(43, 49);
                PloppableButton.eventClick      += PloppablebuttonClicked;
                PloppableButton.normalBgSprite   = "ToolbarIconGroup6Normal";
                PloppableButton.normalFgSprite   = "IconPolicyBigBusiness";
                PloppableButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
                PloppableButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
                PloppableButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
                PloppableButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
                PloppableButton.relativePosition = new Vector2(800, 0);
                PloppableButton.name             = "PloppableButton";
                PloppableButton.tooltip          = "Ploppable RICO";

                BuildingPanel = UIView.GetAView().FindUIComponent("TSContainer").AddUIComponent <UIPanel>(); //this is the base panel.
                BuildingPanel.backgroundSprite = "SubcategoriesPanel";
                BuildingPanel.isVisible        = false;
                BuildingPanel.name             = "PloppableBuildingPanel";
                BuildingPanel.size             = new Vector2(859, 109);
                BuildingPanel.relativePosition = new Vector2(0, 0);

                Tabs                  = UIView.GetAView().FindUIComponent("PloppableBuildingPanel").AddUIComponent <UITabstrip>();
                Tabs.size             = new Vector2(832, 25);
                Tabs.relativePosition = new Vector2(13, -25);
                Tabs.pivot            = UIPivotPoint.BottomCenter;
                Tabs.padding          = new RectOffset(0, 3, 0, 0);

                //var i =

                for (int i = 0; i <= types; i++)
                {
                    BuildingPanels[i]                      = new UIScrollablePanel(); //draw scrollable panels
                    BuildingPanels[i]                      = BuildingPanel.AddUIComponent <UIScrollablePanel>();
                    BuildingPanels[i].size                 = new Vector2(763, 109);
                    BuildingPanels[i].relativePosition     = new Vector2(50, 0);
                    BuildingPanels[i].name                 = Names[i] + "Panel";
                    BuildingPanels[i].isVisible            = false;
                    BuildingPanels[i].autoLayout           = true;
                    BuildingPanels[i].autoLayoutStart      = LayoutStart.BottomLeft;
                    BuildingPanels[i].builtinKeyNavigation = true;
                    BuildingPanels[i].autoLayoutDirection  = LayoutDirection.Horizontal;
                    BuildingPanels[i].clipChildren         = true;
                    BuildingPanels[i].freeScroll           = false;
                    BuildingPanels[i].horizontalScrollbar  = new UIScrollbar();

                    BuildingPanels[i].scrollWheelAmount                   = 109;
                    BuildingPanels[i].horizontalScrollbar.stepSize        = 1f;
                    BuildingPanels[i].horizontalScrollbar.incrementAmount = 109f;
                    BuildingPanels[i].scrollWithArrowKeys                 = true;


                    TabButtons[i]                  = new UIButton(); //draw RICO tabstrip.
                    TabButtons[i]                  = Tabs.AddUIComponent <UIButton>();
                    TabButtons[i].size             = new Vector2(58, 25);
                    TabButtons[i].normalBgSprite   = "SubBarButtonBase";
                    TabButtons[i].disabledBgSprite = "SubBarButtonBaseDisabled";
                    TabButtons[i].pressedBgSprite  = "SubBarButtonBasePressed";
                    TabButtons[i].hoveredBgSprite  = "SubBarButtonBaseHovered";
                    TabButtons[i].focusedBgSprite  = "SubBarButtonBaseFocused";
                    TabButtons[i].state            = UIButton.ButtonState.Normal;
                    //TabButtons[i].isEnabled = enabled;
                    TabButtons[i].name     = Names[i] + "Button";
                    TabButtons[i].tabStrip = true;

                    TabSprites[i] = new UISprite();
                    TabSprites[i] = TabButtons[i].AddUIComponent <UISprite>();

                    if (i <= 5)
                    {
                        TabSprites[i].atlas = thumbnails;
                        SetSprites(TabSprites[i], "Zoning" + Names[i]);
                    }
                    else
                    {
                        SetSprites(TabSprites[i], "IconPolicy" + Names[i]);
                    }
                }

                LeftButton  = BuildingPanel.AddUIComponent <UIButton>();
                RightButton = BuildingPanel.AddUIComponent <UIButton>();

                LeftButton.size  = new Vector2(32, 32);
                RightButton.size = new Vector2(32, 32);

                LeftButton.normalBgSprite   = "ArrowLeft";
                LeftButton.pressedBgSprite  = "ArrowLeftPressed";
                LeftButton.hoveredBgSprite  = "ArrowLeftHovered";
                LeftButton.disabledBgSprite = "ArrowLeftDisabled";

                LeftButton.relativePosition  = new Vector3(16, 33);
                RightButton.relativePosition = new Vector3(812, 33);


                //LeftButton.anchor = UIAnchorStyle.None;

                RightButton.normalBgSprite   = "ArrowRight";
                RightButton.pressedBgSprite  = "ArrowRightPressed";
                RightButton.hoveredBgSprite  = "ArrowRightHovered";
                RightButton.disabledBgSprite = "ArrowRightDisabled";

                currentSelection = BuildingPanels[0];

                RightButton.eventClick += (sender, e) => ArrowClicked(sender, e, currentSelection);
                LeftButton.eventClick  += (sender, e) => ArrowClicked(sender, e, currentSelection);

                if (BuildingPanels[0].childCount > 7)
                {
                    LeftButton.isVisible  = true;
                    RightButton.isVisible = true;
                }
                else
                {
                    LeftButton.isVisible  = false;
                    RightButton.isVisible = false;
                }

                //Couldnt get this to work in the loop.

                TabButtons[0].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[0], TabButtons[0], TabSprites[0]);
                TabButtons[1].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[1], TabButtons[1], TabSprites[1]);
                TabButtons[2].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[2], TabButtons[2], TabSprites[2]);
                TabButtons[3].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[3], TabButtons[3], TabSprites[3]);
                TabButtons[4].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[4], TabButtons[4], TabSprites[4]);
                TabButtons[5].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[5], TabButtons[5], TabSprites[5]);
                TabButtons[6].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[6], TabButtons[6], TabSprites[6]);
                TabButtons[7].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[7], TabButtons[7], TabSprites[7]);
                TabButtons[8].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[8], TabButtons[8], TabSprites[8]);
                TabButtons[9].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[9], TabButtons[9], TabSprites[9]);

                TabButtons[10].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[10], TabButtons[10], TabSprites[10]);
                TabButtons[11].eventClick += (sender, e) => TabClicked(sender, e, BuildingPanels[11], TabButtons[11], TabSprites[11]);

                BuildingPanels[0].isVisible = true; //start with lowres panel visible.

                if (!Util.isADinstalled())
                { //if AD is not installed, hide extra tabs
                    TabButtons[10].isVisible = false;
                    TabButtons[11].isVisible = false;
                }

                UIButton showThemeManager = UIUtils.CreateButton(Tabs);
                showThemeManager.size           = new Vector2(80, 25);
                showThemeManager.normalBgSprite = "SubBarButtonBase";
                showThemeManager.text           = "Settings";
                showThemeManager.eventClick    += (c, p) => RICOSettingsPanel.instance.Toggle();
            }
        }
        /// <summary>
        /// Draws the Ploppable Tool panel.
        /// </summary>
        private void DrawPloppablePanel()
        {
            // Check to make sure that we haven't already done this.
            if (PloppableButton == null)
            {
                // Set state flag; this is a new setup.
                hasShown = false;

                // Main button on ingame toolbar.
                PloppableButton                  = UIView.GetAView().FindUIComponent <UITabstrip>("MainToolstrip").AddUIComponent <UIButton>();
                PloppableButton.size             = new Vector2(43, 49);
                PloppableButton.normalBgSprite   = "ToolbarIconGroup6Normal";
                PloppableButton.normalFgSprite   = "IconPolicyBigBusiness";
                PloppableButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
                PloppableButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
                PloppableButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
                PloppableButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
                PloppableButton.relativePosition = new Vector2(800, 0);
                PloppableButton.name             = "PloppableButton";

                // Event handler - show the Ploppable Tool panel when the button is clicked.
                PloppableButton.eventClick += (component, clickEvent) =>
                {
                    component.Focus();
                    buildingPanel.isVisible = true;
                };

                // Base panel.
                buildingPanel = UIView.GetAView().FindUIComponent("TSContainer").AddUIComponent <UIPanel>();
                buildingPanel.backgroundSprite = "SubcategoriesPanel";
                buildingPanel.isVisible        = false;
                buildingPanel.name             = "PloppableBuildingPanel";
                buildingPanel.size             = new Vector2(859, 109);
                buildingPanel.relativePosition = new Vector2(0, 0);

                // Tabstrip.
                Tabs                  = UIView.GetAView().FindUIComponent("PloppableBuildingPanel").AddUIComponent <UITabstrip>();
                Tabs.size             = new Vector2(832, 25);
                Tabs.relativePosition = new Vector2(13, -25);
                Tabs.pivot            = UIPivotPoint.BottomCenter;
                Tabs.padding          = new RectOffset(0, 3, 0, 0);

                // Get game sprite thumbnail atlas.
                UITextureAtlas gameIconAtlas = Resources.FindObjectsOfTypeAll <UITextureAtlas>().FirstOrDefault(a => a.name == "Thumbnails");

                // Scroll panel.
                AddScrollPanel();

                // Tabs.
                for (int i = 0; i <= NumTypes; i++)
                {
                    // Draw tabs in tabstrip.
                    TabButtons[i]                  = new UIButton();
                    TabButtons[i]                  = Tabs.AddUIComponent <UIButton>();
                    TabButtons[i].size             = new Vector2(46, 25);
                    TabButtons[i].normalBgSprite   = "SubBarButtonBase";
                    TabButtons[i].disabledBgSprite = "SubBarButtonBaseDisabled";
                    TabButtons[i].pressedBgSprite  = "SubBarButtonBasePressed";
                    TabButtons[i].hoveredBgSprite  = "SubBarButtonBaseHovered";
                    TabButtons[i].focusedBgSprite  = "SubBarButtonBaseFocused";
                    TabButtons[i].state            = UIButton.ButtonState.Normal;
                    TabButtons[i].name             = Names[i] + "Button";
                    TabButtons[i].tabStrip         = true;

                    TabSprites[i] = new UISprite();
                    TabSprites[i] = TabButtons[i].AddUIComponent <UISprite>();

                    // Standard "Vanilla" categories (low and high residential, low and high commercial, and offices) - use standard zoning icons from original vanilla release.
                    if (i <= 5)
                    {
                        TabSprites[i].atlas = gameIconAtlas;
                        SetTabSprite(TabSprites[i], "Zoning" + Names[i]);
                    }
                    else
                    {
                        // Other types don't have standard zoning icons; use policy icons instead.
                        SetTabSprite(TabSprites[i], "IconPolicy" + Names[i]);
                    }
                }

                // This can't happen in a loop, because the loop index is undefined after setup has occured (i.e. when the function is actually called).
                TabButtons[0].eventClick += (component, clickEvent) => TabClicked(0, TabSprites[0]);
                TabButtons[1].eventClick += (component, clickEvent) => TabClicked(1, TabSprites[1]);
                TabButtons[2].eventClick += (component, clickEvent) => TabClicked(2, TabSprites[2]);
                TabButtons[3].eventClick += (component, clickEvent) => TabClicked(3, TabSprites[3]);
                TabButtons[4].eventClick += (component, clickEvent) => TabClicked(4, TabSprites[4]);
                TabButtons[5].eventClick += (component, clickEvent) => TabClicked(5, TabSprites[5]);
                TabButtons[6].eventClick += (component, clickEvent) => TabClicked(6, TabSprites[6]);
                TabButtons[7].eventClick += (component, clickEvent) => TabClicked(7, TabSprites[7]);
                TabButtons[8].eventClick += (component, clickEvent) => TabClicked(8, TabSprites[8]);
                TabButtons[9].eventClick += (component, clickEvent) => TabClicked(9, TabSprites[9]);
                // Below are DLC categories - AD for first two, then GC for next 3.  Will be hidden if relevant DLC is not installed.
                TabButtons[10].eventClick += (component, clickEvent) => TabClicked(10, TabSprites[10]);
                TabButtons[11].eventClick += (component, clickEvent) => TabClicked(11, TabSprites[11]);
                TabButtons[12].eventClick += (component, clickEvent) => TabClicked(12, TabSprites[12]);
                TabButtons[13].eventClick += (component, clickEvent) => TabClicked(13, TabSprites[13]);
                TabButtons[14].eventClick += (component, clickEvent) => TabClicked(14, TabSprites[14]);

                // Activate low residential panel to start with (what the user sees on first opening the panel).
                //BuildingPanels[0].isVisible = true;

                // Hide AD tabs if AD is not installed.
                if (!Util.IsADinstalled())
                {
                    TabButtons[10].isVisible = false;
                    TabButtons[11].isVisible = false;
                }

                // Hide GC tabs if GC is not installed.
                if (!Util.IsGCinstalled())
                {
                    TabButtons[12].isVisible = false;
                    TabButtons[13].isVisible = false;
                    TabButtons[14].isVisible = false;
                }

                // Settings tab.
                showSettings                = UIUtils.CreateButton(Tabs);
                showSettings.size           = new Vector2(100, 25);
                showSettings.normalBgSprite = "SubBarButtonBase";
                showSettings.eventClick    += (component, clickEvent) =>
                {
                    SettingsPanel.Open(scrollPanel?.selectedItem?.prefab);
                };

                // Add UI text.
                SetText();


                // Toggle active state on visibility changed if we're using the UI speed boost (deactivating when hidden to minimise UI workload and impact on performance).
                buildingPanel.eventVisibilityChanged += (component, isVisible) =>
                {
                    // Additional check to allow for the case where speedboost has been deactivated mid-game while the panel was deactivated.
                    if ((ModSettings.speedBoost) || (isVisible && !buildingPanel.gameObject.activeSelf))
                    {
                        buildingPanel.gameObject.SetActive(isVisible);
                    }

                    // Other checks.
                    if (isVisible)
                    {
                        // If this is the first time we're visible, set the display to the initial default tab (low residential).
                        if (!hasShown)
                        {
                            // Set initial default tab.
                            TabClicked(0, _instance.TabSprites[0]);

                            // Done!
                            hasShown = true;
                        }
                        else
                        {
                            // Clear previous selection and refresh panel.
                            scrollPanel.selectedItem = null;
                            scrollPanel.Refresh();
                        }
                    }
                    else
                    {
                        // Destroy thumbnail renderer if we're no longer visible.
                        ThumbnailManager.Close();
                    }
                };
            }
        }
        /// <summary>
        /// Draws the Ploppable Tool panel.
        /// </summary>
        private void DrawPloppablePanel()
        {
            // Check to make sure that we haven't already done this.
            if (PloppableButton == null)
            {
                // Main button on ingame toolbar.
                PloppableButton                  = UIView.GetAView().FindUIComponent <UITabstrip>("MainToolstrip").AddUIComponent <UIButton>();
                PloppableButton.size             = new Vector2(43, 49);
                PloppableButton.normalBgSprite   = "ToolbarIconGroup6Normal";
                PloppableButton.normalFgSprite   = "IconPolicyBigBusiness";
                PloppableButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
                PloppableButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
                PloppableButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
                PloppableButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
                PloppableButton.relativePosition = new Vector2(800, 0);
                PloppableButton.name             = "PloppableButton";
                PloppableButton.tooltip          = Translations.Translate("PRR_NAME");

                // Event handler - show the Ploppable Tool panel when the button is clicked.
                PloppableButton.eventClick += (component, clickEvent) =>
                {
                    component.Focus();
                    BuildingPanel.isVisible = true;
                };

                // Base panel.
                BuildingPanel = UIView.GetAView().FindUIComponent("TSContainer").AddUIComponent <UIPanel>();
                BuildingPanel.backgroundSprite = "SubcategoriesPanel";
                BuildingPanel.isVisible        = false;
                BuildingPanel.name             = "PloppableBuildingPanel";
                BuildingPanel.size             = new Vector2(859, 109);
                BuildingPanel.relativePosition = new Vector2(0, 0);

                // Tabstrip.
                Tabs                  = UIView.GetAView().FindUIComponent("PloppableBuildingPanel").AddUIComponent <UITabstrip>();
                Tabs.size             = new Vector2(832, 25);
                Tabs.relativePosition = new Vector2(13, -25);
                Tabs.pivot            = UIPivotPoint.BottomCenter;
                Tabs.padding          = new RectOffset(0, 3, 0, 0);

                // Get game sprite thumbnail atlas.
                UITextureAtlas gameIconAtlas = Resources.FindObjectsOfTypeAll <UITextureAtlas>().FirstOrDefault(a => a.name == "Thumbnails");

                // Scrollable panels.
                for (int i = 0; i <= NumTypes; i++)
                {
                    // Basic setup.
                    BuildingPanels[i]                                     = new UIScrollablePanel();
                    BuildingPanels[i]                                     = BuildingPanel.AddUIComponent <UIScrollablePanel>();
                    BuildingPanels[i].size                                = new Vector2(763, 109);
                    BuildingPanels[i].relativePosition                    = new Vector2(50, 0);
                    BuildingPanels[i].name                                = Names[i] + "Panel";
                    BuildingPanels[i].isVisible                           = false;
                    BuildingPanels[i].autoLayout                          = true;
                    BuildingPanels[i].autoLayoutStart                     = LayoutStart.BottomLeft;
                    BuildingPanels[i].builtinKeyNavigation                = true;
                    BuildingPanels[i].autoLayoutDirection                 = LayoutDirection.Horizontal;
                    BuildingPanels[i].clipChildren                        = true;
                    BuildingPanels[i].freeScroll                          = false;
                    BuildingPanels[i].horizontalScrollbar                 = new UIScrollbar();
                    BuildingPanels[i].scrollWheelAmount                   = 109;
                    BuildingPanels[i].horizontalScrollbar.stepSize        = 1f;
                    BuildingPanels[i].horizontalScrollbar.incrementAmount = 109f;
                    BuildingPanels[i].scrollWithArrowKeys                 = true;

                    // Draw tabs in tabstrip.
                    TabButtons[i]                  = new UIButton();
                    TabButtons[i]                  = Tabs.AddUIComponent <UIButton>();
                    TabButtons[i].size             = new Vector2(46, 25);
                    TabButtons[i].normalBgSprite   = "SubBarButtonBase";
                    TabButtons[i].disabledBgSprite = "SubBarButtonBaseDisabled";
                    TabButtons[i].pressedBgSprite  = "SubBarButtonBasePressed";
                    TabButtons[i].hoveredBgSprite  = "SubBarButtonBaseHovered";
                    TabButtons[i].focusedBgSprite  = "SubBarButtonBaseFocused";
                    TabButtons[i].state            = UIButton.ButtonState.Normal;
                    TabButtons[i].name             = Names[i] + "Button";
                    TabButtons[i].tabStrip         = true;

                    TabSprites[i] = new UISprite();
                    TabSprites[i] = TabButtons[i].AddUIComponent <UISprite>();

                    // Standard "Vanilla" categories (low and high residential, low and high commercial, and offices) - use standard zoning icons from original vanilla release.
                    if (i <= 5)
                    {
                        TabSprites[i].atlas = gameIconAtlas;
                        SetTabSprite(TabSprites[i], "Zoning" + Names[i]);
                    }
                    else
                    {
                        // Other types don't have standard zoning icons; use policy icons instead.
                        SetTabSprite(TabSprites[i], "IconPolicy" + Names[i]);
                    }
                }

                // 'Left' and 'Right' buttons to croll panel.
                LeftButton  = BuildingPanel.AddUIComponent <UIButton>();
                RightButton = BuildingPanel.AddUIComponent <UIButton>();

                LeftButton.size  = new Vector2(32, 32);
                RightButton.size = new Vector2(32, 32);

                LeftButton.normalBgSprite   = "ArrowLeft";
                LeftButton.pressedBgSprite  = "ArrowLeftPressed";
                LeftButton.hoveredBgSprite  = "ArrowLeftHovered";
                LeftButton.disabledBgSprite = "ArrowLeftDisabled";

                LeftButton.relativePosition  = new Vector3(16, 33);
                RightButton.relativePosition = new Vector3(812, 33);

                RightButton.normalBgSprite   = "ArrowRight";
                RightButton.pressedBgSprite  = "ArrowRightPressed";
                RightButton.hoveredBgSprite  = "ArrowRightHovered";
                RightButton.disabledBgSprite = "ArrowRightDisabled";

                // Initialise current selection to first panel.
                currentSelection = BuildingPanels[0];

                // Event handlers.
                RightButton.eventClick += (component, clickEvent) => ArrowClicked(component);
                LeftButton.eventClick  += (component, clickEvent) => ArrowClicked(component);

                // Show left/right scroll buttons if we've got more than seven buttons, otherwise hide.
                if (BuildingPanels[0].childCount > 7)
                {
                    LeftButton.isVisible  = true;
                    RightButton.isVisible = true;
                }
                else
                {
                    LeftButton.isVisible  = false;
                    RightButton.isVisible = false;
                }

                // This can't happen in a loop, because the loop index is undefined after setup has occured (i.e. when the function is actually called).
                TabButtons[0].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[0], TabSprites[0]);
                TabButtons[1].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[1], TabSprites[1]);
                TabButtons[2].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[2], TabSprites[2]);
                TabButtons[3].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[3], TabSprites[3]);
                TabButtons[4].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[4], TabSprites[4]);
                TabButtons[5].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[5], TabSprites[5]);
                TabButtons[6].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[6], TabSprites[6]);
                TabButtons[7].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[7], TabSprites[7]);
                TabButtons[8].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[8], TabSprites[8]);
                TabButtons[9].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[9], TabSprites[9]);
                // Below are DLC categories - AD for first two, then GC for next 3.  Will be hidden if relevant DLC is not installed.
                TabButtons[10].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[10], TabSprites[10]);
                TabButtons[11].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[11], TabSprites[11]);
                TabButtons[12].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[12], TabSprites[12]);
                TabButtons[13].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[13], TabSprites[13]);
                TabButtons[14].eventClick += (component, clickEvent) => TabClicked(BuildingPanels[14], TabSprites[14]);

                // Activate low residential panel to start with (what the user sees on first opening the panel).
                BuildingPanels[0].isVisible = true;

                // Hide AD tabs if AD is not installed.
                if (!Util.isADinstalled())
                {
                    TabButtons[10].isVisible = false;
                    TabButtons[11].isVisible = false;
                }

                // Hide GC tabs if GC is not installed.
                if (!Util.isGCinstalled())
                {
                    TabButtons[12].isVisible = false;
                    TabButtons[13].isVisible = false;
                    TabButtons[14].isVisible = false;
                }

                // Settings tab.
                showSettings                = UIUtils.CreateButton(Tabs);
                showSettings.size           = new Vector2(80, 25);
                showSettings.normalBgSprite = "SubBarButtonBase";
                showSettings.eventClick    += (component, clickEvent) => SettingsPanel.Open();

                // Add UI text.
                SetText();

                // Toggle active state on visibility changed (deactivating when hidden to minimise UI workload and impact on performance).
                BuildingPanel.eventVisibilityChanged += (component, isVisible) =>
                {
                    BuildingPanel.gameObject.SetActive(isVisible);
                };
            }
        }