コード例 #1
0
        public StorageGroupUI(StoredApparelSet set, ApparelFromEnum apparelFrom, Building_Dresser dresser, Pawn pawn, bool isNew, bool fromGizmo = false)
        {
            this.set         = set;
            this.ApparelFrom = apparelFrom;
            this.Dresser     = dresser;
            this.Pawn        = pawn;
            this.IsNew       = isNew;
            this.FromGizmo   = fromGizmo;
            if (this.FromGizmo)
            {
                if (this.set.HasOwner)
                {
                    this.isRestricted = true;
                }

                this.PlayerPawns = new List <Pawn>();
                foreach (Pawn p in PawnsFinder.AllMaps_SpawnedPawnsInFaction(Faction.OfPlayer))
                {
                    if (p.def.defName.Equals("Human"))
                    {
                        this.PlayerPawns.Add(p);
                    }
                }
            }

            this.closeOnEscapeKey        = false;
            this.doCloseButton           = false;
            this.doCloseX                = false;
            this.absorbInputAroundWindow = true;
            this.forcePause              = true;
        }
コード例 #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Building_Dresser dresser = (Building_Dresser)this.TargetA.Thing;
                    Pawn pawn = this.GetActor();

                    string lookForId = this.TargetB.Thing.ThingID;
                    for (int i = 0; i < dresser.StoredApparel.Count; ++i)
                    {
                        Apparel a = dresser.StoredApparel[i];
                        if (lookForId.Equals(a.ThingID))
                        {
                            pawn.apparel.Wear(a, true);
                            dresser.StoredApparel.RemoveAt(i);
                            break;
                        }
                    }
                }
            });

            yield break;
        }
コード例 #3
0
        public AssignOutfitUI(Building_Dresser dresser)
        {
            this.Dresser = dresser;

            this.closeOnClickedOutside = true;
            this.doCloseButton         = true;
            this.doCloseX = true;
            this.absorbInputAroundWindow = true;
            this.forcePause            = true;
            this.closeOnClickedOutside = false;

            foreach (Pawn p in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists)
            {
                if (p.Faction == Faction.OfPlayer && p.def.race.Humanlike)
                {
                    if (!WorldComp.PawnOutfits.ContainsKey(p))
                    {
                        PawnOutfitTracker po = new PawnOutfitTracker();
                        po.Pawn = p;
                        Outfit currentOutfit = p.outfits.CurrentOutfit;
                        if (currentOutfit != null)
                        {
                            po.AddOutfit(new DefinedOutfit(currentOutfit, WorldComp.GetOutfitType(currentOutfit)));
                        }
                        WorldComp.PawnOutfits.Add(p, po);
                    }
                }
            }
        }
コード例 #4
0
 public static List <StoredApparelSet> GetApparelSets(Building_Dresser dresser)
 {
     if (dresser != null)
     {
         return(GetApparelSets(dresser.ThingID));
     }
     return(new List <StoredApparelSet>());
 }
コード例 #5
0
        public StorageUI(Building_Dresser dresser, Pawn pawn)
        {
            this.Dresser = dresser;
            this.Pawn    = pawn;

            this.closeOnClickedOutside = true;
            this.doCloseButton         = true;
            this.doCloseX = true;
            this.absorbInputAroundWindow = true;
            this.forcePause = true;
        }
コード例 #6
0
        public StorageUI(Building_Dresser dresser, Pawn pawn, bool fromGizmo = false)
        {
            this.Dresser   = dresser;
            this.Pawn      = pawn;
            this.FromGizmo = fromGizmo;

            this.closeOnEscapeKey        = true;
            this.doCloseButton           = true;
            this.doCloseX                = true;
            this.absorbInputAroundWindow = true;
            this.forcePause              = true;
        }
コード例 #7
0
 public static List <StoredApparelSet> RemoveApparelSets(Building_Dresser dresser)
 {
     if (dresser != null)
     {
         List <StoredApparelSet> l = new List <StoredApparelSet>();
         for (LinkedListNode <StoredApparelSet> n = storedApparelSets.First; n.Next != null; n = n.Next)
         {
             if (n.Value.ParentDresserId.Equals(dresser.ThingID))
             {
                 l.Add(n.Value);
                 storedApparelSets.Remove(n);
             }
         }
     }
     return(new List <StoredApparelSet>(0));
 }
