Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
- Any of the core rules (Food Policy, Bonding Policy, Allow Courting, Allow Artisan) can be hidden by disabling them in the Global Options menu.
  • Loading branch information
Jaxe-Wilde committed Sep 1, 2018
1 parent 5a20bf4 commit a906c90
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<name>Pawn Rules</name>
<author>Jaxe</author>
<targetVersion>0.19.0</targetVersion>
<description>Pawn Rules is a mod that allows custom rules to be assigned individually to your colonists, animals, guests and prisoners.\n\nCurrently the following rules can be applied:\n\n- Disallow certain foods\n- Disallow bonding with certain animals\n- Disallow new romances\n- Disallow constructing items that have a quality level\n\n</description>
<description>Pawn Rules is a mod that allows custom rules to be assigned individually to your colonists, animals, guests and prisoners.\n\nCurrently the following rules can be applied:\n\n- Disallow certain foods\n- Disallow bonding with certain animals\n- Disallow new romances\n- Disallow constructing items that have a quality level\n\nAny of these rules can be disabled and hidden from the rules window.</description>
<url>https://ludeon.com/forums/index.php?topic=43086.0</url>
</ModMetaData>
2 changes: 1 addition & 1 deletion About/ModSync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ModSyncNinjaData>
<ID>59f538ed-f86d-4506-a4a5-7e9faaa37508</ID>
<ModName>Pawn Rules</ModName>
<Version>v1.0.4</Version>
<Version>v1.0.5</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>Jaxe-Dev</Owner>
Expand Down
Binary file modified About/Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions About/PublishedFileId.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1499843448
1 change: 1 addition & 0 deletions Languages/English/Keyed/PawnRules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<PawnRules.Gizmo.EditRulesDesc>Edit the rules for this {0}.</PawnRules.Gizmo.EditRulesDesc>

<PawnRules.Dialog_Global.Title>Global Options</PawnRules.Dialog_Global.Title>
<PawnRules.Dialog_Global.ShowRule>Show {0}</PawnRules.Dialog_Global.ShowRule>

<PawnRules.Dialog_Rules.Title>Rules for {0}, {1}</PawnRules.Dialog_Rules.Title>
<PawnRules.Dialog_Rules.TitleDefault>Default Rules for {0}</PawnRules.Dialog_Rules.TitleDefault>
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pawn Rules
![](https://img.shields.io/badge/Version-1.0.4-brightgreen.svg)
![](https://img.shields.io/badge/Version-1.0.5-brightgreen.svg)

Built for **RimWorld 1.0.x / 0.19.x**\
Powered by **Harmony**\
Expand All @@ -21,6 +21,8 @@ Currently the following rules can be applied:
- Disallow constructing items that have a quality level
- *Can still haul materials to blueprints*

Any of these rules can be disabled and hidden from the rules window.

------------

Supports addons created by other modders by allowing easy creation of new rule options while handling the GUI and world storage saving. For more information check out the [wiki page on Addons](https://github.com/Jaxe-Dev/PawnRules/wiki/Addons).
Expand Down
15 changes: 15 additions & 0 deletions Source/Data/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ internal class Registry : WorldObject

private static bool _isDeactivating;

public static bool ShowFoodPolicy { get => Instance._showFoodPolicy; set => Instance._showFoodPolicy = value; }
public static bool ShowBondingPolicy { get => Instance._showBondingPolicy; set => Instance._showBondingPolicy = value; }
public static bool ShowAllowCourting { get => Instance._showAllowCourting; set => Instance._showAllowCourting = value; }
public static bool ShowAllowArtisan { get => Instance._showAllowArtisan; set => Instance._showAllowArtisan = value; }

private readonly Dictionary<Type, Dictionary<IPresetableType, Presetable>> _voidPresets = new Dictionary<Type, Dictionary<IPresetableType, Presetable>>();
private readonly Dictionary<Type, Dictionary<IPresetableType, Dictionary<string, Presetable>>> _presets = new Dictionary<Type, Dictionary<IPresetableType, Dictionary<string, Presetable>>>();
private readonly Dictionary<PawnType, Rules> _defaults = new Dictionary<PawnType, Rules>();
Expand All @@ -30,6 +35,11 @@ internal class Registry : WorldObject
private List<Binding> _savedBindings = new List<Binding>();
private List<Binding> _savedDefaults = new List<Binding>();

private bool _showFoodPolicy = true;
private bool _showBondingPolicy = true;
private bool _showAllowCourting = true;
private bool _showAllowArtisan = true;

public static void Initialize()
{
var worldObjects = Current.Game.World.worldObjects;
Expand Down Expand Up @@ -282,6 +292,11 @@ public override void ExposeData()
_savedBindings.AddRange(_rules.Where(rules => rules.Key.CanHaveRules()).Select(rules => new Binding(rules.Key, rules.Value.IsIgnored() ? null : rules.Value)).ToArray());
}

Scribe_Values.Look(ref _showFoodPolicy, "showFoodPolicy", true);
Scribe_Values.Look(ref _showBondingPolicy, "showBondingPolicy", true);
Scribe_Values.Look(ref _showAllowCourting, "showAllowCourting", true);
Scribe_Values.Look(ref _showAllowArtisan, "showAllowArtisan", true);

Scribe_Collections.Look(ref _savedPresets, "presets", LookMode.Deep);
Scribe_Collections.Look(ref _savedBindings, "bindings", LookMode.Deep);
Scribe_Collections.Look(ref _savedDefaults, "defaults", LookMode.Deep);
Expand Down
17 changes: 17 additions & 0 deletions Source/Interface/Dialog_Global.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using PawnRules.Data;
using PawnRules.Patch;
using UnityEngine;
using Verse;

Expand All @@ -13,8 +14,24 @@ public override void DoContent(Rect rect)
{
var listing = new Listing_Standard();
listing.Begin(rect);

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

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

if (listing.ButtonText(Lang.Get("Button.RemoveMod"), Lang.Get("Button.RemoveModDesc"))) { Find.WindowStack.Add(new Dialog_Alert(Lang.Get("Button.RemoveModConfirm"), Dialog_Alert.Buttons.YesNo, Registry.DeactivateMod)); }
listing.End();
}

private static bool ShowRuleListing(Listing_Standard listing, string label, bool value)
{
listing.CheckboxLabeled(Lang.Get("Dialog_Global.ShowRule", label.Italic()), ref value);
return value;
}
}
}
17 changes: 10 additions & 7 deletions Source/Interface/Dialog_Rules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void AssignSpecific(Pawn pawn)
Find.WindowStack.Add(new Dialog_Alert(Lang.Get("Dialog_Rules.AssignSpecificConfirm", GetPresetNameDefinite(), pawn.Name.ToString().Italic()), Dialog_Alert.Buttons.YesNo, OnAccept));
}

