Beispiel #1
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();
        }
Beispiel #2
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();
        }
Beispiel #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();
        }
Beispiel #4
0
        private void DoMembers(Rect rect)
        {
            _membersList.Begin(rect, true);

            foreach (var category in _template.Categories)
            {
                if ((_type == RestrictionType.Food) && (_rules.Pawn != null) && !category.Members.Any(member => _rules.Pawn.RaceProps.CanEverEat((ThingDef)member.Def)))
                {
                    continue;
                }

                _membersList.LabelTiny(category.Label.Bold());

                foreach (var member in category.Members)
                {
                    if (_presetList.EditMode)
                    {
                        _membersList.CheckboxLabeled(member.Def.LabelCap, ref member.Value, member.Def.description);
                        continue;
                    }

                    if ((_type == RestrictionType.Food) && (_rules.Pawn != null) && !_rules.Pawn.RaceProps.CanEverEat((ThingDef)member.Def))
                    {
                        continue;
                    }

                    GUI.color = GuiPlus.ReadOnlyColor;
                    _membersList.CheckboxLabeled(member.Def.LabelCap, ref member.Value, member.Def.description, false);
                    GUI.color = _color;
                }

                _membersList.Gap();
            }

            _membersList.End();
        }
Beispiel #5
0
        private void DoCategories(Rect categoriesRect, Rect membersRect)
        {
            var vGrid = categoriesRect.GetVGrid(4f, -1f, 30f);

            _categoryList.Begin(vGrid[1], true);

            var members = new Dictionary <string, RestrictionTemplate.Toggle[]>();

            foreach (var category in _template.Categories)
            {
                var state = category.GetListState();

                var showAll = _presetList.EditMode || (_rules.Pawn == null);
                if (_type == RestrictionType.Food)
                {
                    members[category.Label] = category.Members.Where(member => member.Def is ThingDef def && (!def.IsDrug || Registry.AllowDrugsRestriction) && (showAll || _rules.Pawn.RaceProps.CanEverEat(def))).ToArray();
                }
                else if (_type == RestrictionType.Bonding)
                {
                    members[category.Label] = category.Members.ToArray();
                }
                else
                {
                    throw new Mod.Exception("Unsupported restriction type");
                }

                if (members[category.Label].Length == 0)
                {
                    continue;
                }

                if (_presetList.EditMode)
                {
                    _categoryList.CheckboxPartial(category.Label, ref state);
                    category.UpdateState(state);
                }
                else
                {
                    GUI.color = GuiPlus.ReadOnlyColor;
                    _categoryList.CheckboxPartial(category.Label, ref state);
                    GUI.color = _color;
                }
            }

            _membersList.Gap();
            _categoryList.End();

            if (!_presetList.EditMode)
            {
                DoMembers(membersRect, members);
                return;
            }

            var hGrid           = vGrid[2].GetHGrid(4f, -1f, -1f);
            var categoryButtons = new Listing_Standard();

            categoryButtons.Begin(hGrid[1]);
            if (categoryButtons.ButtonText(Lang.Get("Button.RestrictionsAllowOn")))
            {
                _template.ToggleAll(true);
            }
            categoryButtons.End();
            categoryButtons.Begin(hGrid[2]);
            if (categoryButtons.ButtonText(Lang.Get("Button.RestrictionsAllowOff")))
            {
                _template.ToggleAll(false);
            }
            categoryButtons.End();

            DoMembers(membersRect, members);
        }