//////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static CustomizeScreen Create(Transform parent, SaveDataEntry data, GameObject lockerPrefab = null)
        {
#if SUBNAUTICA
            lockerPrefab = Resources.Load <GameObject>("Submarine/Build/SmallLocker");
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <Text>());
#elif BELOWZERO
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <TextMeshProUGUI>());
#endif
            textPrefab.fontSize = 12;
            textPrefab.color    = CustomizeScreen.ScreenContentColor;

            var screen = new GameObject("CustomizeScreen", typeof(RectTransform)).AddComponent <CustomizeScreen>();
            RectTransformExtensions.SetParams(screen.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), parent);
            RectTransformExtensions.SetSize(screen.rectTransform, 114, 241);

            screen.background        = new GameObject("Background").AddComponent <Image>();
            screen.background.sprite = ImageUtils.LoadSprite(Mod.GetAssetPath("CustomizeScreen.png"));
            RectTransformExtensions.SetParams(screen.background.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), screen.transform);
            RectTransformExtensions.SetSize(screen.background.rectTransform, 114, 241);

            screen.labelLabel = LockerPrefabShared.CreateText(screen.background.transform, textPrefab, ScreenContentColor, 100, 9, "Label:");
            RectTransformExtensions.SetSize(screen.labelLabel.rectTransform, 90, 40);
#if SUBNAUTICA
            screen.labelLabel.alignment = TextAnchor.MiddleLeft;
#elif BELOWZERO
            screen.labelLabel.alignment = TextAlignmentOptions.MidlineLeft;
#endif

            screen.label = LabelController.Create(data, screen.background.transform, lockerPrefab);
            screen.label.rectTransform.anchoredPosition = new Vector2(0, 80);

            screen.exitButton = ConfigureButton.Create(screen.background.transform, Color.white, 40);

            var startX = 0;
            var startY = 30;
            screen.labelColorSetting = ColorSetting.Create(screen.background.transform, "Label Color", lockerPrefab);
            screen.labelColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY);

            screen.iconColorSetting = ColorSetting.Create(screen.background.transform, "Icon Color", lockerPrefab);
            screen.iconColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - 19);

            screen.textColorSetting = ColorSetting.Create(screen.background.transform, "Filters Color", lockerPrefab);
            screen.textColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 2));

            screen.buttonsColorSetting = ColorSetting.Create(screen.background.transform, "Misc Color", lockerPrefab);
            screen.buttonsColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 3));

            screen.lockerColorSetting = ColorSetting.Create(screen.background.transform, "Locker Color", lockerPrefab);
            screen.lockerColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 4));

            screen.colorPicker = ColorPicker.Create(screen.background.transform, lockerPrefab);
            screen.colorPicker.gameObject.SetActive(false);
            screen.colorPicker.rectTransform.anchoredPosition = new Vector2(0, 30);

            return(screen);
        }
        public static GameObject GetPrefab(TechType basePrefab)
        {
            GameObject originalPrefab = CraftData.GetPrefabForTechType(basePrefab);
            GameObject prefab         = GameObject.Instantiate(originalPrefab);

            var meshRenderers = prefab.GetComponentsInChildren <MeshRenderer>();

            foreach (var meshRenderer in meshRenderers)
            {
                meshRenderer.material.color = new Color(0.3f, 0.3f, 0.3f);
            }

            var autosortTarget = prefab.AddComponent <AutosortTarget>();

            var smallLockerPrefab = CraftData.GetPrefabForTechType(TechType.SmallLocker);

            autosortTarget.textPrefab = GameObject.Instantiate(smallLockerPrefab.GetComponentInChildren <Text>());
            var label = prefab.FindChild("Label");

            DestroyImmediate(label);

            var canvas = LockerPrefabShared.CreateCanvas(prefab.transform);

            if (basePrefab == TechType.Locker)
            {
                canvas.transform.localPosition = new Vector3(0, 1.1f, 0.25f);
            }

            autosortTarget.background = LockerPrefabShared.CreateBackground(canvas.transform);
            autosortTarget.icon       = LockerPrefabShared.CreateIcon(autosortTarget.background.transform, autosortTarget.textPrefab.color, 70);
            autosortTarget.text       = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, -20, 12, "Any");

            autosortTarget.label = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 100, 12, "Locker");

            autosortTarget.background.gameObject.SetActive(false);
            autosortTarget.icon.gameObject.SetActive(false);
            autosortTarget.text.gameObject.SetActive(false);

            autosortTarget.plus       = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 30, "+");
            autosortTarget.plus.color = new Color(autosortTarget.textPrefab.color.r, autosortTarget.textPrefab.color.g, autosortTarget.textPrefab.color.g, 0);
            autosortTarget.plus.rectTransform.anchoredPosition += new Vector2(30, 70);

            autosortTarget.quantityText = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 10, "XX");
            autosortTarget.quantityText.rectTransform.anchoredPosition += new Vector2(-35, -104);

            autosortTarget.configureButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 40);
            autosortTarget.configureButtonImage = autosortTarget.configureButton.GetComponent <Image>();
            autosortTarget.customizeButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 20);
            autosortTarget.customizeButtonImage = autosortTarget.customizeButton.GetComponent <Image>();

            return(prefab);
        }
