public override void Start()
        {
            base.Start();

            backgroundSprite = "UnlockingPanel2";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            clipChildren     = true;
            width            = 450;
            height           = 200;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Warning";
            m_title.iconSprite = "ToolbarIconZoomOutCity";
            m_title.isModal    = true;

            // Icon
            m_warningIcon                  = AddUIComponent <UISprite>();
            m_warningIcon.size             = new Vector2(90, 90);
            m_warningIcon.spriteName       = "IconWarning";
            m_warningIcon.relativePosition = new Vector3(5, m_title.height + (height - m_title.height - 40 - m_warningIcon.height) / 2);

            // Message
            m_messageLabel       = AddUIComponent <UILabel>();
            m_messageLabel.width = width - m_warningIcon.width - 15;

            message = m_message;

            // Ok
            m_ok                  = UIUtils.CreateButton(this);
            m_ok.text             = "OK";
            m_ok.relativePosition = new Vector3((width - m_ok.width) / 2, height - m_ok.height - 5);

            m_ok.eventClick += (c, p) =>
            {
                UIView.PopModal();
                Hide();
            };

            isVisible = true;
        }
        private void SetupControls()
        {
            if (m_noOption != null)
            {
                return;
            }

            // No option available
            m_noOption           = AddUIComponent <UILabel>();
            m_noOption.textScale = 0.9f;
            m_noOption.text      = "No option available";

            // Include
            m_include           = UIUtils.CreateCheckBox(this);
            m_include.text      = "Include";
            m_include.isVisible = false;

            m_include.eventCheckChanged += (c, state) =>
            {
                UIThemeManager.instance.ChangeBuildingStatus(m_item, state);
                Show(m_item);
            };

            // Spawn rate
            UIPanel spawnRatePanel = AddUIComponent <UIPanel>();

            spawnRatePanel.height    = 25;
            spawnRatePanel.isVisible = false;

            UILabel spawnRateLabel = spawnRatePanel.AddUIComponent <UILabel>();

            spawnRateLabel.textScale        = 0.9f;
            spawnRateLabel.text             = "Spawn rate:";
            spawnRateLabel.relativePosition = new Vector3(0, 5);

            m_spawnRate                  = UIUtils.CreateTextField(spawnRatePanel);
            m_spawnRate.size             = new Vector2(60, 25);
            m_spawnRate.padding          = new RectOffset(6, 6, 6, 0);
            m_spawnRate.numericalOnly    = true;
            m_spawnRate.tooltip          = "The higher the number, the more the building is likely to spawn.\nDefault value is 10. Maximum value is 100.";
            m_spawnRate.relativePosition = new Vector3(width - 70, 0);

            m_spawnRate.eventTextSubmitted += (c, s) =>
            {
                int spawnRate;
                if (int.TryParse(m_spawnRate.text, out spawnRate))
                {
                    UIThemeManager.instance.ChangeSpawnRate(spawnRate);
                }
                m_spawnRate.text = m_item.building.spawnRate.ToString();
            };

            // Upgrade Name
            UIPanel upgradeNamePanel = AddUIComponent <UIPanel>();

            upgradeNamePanel.height    = 50;
            upgradeNamePanel.isVisible = false;

            UILabel upgradeNameLabel = upgradeNamePanel.AddUIComponent <UILabel>();

            upgradeNameLabel.textScale        = 0.9f;
            upgradeNameLabel.text             = "Upgrade:";
            upgradeNameLabel.relativePosition = new Vector3(0, 5);

            m_upgradeName                  = UIUtils.CreateTextField(upgradeNamePanel);
            m_upgradeName.size             = new Vector2(width - 10, 25);
            m_upgradeName.padding          = new RectOffset(6, 6, 6, 0);
            m_upgradeName.tooltip          = "Name of the building to spawn when upgraded.\nLeave empty for random spawn.";
            m_upgradeName.relativePosition = new Vector3(0, 25);

            m_upgradeName.eventMouseEnter += (c, p) =>
            {
                if (!m_upgradeName.hasFocus && m_upgradeBuilding != null)
                {
                    UIThemeManager.instance.buildingPreview.Show(m_upgradeBuilding);
                }
            };

            m_upgradeName.eventMouseLeave += (c, p) =>
            {
                UIThemeManager.instance.buildingPreview.Show(m_item);
            };

            m_upgradeName.eventEnterFocus += (c, p) =>
            {
                if (!m_upgradeName.text.IsNullOrWhiteSpace())
                {
                    ShowDropDown();
                }
            };

            m_upgradeName.eventTextChanged += (c, name) =>
            {
                if (m_upgradeName.hasFocus && !name.IsNullOrWhiteSpace())
                {
                    ShowDropDown();
                }
            };

            m_upgradeName.eventTextSubmitted += (c, name) =>
            {
                if (m_dropDownList == null || !m_dropDownList.isVisible)
                {
                    UIThemeManager.instance.ChangeUpgradeBuilding(null);
                }
                else
                {
                    HideDropDown();
                }

                Show(m_item);
            };

            var constructionPanel = AddUIComponent <UIPanel>();

            constructionPanel.height    = 30;
            constructionPanel.isVisible = true;


            m_plop                  = UIUtils.CreateButton(constructionPanel);
            m_plop.width            = 60;
            m_plop.text             = "Plop";
            m_plop.relativePosition = new Vector3(0, 0);;

            m_plop.eventClick += (c, p) =>
            {
                UIThemeManager.instance.Plop(m_item);
            };

            m_destroy                  = UIUtils.CreateButton(constructionPanel);
            m_destroy.width            = 120;
            m_destroy.text             = "Bulldoze All";
            m_destroy.relativePosition = new Vector3(m_plop.width + 10f, 0);
            m_destroy.eventClick      += (c, p) =>
            {
                UIThemeManager.instance.DestroyAll(m_item);
            };

            // Base Name
            UIPanel baseNamePanel = AddUIComponent <UIPanel>();

            baseNamePanel.height    = 50;
            baseNamePanel.isVisible = false;

            UILabel baseNameLabel = baseNamePanel.AddUIComponent <UILabel>();

            baseNameLabel.textScale        = 0.9f;
            baseNameLabel.text             = "Base:";
            baseNameLabel.relativePosition = new Vector3(0, 5);

            m_baseName                  = UIUtils.CreateTextField(baseNamePanel);
            m_baseName.size             = new Vector2(width - 10, 25);
            m_baseName.padding          = new RectOffset(6, 6, 6, 0);
            m_baseName.isEnabled        = false;
            m_baseName.tooltip          = "Name of the original building.";
            m_baseName.relativePosition = new Vector3(0, 25);

            m_baseName.eventMouseEnter += (c, p) => UIThemeManager.instance.buildingPreview.Show(m_baseBuilding);
            m_baseName.eventMouseLeave += (c, p) => UIThemeManager.instance.buildingPreview.Show(m_item);
        }
