public SLPackListView() { Instance = this; m_currentCategory = SLPackManager.GetCategoryInstance <ItemCategory>(); var list = At.GetImplementationsOf(typeof(ContentTemplate)); s_templateTypes = list.OrderBy(it => it.Name).ToList(); ConstructUI(); }
private void ConstructListView(GameObject leftPane) { var titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.MiddleLeft); var titleLayout = titleObj.AddComponent <LayoutElement>(); titleLayout.minHeight = 25; var titleText = titleObj.GetComponent <Text>(); titleText.text = "SLPack Category:"; var subfolderDropObj = UIFactory.CreateDropdown(leftPane, out Dropdown subDrop); var subdropLayout = subfolderDropObj.AddComponent <LayoutElement>(); subdropLayout.minHeight = 25; var list = new List <ITemplateCategory>(); foreach (var ctg in SLPackManager.SLPackCategories) { if (ctg is ITemplateCategory category) { list.Add(category); } } list = list.OrderBy(it => it.FolderName).ToList(); subDrop.options = new List <Dropdown.OptionData>(); foreach (var entry in list) { subDrop.options.Add(new Dropdown.OptionData { text = entry.FolderName }); } var itemCtg = SLPackManager.GetCategoryInstance <ItemCategory>(); subDrop.value = list.IndexOf(itemCtg); subDrop.onValueChanged.AddListener((int val) => { m_currentCategory = list[val]; RefreshGeneratorTypeDropdown(); RefreshSLPackContentList(); }); m_scrollObj = UIFactory.CreateScrollView(leftPane, out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f)); }
/// <summary> /// Returns the folder path for this SLPack, plus the given SLPackCategory's FolderPath. /// </summary> /// <param name="type">The SLPackCategory type.</param> /// <returns>The path string, or null if an error was experienced.</returns> public string GetPathForCategory(Type type) { if (type == null || !typeof(SLPackCategory).IsAssignableFrom(type)) { throw new ArgumentException("type"); } var instance = SLPackManager.GetCategoryInstance(type); if (instance == null) { throw new Exception($"Trying to get folder path for '{type.FullName}', but category instance is null!"); } string ret = this.FolderPath; if (!string.IsNullOrEmpty(ret)) { ret += Path.DirectorySeparatorChar; } return($@"{ret}{instance.FolderName}"); }