orbitusii / loki-bms-csharp

Battle Management Scope for DCS World (and maybe others?), this time in C#!
MIT License
2 stars 0 forks source link

Data Sources - Refactor into Plugin system #15

Closed orbitusii closed 4 months ago

orbitusii commented 1 year ago

DataSource should be an abstract or generic class that handles the connection process and maintenance DataSource will not do any of its own interpretation, but will feed into a subclass (maybe the target class of the Generic) that does the interpretation and allows for polymorphic, factory-built conversion from raw server data to a TrackDatum

LOKI should load plugin .dlls from ./Plugins/ at runtime using C# Reflection

orbitusii commented 1 year ago

Design change: data source should be an abstract class within the LOKI-BMS project proper. Implementation-level data source objects should be separate class libraries that get loaded at runtime using C#'s Reflection capabilities, allowing for simpler plug-and-play functionality for unique data sources.

Specific steps to take:

  1. Extract DataSource's DCS interface into a separate project within the LOKI-BMS-csharp solution (likely called LOKI-DCS) 1.1. Other DataSource plugins will be named things like "LOKI-Falcon4," "LOKI-CVW5," etc.
  2. The abstract DataSource class within the LOKI-BMS project and core library should have methods needed for all of its important behavior already defined 2.1. Plugin developers shouldn't handle the activation/deactivation logic, but will author specifics of connection, streaming, and parsing 2.2. Plugin developers should be able to add special Advanced settings for a data source class that can be tweaked in the Sources window and get serialized
  3. LOKI-BMS will need to use C#'s Reflection features to load user plugins for DataSources in order to make the plugins work
  4. Sources Window "ADD" button will need to be changed into a dropdown menu that works with a DataSourceFactory thing to build the specific DataSource a user specifies
orbitusii commented 1 year ago

Created loki-plugin-base subproject within the solution. Key classes and functions:

LOKI won't care about anything that goes on within the plugins besides these three classes. Plugins should reference loki-plugin-base and not loki-bms-csharp proper when being developed... unless they're specialized for deeper behavior within LOKI.

orbitusii commented 1 year ago

Functioning for now, needs some refinement and logic for custom menus implemented, but we'll get there eventually

orbitusii commented 1 year ago

Looks like Xaml content for LokiCustomMenu types will have to be loaded by the PluginLoader class in loki-bms-csharp proper. loki-bms-common does not have the required references and I can't find them, nor do I feel like it's strictly necessary to have that behavior implemented in common. Will work on that more tomorrow.

orbitusii commented 11 months ago

CustomMenu class can utilize TemplateWindow functionality, though that behavior will have to be implemented before it can be added to the plugins.