Skip to content

Commit

Permalink
better handle localized material names
Browse files Browse the repository at this point in the history
  • Loading branch information
mhwlng committed Mar 22, 2021
1 parent b5d8db4 commit 343275d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 38 deletions.
44 changes: 22 additions & 22 deletions EDEngineer/EDEngineer/Resources/Data/entryData.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"Name": "Aberrant Shield Pattern Analysis",
"Rarity": "Rare",
"FormattedName": "aberrantshieldpatternanalysis",
"FormattedName": "shieldpatternanalysis",
"Kind": "Data",
"OriginDetails": [
"Ship scanning (combat ships)",
Expand All @@ -26,7 +26,7 @@
{
"Name": "Adaptive Encryptors Capture",
"Rarity": "VeryRare",
"FormattedName": "adaptiveencryptorscapture",
"FormattedName": "adaptiveencryptors",
"Kind": "Data",
"OriginDetails": [
"Mission reward",
Expand All @@ -37,7 +37,7 @@
{
"Name": "Anomalous Bulk Scan Data",
"Rarity": "VeryCommon",
"FormattedName": "anomalousbulkscandata",
"FormattedName": "bulkscandata",
"Kind": "Data",
"OriginDetails": [
"Ship scanning (transport ships)",
Expand All @@ -48,7 +48,7 @@
{
"Name": "Anomalous FSD Telemetry",
"Rarity": "Common",
"FormattedName": "anomalousfsdtelemetry",
"FormattedName": "fsdtelemetry",
"Kind": "Data",
"OriginDetails": [
"High wake scanning",
Expand Down Expand Up @@ -116,7 +116,7 @@
{
"Name": "Atypical Disrupted Wake Echoes",
"Rarity": "VeryCommon",
"FormattedName": "atypicaldisruptedwakeechoes",
"FormattedName": "disruptedwakeechoes",
"Kind": "Data",
"OriginDetails": [
"High wake scanning",
Expand All @@ -127,7 +127,7 @@
{
"Name": "Atypical Encryption Archives",
"Rarity": "Rare",
"FormattedName": "atypicalencryptionarchives",
"FormattedName": "encryptionarchives",
"Kind": "Data",
"OriginDetails": [
"Surface POI",
Expand Down Expand Up @@ -373,7 +373,7 @@
{
"Name": "Cracked Industrial Firmware",
"Rarity": "Standard",
"FormattedName": "crackedindustrialfirmware",
"FormattedName": "industrialfirmware",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand All @@ -396,7 +396,7 @@
{
"Name": "Datamined Wake Exceptions",
"Rarity": "VeryRare",
"FormattedName": "dataminedwakeexceptions",
"FormattedName": "dataminedwake",
"Kind": "Data",
"OriginDetails": [
"High wake scanning",
Expand All @@ -419,7 +419,7 @@
{
"Name": "Distorted Shield Cycle Recordings",
"Rarity": "VeryCommon",
"FormattedName": "distortedshieldcyclerecordings",
"FormattedName": "shieldcyclerecordings",
"Kind": "Data",
"OriginDetails": [
"Ship scanning (transport ships)",
Expand All @@ -441,7 +441,7 @@
{
"Name": "Eccentric Hyperspace Trajectories",
"Rarity": "Rare",
"FormattedName": "eccentrichyperspacetrajectories",
"FormattedName": "hyperspacetrajectories",
"Kind": "Data",
"OriginDetails": [
"High wake scanning"
Expand Down Expand Up @@ -472,7 +472,7 @@
{
"Name": "Exceptional Scrambled Emission Data",
"Rarity": "VeryCommon",
"FormattedName": "exceptionalscrambledemissiondata",
"FormattedName": "scrambledemissiondata",
"Kind": "Data",
"OriginDetails": [
"Ship scanning",
Expand Down Expand Up @@ -697,7 +697,7 @@
{
"Name": "Inconsistent Shield Soak Analysis",
"Rarity": "Common",
"FormattedName": "inconsistentshieldsoakanalysis",
"FormattedName": "shieldsoakanalysis",
"Kind": "Data",
"OriginDetails": [
"Ship scanning (transport ships)",
Expand Down Expand Up @@ -852,7 +852,7 @@
{
"Name": "Modified Consumer Firmware",
"Rarity": "Common",
"FormattedName": "modifiedconsumerfirmware",
"FormattedName": "consumerfirmware",
"Kind": "Data",
"OriginDetails": [
"Mission reward",
Expand All @@ -864,7 +864,7 @@
{
"Name": "Modified Embedded Firmware",
"Rarity": "VeryRare",
"FormattedName": "modifiedembeddedfirmware",
"FormattedName": "embeddedfirmware",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand Down Expand Up @@ -921,7 +921,7 @@
{
"Name": "Open Symmetric Keys",
"Rarity": "Standard",
"FormattedName": "opensymmetrickeys",
"FormattedName": "symmetrickeys",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand Down Expand Up @@ -988,7 +988,7 @@
{
"Name": "Peculiar Shield Frequency Data",
"Rarity": "VeryRare",
"FormattedName": "peculiarshieldfrequencydata",
"FormattedName": "shieldfrequencydata",
"Kind": "Data",
"OriginDetails": [
"Ship scanning",
Expand Down Expand Up @@ -1204,7 +1204,7 @@
{
"Name": "Security Firmware Patch",
"Rarity": "Rare",
"FormattedName": "securityfirmwarepatch",
"FormattedName": "securityfirmware",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand Down Expand Up @@ -1252,7 +1252,7 @@
{
"Name": "Specialised Legacy Firmware",
"Rarity": "VeryCommon",
"FormattedName": "specialisedlegacyfirmware",
"FormattedName": "legacyfirmware",
"Kind": "Data",
"OriginDetails": [
"Mission reward",
Expand All @@ -1264,7 +1264,7 @@
{
"Name": "Strange Wake Solutions",
"Rarity": "Standard",
"FormattedName": "strangewakesolutions",
"FormattedName": "wakesolutions",
"Kind": "Data",
"OriginDetails": [
"High wake scanning",
Expand All @@ -1288,7 +1288,7 @@
{
"Name": "Tagged Encryption Codes",
"Rarity": "Common",
"FormattedName": "taggedencryptioncodes",
"FormattedName": "encryptioncodes",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand Down Expand Up @@ -1378,7 +1378,7 @@
{
"Name": "Unidentified Scan Archives",
"Rarity": "Common",
"FormattedName": "unidentifiedscanarchives",
"FormattedName": "scanarchives",
"Kind": "Data",
"OriginDetails": [
"Ship scanning (transport ships)"
Expand All @@ -1398,7 +1398,7 @@
{
"Name": "Unusual Encrypted Files",
"Rarity": "VeryCommon",
"FormattedName": "unusualencryptedfiles",
"FormattedName": "encryptedfiles",
"Kind": "Data",
"OriginDetails": [
"Surface data point",
Expand Down
2 changes: 1 addition & 1 deletion Elite/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ protected override void OnStartup(StartupEventArgs evtArgs)
Data.EngineersList = Station.GetEngineers(@"Data\engineers.json");

splashScreen.Dispatcher.Invoke(() => splashScreen.ProgressText.Text = "Loading Engineering Materials...");
Engineer.EngineeringMaterials = Engineer.GetAllEngineeringMaterials(@"Data\entryData.json");
(Engineer.EngineeringMaterials, Engineer.EngineeringMaterialsByKey) = Engineer.GetAllEngineeringMaterials(@"Data\entryData.json");

splashScreen.Dispatcher.Invoke(() => splashScreen.ProgressText.Text = "Loading Blueprints...");
Engineer.Blueprints = Engineer.GetAllBlueprints(@"Data\blueprints.json", Engineer.EngineeringMaterials);
Expand Down
12 changes: 8 additions & 4 deletions Elite/Engineer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,34 @@ public static class Engineer

public static Dictionary<string,EntryData> EngineeringMaterials;

public static Dictionary<string, EntryData> EngineeringMaterialsByKey;

public static string CommanderName;

public static List<BlueprintShoppingListItem> BlueprintShoppingList = new List<BlueprintShoppingListItem>();

public static List<IngredientShoppingListItem> IngredientShoppingList = new List<IngredientShoppingListItem>();

public static Dictionary<string,EntryData> GetAllEngineeringMaterials(string path)
public static (Dictionary<string,EntryData>,Dictionary<string, EntryData>) GetAllEngineeringMaterials(string path)
{
try
{
path = Path.Combine(App.ExePath, path);

if (File.Exists(path))
{
return JsonConvert.DeserializeObject<List<EntryData>>(File.ReadAllText(path))
.ToDictionary(x => x.Name, x => x);
var json = JsonConvert.DeserializeObject<List<EntryData>>(File.ReadAllText(path));

return (json.ToDictionary(x => x.Name, x => x),
json.ToDictionary(x => x.FormattedName.ToLower(), x => x));
}
}
catch (Exception ex)
{
App.Log.Error(ex);
}

return new Dictionary<string, EntryData>();
return (new Dictionary<string, EntryData>(), new Dictionary<string, EntryData>());
}

public static Dictionary<(string, string, int?), Blueprint> GetAllBlueprints(string path, Dictionary<string, EntryData> engineeringMaterials)
Expand Down
14 changes: 7 additions & 7 deletions Elite/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static int GetMaximumCapacity(string name)
{
var maximumCapacity = 0;

Engineer.EngineeringMaterials.TryGetValue(name, out var entry);
Engineer.EngineeringMaterialsByKey.TryGetValue(name, out var entry);
if (entry != null)
{
maximumCapacity = entry.MaximumCapacity;
Expand All @@ -87,7 +87,7 @@ public static void HandleMaterialsEvent(MaterialsEvent.MaterialsEventArgs info)
{
var name = (e.Name_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(e.Name.ToLower())).Trim();

MaterialList.Add(e.Name, new MaterialItem{ Category = "Encoded" ,Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(name)});
MaterialList.Add(e.Name, new MaterialItem{ Category = "Encoded" ,Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(e.Name.ToLower()) });
}
}

Expand All @@ -97,7 +97,7 @@ public static void HandleMaterialsEvent(MaterialsEvent.MaterialsEventArgs info)
{
var name = (e.Name_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(e.Name.ToLower())).Trim();

MaterialList.Add(e.Name, new MaterialItem { Category = "Manufactured", Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(name) });
MaterialList.Add(e.Name, new MaterialItem { Category = "Manufactured", Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(e.Name.ToLower()) });
}
}

Expand All @@ -107,7 +107,7 @@ public static void HandleMaterialsEvent(MaterialsEvent.MaterialsEventArgs info)
{
var name = (e.Name_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(e.Name.ToLower())).Trim();

MaterialList.Add(e.Name, new MaterialItem { Category = "Raw", Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(name) });
MaterialList.Add(e.Name, new MaterialItem { Category = "Raw", Name = name, Count = e.Count, MaximumCapacity = GetMaximumCapacity(e.Name.ToLower()) });
}
}

Expand All @@ -123,7 +123,7 @@ public static void HandleMaterialCollectedEvent(MaterialCollectedEvent.MaterialC
{
var name = (info.Name_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(info.Name.ToLower())).Trim();

MaterialList.Add(info.Name, new MaterialItem { Category = info.Category, Name = name, Count = info.Count, MaximumCapacity = GetMaximumCapacity(name) });
MaterialList.Add(info.Name, new MaterialItem { Category = info.Category, Name = name, Count = info.Count, MaximumCapacity = GetMaximumCapacity(info.Name.ToLower()) });
}

}
Expand Down Expand Up @@ -159,7 +159,7 @@ public static void HandleMaterialTradedEvent(MaterialTradeEvent.MaterialTradeEve
{
var name = (info.Received.Material_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(info.Received.Material.ToLower())).Trim();

MaterialList.Add(info.Received.Material, new MaterialItem { Category = info.Received.Category_Localised ?? info.Received.Category, Name = name, Count = info.Received.Quantity, MaximumCapacity = GetMaximumCapacity(name) });
MaterialList.Add(info.Received.Material, new MaterialItem { Category = info.Received.Category_Localised ?? info.Received.Category, Name = name, Count = info.Received.Quantity, MaximumCapacity = GetMaximumCapacity(info.Received.Material.ToLower()) });
}
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public static void HandleMissionCompletedEvent(MissionCompletedEvent.MissionComp
{
var name = (i.Name_Localised ?? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(i.Name.ToLower())).Trim();

MaterialList.Add(i.Name, new MaterialItem { Category = i.Category_Localised ?? i.Category, Name = name, Count = i.Count, MaximumCapacity = GetMaximumCapacity(name) });
MaterialList.Add(i.Name, new MaterialItem { Category = i.Category_Localised ?? i.Category, Name = name, Count = i.Count, MaximumCapacity = GetMaximumCapacity(i.Name.ToLower()) });
}

}
Expand Down
4 changes: 2 additions & 2 deletions Elite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.7.0")]
[assembly: AssemblyFileVersion("1.6.7.0")]
[assembly: AssemblyVersion("1.6.8.0")]
[assembly: AssemblyFileVersion("1.6.8.0")]

[assembly: log4net.Config.XmlConfigurator(Watch = true)]
4 changes: 2 additions & 2 deletions ImportData/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.7.0")]
[assembly: AssemblyFileVersion("1.6.7.0")]
[assembly: AssemblyVersion("1.6.8.0")]
[assembly: AssemblyFileVersion("1.6.8.0")]

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

0 comments on commit 343275d

Please sign in to comment.