Exemple #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();
        }
Exemple #2
0
        private Rect DoTitle(Rect rect)
        {
            if (Title.NullOrEmpty())
            {
                return(rect);
            }

            var header = new Listing_StandardPlus();

            header.Begin(rect);
            header.LabelMedium(Title);
            header.GapLine();
            header.End();

            var contentRect = rect;

            contentRect.y      += header.CurHeight;
            contentRect.height -= header.CurHeight;

            if (doCloseButton)
            {
                contentRect.height -= 55f;
            }

            return(contentRect);
        }
Exemple #3
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();
        }
Exemple #4
0
        protected override void DoContent(Rect rect)
        {
            var listing = new Listing_StandardPlus();

            listing.Begin(rect);

            Registry.AllowDrugsRestriction = listing.CheckboxLabeled(Lang.Get("Dialog_Global.AllowDrugsRestriction"), Registry.AllowDrugsRestriction);
            Registry.AllowEmergencyFood    = listing.CheckboxLabeled(Lang.Get("Dialog_Global.AllowEmergencyFood"), Registry.AllowEmergencyFood);
            Registry.AllowTrainingFood     = listing.CheckboxLabeled(Lang.Get("Dialog_Global.AllowTrainingFood"), Registry.AllowTrainingFood);

            listing.Gap();
            listing.GapLine();
            listing.Gap();

            Registry.ShowFoodPolicy    = listing.CheckboxLabeled(GetShowRuleLabel(Lang.Get("RestrictionType.Food")), Registry.ShowFoodPolicy);
            Registry.ShowBondingPolicy = listing.CheckboxLabeled(GetShowRuleLabel(Lang.Get("RestrictionType.Bonding")), Registry.ShowBondingPolicy);
            Registry.ShowAllowCourting = listing.CheckboxLabeled(GetShowRuleLabel(Lang.Get("Rules.AllowCourting")), Registry.ShowAllowCourting);
            Registry.ShowAllowArtisan  = listing.CheckboxLabeled(GetShowRuleLabel(Lang.Get("Rules.AllowArtisan")), Registry.ShowAllowArtisan);

            listing.Gap();
            listing.GapLine();
            listing.Gap();

            if (listing.ButtonText(Lang.Get("Dialog_Global.Plans")))
            {
                Close();
                Dialog_Plans.Open();
            }

            listing.End();
        }
Exemple #5
0
        protected override void DoContent(Rect rect)
        {
            if (!Registry.IsActive)
            {
                Close();
                return;
            }

            Title = _type == null?Lang.Get("Dialog_Rules.Title", _pawn.Name.ToStringFull.Bold(), _preset.Type.Label) : Lang.Get("Dialog_Rules.TitleDefault", _type.LabelPlural.Bold());

            var listing = new Listing_StandardPlus();
            var hGrid   = rect.GetHGrid(8f, 200f, -1f);
            var lGrid   = hGrid[1].GetVGrid(4f, 42f, -1f);

            listing.Begin(lGrid[1]);
            listing.Label(Lang.Get("Preset.Header").Italic().Bold());
            listing.GapLine();
            listing.End();
            _preset.DoContent(lGrid[2]);

            var vGrid = hGrid[2].GetVGrid(4f, 42f, -1f, 62f);

            listing.Begin(vGrid[1]);
            listing.Label(Lang.Get("Dialog_Rules.Configuration").Italic().Bold());
            listing.GapLine();
            listing.End();

            var editMode = _preset.EditMode || (_template == _personalized);

            var color = GUI.color;

            if (!editMode)
            {
                GUI.color = GuiPlus.ReadOnlyColor;
            }

            listing.Begin(vGrid[2]);
            if (Registry.ShowFoodPolicy && listing.ButtonText(Lang.Get("Rules.FoodRestrictions", GetRestrictionDisplayName(_template.GetRestriction(RestrictionType.Food))), Lang.Get("Rules.FoodRestrictionsDesc")) && editMode)
            {
                ChangeRestriction(RestrictionType.Food);
            }
            if (_template.Type == PawnType.Colonist)
            {
                if (Registry.ShowBondingPolicy && listing.ButtonText(Lang.Get("Rules.BondingRestrictions", GetRestrictionDisplayName(_template.GetRestriction(RestrictionType.Bonding))), Lang.Get("Rules.BondingRestrictionsDesc")) && editMode)
                {
                    ChangeRestriction(RestrictionType.Bonding);
                }

                if ((Registry.ShowFoodPolicy || Registry.ShowBondingPolicy) && (Registry.ShowAllowCourting || Registry.ShowAllowArtisan))
                {
                    listing.GapLine();
                }
                if (Registry.ShowAllowCourting)
                {
                    listing.CheckboxLabeled(Lang.Get("Rules.AllowCourting"), ref _template.AllowCourting, Lang.Get("Rules.AllowCourtingDesc"), editMode);
                }
                if (Registry.ShowAllowArtisan)
                {
                    listing.CheckboxLabeled(Lang.Get("Rules.AllowArtisan"), ref _template.AllowArtisan, Lang.Get("Rules.AllowArtisanDesc"), editMode);
                }
            }

            if (Registry.ShowFoodPolicy || Registry.ShowBondingPolicy || Registry.ShowAllowCourting || Registry.ShowAllowArtisan)
            {
                listing.GapLine();
            }

            listing.End();

            if (_template.HasAddons)
            {
                var addonsRect = vGrid[2].GetVGrid(4f, listing.CurHeight, -1f)[2];
                _addons.Begin(addonsRect, addonsRect.height <= _template.AddonsRectHeight);
                GuiPlus.DoAddonsListing(_addons, _template, editMode);
                _addons.End();
            }

            GUI.color = color;

            var optionGrid = vGrid[3].GetVGrid(2f, -1f, -1f);

            listing.Begin(optionGrid[1]);
            if (listing.ButtonText(Lang.Get("Button.AssignTo"), Lang.Get("Button.AssignToDesc"), (_floatMenuAssign.Count > 0) && (!editMode || (_template == _personalized))))
            {
                Find.WindowStack.Add(new FloatMenu(_floatMenuAssign));
            }
            listing.End();

            listing.Begin(optionGrid[2]);
            if (listing.ButtonText(_type == null ? Lang.Get("Button.ViewType", Lang.Get("PawnType.Individual")) : Lang.Get("Button.ViewTypeDefault", _type.LabelPlural), Lang.Get("Button.ViewTypeDesc"), !editMode || (_template == _personalized)))
            {
                Find.WindowStack.Add(new FloatMenu(_floatMenuViews));
            }
            listing.End();

            GUI.EndGroup();

            if (GuiPlus.ButtonText(new Rect(rect.xMax - (80f - Margin), rect.yMax + (Margin * 2), OptionButtonSize, CloseButSize.y), Lang.Get("Button.GlobalOptions"), Lang.Get("Button.GlobalOptionsDesc")))
            {
                Dialog_Global.Open();
            }
            GUI.BeginGroup(windowRect);
        }
