示例#1
0
        private void Start()
        {
            if (!popoutPanel)
            {
                return;
            }

            var popoutController = popoutPanel.GetComponent <HGPopoutPanel>();

            popoutController.popoutPanelTitleText.token = LanguageTokens.IN_LOBBY_CONFIG_POPOUT_PANEL_NAME;
            popoutController.popoutPanelDescriptionText.transform.parent.gameObject.SetActive(false);

            var popoutChildLocator = popoutPanel.GetComponent <ChildLocator>();

            popoutChildLocator.FindChild("RandomButtonContainer")?.gameObject?.SetActive(false);

            var contentContainer = popoutController.popoutPanelContentContainer;

            DestroyImmediate(contentContainer.GetComponent <GridLayoutGroup>());

            var rectTransform = contentContainer.GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(0, 700);
            rectTransform.anchorMin = new Vector2(0, 1);
            rectTransform.anchorMax = new Vector2(1, 1);
            rectTransform.pivot     = new Vector2(0.5F, 1);
            rectTransform.offsetMin = new Vector2();
            rectTransform.offsetMax = new Vector2();

            var layoutElement = contentContainer.gameObject.AddComponent <LayoutElement>();

            layoutElement.minHeight = 700;

            //If SLUI is loaded content container's height is limmited to 425px, changing it to 700
            if (InLobbyConfigPlugin.IsScrollableLobbyUILoaded)
            {
                ModifyIfSLUILoaded(contentContainer);
            }

            contentContainer.gameObject.AddComponent <RectMask2D>();

            scrollContent = Instantiate(AssetBundleHelper.LoadPrefab("ScrollContent"), contentContainer.transform);
            var scrollbar = Instantiate(AssetBundleHelper.LoadPrefab("ScrollBar"), contentContainer.transform);

            var scrollRect = contentContainer.gameObject.AddComponent <ScrollRect>();

            scrollRect.content                     = scrollContent.GetComponent <RectTransform>();
            scrollRect.movementType                = ScrollRect.MovementType.Clamped;
            scrollRect.horizontal                  = false;
            scrollRect.vertical                    = true;
            scrollRect.viewport                    = contentContainer;
            scrollRect.scrollSensitivity           = 30;
            scrollRect.verticalScrollbar           = scrollbar.GetComponent <Scrollbar>();
            scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide;

            if (popoutPanel.activeSelf)
            {
                InitContent();
            }
        }
示例#2
0
        private void InitContent()
        {
            if (initialized)
            {
                return;
            }

            foreach (var configEntry in ModConfigCatalog.ReadonlyList)
            {
                if (configEntry == null)
                {
                    InLobbyConfigPlugin.InstanceLogger.LogWarning($"Skipping over null ModConfigEntry");
                    continue;
                }
                if (configEntry.EnableField == null && (configEntry.SectionFields.Count == 0 || configEntry.SectionFields.All(row => row.Value.Count() == 0)))
                {
                    InLobbyConfigPlugin.InstanceLogger.LogWarning($"Skipping over `{configEntry.DisplayName}` because it has no fields assigned");
                    continue;
                }
                var modConfigInstance = Instantiate(AssetBundleHelper.LoadPrefab("ModConfigPrefab"), scrollContent.transform);
                if (!modConfigInstance)
                {
                    InLobbyConfigPlugin.InstanceLogger.LogWarning("Failed to instantiate `ModConfigPrefab`");
                    continue;
                }
                var configController = modConfigInstance.GetComponent <ModConfigController>();
                configController.configEntry = configEntry;
            }

            initialized = true;
        }
        private void InitContent()
        {
            if (initialized)
            {
                return;
            }

            foreach (var row in configEntry.SectionFields)
            {
                var sectionPrefab     = Instantiate(AssetBundleHelper.LoadPrefab("SectionPrefab"), contentContainer.transform);
                var sectionController = sectionPrefab.GetComponent <ConfigSectionController>();
                sectionController.sectionName = row.Key;
                sectionController.fields      = row.Value;
                configEntry.SectionEnableFields.TryGetValue(row.Key, out sectionController.enableField);
            }

            initialized = true;
        }
示例#4
0
        private static void CachePrefabFromSurvivorGrid(Transform panel, string survivorGridName)
        {
            if (CachedPrefab)
            {
                return;
            }
            var survivorGrid = panel.Find(survivorGridName);

            CachedPrefab = AssetBundleHelper.LoadPrefab("ConfigPanel");

            CachedPrefab.GetComponent <Image>().sprite = panel.Find("BorderImage").GetComponent <Image>().sprite;
            var baseOutlineSprite  = survivorGrid.Find("SurvivorIconPrefab/BaseOutline").GetComponent <Image>().sprite;
            var hoverOutlineSprite = survivorGrid.Find("SurvivorIconPrefab/HoverOutline").GetComponent <Image>().sprite;
            var buttonSkin         = GameObject.Instantiate(survivorGrid.Find("WIPClassButtonPrefab").GetComponent <ButtonSkinController>().skinData);

            buttonSkin.buttonStyle.colors.normalColor = Color.white;
            foreach (var button in CachedPrefab.GetComponentsInChildren <HGButton>())
            {
                button.GetComponent <ButtonSkinController>().skinData = buttonSkin;
                button.transform.Find("BaseOutline").GetComponent <Image>().sprite  = baseOutlineSprite;
                button.transform.Find("HoverOutline").GetComponent <Image>().sprite = hoverOutlineSprite;
            }
        }