예제 #1
0
        private void ApplyToggleFormattingOptions(
            GameObject widget,
            ButtonFormattingOptions options)
        {
            Color bgColor;
            Color checkColor;

            switch (ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask))
            {
            case ButtonFormattingOptions.ThemeType_SystemWidget:
                bgColor    = InternalButtonNormalBG;
                checkColor = InternalButtonNormalText;
                break;

            case ButtonFormattingOptions.ThemeType_KeyInput:
                bgColor    = InternalButtonInvertedBG;
                checkColor = InternalButtonInvertedText;
                break;

            case ButtonFormattingOptions.ThemeType_ListInput:
                bgColor    = InternalButtonSpecialBG;
                checkColor = InternalButtonSpecialText;
                break;

            default:
                Debug.LogError($"Unrecognized ThemeType: {(int)ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)}");
                goto case ButtonFormattingOptions.ThemeType_SystemWidget;
            }

            Toggle toggle = widget.GetComponent <Toggle>();

            toggle.targetGraphic.color = bgColor;
            toggle.graphic.color       = checkColor;
        }
예제 #2
0
        public GameObject CreateToggleWidget(
            GameObject parent = null,
            bool value        = false,
            ButtonFormattingOptions formattingOptions            = ButtonFormattingOptions.None,
            UnityEngine.Events.UnityAction <bool> onValueChanged = null,
            ContainerConfig configOverride = ContainerConfig.Submissive,
            int index = -1,
            int slots = -1)
        {
            GameObject toggleWidget = GameObject.Instantiate(optionTogglePrefab);

            //Attach to parent and load up appropriate configurations
            CoupleToParent(
                widget: toggleWidget,
                parent: parent,
                index: index,
                slots: slots,
                config: configOverride);

            //Apply specific widget options
            ApplyToggleFormattingOptions(toggleWidget, formattingOptions);

            Toggle toggle = toggleWidget.GetComponent <Toggle>();

            if (onValueChanged != null)
            {
                toggle.onValueChanged.AddListener(onValueChanged);
            }

            toggle.isOn = value;

            return(toggleWidget);
        }
예제 #3
0
        public GameObject UpdateWidgetFormattingOptions(
            GameObject widget,
            ButtonFormattingOptions formattingOptions)
        {
            ApplyButtonFormattingOptions(widget, formattingOptions);

            return(widget);
        }
예제 #4
0
        public GameObject CreateButtonWidget(
            GameObject parent = null,
            IConvertible text = null,
            UnityEngine.Events.UnityAction onClick = null,
            ButtonFormattingOptions buttonOptions  = ButtonFormattingOptions.None,
            ContainerConfig configOverride         = ContainerConfig.Submissive,
            int index = -1,
            int slots = -1)
        {
            GameObject buttonWidget = GameObject.Instantiate(optionButtonPrefab);

            //Attach to parent and load up appropriate configurations
            CoupleToParent(
                widget: buttonWidget,
                parent: parent,
                index: index,
                slots: slots,
                config: configOverride);

            //Apply specific widget options
            ApplyButtonFormattingOptions(buttonWidget, buttonOptions);

            Button button = buttonWidget.GetComponent <Button>();

            if (onClick != null)
            {
                button.onClick.AddListener(onClick);
            }

            if (text == null)
            {
                text = "";
            }
            Text textElement = buttonWidget.GetComponentInChildren <Text>();

            textElement.text = text.ToString();

            return(buttonWidget);
        }
예제 #5
0
        private void ApplyButtonFormattingOptions(
            GameObject widget,
            ButtonFormattingOptions options)
        {
            Color bgColor;
            Color textColor;

            switch (ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask))
            {
            case ButtonFormattingOptions.ThemeType_SystemWidget:
                bgColor   = InternalButtonNormalBG;
                textColor = InternalButtonNormalText;
                break;

            case ButtonFormattingOptions.ThemeType_KeyInput:
                bgColor   = InternalButtonInvertedBG;
                textColor = InternalButtonInvertedText;
                break;

            case ButtonFormattingOptions.ThemeType_DeleteButton:
                bgColor   = DeleteButtonBG;
                textColor = DeleteButtonText;
                break;

            case ButtonFormattingOptions.ThemeType_ListInput:
                bgColor   = InternalButtonSpecialBG;
                textColor = InternalButtonSpecialText;
                break;

            default:
                Debug.LogError($"Unrecognized ThemeType: {(int)ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)}");
                goto case ButtonFormattingOptions.ThemeType_SystemWidget;
            }

            widget.GetComponent <Image>().color          = bgColor;
            widget.GetComponentInChildren <Text>().color = textColor;
        }
예제 #6
0
 private static int GetMaskedFlagValue(ButtonFormattingOptions config, ButtonFormattingOptions mask, ButtonFormattingOptions firstBit)
 {
     return((int)(config & mask) / (int)firstBit);
 }
예제 #7
0
 public static ButtonFormattingOptions ApplyMask(ButtonFormattingOptions config, ButtonFormattingOptions mask)
 {
     return(config & mask);
 }
예제 #8
0
 //ButtonFormattingOptions
 private static bool CheckFlag(ButtonFormattingOptions options, ButtonFormattingOptions flag)
 {
     return((options & flag) == flag);
 }