- Timestamp:
- Dec 12, 2015, 4:08:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
r251 r253 8 8 { 9 9 public class GetPlayerInventory : WebAPI { 10 10 11 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) { 11 12 if (req.QueryString ["steamid"] == null) { … … 38 39 DoInventory (bag, inv.bag); 39 40 40 AddEquipment (equipment, "head", inv.equipment, XMLData.Item.EnumEquipmentSlot.Head, NGuiInvGridEquipment.EnumClothingLayer.Middle);41 AddEquipment (equipment, "eyes", inv.equipment, XMLData.Item.EnumEquipmentSlot.Eyes, NGuiInvGridEquipment.EnumClothingLayer.Middle);42 AddEquipment (equipment, "face", inv.equipment, XMLData.Item.EnumEquipmentSlot.Face, NGuiInvGridEquipment.EnumClothingLayer.Middle);41 AddEquipment (equipment, "head", inv.equipment, EquipmentSlots.Headgear); 42 AddEquipment (equipment, "eyes", inv.equipment, EquipmentSlots.Eyewear); 43 AddEquipment (equipment, "face", inv.equipment, EquipmentSlots.Face); 43 44 44 AddEquipment (equipment, "armor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Outer);45 AddEquipment (equipment, "jacket", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Middle);46 AddEquipment (equipment, "shirt", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Inner);45 AddEquipment (equipment, "armor", inv.equipment, EquipmentSlots.ChestArmor); 46 AddEquipment (equipment, "jacket", inv.equipment, EquipmentSlots.Jacket); 47 AddEquipment (equipment, "shirt", inv.equipment, EquipmentSlots.Shirt); 47 48 48 AddEquipment (equipment, "legarmor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Outer);49 AddEquipment (equipment, "pants", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Inner);50 AddEquipment (equipment, "boots", inv.equipment, XMLData.Item.EnumEquipmentSlot.Feet, NGuiInvGridEquipment.EnumClothingLayer.Inner);49 AddEquipment (equipment, "legarmor", inv.equipment, EquipmentSlots.LegArmor); 50 AddEquipment (equipment, "pants", inv.equipment, EquipmentSlots.Legs); 51 AddEquipment (equipment, "boots", inv.equipment, EquipmentSlots.Feet); 51 52 52 AddEquipment (equipment, "gloves", inv.equipment, XMLData.Item.EnumEquipmentSlot.Hands, NGuiInvGridEquipment.EnumClothingLayer.Inner); 53 AddEquipment (equipment, "backpack", inv.equipment, XMLData.Item.EnumEquipmentSlot.Back, NGuiInvGridEquipment.EnumClothingLayer.Outer); 53 AddEquipment (equipment, "gloves", inv.equipment, EquipmentSlots.Hands); 54 54 55 55 WriteJSON (resp, result); … … 62 62 } 63 63 64 private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, XMLData.Item.EnumEquipmentSlot _slot, NGuiInvGridEquipment.EnumClothingLayer _layer) { 65 int index = (int)_slot + (int)_layer * (int)XMLData.Item.EnumEquipmentSlot.Count; 66 if (_items != null) { 67 _eq.Add (_slotname, GetJsonForItem (_items [index])); 68 } else { 69 _eq.Add (_slotname, new JSONNull ()); 64 private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, EquipmentSlots _slot) { 65 int[] slotindices = XUiM_PlayerEquipment.GetSlotIndicesByEquipmentSlot (_slot); 66 67 for (int i = 0; i < slotindices.Length; i++) { 68 if (_items != null && _items [slotindices [i]] != null) { 69 InvItem item = _items [slotindices [i]]; 70 _eq.Add (_slotname, GetJsonForItem (item)); 71 return; 72 } 70 73 } 74 75 _eq.Add (_slotname, new JSONNull ()); 71 76 } 72 77 … … 75 80 JSONObject jsonItem = new JSONObject (); 76 81 jsonItem.Add ("count", new JSONNumber (_item.count)); 77 78 79 jsonItem.Add ("iconcolor", new JSONString ((string.IsNullOrEmpty (_item.iconcolor) || _item.iconcolor == "FFFFFF" ? "" : _item.iconcolor)));80 jsonItem.Add ("quality", new JSONNumber(_item.quality));82 jsonItem.Add ("name", new JSONString (_item.itemName)); 83 jsonItem.Add ("icon", new JSONString (_item.icon)); 84 jsonItem.Add ("iconcolor", new JSONString (_item.iconcolor)); 85 jsonItem.Add ("quality", new JSONNumber (_item.quality)); 81 86 if (_item.quality >= 0) { 82 87 jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality)));
Note:
See TracChangeset
for help on using the changeset viewer.