Exemple #1
0
        /// <inheritdoc cref="ItemTableWorker.DrawItem"/>
        protected override void DrawItem(Rect region, TableSettingsItem <ThingItem> item)
        {
            bool hasIcon = Widgets.CanDrawIconFor(item.Data.Thing);

            var infoRect     = new Rect(hasIcon ? NameHeaderRect.x : NameHeaderTextRect.x, region.y, hasIcon ? NameHeaderRect.width : NameHeaderTextRect.width, region.height);
            var priceRect    = new Rect(PriceHeaderRect.x, region.y, PriceHeaderRect.width, RowLineHeight);
            var categoryRect = new Rect(CategoryHeaderRect.x, region.y, CategoryHeaderRect.width, RowLineHeight);

            if (item.Data.Thing != null && hasIcon)
            {
                UiHelper.DrawThing(infoRect, item.Data.Thing, item.Data.Name, !item.EditingName);
            }

            if (item.Data.Cost > 0)
            {
                UiHelper.Label(priceRect, item.Data.Cost.ToString("N0"));
            }

            UiHelper.Label(categoryRect, item.Data.Category);
        }
Exemple #2
0
        /// <summary>
        ///     Draws the given <see cref="ThingItem"/> at the given region.
        /// </summary>
        /// <param name="region">
        ///     The region to draw the <see cref="ThingItem"/>
        ///     in
        /// </param>
        /// <param name="item">The <see cref="ThingItem"/> to draw</param>
        protected virtual void DrawItem(Rect region, [NotNull] TableSettingsItem <ThingItem> item)
        {
            bool hasIcon = Widgets.CanDrawIconFor(item.Data.Thing);

            Rect checkboxRect = LayoutHelper.IconRect(_stateHeaderRect.x + 2f, region.y + 2f, _stateHeaderRect.width - 4f, RowLineHeight - 4f);
            var  iconRect     = new Rect(NameHeaderRect.x + 4f, region.y + 4f, RowLineHeight - 8f, RowLineHeight - 8f);

            var nameRect = new Rect(
                hasIcon ? NameHeaderRect.x + RowLineHeight : NameHeaderTextRect.x,
                region.y,
                hasIcon ? NameHeaderRect.width - RowLineHeight - 4f : NameHeaderTextRect.width,
                RowLineHeight
                );

            var thingRect = new Rect(
                hasIcon ? NameHeaderRect.x : NameHeaderTextRect.x,
                region.y,
                hasIcon ? NameHeaderRect.width - nameRect.height - 4f : NameHeaderTextRect.width,
                nameRect.height
                );

            var priceRect    = new Rect(PriceHeaderTextRect.x, region.y, PriceHeaderTextRect.width, RowLineHeight);
            var categoryRect = new Rect(CategoryHeaderTextRect.x, region.y, CategoryHeaderTextRect.width, RowLineHeight);

            Rect settingRect = LayoutHelper.IconRect(
                _expandedHeaderRect.x + 2f,
                region.y + Mathf.FloorToInt(Mathf.Abs(_expandedHeaderRect.width - RowLineHeight) / 2f) + 2f,
                _expandedHeaderRect.width - 4f,
                _expandedHeaderRect.width - 4f
                );

            bool proxy = item.Data.Enabled;

            if (UiHelper.DrawCheckbox(checkboxRect, ref proxy))
            {
                item.Data.Enabled = proxy;
                item.Data.Update();
            }

            if (hasIcon)
            {
                Widgets.ThingIcon(iconRect, item.Data.Thing);
            }

            DrawConfigurableItemName(nameRect, item);

            if (!item.EditingName && item.Data.Thing != null && Current.Game != null)
            {
                Widgets.DrawHighlightIfMouseover(thingRect);

                if (Widgets.ButtonInvisible(thingRect))
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(item.Data.Thing));
                }
            }

            if (item.Data.Cost > 0)
            {
                SettingsHelper.DrawPriceField(priceRect, ref item.Data.Item !.price);
            }

            UiHelper.Label(categoryRect, item.Data.Category);

            if (Widgets.ButtonImage(settingRect, Textures.Gear))
            {
                item.SettingsVisible = !item.SettingsVisible;
            }

            if (!item.SettingsVisible)
            {
                return;
            }

            var expandedRect = new Rect(
                NameHeaderRect.x + 10f,
                region.y + RowLineHeight + 10f,
                region.width - checkboxRect.width - settingRect.width - 20f,
                region.height - RowLineHeight - 20f
                );

            GUI.BeginGroup(expandedRect);
            DrawExpandedSettings(expandedRect.AtZero(), item);
            GUI.EndGroup();
        }