Exemple #3
0
        private void SetupControls()
        {
            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Theme Manager";
            m_title.iconSprite = "ToolbarIconZoomOutCity";

            // Filter
            m_filter                  = AddUIComponent <UIBuildingFilter>();
            m_filter.width            = width - SPACING * 2;
            m_filter.height           = 70;
            m_filter.relativePosition = new Vector3(SPACING, TITLE_HEIGHT);

            m_filter.eventFilteringChanged += (c, i) =>
            {
                if (m_themeSelection != null && m_themeSelection.selectedIndex != -1)
                {
                    Configuration.Theme theme = m_themeSelection.selectedItem as Configuration.Theme;
                    m_buildingSelection.selectedIndex = -1;
                    m_buildingSelection.rowsData      = Filter(m_themes[theme]);
                }
            };

            // Panels
            UIPanel left = AddUIComponent <UIPanel>();

            left.width            = LEFT_WIDTH;
            left.height           = HEIGHT - m_filter.height;
            left.relativePosition = new Vector3(SPACING, TITLE_HEIGHT + m_filter.height + SPACING);

            UIPanel middle = AddUIComponent <UIPanel>();

            middle.width            = MIDDLE_WIDTH;
            middle.height           = HEIGHT - m_filter.height;
            middle.relativePosition = new Vector3(LEFT_WIDTH + SPACING * 2, TITLE_HEIGHT + m_filter.height + SPACING);

            UIPanel right = AddUIComponent <UIPanel>();

            right.width            = RIGHT_WIDTH;
            right.height           = HEIGHT - m_filter.height;
            right.relativePosition = new Vector3(LEFT_WIDTH + MIDDLE_WIDTH + SPACING * 3, TITLE_HEIGHT + m_filter.height + SPACING);

            // Theme selection
            m_themeSelection = UIFastList.Create <UIThemeItem>(left);

            m_themeSelection.backgroundSprite  = "UnlockingPanel";
            m_themeSelection.width             = left.width;
            m_themeSelection.height            = left.height - 40;
            m_themeSelection.canSelect         = true;
            m_themeSelection.rowHeight         = 40;
            m_themeSelection.autoHideScrollbar = true;
            m_themeSelection.relativePosition  = Vector3.zero;

            m_themeSelection.rowsData.m_buffer = m_themes.Keys.ToArray();
            m_themeSelection.rowsData.m_size   = m_themeSelection.rowsData.m_buffer.Length;
            m_themeSelection.DisplayAt(0);

            m_themeSelection.eventSelectedIndexChanged += (c, i) =>
            {
                if (i == -1)
                {
                    return;
                }

                int   listCount = m_buildingSelection.rowsData.m_size;
                float pos       = m_buildingSelection.listPosition;

                Configuration.Theme theme = m_themeSelection.selectedItem as Configuration.Theme;
                m_buildingSelection.selectedIndex = -1;
                m_buildingSelection.rowsData      = Filter(m_themes[theme]);

                if (m_filter.buildingStatus == Status.All && m_buildingSelection.rowsData.m_size == listCount)
                {
                    m_buildingSelection.DisplayAt(pos);
                }

                m_themeRemove.isEnabled = !((Configuration.Theme)m_themeSelection.selectedItem).isBuiltIn;
            };

            // Add theme
            m_themeAdd                  = UIUtils.CreateButton(left);
            m_themeAdd.width            = (LEFT_WIDTH - SPACING) / 2;
            m_themeAdd.text             = "New Theme";
            m_themeAdd.relativePosition = new Vector3(0, m_themeSelection.height + SPACING);

            m_themeAdd.eventClick += (c, p) =>
            {
                UIView.PushModal(UINewThemeModal.instance);
                UINewThemeModal.instance.Show(true);
            };

            // Remove theme
            m_themeRemove                  = UIUtils.CreateButton(left);
            m_themeRemove.width            = (LEFT_WIDTH - SPACING) / 2;
            m_themeRemove.text             = "Delete Theme";
            m_themeRemove.isEnabled        = false;
            m_themeRemove.relativePosition = new Vector3(LEFT_WIDTH - m_themeRemove.width, m_themeSelection.height + SPACING);

            m_themeRemove.eventClick += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete Theme", "Are you sure you want to delete '" + selectedTheme.name + "' theme ?",
                                       (d, i) => { if (i == 1)
                                                   {
                                                       DeleteTheme(selectedTheme);
                                                   }
                                       });
            };

            // Building selection
            m_buildingSelection = UIFastList.Create <UIBuildingItem>(middle);

            m_buildingSelection.backgroundSprite  = "UnlockingPanel";
            m_buildingSelection.width             = middle.width;
            m_buildingSelection.height            = middle.height - 40;
            m_buildingSelection.canSelect         = true;
            m_buildingSelection.rowHeight         = 40;
            m_buildingSelection.autoHideScrollbar = true;
            m_buildingSelection.relativePosition  = Vector3.zero;

            m_buildingSelection.rowsData = new FastList <object>();

            m_buildingSelection.eventSelectedIndexChanged += (c, i) =>
            {
                m_cloneBuilding.isEnabled = selectedBuilding != null && selectedBuilding.prefab != null;

                if (selectedBuilding != null && selectedBuilding.isCloned)
                {
                    BuildingItem item = GetBuildingItem(selectedBuilding.building.baseName);
                    m_cloneBuilding.isEnabled = item != null && item.prefab != null;
                }
            };

            m_buildingSelection.eventMouseLeave += (c, p) =>
            {
                UpdateBuildingInfo(selectedBuilding);
            };

            // Include buttons
            m_includeNone                  = UIUtils.CreateButton(middle);
            m_includeNone.width            = 55;
            m_includeNone.text             = "None";
            m_includeNone.relativePosition = new Vector3(MIDDLE_WIDTH - m_includeNone.width, m_buildingSelection.height + SPACING);

            m_includeAll                  = UIUtils.CreateButton(middle);
            m_includeAll.width            = 55;
            m_includeAll.text             = "All";
            m_includeAll.relativePosition = new Vector3(m_includeNone.relativePosition.x - m_includeAll.width - SPACING, m_buildingSelection.height + SPACING);

            UILabel include = middle.AddUIComponent <UILabel>();

            include.width            = 100;
            include.padding          = new RectOffset(0, 0, 8, 0);
            include.textScale        = 0.8f;
            include.text             = "Include:";
            include.relativePosition = new Vector3(m_includeAll.relativePosition.x - include.width - SPACING, m_buildingSelection.height + SPACING);

            m_includeAll.eventClick += (c, p) =>
            {
                for (int i = 0; i < m_buildingSelection.rowsData.m_size; i++)
                {
                    BuildingItem item = m_buildingSelection.rowsData[i] as BuildingItem;
                    if (item != null)
                    {
                        ChangeBuildingStatus(item, true);
                    }
                }

                m_buildingSelection.Refresh();
            };

            m_includeNone.eventClick += (c, p) =>
            {
                for (int i = 0; i < m_buildingSelection.rowsData.m_size; i++)
                {
                    BuildingItem item = m_buildingSelection.rowsData[i] as BuildingItem;
                    if (item != null)
                    {
                        ChangeBuildingStatus(item, false);
                    }
                }

                m_buildingSelection.Refresh();
            };

            // Preview
            m_buildingPreview                  = right.AddUIComponent <UIBuildingPreview>();
            m_buildingPreview.width            = right.width;
            m_buildingPreview.height           = (right.height - SPACING) / 2;
            m_buildingPreview.relativePosition = Vector3.zero;

            // Building Options
            m_buildingOptions                  = right.AddUIComponent <UIBuildingOptions>();
            m_buildingOptions.width            = RIGHT_WIDTH;
            m_buildingOptions.height           = (right.height - SPACING) / 2 - 40;
            m_buildingOptions.relativePosition = new Vector3(0, m_buildingPreview.height + SPACING);

            // Clone building
            m_cloneBuilding                  = UIUtils.CreateButton(right);
            m_cloneBuilding.width            = RIGHT_WIDTH;
            m_cloneBuilding.height           = 30;
            m_cloneBuilding.text             = "Clone building";
            m_cloneBuilding.isEnabled        = false;
            m_cloneBuilding.relativePosition = new Vector3(0, m_buildingOptions.relativePosition.y + m_buildingOptions.height + SPACING);

            m_cloneBuilding.eventClick += (c, p) =>
            {
                UIView.PushModal(UICloneBuildingModal.instance);
                UICloneBuildingModal.instance.Show(true);
            };
        }
        public override void Start()
        {
            base.Start();

            // Zoning
            zoningToggles = new UICheckBox[10];
            for (int i = 0; i < 10; i++)
            {
                zoningToggles[i]                  = UIUtils.CreateIconToggle(this, CategoryIcons.atlases[i], CategoryIcons.spriteNames[i], CategoryIcons.spriteNames[i] + "Disabled");
                zoningToggles[i].tooltip          = CategoryIcons.tooltips[i];
                zoningToggles[i].relativePosition = new Vector3(40 * i, 0);
                zoningToggles[i].isChecked        = true;
                zoningToggles[i].readOnly         = true;
                zoningToggles[i].checkedBoxObject.isInteractive = false; // Don't eat my double click event please

                zoningToggles[i].eventClick += (c, p) =>
                {
                    ((UICheckBox)c).isChecked = !((UICheckBox)c).isChecked;
                    eventFilteringChanged(this, 0);
                };

                zoningToggles[i].eventDoubleClick += (c, p) =>
                {
                    for (int j = 0; j < 10; j++)
                    {
                        zoningToggles[j].isChecked = false;
                    }
                    ((UICheckBox)c).isChecked = true;

                    eventFilteringChanged(this, 0);
                };
            }

            allZones                  = UIUtils.CreateButton(this);
            allZones.width            = 55;
            allZones.text             = "All";
            allZones.relativePosition = new Vector3(400, 5);

            allZones.eventClick += (c, p) =>
            {
                for (int i = 0; i < 10; i++)
                {
                    zoningToggles[i].isChecked = true;
                }
                eventFilteringChanged(this, 0);
            };

            noZones                  = UIUtils.CreateButton(this);
            noZones.width            = 55;
            noZones.text             = "None";
            noZones.relativePosition = new Vector3(460, 5);

            noZones.eventClick += (c, p) =>
            {
                for (int i = 0; i < 10; i++)
                {
                    zoningToggles[i].isChecked = false;
                }
                eventFilteringChanged(this, 0);
            };

            // Display
            UILabel display = AddUIComponent <UILabel>();

            display.textScale        = 0.8f;
            display.padding          = new RectOffset(0, 0, 8, 0);
            display.text             = "Display: ";
            display.relativePosition = new Vector3(0, 40);

            origin       = UIUtils.CreateDropDown(this);
            origin.width = 90;
            origin.AddItem("All");
            origin.AddItem("Default");
            origin.AddItem("Custom");
            origin.AddItem("Cloned");
            origin.selectedIndex    = 0;
            origin.relativePosition = new Vector3(display.relativePosition.x + display.width + 5, 40);

            origin.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 1);

            status       = UIUtils.CreateDropDown(this);
            status.width = 90;
            status.AddItem("All");
            status.AddItem("Included");
            status.AddItem("Excluded");
            status.selectedIndex    = 0;
            status.relativePosition = new Vector3(origin.relativePosition.x + origin.width + 5, 40);

            status.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 2);

            // Level
            UILabel levelLabel = AddUIComponent <UILabel>();

            levelLabel.textScale        = 0.8f;
            levelLabel.padding          = new RectOffset(0, 0, 8, 0);
            levelLabel.text             = "Level: ";
            levelLabel.relativePosition = new Vector3(status.relativePosition.x + status.width + 10, 40);

            levelFilter       = UIUtils.CreateDropDown(this);
            levelFilter.width = 55;
            levelFilter.AddItem("All");
            levelFilter.AddItem("1");
            levelFilter.AddItem("2");
            levelFilter.AddItem("3");
            levelFilter.AddItem("4");
            levelFilter.AddItem("5");
            levelFilter.selectedIndex    = 0;
            levelFilter.relativePosition = new Vector3(levelLabel.relativePosition.x + levelLabel.width + 5, 40);

            levelFilter.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 3);

            // Size
            UILabel sizeLabel = AddUIComponent <UILabel>();

            sizeLabel.textScale        = 0.8f;
            sizeLabel.padding          = new RectOffset(0, 0, 8, 0);
            sizeLabel.text             = "Size: ";
            sizeLabel.relativePosition = new Vector3(levelFilter.relativePosition.x + levelFilter.width + 10, 40);

            sizeFilterX       = UIUtils.CreateDropDown(this);
            sizeFilterX.width = 55;
            sizeFilterX.AddItem("All");
            sizeFilterX.AddItem("1");
            sizeFilterX.AddItem("2");
            sizeFilterX.AddItem("3");
            sizeFilterX.AddItem("4");
            sizeFilterX.selectedIndex    = 0;
            sizeFilterX.relativePosition = new Vector3(sizeLabel.relativePosition.x + sizeLabel.width + 5, 40);

            UILabel XLabel = AddUIComponent <UILabel>();

            XLabel.textScale        = 0.8f;
            XLabel.padding          = new RectOffset(0, 0, 8, 0);
            XLabel.text             = "X";
            XLabel.isVisible        = false;
            XLabel.relativePosition = new Vector3(sizeFilterX.relativePosition.x + sizeFilterX.width - 5, 40);

            sizeFilterY       = UIUtils.CreateDropDown(this);
            sizeFilterY.width = 45;
            sizeFilterY.AddItem("1");
            sizeFilterY.AddItem("2");
            sizeFilterY.AddItem("3");
            sizeFilterY.AddItem("4");
            sizeFilterY.selectedIndex    = 0;
            sizeFilterY.isVisible        = false;
            sizeFilterY.relativePosition = new Vector3(XLabel.relativePosition.x + XLabel.width + 5, 40);

            sizeFilterX.eventSelectedIndexChanged += (c, i) =>
            {
                if (i == 0)
                {
                    sizeFilterX.width     = 55;
                    XLabel.isVisible      = false;
                    sizeFilterY.isVisible = false;
                }
                else
                {
                    sizeFilterX.width     = 45;
                    XLabel.isVisible      = true;
                    sizeFilterY.isVisible = true;
                }

                eventFilteringChanged(this, 4);
            };

            sizeFilterY.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 4);

            // Name filter
            UILabel nameLabel = AddUIComponent <UILabel>();

            nameLabel.textScale        = 0.8f;
            nameLabel.padding          = new RectOffset(0, 0, 8, 0);
            nameLabel.relativePosition = new Vector3(width - 250, 0);
            nameLabel.text             = "Name: ";

            nameFilter                  = UIUtils.CreateTextField(this);
            nameFilter.width            = 200;
            nameFilter.height           = 30;
            nameFilter.padding          = new RectOffset(6, 6, 6, 6);
            nameFilter.relativePosition = new Vector3(width - nameFilter.width, 0);

            nameFilter.eventTextChanged   += (c, s) => eventFilteringChanged(this, 5);
            nameFilter.eventTextSubmitted += (c, s) => eventFilteringChanged(this, 5);
        }
