private ItemToCreate FindItemToCreate(UUID uuid, AssetType assetType, bool sameIds)
        {
            var itc = GetOld(uuid) as ItemToCreate;

            if (itc == null)
            {
                itc = new ItemToCreate(uuid, assetType);
                UUID2OBJECT[uuid] = itc;
                if (!CogbotHelpers.IsNullOrZero(itc.NewID))
                {
                    NewUUID2OBJECT[itc.NewID] = itc;
                }
            }
            return(itc);
        }
 private void EnsureUploaded(ItemToCreate itc, bool alwayReupload, ref int uploaded, ref int reuploaded)
 {
     if (!itc.RezRequested)
     {
         itc.UploadAssetData(false);
         if (!CogbotHelpers.IsNullOrZero(itc.NewID))
         {
             NewUUID2OBJECT[itc.NewID] = itc;
         }
         uploaded++;
     }
     else if (alwayReupload)
     {
         itc.UpdateAsset(itc.AssetData);
         reuploaded++;
     }
     if (!CogbotHelpers.IsNullOrZero(itc.NewID))
     {
         NewUUID2OBJECT[itc.NewID] = itc;
     }
 }
        private void GleanUUIDsFrom(UUID uuid)
        {
            if (CogbotHelpers.IsNullOrZero(uuid))
            {
                return;
            }
            var clientInventoryStore = Client.Inventory.Store;

            if (clientInventoryStore == null)
            {
                return;
            }
            foreach (var item0 in clientInventoryStore.GetContents(uuid))
            {
                UUID oldID;
                if (UUID.TryParse(item0.Name, out oldID))
                {
                    var item = item0 as InventoryItem;
                    if (item == null)
                    {
                        continue;
                    }
                    ItemToCreate itc = FindItemToCreate(oldID, item.AssetType, true);
                    if (itc.RezRequested)
                    {
                    }
                }
            }
            lock (UUID2OBJECT) lock (MissingFromExport)
                {
                    foreach (MissingItemInfo ur in LockInfo.CopyOf(MissingFromExport))
                    {
                        if (UUID2OBJECT.ContainsKey(ur.MissingID))
                        {
                            Success("Not Missing anymore: " + ur);
                            MissingFromExport.Remove(ur);
                        }
                    }
                }
        }
Esempio n. 4
0
        public static List <ItemToCreate> GetItemsToCreate(int?temp_id)
        {
            List <ItemToCreate> items = new List <ItemToCreate>();
            var connectionString      = ConfigurationManager.ConnectionStrings["prod_connection"].ConnectionString;

            using (var con = new SqlConnection(connectionString))
            {
                using (var cmd = new SqlCommand("bm.get_products_to_transfer"))
                {
                    con.Open();
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.StoredProcedure;
                    if (temp_id.HasValue)
                    {
                        cmd.Parameters.AddWithValue("@temp_id", temp_id);
                    }
                    var reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            if (temp_id.HasValue)
                            {
                                var item = new ItemToCreate
                                {
                                    product_no        = DataWriter.ReadString(reader, 0),
                                    product_name      = DataWriter.ReadString(reader, 1),
                                    description       = DataWriter.ReadString(reader, 2),
                                    division_no       = DataWriter.ReadString(reader, 3),
                                    division          = DataWriter.ReadString(reader, 4),
                                    department_no     = DataWriter.ReadString(reader, 5),
                                    department        = DataWriter.ReadString(reader, 6),
                                    sup_department_no = DataWriter.ReadString(reader, 7),
                                    sup_department    = DataWriter.ReadString(reader, 8),
                                    option_name_no    = DataWriter.ReadString(reader, 9),
                                    option_name       = DataWriter.ReadString(reader, 10),
                                    size_no           = DataWriter.ReadString(reader, 11),
                                    size             = DataWriter.ReadString(reader, 12),
                                    color_no         = DataWriter.ReadString(reader, 13),
                                    color            = DataWriter.ReadString(reader, 14),
                                    color_group_no   = DataWriter.ReadString(reader, 15),
                                    color_group      = DataWriter.ReadString(reader, 16),
                                    size_group_no    = DataWriter.ReadString(reader, 17),
                                    size_group       = DataWriter.ReadString(reader, 18),
                                    temp_id          = DataWriter.ReadInt(reader, 19).Value,
                                    master_status    = DataWriter.ReadInt(reader, 20).Value,
                                    min_order_qty    = DataWriter.ReadDecimal(reader, 21),
                                    pack_size        = DataWriter.ReadDecimal(reader, 22),
                                    display_stock    = DataWriter.ReadDecimal(reader, 23),
                                    option_id        = DataWriter.ReadInt(reader, 24).Value,
                                    primar_vendor_no = DataWriter.ReadString(reader, 25),
                                    sale_price       = DataWriter.ReadDecimal(reader, 26),
                                    cost_price       = DataWriter.ReadDecimal(reader, 27)
                                };
                                items.Add(item);
                            }
                            else
                            {
                                var item = new ItemToCreate
                                {
                                    temp_id = DataWriter.ReadInt(reader, 0).Value
                                };
                                items.Add(item);
                            }
                        }
                    }
                }
            }
            return(items);
        }
