コード例 #1
0
    //生成并加入引用信息
    private void ImportAsset(string path)
    {
        //通过path获取guid进行储存
        string guid = AssetDatabase.AssetPathToGUID(path);
        //获取该资源的最后修改时间,用于之后的修改判断
        Hash128 assetDependencyHash = AssetDatabase.GetAssetDependencyHash(path);

        //如果assetDict没包含该guid或包含了修改时间不一样则需要更新
        if (!assetDict.ContainsKey(guid) || assetDict[guid].assetDependencyHash != assetDependencyHash)
        {
            //将每个资源的直接依赖资源转化为guid进行储存
            var guids = AssetDatabase.GetDependencies(path, false).
                        Select(p => AssetDatabase.AssetPathToGUID(p)).
                        ToList();

            //生成asset依赖信息,被引用需要在所有的asset依赖信息生成完后才能生成
            AssetDescription ad = new AssetDescription();
            ad.name = Path.GetFileNameWithoutExtension(path);
            ad.path = path;
            ad.assetDependencyHash = assetDependencyHash;
            ad.dependencies        = guids;

            if (assetDict.ContainsKey(guid))
            {
                assetDict[guid] = ad;
            }
            else
            {
                assetDict.Add(guid, ad);
            }
        }
    }
コード例 #2
0
 public FullHistoryTradeItem(TradedAsset tradedAsset, TradedCurrency tradedCurrency,
                             AssetDescription assetDescription)
 {
     Asset       = tradedAsset;
     Currency    = tradedCurrency;
     Description = assetDescription;
 }
コード例 #3
0
        private void ItemsGridViewCellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (!(sender is DataGridView grid))
                {
                    return;
                }

                var selectedRows = grid.SelectedRows;
                if (selectedRows.Count == 0)
                {
                    return;
                }

                var index       = selectedRows[0].Index;
                var description = (AssetDescription)grid.Rows[index].Cells[3].Value;
                if (description.Equals(this.selectedItemDescription))
                {
                    return;
                }

                this.selectedItemDescription = description;
                this.ChangeSelectedItem();
            }
            catch (Exception ex)
            {
                Logger.Critical(ex);
            }
        }
コード例 #4
0
 public static void UpdateItemImageOnPanelAsync(AssetDescription assetDescription, Panel imageBox)
 {
     UpdateImageOnItemPanelAsync(
         assetDescription.MarketHashName,
         $"https://steamcommunity-a.akamaihd.net/economy/image/{assetDescription.IconUrl}/192fx192f",
         imageBox);
 }
コード例 #5
0
        private static void UpdateItemDescriptionTextBox(
            RichTextBox textBox,
            Control label,
            AssetDescription description)
        {
            textBox.Clear();

            label.Text = description.Name;

            var descriptionText = string.Empty;

            if (description.Descriptions != null)
            {
                foreach (var item in description.Descriptions)
                {
                    var text = item.Value.Trim();
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        descriptionText += text + ", ";
                    }
                }

                if (descriptionText.EndsWith(", "))
                {
                    descriptionText = descriptionText.Substring(0, descriptionText.Length - 2);
                }
            }

            var tagsText = string.Empty;

            CommonUtils.AppendBoldText(textBox, "Game: ");
            textBox.AppendText(description.AppId + "\n");

            CommonUtils.AppendBoldText(textBox, "Name: ");
            textBox.AppendText(description.MarketHashName + "\n");

            CommonUtils.AppendBoldText(textBox, "Type: ");
            textBox.AppendText(description.Type);

            if (!string.IsNullOrWhiteSpace(descriptionText))
            {
                textBox.AppendText("\n");
                CommonUtils.AppendBoldText(textBox, "Description: ");
                textBox.AppendText(descriptionText);
            }

            if (string.IsNullOrWhiteSpace(tagsText))
            {
                return;
            }

            textBox.AppendText("\n");
            CommonUtils.AppendBoldText(textBox, "Tags: ");
            textBox.AppendText(tagsText);
        }
コード例 #6
0
    //读取缓存信息
    public bool ReadFromCache()
    {
        assetDict.Clear();
        if (File.Exists(CACHE_PATH))
        {
            var serializedGuid           = new List <string>();
            var serializedDependencyHash = new List <Hash128>();
            var serializedDenpendencies  = new List <int[]>();

            //反序列化数据
            using (FileStream fs = File.OpenRead(CACHE_PATH))
            {
                BinaryFormatter bf = new BinaryFormatter();
                EditorUtility.DisplayCancelableProgressBar("Import Cache", "Reading Cache", 0);
                serializedGuid           = (List <string>)bf.Deserialize(fs);
                serializedDependencyHash = (List <Hash128>)bf.Deserialize(fs);
                serializedDenpendencies  = (List <int[]>)bf.Deserialize(fs);
                EditorUtility.ClearProgressBar();
            }

            for (int i = 0; i < serializedGuid.Count; ++i)
            {
                string path = AssetDatabase.GUIDToAssetPath(serializedGuid[i]);
                if (!string.IsNullOrEmpty(path))
                {
                    var ad = new AssetDescription();
                    ad.name = Path.GetFileNameWithoutExtension(path);
                    ad.path = path;
                    ad.assetDependencyHash = serializedDependencyHash[i];
                    assetDict.Add(serializedGuid[i], ad);
                }
            }

            for (int i = 0; i < serializedGuid.Count; ++i)
            {
                string guid = serializedGuid[i];
                if (assetDict.ContainsKey(guid))
                {
                    var guids = serializedDenpendencies[i].
                                Select(index => serializedGuid[index]).
                                Where(g => assetDict.ContainsKey(g)).
                                ToList();
                    assetDict[guid].dependencies = guids;
                }
            }
            UpdateReferenceInfo();
            return(true);
        }
        return(false);
    }
