From 72f59d1ff28d8ce3f106b27cdcb57ab5b293fafb Mon Sep 17 00:00:00 2001 From: the-paid-actor Date: Thu, 8 Feb 2024 19:11:36 -0300 Subject: [PATCH] [Apache] Added option to clear all points [Apache] Fix error when uploading empty lists of points [General] Fix error if windows is out of bounds of any display --- dcs-dtc/DTC.csproj | 2 +- .../Aircrafts/AH64D/Systems/UploadSystem.cs | 3 + .../Presets/V2/Base/Systems/WaypointSystem.cs | 5 ++ .../AH64D/Systems/UploadPage.Designer.cs | 50 +++++++++++++++- .../UI/Aircrafts/AH64D/Systems/UploadPage.cs | 21 +++++++ dcs-dtc/New/UI/Base/MainForm.cs | 20 ++++++- .../Aircrafts/AH64D/Systems/Waypoints.cs | 57 ++++++++++++++++--- installer/installer.vdproj | 6 +- 8 files changed, 151 insertions(+), 13 deletions(-) diff --git a/dcs-dtc/DTC.csproj b/dcs-dtc/DTC.csproj index 3e5be3f..77f0e1e 100644 --- a/dcs-dtc/DTC.csproj +++ b/dcs-dtc/DTC.csproj @@ -7,7 +7,7 @@ enable true enable - 7.2.0 + 7.2.1 DTC for DCS $(Product) Resources\Iconleak-Atrous-Disk.ico diff --git a/dcs-dtc/New/Presets/V2/Aircrafts/AH64D/Systems/UploadSystem.cs b/dcs-dtc/New/Presets/V2/Aircrafts/AH64D/Systems/UploadSystem.cs index 7331efd..558a94e 100644 --- a/dcs-dtc/New/Presets/V2/Aircrafts/AH64D/Systems/UploadSystem.cs +++ b/dcs-dtc/New/Presets/V2/Aircrafts/AH64D/Systems/UploadSystem.cs @@ -7,4 +7,7 @@ public class UploadSystem public bool Targets { get; set; } public bool Routes { get; set; } public bool TSD { get; set; } + public bool DeleteWaypoints { get; set; } + public bool DeleteControlMeasures { get; set; } + public bool DeleteTargets { get; set; } } diff --git a/dcs-dtc/New/Presets/V2/Base/Systems/WaypointSystem.cs b/dcs-dtc/New/Presets/V2/Base/Systems/WaypointSystem.cs index 78dc433..50f718e 100644 --- a/dcs-dtc/New/Presets/V2/Base/Systems/WaypointSystem.cs +++ b/dcs-dtc/New/Presets/V2/Base/Systems/WaypointSystem.cs @@ -29,6 +29,11 @@ public virtual T NewWaypoint() }; } + public bool HasWaypoints() + { + return Waypoints != null && Waypoints.Count > 0; + } + public abstract int GetFirstAllowedSequence(); public abstract int GetLastAllowedSequence(); diff --git a/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.Designer.cs b/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.Designer.cs index 6155b9a..aad07e9 100644 --- a/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.Designer.cs +++ b/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.Designer.cs @@ -38,6 +38,9 @@ private void InitializeComponent() chkTargets = new CheckBox(); chkRoutes = new CheckBox(); chkTSD = new CheckBox(); + chkClearWaypoints = new CheckBox(); + chkClearControlMeasures = new CheckBox(); + chkClearTargets = new CheckBox(); SuspendLayout(); // // chkWaypoints @@ -48,7 +51,7 @@ private void InitializeComponent() chkWaypoints.Location = new Point(15, 15); chkWaypoints.Margin = new Padding(4); chkWaypoints.Name = "chkWaypoints"; - chkWaypoints.Size = new Size(102, 25); + chkWaypoints.Size = new Size(154, 25); chkWaypoints.TabIndex = 0; chkWaypoints.Text = "Waypoints"; chkWaypoints.UseVisualStyleBackColor = true; @@ -113,6 +116,45 @@ private void InitializeComponent() chkTSD.Text = "TSD"; chkTSD.UseVisualStyleBackColor = true; // + // chkClearWaypoints + // + chkClearWaypoints.Checked = true; + chkClearWaypoints.CheckState = CheckState.Checked; + chkClearWaypoints.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point); + chkClearWaypoints.Location = new Point(177, 15); + chkClearWaypoints.Margin = new Padding(4); + chkClearWaypoints.Name = "chkClearWaypoints"; + chkClearWaypoints.Size = new Size(154, 25); + chkClearWaypoints.TabIndex = 0; + chkClearWaypoints.Text = "Delete all"; + chkClearWaypoints.UseVisualStyleBackColor = true; + // + // chkClearControlMeasures + // + chkClearControlMeasures.Checked = true; + chkClearControlMeasures.CheckState = CheckState.Checked; + chkClearControlMeasures.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point); + chkClearControlMeasures.Location = new Point(177, 48); + chkClearControlMeasures.Margin = new Padding(4); + chkClearControlMeasures.Name = "chkClearControlMeasures"; + chkClearControlMeasures.Size = new Size(154, 25); + chkClearControlMeasures.TabIndex = 0; + chkClearControlMeasures.Text = "Delete all"; + chkClearControlMeasures.UseVisualStyleBackColor = true; + // + // chkClearTargets + // + chkClearTargets.Checked = true; + chkClearTargets.CheckState = CheckState.Checked; + chkClearTargets.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point); + chkClearTargets.Location = new Point(177, 81); + chkClearTargets.Margin = new Padding(4); + chkClearTargets.Name = "chkClearTargets"; + chkClearTargets.Size = new Size(154, 25); + chkClearTargets.TabIndex = 0; + chkClearTargets.Text = "Delete all"; + chkClearTargets.UseVisualStyleBackColor = true; + // // UploadPage // AutoScaleDimensions = new SizeF(96F, 96F); @@ -120,8 +162,11 @@ private void InitializeComponent() BackColor = Color.PaleGoldenrod; Controls.Add(chkTSD); Controls.Add(chkRoutes); + Controls.Add(chkClearTargets); Controls.Add(chkTargets); + Controls.Add(chkClearControlMeasures); Controls.Add(chkControlMeasures); + Controls.Add(chkClearWaypoints); Controls.Add(chkWaypoints); Font = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point); Margin = new Padding(4); @@ -137,5 +182,8 @@ private void InitializeComponent() private CheckBox chkTargets; private CheckBox chkRoutes; private CheckBox chkTSD; + private CheckBox chkClearWaypoints; + private CheckBox chkClearControlMeasures; + private CheckBox chkClearTargets; } } diff --git a/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.cs b/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.cs index 49a6b41..7e8b3a7 100644 --- a/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.cs +++ b/dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.cs @@ -17,6 +17,13 @@ public UploadPage(AH64DPage parent) : base(parent, nameof(parent.Configuration.U this.SavePreset(); }; + chkClearWaypoints.Checked = upload.DeleteWaypoints; + chkClearWaypoints.CheckedChanged += (s, e) => + { + upload.DeleteWaypoints = chkClearWaypoints.Checked; + this.SavePreset(); + }; + chkControlMeasures.Checked = upload.ControlMeasures; chkControlMeasures.CheckedChanged += (s, e) => { @@ -24,6 +31,13 @@ public UploadPage(AH64DPage parent) : base(parent, nameof(parent.Configuration.U this.SavePreset(); }; + chkClearControlMeasures.Checked = upload.DeleteControlMeasures; + chkClearControlMeasures.CheckedChanged += (s, e) => + { + upload.DeleteControlMeasures = chkClearControlMeasures.Checked; + this.SavePreset(); + }; + chkTargets.Checked = upload.Targets; chkTargets.CheckedChanged += (s, e) => { @@ -31,6 +45,13 @@ public UploadPage(AH64DPage parent) : base(parent, nameof(parent.Configuration.U this.SavePreset(); }; + chkClearTargets.Checked = upload.DeleteTargets; + chkClearTargets.CheckedChanged += (s, e) => + { + upload.DeleteTargets = chkClearTargets.Checked; + this.SavePreset(); + }; + chkRoutes.Checked = upload.Routes; chkRoutes.CheckedChanged += (s, e) => { diff --git a/dcs-dtc/New/UI/Base/MainForm.cs b/dcs-dtc/New/UI/Base/MainForm.cs index 9ab1880..3cfda7d 100644 --- a/dcs-dtc/New/UI/Base/MainForm.cs +++ b/dcs-dtc/New/UI/Base/MainForm.cs @@ -28,11 +28,29 @@ public MainForm() DataReceiver.DataReceived += DataReceiver_DataReceived; DataReceiver.Start(); - this.Location = new Point(Settings.MainWindowX, Settings.MainWindowY); + var position = new Point(Settings.MainWindowX, Settings.MainWindowY); + if (!IsVisibleOnAnyScreen(new Rectangle(position, this.Size))) + { + position = new Point(Math.Max(Settings.MainWindowX, 0), Math.Max(Settings.MainWindowY, 0)); + } + this.Location = position; this.ResizeEnd += MainForm_Move; } + private bool IsVisibleOnAnyScreen(Rectangle rect) + { + foreach (Screen screen in Screen.AllScreens) + { + if (screen.WorkingArea.Contains(rect)) + { + return true; + } + } + + return false; + } + private void MainForm_Move(object? sender, EventArgs e) { Settings.MainWindowX = Location.X; diff --git a/dcs-dtc/New/Uploader/Aircrafts/AH64D/Systems/Waypoints.cs b/dcs-dtc/New/Uploader/Aircrafts/AH64D/Systems/Waypoints.cs index ce228b1..cd7320b 100644 --- a/dcs-dtc/New/Uploader/Aircrafts/AH64D/Systems/Waypoints.cs +++ b/dcs-dtc/New/Uploader/Aircrafts/AH64D/Systems/Waypoints.cs @@ -9,6 +9,38 @@ public partial class AH64DUploader { private void BuildWaypoints(bool pilot) { + Device display = pilot ? MFD_PLT_RIGHT : MFD_CPG_RIGHT; + Device keyboard = pilot ? KU_PILOT : KU_CPG; + + if (config.Upload.DeleteWaypoints || config.Upload.DeleteControlMeasures || config.Upload.DeleteTargets) + { + if (config.Upload.DeleteWaypoints && config.Upload.DeleteControlMeasures && config.Upload.DeleteTargets) + { + DeletePoints(display); + } + else + { + Cmd(display.GetCommand("TSD")); + Cmd(display.GetCommand("T5")); + Cmd(StoreCurrentCoords(display)); + + if (config.Upload.DeleteWaypoints) + { + DeletePoints(display, keyboard, "W", config.Waypoints.GetFirstAllowedSequence(), config.Waypoints.GetLastAllowedSequence()); + } + if (config.Upload.DeleteControlMeasures) + { + DeletePoints(display, keyboard, "C", config.ControlMeasures.GetFirstAllowedSequence(), config.ControlMeasures.GetLastAllowedSequence()); + } + if (config.Upload.DeleteTargets) + { + DeletePoints(display, keyboard, "T", config.Targets.GetFirstAllowedSequence(), config.Targets.GetLastAllowedSequence()); + } + } + } + + Cmd(display.GetCommand("TSD")); + if (!config.Upload.Waypoints && !config.Upload.ControlMeasures && !config.Upload.Targets) @@ -16,27 +48,38 @@ private void BuildWaypoints(bool pilot) return; } - Device display = pilot ? MFD_PLT_RIGHT : MFD_CPG_RIGHT; - Device keyboard = pilot ? KU_PILOT : KU_CPG; - - Cmd(display.GetCommand("TSD")); Cmd(display.GetCommand("T5")); Cmd(StoreCurrentCoords(display)); - if (config.Upload.Waypoints && config.Waypoints != null && config.Waypoints.Waypoints != null) + if (config.Upload.Waypoints && config.Waypoints != null && config.Waypoints.HasWaypoints()) { UploadPoints(config.Waypoints, "W", display, keyboard, true); } - if (config.Upload.ControlMeasures && config.ControlMeasures != null && config.ControlMeasures.Waypoints != null) + if (config.Upload.ControlMeasures && config.ControlMeasures != null && config.ControlMeasures.HasWaypoints()) { UploadPoints(config.ControlMeasures, "C", display, keyboard, false); } - if (config.Upload.Targets && config.Targets != null && config.Targets.Waypoints != null) + if (config.Upload.Targets && config.Targets != null && config.Targets.HasWaypoints()) { UploadPoints(config.Targets, "T", display, keyboard, false); } } + private void DeletePoints(Device display, Device keyboard, string genericPointType, int first, int last) + { + Cmd(display.GetCommand("TSD")); + Cmd(display.GetCommand("B6")); + + for (var i = first; i <= last; i++) + { + StartIf(SequenceInUse(genericPointType, i)); + { + DeletePoint(display, keyboard, genericPointType, i); + } + EndIf(); + } + } + private void UploadPoints(WaypointSystem wptList, string genericPointType, Device display, Device keyboard, bool fullSync) { Cmd(display.GetCommand("TSD")); diff --git a/installer/installer.vdproj b/installer/installer.vdproj index d28d66a..07cda85 100644 --- a/installer/installer.vdproj +++ b/installer/installer.vdproj @@ -198,15 +198,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:DTC for DCS" - "ProductCode" = "8:{168B186C-F722-4107-8804-EA3B5A96ED5A}" - "PackageCode" = "8:{0087B229-644C-4899-BC24-E87F52C45615}" + "ProductCode" = "8:{6C19C2FE-0110-4048-8520-A7F8671B33BF}" + "PackageCode" = "8:{34F0219D-7767-47F2-A498-8CE39527C05E}" "UpgradeCode" = "8:{3D5849D5-76B8-466F-9C16-2B1A020D0784}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:7.2.0" + "ProductVersion" = "8:7.2.1" "Manufacturer" = "8:The_Paid_Actor" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:"