Пример #1
0
        protected override void DoContent(Rect rect)
        {
            var listing = new Listing_StandardPlus();

            listing.Begin(rect);
            listing.Label(_label);
            GUI.SetNextControlName("NameField");
            _name = listing.TextEntry(_name);
            UI.FocusControl("NameField", this);
            listing.Gap();
            listing.End();

            var grid = rect.AdjustedBy(0f, listing.CurHeight, 0f, -listing.CurHeight).GetHGrid(4f, -1f, -1f);

            listing.Begin(grid[1]);
            if (listing.ButtonText(Lang.Get("Button.OK"), null, NameIsValid()))
            {
                CommitName();
            }
            listing.End();

            listing.Begin(grid[2]);
            if (listing.ButtonText(Lang.Get("Button.Cancel")))
            {
                Close();
            }
            listing.End();
        }
Пример #2
0
        public override void DoContent(Rect rect)
        {
            var listing = new Listing_StandardPlus();

            listing.Begin(rect);
            listing.Label(Lang.Get("Dialog_PresetName.Label"));
            GUI.SetNextControlName("RenameField");
            _name = listing.TextEntry(_name);
            var valid = NameIsValid();

            if (!_focused)
            {
                UI.FocusControl("RenameField", this);
                _focused = true;
            }
            listing.Gap();
            listing.End();

            var grid = rect.AdjustedBy(0f, listing.CurHeight, 0f, -listing.CurHeight).GetHGrid(4f, 0f, 0f);

            listing.Begin(grid[0]);
            if (listing.ButtonText(Lang.Get("Button.OK"), null, valid))
            {
                CommitName();
                Close();
            }
            listing.End();

            listing.Begin(grid[1]);
            if (listing.ButtonText(Lang.Get("Button.Cancel")))
            {
                Close();
            }
            listing.End();
        }
Пример #3
0
        public static bool RadioButtonInverted(Rect rect, string labelText, bool chosen, bool enabled)
        {
            var anchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;
            var color = GUI.color;

            if (!enabled)
            {
                GUI.color = InactiveColor;
            }
            Widgets.Label(rect.AdjustedBy(RadioButtonSize + 4f, 0f, -(RadioButtonSize + 4f), 0f), labelText);
            GUI.color   = color;
            Text.Anchor = anchor;
            var labelClicked = Widgets.ButtonInvisible(rect);
            var radioClicked = Widgets.RadioButton(rect.x, (rect.y + (rect.height / 2f)) - (RadioButtonSize / 2f), chosen);

            if (labelClicked && !radioClicked && !chosen)
            {
                SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera();
            }

            return(enabled && labelClicked);
        }