Commit dde492bb authored by Adam Leyshon's avatar Adam Leyshon
Browse files

Added some error trapping around the filter menu construction

parent 46683dae
......@@ -415,20 +415,27 @@ namespace Glitterworld_Prime
// Enumerate list of ThingCategoryDef and add to menu options.
var allDefsListForReading = DefDatabase<ThingCategoryDef>.AllDefsListForReading;
for (var i = 0; i < allDefsListForReading.Count; i++)
foreach (var def in allDefsListForReading)
{
var def = allDefsListForReading[i];
try
{
if (def.LabelCap.NullOrEmpty())
{
LogWriter.WriteMessage(
$"ThingCategoryDef {def.defName} has no label!, Not able to filter by this, skipping. Please report to Mod Author.");
continue;
}
if (def.LabelCap.NullOrEmpty())
// We'll never deal with corpses so don't show them.
if (def.LabelCap.ToLower().Contains("corpse")) continue;
list.Add(new FloatMenuOption(def.LabelCap, delegate { filterSetter(def); }));
}
catch (Exception e)
{
LogWriter.WriteMessage(
$"ThingCategoryDef {def.defName} has no label!, Not able to filter by this, skipping. Please report to Mod Author.");
Utilities.CaptureError(e);
continue;
}
// We'll never deal with corpses so don't show them.
if (!def.LabelCap.ToLower().Contains("corpse"))
list.Add(new FloatMenuOption(def.LabelCap, delegate { filterSetter(def); }));
}
Find.WindowStack.Add(new FloatMenu(list));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment