Ejemplo n.º 1
0
        // public static float horHeadOffset;
        protected override void DoBasicSettingsMenu(Listing_Standard listing)
        {
            base.DoBasicSettingsMenu(listing);

            //  listing.CheckboxLabeled("Moving", ref IsMoving);

            // listing_Standard.CheckboxLabeled("Equipment", ref Equipment);

            // listing_Standard.Label(horHeadOffset.ToString("N2") + " - " + verHeadOffset.ToString("N2"));
            // horHeadOffset = listing_Standard.Slider(horHeadOffset, -1f, 1f);
            // verHeadOffset = listing_Standard.Slider(verHeadOffset, -1f, 1f);
            listing.Label(this.BodyAnimDef.offCenterX.ToString("N2"));
            this.BodyAnimDef.offCenterX = listing.Slider(this.BodyAnimDef.offCenterX, -0.2f, 0.2f);

            if (listing.ButtonText(EditorWalkcycle.LabelCap))
            {
                List <string>          exists = new List <string>();
                List <FloatMenuOption> list   = new List <FloatMenuOption>();
                this.BodyAnimDef.walkCycles.Clear();

                foreach (WalkCycleDef walkcycle in (from bsm in DefDatabase <WalkCycleDef> .AllDefs
                                                    orderby bsm.LabelCap
                                                    select bsm)
                         .TakeWhile(current => this.BodyAnimDef.WalkCycleType != "None")
                         .Where(current => current.WalkCycleType ==
                                this.BodyAnimDef.WalkCycleType))
                {
                    list.Add(new FloatMenuOption(walkcycle.LabelCap, delegate { EditorWalkcycle = walkcycle; }));
                    exists.Add(walkcycle.locomotionUrgency.ToString());
                    this.BodyAnimDef.walkCycles.Add(walkcycle.locomotionUrgency, walkcycle);
                }

                string[] names = Enum.GetNames(typeof(LocomotionUrgency));
                for (int index = 0; index < names.Length; index++)
                {
                    string            name   = names[index];
                    LocomotionUrgency myenum = (LocomotionUrgency)Enum.ToObject(typeof(LocomotionUrgency), index);

                    if (exists.Contains(myenum.ToString()))
                    {
                        continue;
                    }

                    list.Add(
                        new FloatMenuOption(
                            "Add new " + this.BodyAnimDef.WalkCycleType + "_" + myenum,
                            delegate
                    {
                        WalkCycleDef newCycle = new WalkCycleDef();
                        newCycle.defName      =
                            newCycle.label    =
                                this.BodyAnimDef.WalkCycleType + "_" + name;
                        newCycle.locomotionUrgency = myenum;
                        newCycle.WalkCycleType     = this.BodyAnimDef.WalkCycleType;
                        GameComponent_FacialStuff.BuildWalkCycles(newCycle);
                        EditorWalkcycle = newCycle;

                        this.BodyAnimDef.walkCycles.Add(myenum, newCycle);
                    }));
                }

                Find.WindowStack.Add(new FloatMenu(list));
            }

            if (listing.ButtonText("This pawn is using: " + this.BodyAnimDef.WalkCycleType))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                List <WalkCycleDef> listy = DefDatabase <WalkCycleDef> .AllDefsListForReading;

                List <string> stringsy = new List <string>();

                foreach (WalkCycleDef cycleDef in listy)
                {
                    if (!stringsy.Contains(cycleDef.WalkCycleType))
                    {
                        stringsy.Add(cycleDef.WalkCycleType);
                    }
                }

                foreach (string s in stringsy)
                {
                    list.Add(new FloatMenuOption(s, delegate { this.BodyAnimDef.WalkCycleType = s; }));
                }

                Find.WindowStack.Add(new FloatMenu(list));
            }

            listing.Gap();
            string configFolder = DefPath;

            if (listing.ButtonText("Export BodyDef"))
            {
                string filePath = configFolder + "/BodyAnimDefs/" + this.BodyAnimDef.defName + ".xml";

                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        "Confirm overwriting " +
                        filePath,
                        delegate
                {
                    ExportAnimDefs.Defs animDef =
                        new ExportAnimDefs.Defs(this.BodyAnimDef);

                    DirectXmlSaver.SaveDataObject(
                        animDef,
                        filePath);
                },
                        true));

                // BodyAnimDef animDef = this.bodyAnimDef;
            }

            if (listing.ButtonText("Export WalkCycle"))
            {
                string path = configFolder + "/WalkCycleDefs/" + EditorWalkcycle.defName + ".xml";

                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        "Confirm overwriting " + path,
                        delegate
                {
                    ExportWalkCycleDefs.Defs cycle =
                        new ExportWalkCycleDefs.Defs(EditorWalkcycle);

                    DirectXmlSaver.SaveDataObject(
                        cycle,
                        path);
                },
                        true));
            }
        }