Пример #3
0
        /*_____________________________________________________________________________________________________*/

        public static CustomizeScreen Create(Transform parent, SaveDataEntry data, GameObject lockerPrefab = null)
        {
#if SUBNAUTICA
            lockerPrefab = Resources.Load <GameObject>("Submarine/Build/SmallLocker");
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <Text>());
#elif BELOWZERO
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <TextMeshProUGUI>());
#endif
            textPrefab.fontSize = 12;
            textPrefab.color    = CustomizeScreen.ScreenContentColor;
            // The color picker settings
            var screen = new GameObject("CustomizeScreen", typeof(RectTransform)).AddComponent <CustomizeScreen>();
            RectTransformExtensions.SetParams(screen.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), parent);
            RectTransformExtensions.SetSize(screen.rectTransform, 114, 241);

            screen.background        = new GameObject("Background").AddComponent <Image>();
            screen.background.sprite = ImageUtils.LoadSprite(Mod.GetAssetPath("CustomizeScreen.png"));
            // 1st = 2nd = 3rd = horizontal 4th = vertical positon of the color settings
            RectTransformExtensions.SetParams(screen.background.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0.41f, 0.4f), screen.transform);
            RectTransformExtensions.SetSize(screen.background.rectTransform, 114, 220);

            screen.label = LabelController.Create(data, screen.background.transform, lockerPrefab);
            // The position of the LOCKER label
            screen.label.rectTransform.anchoredPosition = new Vector2(0, 70);
            // The position of the close (X) button on the color settings
            screen.exitButton = ConfigureButton.Create(screen.background.transform, Color.white, 0, -85);

            var startX = 0;
            var startY = 30;
            screen.lockerColorSetting = ColorSetting.Create(screen.background.transform, "Locker Color", lockerPrefab);
            screen.lockerColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY);

            screen.iconColorSetting = ColorSetting.Create(screen.background.transform, "Icon Color", lockerPrefab);
            screen.iconColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - 19);

            screen.textColorSetting = ColorSetting.Create(screen.background.transform, "Filters Color", lockerPrefab);
            screen.textColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 2));

            screen.buttonsColorSetting = ColorSetting.Create(screen.background.transform, "Misc Color", lockerPrefab);
            screen.buttonsColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 3));

            screen.labelColorSetting = ColorSetting.Create(screen.background.transform, "Label Color", lockerPrefab);
            screen.labelColorSetting.rectTransform.anchoredPosition = new Vector2(startX, startY - (19 * 4));

            screen.colorPicker = ColorPicker.Create(screen.background.transform, lockerPrefab);
            screen.colorPicker.gameObject.SetActive(false);
            screen.colorPicker.rectTransform.anchoredPosition = new Vector2(0, 30);

            return(screen);
        }
        public static IEnumerator GetPrefabAsync(TechType basePrefab, IOut <GameObject> gameObject)
        {
            //Logger.Log($"GetPrefabAsync() executing for basePrefab TechType.{basePrefab.AsString()}");
            CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(basePrefab);

            yield return(task);

            GameObject originalPrefab = task.GetResult();
            GameObject prefab         = GameObject.Instantiate(originalPrefab);

            var meshRenderers = prefab.GetComponentsInChildren <MeshRenderer>();

            foreach (var meshRenderer in meshRenderers)
            {
                meshRenderer.material.color = new Color(0.3f, 0.3f, 0.3f);
            }

            var autosortTarget = prefab.AddComponent <AutosortTarget>();

            task = CraftData.GetPrefabForTechTypeAsync(TechType.SmallLocker);
            yield return(task);

            //var smallLockerPrefab = CraftData.GetPrefabForTechType(TechType.SmallLocker);

            //Logger.Log($"GetPrefabAsync() attempting to instantiate smallLockerPrefab");
            var smallLockerPrefab = GameObject.Instantiate(task.GetResult());

            //Logger.Log($"GetPrefabAsync() attempting to instantiate autosortTarget; smallLockerPrefab " + (smallLockerPrefab == null ? "is" : "is not") + " null");
#if SUBNAUTICA
            autosortTarget.textPrefab = GameObject.Instantiate(smallLockerPrefab.GetComponentInChildren <Text>());
#elif BELOWZERO
            autosortTarget.textPrefab = GameObject.Instantiate(smallLockerPrefab.GetComponentInChildren <TextMeshProUGUI>());
#endif
            var label = prefab.FindChild("Label");
            DestroyImmediate(label);

            var canvas = LockerPrefabShared.CreateCanvas(prefab.transform);
            if (basePrefab == TechType.Locker)
            {
                canvas.transform.localPosition = new Vector3(0, 1.1f, 0.25f);
            }

            autosortTarget.background = LockerPrefabShared.CreateBackground(canvas.transform);
            autosortTarget.icon       = LockerPrefabShared.CreateIcon(autosortTarget.background.transform, autosortTarget.textPrefab.color, 70);
            autosortTarget.text       = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, -20, 12, "Any");

            autosortTarget.label = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 100, 12, "Locker");

            autosortTarget.background.gameObject.SetActive(false);
            autosortTarget.icon.gameObject.SetActive(false);
            autosortTarget.text.gameObject.SetActive(false);

            autosortTarget.plus       = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 30, "+");
            autosortTarget.plus.color = new Color(autosortTarget.textPrefab.color.r, autosortTarget.textPrefab.color.g, autosortTarget.textPrefab.color.g, 0);
            autosortTarget.plus.rectTransform.anchoredPosition += new Vector2(30, 70);

            autosortTarget.quantityText = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 10, "XX");
            autosortTarget.quantityText.rectTransform.anchoredPosition += new Vector2(-35, -104);

            autosortTarget.configureButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 40);
            autosortTarget.configureButtonImage = autosortTarget.configureButton.GetComponent <Image>();
            autosortTarget.customizeButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 20);
            autosortTarget.customizeButtonImage = autosortTarget.customizeButton.GetComponent <Image>();

            //return prefab;
            //originalPrefab.SetActive(false);
            gameObject.Set(prefab);
        }
