Exemplo n.º 1
0
    [SerializeField] private StoreDialog pnlStore;       //商店页面

    //主页面按钮点击事件
    public void StoreClick()
    {
        StoreDialog storeDialog = Instantiate(pnlStore, transform);

        storeDialog.gameObject.SetActive(true);
        storeDialog.Init();
    }
Exemplo n.º 2
0
        private static void ValidateItemData()
        {
            ItemData ??= new Dictionary <string, ItemData>();
            List <string> tradeables = StoreDialog.GetTradeables().Select(t => t.defName).ToList();
            List <string> toCull     = ItemData.Keys.Where(dataKey => !tradeables.Contains(dataKey.CapitalizeFirst())).ToList();

            foreach (string defName in toCull)
            {
                ItemData.Remove(defName);
            }

            var builder = new StringBuilder();

            foreach (ThingDef item in tradeables.Where(t => !ItemData.ContainsKey(t)).Select(i => DefDatabase <ThingDef> .GetNamed(i)))
            {
                ModContentPack contentPack = item.modContentPack;

                var data = new ItemData
                {
                    Version        = Models.ItemData.CurrentVersion,
                    QuantityLimit  = -1,
                    IsStuffAllowed = true,
                    IsUsable       = GameHelper.GetDefaultUsability(item),
                    IsWearable     = true,
                    IsEquippable   = true
                };

                if (contentPack != null)
                {
                    data.Mod = contentPack.IsCoreMod ? "RimWorld" : contentPack.Name ?? "Unknown";
                }

                ItemData[item.defName] = data;

                try
                {
                    data.IsMelee  = item.IsMeleeWeapon;
                    data.IsRanged = item.IsRangedWeapon;
                    data.IsWeapon = item.IsWeapon;
                }
                catch (Exception e)
                {
                    builder.Append($"Failed to gather weapon data for item '{item.label ?? "Unknown"}' from mod '{item.TryGetModName()}'");
                    builder.AppendLine($" -- Exception: {e.GetType().Name}({e.Message ?? "No message"})");
                }
            }

            foreach (KeyValuePair <string, ItemData> pair in ItemData.Where(data => data.Value.Version < Models.ItemData.CurrentVersion))
            {
                string   defName = pair.Key;
                ItemData data    = pair.Value;

                ThingItem item = Items.Find(i => i.DefName?.Equals(defName) == true);

                data.IsUsable     = item?.Thing == null || GameHelper.GetDefaultUsability(item.Thing);
                data.IsWearable   = true;
                data.IsEquippable = true;
                data.Version      = Models.ItemData.CurrentVersion;
            }
        }
Exemplo n.º 3
0
        private static void Postfix()
        {
            int?itemCount    = Data.Items?.Count;
            int ttkItemCount = StoreInventory.items.Count;

            if (itemCount >= ttkItemCount)
            {
                if (itemCount > ttkItemCount)
                {
                    Data.Items = Data.Items.Where(i => StoreInventory.items.Contains(i.Item)).ToList();
                }

                return;
            }

            TkUtils.Logger.Info("Utils' item list didn't match Twitch Toolkit's; rebuilding list...");
            Data.Items = StoreDialog.ValidateContainers().ToList();
        }
Exemplo n.º 4
0
        private static bool Prefix()
        {
            List <Item>   inventory    = StoreInventory.items;
            var           tradeables   = new HashSet <ThingDef>(StoreDialog.GetTradeables());
            List <string> tradeableIds = tradeables.Select(t => t.defName).ToList();

            if (Data.PawnKinds != null)
            {
                DisableKinds(inventory);
            }

            StoreInventory.items = inventory.Where(i => !string.IsNullOrEmpty(i.defname)).Where(i => tradeableIds.Contains(i.defname)).ToList();

            RemoveDanglingItems();
            FixNullItemNames(tradeables);

            List <ToolkitItem> items = PrepareItems(tradeables).ToList();

            if (TkSettings.Offload)
            {
                Task.Run(
                    async() =>
                {
                    await Data.SaveJsonAsync(new ItemList {
                        Items = items
                    }, Paths.ToolkitItemFilePath);
                    await Data.SaveItemDataAsync(Paths.ItemDataFilePath);
                }
                    )
                .ConfigureAwait(false);
            }
            else
            {
                Data.SaveJson(new ItemList {
                    Items = items
                }, Paths.ToolkitItemFilePath);
                Data.SaveItemData(Paths.ItemDataFilePath);
            }

            return(false);
        }