コード例 #8
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Building_Dresser dresser = (Building_Dresser)base.CurJob.targetA;
                    string apparelGroupName = ((SwapApparelJob)base.CurJob).ApparelGroupName;
                    Pawn pawn = this.GetActor();

                    StoredApparelSet setToGet = null;

                    IEnumerable <StoredApparelSet> sets;
                    if (Settings.LinkGroupsToDresser)
                    {
                        sets = StoredApparelContainer.GetApparelSets(dresser);
                    }
                    else
                    {
                        sets = StoredApparelContainer.GetAllApparelSets();
                    }

                    foreach (StoredApparelSet set in sets)
                    {
                        if (set.IsOwnedBy(pawn) && set.Name.Equals(apparelGroupName))
                        {
                            setToGet = set;
                            break;
                        }
                    }
                    if (setToGet == null)
                    {
                        Messages.Message(pawn.Name.ToStringShort + " " + "ChangeDresser.UnableToWearApparelGroup".Translate() + " " + apparelGroupName + ".", MessageSound.Negative);
                    }
                    else
                    {
                        setToGet.SwapApparel(pawn);
                    }
                }
            });

            yield break;
        }
コード例 #9
0
        public static DresserDTO Create(Pawn pawn, Job job, CurrentEditorEnum selectedEditor)
        {
            bool isAlien = AlienRaceUtil.IsAlien(pawn);
            IEnumerable <CurrentEditorEnum> editors;

            if (job.targetA.Thing is Building_Dresser)
            {
                editors = Building_Dresser.GetSupportedEditors(isAlien);
            }
            else
            {
                editors = Building_ChangeMirror.GetSupportedEditors(isAlien);
            }

            if (isAlien)
            {
                return(new AlienDresserDTO(pawn, selectedEditor, editors));
            }
            return(new DresserDTO(pawn, selectedEditor, editors));
        }
コード例 #10
0
        public CustomOutfitUI(Building_Dresser dresser)
        {
#if CUSTOM_OUTFIT_UI
            Log.Warning("Begin CustomOutfitUI.CustomOutfitUI(Dresser: " + dresser.Label + ")");
#endif
            this.Dresser = dresser;

            this.closeOnClickedOutside = false;
            this.doCloseButton         = false;
            this.doCloseX = false;
            this.absorbInputAroundWindow = true;
            this.forcePause = true;

            WorldComp.CleanupCustomOutfits();

#if CUSTOM_OUTFIT_UI
            Log.Message("    Populate Selectable Pawns:");
#endif
            foreach (Pawn p in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists)
            {
#if CUSTOM_OUTFIT_UI
                Log.Message("        " + p.Name.ToStringShort + " " + p.Faction + " " + p.def.defName);
#endif
                if (p.Faction == Faction.OfPlayer && p.def.race.Humanlike && p.apparel?.LockedApparel?.Count == 0)
                {
#if CUSTOM_OUTFIT_UI
                    Log.Message("            -- Added");
#endif
                    selectablePawns.Add(p);
                }
            }

            this.UpdateAvailableApparel();

#if CUSTOM_OUTFIT_UI
            Log.Warning("End CustomOutfitUI.CustomOutfitUI");
#endif
        }
