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); }
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; }