Exemple #5
0
        public override void Start()
        {
            base.Start();

            backgroundSprite = "UnlockingPanel2";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            width            = 250;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Create New Theme";
            m_title.iconSprite = "ToolbarIconZoomOutCity";
            m_title.isModal    = true;

            // Name
            UILabel name = AddUIComponent <UILabel>();

            name.height           = 30;
            name.text             = "Theme name:";
            name.relativePosition = new Vector3(5, m_title.height);

            m_name                  = UIUtils.CreateTextField(this);
            m_name.width            = width - 10;
            m_name.height           = 30;
            m_name.padding          = new RectOffset(6, 6, 6, 6);
            m_name.relativePosition = new Vector3(5, name.relativePosition.y + name.height + 5);

            m_name.Focus();
            m_name.eventTextChanged += (c, s) =>
            {
                m_ok.isEnabled = !s.IsNullOrWhiteSpace() && BuildingThemesManager.instance.GetThemeByName(s) == null;
            };

            m_name.eventTextSubmitted += (c, s) =>
            {
                if (m_ok.isEnabled && Input.GetKey(KeyCode.Return))
                {
                    m_ok.SimulateClick();
                }
            };

            // Ok
            m_ok                  = UIUtils.CreateButton(this);
            m_ok.text             = "Create";
            m_ok.isEnabled        = false;
            m_ok.relativePosition = new Vector3(5, m_name.relativePosition.y + m_name.height + 5);

            m_ok.eventClick += (c, p) =>
            {
                UIThemeManager.instance.CreateTheme(m_name.text);
                UIView.PopModal();
                Hide();
            };

            // Cancel
            m_cancel                  = UIUtils.CreateButton(this);
            m_cancel.text             = "Cancel";
            m_cancel.relativePosition = new Vector3(width - m_cancel.width - 5, m_ok.relativePosition.y);

            m_cancel.eventClick += (c, p) =>
            {
                UIView.PopModal();
                Hide();
            };

            height           = m_cancel.relativePosition.y + m_cancel.height + 5;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            isVisible = true;
        }
        public override void Start()
        {
            base.Start();

            backgroundSprite = "UnlockingPanel2";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            width            = 350;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Clone Building";
            m_title.iconSprite = "ToolbarIconZoomOutCity";
            m_title.isModal    = true;

            // Name
            UILabel name = AddUIComponent <UILabel>();

            name.height           = 30;
            name.text             = "Building name:";
            name.relativePosition = new Vector3(5, m_title.height);

            m_name                  = UIUtils.CreateTextField(this);
            m_name.width            = width - 115;
            m_name.height           = 30;
            m_name.padding          = new RectOffset(6, 6, 6, 6);
            m_name.relativePosition = new Vector3(5, name.relativePosition.y + name.height + 5);

            m_name.Focus();
            m_name.eventTextChanged += (c, s) => CheckValidity();

            // Level
            m_level        = UIUtils.CreateDropDown(this);
            m_level.width  = 100;
            m_level.height = 30;
            (m_level.triggerButton as UIButton).textPadding = new RectOffset(6, 6, 6, 0);
            m_level.relativePosition = new Vector3(m_name.relativePosition.x + m_name.width + 5, m_name.relativePosition.y);

            m_level.eventSelectedIndexChanged += (c, i) => CheckValidity();

            // Ok
            m_ok                  = UIUtils.CreateButton(this);
            m_ok.text             = "Clone";
            m_ok.isEnabled        = false;
            m_ok.relativePosition = new Vector3(5, m_name.relativePosition.y + m_name.height + 5);

            m_ok.eventClick += (c, p) =>
            {
                UIThemeManager.instance.CloneBuilding(m_item, m_cloneName, m_selectedLevel);
                UIView.PopModal();
                Hide();
            };

            // Cancel
            m_cancel                  = UIUtils.CreateButton(this);
            m_cancel.text             = "Cancel";
            m_cancel.relativePosition = new Vector3(width - m_cancel.width - 5, m_ok.relativePosition.y);

            m_cancel.eventClick += (c, p) =>
            {
                UIView.PopModal();
                Hide();
            };

            height           = m_cancel.relativePosition.y + m_cancel.height + 5;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            isVisible = true;
        }