Skip to content

Commit

Permalink
[General] Bugfixes related to coordinate capture
Browse files Browse the repository at this point in the history
  • Loading branch information
the-paid-actor committed Oct 26, 2023
1 parent c8ffd6b commit d13d037
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 23 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>5.3.1</Version>
<Version>5.3.3</Version>
<Product>DTC for DCS</Product>
<Description>$(Product)</Description>
<ApplicationIcon>Resources\Iconleak-Atrous-Disk.ico</ApplicationIcon>
Expand Down
6 changes: 6 additions & 0 deletions dcs-dtc/Models/F15E/Waypoints/Waypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions dcs-dtc/Models/F16/Waypoints/Waypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions dcs-dtc/Models/FA18/Waypoints/Waypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dcs-dtc/UI/Aircrafts/F15E/F15EPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion dcs-dtc/UI/Aircrafts/F15E/WaypointEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
});
Expand Down
2 changes: 1 addition & 1 deletion dcs-dtc/UI/Aircrafts/F16/F16Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions dcs-dtc/UI/Aircrafts/F16/WaypointEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);
}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}));
});
}
Expand Down
2 changes: 1 addition & 1 deletion dcs-dtc/UI/Aircrafts/FA18/FA18Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion dcs-dtc/UI/Aircrafts/FA18/PrePlannedEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}));
});
Expand Down
5 changes: 3 additions & 2 deletions dcs-dtc/UI/Aircrafts/FA18/WaypointEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}));
});
Expand Down
2 changes: 1 addition & 1 deletion dcs-dtc/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions dcs-dtc/Utilities/DCSInstallCheck.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;

namespace DTC.Utilities
{
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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
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:{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:"
Expand Down

0 comments on commit d13d037

Please sign in to comment.