Skip to content

Commit

Permalink
Merge pull request #176 from EDCD/BugFix/83-materialmonitor
Browse files Browse the repository at this point in the history
Bugfix for #83 - materialsmonitor
  • Loading branch information
richardbuckle committed Oct 23, 2017
2 parents f7dc2cf + cbb28ff commit b098eec
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 54 deletions.
26 changes: 22 additions & 4 deletions DataDefinitions/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ private Material(string EDName, string category, string name, Rarity rarity, str
public static readonly Material PeculiarShieldFrequencyData = new Material("shieldfrequencydata", "Data", "Peculiar Shield Frequency Data", Rarity.VeryRare);

public static readonly Material BasicConductors = new Material("basicconductors", "Manufactured", "Basic Conductors", Rarity.VeryCommon);
public static readonly Material ChemicalStorageUnits = new Material("", "Manufactured", "Chemical Storage Units", Rarity.VeryCommon);
public static readonly Material CompactComposites = new Material("", "Manufactured", "Compact Composites", Rarity.VeryCommon);
public static readonly Material ChemicalStorageUnits = new Material("chemicalstorageunits", "Manufactured", "Chemical Storage Units", Rarity.VeryCommon);
public static readonly Material CompactComposites = new Material("compactcomposites", "Manufactured", "Compact Composites", Rarity.VeryCommon);
public static readonly Material CrystalShards = new Material("crystalshards", "Manufactured", "Crystal Shards", Rarity.VeryCommon);
public static readonly Material GridResistors = new Material("gridresistors", "Manufactured", "Grid Resistors", Rarity.VeryCommon);
public static readonly Material HeatConductionWiring = new Material("heatconductionwiring", "Manufactured", "Heat Conduction Wiring", Rarity.VeryCommon);
Expand All @@ -128,7 +128,7 @@ private Material(string EDName, string category, string name, Rarity rarity, str

public static readonly Material ChemicalProcessors = new Material("chemicalprocessors", "Manufactured", "Chemical Processors", Rarity.Common);
public static readonly Material ConductiveComponents = new Material("conductivecomponents", "Manufactured", "Conductive Components", Rarity.Common);
public static readonly Material FilamentComposites = new Material("", "Manufactured", "Filament Composites", Rarity.Common);
public static readonly Material FilamentComposites = new Material("filamentcomposites", "Manufactured", "Filament Composites", Rarity.Common);
public static readonly Material FlawedFocusCrystals = new Material("uncutfocuscrystals", "Manufactured", "Flawed Focus Crystals", Rarity.Common);
public static readonly Material GalvanisingAlloys = new Material("galvanisingalloys", "Manufactured", "Galvanising Alloys", Rarity.Common);
public static readonly Material HeatDispersionPlate = new Material("heatdispersionplate", "Manufactured", "Heat Dispersion Plate", Rarity.Common);
Expand Down Expand Up @@ -198,7 +198,7 @@ public static Material FromName(string from)
if (result == null)
{
Logging.Report("Unknown material name " + from);
result = new Material(tidiedFrom, "Unknown", from, Rarity.Unknown);
result = new Material(null, "Unknown", from, Rarity.Unknown);
}
return result;
}
Expand Down Expand Up @@ -229,5 +229,23 @@ public static Material FromSymbol(string from)
}
return result;
}

