public static void DrawFactionButton(Rect rect, CompPauldronDrawer comp, ShoulderPadEntry entry, bool paintable = false) { Rect rect1 = rect.LeftHalf().LeftHalf(); Rect rect2 = rect.LeftHalf().RightHalf(); rect2.width *= 2; Rect rect3 = rect.RightHalf().RightHalf(); Widgets.Label(rect1, comp.GetDescription(entry.shoulderPadType)); Widgets.Dropdown <ShoulderPadEntry, PauldronTextureOption> ( rect2, entry, (ShoulderPadEntry sp) => entry.Used, new Func <ShoulderPadEntry, IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > >(DrawFactionButton_GenerateMenu), entry.Used.Label, null, null, null, delegate() { }, paintable ); }
public static void SetApparelColours(ShoulderPadEntry e, PauldronTextureOption variant) { Graphic graphic = e.Drawer.Apparel.DefaultGraphic; Color color = graphic.Color; Color colorTwo = graphic.ColorTwo; graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); e.Drawer.Apparel.SetColors(color, colorTwo, true, null, graphic); { if (variant.Color.HasValue) { color = variant.Color.Value; } if (variant.ColorTwo.HasValue) { colorTwo = variant.ColorTwo.Value; } } graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); e.Drawer.Apparel.SetColors(color, colorTwo, true, variant.factionDef, graphic); if (e.Drawer.pawn != null) { UpdateApparelGraphicsFor(e.Drawer.pawn); } }
public float WestOffset(ShoulderPadEntry Entry) { if (Entry.WestOffset != 0) { return(Entry.WestOffset); } return(this.Props.WestOffset); }
public float SouthOffset(ShoulderPadEntry Entry) { if (Entry.SouthOffset != 0) { return(Entry.SouthOffset); } return(this.Props.SouthOffset); }
public Color mainColorFor(ShoulderPadEntry entry) { if (entry != null) { if (!entry.Options.NullOrEmpty()) { if (entry.Used.Color.HasValue) { // Log.Message("mainColorFor "+ entry.shoulderPadType + " activeOption: " + entry.Used.Label + " Color: "+ entry.Used.Color.Value); return(entry.Used.Color.Value); } } if (entry.UseFactionColors) { CompColorableTwoFaction colours = Colours as CompColorableTwoFaction; if (colours != null) { if (colours.Active) { // Log.Message("mainColorFor " + entry.shoulderPadType + " UseFactionColors"); return(colours.Color); } } /* * else * { * FactionDef def = pawn?.Faction?.def; * if (entry.FactionColours(out Color color, out Color colorTwo, def)) * { * if (color != Color.white) * { * return color; * } * } * } */ } if (entry.overridePrimaryColor.HasValue) { // Log.Message("mainColorFor " + entry.shoulderPadType + " overridePrimaryColor"); return(entry.overridePrimaryColor.Value); } if (entry.UseSecondaryColorAsPrimary) { if (entry.overrideSecondaryColor.HasValue) { // Log.Message("mainColorFor " + entry.shoulderPadType + " overrideSecondaryColor"); return(entry.overrideSecondaryColor.Value); } // Log.Message("mainColorFor " + entry.shoulderPadType + " DrawColorTwo"); return(this.parent.DrawColorTwo); } } // Log.Message("mainColorFor " + entry.shoulderPadType + " DrawColor"); return(this.parent.DrawColor); }
public static void DrawVariantButton(Rect rect, CompPauldronDrawer comp, ShoulderPadEntry entry, bool paintable) { Rect rect1 = rect.LeftHalf().LeftHalf(); Rect rect2 = rect.LeftHalf().RightHalf(); rect2.width *= 2; // entry.Drawer = comp; Rect rect3 = rect.RightHalf().RightHalf(); Widgets.Label(rect1, comp.GetDescription(entry.shoulderPadType)); Widgets.Dropdown <ShoulderPadEntry, PauldronTextureOption>(rect2, entry, (ShoulderPadEntry p) => p.Used, new Func <ShoulderPadEntry, IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > >(DrawVariantButton_GenerateMenu), entry.Used.Label, null, null, null, null, true); /* * Widgets.Dropdown<ShoulderPadEntry, PauldronTextureOption>(rect2, entry, * (ShoulderPadEntry sp) => sp.Used, * new Func<ShoulderPadEntry, IEnumerable<Widgets.DropdownMenuElement<PauldronTextureOption>>>(DrawVariantButton_GenerateMenu), * entry.VariantTextures.activeOption.Label, null, null, null, delegate () * { * * }, paintable); */ }
private static IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > DrawFactionButton_GenerateMenu(ShoulderPadEntry e) { if (e.Used != e.DefaultOption) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(e.DefaultOption.TexPath, delegate() { Graphic graphic = e.Drawer.apparel.DefaultGraphic; Color color = graphic.Color; Color colorTwo = graphic.ColorTwo; graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); /* * e.Drawer.apparel.SetColors(color, colorTwo, true, null, graphic); * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ e.Used = e.DefaultOption; e.faction = e.DefaultOption.factionDef; e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = e.DefaultOption }); } using (List <PauldronTextureOption> .Enumerator enumerator = e.Options.OrderBy(x => x.Label).ToList().GetEnumerator()) { while (enumerator.MoveNext()) { PauldronTextureOption variant = enumerator.Current; if (e.Used != variant) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(variant.Label.CapitalizeFirst() ?? variant.TexPath, delegate() { Graphic graphic = e.Drawer.apparel.Graphic; graphic.path += "_" + variant.TexPath; Color color = graphic.Color; Color colorTwo = graphic.ColorTwo; if (variant.factionDef != null) { // e.faction = variant.factionDef; if (variant.factionDef.HasModExtension <FactionDefExtension>()) { FactionDefExtension extension = variant.factionDef.GetModExtensionFast <FactionDefExtension>(); if (extension.factionColor != null) { color = extension.factionColor.Value; } if (extension.factionColorTwo != null) { colorTwo = extension.factionColorTwo.Value; } } } else { if (e.UseFactionColors) { if (variant.Color.HasValue) { color = variant.Color.Value; } if (variant.ColorTwo.HasValue) { colorTwo = variant.ColorTwo.Value; } } } graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); /* * e.Drawer.apparel.SetColors(color, colorTwo, true, variant.factionDef, graphic); * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ // Log.Message("set active"); e.faction = variant.factionDef; e.Used = variant; // Log.Message("Update PadGraphic"); e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = variant }); } } } yield break; }
private static IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > DrawVariantButton_GenerateMenu(ShoulderPadEntry e) { if (e.Used != e.DefaultOption) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(e.DefaultOption.TexPath, delegate() { e.activeOption = e.DefaultOption; /* * if (e.UseFactionColors) * { * SetApparelColours(e, e.DefaultOption); * } */ e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = e.DefaultOption }); } using (List <PauldronTextureOption> .Enumerator enumerator = e.Options.GetEnumerator()) { while (enumerator.MoveNext()) { PauldronTextureOption variant = enumerator.Current; if (e.Used != variant) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(variant.Label.CapitalizeFirst() ?? variant.TexPath, delegate() { e.Used = variant; /* * if (e.UseFactionColors) * { * SetApparelColours(e, variant); * } */ e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = variant }); } } } yield break; }
public Vector3 WestOffset(ShoulderPadEntry Entry) { return(this.Props.WestOffset + Entry.Props.WestOffset); }
public Vector3 SouthOffset(ShoulderPadEntry Entry) { return(this.Props.SouthOffset + Entry.Props.SouthOffset); }
public Color secondaryColorFor(ShoulderPadEntry entry) { Color secondary = apparel.DrawColorTwo; string log = (pawn != null ? pawn.NameShortColored.ToString() + "'s " : string.Empty) + parent.LabelCap + " secondaryColorFor " + entry.shoulderPadType; if (entry != null) { if (entry.UsePrimaryColorAsSecondary) { log += " UsePrimaryColorAsSecondary"; } if (!entry.Options.NullOrEmpty()) { if (entry.Used.ColorTwo != null) { secondary = entry.UsePrimaryColorAsSecondary ? entry.Used.Color.Value : entry.Used.ColorTwo.Value; log += " activeOption: " + secondary; // Log.Message(log); return(secondary); } } if (entry.overrideSecondaryColor.HasValue) { // Log.Message("secondaryColorFor " + entry.shoulderPadType + " overrideSecondaryColor"); secondary = entry.overrideSecondaryColor.Value; log += " overrideSecondaryColor: " + secondary; // Log.Message(log); return(secondary); } if (entry.UsePrimaryColorAsSecondary) { log += " UsePrimaryColorAsSecondary"; if (entry.overridePrimaryColor.HasValue) { // Log.Message("secondaryColorFor " + entry.shoulderPadType + " overridePrimaryColor"); secondary = entry.overrideSecondaryColor.Value; log += " overridePrimaryColor: " + secondary; // Log.Message(log); return(secondary); } // Log.Message("secondaryColorFor " + entry.shoulderPadType + " DrawColor"); secondary = this.parent.DrawColor; log += " DrawColor: " + secondary; // Log.Message(log); return(this.parent.DrawColor); } if (entry.UseFactionColors) { if (Colours is CompColorableTwoFaction colours) { if (colours.FactionActiveTwo) { secondary = entry.UsePrimaryColorAsSecondary ? colours.Color : colours.ColorTwo; log += " UseFactionColors: " + secondary; // Log.Message(log); return(secondary); } } /* * else * { * FactionDef def = pawn?.Faction?.def; * if (entry.FactionColours(out Color color, out Color colorTwo, def)) * { * if (colorTwo != Color.white) * { * return colorTwo; * } * } * } */ } } // Log.Message("secondaryColorFor " + entry.shoulderPadType + " DrawColorTwo"); log += " DrawColorTwo: " + secondary; // Log.Message(log); return(secondary); }
public void Initialize() { if (!pauldronInitialized) { // Log.Message(apparel.LabelShortCap + " pauldrons initializing"); if (activeEntries.EnumerableNullOrEmpty()) { activeEntries = new List <ShoulderPadEntry>(); } if (Props.drawAll) { for (int i = 0; i < Props.PauldronEntries.Count; i++) { ShoulderPadEntry entry = new ShoulderPadEntry(Props.PauldronEntries[i], this); activeEntries.Add(entry); } } else { #pragma warning disable CS0219 // Variable is assigned but its value is never used bool backpack = false; bool bothPauldrons = false; bool leftPauldron = false; bool rightPauldron = false; #pragma warning restore CS0219 // Variable is assigned but its value is never used ShoulderPadEntry entry = new ShoulderPadEntry(Props.PauldronEntries.RandomElementByWeight(x => x.commonality), this); if (!entry.Options.NullOrEmpty()) { entry.Used = entry.DefaultOption; } activeEntries.Add(entry); } /* * if (!activeEntries.EnumerableNullOrEmpty()) * { * // Log.Message("activeEntries count " + activeEntries.Count); * } */ } else { // Log.Message(apparel.LabelShortCap + " pauldrons initialized"); foreach (ShoulderPadEntry item in activeEntries) { // item.Drawer = this; item.UpdateProps(); item.apparel = this.apparel; /* * if (Props.PauldronEntries.Any(x => x.padTexPath == item.padTexPath && x.shoulderPadType == item.shoulderPadType)) * { * item.EastOffset = Props.PauldronEntries.Find(x => x.padTexPath == item.padTexPath && x.shoulderPadType == item.shoulderPadType).EastOffset; * item.WestOffset = Props.PauldronEntries.Find(x => x.padTexPath == item.padTexPath && x.shoulderPadType == item.shoulderPadType).WestOffset; * item.NorthOffset = Props.PauldronEntries.Find(x => x.padTexPath == item.padTexPath && x.shoulderPadType == item.shoulderPadType).NorthOffset; * item.SouthOffset = Props.PauldronEntries.Find(x => x.padTexPath == item.padTexPath && x.shoulderPadType == item.shoulderPadType).SouthOffset; * } */ } if (Props.drawAll && Props.PauldronEntries.Count != activeEntries.Count) { if (Props.PauldronEntries.Count > activeEntries.Count) { foreach (ShoulderPadProperties props in Props.PauldronEntries) { if (!activeEntries.Any(x => x.Props == props)) { ShoulderPadEntry entry = new ShoulderPadEntry(props, this); activeEntries.Add(entry); } } } } } }