コード例 #1
0
        private static void ProcessSell(InventoryDataObject_SHOP selected)
        {
            if (selected == null)
            {
                Control.LogDebug(DInfo.ShopActions, "-- nothing to sell, return");

                return;
            }

            var price = selected.GetCBillValue();

            if (selected.quantity == 1 || !Control.Settings.AllowMultiSell)
            {
                Control.LogDebug(DInfo.ShopActions, $"-- selling 1x{selected.GetName()}");
                if (Control.Settings.ShowConfirm && price > Control.Settings.ConfirmLowLimit)
                {
                    GenericPopupBuilder.Create("Confirm?", $"Sell {selected.GetName()} for {price}?")
                    .AddButton("Cancel", null, true, null)
                    .AddButton("Accept", () => OnSellItems(1), true, null)
                    .CancelOnEscape()
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true)
                    .Render();
                }
                else
                {
                    OnSellItems(1);
                }
            }
            else
            {
                Control.LogDebug(DInfo.ShopActions, $"-- show multisell dialog");
                SG_Stores_MultiPurchasePopup_Handler.StartDialog("Sell", selected.shopDefItem,
                                                                 selected.GetName(), selected.quantity, price, OnSellItems, null);
            }
        }
コード例 #2
0
 public static void HandleExit()
 {
     if (!SG_Stores_MultiPurchasePopup_Handler.Replace)
     {
         return;
     }
     SG_Stores_MultiPurchasePopup_Handler.Reset();
 }
コード例 #3
0
        private static void ProcessBuy(InventoryDataObject_SHOP selected)
        {
            var item_type = selected.GetItemType();

            if (Control.State.Sim.InMechLabStore() && (
                    item_type == MechLabDraggableItemType.StorePart ||
                    item_type == MechLabDraggableItemType.SalvagePart
                    ))
            {
                Control.LogDebug(DInfo.ShopActions, "- cannot buy mech and parts in mechlab, return");
                return;
            }

            //if (ActiveShop is IDefaultShop def_shop)
            ////{
            //    Control.LogDebug(DInfo.ShopActions, "- IDefaultShop");
            //    var shop = def_shop.ShopToUse;
            //    if (shop == null)
            //    {
            //        Control.LogDebug(DInfo.ShopActions, "-- no shop, return");
            //        return;
            //    }
            int price      = GetPrice_Transpliters.GetPrice(null, selected.shopDefItem, Shop.PurchaseType.Normal, Shop.ShopType.System);
            var money      = Control.State.Sim.Funds;
            var max_to_buy = money / price;

            if (!selected.shopDefItem.IsInfinite && max_to_buy > selected.quantity)
            {
                max_to_buy = selected.quantity;
            }

            Control.LogDebug(DInfo.ShopActions, $"-- money:{money} price:{price} num:{selected.quantity} max:{max_to_buy}");

            if (max_to_buy == 1 || !Control.Settings.AllowMultiBuy)
            {
                if (Control.Settings.ShowConfirm && price >= Control.Settings.ConfirmLowLimit)
                {
                    GenericPopupBuilder.Create("Confirm?", $"Purchase {selected.GetName()} for {price}?")
                    .AddButton("Cancel", null, true, null)
                    .AddButton("Accept", () => OnBuyItem(1), true, null)
                    .CancelOnEscape()
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true)
                    .Render();
                }
                else
                {
                    OnBuyItem(1);
                }
            }
            else
            {
                SG_Stores_MultiPurchasePopup_Handler.StartDialog("Buy", selected.shopDefItem,
                                                                 selected.GetName(), max_to_buy, price, OnBuyItem, null);
            }
            //}
            //else if (ActiveShop is IListShop shop)
            //{

            //}
            //else
            //{
            //    Control.LogError("- unknown type of shop, return");
            //}
        }