/// <summary> /// Exports the attribute categories. /// </summary> /// <returns></returns> private static IEnumerable<SerializablePropertyCategory> ExportAttributeCategories() { List<SerializablePropertyCategory> categories = new List<SerializablePropertyCategory>(); // Export attribute categories List<SerializableProperty> gProperties = new List<SerializableProperty>(); foreach (DgmAttributeCategories srcCategory in Database.DgmAttributeCategoriesTable) { List<SerializableProperty> properties = new List<SerializableProperty>(); SerializablePropertyCategory category = new SerializablePropertyCategory { ID = srcCategory.ID, Description = srcCategory.Description, Name = srcCategory.Name }; categories.Add(category); // Export attributes foreach (DgmAttributeTypes srcProp in Database.DgmAttributeTypesTable.Concat(s_injectedProperties).Where( x => x.CategoryID == category.ID)) { Util.UpdatePercentDone(Database.PropertiesTotalCount); SerializableProperty prop = new SerializableProperty(); properties.Add(prop); prop.ID = srcProp.ID; prop.DefaultValue = srcProp.DefaultValue; prop.Description = srcProp.Description; prop.HigherIsBetter = srcProp.HigherIsBetter; prop.Name = !String.IsNullOrEmpty(srcProp.DisplayName) ? srcProp.DisplayName : !String.IsNullOrEmpty(srcProp.Name) ? srcProp.Name : String.Empty; // Unit prop.UnitID = srcProp.UnitID.GetValueOrDefault(); prop.Unit = srcProp.UnitID.HasValue ? Database.EveUnitsTable.Concat(s_injectedUnits).First( x => x.ID == srcProp.UnitID.Value).DisplayName : String.Empty; // Icon prop.Icon = srcProp.IconID.HasValue ? Database.EveIconsTable[srcProp.IconID.Value].Icon : String.Empty; // Reordering some properties ReorderProperties(gProperties, prop, srcProp, properties); } category.Properties.AddRange(properties); } // New category ID int newCategoryID = Database.DgmAttributeCategoriesTable.Last().ID; // We insert custom categories SerializablePropertyCategory general = new SerializablePropertyCategory { ID = ++newCategoryID, Name = DBConstants.GeneralCategoryName, Description = "General information" }; general.Properties.AddRange(gProperties); categories.Insert(0, general); return categories; }
/// <summary> /// Generate the properties datafile. /// </summary> private static void GenerateProperties() { Console.WriteLine(); Console.Write(@"Generated properties datafile... "); s_counter = 0; s_percentOld = 0; s_text = String.Empty; s_startTime = DateTime.Now; int newID = 0; // Change some display names and default values s_attributeTypes[9].DisplayName = "Structure HP"; s_attributeTypes[263].DisplayName = "Shield HP"; s_attributeTypes[265].DisplayName = "Armor HP"; s_attributeTypes[38].DisplayName = "Cargo Capacity"; s_attributeTypes[48].DisplayName = "CPU"; s_attributeTypes[11].DisplayName = "Powergrid"; // Shield s_attributeTypes[271].DisplayName = "EM Resistance"; s_attributeTypes[272].DisplayName = "Explosive Resistance"; s_attributeTypes[273].DisplayName = "Kinetic Resistance"; s_attributeTypes[274].DisplayName = "Thermal Resistance"; // Armor s_attributeTypes[267].DisplayName = "EM Resistance"; s_attributeTypes[268].DisplayName = "Explosive Resistance"; s_attributeTypes[269].DisplayName = "Kinetic Resistance"; s_attributeTypes[270].DisplayName = "Thermal Resistance"; // Hull s_attributeTypes[974].DisplayName = "EM Resistance"; s_attributeTypes[975].DisplayName = "Explosive Resistance"; s_attributeTypes[976].DisplayName = "Kinetic Resistance"; s_attributeTypes[977].DisplayName = "Thermal Resistance"; // Items attribute s_attributeTypes[6].DisplayName = "Activation cost"; s_attributeTypes[30].DisplayName = "Powergrid usage"; s_attributeTypes[68].DisplayName = "Shield Bonus"; s_attributeTypes[87].DisplayName = "Shield Transfer Range"; s_attributeTypes[116].DisplayName = "Explosive damage"; s_attributeTypes[424].DisplayName = "CPU Output Bonus"; s_attributeTypes[1082].DisplayName = "CPU Penalty"; // Changing the categoryID for some attributes s_attributeTypes[1132].CategoryID = 1; // Calibration s_attributeTypes[1547].CategoryID = 1; // Rig Size s_attributeTypes[908].CategoryID = 4; // Ship Maintenance Bay Capacity s_attributeTypes[1692].CategoryID = 9; // MetaGroup of type // Changing HigherIsBetter to false (CCP has this wrong?) s_attributeTypes[30].HigherIsBetter = false; // CPU usage s_attributeTypes[50].HigherIsBetter = false; // PG usage s_attributeTypes[161].HigherIsBetter = false; // Volume s_attributeTypes[70].HigherIsBetter = false; // Inertia Modifier s_attributeTypes[4].HigherIsBetter = false; // Mass s_attributeTypes[6].HigherIsBetter = false; // Activation Cost s_attributeTypes[55].HigherIsBetter = false; // Capacitor recharge time s_attributeTypes[144].HigherIsBetter = false; // Capacitor recharge rate bonus (reversed due to values deriving from substraction) s_attributeTypes[479].HigherIsBetter = false; // Shield recharge time s_attributeTypes[552].HigherIsBetter = false; // Signature radius s_attributeTypes[560].HigherIsBetter = false; // Sensor Recalibration Time s_attributeTypes[1082].HigherIsBetter = false; // CPU Penalty s_attributeTypes[1153].HigherIsBetter = false; // Calibration cost s_attributeTypes[1272].HigherIsBetter = false; // Bandwidth Needed s_attributeTypes[1416].HigherIsBetter = false; // Target Switch Timer s_attributeTypes[73].HigherIsBetter = false; // Activation time / duration s_attributeTypes[556].HigherIsBetter = false; // Anchoring Delay s_attributeTypes[676].HigherIsBetter = false; // Unanchoring Delay s_attributeTypes[677].HigherIsBetter = false; // Onlining Delay s_attributeTypes[780].HigherIsBetter = false; // Cycle Time bonus s_attributeTypes[669].HigherIsBetter = false; // Reactivation Delay // Export attribute categories var categories = new List<SerializablePropertyCategory>(); // We insert custom categories var general = new SerializablePropertyCategory {Name = "General", Description = "General informations"}; var propulsion = new SerializablePropertyCategory {Name = "Propulsion", Description = "Navigation attributes for ships"}; var gProperties = new List<SerializableProperty>(); var pProperties = new List<SerializableProperty>(); categories.Insert(0, general); categories.Insert(0, propulsion); foreach (DgmAttributeCategory srcCategory in s_attributeCategories) { var category = new SerializablePropertyCategory(); categories.Add(category); category.Description = srcCategory.Description; category.Name = srcCategory.Name; // Export attributes var properties = new List<SerializableProperty>(); foreach (var srcProp in s_attributeTypes.Where(x => x.CategoryID == srcCategory.ID)) { UpdatePercentDone(s_propGenTotal); var prop = new SerializableProperty(); properties.Add(prop); prop.DefaultValue = srcProp.DefaultValue; prop.Description = srcProp.Description; prop.HigherIsBetter = srcProp.HigherIsBetter; prop.Name = (String.IsNullOrEmpty(srcProp.DisplayName) ? srcProp.Name : srcProp.DisplayName); prop.ID = srcProp.ID; // Unit if (srcProp.UnitID == null) { prop.Unit = String.Empty; } else { prop.Unit = s_units[srcProp.UnitID.Value].DisplayName; prop.UnitID = srcProp.UnitID.Value; } // Ship warp speed unit if (srcProp.ID == DBConstants.ShipWarpSpeedPropertyID) prop.Unit = "AU/S"; // Icon prop.Icon = (srcProp.IconID.HasValue ? s_icons[srcProp.IconID.Value].Icon : String.Empty); // Reordering some properties int index = properties.IndexOf(prop); switch (srcProp.ID) { case 9: properties.Insert(0, prop); properties.RemoveAt(index + 1); break; case 37: pProperties.Insert(0, prop); properties.RemoveAt(index); break; case 38: properties.Insert(1, prop); properties.RemoveAt(index + 1); break; case 48: properties.Insert(0, prop); properties.RemoveAt(index + 1); break; case 70: properties.Insert(3, prop); properties.RemoveAt(index + 1); break; case 161: properties.Insert(3, prop); properties.RemoveAt(index + 1); break; case 422: gProperties.Insert(0, prop); properties.RemoveAt(index); break; case 479: properties.Insert(6, prop); properties.RemoveAt(index + 1); break; case 482: properties.Insert(0, prop); properties.RemoveAt(index + 1); break; case 564: properties.Insert(4, prop); properties.RemoveAt(index + 1); break; case 633: gProperties.Insert(1, prop); properties.RemoveAt(index); break; case 974: properties.Insert(5, prop); properties.RemoveAt(index + 1); break; case 975: properties.Insert(6, prop); properties.RemoveAt(index + 1); break; case 976: properties.Insert(7, prop); properties.RemoveAt(index + 1); break; case 977: properties.Insert(8, prop); properties.RemoveAt(index + 1); break; case 1132: properties.Insert(2, prop); properties.RemoveAt(index + 1); break; case 1137: properties.Insert(10, prop); properties.RemoveAt(index + 1); break; case 1281: pProperties.Insert(1, prop); properties.RemoveAt(index); break; case 1547: properties.Insert(11, prop); properties.RemoveAt(index + 1); break; default: break; } // New ID newID = Math.Max(newID, srcProp.ID); } category.Properties = properties.ToArray(); } // Add EVEMon custom properties (Base Price) var gprop = new SerializableProperty(); s_propBasePriceID = newID + 1; gProperties.Insert(0, gprop); gprop.ID = s_propBasePriceID; gprop.Name = "Base Price"; gprop.Unit = "ISK"; gprop.Description = "The price from NPC vendors (does not mean there is any)."; // Add properties to custom categories general.Properties = gProperties.ToArray(); propulsion.Properties = pProperties.ToArray(); // Sort groups string[] orderedGroupNames = { "General", "Fitting", "Drones", "Structure", "Armor", "Shield", "Capacitor", "Targeting", "Propulsion", "Miscellaneous", "NULL" }; s_endTime = DateTime.Now; Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0')); // Serialize var datafile = new PropertiesDatafile(); datafile.Categories = categories.OrderBy(x => Array.IndexOf(orderedGroupNames, String.Intern(x.Name))).ToArray(); Util.SerializeXML(datafile, DatafileConstants.PropertiesDatafile); }