internal void OpenAt(ServiceSystemDefinition ssd) { m_StripMain.selectedIndex = 0; if (ssd != null) { var catIdx = SVMConfigWarehouse.getCategory(ssd.toConfigIndex()); m_StripBuilings.selectedIndex = (int)catIdx; m_StripBuilingsStrips[catIdx].selectedIndex = m_StripBuilingsStrips[catIdx].Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0; } ServiceVehiclesManagerMod.instance.controller.OpenSVMPanel(); }
private void CreateSsdTabstrip(ref UITabstrip strip, ref Dictionary <CategoryTab, UITabstrip> substrips, UIPanel titleLine, UIComponent parent, bool buildings = false) { SVMUtils.createUIElement(out strip, parent.transform, "SVMTabstrip", new Vector4(5, 0, parent.width - 10, 40)); var effectiveOffsetY = strip.height + (titleLine?.height ?? 0); SVMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "SVMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40)); strip.tabPages = tabContainer; UIButton tabTemplate = CreateTabTemplate(); UIComponent bodyContent = CreateContentTemplate(parent.width - 10, parent.height - effectiveOffsetY - 50); SVMUtils.createUIElement(out UIPanel bodySuper, null); bodySuper.name = "Container"; bodySuper.area = new Vector4(0, 40, parent.width, parent.height - 50); Dictionary <CategoryTab, UIComponent> tabsCategories = new Dictionary <CategoryTab, UIComponent>(); foreach (var catTab in Enum.GetValues(typeof(CategoryTab)).Cast <CategoryTab>()) { GameObject tabCategory = Instantiate(tabTemplate.gameObject); GameObject contentCategory = Instantiate(bodySuper.gameObject); UIButton tabButtonSuper = tabCategory.GetComponent <UIButton>(); tabButtonSuper.tooltip = catTab.getCategoryName(); tabButtonSuper.normalFgSprite = catTab.getCategoryIcon(); tabsCategories[catTab] = strip.AddTab(catTab.ToString(), tabCategory, contentCategory); tabsCategories[catTab].isVisible = false; SVMUtils.createUIElement(out UITabstrip subStrip, contentCategory.transform, "SVMTabstripCat" + catTab, new Vector4(5, 0, bodySuper.width - 10, 40)); SVMUtils.createUIElement(out UITabContainer tabSubContainer, contentCategory.transform, "SVMTabContainer" + catTab, new Vector4(5, effectiveOffsetY, bodySuper.width - 10, bodySuper.height - effectiveOffsetY)); subStrip.tabPages = tabSubContainer; substrips[catTab] = subStrip; } foreach (var kv in ServiceSystemDefinition.sysDefinitions) { GameObject tab = Instantiate(tabTemplate.gameObject); GameObject body = Instantiate(bodyContent.gameObject); var configIdx = kv.Key.toConfigIndex(); String name = kv.Value.Name; SVMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} "); String bgIcon = SVMConfigWarehouse.getIconServiceSystem(configIdx); String fgIcon = SVMConfigWarehouse.getFgIconServiceSystem(configIdx); UIButton tabButton = tab.GetComponent <UIButton>(); tabButton.tooltip = SVMConfigWarehouse.getNameForServiceSystem(configIdx); tabButton.normalFgSprite = bgIcon; if (!string.IsNullOrEmpty(fgIcon)) { SVMUtils.createUIElement(out UISprite sprite, tabButton.transform, "OverSprite", new Vector4(0, 0, 40, 40)); sprite.spriteName = fgIcon; sprite.atlas = SVMController.taSVM; } Type[] components; Type targetType; if (buildings) { targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMTabControllerBuildingList <>), kv.Value); components = new Type[] { targetType }; } else { try { targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMTabControllerDistrictList <>), kv.Value); components = new Type[] { targetType }; } catch { continue; } } CategoryTab catTab = SVMConfigWarehouse.getCategory(configIdx); substrips[catTab].AddTab(name, tab, body, components); body.GetComponent <UIComponent>().eventVisibilityChanged += (x, y) => { if (y) { m_directionLabel.isVisible = kv.Key.outsideConnection; } }; tabsCategories[catTab].isVisible = true; } }