Exemple #6
0
        public static void DoAddonsListing(Listing_StandardPlus listing, Rules rules, bool editMode)
        {
            foreach (var addon in rules.GetAddons())
            {
                if (rules.IsPreset && !addon.AllowedInPreset)
                {
                    continue;
                }

                if (addon.Widget == OptionWidget.Checkbox)
                {
                    var value = rules.GetAddonValue(addon, (bool)addon.DefaultValue);
                    if (!listing.CheckboxLabeled(addon.Label, ref value, addon.Tooltip, editMode))
                    {
                        continue;
                    }
                    if (rules.IsPreset)
                    {
                        addon.Handle.ChangePresetValue(rules, value);
                    }
                    else
                    {
                        addon.Handle.ChangeValue(rules.Pawn, value);
                    }
                }
                else if (addon.Widget == OptionWidget.TextEntry)
                {
                    if (addon.Type == typeof(string))
                    {
                        var oldValue = rules.GetAddonValue(addon, (string)addon.DefaultValue);
                        var newValue = listing.TextEntryLabeled(addon.Label, oldValue, addon.Tooltip);
                        if (!editMode || oldValue.Equals(newValue))
                        {
                            continue;
                        }

                        if (rules.IsPreset)
                        {
                            addon.Handle.ChangePresetValue(rules, newValue);
                        }
                        else
                        {
                            addon.Handle.ChangeValue(rules.Pawn, newValue);
                        }
                    }
                    else if (addon.Type == typeof(int))
                    {
                        var oldValue = rules.GetAddonValue(addon, (int)addon.DefaultValue).ToString();
                        var newValue = listing.TextEntryLabeled(addon.Label, oldValue, addon.Tooltip);
                        if (!editMode || oldValue.Equals(newValue))
                        {
                            continue;
                        }

                        if (rules.IsPreset)
                        {
                            addon.Handle.ChangePresetValue(rules, newValue.ToInt());
                        }
                        else
                        {
                            addon.Handle.ChangeValue(rules.Pawn, newValue.ToInt());
                        }
                    }
                    else if (addon.Type == typeof(float))
                    {
                        var oldValue = rules.GetAddonValue(addon, (float)addon.DefaultValue).ToString(CultureInfo.InvariantCulture);
                        var newValue = listing.TextEntryLabeled(addon.Label, oldValue, addon.Tooltip);
                        if (!editMode || oldValue.Equals(newValue))
                        {
                            continue;
                        }

                        if (rules.IsPreset)
                        {
                            addon.Handle.ChangePresetValue(rules, newValue.ToFloat());
                        }
                        else
                        {
                            addon.Handle.ChangeValue(rules.Pawn, newValue.ToFloat());
                        }
                    }
                }
                else if (addon.Widget == OptionWidget.Button)
                {
                    if (!listing.ButtonText(addon.Label, addon.Tooltip) && editMode)
                    {
                        continue;
                    }

                    if (rules.IsPreset)
                    {
                        addon.Handle.DoDefaultClick(rules.Type.AsTarget);
                    }
                    else
                    {
                        addon.Handle.DoClick(rules.Pawn);
                    }
                }
            }
        }