コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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();
                        if (e.Drawer.pawn != null)
                        {
                            UpdateApparelGraphicsFor(e.Drawer.pawn);
                        }
                    }, 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();
                                if (e.Drawer.pawn != null)
                                {
                                    UpdateApparelGraphicsFor(e.Drawer.pawn);
                                }
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = variant
                        });
                    }
                }
            }
            yield break;
        }
コード例 #3
0
 public PauldronTextureOption(PauldronTextureOption o)
 {
     faction      = o.faction;
     texPath      = o.texPath;
     color        = o.color;
     colorTwo     = o.colorTwo;
     label        = o.label ?? o.texPath;
     invertColors = o.invertColors;
 }
コード例 #4
0
        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;
        }