コード例 #7
0
        //private readonly DeliveryClient _deliveryClient;

        public async Task <string> CreateAssetAsync()
        {
            // Defines the description of an asset
            var assetDescription = new AssetDescription
            {
                Description = "Description of the asset in the default Language",
                Language    = LanguageIdentifier.DEFAULT_LANGUAGE
            };

            IEnumerable <AssetDescription> descriptions = new [] { assetDescription };

            const string filePath    = @"C:\Users\mattn\projects\KenticoCloudImport\KenticoCloudImport\Images\KenticoCloudLogo.jpg";
            const string contentType = "image/jpg";

            // Uploads the file and links it to a new asset
            var response = await _managementClient.CreateAssetAsync(new FileContentSource(filePath, contentType), descriptions);

            return(response.ExternalId);
        }
コード例 #8
0
        public static AssetDescription GetDescription(CEconAsset asset, List <AssetDescription> descriptions)
        {
            AssetDescription description = null;

            try
            {
                description = descriptions
                              .First(item => asset.InstanceId == item.InstanceId && asset.ClassId == item.ClassId);
            }
            catch (Exception ex) when(ex is ArgumentNullException || ex is InvalidOperationException)
            {
                description = new AssetDescription
                {
                    MarketHashName = "[Info is missing]",
                    AppId          = int.Parse(asset.AppId),
                    Name           = "[Info is missing]",
                    Type           = "[Info is missing]"
                };
            }

            return(description);
        }
コード例 #9
0
        //更新引用信息状态
        public void UpdateAssetState(string guid)
        {
            AssetDescription ad;

            if (assetDict.TryGetValue(guid, out ad) && ad.state != AssetState.NODATA)
            {
                if (File.Exists(ad.path))
                {
                    //修改时间与记录的不同为修改过的资源
                    if (ad.assetDependencyHash != AssetDatabase.GetAssetDependencyHash(ad.path))
                    {
                        ad.state = AssetState.CHANGED;
                    }
                    else
                    {
                        //默认为普通资源
                        ad.state = AssetState.NORMAL;
                    }
                }
                //不存在为丢失
                else
                {
                    ad.state = AssetState.MISSING;
                }
            }

            //字典中没有该数据
            else if (!assetDict.TryGetValue(guid, out ad))
            {
                string path = AssetDatabase.GUIDToAssetPath(guid);
                ad       = new AssetDescription();
                ad.name  = Path.GetFileNameWithoutExtension(path);
                ad.path  = path;
                ad.type  = AssetDatabase.GetMainAssetTypeAtPath(path).ToString();
                ad.state = AssetState.NODATA;
                assetDict.Add(guid, ad);
            }
        }
コード例 #10
0
        private void LoadInventoryButtonClick(object sender, EventArgs e)
        {
            try
            {
                if (CurrentSession.SteamManager == null)
                {
                    MessageBox.Show(
                        @"You should login first",
                        @"Error trades loading",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    Logger.Error("Error on trades history loading. No logged account found.");
                    return;
                }

                var sentOffers     = this.SentOffersCheckBox.Checked;
                var receivedOffers = this.ReceivedOffersCheckBox.Checked;

                if (!sentOffers && !receivedOffers)
                {
                    MessageBox.Show(
                        @"You should select at least one type of offers to load (Received/Sent)",
                        @"Error trades loading",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    Logger.Error("Error on trades history loading. No trades type selected.");
                    return;
                }

                CommonUtils.ClearGrids(
                    this.CurrentTradesGridView,
                    this.MyItemsGridView,
                    this.HisItemsGridView,
                    this.ExtraTradeInfoGridView);
                this.selectedItemDescription  = null;
                this.selectedOfferId          = null;
                this.LoadTradesButton.Enabled = false;
                var activeOnly = this.ActiveOnlyCheckBox.Checked;

                var language = this.DescriptionLanguageComboBox.Text ?? "en_US";

                Task.Run(
                    () =>
                {
                    this.allTrades.Clear();
                    Program.LoadingForm.InitCurrentTradesLoadingProcess(
                        sentOffers,
                        receivedOffers,
                        activeOnly,
                        language);
                    var fullTradeOffers = Program.LoadingForm.GetLoadedCurrentTrades();
                    Program.LoadingForm.DeactivateForm();

                    foreach (var trade in fullTradeOffers)
                    {
                        this.allTrades.Add(trade.Offer.TradeOfferId, trade);

                        Dispatcher.AsMainForm(
                            () =>
                        {
                            var steamId = new SteamID(
                                (uint)trade.Offer.AccountIdOther,
                                EUniverse.Public,
                                EAccountType.Individual).ConvertToUInt64();

                            var state = trade.Offer.TradeOfferState.ToString().Replace(
                                "TradeOfferState",
                                string.Empty);

                            this.CurrentTradesGridView.Rows.Add(
                                trade.Offer.TradeOfferId,
                                steamId,
                                state);
                        });
                    }

                    Dispatcher.AsMainForm(() => { this.LoadTradesButton.Enabled = true; });
                });
            }
            catch (Exception ex)
            {
                Logger.Critical(ex);
            }
        }