private string GetRestrictionDisplayName(Presetable restriction) => restriction.IsPreset && !restriction.IsVoid ? restriction.Name.Bold() : restriction.Name;
private static string GetRestrictionDisplayName(Presetable restriction) => restriction.IsPreset && !restriction.IsVoid ? restriction.Name.Bold() : restriction.Name;

public override void Close(bool doCloseSound = true)
{
Expand Down Expand Up @@ -222,15 +222,18 @@ public override void DoContent(Rect rect)
if (!editMode) { GUI.color = GuiPlus.ReadOnlyColor; }

listing.Begin(vGrid[1]);
if (listing.ButtonText(Lang.Get("Rules.FoodRestrictions", GetRestrictionDisplayName(_template.GetRestriction(RestrictionType.Food))), Lang.Get("Rules.FoodRestrictionsDesc")) && editMode) { ChangeRestriction(RestrictionType.Food); }
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 (listing.ButtonText(Lang.Get("Rules.BondingRestrictions", GetRestrictionDisplayName(_template.GetRestriction(RestrictionType.Bonding))), Lang.Get("Rules.BondingRestrictionsDesc")) && editMode) { ChangeRestriction(RestrictionType.Bonding); }
listing.GapLine();
listing.CheckboxLabeled(Lang.Get("Rules.AllowCourting"), ref _template.AllowCourting, Lang.Get("Rules.AllowCourtingDesc"), editMode);
listing.CheckboxLabeled(Lang.Get("Rules.AllowArtisan"), ref _template.AllowArtisan, Lang.Get("Rules.AllowArtisanDesc"), editMode);
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); }
}
listing.GapLine();

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

listing.End();

if (_template.HasAddons)
Expand Down
2 changes: 1 addition & 1 deletion Source/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class Mod : Verse.Mod
public const string Id = "PawnRules";
public const string Name = "Pawn Rules";
public const string Author = "Jaxe";
public const string Version = "1.0.4";
public const string Version = "1.0.5";

public static ModContentPack ContentPack { get; private set; }

Expand Down

0 comments on commit a906c90

Please sign in to comment.