2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-07-01 08:23:42 -04:00

Rework Journal File Reading

Remove Explorer
Remove Plugin Architecture
This commit is contained in:
2024-04-14 21:51:56 +10:00
parent c0c69dcdf7
commit 256ebb179e
42 changed files with 855 additions and 2807 deletions

View File

@ -1,20 +1,22 @@
namespace Observatory.Framework;
using System.Text.Json.Nodes;
namespace Observatory.Framework;
/// <summary>
/// Provides data for Elite Dangerous journal events.
/// </summary>
public class JournalEventArgs : EventArgs
public class JournalEventArgs(string journalEventType, JsonObject journalEvent) : EventArgs
{
/// <summary>
/// <para>Type of journal entry that triggered event.</para>
/// <para>Will be a class from the Observatory.Framework.Files.Journal namespace derived from JournalBase, or JournalBase itself in the case of an unhandled journal event type.</para>
/// </summary>
public Type journalType;
public string JournalEventType = journalEventType;
/// <summary>
/// <para>Elite Dangerous journal event, deserialized into a .NET object of the type specified by JournalEventArgs.journalType.</para>
/// <para>Unhandled json values within a journal entry type will be contained in member property:<br/>Dictionary&lt;string, object&gt; AdditionalProperties.</para>
/// </summary>
public object journalEvent;
public JsonObject JournalEvent = journalEvent;
}
/// <summary>
@ -26,48 +28,59 @@ public class NotificationArgs
/// Text typically displayed as header content.
/// </summary>
public string Title;
/// <summary>
/// SSML representation of Title text.<br/>
/// This value is optional, if omitted the value of <c>NotificationArgs.Title</c> will be used for voice synthesis without markup.
/// </summary>
public string TitleSsml;
/// <summary>
/// Text typically displayed as body content.
/// </summary>
public string Detail;
/// <summary>
/// SSML representation of Detail text.<br/>
/// This value is optional, if omitted the value of <c>NotificationArgs.Detail</c> will be used for voice synthesis without markup.
/// </summary>
public string DetailSsml;
/// <summary>
/// Specify window timeout in ms (overrides Core setting). Specify 0 timeout to persist until removed via IObservatoryCore.CancelNotification. Default -1 (use Core setting).
/// </summary>
public int Timeout = -1;
/// <summary>
/// Specify window X position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
/// </summary>
public double XPos = -1.0;
/// <summary>
/// Specify window Y position as a percentage from upper left corner (overrides Core setting). Default -1.0 (use Core setting).
/// </summary>
public double YPos = -1.0;
/// <summary>
/// Specifies the desired renderings of the notification. Defaults to <see cref="NotificationRendering.All"/>.
/// </summary>
public NotificationRendering Rendering = NotificationRendering.All;
/// <summary>
/// Specifies if some part of the notification should be suppressed. Not supported by all notifiers. Defaults to <see cref="NotificationSuppression.None"/>.
/// </summary>
public NotificationSuppression Suppression = NotificationSuppression.None;
/// <summary>
/// The plugin sending this notification.
/// </summary>
public string Sender = "";
/// <summary>
/// Additional notification detailed (generally not rendered by voice or popup; potentially used by aggregating/logging plugins).
/// </summary>
public string ExtendedDetails;
/// <summary>
/// A value which allows grouping of notifications together. For example, values &gt;= 0 &lt;= 1000 could be system body IDs, -1 is the system, anything else is arbitrary.
/// </summary>
@ -84,10 +97,12 @@ public enum NotificationSuppression
/// No suppression.
/// </summary>
None = 0,
/// <summary>
/// Suppress title.
/// </summary>
Title = 1,
/// <summary>
/// Suppress detail.
/// </summary>
@ -104,14 +119,17 @@ public enum NotificationRendering
/// Send notification to native visual popup notificaiton handler.
/// </summary>
NativeVisual = 1,
/// <summary>
/// Send notification to native speech notification handler.
/// </summary>
NativeVocal = 2,
/// <summary>
/// Send notification to all installed notifier plugins.
/// </summary>
PluginNotifier = 4,
/// <summary>
/// Send notification to all available handlers.
/// </summary>
@ -128,18 +146,21 @@ public enum LogMonitorState : uint
/// Monitoring is stopped.
/// </summary>
Idle = 0,
/// <summary>
/// Real-time monitoring is active.
/// </summary>
Realtime = 1,
/// <summary>
/// Batch read of historical journals is in progress.
/// </summary>
Batch = 2,
BatchProcessing = 2,
/// <summary>
/// Batch read of recent journals is in progress to establish current player state.
/// Initial read of recent journals to establish current player state is in progress .
/// </summary>
PreRead = 4
Init = 4
}
/// <summary>
@ -164,6 +185,6 @@ public class LogMonitorStateChangedEventArgs : EventArgs
/// <returns>A boolean; True iff the state provided represents a batch-mode read.</returns>
public static bool IsBatchRead(LogMonitorState state)
{
return state.HasFlag(LogMonitorState.Batch) || state.HasFlag(LogMonitorState.PreRead);
return state.HasFlag(LogMonitorState.BatchProcessing) || state.HasFlag(LogMonitorState.Init);
}
}

