Skip to content

Commit

Permalink
[Apache] Added option to clear all points
Browse files Browse the repository at this point in the history
[Apache] Fix error when uploading empty lists of points
[General] Fix error if windows is out of bounds of any display
  • Loading branch information
the-paid-actor committed Feb 8, 2024
1 parent e314901 commit 72f59d1
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dcs-dtc/DTC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>7.2.0</Version>
<Version>7.2.1</Version>
<Product>DTC for DCS</Product>
<Description>$(Product)</Description>
<ApplicationIcon>Resources\Iconleak-Atrous-Disk.ico</ApplicationIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
5 changes: 5 additions & 0 deletions dcs-dtc/New/Presets/V2/Base/Systems/WaypointSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
50 changes: 49 additions & 1 deletion dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions dcs-dtc/New/UI/Aircrafts/AH64D/Systems/UploadPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,41 @@ 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) =>
{
upload.ControlMeasures = chkControlMeasures.Checked;
this.SavePreset();
};

chkClearControlMeasures.Checked = upload.DeleteControlMeasures;
chkClearControlMeasures.CheckedChanged += (s, e) =>
{
upload.DeleteControlMeasures = chkClearControlMeasures.Checked;
this.SavePreset();
};

chkTargets.Checked = upload.Targets;
chkTargets.CheckedChanged += (s, e) =>
{
upload.Targets = chkTargets.Checked;
this.SavePreset();
};

chkClearTargets.Checked = upload.DeleteTargets;
chkClearTargets.CheckedChanged += (s, e) =>
{
upload.DeleteTargets = chkClearTargets.Checked;
this.SavePreset();
};

chkRoutes.Checked = upload.Routes;
chkRoutes.CheckedChanged += (s, e) =>
{
Expand Down
20 changes: 19 additions & 1 deletion dcs-dtc/New/UI/Base/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
57 changes: 50 additions & 7 deletions dcs-dtc/New/Uploader/Aircrafts/AH64D/Systems/Waypoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,77 @@ 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)
{
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<Waypoint> wptList, string genericPointType, Device display, Device keyboard, bool fullSync)
{
Cmd(display.GetCommand("TSD"));
Expand Down
6 changes: 3 additions & 3 deletions installer/installer.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down

0 comments on commit 72f59d1

Please sign in to comment.