コード例 #11
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A));

            yield return(new Toil
            {
                initAction = delegate
                {
#if DEBUG || DEBUG_TRACKER
                    Log.Message(System.Environment.NewLine + "Begin JobDriver_WearApparelFromStorage");
#endif
                    Building_Dresser dresser = (Building_Dresser)this.TargetA.Thing;
                    Pawn pawn = this.GetActor();

                    Thing t = this.TargetB.Thing;
                    if (t is Apparel &&
                        dresser.RemoveNoDrop((Apparel)t))
                    {
                        List <Apparel> worn = new List <Apparel>(pawn.apparel.WornApparel);
                        foreach (Apparel w in worn)
                        {
#if DEBUG || DEBUG_TRACKER
                            Log.Warning(" Remove " + w.Label);
#endif
                            if (Settings.KeepForcedApparel && pawn.outfits.forcedHandler.IsForced(w))
                            {
                                continue;
                            }
                            pawn.apparel.Remove(w);
                        }

#if DEBUG || DEBUG_TRACKER
                        Log.Warning(" Thing to wear as new: " + t.Label);
#endif
                        pawn.apparel.Wear((Apparel)t, true);

                        foreach (Apparel w in worn)
                        {
                            if (pawn.apparel.CanWearWithoutDroppingAnything(w.def))
                            {
                                pawn.apparel.Wear(w);
                            }
                            else
                            {
                                dresser.AddApparel(w);
                            }
                        }

                        /*PawnOutfits outfits;
                         * if (WorldComp.PawnOutfits.TryGetValue(pawn, out outfits))
                         * {
                         *  outfits.ColorApparel(pawn);
                         * }*/
                    }
#if DEBUG || DEBUG_TRACKER
                    Log.Message("End JobDriver_WearApparelFromStorage" + System.Environment.NewLine);
#endif
                }
            });

            yield break;
        }