Exemplo n.º 5
0
        private void StoreButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!this.paretocalculator.stackEmpty())
                {
                    StoreDialog     dialogBox    = new StoreDialog(this.paretocalculator.peek());
                    Nullable <bool> dialogResult = dialogBox.ShowDialog();

                    if (dialogResult == true)
                    {
                        this.paretocalculator.storePop(dialogBox.NameResult);
                        this.UpdateStack();
                    }
                }
            }
            catch (ParetoCalculatorExceptionW exc)
            {
                this.ParetoCalculatorExceptionOccurred(exc);
                this.UpdateStack();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the security token for signing messages.
        /// </summary>
        /// <returns>Returns </returns>
        public X509SecurityToken GetSecurityToken()
        {
            X509SecurityToken securityToken;
            //
            // open the current user's certificate store
            //
            X509CertificateStore store = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore);
            bool open = store.OpenRead();

            try
            {
                //
                // Open a dialog to allow user to select the certificate to use
                //
                StoreDialog     dialog = new StoreDialog(store);
                X509Certificate cert   = dialog.SelectCertificate(IntPtr.Zero, "Select Certificate", "Choose a Certificate below for signing.");
                if (cert == null)
                {
                    throw new ApplicationException("You chose not to select an X509 certificate for signing your messages.");
                }
                else if (!cert.SupportsDigitalSignature)
                {
                    throw new ApplicationException("The certificate must support digital signatures and have a private key available.");
                }
                else
                {
                    securityToken = new X509SecurityToken(cert);
                }
            }
            finally
            {
                if (store != null)
                {
                    store.Close();
                }
            }
            return(securityToken);
        }
Exemplo n.º 7
0
    //打开商店
    public void OpenStore()
    {
        StoreDialog store = Instantiate(storeDialog, transform);

        store.Init();
    }
Exemplo n.º 8
0
 private void ShowStore(Store store)
 {
     this.SelectedStore = store;
     StoreDialog.Show();
 }
 public void OnClickShop()
 {
     StoreDialog dialog = GUIManager.Instance.OnShowDialog <StoreDialog>("Store");
 }
Exemplo n.º 10
0
 private static void ValidateItems()
 {
     Items = StoreDialog.GetTradeables().Select(t => new ThingItem {
         Thing = t
     }).ToList();
 }
Exemplo n.º 11
0
      /// <summary>
      /// Gets the security token for signing messages.
      /// </summary>
      /// <returns>Returns </returns>
      public X509SecurityToken GetSecurityToken()
	{
	  X509SecurityToken securityToken;
	  //
	  // open the current user's certificate store
	  //
	  X509CertificateStore store = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore);
	  bool open = store.OpenRead();

	  try
	    {
	      //
	      // Open a dialog to allow user to select the certificate to use
	      //
	      StoreDialog dialog = new StoreDialog(store);
	      X509Certificate cert = dialog.SelectCertificate(IntPtr.Zero, "Select Certificate", "Choose a Certificate below for signing.");
	      if (cert == null)
		{
		  throw new ApplicationException("You chose not to select an X509 certificate for signing your messages.");
		}
	      else if (!cert.SupportsDigitalSignature)
		{
		  throw new ApplicationException("The certificate must support digital signatures and have a private key available.");
		}
	      else
		{
		  securityToken = new X509SecurityToken(cert);
		}
	    }
	  finally
	    {
	      if (store != null) { store.Close(); }
	    }
	  return securityToken;
	}