Skip to content

Commit

Permalink
nre fix in TagRestrictionsHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Denadan committed May 20, 2019
1 parent 19e3ab4 commit fc93c65
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

"CategoryDescriptionColor" : "#008000",

"TestEnableAllTags": true,
"TestEnableAllTags": false,
"OmniTechFlag": "cc_omnitech",
"OmniTechCostBySize": false,
"OmniTechInstallCost": 1,
Expand Down
2 changes: 1 addition & 1 deletion source/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void Init(string directory, string settingsJSON)
Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
Validator.RegisterMechValidator(CategoryController.Shared.ValidateMech, CategoryController.Shared.ValidateMechCanBeFielded);

Logger.Log("Loaded CustomComponents v0.9.7.0 for bt 1.5.1");
Logger.Log("Loaded CustomComponents v0.9.7.1 for bt 1.5.1");

Validator.RegisterMechValidator(TagRestrictionsHandler.Shared.ValidateMech, TagRestrictionsHandler.Shared.ValidateMechCanBeFielded);
Validator.RegisterDropValidator(pre: TagRestrictionsHandler.Shared.ValidateDrop);
Expand Down
57 changes: 34 additions & 23 deletions source/TagRestrictions/TagRestrictionsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,38 +321,49 @@ private static string NameForTag(string tag)

public void ProcessDescription(TagSet tags, DescriptionDef description)
{
string fulltags = "";
string shorttags = "";

foreach (var tag in Restrictions.Values)
try
{
if (tags.Contains(tag.Tag))
{
if (!string.IsNullOrEmpty(tag.ShortText))
shorttags += tag.ShortText + ", ";
if (!string.IsNullOrEmpty(tag.FullText))
fulltags += "\n" + tag.FullText;
}
}
if (tags == null || description == null)
return;

if (shorttags != "" || fulltags != "")
{
var trav = new Traverse(description).Property<string>("Details");
string fulltags = "";
string shorttags = "";

if (shorttags != "")
foreach (var tag in Restrictions.Values)
{
shorttags = shorttags.Substring(0, shorttags.Length - 2);
shorttags = "\n<b><color=" + Control.Settings.ShortTagsColor + ">[" + shorttags + "]</b></color>";
trav.Value = description.Details + shorttags;
;

if (tags.Contains(tag.Tag))
{
if (!string.IsNullOrEmpty(tag.ShortText))
shorttags += tag.ShortText + ", ";
if (!string.IsNullOrEmpty(tag.FullText))
fulltags += "\n" + tag.FullText;
}
}

if (fulltags != "")
if (shorttags != "" || fulltags != "")
{
trav.Value = description.Details + fulltags;
var trav = new Traverse(description).Property<string>("Details");

if (shorttags != "")
{
shorttags = shorttags.Substring(0, shorttags.Length - 2);
shorttags = "\n<b><color=" + Control.Settings.ShortTagsColor + ">[" + shorttags +
"]</b></color>";
trav.Value = description.Details + shorttags;
;

}

if (fulltags != "")
{
trav.Value = description.Details + fulltags;
}
}
}
catch (Exception e)
{
Control.LogError("Errpr in TagRestrictionHandler.ProcessDescription", e);
}

}
}
Expand Down

0 comments on commit fc93c65

Please sign in to comment.