Example #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();
        }
Example #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);
        }
Example #3
0
        private void DoHeader(Rect rect)
        {
            var grid = rect.GetHGrid(8f, 200f, -1f, -1f);

            _headerList.Begin(grid[1]);
            _headerList.Label(Lang.Get("Preset.Header").Italic().Bold());
            _headerList.GapLine();
            _headerList.End();

            _headerList.Begin(grid[2]);
            _headerList.Label(Lang.Get("Dialog_Restrictions.HeaderCategory").Italic().Bold());
            _headerList.GapLine();
            _headerList.End();

            _headerList.Begin(grid[3]);
            _headerList.Label(_type.Categorization.Italic().Bold());
            _headerList.GapLine();
            _headerList.End();
        }
Example #4
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);
        }
Example #5
0
        public void DoContent(Rect rect)
        {
            var selectedIsIgnored = Selected.IsIgnored();
            var presets           = Registry.GetPresets <T>(Type).ToArray();

            _listing.Begin(rect);
            foreach (var preset in FixedPresets)
            {
                var isSelected = (Selected == preset) || (Selected.Name == preset.Name);
                if (_listing.RadioButtonInverted(preset.GetDisplayName().Italic(), isSelected, null, !EditMode || isSelected))
                {
                    ChangeSelected(preset);
                }
            }
            if (presets.Any())
            {
                _listing.GapLine();
            }
            _listing.End();

            var presetGrid = rect.GetVGrid(4f, _listing.CurHeight, -1f, 62f);

            _presetListing.Begin(presetGrid[2], true);
            foreach (var preset in presets)
            {
                var isSelected = (Selected == preset) || (Selected.Name == preset.Name);
                if (_presetListing.RadioButtonInverted(preset.Name, isSelected, null, !EditMode || isSelected))
                {
                    ChangeSelected(preset);
                }
            }
            _presetListing.End();

            var buttonGrid = presetGrid[3].GetHGrid(4f, -1f, -1f);

            _listing.Begin(buttonGrid[1]);

            if (_listing.ButtonText(Lang.Get("Button.PresetNew"), Lang.Get("Button.PresetNewDesc"), !EditMode))
            {
                Presetable.SetName <T>(Type, CreatePreset);
            }

            if (EditMode)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetSave"), Lang.Get("Button.PresetSaveDesc")))
                {
                    Commit();
                    ChangeEditMode(false);
                    OnSave?.Invoke();
                }
            }
            else if (Selected.IsPreset)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetEdit"), Lang.Get("Button.PresetEditDesc"), !Selected.IsVoid))
                {
                    ChangeEditMode(true);
                }
            }
            else
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetSaveAs"), Lang.Get("Button.PresetSaveAsDesc"), !Selected.IsVoid && !selectedIsIgnored))
                {
                    OnSave?.Invoke();
                }
            }

            _listing.End();
            _listing.Begin(buttonGrid[2]);

            if (_listing.ButtonText(Lang.Get("Button.PresetDelete"), Lang.Get("Button.PresetDeleteDesc"), !Selected.IsVoid && Selected.IsPreset && !EditMode))
            {
                Dialog_Alert.Open(Lang.Get("Button.PresetDeleteConfirm", Selected.Name), Dialog_Alert.Buttons.YesNo, DeletePreset);
            }

            if (EditMode)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetRevert"), Lang.Get("Button.PresetRevertDesc"), !Selected.IsVoid))
                {
                    Revert();

                    ChangeEditMode(false);
                    OnRevert?.Invoke();
                }
            }
            else if (Selected.IsPreset)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetRename"), Lang.Get("Button.PresetRenameDesc"), !Selected.IsVoid && !EditMode))
                {
                    Presetable.SetName(Selected, ChangeSelected);
                }
            }
            else
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetClear"), Lang.Get("Button.PresetClearDesc"), !Selected.IsVoid && !selectedIsIgnored))
                {
                    OnRevert?.Invoke();
                }
            }

            _listing.End();
        }
Example #6
0
        public void DoContent(Rect rect)
        {
            var selectedIsIgnored = Selected.IsIgnored();
            var presets           = Registry.GetPresets <T>(Type);

            _listing.Begin(rect);
            foreach (var preset in FixedPresets)
            {
                var isSelected = (Selected == preset) || (Selected.Name == preset.Name);
                if (_listing.RadioButtonInverted((preset.IsPreset ? preset.Name : Lang.Get("Preset.Personalized")).Italic(), isSelected, null, !EditMode || isSelected))
                {
                    ChangeSelected(preset);
                }
            }
            if (presets.Any())
            {
                _listing.GapLine();
            }
            _listing.End();

            var presetGrid = rect.GetVGrid(4f, _listing.CurHeight, 0f, 62f);

            _presetListing.Begin(presetGrid[1], true);
            foreach (var preset in presets)
            {
                var isSelected = (Selected == preset) || (Selected.Name == preset.Name);
                if (_presetListing.RadioButtonInverted(preset.Name, isSelected, null, !EditMode || isSelected))
                {
                    ChangeSelected(preset);
                }
            }
            _presetListing.End();

            var buttonGrid = presetGrid[2].GetHGrid(4f, 0f, 0f);

            _listing.Begin(buttonGrid[0]);

            if (_listing.ButtonText(Lang.Get("Button.PresetNew"), Lang.Get("Button.PresetNewDesc"), !EditMode))
            {
                Find.WindowStack.Add(new Dialog_PresetName <T>(Type, preset =>
                {
                    _lastSelected = Selected;
                    ChangeEditMode(true);
                    ChangeSelected(preset);
                }));
            }

            if (EditMode)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetSave"), Lang.Get("Button.PresetSaveDesc")))
                {
                    Commit();
                    ChangeEditMode(false);
                    OnSave?.Invoke();
                }
            }
            else if (Selected.IsPreset)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetEdit"), Lang.Get("Button.PresetEditDesc"), !Selected.IsVoid))
                {
                    ChangeEditMode(true);
                }
            }
            else
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetSaveAs"), Lang.Get("Button.PresetSaveAsDesc"), !Selected.IsVoid && !selectedIsIgnored))
                {
                    OnSave?.Invoke();
                }
            }

            _listing.End();
            _listing.Begin(buttonGrid[1]);

            if (_listing.ButtonText(Lang.Get("Button.PresetDelete"), Lang.Get("Button.PresetDeleteDesc"), !Selected.IsVoid && Selected.IsPreset && !EditMode))
            {
                Find.WindowStack.Add(new Dialog_Alert(Lang.Get("Button.PresetDeleteConfirm", Selected.Name), Dialog_Alert.Buttons.YesNo, () =>
                {
                    Registry.DeletePreset(Selected);
                    ChangeSelected(Registry.GetVoidPreset <T>(Type));
                }));
            }

            if (EditMode)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetRevert"), Lang.Get("Button.PresetRevertDesc"), !Selected.IsVoid))
                {
                    Revert();

                    ChangeEditMode(false);
                    OnRevert?.Invoke();
                }
            }
            else if (Selected.IsPreset)
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetRename"), Lang.Get("Button.PresetRenameDesc"), !Selected.IsVoid && !EditMode))
                {
                    Find.WindowStack.Add(new Dialog_PresetName <T>(Selected, ChangeSelected));
                }
            }
            else
            {
                if (_listing.ButtonText(Lang.Get("Button.PresetClear"), Lang.Get("Button.PresetClearDesc"), !Selected.IsVoid && !selectedIsIgnored))
                {
                    OnRevert?.Invoke();
                }
            }

            _listing.End();
        }