From d13d0371a2c2874c7356d030742cdd8f1499d981 Mon Sep 17 00:00:00 2001 From: the-paid-actor Date: Thu, 26 Oct 2023 10:51:19 -0300 Subject: [PATCH] [General] Bugfixes related to coordinate capture --- dcs-dtc/DTC.csproj | 2 +- dcs-dtc/Models/F15E/Waypoints/Waypoint.cs | 6 ++++++ dcs-dtc/Models/F16/Waypoints/Waypoint.cs | 6 ++++++ dcs-dtc/Models/FA18/Waypoints/Waypoint.cs | 6 ++++++ dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs | 2 +- dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs | 3 ++- dcs-dtc/UI/Aircrafts/F16/F16Page.cs | 2 +- dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs | 5 +++-- .../CompositeControls/SteerPointEditControl.cs | 3 ++- dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs | 2 +- dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs | 3 ++- dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs | 5 +++-- dcs-dtc/UI/MainForm.cs | 2 +- dcs-dtc/Utilities/DCSInstallCheck.cs | 17 +++++++++-------- installer/installer.vdproj | 6 +++--- 15 files changed, 47 insertions(+), 23 deletions(-) diff --git a/dcs-dtc/DTC.csproj b/dcs-dtc/DTC.csproj index 951f5f1..1e46826 100644 --- a/dcs-dtc/DTC.csproj +++ b/dcs-dtc/DTC.csproj @@ -7,7 +7,7 @@ enable true enable - 5.3.1 + 5.3.3 DTC for DCS $(Product) Resources\Iconleak-Atrous-Disk.ico diff --git a/dcs-dtc/Models/F15E/Waypoints/Waypoint.cs b/dcs-dtc/Models/F15E/Waypoints/Waypoint.cs index e2f287e..dd76983 100644 --- a/dcs-dtc/Models/F15E/Waypoints/Waypoint.cs +++ b/dcs-dtc/Models/F15E/Waypoints/Waypoint.cs @@ -55,6 +55,12 @@ public void SetCoordinate(string coord) Longitude = match.Groups[2].Value; } + public void SetCoordinate((string, string) latlon) + { + Latitude = latlon.Item1; + Longitude = latlon.Item2; + } + public static bool IsCoordinateValid(string coord) { var match = Coordinate.DegreesMinutesThousandthsRegex.Match(coord); diff --git a/dcs-dtc/Models/F16/Waypoints/Waypoint.cs b/dcs-dtc/Models/F16/Waypoints/Waypoint.cs index 1438bcf..a6cb887 100644 --- a/dcs-dtc/Models/F16/Waypoints/Waypoint.cs +++ b/dcs-dtc/Models/F16/Waypoints/Waypoint.cs @@ -83,6 +83,12 @@ public void SetCoordinate(string coord) Longitude = match.Groups[2].Value; } + public void SetCoordinate((string, string) latlon) + { + Latitude = latlon.Item1; + Longitude = latlon.Item2; + } + public static bool IsCoordinateValid(string coord) { var match = Coordinate.DegreesMinutesThousandthsRegex.Match(coord); diff --git a/dcs-dtc/Models/FA18/Waypoints/Waypoint.cs b/dcs-dtc/Models/FA18/Waypoints/Waypoint.cs index 5ea9d0e..e9b3c92 100644 --- a/dcs-dtc/Models/FA18/Waypoints/Waypoint.cs +++ b/dcs-dtc/Models/FA18/Waypoints/Waypoint.cs @@ -48,6 +48,12 @@ public void SetCoordinate(string coord) Longitude = match.Groups[2].Value; } + public void SetCoordinate((string, string) latlon) + { + Latitude = latlon.Item1; + Longitude = latlon.Item2; + } + public static bool IsCoordinateValid(string coord) { var match = Coordinate.DegreesMinutesHundredthsRegex.Match(coord); diff --git a/dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs b/dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs index ee87a6a..dc8373d 100644 --- a/dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs +++ b/dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs @@ -42,7 +42,7 @@ protected override void WaypointCaptureReceived(WaypointCaptureData[] data) var coord = Coordinate.FromString(d.latitude, d.longitude, CoordinateFormat.NativeDCSFormat); var wpt = new Waypoint(0); wpt.Target = d.target; - wpt.SetCoordinate(string.Join(" ", coord.ToDegreesMinutesThousandths())); + wpt.SetCoordinate(coord.ToDegreesMinutesThousandths()); wpt.Elevation = int.Parse(d.elevation); newWptList.Add(wpt); } diff --git a/dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs b/dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs index 662d127..d57222b 100644 --- a/dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs +++ b/dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs @@ -151,7 +151,8 @@ private void btnCapture_Click(object sender, EventArgs e) { this.ParentForm.Invoke(new MethodInvoker(delegate () { - txtWptLatLong.Text = string.Join(" ", coord.ToDegreesMinutesThousandths()); + var latlon = coord.ToDegreesMinutesThousandths(); + txtWptLatLong.Text = latlon.Item1 + " " + latlon.Item2; txtWptElevation.Value = decimal.Parse(elevation); })); }); diff --git a/dcs-dtc/UI/Aircrafts/F16/F16Page.cs b/dcs-dtc/UI/Aircrafts/F16/F16Page.cs index 8280996..5317601 100644 --- a/dcs-dtc/UI/Aircrafts/F16/F16Page.cs +++ b/dcs-dtc/UI/Aircrafts/F16/F16Page.cs @@ -46,7 +46,7 @@ protected override void WaypointCaptureReceived(WaypointCaptureData[] data) { var coord = Coordinate.FromString(d.latitude, d.longitude, CoordinateFormat.NativeDCSFormat); var wpt = new Waypoint(0); - wpt.SetCoordinate(string.Join(" ", coord.ToDegreesMinutesThousandths())); + wpt.SetCoordinate(coord.ToDegreesMinutesThousandths()); wpt.Elevation = int.Parse(d.elevation); newWptList.Add(wpt); } diff --git a/dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs b/dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs index 0d3173d..68fa018 100644 --- a/dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs +++ b/dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs @@ -136,7 +136,7 @@ private void cboAirbases_SelectedIndexChanged(object sender, EventArgs e) { var item = (AirbaseComboBoxItem)cboAirbases.SelectedItem; _waypoint.Name = item.Airbase; - _waypoint.SetCoordinate(item.Latitude + " " + item.Longitude); + _waypoint.SetCoordinate((item.Latitude, item.Longitude)); _waypoint.Elevation = item.Elevation; LoadWaypoint(); } @@ -151,7 +151,8 @@ private void btnCapture_Click(object sender, EventArgs e) { this.ParentForm.Invoke(new MethodInvoker(delegate () { - txtWptLatLong.Text = string.Join(" ", coord.ToDegreesMinutesThousandths()); + var latlon = coord.ToDegreesMinutesThousandths(); + txtWptLatLong.Text = latlon.Item1 + " " + latlon.Item2; txtWptElevation.Value = decimal.Parse(elevation); })); }); diff --git a/dcs-dtc/UI/Aircrafts/FA18/CompositeControls/SteerPointEditControl.cs b/dcs-dtc/UI/Aircrafts/FA18/CompositeControls/SteerPointEditControl.cs index c844f97..da2cd31 100644 --- a/dcs-dtc/UI/Aircrafts/FA18/CompositeControls/SteerPointEditControl.cs +++ b/dcs-dtc/UI/Aircrafts/FA18/CompositeControls/SteerPointEditControl.cs @@ -163,7 +163,8 @@ private void btnCapture_Click(object sender, EventArgs e) { this.Invoke(new MethodInvoker(delegate () { - txtCoord.Text = string.Join(" ", coord.ToDegreesMinutesSecondsHundredths()); + var latlon = coord.ToDegreesMinutesSecondsHundredths(); + txtCoord.Text = latlon.Item1 + " " + latlon.Item2; })); }); } diff --git a/dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs b/dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs index 5d836ee..0b5249c 100644 --- a/dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs +++ b/dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs @@ -44,7 +44,7 @@ protected override void WaypointCaptureReceived(WaypointCaptureData[] data) { var coord = Coordinate.FromString(d.latitude, d.longitude, CoordinateFormat.NativeDCSFormat); var wpt = new Waypoint(0); - wpt.SetCoordinate(string.Join(" ", coord.ToDegreesMinutesHundredths())); + wpt.SetCoordinate(coord.ToDegreesMinutesHundredths()); wpt.Elevation = int.Parse(d.elevation); newWptList.Add(wpt); } diff --git a/dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs b/dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs index c09c91e..cb45e2c 100644 --- a/dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs +++ b/dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs @@ -124,7 +124,8 @@ private void btnCapture_Click(object sender, EventArgs e) { this.ParentForm.Invoke(new MethodInvoker(delegate () { - txtWptLatLong.Text = string.Join(" ", coord.ToDegreesMinutesSecondsHundredths()); + var latlon = coord.ToDegreesMinutesSecondsHundredths(); + txtWptLatLong.Text = latlon.Item1 + " " + latlon.Item2; txtWptElevation.Text = elevation; })); }); diff --git a/dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs b/dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs index e5f97ab..3dafa51 100644 --- a/dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs +++ b/dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs @@ -201,7 +201,7 @@ private void cboAirbases_SelectedIndexChanged(object sender, EventArgs e) var c = Coordinate.FromString(item.Latitude, item.Longitude, CoordinateFormat.DegreesMinutesThousandths); var wpt = new Waypoint(0); wpt.Name = item.Airbase; - wpt.SetCoordinate(string.Join(" ", c.ToDegreesMinutesHundredths())); + wpt.SetCoordinate(c.ToDegreesMinutesHundredths()); wpt.Elevation = item.Elevation; LoadWaypoint(wpt); } @@ -216,7 +216,8 @@ private void btnCapture_Click(object sender, EventArgs e) { this.ParentForm.Invoke(new MethodInvoker(delegate () { - txtWptLatLong.Text = string.Join(" ", coord.ToDegreesMinutesHundredths()); + var latlon = coord.ToDegreesMinutesHundredths(); + txtWptLatLong.Text = latlon.Item1 + " " + latlon.Item2; txtWptElevation.Text = elevation; })); }); diff --git a/dcs-dtc/UI/MainForm.cs b/dcs-dtc/UI/MainForm.cs index 9f3bdcf..d78d8f0 100644 --- a/dcs-dtc/UI/MainForm.cs +++ b/dcs-dtc/UI/MainForm.cs @@ -23,7 +23,7 @@ public partial class MainForm : Form public MainForm() { InitializeComponent(); - lblVersion.Text = "Version " + Application.ProductVersion; + lblVersion.Text = "Version " + Util.GetAppVersion(); ResetToPage(_mainPage); this.TopMost = Settings.AlwaysOnTop; diff --git a/dcs-dtc/Utilities/DCSInstallCheck.cs b/dcs-dtc/Utilities/DCSInstallCheck.cs index 61f0a69..5cc611c 100644 --- a/dcs-dtc/Utilities/DCSInstallCheck.cs +++ b/dcs-dtc/Utilities/DCSInstallCheck.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace DTC.Utilities { @@ -8,8 +6,11 @@ internal static class DCSInstallCheck { [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)] static extern string SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken = default); + static Guid SavedGamesFolderGuid = new Guid("4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"); + private const string MAIN_LUA_FILE = "DCSDTC.lua"; + public static bool Check() { if (Settings.SkipDCSInstallCheck) return true; @@ -119,13 +120,13 @@ private static bool CheckAndInstall(string path) } var exportLuaContent = File.ReadAllText(exportLuaPath); - if (!exportLuaContent.Contains("local DCSDTClfs=require('lfs'); dofile(DCSDTClfs.writedir()..'Scripts/DCSDTC.lua')")) + if (!exportLuaContent.Contains("local DCSDTClfs=require('lfs'); dofile(DCSDTClfs.writedir()..'Scripts/" + MAIN_LUA_FILE + "')")) { - if (!exportLuaContent.Contains("DCSDTC.lua")) + if (!exportLuaContent.Contains(MAIN_LUA_FILE)) { if (!userAsked && AskUserToInstall(path) == false) return false; dtcLuaInstalled = true; - exportLuaContent += "\n\nlocal DCSDTClfs=require('lfs'); dofile(DCSDTClfs.writedir()..'Scripts/DCSDTC.lua')"; + exportLuaContent += "\n\nlocal DCSDTClfs=require('lfs'); dofile(DCSDTClfs.writedir()..'Scripts/" + MAIN_LUA_FILE + "')"; File.WriteAllText(exportLuaPath, exportLuaContent); } else @@ -135,8 +136,8 @@ private static bool CheckAndInstall(string path) } } - var dcsDtcLuaPath = Path.Combine(scriptsFolder, "DCSDTC.lua"); - var originalDcsDtcLuaPath = Path.Combine(FileStorage.GetCurrentFolder(), "DCS", "DCSDTC.lua"); + var dcsDtcLuaPath = Path.Combine(scriptsFolder, MAIN_LUA_FILE); + var originalDcsDtcLuaPath = Path.Combine(FileStorage.GetCurrentFolder(), "DCS", MAIN_LUA_FILE); if (!File.Exists(dcsDtcLuaPath)) { dtcLuaInstalled = true; diff --git a/installer/installer.vdproj b/installer/installer.vdproj index 817c34a..154b911 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:{CFDB9247-CA38-461E-8577-FC4DC2211511}" - "PackageCode" = "8:{6040A938-9320-4E13-B3C9-18653255C276}" + "ProductCode" = "8:{FAB5643C-19CE-4FFB-A0D1-6875EE3AF80B}" + "PackageCode" = "8:{90495898-9E0D-45EC-96E3-43902548F82B}" "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:5.3.1" + "ProductVersion" = "8:5.3.3" "Manufacturer" = "8:The_Paid_Actor" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:"