예제 #1
0
        public void DrawCustomItemCard(Rect rect, SellableItemWithModif item, Pawn speaker)
        {
            bgCardColor.a = 150;
            Widgets.DrawBoxSolid(rect, bgCardColor);

            GUI.color = GUIUtils.CommBorderColor;
            Widgets.DrawBox(rect);
            GUI.color = Color.white;

            Widgets.ThingIcon(new Rect(rect.x + 8, rect.y + 18, 64, 64), item.Item);

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(rect.x + 80, rect.y + 8, rect.width - 88, 25), item.Item.Label);
            Text.Anchor = TextAnchor.UpperLeft;

            GUIUtils.DrawLineHorizontal(rect.x + 80, rect.y + 34, rect.width - 88, Color.gray);
            float y = rect.y + 36;

            Widgets.Label(new Rect(rect.x + 80, y, rect.width - 88, 25), $"DarkNetModificator_Price".Translate(item.MarketValue));
            y += 25;
            if (item.Modificator != null)
            {
                Widgets.Label(new Rect(rect.x + 80, y, rect.width - 88, 40), item.Modificator.LabelCap);
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            if (GUIUtils.DrawCustomButton(new Rect(rect.x, rect.y + 105, rect.width, 25), "DarkNetButtons_Buy".Translate(), Color.white))
            {
                if (DarkNetPriceUtils.BuyAndDropItem(item, speaker.Map))
                {
                    if (stock.Contains(item))
                    {
                        stock.Remove(item);
                    }
                    else
                    {
                        goodOfTheWeek = null;
                    }

                    Text.Anchor = TextAnchor.UpperLeft;
                    return;
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;

            if (Mouse.IsOver(rect))
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("TraderWorker_RogerEdmonson_FullDesc".Translate(item.Item.Label, item.Item.DescriptionFlavor, item.MarketValue));
                if (item.Modificator != null)
                {
                    builder.Append("TraderWorker_RogerEdmonson_Modificator".Translate(item.Modificator.LabelCap, item.Modificator.description, item.Modificator.PriceModficator));
                }

                TooltipHandler.TipRegion(rect, builder.ToString());
            }
        }
예제 #2
0
        public bool AcceptOrder()
        {
            if (DarkNetPriceUtils.BuyAndDropItem(Order.OrderedItem, (int)Order.Price, Find.AnyPlayerHomeMap, true))
            {
                Order = null;
                return(true);
            }

            return(false);
        }
예제 #3
0
        private void DrawItem(SellableItemWithModif item, List <SellableItemWithModif> itemsList, Rect rect, Pawn speaker)
        {
            bgCardColor.a = 150;
            Widgets.DrawBoxSolid(rect, bgCardColor);

            GUI.color = GUIUtils.CommBorderColor;
            Widgets.DrawBox(rect);
            GUI.color = Color.white;

            Widgets.ThingIcon(new Rect(rect.x + 8, rect.y + 18, 64, 64), item.Item);

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(rect.x + 80, rect.y + 8, rect.width - 88, 25), "TraderWorker_Eisenberg_ItemLabel".Translate(item.Item.LabelNoCount, item.Item.stackCount, item.MarketValue));
            Text.Anchor = TextAnchor.UpperLeft;

            GUIUtils.DrawLineHorizontal(rect.x + 80, rect.y + 34, rect.width - 88, Color.gray);
            float y = rect.y + 36;

            Widgets.Label(new Rect(rect.x + 80, y, rect.width - 88, 120), $"TraderWorker_Eisenberg_Description".Translate(item.Item.DescriptionDetailed));

            Text.Anchor = TextAnchor.MiddleCenter;
            Rect arrowRect = new Rect(rect.x + 10, rect.y + 165, 25, 25);

            DrawSelectArrows(item, arrowRect);
            float addX = 200;

            if (item.CountToTransfer > 0)
            {
                Widgets.Label(new Rect(rect.x + 200, rect.y + 165, 250, 25), "TraderWorker_Eisenberg_Total".Translate(item.CountToTransfer, item.CountToTransfer * item.MarketValue));
                addX = 450;
            }
            if (GUIUtils.DrawCustomButton(new Rect(rect.x + addX, rect.y + 165, 200, 25), "DarkNetButtons_Buy".Translate(), item.CountToTransfer > 0 ? Color.white : Color.gray))
            {
                if (item.CountToTransfer == 0)
                {
                    return;
                }

                if (DarkNetPriceUtils.BuyAndDropItem(item, item.CountToTransfer, speaker.Map))
                {
                    if (item.Item == null)
                    {
                        itemsList.Remove(item);
                    }

                    Reputation     += (item.CountToTransfer * item.MarketValue) * reputationGainForBuy;
                    needRecalculate = true;

                    if (item.Item != null)
                    {
                        if (item.CountToTransfer > item.Item.stackCount)
                        {
                            item.AddToTransfer(item.Item.stackCount);
                        }
                    }

                    Text.Anchor = TextAnchor.UpperLeft;
                    return;
                }
            }
            addX += 205;
            if (GUIUtils.DrawCustomButton(new Rect(rect.x + addX, rect.y + 165, 200, 25), "DarkNetButtons_GoPriceDown".Translate(), (Reputation > minReputationToDiscount || !item.PriceReduced) ? Color.white : Color.gray, "DarkNetButtons_GoPriceDownInfo".Translate()))
            {
                if (item.PriceReduced || Reputation < minReputationToDiscount)
                {
                    return;
                }

                Reputation -= minReputationToDiscount;

                item.PriceReduced = true;
                item.MarketValue  = (int)(item.MarketValue * forceDiscount);
            }
            Text.Anchor = TextAnchor.UpperLeft;

            if (Mouse.IsOver(rect))
            {
                TooltipHandler.TipRegion(rect, "TraderWorker_RogerEdmonson_FullDesc".Translate(item.Item.LabelNoCount, item.Item.DescriptionFlavor, item.MarketValue));
            }
        }