Exemple #1
0
        private void DrawBottomButtons(int x, int y, float width)
        {
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("Begin CustomOutfitUI.DrawBottomButtons " + x + " " + y);
#endif
            float middle = width / 2f;
            if (this.pawn == null || this.outfitTracker == null || this.customOutfit == null)
            {
                this.DrawCloseButton((int)middle - 50, y);
#if TRACE && CUSTOM_OUTFIT_UI
                Log.Warning("End CustomOutfitUI.DrawBottomButtons -- Close Button Only");
#endif
                return;
            }

            float halfMiddle = middle / 2f;
            // Delete
            if (Widgets.ButtonText(new Rect(halfMiddle - 50, y, 100, 30), "Delete".Translate()))
            {
                if (this.outfitTracker.Remove(this.customOutfit))
                {
                    this.outfitTracker.UpdateCustomApparel(this.Dresser);
                }
                this.customOutfit = null;
            }

            // Save
            if (Widgets.ButtonText(new Rect(middle - 50, y, 100, 30), "Save".Translate()))
            {
                this.outfitTracker.AddOutfit(this.customOutfit);
                this.outfitTracker.UpdateCustomApparel(this.Dresser);
                foreach (Apparel a in this.customOutfit.Apparel)
                {
                    if (!this.Dresser.RemoveNoDrop(a))
                    {
#if CUSTOM_OUTFIT_UI
                        Log.Warning("CustomOutfitUI.DrawBottomButtons -- Save failed to removed [" + a.Label + "] from dresser");
#endif
                    }
#if CUSTOM_OUTFIT_UI
                    else
                    {
                        Log.Warning("CustomOutfitUI.DrawBottomButtons -- Save removed [" + a.Label + "] from dresser");
                    }
#endif
                }
                this.customOutfit = null;
            }

            // Cancel
            if (Widgets.ButtonText(new Rect(middle + halfMiddle - 50, y, 100, 30), "ChangeDresser.Cancel".Translate()))
            {
                this.outfitTracker.UpdateCustomApparel(this.Dresser);
                this.customOutfit = null;
            }
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("End CustomOutfitUI.DrawBottomButtons " + x + " " + y);
#endif
        }
        public override void DoWindowContents(Rect inRect)
        {
            try
            {
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
                Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.CustomOutfits".Translate());
                int y = HEIGHT + Y_BUFFER;
                int x = 0;

                x = this.DrawPawnSelection(x, y);
                x = this.DrawOutfitSelection(x, y);
                // New Outfit button
                if (this.outfitTracker != null &&
                    Widgets.ButtonText(new Rect(x, y, 75, 30), "ChangeDresser.New".Translate()))
                {
                    this.customOutfit      = new CustomOutfit();
                    this.customOutfit.Name = "";
                    this.UpdateAvailableApparel();
                }

                y += HEIGHT + Y_BUFFER;

                if (this.customOutfit != null)
                {
                    Widgets.Label(new Rect(0, y, 60, 30), "ChangeDresser.OutfitName".Translate() + ":");
                    this.customOutfit.Name = Widgets.TextField(new Rect(70, y, 100, 30), this.customOutfit.Name);

                    x = this.DrawUseInBattle(200, y);
                    x = this.DrawBaseOutfit(x, y);

                    y += HEIGHT + Y_BUFFER;
                }

                float height = inRect.height - y;
                height -= HEIGHT * 3;
                height -= Y_BUFFER * 2;

                this.DrawAvailableApparel(0, y, inRect.width * 0.5f, height);
                this.DrawOutfitApparel(inRect.width * 0.5f, y, inRect.width * 0.5f, height);
                y += (int)height;

                this.DrawBottomButtons(x, (int)inRect.yMax - 40, inRect.width);
            }
            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.NegativeEvent);

                base.Close();
            }
        }
