Compare commits

...

2 Commits

5 changed files with 49 additions and 2 deletions

View File

@ -3,13 +3,25 @@
namespace EDJournal {
public class Credits {
public static string FormatCredits(int amount) {
return FormatCredits((long)amount);
}
public static string FormatCredits(long amount) {
var format = new CultureInfo(CultureInfo.CurrentCulture.Name, true).NumberFormat;
format.NumberGroupSeparator = ",";
format.NumberDecimalSeparator = ".";
format.NumberGroupSizes = new int[1] { 3 };
format.NumberDecimalDigits = 0;
if (amount > 0 && (amount % 1000000) == 0) {
format.NumberDecimalDigits = 1;
if (amount > 0 && (amount % 1000000000) == 0) {
amount /= 1000000000;
return string.Format("{0}M CR", amount.ToString("N", format));
} else if (amount > 0 && (amount % 1000000) == 0) {
amount /= 1000000;
return string.Format("{0}M CR", amount.ToString("N", format));
} else if (amount > 0 && (amount % 100000) == 0) {
double am = ((double)amount) / 1000000;
format.NumberDecimalDigits = 1;
return string.Format("{0}M CR", am.ToString("N", format));
} else if (amount > 0 && (amount % 1000) == 0) {
amount /= 1000;
return string.Format("{0}K CR", amount.ToString("N", format));

View File

@ -29,6 +29,7 @@ namespace EDJournal {
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
{ Events.SellExplorationData, typeof(SellExplorationDataEntry) },
{ Events.SellMicroResources, typeof(SellMicroResourcesEntry) },
{ Events.ShieldState, typeof(ShieldStateEntry) },
{ Events.ShipTargeted, typeof(ShipTargetedEntry) },

View File

@ -18,6 +18,7 @@
public static readonly string MissionRedirected = "MissionRedirected";
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
public static readonly string RedeemVoucher = "RedeemVoucher";
public static readonly string SellExplorationData = "SellExplorationData";
public static readonly string SellMicroResources = "SellMicroResources";
public static readonly string ShieldState = "ShieldState";
public static readonly string ShipTargeted = "ShipTargeted";

View File

@ -0,0 +1,32 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Linq;
namespace EDJournal {
public class SellExplorationDataEntry : Entry {
private List<string> systems = new List<string>();
private List<string> discovered = new List<string>();
public long BaseValue { get; set; }
public long Bonus { get; set; }
public long TotalEarnings { get; set; }
public List<string> Systems => systems;
public List<string> Discovered => discovered;
protected override void Initialise() {
BaseValue = JSON.Value<long?>("BaseValue") ?? 0;
Bonus = JSON.Value<long?>("Bonus") ?? 0;
TotalEarnings = JSON.Value<long?>("TotalEarnings") ?? 0;
var sys = JSON.Value<JArray>("Systems");
if (sys != null) {
systems = sys.Select(x => x.ToString()).ToList<string>();
}
var dis = JSON.Value<JArray>("Discovered");
if (dis != null) {
discovered = dis.Select(x => x.ToString()).ToList<string>();
}
}
}
}

View File

@ -68,6 +68,7 @@
<Compile Include="PlayerJournal.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RedeemVoucherEntry.cs" />
<Compile Include="SellExplorationDataEntry.cs" />
<Compile Include="SellMicroResourcesEntry.cs" />
<Compile Include="ShieldStateEntry.cs" />
<Compile Include="ShipTargetedEntry.cs" />