private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category) { TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40)); var effectiveOffsetY = strip.height; TLMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40)); strip.tabPages = tabContainer; UIButton tabTemplate = CreateTabSubStripTemplate(); UIComponent bodyContent = CreateContentTemplate(parent.width, parent.height - effectiveOffsetY - 10, category.isScrollable()); foreach (var kv in TransportSystemDefinition.sysDefinitions) { Type[] components; Type targetType; try { targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value); components = new Type[] { targetType }; } catch { continue; } GameObject tab = Instantiate(tabTemplate.gameObject); GameObject body = Instantiate(bodyContent.gameObject); var configIdx = kv.Key.toConfigIndex(); String name = kv.Value.Name; TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} "); String bgIcon = TLMConfigWarehouse.getBgIconForIndex(configIdx); String fgIcon = kv.Key.getTransportTypeIcon(); UIButton tabButton = tab.GetComponent <UIButton>(); tabButton.tooltip = TLMConfigWarehouse.getNameForTransportType(configIdx); tabButton.hoveredBgSprite = bgIcon; tabButton.focusedBgSprite = bgIcon; tabButton.normalBgSprite = bgIcon; tabButton.disabledBgSprite = bgIcon; tabButton.focusedColor = Color.green; tabButton.hoveredColor = new Color(0, 0.5f, 0f); tabButton.color = Color.black; tabButton.disabledColor = Color.gray; if (!string.IsNullOrEmpty(fgIcon)) { TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30)); secSprite.normalFgSprite = fgIcon; secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale; secSprite.isInteractive = false; secSprite.disabledColor = Color.black; } strip.AddTab(name, tab, body, components); } }
private static bool OpenDetailPanel(int idx) { TransportSystemDefinition def; UiCategoryTab cat = UiCategoryTab.LineListing; switch (idx) { case 0: def = TransportSystemDefinition.BUS; break; case 1: def = TransportSystemDefinition.TRAM; break; case 2: def = TransportSystemDefinition.METRO; break; case 3: def = TransportSystemDefinition.TRAIN; break; case 4: def = TransportSystemDefinition.FERRY; break; case 5: def = TransportSystemDefinition.BLIMP; break; case 6: def = TransportSystemDefinition.MONORAIL; break; case 8: cat = UiCategoryTab.TourListing; def = TransportSystemDefinition.TOUR_PED; break; case 9: cat = UiCategoryTab.TourListing; def = TransportSystemDefinition.TOUR_BUS; break; default: def = TransportSystemDefinition.BUS; break; } TLMPublicTransportManagementPanel.instance?.OpenAt(cat, def); return(false); }
internal void OpenAt(UiCategoryTab cat, TransportSystemDefinition tsd) { if (cat == UiCategoryTab.LineListing && tsd.isTour()) { cat = UiCategoryTab.TourListing; } if (tsd != null) { m_StripsSubcategories[cat].selectedIndex = m_StripsSubcategories[cat].Find <UIComponent>(tsd.GetDefType().Name)?.zOrder ?? -1; } TLMUtils.doLog($"OpenAt: {cat} ({(int)cat})=>{tsd.GetDefType()}"); m_StripMain.selectedIndex = (int)cat; TLMController.instance.OpenTLMPanel(); }
public static bool isScrollable(this UiCategoryTab tab) { switch (tab) { case UiCategoryTab.LineListing: return(false); case UiCategoryTab.DepotListing: return(false); case UiCategoryTab.TourListing: return(false); case UiCategoryTab.PrefixEditor: default: return(true); } }
public static Type getTabGenericContentImpl(this UiCategoryTab tab) { switch (tab) { case UiCategoryTab.LineListing: return(typeof(TLMTabControllerLineListTransport <>)); case UiCategoryTab.TourListing: return(typeof(TLMTabControllerLineListTourism <>)); case UiCategoryTab.DepotListing: return(typeof(TLMTabControllerDepotList <>)); case UiCategoryTab.PrefixEditor: return(typeof(TLMTabControllerPrefixList <>)); default: throw new Exception($"Not supported: {tab}"); } }
public static string getTabFgSprite(this UiCategoryTab tab) { switch (tab) { case UiCategoryTab.LineListing: return("ToolbarIconPublicTransport"); case UiCategoryTab.DepotListing: return("UIFilterBigBuildings"); case UiCategoryTab.TourListing: return("InfoIconTours"); case UiCategoryTab.PrefixEditor: return("InfoIconLevel"); default: throw new Exception($"Not supported: {tab}"); } }
public static string getTabName(this UiCategoryTab tab) { switch (tab) { case UiCategoryTab.LineListing: return(Locale.Get("TLM_LIST_LINES_TOOLTIP")); case UiCategoryTab.DepotListing: return(Locale.Get("TLM_LIST_DEPOT_TOOLTIP")); case UiCategoryTab.TourListing: return(Locale.Get("TLM_LIST_TOURS_TOOLTIP")); case UiCategoryTab.PrefixEditor: return(Locale.Get("TLM_CITY_ASSETS_SELECTION")); default: throw new Exception($"Not supported: {tab}"); } }