View File

@ -5,11 +5,5 @@ public class CarrierDecommission : JournalBase
public ulong CarrierID { get; init; }
public long ScrapRefund { get; init; }
public long ScrapTime { get; init; }
public DateTime ScrapTimeUTC
{
get
{
return DateTimeOffset.FromUnixTimeSeconds(ScrapTime).UtcDateTime;
}
}
public DateTime ScrapTimeUTC => DateTimeOffset.FromUnixTimeSeconds(ScrapTime).UtcDateTime;
}

View File

@ -1,6 +1,4 @@
using System.Text.Json.Serialization;
namespace Observatory.Framework.Files.Journal.FleetCarrier;
namespace Observatory.Framework.Files.Journal.FleetCarrier;
public class CarrierJumpRequest : JournalBase
{
@ -10,10 +8,5 @@ public class CarrierJumpRequest : JournalBase
public ulong CarrierID { get; init; }
public string SystemName { get; init; }
public ulong SystemID { get; init; }
public string DepartureTime { get; init; }
[JsonIgnore]
public DateTimeOffset DepartureTimeDateTime {
get => ParseDateTime(DepartureTime);
}
public DateTimeOffset DepartureTime { get; init; }
}

View File

@ -1,52 +1,289 @@
using System.Globalization;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using Observatory.Framework.Files.Journal.Combat;
using Observatory.Framework.Files.Journal.Exploration;
using Observatory.Framework.Files.Journal.FleetCarrier;
using Observatory.Framework.Files.Journal.Odyssey;
using Observatory.Framework.Files.Journal.Other;
using Observatory.Framework.Files.Journal.Powerplay;
using Observatory.Framework.Files.Journal.Squadron;
using Observatory.Framework.Files.Journal.Startup;
using Observatory.Framework.Files.Journal.StationServices;
using Observatory.Framework.Files.Journal.Trade;
using Observatory.Framework.Files.Journal.Travel;
namespace Observatory.Framework.Files.Journal;
[JsonDerivedType(typeof(BackpackFile))]
[JsonDerivedType(typeof(CargoFile))]
[JsonDerivedType(typeof(FCMaterialsFile))]
[JsonDerivedType(typeof(Bounty))]
[JsonDerivedType(typeof(CapShipBound))]
[JsonDerivedType(typeof(Died))]
[JsonDerivedType(typeof(EscapeInterdiction))]
[JsonDerivedType(typeof(FactionKillBond))]
[JsonDerivedType(typeof(FighterDestroyed))]
[JsonDerivedType(typeof(HeatDamage))]
[JsonDerivedType(typeof(HeatWarning))]
[JsonDerivedType(typeof(HullDamage))]
[JsonDerivedType(typeof(Interdicted))]
[JsonDerivedType(typeof(Interdiction))]
[JsonDerivedType(typeof(PVPKill))]
[JsonDerivedType(typeof(SRVDestroyed))]
[JsonDerivedType(typeof(ShieldState))]
[JsonDerivedType(typeof(ShipTargeted))]
[JsonDerivedType(typeof(UnderAttack))]
[JsonDerivedType(typeof(BuyExplorationData))]
[JsonDerivedType(typeof(CodexEntry))]
[JsonDerivedType(typeof(DiscoveryScan))]
[JsonDerivedType(typeof(FSSAllBodiesFound))]
[JsonDerivedType(typeof(FSSBodySignals))]
[JsonDerivedType(typeof(FSSDiscoveryScan))]
[JsonDerivedType(typeof(FSSSignalDiscovered))]
[JsonDerivedType(typeof(MaterialCollected))]
[JsonDerivedType(typeof(MaterialDiscarded))]
[JsonDerivedType(typeof(MaterialDiscovered))]
[JsonDerivedType(typeof(MultiSellExplorationData))]
[JsonDerivedType(typeof(NavBeaconScan))]
[JsonDerivedType(typeof(SAAScanComplete))]
[JsonDerivedType(typeof(SAASignalsFound))]
[JsonDerivedType(typeof(Scan))]
[JsonDerivedType(typeof(ScanBaryCentre))]
[JsonDerivedType(typeof(Screenshot))]
[JsonDerivedType(typeof(SellExplorationData))]
[JsonDerivedType(typeof(CarrierBankTransfer))]
[JsonDerivedType(typeof(CarrierBuy))]
[JsonDerivedType(typeof(CarrierCancelDecommission))]
[JsonDerivedType(typeof(CarrierCrewServices))]
[JsonDerivedType(typeof(CarrierDecommission))]
[JsonDerivedType(typeof(CarrierDepositFuel))]
[JsonDerivedType(typeof(CarrierDockingPermission))]
[JsonDerivedType(typeof(CarrierFinance))]
[JsonDerivedType(typeof(CarrierJump))]
[JsonDerivedType(typeof(CarrierJumpCancelled))]
[JsonDerivedType(typeof(CarrierJumpRequest))]
[JsonDerivedType(typeof(CarrierModulePack))]
[JsonDerivedType(typeof(CarrierShipPack))]
[JsonDerivedType(typeof(CarrierStats))]
[JsonDerivedType(typeof(CarrierTradeOrder))]
[JsonDerivedType(typeof(FCMaterlas))]
[JsonDerivedType(typeof(InvalidJson))]
[JsonDerivedType(typeof(BackPack))]
[JsonDerivedType(typeof(BackpackChange))]
[JsonDerivedType(typeof(BackpackMaterials))]
[JsonDerivedType(typeof(BookDropship))]
[JsonDerivedType(typeof(BookTaxi))]
[JsonDerivedType(typeof(BuyMicroResources))]
[JsonDerivedType(typeof(BuySuit))]
[JsonDerivedType(typeof(BuyWeapon))]
[JsonDerivedType(typeof(CancelDropship))]
[JsonDerivedType(typeof(CancelTaxi))]
[JsonDerivedType(typeof(CollectItems))]
[JsonDerivedType(typeof(CreateSuitLoadout))]
[JsonDerivedType(typeof(DeleteSuitLoadout))]
[JsonDerivedType(typeof(Disembark))]
[JsonDerivedType(typeof(DropItems))]
[JsonDerivedType(typeof(DropShipDeploy))]
[JsonDerivedType(typeof(Embark))]
[JsonDerivedType(typeof(FCMaterials))]
[JsonDerivedType(typeof(LoadoutEquipModule))]
[JsonDerivedType(typeof(LoadoutRemoveModule))]
[JsonDerivedType(typeof(RenameSuitLoadout))]
[JsonDerivedType(typeof(ScanOrganic))]
[JsonDerivedType(typeof(SellMicroResources))]
[JsonDerivedType(typeof(SellOrganicData))]
[JsonDerivedType(typeof(SellSuit))]
[JsonDerivedType(typeof(SellWeapon))]
[JsonDerivedType(typeof(ShipLockerMaterials))]
[JsonDerivedType(typeof(SuitLoadout))]
[JsonDerivedType(typeof(SwitchSuitLoadout))]
[JsonDerivedType(typeof(TradeMicroResources))]
[JsonDerivedType(typeof(TransferMicroResources))]
[JsonDerivedType(typeof(UpgradeSuit))]
[JsonDerivedType(typeof(UpgradeWeapon))]
[JsonDerivedType(typeof(UseConsumable))]
[JsonDerivedType(typeof(AfmuRepairs))]
[JsonDerivedType(typeof(ApproachSettlement))]
[JsonDerivedType(typeof(CargoTransfer))]
[JsonDerivedType(typeof(ChangeCrewRole))]
[JsonDerivedType(typeof(CockpitBreached))]
[JsonDerivedType(typeof(CommitCrime))]
[JsonDerivedType(typeof(Continued))]
[JsonDerivedType(typeof(CrewLaunchFighter))]
[JsonDerivedType(typeof(CrewMemberJoins))]
[JsonDerivedType(typeof(CrewMemberQuits))]
[JsonDerivedType(typeof(CrewMemberRoleChange))]
[JsonDerivedType(typeof(CrimeVictim))]
[JsonDerivedType(typeof(DataScanned))]
[JsonDerivedType(typeof(DatalinkScan))]
[JsonDerivedType(typeof(DatalinkVoucher))]
[JsonDerivedType(typeof(DockFighter))]
[JsonDerivedType(typeof(DockSRV))]
[JsonDerivedType(typeof(EndCrewSession))]
[JsonDerivedType(typeof(FighterRebuilt))]
[JsonDerivedType(typeof(Friends))]
[JsonDerivedType(typeof(FuelScoop))]
[JsonDerivedType(typeof(JetConeBoost))]
[JsonDerivedType(typeof(JetConeDamage))]
[JsonDerivedType(typeof(JoinACrew))]
[JsonDerivedType(typeof(KickCrewMember))]
[JsonDerivedType(typeof(LaunchDrone))]
[JsonDerivedType(typeof(LaunchFighter))]
[JsonDerivedType(typeof(LaunchSRV))]
[JsonDerivedType(typeof(ModuleInfo))]
[JsonDerivedType(typeof(Music))]
[JsonDerivedType(typeof(NpcCrewPaidWage))]
[JsonDerivedType(typeof(NpcCrewRank))]
[JsonDerivedType(typeof(Promotion))]
[JsonDerivedType(typeof(ProspectedAsteroid))]
[JsonDerivedType(typeof(QuitACrew))]
[JsonDerivedType(typeof(RebootRepair))]
[JsonDerivedType(typeof(ReceiveText))]
[JsonDerivedType(typeof(RepairDrone))]
[JsonDerivedType(typeof(ReservoirReplenished))]
[JsonDerivedType(typeof(Resurrect))]
[JsonDerivedType(typeof(Scanned))]
[JsonDerivedType(typeof(SelfDestruct))]
[JsonDerivedType(typeof(SendText))]
[JsonDerivedType(typeof(Shutdown))]
[JsonDerivedType(typeof(Synthesis))]
[JsonDerivedType(typeof(SystemsShutdown))]
[JsonDerivedType(typeof(USSDrop))]
[JsonDerivedType(typeof(VehicleSwitch))]
[JsonDerivedType(typeof(WingAdd))]
[JsonDerivedType(typeof(WingInvite))]
[JsonDerivedType(typeof(WingJoin))]
[JsonDerivedType(typeof(WingLeave))]
[JsonDerivedType(typeof(PowerplayCollect))]
[JsonDerivedType(typeof(PowerplayDefect))]
[JsonDerivedType(typeof(PowerplayDeliver))]
[JsonDerivedType(typeof(PowerplayFastTrack))]
[JsonDerivedType(typeof(PowerplayJoin))]
[JsonDerivedType(typeof(PowerplayLeave))]
[JsonDerivedType(typeof(PowerplaySalary))]
[JsonDerivedType(typeof(PowerplayVote))]
[JsonDerivedType(typeof(PowerplayVoucher))]
[JsonDerivedType(typeof(AppliedToSquadron))]
[JsonDerivedType(typeof(DisbandedSquadron))]
[JsonDerivedType(typeof(InvitedToSquadron))]
[JsonDerivedType(typeof(JoinedSquadron))]
[JsonDerivedType(typeof(KickedFromSquadron))]
[JsonDerivedType(typeof(LeftSquadron))]
[JsonDerivedType(typeof(SharedBookmarkToSquadron))]
[JsonDerivedType(typeof(SquadronCreated))]
[JsonDerivedType(typeof(SquadronDemotion))]
[JsonDerivedType(typeof(SquadronPromotion))]
[JsonDerivedType(typeof(SquadronStartup))]
[JsonDerivedType(typeof(WonATrophyForSquadron))]
[JsonDerivedType(typeof(Cargo))]
[JsonDerivedType(typeof(ClearSavedGame))]
[JsonDerivedType(typeof(Commander))]
[JsonDerivedType(typeof(FileHeader))]
[JsonDerivedType(typeof(LoadGame))]
[JsonDerivedType(typeof(Loadout))]
[JsonDerivedType(typeof(Materials))]
[JsonDerivedType(typeof(Missions))]
[JsonDerivedType(typeof(NewCommander))]
[JsonDerivedType(typeof(Passengers))]
[JsonDerivedType(typeof(Startup.Powerplay))]
[JsonDerivedType(typeof(Progress))]
[JsonDerivedType(typeof(Rank))]
[JsonDerivedType(typeof(Reputation))]
[JsonDerivedType(typeof(Statistics))]
[JsonDerivedType(typeof(BuyAmmo))]
[JsonDerivedType(typeof(BuyDrones))]
[JsonDerivedType(typeof(CargoDepot))]
[JsonDerivedType(typeof(ClearImpound))]
[JsonDerivedType(typeof(CommunityGoal))]
[JsonDerivedType(typeof(CommunityGoalDiscard))]
[JsonDerivedType(typeof(CommunityGoalJoin))]
[JsonDerivedType(typeof(CommunityGoalReward))]
[JsonDerivedType(typeof(CrewAssign))]
[JsonDerivedType(typeof(CrewFire))]
[JsonDerivedType(typeof(CrewHire))]
[JsonDerivedType(typeof(EngineerApply))]
[JsonDerivedType(typeof(EngineerContribution))]
[JsonDerivedType(typeof(EngineerCraft))]
[JsonDerivedType(typeof(EngineerLegacyConvert))]
[JsonDerivedType(typeof(EngineerProgress))]
[JsonDerivedType(typeof(FetchRemoteModule))]
[JsonDerivedType(typeof(Market))]
[JsonDerivedType(typeof(MassModuleStore))]
[JsonDerivedType(typeof(MaterialTrade))]
[JsonDerivedType(typeof(MissionAbandoned))]
[JsonDerivedType(typeof(MissionAccepted))]
[JsonDerivedType(typeof(MissionCompleted))]
[JsonDerivedType(typeof(MissionFailed))]
[JsonDerivedType(typeof(MissionRedirected))]
[JsonDerivedType(typeof(ModuleBuy))]
[JsonDerivedType(typeof(ModuleRetrieve))]
[JsonDerivedType(typeof(ModuleSell))]
[JsonDerivedType(typeof(ModuleSellRemote))]
[JsonDerivedType(typeof(ModuleStore))]
[JsonDerivedType(typeof(ModuleSwap))]
[JsonDerivedType(typeof(Outfitting))]
[JsonDerivedType(typeof(PayBounties))]
[JsonDerivedType(typeof(PayFines))]
[JsonDerivedType(typeof(PayLegacyFines))]
[JsonDerivedType(typeof(RedeemVoucher))]
[JsonDerivedType(typeof(RefuelAll))]
[JsonDerivedType(typeof(RefuelPartial))]
[JsonDerivedType(typeof(Repair))]
[JsonDerivedType(typeof(RepairAll))]
[JsonDerivedType(typeof(RestockVehicle))]
[JsonDerivedType(typeof(ScientificResearch))]
[JsonDerivedType(typeof(SearchAndRescue))]
[JsonDerivedType(typeof(SellDrones))]
[JsonDerivedType(typeof(SellShipOnRebuy))]
[JsonDerivedType(typeof(SetUserShipName))]
[JsonDerivedType(typeof(Shipyard))]
[JsonDerivedType(typeof(ShipyardBuy))]
[JsonDerivedType(typeof(ShipyardNew))]
[JsonDerivedType(typeof(ShipyardSell))]
[JsonDerivedType(typeof(ShipyardSwap))]
[JsonDerivedType(typeof(ShipyardTransfer))]
[JsonDerivedType(typeof(StoredModules))]
[JsonDerivedType(typeof(StoredShips))]
[JsonDerivedType(typeof(TechnologyBroker))]
[JsonDerivedType(typeof(AsteroidCracked))]
[JsonDerivedType(typeof(BuyTradeData))]
[JsonDerivedType(typeof(CollectCargo))]
[JsonDerivedType(typeof(EjectCargo))]
[JsonDerivedType(typeof(MarketBuy))]
[JsonDerivedType(typeof(MarketSell))]
[JsonDerivedType(typeof(MiningRefined))]
[JsonDerivedType(typeof(ApproachBody))]
[JsonDerivedType(typeof(Docked))]
[JsonDerivedType(typeof(DockingCancelled))]
[JsonDerivedType(typeof(DockingDenied))]
[JsonDerivedType(typeof(DockingGranted))]
[JsonDerivedType(typeof(DockingRequested))]
[JsonDerivedType(typeof(DockingTimeout))]
[JsonDerivedType(typeof(FSDJump))]
[JsonDerivedType(typeof(FSDTarget))]
[JsonDerivedType(typeof(LeaveBody))]
[JsonDerivedType(typeof(Liftoff))]
[JsonDerivedType(typeof(Location))]
[JsonDerivedType(typeof(NavRoute))]
[JsonDerivedType(typeof(NavRouteClear))]
[JsonDerivedType(typeof(StartJump))]
[JsonDerivedType(typeof(SupercruiseDestinationDrop))]
[JsonDerivedType(typeof(SupercruiseEntry))]
[JsonDerivedType(typeof(SupercruiseExit))]
[JsonDerivedType(typeof(Touchdown))]
[JsonDerivedType(typeof(Undocked))]
[JsonDerivedType(typeof(MarketFile))]
[JsonDerivedType(typeof(ModuleInfoFile))]
[JsonDerivedType(typeof(NavRouteFile))]
[JsonDerivedType(typeof(OutfittingFile))]
[JsonDerivedType(typeof(ShipyardFile))]
[JsonDerivedType(typeof(Status))]
public class JournalBase
{
[JsonPropertyName("timestamp")]
public string Timestamp { get; init; }
[JsonIgnore]
public DateTimeOffset TimestampDateTime
{
get => ParseDateTime(Timestamp);
}
public DateTimeOffset Timestamp { get; init; }
[JsonPropertyName("event")]
public string Event { get; init; }
[JsonExtensionData]
public Dictionary<string, object> AdditionalProperties { get; init; }
[JsonIgnore]
public string Json
{
get => json;
set
{
if (json == null || string.IsNullOrWhiteSpace(json))
{
json = value;
}
else
{
throw new Exception("Journal property \"Json\" can only be set while empty.");
}
}
}
private string json;
// For use by Journal object classes for .*DateTime properties, like TimestampeDateTime, above.
internal static DateTimeOffset ParseDateTime(string value)
{
if (DateTime.TryParseExact(value, "yyyy-MM-ddTHH:mm:ssZ", null, DateTimeStyles.AssumeUniversal, out var dateTimeValue))
{
return dateTimeValue;
}
return new DateTime();
}
}