public static bool DeprecatedMaterials(string name)
{
// These material names have been replaced / are no longer in use. Listed for reference so that they won't be retained by the material monitor.
if (name == null)
{
return false;
}
List<string> deprecatedMaterialsList = new List<string>
{
"Thargoid Residue Data Analysis",
"Unknown Ship Signature",
"Unknown Wake Data",
"Unknown Fragment",
};

return deprecatedMaterialsList.Contains(name.Trim());
}
}
}
37 changes: 30 additions & 7 deletions DataDefinitions/MaterialAmount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,27 @@ namespace EddiDataDefinitions
{
public class MaterialAmount : INotifyPropertyChanged
{
public string material { get; private set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
[DefaultValue(null)]
public string edname { get; private set; }

[JsonIgnore]
private string _material;
public string material
{
get
{
return _material;
}
set
{
if (_material != value)
{
_material = value;
NotifyPropertyChanged("material");
}
}
}

[JsonIgnore]
private int _amount;
Expand Down Expand Up @@ -101,17 +121,19 @@ public string Category

public MaterialAmount(Material material, int amount)
{
Material My_material = Material.FromName(material.name);
this.material = material.name;
Material My_material = Material.FromEDName(material.EDName);
this.material = My_material.name;
this.edname = My_material.EDName;
this.amount = amount;
this.Category = My_material.category;
}

public MaterialAmount(Material material, int? minimum, int? desired, int? maximum)
public MaterialAmount(Material material, int amount, int? minimum, int? desired, int? maximum)
{
Material My_material = Material.FromName(material.name);
this.material = material.name;
amount = 0;
Material My_material = Material.FromEDName(material.EDName);
this.material = My_material.name;
this.edname = My_material.EDName;
this.amount = amount;
this.minimum = minimum;
this.desired = desired;
this.maximum = maximum;
Expand All @@ -123,6 +145,7 @@ public MaterialAmount(string material, int amount, int? minimum, int? desired, i
{
Material My_material = Material.FromName(material);
this.material = material;
this.edname = My_material.EDName;
this.amount = amount;
this.minimum = minimum;
this.desired = desired;
Expand Down
2 changes: 2 additions & 0 deletions EDDI/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Core
* Revised EDDN updating for naming changes in ED 2.4.
* Revised error reporting. The 'Send EDDI log to developers' button is now called 'Report an Issue' and routes users to our Github issues page. If verbose logging is enabled, a zipped and truncated log file is placed on the desktop so that it may be attached to the Github issue.
* Material Monitor
* Fixed a bug that prevented EDDI from recognizing and removing old versions of some data from the Material Monitor.

### 2.4.1
* We just needed to bump the version number to flush out 2.4.0 builds that didn't understand that 'rc' means 'release candidate'. (Because it's a computer and, guess what, we have to tell it stuff like that.)
Expand Down
2 changes: 1 addition & 1 deletion EDSMResponder/EDSMResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void Handle(Event theEvent)
Dictionary<string, int> data = new Dictionary<string, int>();
foreach (MaterialAmount ma in materialInventoryEvent.inventory)
{
Material material = Material.FromName(ma.material);
Material material = Material.FromEDName(ma.edname);
if (material.category == "Element" || material.category == "Manufactured")
{
materials.Add(material.EDName, ma.amount);
Expand Down
7 changes: 6 additions & 1 deletion Events/MaterialCollectedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ static MaterialCollectedEvent()
[JsonProperty("amount")]
public int amount { get; private set; }

// Admin
[JsonProperty("edname")]
public string edname { get; private set; }

public MaterialCollectedEvent(DateTime timestamp, Material material, int amount) : base(timestamp, NAME)
{
this.name = (material == null ? null : material.name);
this.name = material?.name;
this.amount = amount;
this.edname = material?.EDName;
}
}
}
7 changes: 6 additions & 1 deletion Events/MaterialDiscardedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ static MaterialDiscardedEvent()
[JsonProperty("amount")]
public int amount { get; private set; }

// Admin
[JsonProperty("edname")]
public string edname { get; private set; }

public MaterialDiscardedEvent(DateTime timestamp, Material material, int amount) : base(timestamp, NAME)
{
this.name = (material == null ? null : material.name);
this.name = material?.name;
this.amount = amount;
this.edname = material?.EDName;
}
}
}
2 changes: 1 addition & 1 deletion Events/MaterialDiscoveredEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static MaterialDiscoveredEvent()

public MaterialDiscoveredEvent(DateTime timestamp, Material material) : base(timestamp, NAME)
{
this.name = (material == null ? null : material.name);
this.name = material?.name;
}
}
}
7 changes: 6 additions & 1 deletion Events/MaterialDonatedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ static MaterialDonatedEvent()
[JsonProperty("amount")]
public int amount { get; private set; }

// Admin
[JsonProperty("edname")]
public string edname { get; private set; }

public MaterialDonatedEvent(DateTime timestamp, Material material, int amount) : base(timestamp, NAME)
{
this.name = (material == null ? null : material.name);
this.name = material?.name;
this.amount = amount;
this.edname = material?.EDName;
}
}
}
Loading

0 comments on commit b098eec

Please sign in to comment.