Esempio n. 5
0
    void OnGUI()
    {
        if (itemManager != null)
        {
            List <WeaponItem> weaponList = new List <WeaponItem>();
            List <ArmorItem>  armorList  = new List <ArmorItem>();
            newItemID = _itemList.Count;

            for (int i = 0; i < _itemList.Count; i++)
            {
                if (_itemList[i].GetType() == typeof(WeaponItem))
                {
                    weaponList.Add((WeaponItem)_itemList[i]);
                }
                if (_itemList[i].GetType() == typeof(ArmorItem))
                {
                    armorList.Add((ArmorItem)_itemList[i]);
                }
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Item Type: ");
            currentItemToCreate = (ItemToCreate)EditorGUILayout.EnumPopup(currentItemToCreate);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("General Attributes:", EditorStyles.boldLabel);
            newItemID    = EditorGUILayout.IntField("ID (BE CAREFUL): ", newItemID);
            newItemName  = EditorGUILayout.TextField("Name: ", newItemName);
            newItemDesc  = EditorGUILayout.TextField("Description: ", newItemDesc);
            newItemValue = EditorGUILayout.IntField("Item Value: ", newItemValue);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Icon: ");
            newItemIcon = (Texture2D)EditorGUILayout.ObjectField(newItemIcon, typeof(Texture2D), true);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Rarity: ");
            newItemRarity = (RarityTypes)EditorGUILayout.EnumPopup(newItemRarity);
            EditorGUILayout.EndHorizontal();


            switch (currentItemToCreate)
            {
            case ItemToCreate.Weapon:
                EditorGUILayout.LabelField("Weapon-Specific Attributes:", EditorStyles.boldLabel);
                newWeaponMaxDamage = EditorGUILayout.IntField("Max Damage: ", newWeaponMaxDamage);
                newWeaponMinDamage = EditorGUILayout.IntField("Min Damage: ", newWeaponMinDamage);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Damage Type: ");
                newWeaponDamageType = (DamageType)EditorGUILayout.EnumPopup(newWeaponDamageType);
                EditorGUILayout.EndHorizontal();
                break;

            case ItemToCreate.Armor:
                EditorGUILayout.LabelField("Armor-Specific Attributes:", EditorStyles.boldLabel);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Armor Slot: ");
                newArmorSlot = (ArmorSlot)EditorGUILayout.EnumPopup(newArmorSlot);
                EditorGUILayout.EndHorizontal();
                newArmorLvl = EditorGUILayout.IntField("Armor Level: ", newArmorLvl);
                break;
            }

            if (GUILayout.Button("Add New Item"))
            {
                switch (currentItemToCreate)
                {
                case ItemToCreate.Weapon:
                    WeaponItem newWeapon = (WeaponItem)ScriptableObject.CreateInstance <WeaponItem>();
                    newWeapon.Name            = newItemName;
                    newWeapon.ItemDescription = newItemDesc;
                    newWeapon.ItemID          = newItemID;
                    newWeapon.ItemIcon        = newItemIcon;
                    newWeapon.Value           = newItemValue;
                    newWeapon.Rarity          = newItemRarity;
                    newWeapon.MaxDamage       = newWeaponMaxDamage;
                    newWeapon.MinDamage       = newWeaponMinDamage;
                    newWeapon.TypeOfDamage    = newWeaponDamageType;
                    newWeapon.ItemTypeV       = (ItemType)currentItemToCreate;
                    _itemList.Add(newWeapon);
                    break;

                case ItemToCreate.Armor:
                    ArmorItem newArmor = (ArmorItem)ScriptableObject.CreateInstance <ArmorItem>();
                    newArmor.Name            = newItemName;
                    newArmor.ItemDescription = newItemDesc;
                    newArmor.ItemID          = newItemID;
                    newArmor.ItemIcon        = newItemIcon;
                    newArmor.Value           = newItemValue;
                    newArmor.Rarity          = newItemRarity;
                    newArmor.ArmorLevel      = newArmorLvl;
                    newArmor.Slot            = newArmorSlot;
                    newArmor.ItemTypeV       = (ItemType)currentItemToCreate;
                    _itemList.Add(newArmor);
                    break;
                }
            }

            EditorGUILayout.Space();

            showingLists          = EditorGUILayout.Foldout(showingLists, "Item Database");
            EditorGUI.indentLevel = 2;


//			if (showingLists){
//				EditorGUILayout.LabelField("Total items: " + _itemList.Count);
//				EditorGUILayout.LabelField("Total weapons: " + weaponList.Count);
//				EditorGUILayout.LabelField("Total armor items: " + armorList.Count);
//				EditorGUILayout.Space();
//
//				scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
//				EditorGUI.indentLevel -= 1;
//				showingWeapons = EditorGUILayout.Foldout(showingWeapons, "Weapons");
//				if (showingWeapons){
//					EditorGUI.indentLevel += 2;
//					for (int i = 0; i < weaponList.Count; i++){
//						EditorGUILayout.BeginHorizontal();
//						EditorGUILayout.LabelField(weaponList[i].Name);
//						if (GUILayout.Button("-")){
//							_itemList.Remove(_itemList[i]);
//						}
//						EditorGUILayout.EndHorizontal();
//						EditorGUI.indentLevel +=1;
//						weaponList[i].ItemID = EditorGUILayout.IntField ("ID: ", weaponList[i].ItemID);
//						weaponList[i].Name = EditorGUILayout.TextField ("Name: ", weaponList[i].Name);
//						weaponList[i].ItemDescription = EditorGUILayout.TextField ("Description: ", weaponList[i].ItemDescription);
//						weaponList[i].Value = EditorGUILayout.IntField ("Value: ", weaponList[i].Value);
//						weaponList[i].MaxDamage = EditorGUILayout.IntField ("Max Damage: ", weaponList[i].MaxDamage);
//						weaponList[i].MinDamage = EditorGUILayout.IntField ("Min Damage: ", weaponList[i].MinDamage);
//						EditorGUILayout.BeginHorizontal();
//						EditorGUILayout.PrefixLabel("Damage Type: ");
//						weaponList[i].TypeOfDamage = (DamageType)EditorGUILayout.EnumPopup(weaponList[i].TypeOfDamage);
//						EditorGUILayout.EndHorizontal();
//						EditorGUI.indentLevel -=1;
//					}
//					EditorGUI.indentLevel -= 2;
//				}
//				showingArmor = EditorGUILayout.Foldout(showingArmor, "Armor Items");
//				if (showingArmor){
//					EditorGUI.indentLevel += 2;
//					for (int i = 0; i < armorList.Count; i++){
//						EditorGUILayout.BeginHorizontal();
//						EditorGUILayout.LabelField(armorList[i].Name);
//						if (GUILayout.Button("-")){
//							_itemList.Remove(_itemList[i]);
//						}
//						EditorGUILayout.EndHorizontal();
//						EditorGUI.indentLevel +=1;
//						armorList[i].ItemID = EditorGUILayout.IntField ("ID: ", armorList[i].ItemID);
//						armorList[i].Name = EditorGUILayout.TextField ("Name: ", armorList[i].Name);
//						armorList[i].ItemDescription = EditorGUILayout.TextField ("Description: ", armorList[i].ItemDescription);
//						armorList[i].Value = EditorGUILayout.IntField ("Value: ", armorList[i].Value);
//						armorList[i].ArmorLevel = EditorGUILayout.IntField("Armor Level: ", armorList[i].ArmorLevel);
//						EditorGUI.indentLevel -=1;
//					}
//					EditorGUI.indentLevel -= 2;
//				}
//				EditorGUILayout.EndScrollView();
//			}
            EditorGUI.indentLevel -= 2;
            showingIDList          = EditorGUILayout.Foldout(showingIDList, "ID list");
            EditorGUI.indentLevel  = 2;
            if (showingIDList)
            {
                for (int i = 0; i < _itemList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(_itemList[i].ItemID.ToString() + ":\t" + _itemList[i].Name);
                    if (GUILayout.Button("Edit"))
                    {
                        AssetDatabase.OpenAsset(_itemList[i]);
                    }
                    if (GUILayout.Button("Remove"))
                    {
                        if (EditorUtility.DisplayDialog("Are you sure you want to remove object?", "Cannot be undone",
                                                        "Remove", "Cancel"))
                        {
                            _itemList.Remove(_itemList[i]);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
//			if (showingLists = true) EditorGUILayout.EndScrollView();
        }
    }
 private ItemToCreate FindItemToCreate(UUID uuid, AssetType assetType, bool sameIds)
 {
     var itc = GetOld(uuid) as ItemToCreate;
     if (itc == null)
     {
         itc = new ItemToCreate(uuid, assetType);
         UUID2OBJECT[uuid] = itc;
         if (!CogbotHelpers.IsNullOrZero(itc.NewID))
         {
             NewUUID2OBJECT[itc.NewID] = itc;
         }
     }
     return itc;
 }
 private void EnsureUploaded(ItemToCreate itc, bool alwayReupload, ref int uploaded, ref int reuploaded)
 {
     if (!itc.RezRequested)
     {
         itc.UploadAssetData(false);
         if (!CogbotHelpers.IsNullOrZero(itc.NewID))
         {
             NewUUID2OBJECT[itc.NewID] = itc;
         }
         uploaded++;
     }
     else if (alwayReupload)
     {
         itc.UpdateAsset(itc.AssetData);
         reuploaded++;
     }
     if (!CogbotHelpers.IsNullOrZero(itc.NewID))
     {
         NewUUID2OBJECT[itc.NewID] = itc;
     }
 }
        private void UploadAllAssets(ImportSettings arglist)
        {
            bool sameIds    = arglist.Contains("sameid");
            int  uploaded   = 0;
            int  reuploaded = 0;
            int  seenAsset  = 0;
            HashSet <ItemToCreate> ItemsToCreate = LocalScene.Assets;
            bool alwayReupload = arglist.Contains("reup");

            Success("Uploading assets... sameIds=" + sameIds);
            var au = GetAssetUploadsFolder();

            if (CogbotHelpers.IsNullOrZero(au))
            {
                Success("Cant get AssetUploads folder");
                return;
            }
            foreach (var file in Directory.GetFiles(ExportCommand.assetDumpDir, "*.*"))
            {
                if (file.EndsWith(".object") || file.EndsWith(".simasset") || file.EndsWith(".rzi"))
                {
                    continue;
                }
                string    sid       = file;
                AssetType assetType = AssetType.Unknown;
                foreach (var ate in ArchiveConstants.ASSET_TYPE_TO_EXTENSION)
                {
                    string ateValue = ate.Value;
                    if (file.EndsWith(ateValue))
                    {
                        assetType = ate.Key;
                        sid       = Path.GetFileName(file.Substring(0, file.Length - ateValue.Length));
                        break;
                    }
                }
                if (assetType == AssetType.Unknown)
                {
                    if (file.EndsWith(".jp2"))
                    {
                        assetType = AssetType.Texture;
                        sid       = Path.GetFileName(file.Substring(0, file.Length - ".jp2".Length));
                    }
                    if (file.EndsWith(".ogg"))
                    {
                        assetType = AssetType.Sound;
                        sid       = Path.GetFileName(file.Substring(0, file.Length - ".ogg".Length));
                    }
                }
                if (assetType == AssetType.Unknown)
                {
                    Failure("Cant guess assetyype for " + file);
                    continue;
                }
                seenAsset++;
                UUID         oldID = UUID.Parse(sid);
                ItemToCreate itc   = FindItemToCreate(oldID, assetType, sameIds);
                itc.LLSDFilename = file;
                ItemsToCreate.Add(itc);
            }
            foreach (ItemToCreate itc in ItemsToCreate)
            {
                if (itc.PassNumber == 1)
                {
                    EnsureUploaded(itc, alwayReupload, ref uploaded, ref reuploaded);
                }
            }
            foreach (ItemToCreate itc in ItemsToCreate)
            {
                if (itc.PassNumber == 2)
                {
                    itc.ReplaceAll();
                    EnsureUploaded(itc, alwayReupload, ref uploaded, ref reuploaded);
                }
            }
            Success("Uploaded assets=" + uploaded + " seenAssets=" + seenAsset + " reuploaded=" + reuploaded);
        }