View File

@ -1,34 +1,12 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
namespace Observatory.Framework.Files.Journal;
public static class JournalUtilities
{
public static string GetEventType(string line)
public static string? GetEventType(JsonObject? line)
{
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(line));
var result = string.Empty;
try
{
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.PropertyName && reader.GetString() == "event")
{
reader.Read();
result = reader.GetString();
}
}
}
catch
{
result = "InvalidJson";
}
return result;
return line.ContainsKey("event") ? line["event"]?.ToString() : null;
}
public static string CleanScanEvent(string line)
@ -38,6 +16,6 @@ public static class JournalUtilities
public const string ObsoleteMessage = "Unused in Elite Dangerous 3.7+, may appear in legacy journal data.";
public const string UnusedMessage = "Documented by Frontier, but no occurances of this value ever found in real journal data.";
public const string UnusedMessage =
"Documented by Frontier, but no occurances of this value ever found in real journal data.";
}

View File

@ -22,23 +22,14 @@ public class Docked : JournalBase
[Obsolete(JournalUtilities.ObsoleteMessage), JsonConverter(typeof(LegacyFactionConverter<Faction>))]
public Faction Faction
{
private get
{
return StationFaction;
}
init
{
StationFaction = value;
}
private get => StationFaction;
init => StationFaction = value;
}
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string FactionState
{
private get
{
return StationFaction.FactionState;
}
private get => StationFaction.FactionState;
init
{
@ -51,24 +42,24 @@ public class Docked : JournalBase
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string Government
{
private get { return StationGovernment; }
init { StationGovernment = value; }
private get => StationGovernment;
init => StationGovernment = value;
}
public string StationGovernment_Localised { get; init; }
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string Government_Localised
{
private get { return StationGovernment_Localised; }
init { StationGovernment_Localised = value; }
private get => StationGovernment_Localised;
init => StationGovernment_Localised = value;
}
public string StationAllegiance { get; init; }
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string Allegiance
{
private get { return StationAllegiance; }
init { StationAllegiance = value; }
private get => StationAllegiance;
init => StationAllegiance = value;
}
[JsonConverter(typeof(StationServiceConverter))]
@ -78,16 +69,16 @@ public class Docked : JournalBase
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string Economy
{
private get { return StationEconomy; }
init { StationEconomy = value; }
private get => StationEconomy;
init => StationEconomy = value;
}
public string StationEconomy_Localised { get; init; }
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string Economy_Localised
{
private get { return StationEconomy_Localised; }
init { StationEconomy_Localised = value; }
private get => StationEconomy_Localised;
init => StationEconomy_Localised = value;
}
public ImmutableList<StationEconomy> StationEconomies { get; init; }

View File

@ -23,10 +23,7 @@ public class FSDJump : JournalBase
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string FactionState
{
get
{
return SystemFaction.FactionState;
}
get => SystemFaction.FactionState;
init
{
//Stale Data, discard

View File

@ -14,10 +14,7 @@ public class Location : JournalBase
[Obsolete(JournalUtilities.ObsoleteMessage)]
public string FactionState
{
get
{
return SystemFaction.FactionState;
}
get => SystemFaction.FactionState;
init
{
//Stale Data, discard

View File

@ -1,6 +1,4 @@
using Observatory.Framework.Files.Journal;
namespace Observatory.Framework.Files.ParameterTypes;
namespace Observatory.Framework.Files.ParameterTypes;
public class CurrentGoal
{
@ -8,11 +6,7 @@ public class CurrentGoal
public string Title { get; init; }
public string SystemName { get; init; }
public string MarketName { get; init; }
public string Expiry { get; init; }
public DateTimeOffset ExpiryDateTime
{
get => JournalBase.ParseDateTime(Expiry);
}
public DateTimeOffset Expiry { get; init; }
public bool IsComplete { get; init; }
public long CurrentTotal { get; init; }
public long PlayerContribution { get; init; }

View File

@ -22,13 +22,7 @@ public class MaterialTrader
[JsonPropertyName("Raw_Materials_Traded")]
public int RawMaterialsTraded { get; init; }
public int DataMaterialsTraded
{
get
{
return MaterialsTraded - EncodedMaterialsTraded - RawMaterialsTraded;
}
}
public int DataMaterialsTraded => MaterialsTraded - EncodedMaterialsTraded - RawMaterialsTraded;
[JsonPropertyName("Grade_1_Materials_Traded")]
public int Grade1MaterialsTraded { get; init; }

View File

@ -0,0 +1,81 @@
using Observatory.Framework.Files;
namespace Observatory.Framework;
/// <summary>
/// Interface passed by Observatory Core to plugins. Primarily used for sending notifications and UI updates back to Core.
/// </summary>
public interface IObservatoryCore
{
/// <summary>
/// Send a notification out to all native notifiers and any plugins implementing IObservatoryNotifier.
/// </summary>
/// <param name="title">Title text for notification.</param>
/// <param name="detail">Detail/body text for notificaiton.</param>
/// <returns>Guid associated with the notification during its lifetime. Used as an argument with CancelNotification and UpdateNotification.</returns>
public Guid SendNotification(string title, string detail);
/// <summary>
/// Send a notification with arguments out to all native notifiers and any plugins implementing IObservatoryNotifier.
/// </summary>
/// <param name="notificationEventArgs">NotificationArgs object specifying notification content and behaviour.</param>
/// <returns>Guid associated with the notification during its lifetime. Used as an argument with CancelNotification and UpdateNotification.</returns>
public Guid SendNotification(NotificationArgs notificationEventArgs);
/// <summary>
/// Cancel or close an active notification.
/// </summary>
/// <param name="notificationId">Guid of notification to be cancelled.</param>
public void CancelNotification(Guid notificationId);
/// <summary>
/// Update an active notification with a new set of NotificationsArgs. Timeout values are reset and begin counting again from zero if specified.
/// </summary>
/// <param name="notificationId">Guid of notification to be updated.</param>
/// <param name="notificationEventArgs">NotificationArgs object specifying updated notification content and behaviour.</param>
public void UpdateNotification(Guid notificationId, NotificationArgs notificationEventArgs);
/// <summary>
/// Requests current Elite Dangerous status.json content.
/// </summary>
/// <returns>Status object reflecting current Elite Dangerous player status.</returns>
public Status GetStatus();
/// <summary>
/// Version string of Observatory Core.
/// </summary>
public string Version { get; }
/// <summary>
/// Returns a delegate for logging an error for the calling plugin. A plugin can wrap this method
/// or pass it along to its collaborators.
/// </summary>
/// <param name="plugin">The calling plugin</param>
public Action<Exception, string> GetPluginErrorLogger(IObservatoryPlugin plugin);
/// <summary>
/// Shared application HttpClient object. Provided so that plugins can adhere to .NET recommended behaviour of a single HttpClient object per application.
/// </summary>
public HttpClient HttpClient { get; }
/// <summary>
/// Returns the current LogMonitor state.
/// </summary>
public LogMonitorState CurrentLogMonitorState { get; }
/// <summary>
/// Returns true if the current LogMonitor state represents a batch-read mode.
/// </summary>
public bool IsLogMonitorBatchReading { get; }
/// <summary>
/// Retrieves and ensures creation of a location which can be used by the plugin to store persistent data.
/// </summary>
public string PluginStorageFolder { get; }
/// <summary>
/// Sends arbitrary data to all other plugins. The full name and version of the sending plugin will be used to identify the sender to any recipients.
/// </summary>
/// <param name="message">Utf8 data to be sent. Must be serializable to JSON.</param>
public void SendPluginMessage(IObservatoryPlugin plugin, ReadOnlySpan<byte> message);
}

View File

@ -1,5 +1,4 @@
using System.Collections;
using Observatory.Framework.Files;
using Observatory.Framework.Files;
using Observatory.Framework.Files.Journal;
namespace Observatory.Framework;
@ -26,7 +25,7 @@ public interface IObservatoryPlugin
/// Short name of the plugin. Used as the tab title for the plugin UI.<br/>
/// Can be omitted, in which case the full Name will be used.
/// </summary>
public string ShortName { get => Name; }
public string ShortName => Name;
/// <summary>
/// Version string displayed in the Core settings tab's plugin list.<br/>
@ -39,23 +38,6 @@ public interface IObservatoryPlugin
/// </summary>
public PluginUI PluginUI { get; }
/// <summary>
/// <para>Accessors for plugin settings object. Should be initialized with a default state during the plugin constructor.</para>
/// <para>Saving and loading of settings is handled by Observatory Core, and any previously saved settings will be set after plugin instantiation, but before Load() is called.</para>
/// <para>A plugin's settings class is expected to consist of properties with public getters and setters. The settings UI will be automatically generated based on each property type.<br/>
/// The [SettingDisplayName(string name)] attribute can be used to specify a display name, otherwise the name of the property will be used.<br/>
/// Private or internal properties and methods are ignored and can be used for backing values or any other purpose.<br/>
/// If a public property is necessary but not required to be user accessible the [SettingIgnore] property will suppress display.</para>
/// </summary>
public object Settings { get; set; }
/// <summary>
/// <para>Plugin-specific object implementing the IComparer interface which is used to sort columns in the basic UI datagrid.</para>
/// <para>If omitted a natural sort order is used.</para>
/// </summary>
public IObservatoryComparer ColumnSorter
{ get => null; }
/// <summary>
/// Receives data sent by other plugins.
/// </summary>
@ -93,24 +75,6 @@ public interface IObservatoryWorker : IObservatoryPlugin
/// </summary>
public void LogMonitorStateChanged(LogMonitorStateChangedEventArgs eventArgs)
{ }
/// <summary>
/// Method called when the user begins "Read All" journal processing, before any journal events are sent.<br/>
/// Used to track if a "Read All" operation is in progress or not to avoid unnecessary processing or notifications.<br/>
/// Can be omitted for plugins which do not require the distinction.
/// </summary>
[Obsolete("Deprecated in favour of LogMonitorStateChanged")]
public void ReadAllStarted()
{ }
/// <summary>
/// Method called when "Read All" journal processing completes.<br/>
/// Used to track if a "Read All" operation is in progress or not to avoid unnecessary processing or notifications.<br/>
/// Can be omitted for plugins which do not require the distinction.
/// </summary>
[Obsolete("Deprecated in favour of LogMonitorStateChanged")]
public void ReadAllFinished()
{ }
}
/// <summary>
@ -127,116 +91,3 @@ public interface IObservatoryNotifier : IObservatoryPlugin
public void OnNotificationEvent(NotificationArgs notificationEventArgs);
}
/// <summary>
/// Interface passed by Observatory Core to plugins. Primarily used for sending notifications and UI updates back to Core.
/// </summary>
public interface IObservatoryCore
{
/// <summary>
/// Send a notification out to all native notifiers and any plugins implementing IObservatoryNotifier.
/// </summary>
/// <param name="title">Title text for notification.</param>
/// <param name="detail">Detail/body text for notificaiton.</param>
/// <returns>Guid associated with the notification during its lifetime. Used as an argument with CancelNotification and UpdateNotification.</returns>
public Guid SendNotification(string title, string detail);
/// <summary>
/// Send a notification with arguments out to all native notifiers and any plugins implementing IObservatoryNotifier.
/// </summary>
/// <param name="notificationEventArgs">NotificationArgs object specifying notification content and behaviour.</param>
/// <returns>Guid associated with the notification during its lifetime. Used as an argument with CancelNotification and UpdateNotification.</returns>
public Guid SendNotification(NotificationArgs notificationEventArgs);
/// <summary>
/// Cancel or close an active notification.
/// </summary>
/// <param name="notificationId">Guid of notification to be cancelled.</param>
public void CancelNotification(Guid notificationId);
/// <summary>
/// Update an active notification with a new set of NotificationsArgs. Timeout values are reset and begin counting again from zero if specified.
/// </summary>
/// <param name="notificationId">Guid of notification to be updated.</param>
/// <param name="notificationEventArgs">NotificationArgs object specifying updated notification content and behaviour.</param>
public void UpdateNotification(Guid notificationId, NotificationArgs notificationEventArgs);
/// <summary>
/// Add an item to the bottom of the basic UI grid.
/// </summary>
/// <param name="worker">Reference to the calling plugin's worker interface.</param>
/// <param name="item">Grid item to be added. Object type should match original template item used to create the grid.</param>
public void AddGridItem(IObservatoryWorker worker, object item);
/// <summary>
/// Add multiple items to the bottom of the basic UI grid.
/// </summary>
/// <param name="worker">Reference to the calling plugin's worker interface.</param>
/// <param name="items">Grid items to be added. Object types should match original template item used to create the grid.</param>
public void AddGridItems(IObservatoryWorker worker, IEnumerable<Dictionary<string,string>> items);
/// <summary>
/// Replace the contents of the grid with the provided items.
/// </summary>
/// <param name="worker">Reference to the calling plugin's worker interface.</param>
/// <param name="items">Grid items to be added. Object types should match original template item used to create the grid.</param>
public void SetGridItems(IObservatoryWorker worker, IEnumerable<Dictionary<string,string>> items);
/// <summary>
/// Requests current Elite Dangerous status.json content.
/// </summary>
/// <returns>Status object reflecting current Elite Dangerous player status.</returns>
public Status GetStatus();
/// <summary>
/// Version string of Observatory Core.
/// </summary>
public string Version { get; }
/// <summary>
/// Returns a delegate for logging an error for the calling plugin. A plugin can wrap this method
/// or pass it along to its collaborators.
/// </summary>
/// <param name="plugin">The calling plugin</param>
public Action<Exception, string> GetPluginErrorLogger(IObservatoryPlugin plugin);
/// <summary>
/// Shared application HttpClient object. Provided so that plugins can adhere to .NET recommended behaviour of a single HttpClient object per application.
/// </summary>
public HttpClient HttpClient { get; }
/// <summary>
/// Returns the current LogMonitor state.
/// </summary>
public LogMonitorState CurrentLogMonitorState { get; }
/// <summary>
/// Returns true if the current LogMonitor state represents a batch-read mode.
/// </summary>
public bool IsLogMonitorBatchReading { get; }
/// <summary>
/// Retrieves and ensures creation of a location which can be used by the plugin to store persistent data.
/// </summary>
public string PluginStorageFolder { get; }
/// <summary>
/// Sends arbitrary data to all other plugins. The full name and version of the sending plugin will be used to identify the sender to any recipients.
/// </summary>
public void SendPluginMessage(IObservatoryPlugin plugin, object message);
}
/// <summary>
/// Extends the base IComparer interface with exposed values for the column ID and sort order to use.
/// </summary>
public interface IObservatoryComparer : IComparer
{
/// <summary>
/// Column ID to be currently sorted by.
/// </summary>
public int SortColumn { get; set; }
/// <summary>
/// Current order of sorting. Ascending = 1, Descending = -1, No sorting = 0.
/// </summary>
public int Order { get; set; }
}

View File

@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Observatory.Framework</RootNamespace>
<Configurations>Debug;Release;Portable</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>