示例#1
0
        internal ModTab CreateModTab(string modName)
        {
            UIGrid grid = CreateUIGrid(modName);

            Il2Cpp.List <GameObject> menuItems = new Il2Cpp.List <GameObject>();
            menuItems.Add(modSelector.gameObject);
            ModTab modTab = new ModTab(grid, menuItems);

            grid.onReposition = new System.Action(() => ResizeScrollBar(modTab));

            modTabs.Add(modName, modTab);
            return(modTab);
        }
示例#2
0
        internal void SelectMod(string modName)
        {
            if (currentTab != null)
            {
                currentTab.uiGrid.gameObject.active = false;
            }

            selectedIndex = 0;
            currentTab    = modTabs[modName];
            currentTab.uiGrid.gameObject.active = true;

            ResizeScrollBar(currentTab);
            EnsureSelectedSettingVisible();
        }
示例#3
0
        internal void ResizeScrollBar(ModTab modTab)
        {
            int childCount = modTab.uiGrid.GetChildList().Count;

            if (modTab == currentTab)
            {
                float absoluteVal = scrollBarSlider.value * modTab.scrollBarHeight;

                float height = childCount * GUIBuilder.gridCellHeight;
                modTab.scrollBarHeight = height - scrollPanel.height;

                ScrollbarThumbResizer thumbResizer = scrollBarSlider.GetComponent <ScrollbarThumbResizer>();
                thumbResizer.SetNumSteps((int)scrollPanel.height, (int)height);

                scrollBarSlider.value = Mathf.Clamp01(absoluteVal / Mathf.Max(1, modTab.scrollBarHeight));
                OnScroll(scrollBarSlider, false);
            }
            else
            {
                modTab.scrollBarHeight = childCount * GUIBuilder.gridCellHeight - scrollPanel.height;
            }

            scrollBar.SetActive(currentTab.scrollBarHeight > 0);
        }
示例#4
0
 internal GUIBuilder(string modName, GUI settingsGUI, ModTab modTab) : this(modTab.uiGrid, modTab.menuItems)
 {
     this.settingsGUI = settingsGUI;
     menuGroup        = new MenuGroup(modName, settingsGUI);
 }