예제 #1
0
        internal MultiCheckboxState MultiCheckBoxLabel(MultiCheckboxState state, List <FloatMenuOption> floatMenuList, string keyGroup, string label = null, string infoText = null)
        {
            float lineHeight = Text.LineHeight;
            Rect  rect       = base.GetRect(lineHeight);

            base.Gap(this.verticalSpacing);
            rect.x     += 10f;
            rect.width -= 10f;

            Texture2D tex;

            if (state == MultiCheckboxState.On)
            {
                tex = Widgets.CheckboxOnTex;
            }
            else if (state == MultiCheckboxState.Off)
            {
                tex = Widgets.CheckboxOffTex;
            }
            else
            {
                tex = Widgets.CheckboxPartialTex;
            }

            Color color = Widgets.NormalOptionColor;

            // Checkbox
            Rect texRect = new Rect(rect.width - texSize.x, rect.y, texSize.x, texSize.y);

            MouseoverSounds.DoRegion(texRect);

            // Info Icon
            Rect      infoRect = new Rect(rect.x, rect.y, 22f, 22f);
            Texture2D infoTex  = ContentFinder <Texture2D> .Get("UI/Buttons/InfoButton", true);

            GUI.DrawTexture(infoRect, infoTex);

            // Text label
            Rect labelRect = new Rect(rect);

            labelRect.x = infoRect.width + 15f;
            Widgets.Label(labelRect, label);

            // InfoText, tooltip
            if (infoText != null)
            {
                TooltipHandler.TipRegion(infoRect, infoText);
            }

            // KeyGroup Button
            MakeFloatMenu(rect, keyGroup, floatMenuList);

            MultiCheckboxState stateCheck = (state != MultiCheckboxState.Off) ? MultiCheckboxState.Off : MultiCheckboxState.On;

            if (AnyPressed(Widgets.ButtonImageDraggable(texRect, tex)))
            {
                if (stateCheck == MultiCheckboxState.On)
                {
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                }
                else
                {
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                }
                return(stateCheck);
            }
            return(state);
        }