Пример #5
0
        public static IEnumerator GetPrefabAsync(TechType basePrefab, IOut <GameObject> gameObject)
        {
            CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(basePrefab);

            yield return(task);

            GameObject originalPrefab = task.GetResult();
            GameObject prefab         = GameObject.Instantiate(originalPrefab);

            var meshRenderers = prefab.GetComponentsInChildren <MeshRenderer>();

            foreach (var meshRenderer in meshRenderers)
            {
                meshRenderer.material.color = new Color(0.3f, 0.3f, 0.3f);
            }

            var autosortTarget = prefab.AddComponent <AutosortTarget>();

            task = CraftData.GetPrefabForTechTypeAsync(TechType.SmallLocker);
            yield return(task);

            var smallLockerPrefab = GameObject.Instantiate(task.GetResult());

#if SUBNAUTICA
            autosortTarget.textPrefab = GameObject.Instantiate(smallLockerPrefab.GetComponentInChildren <Text>());
#elif BELOWZERO
            autosortTarget.textPrefab = GameObject.Instantiate(smallLockerPrefab.GetComponentInChildren <TextMeshProUGUI>());
#endif
            // Destroys the lable on the small locker
            var label = prefab.FindChild("Label");
            DestroyImmediate(label);
            label = prefab.FindChild("Locker");
            DestroyImmediate(label);

            var canvas = LockerPrefabShared.CreateCanvas(prefab.transform);
            if (basePrefab == TechType.Locker)
            {
                // Positions the rectangle on the standing locker horz, vert, depth
                canvas.transform.localPosition = new Vector3(0.04f, 1.0f, 0.25f);
            }

            autosortTarget.background = LockerPrefabShared.CreateBackground(canvas.transform, prefab.name);

            int iconPos   = 75;          // The vertical pos of the icon at the top of the container
            int textPos   = 110;         // The vertical pos of the "Locker" text at the top of the container
            int buttonPos = -104;        // The vertical positions of the color and customize buttons
            int labelFont = 12;          // The font for the label on the lockers
            if (Mod.config.ShowLabel)
            {                            // This is a cludge until I can find the placeholder
                labelFont = 0;           // Set to zero and the Locker text does not display
            }
            else
            {
                labelFont = 12;
            }

            // Change the positions for the Standing Locker
            if (prefab.name == "Locker(Clone)")
            {
                iconPos   = 93;
                textPos   = 120;
                buttonPos = -120;
            }

            // Position the locker icon
            autosortTarget.icon = LockerPrefabShared.CreateIcon(autosortTarget.background.transform, autosortTarget.textPrefab.color, iconPos);
            // Position the Filter lables, the first number is the horizontal position, the second number is the font size.
            autosortTarget.text = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 12, "[Any] - Doesn't display", prefab.name);
            // Position the "Locker" text
            autosortTarget.label = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, textPos, labelFont, "Locker - Doesn't display", prefab.name);

            autosortTarget.background.gameObject.SetActive(false);
            autosortTarget.icon.gameObject.SetActive(false);
            autosortTarget.text.gameObject.SetActive(false);
            // The container filters ??
            autosortTarget.plus = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 12, "+ - Doesn't display", prefab.name);

            // Pos of the color picker
            autosortTarget.plus.color = new Color(autosortTarget.textPrefab.color.r, autosortTarget.textPrefab.color.g, autosortTarget.textPrefab.color.g, 0);
            // Pos of the item count on the locker
            autosortTarget.quantityText = LockerPrefabShared.CreateText(autosortTarget.background.transform, autosortTarget.textPrefab, autosortTarget.textPrefab.color, 0, 12, "XX - Doesn't display", prefab.name);
            // Pos the quantity text on the locker
            if (prefab.name == "Locker(Clone)")
            {
                autosortTarget.quantityText.rectTransform.anchoredPosition += new Vector2(14, -210);
            }
            else
            {
                autosortTarget.quantityText.rectTransform.anchoredPosition += new Vector2(4, -198);
            }
            // Pos of the configure button on the locker
            autosortTarget.configureButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 45, buttonPos);
            autosortTarget.configureButtonImage = autosortTarget.configureButton.GetComponent <Image>();
            // Pos of the customize button on the locker
            autosortTarget.customizeButton      = ConfigureButton.Create(autosortTarget.background.transform, autosortTarget.textPrefab.color, 20, buttonPos);
            autosortTarget.customizeButtonImage = autosortTarget.customizeButton.GetComponent <Image>();

            gameObject.Set(prefab);
        }