How the-paid-actor/dcs-dtc works
Project Type and Purpose
• This is a Windows desktop application built in .NET 7.0 (WinForms) that emulates a Data Cartridge (DTC) for various aircraft in DCS World (F-16, F/A-18, F-15E, Apache).
• It provides UI for creating, loading, sharing and uploading mission presets, coordinate capture via in-game Lua scripts, and a CLI for automation.
• Secondary projects include:
• DTCCodeGenerator: a Roslyn source generator tool producing strongly-typed preset classes at build time.
• installer: Visual Studio deployment project producing an MSI.
Key Architectural Components
A. Build & Deployment
• DTCCodeGenerator.csproj runs during build to generate/mutate code (via SourceGenerator.cs).
• dcs-dtc.sln builds the Desktop App (dcs-dtc) and CodeGenerator.
• installer.vdproj packages the compiled desktop app, Lua scripts, and installer components.
B. Desktop Client (dcs-dtc)
1. Program.cs (entrypoint)
• Parses command-line args (--load, --upload, --exit).
• Instantiates MainForm (WinForms).
2. UI Layer
• UI/Base: core forms, controls (buttons, grids, dialogs).
• UI/Aircraft-specific pages under New/UI/Aircrafts (AH64D, F15E, F16, FA18) generated by the source generator and powered by Preset models.
• UI/Base/Systems: reusable system panels (RadioControl, WaypointEdit, KneeboardPage).
3. Preset Model & Config
• New/Presets/V1 and V2: domain model for each aircraft’s configuration.
• Base/ConfigLoader, Configuration, Preset classes handle JSON<–>C# mapping.
• Utilities/FileStorage reads/writes presets and settings in Documents\DCS-DTC.
4. Uploader Engine
• New/Uploader defines per-aircraft uploader classes (e.g. F16Uploader, AH64DUploader).
• Base/Uploader abstracts command sequences, conditions, devices.
• Utilities/CockpitUploadHelper & Network (UDPSocket, KneeboardSender, PresetDataSender) manage the handshake with DCS Lua.
5. Utilities
• Coordinate conversion, INI management (IniFile), NamedPipeServer for IPC.
• Network receivers (CockpitInfoReceiver, WaypointCaptureReceiver) listen for DCS-side events.
6. Embedded DCS Scripts
• Under dcs-dtc/DCS: Lua scripts (DCSDTC.lua, hook.lua) and Skins deliver in-cockpit UI and capture dialogs.
• DCS/Hooks/DCSDTCHook.lua injects the main Lua script into the simulation.
C. DCS Integration
• Lua scripts run inside DCS and communicate over UDP and Named Pipes back to the Windows client.
• Keyboard shortcuts (Ctrl+Shift+D/K) trigger dialogs and data exchange.
Relationships & Data Flow
• Build: → [DTCCodeGenerator] → generates C# model code → compiled into Desktop Client.
• Installer: bundles Desktop Client + DCS Scripts → end user installation.
• Runtime:
a. User invokes Desktop Client (WinForms).
b. UI loads Presets from FileStorage.
c. Selecting “Upload” calls Uploader Engine → sends commands via UDP/Named Pipes to DCS scripts → configures in-game jet.
d. User presses cockpit button in DCS → Lua scripts capture event → send data back to Desktop Client via NamedPipe/UDP → UI updates.
• CLI mode: Program.cs processes args → loads preset → triggers upload → exits.
Architectural Patterns & Design Principles
• Modular “Plugin” style for aircraft: each aircraft has its own Preset, UI, and Uploader under New/…
• Factory pattern: AircraftPageFactory creates the correct UI page based on selected aircraft.
• Command pattern: Base/Uploader chains commands and conditions for each device.
• Separation of concerns:
• UI vs. Model (Presets) vs. Uploader vs. Utilities (storage, network).
• Build-time code generation for strong typing (SourceGenerator).