Ejemplo n.º 2
0
        // public static float horHeadOffset;
        protected override void DoBasicSettingsMenu(Listing_Standard listing)
        {
            base.DoBasicSettingsMenu(listing);

            GetBodyAnimDef();

            // listing_Standard.CheckboxLabeled("Equipment", ref Equipment);

            // listing_Standard.Label(horHeadOffset.ToString("N2") + " - " + verHeadOffset.ToString("N2"));
            // horHeadOffset = listing_Standard.Slider(horHeadOffset, -1f, 1f);
            // verHeadOffset = listing_Standard.Slider(verHeadOffset, -1f, 1f);
            listing.Label(CompAnim.BodyAnim.offCenterX.ToString("N2"));
            CompAnim.BodyAnim.offCenterX = listing.Slider(CompAnim.BodyAnim.offCenterX, -0.2f, 0.2f);

            if (listing.ButtonText(EditorPoseCycle?.LabelCap))
            {
                List <string>          exists = new List <string>();
                List <FloatMenuOption> list   = new List <FloatMenuOption>();
                CompAnim.BodyAnim.poseCycles.Clear();

                foreach (PoseCycleDef posecycle in (from bsm in DefDatabase <PoseCycleDef> .AllDefs
                                                    orderby bsm.LabelCap
                                                    select bsm)
                         .TakeWhile(current => CompAnim.BodyAnim.PoseCycleType != "None")
                         .Where(current => current.PoseCycleType ==
                                CompAnim.BodyAnim.PoseCycleType))
                {
                    list.Add(new FloatMenuOption(posecycle.LabelCap, delegate { EditorPoseCycle = posecycle; }));
                    exists.Add(posecycle.pawnPosture.ToString());
                    CompAnim.BodyAnim.poseCycles.Add(posecycle);
                }

                string[] names = Enum.GetNames(typeof(PawnPosture));
                for (int index = 0; index < names.Length; index++)
                {
                    string      name   = names[index];
                    PawnPosture myenum = (PawnPosture)Enum.ToObject(typeof(PawnPosture), index);

                    if (exists.Contains(myenum.ToString()))
                    {
                        continue;
                    }

                    list.Add(
                        new FloatMenuOption(
                            "Add new " + CompAnim.BodyAnim.PoseCycleType + "_" + myenum,
                            delegate
                    {
                        PoseCycleDef newCycle = new PoseCycleDef();
                        newCycle.defName      =
                            newCycle.label    =
                                CompAnim.BodyAnim.PoseCycleType + "_" + name;
                        newCycle.pawnPosture   = myenum;
                        newCycle.PoseCycleType = CompAnim.BodyAnim.PoseCycleType;
                        GameComponent_FacialStuff.BuildPoseCycles(newCycle);
                        EditorPoseCycle = newCycle;

                        CompAnim.BodyAnim.poseCycles.Add(newCycle);
                    }));
                }

                Find.WindowStack.Add(new FloatMenu(list));
            }

            listing.Gap();
            string configFolder = DefPath;

            if (listing.ButtonText("Export BodyDef"))
            {
                string filePath = configFolder + "/BodyAnimDefs/" + CompAnim.BodyAnim.defName + ".xml";

                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        "Confirm overwriting " +
                        filePath,
                        delegate
                {
                    ExportAnimDefs.Defs animDef =
                        new ExportAnimDefs.Defs(CompAnim.BodyAnim);

                    DirectXmlSaver.SaveDataObject(
                        animDef,
                        filePath);
                },
                        true));

                // BodyAnimDef animDef = this.bodyAnimDef;
            }

            if (listing.ButtonText("Export PoseCycle"))
            {
                string path = configFolder + "/PoseCycleDefs/" + EditorPoseCycle?.defName + ".xml";

                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        "Confirm overwriting " + path,
                        delegate
                {
                    ExportPoseCycleDefs.Defs cycle =
                        new ExportPoseCycleDefs.Defs(EditorPoseCycle);

                    DirectXmlSaver.SaveDataObject(
                        cycle,
                        path);
                },
                        true));
            }
        }