This commit is contained in:
AbstractConcept 2023-02-05 18:41:57 -06:00
parent 38ec4f86c1
commit ae95e34137
35 changed files with 242 additions and 612 deletions

View file

@ -42,8 +42,8 @@ namespace Rimworld_Animations_Patch
public class ApparelSettingsDisplay : Mod
{
private const float windowY = 290f;
private const float windowHeight = 320f;
private const float windowY = 240f;
private const float windowHeight = 360f;
private Vector2 scrollPosition;
private const float scrollBarWidthMargin = 18f;
@ -62,10 +62,10 @@ namespace Rimworld_Animations_Patch
private const float singleColumnWidth = 100f;
private const float doubleColumnWidth = 180f;
private IEnumerable<ThingDef> shortListedApparelDefs = new List<ThingDef>();
private IEnumerable<ThingDef> allApparelDefs = new List<ThingDef>();
private List<ThingDef> shortListedApparelDefs = new List<ThingDef>();
private List<ThingDef> allApparelDefs = new List<ThingDef>();
private IEnumerable<ModContentPack> relevantModContentPacks = new List<ModContentPack>();
private List<ModContentPack> relevantModContentPacks = new List<ModContentPack>();
private ModContentPack currentModContentPack;
public ApparelSettingsDisplay(ModContentPack content) : base(content)
@ -161,18 +161,19 @@ namespace Rimworld_Animations_Patch
bool isEnabled = false;
// Get a list of apparel and mods of interest
if (allApparelDefs.Any() == false)
if (allApparelDefs.NullOrEmpty())
{
allApparelDefs = ApparelSettingsUtility.GetApparelOfInterest();
foreach (ThingDef thingDef in allApparelDefs)
{
if (relevantModContentPacks.Contains(thingDef.modContentPack) == false)
{ relevantModContentPacks.Append(thingDef.modContentPack); }
}
{ relevantModContentPacks.AddDistinct(thingDef.modContentPack); }
currentModContentPack = relevantModContentPacks.First();
shortListedApparelDefs = allApparelDefs.Where(x => x.modContentPack == currentModContentPack);
currentModContentPack = relevantModContentPacks.FirstOrDefault();
if (currentModContentPack == null)
{ DebugMode.Message("ERROR: No mod content has been loaded?"); return; }
shortListedApparelDefs = allApparelDefs.Where(x => x.modContentPack == currentModContentPack)?.ToList();
}
// Ensure that all apparel has associated RimNudeData
@ -182,44 +183,29 @@ namespace Rimworld_Animations_Patch
// Add buttons to the top of the main window
innerX = halfColumnWidth;
// Mod selection button
if (Widgets.ButtonText(new Rect(innerX + SettingsUtility.Align(labelWidth, doubleColumnWidth), windowY - 2 * headerHeight - 5, 2 * doubleColumnWidth + 10, headerHeight), currentModContentPack.Name))
{
if (shortListedApparelDefs.NullOrEmpty()) return;
// Apparel
tempRect = new Rect(innerX + SettingsUtility.Align(labelWidth, doubleColumnWidth), windowY - headerHeight - 5, labelWidth, headerHeight);
Widgets.DrawHighlightIfMouseover(tempRect);
TooltipHandler.TipRegion(tempRect, "List of apparel that covers the legs and/or torso. Use the provided drop down menu to load apparel settings for different mods.");
if (Widgets.ButtonText(tempRect, "Apparel - " + currentModContentPack.ModMetaData.Name)) {
List<FloatMenuOption> options = new List<FloatMenuOption> { };
foreach (ModContentPack modContentPack in relevantModContentPacks)
{
FloatMenuOption option = new FloatMenuOption(modContentPack.Name, delegate ()
{
currentModContentPack = modContentPack;
shortListedApparelDefs = allApparelDefs.Where(x => x.modContentPack == currentModContentPack);
},
FloatMenuOption option = new FloatMenuOption(modContentPack.ModMetaData.Name, delegate ()
{
currentModContentPack = modContentPack;
shortListedApparelDefs = allApparelDefs.Where(x => x.modContentPack == currentModContentPack)?.ToList();
},
MenuOptionPriority.Default, null, null, 0f, null, null, true, 0);
options.Add(option);
}
Find.WindowStack.Add(new FloatMenu(options));
}
if (shortListedApparelDefs.Any() == false) return;
// Apparel
tempRect = new Rect(innerX + SettingsUtility.Align(labelWidth, doubleColumnWidth), windowY - headerHeight - 5, labelWidth, headerHeight);
Widgets.DrawHighlightIfMouseover(tempRect);
TooltipHandler.TipRegion(tempRect, "List of apparel that covers the legs and/or torso. This list can be sorted alphabetically or by the mod that added them.");
if (Widgets.ButtonText(tempRect, "Apparel"))
{
List<FloatMenuOption> options = new List<FloatMenuOption>
{
new FloatMenuOption("Sort by name", delegate()
{ shortListedApparelDefs = shortListedApparelDefs.OrderBy(x => x.label);
}, MenuOptionPriority.Default, null, null, 0f, null, null, true, 0),
new FloatMenuOption("Sort by mod", delegate()
{ shortListedApparelDefs = ApparelSettingsUtility.GetApparelOfInterest();
}, MenuOptionPriority.Default, null, null, 0f, null, null, true, 0),
}; Find.WindowStack.Add(new FloatMenu(options));
}; innerX += doubleColumnWidth;
// Covers groin