コード例 #12
0
        public override void DoWindowContents(Rect inRect)
        {
            try
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.ApparelStorageLabel".Translate());

                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                this.Filter = Widgets.TextArea(new Rect(250, 0, 150, 32), this.Filter);

                Text.Anchor = TextAnchor.MiddleCenter;
                if (Widgets.ButtonText(new Rect(425, 0, 250, 32), ((this.Dresser == null) ? (string)"ChangeDresser".Translate() : this.Dresser.Label)))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>();
                    foreach (Building_Dresser cd in WorldComp.GetDressers(null))
                    {
                        options.Add(new FloatMenuOption(cd.Label, delegate()
                        {
                            this.Dresser = cd;
                        }));
                    }
                    Find.WindowStack.Add(new FloatMenu(options));
                }

                if (this.Dresser == null)
                {
                    return;
                }

                Text.Font = GameFont.Small;

                List <Apparel> wornApparel = (this.Pawn != null) ? this.Pawn.apparel.WornApparel : null;

                const float cellHeight       = 40f;
                float       apparelListWidth = inRect.width * 0.5f - 10f;
                Rect        apparelListRect;
                Rect        apparelScrollRect;

                if (wornApparel != null)
                {
                    GUI.Label(new Rect(0, 60, 100, 30), ("ChangeDresser.Worn").Translate(), WidgetUtil.MiddleCenter);

                    apparelListRect   = new Rect(0, 90, apparelListWidth, inRect.height - 130);
                    apparelScrollRect = new Rect(0f, 0f, apparelListWidth - 16f, wornApparel.Count * cellHeight);

                    GUI.BeginGroup(apparelListRect);
                    this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect);

                    GUI.color = Color.white;
                    Text.Font = GameFont.Medium;
                    for (int i = 0; i < wornApparel.Count; ++i)
                    {
                        Apparel apparel = wornApparel[i];
                        Rect    rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight);
                        GUI.BeginGroup(rowRect);

                        Widgets.ThingIcon(new Rect(0f, 0f, cellHeight, cellHeight), apparel);

                        if (Widgets.InfoCardButton(40, 0, apparel))
                        {
                            Find.WindowStack.Add(new Dialog_InfoCard(apparel));
                        }

                        Text.Font = GameFont.Small;
                        Widgets.Label(new Rect(35f + cellHeight, 0f, rowRect.width - 110f, cellHeight), apparel.Label);

                        GUI.color = Color.white;
                        if (Widgets.ButtonImage(new Rect(rowRect.width - 35f, 10, 20, 20), WidgetUtil.nextTexture))
                        {
                            this.Pawn.apparel.Remove(apparel);
                            this.Dresser.AddApparel(apparel);
                            this.cachedApparel.Clear();
                            this.cachedApparel = null;
                            GUI.EndGroup();
                            break;
                        }
                        GUI.EndGroup();
                    }
                    GUI.EndScrollView();
                    GUI.EndGroup();
                }

                GUI.Label(new Rect((wornApparel == null) ? 0 : inRect.width * 0.5f, 60, (wornApparel == null) ? inRect.width : 100, 30), ("ChangeDresser.Storage").Translate(), WidgetUtil.MiddleCenter);

                float left  = (wornApparel == null) ? 0 : inRect.width - apparelListWidth;
                float width = (wornApparel == null) ? inRect.width : apparelListWidth;
                apparelListRect   = new Rect(left, 90, width, inRect.height - 130);
                apparelScrollRect = new Rect(0f, 0f, width - 16f, this.height);
                this.height       = 2f;

                GUI.BeginGroup(apparelListRect);
                this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect);

                string filter = this.Filter.Trim().ToLower();

                GUI.color = Color.white;
                Text.Font = GameFont.Medium;
                for (int i = 0; i < this.CachedApparel.Count; ++i)
                {
                    Apparel apparel = this.cachedApparel[i];

                    if (filter != "" && apparel.Label.ToLower().IndexOf(filter) == -1)
                    {
                        continue;
                    }

                    Rect rowRect = new Rect(0, this.height, apparelScrollRect.width, cellHeight);
                    this.height += cellHeight;
                    GUI.BeginGroup(rowRect);

                    if (this.Pawn != null)
                    {
                        Rect buttonRect = new Rect(5, 10, 20, 20);
                        bool canWear    = this.Pawn.apparel.CanWearWithoutDroppingAnything(apparel.def);
                        if (canWear)
                        {
                            if (Widgets.ButtonImage(buttonRect, WidgetUtil.previousTexture))
                            {
                                if (this.Dresser.TryRemove(apparel, false))
                                {
                                    this.cachedApparel.Clear();
                                    this.cachedApparel = null;
                                    PawnOutfitTracker outfits;
                                    if (WorldComp.PawnOutfits.TryGetValue(this.Pawn, out outfits))
                                    {
                                        outfits.ApplyApparelColor(apparel);
                                    }
                                    this.Pawn.apparel.Wear(apparel);
                                    GUI.EndGroup();
                                    break;
                                }
                                else
                                {
                                    Log.Error("Problem dropping " + apparel.Label);
                                }
                            }
                        }
                        else
                        {
                            Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture);
                        }
                    }

                    Widgets.ThingIcon(new Rect(35f, 0f, cellHeight, cellHeight), apparel);

                    if (Widgets.InfoCardButton(75, 0, apparel))
                    {
                        Find.WindowStack.Add(new Dialog_InfoCard(apparel));
                    }

                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(new Rect(30 + cellHeight + 15f, 0f, rowRect.width - 110f, cellHeight), apparel.Label);

                    if (Widgets.ButtonImage(new Rect(rowRect.width - 45f, 0f, 20, 20), WidgetUtil.dropTexture))
                    {
                        if (this.Dresser.TryRemove(apparel, false))
                        {
                            this.cachedApparel.Clear();
                            this.cachedApparel = null;
                            GUI.EndGroup();
                            break;
                        }
                        else
                        {
                            Log.Error("Problem dropping " + apparel.Label);
                        }
                    }

                    GUI.EndGroup();
                }
                GUI.EndScrollView();

                GUI.EndGroup();
            }
            catch (Exception e)
            {
                Log.Error(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message);
                Messages.Message(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message, MessageTypeDefOf.RejectInput);
                base.Close();
            }
            finally
            {
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
        }
コード例 #13
0
 /// <summary>
 /// For use by depricated code only
 /// </summary>
 public StoredApparelSet(Building_Dresser parentDresser, string isOwnedByPawnId, string isBeingWornByPawnId)
 {
     this.parentDresserId     = parentDresser.ThingID;
     this.isOwnedByPawnId     = isOwnedByPawnId;
     this.isBeingWornByPawnId = isBeingWornByPawnId;
 }
コード例 #14
0
 public StoredApparelSet(Building_Dresser parentDresser)
 {
     this.parentDresserId = parentDresser.ThingID;
 }