Exemple #3
0
        private int DrawPawnSelection(int x, int y)
        {
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("Begin CustomOutfitUI.DrawPawnSelection " + x + " " + y);
#endif
            string label = (this.pawn != null) ? this.pawn.Name.ToStringShort : "Select Pawn";
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Message("    Label: " + label);
#endif
            if (Widgets.ButtonText(new Rect(x, y, 100, 30), label))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
#if TRACE && CUSTOM_OUTFIT_UI
                Log.Message("    selectablePawns Count: " + this.selectablePawns.Count);
#endif
                foreach (Pawn p in this.selectablePawns)
                {
#if TRACE && CUSTOM_OUTFIT_UI
                    Log.Message("        " + p.Name.ToStringShort);
#endif
                    options.Add(new FloatMenuOption(p.Name.ToStringShort, delegate
                    {
#if CUSTOM_OUTFIT_UI
                        Log.Warning("Begin CustomOutfitUI.DrawAvailableApparel.Delegate " + p.Name.ToStringShort);
#endif
                        if (this.customOutfit != null)
                        {
                            this.outfitTracker.UpdateCustomApparel(this.Dresser);
                            this.customOutfit = null;
                        }

                        this.pawn = p;
                        if (!WorldComp.PawnOutfits.TryGetValue(this.pawn, out outfitTracker))
                        {
                            outfitTracker = new PawnOutfitTracker(this.pawn);
                            WorldComp.PawnOutfits.Add(this.pawn, outfitTracker);
                        }
#if CUSTOM_OUTFIT_UI
                        Log.Warning("End CustomOutfitUI.DrawAvailableApparel.Delegate");
#endif
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options));
            }
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("End CustomOutfitUI.DrawPawnSelection");
#endif
            return(x + 110);
        }
Exemple #4
0
        private int DrawOutfitSelection(int x, int y)
        {
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("Begin CustomOutfitUI.DrawOutfitSelection " + x + " " + y);
#endif
            if (this.outfitTracker != null && this.outfitTracker.CustomOutfits.Count > 0)
            {
                string label = (this.customOutfit != null) ? this.customOutfit.Label : "Select Outfit";
                if (Widgets.ButtonText(new Rect(x, y, 150, 30), label))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>();
                    foreach (CustomOutfit o in this.outfitTracker.CustomOutfits)
                    {
                        options.Add(new FloatMenuOption(o.Label, delegate
                        {
#if CUSTOM_OUTFIT_UI
                            Log.Warning("Begin CustomOutfitUI.DrawOutfitSelection.Delegate " + o.Label);
#endif
                            if (this.customOutfit != null)
                            {
                                this.outfitTracker.UpdateCustomApparel(this.Dresser);
                            }
                            this.customOutfit = o;
#if CUSTOM_OUTFIT_UI
                            Log.Warning("End CustomOutfitUI.DrawOutfitSelection.Delegate");
#endif
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(options));
                }
                return(x + 160);
            }
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("End CustomOutfitUI.DrawOutfitSelection");
#endif
            return(x);
        }
Exemple #5
0
        public override void DoWindowContents(Rect inRect)
        {
            try
            {
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
                Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.CustomOutfits".Translate());
                int y = HEIGHT + Y_BUFFER;
                int x = 0;

                x = this.DrawPawnSelection(x, y);
                x = this.DrawOutfitSelection(x, y);
                // New Outfit button
                if (this.outfitTracker != null &&
                    Widgets.ButtonText(new Rect(x, y, 75, 30), "ChangeDresser.New".Translate()))
                {
                    this.customOutfit      = new CustomOutfit();
                    this.customOutfit.Name = "";
                    this.UpdateAvailableApparel();
                }

                y += HEIGHT + Y_BUFFER;

                if (this.customOutfit != null)
                {
                    Widgets.Label(new Rect(0, y, 60, 30), "ChangeDresser.OutfitName".Translate() + ":");
                    this.customOutfit.Name = Widgets.TextField(new Rect(70, y, 100, 30), this.customOutfit.Name);

                    x = this.DrawUseInBattle(200, y);
                    x = this.DrawBaseOutfit(x, y);

                    y += HEIGHT + Y_BUFFER;
                }

                float height = inRect.height - y;
                height -= HEIGHT * 3;
                height -= Y_BUFFER * 2;

                this.DrawAvailableApparel(0, y, 350, height);
                this.DrawOutfitApparel(360, y, 710, height);
                y += (int)height;

                this.DrawBottomButtons(x, (int)inRect.yMax - 40, inRect.width);

                // Filter start
                y = 50;

                Widgets.Label(new Rect(750, y, 100, 32), "Filter".Translate());
                y += 40;

                Widgets.Label(new Rect(775, y, 75, 32), "ChangeDresser.Name".Translate());
                this.apparelFilter.Name = Widgets.TextField(new Rect(855, y - 3, 120, 32), this.apparelFilter.Name);
                y += 35;

                if (Widgets.ButtonText(new Rect(775, y, 200, 32), this.apparelFilter.LayerString))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>();
                    options.Add(new FloatMenuOption(this.apparelFilter.GetLayerLabel("ChangeDresser.All".Translate()), delegate
                    {
                        this.apparelFilter.Layer       = null;
                        this.apparelFilter.LayerString = this.apparelFilter.GetLayerLabel("ChangeDresser.All".Translate());
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    foreach (ApparelLayerDef d in DefDatabase <ApparelLayerDef> .AllDefs)
                    {
                        options.Add(new FloatMenuOption(d.defName.Translate(), delegate
                        {
                            this.apparelFilter.Layer       = d;
                            this.apparelFilter.LayerString = this.apparelFilter.GetLayerLabel(d.defName.Translate());
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(options));
                }
                y += 35;

                if (Widgets.ButtonText(new Rect(775, y, 200, 32), this.apparelFilter.QualityString))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>();
                    options.Add(new FloatMenuOption(this.apparelFilter.GetQualityLabel("ChangeDresser.All".Translate()), delegate
                    {
                        this.apparelFilter.Quality       = QualityRange.All;
                        this.apparelFilter.QualityString = this.apparelFilter.GetQualityLabel("ChangeDresser.All".Translate());
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    foreach (QualityCategory q in Enum.GetValues(typeof(QualityCategory)))
                    {
                        options.Add(new FloatMenuOption(q.ToString(), delegate
                        {
                            this.apparelFilter.Quality.min   = q;
                            this.apparelFilter.QualityString = this.apparelFilter.GetQualityLabel(q.GetLabel());
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(options));
                }
                y += 35;

                Listing_Standard ls = new Listing_Standard();
                ls.Begin(new Rect(775, y, 216, inRect.height - y));
                Rect view = new Rect(0, 0, 200, 64 * this.apparelFilter.StatDefs.Count);
                ls.BeginScrollView(
                    new Rect(0, 0, 216, inRect.height - y), ref filterScrollPosition, ref view);

                ls.Label("HitPointsBasic".ToString() + " " + (int)this.apparelFilter.HP);
                this.apparelFilter.HP = ls.Slider(this.apparelFilter.HP, 0, 100);

                for (int i = 0; i < this.apparelFilter.StatDefs.Count; ++i)
                {
                    StatDefValue sdv = this.apparelFilter.StatDefs[i];
                    ls.Label(sdv.Def.label + " " + sdv.Value.ToString("n2"), 28);
                    float f = sdv.Value;
                    f = ls.Slider(f, 0, sdv.Max);
                    if (sdv.Value != f)
                    {
                        sdv.Value = f;
                        this.apparelFilter.StatDefs[i] = sdv;
                    }
                }

                ls.EndScrollView(ref view);
                ls.End();
            }
            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.NegativeEvent);

                base.Close();
            }
        }