public override void InventoryTabOnGui(Rect fillRect)
        {
            InventoryPreferences preferences = this.manager.Preferences;
            Rect rect = new Rect(23f, 93f, 928f, 510f);

            GUI.color = new Color(0.08235f, 0.09804f, 0.1137f);
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = new Color(0.5394f, 0.5394f, 0.5394f);
            Widgets.DrawBox(rect, 1);
            try
            {
                Rect position = rect.ContractedBy(1f);
                GUI.BeginGroup(position);
                Rect outRect  = new Rect(0f, 0f, position.width, position.height);
                Rect viewRect = new Rect(outRect.x, outRect.y, outRect.width - 16f, this.scrollViewHeight);
                try
                {
                    Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
                    this.backgroundToggle = false;
                    Vector2 position2 = new Vector2(InventoryTab.SectionPaddingSides, 0f);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Furniture"], this.manager.GetInventoryRecord(InventoryType.BUILDING_FURNITURE), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Production"], this.manager.GetInventoryRecord(InventoryType.BUILDING_PRODUCTION), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Power"], this.manager.GetInventoryRecord(InventoryType.BUILDING_POWER), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Security"], this.manager.GetInventoryRecord(InventoryType.BUILDING_SECURITY), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Joy"], this.manager.GetInventoryRecord(InventoryType.BUILDING_JOY), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Temperature"], this.manager.GetInventoryRecord(InventoryType.BUILDING_TEMPERATURE), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Ship"], this.manager.GetInventoryRecord(InventoryType.BUILDING_SHIP), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["Structure"], this.manager.GetInventoryRecord(InventoryType.BUILDING_STRUCTURE), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, this.labels["FoodUtilities"], this.manager.GetInventoryRecord(InventoryType.BUILDING_FOOD_UTILITIES), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Other".Translate(), this.manager.GetInventoryRecord(InventoryType.BUILDING_OTHER), position2, InventoryTab_Buildings.BuildingSlotSize, InventoryTab_Buildings.BuildingImageOffset, InventoryTab_Buildings.BuildingImageSize, preferences);
                    if (Event.current.type == EventType.Layout)
                    {
                        this.scrollViewHeight = position2.y - 1f;
                    }
                }
                finally
                {
                    Widgets.EndScrollView();
                }
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
            Text.Font   = GameFont.Small;
            string text  = "EdB.Inventory.Prefs.IncludeUnfinished".Translate();
            float  num   = Text.CalcSize(text).x + 40f;
            float  num2  = 22f;
            bool   value = preferences.IncludeUnfinished.Value;

            Widgets.LabelCheckbox(new Rect(fillRect.x + fillRect.width - num - num2, fillRect.y + fillRect.height - 38f, num, 30f), text, ref value, false);
            preferences.IncludeUnfinished.Value = value;
        }
        public override void InventoryTabOnGui(Rect fillRect)
        {
            InventoryPreferences preferences = this.manager.Preferences;
            Rect rect = new Rect(23f, 93f, 928f, 510f);

            GUI.color = new Color(0.08235f, 0.09804f, 0.1137f);
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = new Color(0.5394f, 0.5394f, 0.5394f);
            Widgets.DrawBox(rect, 1);
            try
            {
                Rect position = rect.ContractedBy(1f);
                GUI.BeginGroup(position);
                Rect outRect  = new Rect(0f, 0f, position.width, position.height);
                Rect viewRect = new Rect(outRect.x, outRect.y, outRect.width - 16f, this.scrollViewHeight);
                try
                {
                    Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
                    this.backgroundToggle = false;
                    Vector2 position2 = new Vector2(InventoryTab.SectionPaddingSides, 0f);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Resources".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_RESOURCE), position2, InventoryTab_Items.ItemSlotSize, InventoryTab_Items.ResourceImageOffset, InventoryTab_Items.ResourceImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Food".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_FOOD), position2, InventoryTab_Items.ItemSlotSize, InventoryTab_Items.ResourceImageOffset, InventoryTab_Items.ResourceImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Weapons".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_EQUIPMENT), position2, InventoryTab_Items.WeaponSlotSize, InventoryTab_Items.WeaponImageOffset, InventoryTab_Items.WeaponImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Apparel".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_APPAREL), position2, InventoryTab_Items.ItemSlotSize, InventoryTab_Items.ApparelImageOffset, InventoryTab_Items.ApparelImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Schematics".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_SCHEMATIC), position2, InventoryTab_Items.ItemSlotSize, InventoryTab_Items.ResourceImageOffset, InventoryTab_Items.ResourceImageSize, preferences);
                    position2 = base.DrawResourceSection(viewRect.width, "EdB.Inventory.Section.Other".Translate(), this.manager.GetInventoryRecord(InventoryType.ITEM_OTHER), position2, InventoryTab_Items.ItemSlotSize, InventoryTab_Items.ResourceImageOffset, InventoryTab_Items.ResourceImageSize, preferences);
                    if (Event.current.type == EventType.Layout)
                    {
                        this.scrollViewHeight = position2.y - 1f;
                    }
                }
                finally
                {
                    Widgets.EndScrollView();
                }
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
            Text.Font   = GameFont.Small;
            if (this.manager.CompressedStorage)
            {
                string text  = "EdB.Inventory.Prefs.CompressedStorage".Translate();
                float  num   = Text.CalcSize(text).x + 32f;
                float  num2  = 22f;
                Rect   rect2 = new Rect(fillRect.x + fillRect.width - num - num2, fillRect.y + fillRect.height - 38f, num, 30f);
                bool   value = preferences.CompressedStorage.Value;
                Widgets.LabelCheckbox(rect2, text, ref value, false);
                preferences.CompressedStorage.Value = value;
            }
        }
        protected Vector2 DrawResources(float width, List <InventoryRecord> records, Vector2 position, Vector2 iconSize, Vector2 offset, Vector2 slotSize, InventoryPreferences prefs)
        {
            if (this.equipmentAssignmentFloatMenu != null && Find.WindowStack[0] != this.equipmentAssignmentFloatMenu)
            {
                this.equipmentAssignmentFloatMenu = null;
            }
            Vector2 result = new Vector2(position.x, position.y);

            foreach (InventoryRecord current in records)
            {
                if (current.count != 0 || (current.compressedCount != 0 && prefs.CompressedStorage.Value) || (current.unfinishedCount != 0 && prefs.IncludeUnfinished.Value))
                {
                    if (result.x + slotSize.x > width)
                    {
                        result.y += slotSize.y;
                        result.y += InventoryTab.SlotRowPadding;
                        result.x  = InventoryTab.SectionPaddingSides;
                    }
                    if (current.texture != null)
                    {
                        Vector2 vector = new Vector2(0f, 0f);
                        if (current.thingDef.apparel != null && current.thingDef.apparel.LastLayer == ApparelLayer.Overhead)
                        {
                            vector.y += 10f;
                        }
                        Rect rect = new Rect(result.x + offset.x + vector.x, result.y + offset.y + vector.y, iconSize.x, iconSize.y);
                        GUI.color = current.color;
                        if (current.thingDef.building == null)
                        {
                            GUI.DrawTexture(rect, current.thingDef.uiIcon);
                            if (current.availableCount > 0 && this.equipmentAssignmentFloatMenu == null && Widgets.InvisibleButton(rect) && Event.current.button == 1)
                            {
                                List <FloatMenuOption> list = new List <FloatMenuOption>();
                                foreach (Pawn current2 in Find.ListerPawns.FreeColonists)
                                {
                                    if (current2.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                                    {
                                        InventoryRecord assignedRecord = current;
                                        Pawn            assignedPawn   = current2;
                                        list.Add(new FloatMenuOption(current2.LabelBaseShort, delegate
                                        {
                                            this.AssignEquipmentToPawn(assignedRecord, assignedPawn);
                                        }, MenuOptionPriority.Medium, null, null));
                                    }
                                }
                                this.equipmentAssignmentFloatMenu = new FloatMenu(list, "EdB.Inventory.Equipment.Assign".Translate(), false, false);
                                Find.WindowStack.Add(this.equipmentAssignmentFloatMenu);
                            }
                        }
                        else
                        {
                            if (current.texture == null)
                            {
                                Log.Warning("No texture for building: " + current.thingDef.defName);
                            }
                            Widgets.DrawTextureFitted(rect, current.texture as Texture2D, current.buildingScale, current.proportions, new Rect(0f, 0f, 1f, 1f));
                        }
                        if (this.equipmentAssignmentFloatMenu == null)
                        {
                            string tooltipText = GenLabel.ThingLabel(current.thingDef, current.stuffDef, 1).CapitalizeFirst() + (string.IsNullOrEmpty(current.thingDef.description) ? string.Empty : ("\n\n" + current.thingDef.description));
                            if (current.availableCount > -1)
                            {
                                tooltipText = string.Concat(new string[]
                                {
                                    tooltipText,
                                    "\n\n",
                                    "EdB.Inventory.Equipment.Equipped".Translate(new object[]
                                    {
                                        current.count - current.reservedCount - current.availableCount
                                    }),
                                    "\n",
                                    "EdB.Inventory.Equipment.Reserved".Translate(new object[]
                                    {
                                        current.reservedCount
                                    }),
                                    "\n",
                                    "EdB.Inventory.Equipment.Available".Translate(new object[]
                                    {
                                        current.availableCount
                                    })
                                });
                            }
                            TipSignal tip = new TipSignal(tooltipText, tooltipText.GetHashCode());
                            TooltipHandler.TipRegion(rect, tip);
                        }
                        Text.Anchor = TextAnchor.UpperCenter;
                        GUI.color   = Color.white;
                        Text.Font   = GameFont.Tiny;
                        string label;
                        if (prefs.IncludeUnfinished.Value && current.thingDef.building != null)
                        {
                            label = string.Empty + current.count + ((current.unfinishedCount <= 0) ? string.Empty : (" / " + (current.count + current.unfinishedCount)));
                        }
                        else if (prefs.CompressedStorage.Value && current.compressedCount > 0)
                        {
                            label = string.Concat(new object[]
                            {
                                string.Empty,
                                current.count,
                                " / ",
                                current.count + current.compressedCount
                            });
                        }
                        else
                        {
                            label = string.Empty + current.count;
                        }
                        Widgets.Label(new Rect(result.x, result.y + slotSize.y - InventoryTab.LabelOffset.y, slotSize.x, slotSize.y), label);
                        result.x += slotSize.x;
                    }
                }
            }
            return(result);
        }
        protected Vector2 DrawResourceSection(float width, string label, List <InventoryRecord> records, Vector2 position, Vector2 slotSize, Vector2 offset, Vector2 iconSize, InventoryPreferences prefs)
        {
            float num = width - 20f;

            if (records == null)
            {
                return(position);
            }
            if (prefs.IncludeUnfinished.Value)
            {
                if (records.Count == 0)
                {
                    return(position);
                }
            }
            else
            {
                bool flag = false;
                foreach (InventoryRecord current in records)
                {
                    if (current.count > 0 || (current.compressedCount > 0 && prefs.CompressedStorage.Value) || (current.unfinishedCount > 0 && prefs.IncludeUnfinished.Value))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    return(position);
                }
            }
            Vector2 vector = new Vector2(position.x, position.y);

            if (vector.x != InventoryTab.SectionPaddingSides)
            {
                vector.x  = InventoryTab.SectionPaddingSides;
                vector.y += slotSize.y;
            }
            float num2 = this.MeasureResourceSection(width, label, records, slotSize, prefs);

            if (this.backgroundToggle)
            {
                GUI.color = new Color(0.082f, 0.0977f, 0.1133f);
            }
            else
            {
                GUI.color = new Color(0.1094f, 0.125f, 0.1406f);
            }
            GUI.DrawTexture(new Rect(0f, vector.y, width + 16f, num2), BaseContent.WhiteTex);
            GUI.color = new Color(0.3294f, 0.3294f, 0.3294f);
            Widgets.DrawLineHorizontal(0f, vector.y + num2 - 1f, width + 16f);
            this.backgroundToggle = !this.backgroundToggle;
            vector.y   += InventoryTab.SectionPaddingTop;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
            Text.Font   = InventoryTab.SectionLabelFont;
            float num3 = Text.CalcHeight(label, num);
            Rect  rect = new Rect(InventoryTab.SectionPaddingSides + InventoryTab.SectionLabelHorizontalPadding, vector.y, num - InventoryTab.SectionLabelHorizontalPadding, num3);

            Widgets.Label(rect, label);
            vector.y += num3 + InventoryTab.SectionPaddingBelowLabel;
            vector    = this.DrawResources(num, records, vector, iconSize, offset, slotSize, prefs);
            if (vector.x != InventoryTab.SectionPaddingSides)
            {
                vector.x  = InventoryTab.SectionPaddingSides;
                vector.y += slotSize.y;
            }
            vector.y += InventoryTab.SectionPaddingBottom;
            return(vector);
        }
        protected float MeasureResourceSection(float width, string label, List <InventoryRecord> records, Vector2 slotSize, InventoryPreferences prefs)
        {
            float   num    = width - 20f;
            Vector2 vector = new Vector2(InventoryTab.SectionPaddingSides, InventoryTab.SectionPaddingTop);

            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = InventoryTab.SectionLabelFont;
            vector.y   += Text.CalcHeight(label, num) + InventoryTab.SectionPaddingBelowLabel;
            foreach (InventoryRecord current in records)
            {
                if (current.count != 0 || (current.compressedCount != 0 && prefs.CompressedStorage.Value) || (current.unfinishedCount != 0 && prefs.IncludeUnfinished.Value))
                {
                    if (vector.x + slotSize.x > num)
                    {
                        vector.y += slotSize.y;
                        vector.y += InventoryTab.SlotRowPadding;
                        vector.x  = InventoryTab.SectionPaddingSides;
                    }
                    vector.x += slotSize.x;
                }
            }
            if (vector.x != InventoryTab.SectionPaddingSides)
            {
                vector.x  = InventoryTab.SectionPaddingSides;
                vector.y += slotSize.y;
            }
            vector.y += InventoryTab.SectionPaddingBottom;
            return(vector.y);
        }