Skip to content

Commit

Permalink
Add setting to display next controller CJS label when assumed
Browse files Browse the repository at this point in the history
* Right clicking opens next controller menu
  • Loading branch information
EightSmart committed Jul 7, 2024
1 parent 45fc7fa commit 6294234
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
33 changes: 26 additions & 7 deletions AT3/AT3RadarTargetDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using namespace Gdiplus;
using namespace EuroScopePlugIn;

AT3RadarTargetDisplay::AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, double _PlaneIconScale) :
CJSLabelSize(_CJSLabelSize), CJSLabelOffset(_CJSLabelOffset), PlaneIconScale(_PlaneIconScale)
AT3RadarTargetDisplay::AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, bool _CJSLabelShowWhenTracked, double _PlaneIconScale) :
CJSLabelSize(_CJSLabelSize), CJSLabelOffset(_CJSLabelOffset), CJSLabelShowWhenTracked(_CJSLabelShowWhenTracked), PlaneIconScale(_PlaneIconScale)
{

}
Expand Down Expand Up @@ -137,7 +137,7 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display)
g.EndContainer(gContainer);
DeleteObject(&aircraftIcon);

if (fp.GetState() == FLIGHT_PLAN_STATE_ASSUMED) {
if (fp.GetState() == FLIGHT_PLAN_STATE_ASSUMED && !CJSLabelShowWhenTracked) {
acft = GetPlugIn()->RadarTargetSelectNext(acft);
continue;
}
Expand All @@ -153,9 +153,17 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display)
if (fp.GetState() == FLIGHT_PLAN_STATE_TRANSFER_FROM_ME_INITIATED) {
if (CJSLabelShowFreq[fp.GetCallsign()]) {
CJSLabelText = GetControllerFreqFromId(fp.GetHandoffTargetControllerId());
} else {
}
else {
CJSLabelText = fp.GetHandoffTargetControllerId();
}
} else if (fp.GetState() == FLIGHT_PLAN_STATE_ASSUMED) {
if (CJSLabelShowFreq[fp.GetCallsign()]) {
CJSLabelText = GetControllerFreqFromId(GetControllerIdFromCallsign(fp.GetCoordinatedNextController()));
}
else {
CJSLabelText = GetControllerIdFromCallsign(fp.GetCoordinatedNextController());
}
} else {
if (CJSLabelShowFreq[fp.GetCallsign()]) {
CJSLabelText = GetControllerFreqFromId(fp.GetTrackingControllerId());
Expand Down Expand Up @@ -184,14 +192,20 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display)
dc.DeleteDC();
}

void AT3RadarTargetDisplay::OnClickScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button)
void AT3RadarTargetDisplay::OnClickScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button, HKCPDisplay* Display)
{
if (ObjectType != CJS_INDICATOR) {
return;
}

string callsign = sObjectId;
CJSLabelShowFreq[callsign] = !CJSLabelShowFreq[callsign];
if (Button == BUTTON_LEFT) {
// Toggle between freq and CJS label
string callsign = sObjectId;
CJSLabelShowFreq[callsign] = !CJSLabelShowFreq[callsign];
} else if (Button == BUTTON_RIGHT) {
// Open next controller menu
Display->StartTagFunction(sObjectId, NULL, TAG_ITEM_TYPE_SECTOR_INDICATOR, "", NULL, TAG_ITEM_FUNCTION_ASSIGNED_NEXT_CONTROLLER, Pt, Area);
}
}

string AT3RadarTargetDisplay::GetControllerFreqFromId(string ID)
Expand All @@ -205,3 +219,8 @@ string AT3RadarTargetDisplay::GetControllerFreqFromId(string ID)
freqString.resize(7);
return freqString;
}

string AT3RadarTargetDisplay::GetControllerIdFromCallsign(string callsign)
{
return GetPlugIn()->ControllerSelect(callsign.c_str()).GetPositionId();
}
10 changes: 7 additions & 3 deletions AT3/AT3RadarTargetDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@ class AT3RadarTargetDisplay :
public EuroScopePlugIn::CRadarScreen
{
public:
AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, double _PlaneIconScale);
AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, bool _CJSLabelShowWhenTracked, double _PlaneIconScale);

void OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display);

virtual void OnClickScreenObject(int ObjectType,
void OnClickScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area,
int Button);
int Button,
HKCPDisplay* Display);

string GetControllerFreqFromId(string ID);

string GetControllerIdFromCallsign(string callsign);

// This gets called before OnAsrContentToBeSaved()
inline virtual void OnAsrContentToBeClosed(void)
{
Expand All @@ -38,6 +41,7 @@ class AT3RadarTargetDisplay :
private:
int CJSLabelSize;
int CJSLabelOffset;
bool CJSLabelShowWhenTracked;
double PlaneIconScale;
unordered_map<string, bool> CJSLabelShowFreq;
};
Expand Down
11 changes: 10 additions & 1 deletion HKCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool Ne
{
const char* buffer;
int CJSLabelSize = 12, CJSLabelOffset = 25;
bool CJSLabelShowWhenTracked = 0;
double PlaneIconScale = 1.0;

buffer = GetDataFromSettings("CJSLabelSize");
Expand All @@ -60,6 +61,14 @@ CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool Ne
SaveDataToSettings("CJSLabelOffset", "CJSLabelOffset", to_string(CJSLabelOffset).c_str());
}

buffer = GetDataFromSettings("CJSLabelShowWhenTracked");
if (buffer != NULL) {
CJSLabelShowWhenTracked = atoi(buffer);
}
else {
SaveDataToSettings("CJSLabelShowWhenTracked", "CJSLabelShowWhenTracked", to_string(CJSLabelShowWhenTracked).c_str());
}

buffer = GetDataFromSettings("PlaneIconScale");
if (buffer != NULL) {
PlaneIconScale = atof(buffer);
Expand All @@ -68,7 +77,7 @@ CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool Ne
SaveDataToSettings("PlaneIconScale", "PlaneIconScale", to_string(PlaneIconScale).c_str());
}

return new HKCPDisplay(CJSLabelSize, CJSLabelOffset, PlaneIconScale);
return new HKCPDisplay(CJSLabelSize, CJSLabelOffset, CJSLabelShowWhenTracked, PlaneIconScale);
}

void HKCPPlugin::OnFunctionCall(int FunctionId, const char* ItemString, POINT Pt, RECT Area) {
Expand Down
6 changes: 3 additions & 3 deletions HKCPDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "HKCPDisplay.hpp"


HKCPDisplay::HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, double PlaneIconScale)
HKCPDisplay::HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, bool CJSLabelShowWhenTracked, double PlaneIconScale)
{
AtisDisp = new AtisDisplay();
MissAlarm = new MissedApproachAlarm();
RadarTargets = new AT3RadarTargetDisplay(CJSLabelSize, CJSLabelOffset, PlaneIconScale);
RadarTargets = new AT3RadarTargetDisplay(CJSLabelSize, CJSLabelOffset, CJSLabelShowWhenTracked, PlaneIconScale);
}

HKCPDisplay::~HKCPDisplay()
Expand Down Expand Up @@ -36,7 +36,7 @@ void HKCPDisplay::OnClickScreenObject(int ObjectType, const char* sObjectId, POI
{
MissAlarm->OnClickScreenObject(ObjectType, sObjectId, Pt, Area, Button);
AtisDisp->OnClickScreenObject(ObjectType, sObjectId, Pt, Area, Button);
RadarTargets->OnClickScreenObject(ObjectType, sObjectId, Pt, Area, Button);
RadarTargets->OnClickScreenObject(ObjectType, sObjectId, Pt, Area, Button, this);
}

void HKCPDisplay::OnMoveScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, bool Released)
Expand Down
2 changes: 1 addition & 1 deletion HKCPDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HKCPDisplay :
AT3RadarTargetDisplay* RadarTargets;
public:

HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, double PlaneIconScale);
HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, bool CJSLabelShowWhenTracked, double PlaneIconScale);
virtual ~HKCPDisplay();

//---OnAsrContentLoaded--------------------------------------------
Expand Down

0 comments on commit 6294234

Please sign in to comment.