Skip to content

Commit

Permalink
Implement flexible colors by importing from TopSkySettings.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
EightSmart committed Jul 13, 2024
1 parent da7931a commit c12c3f5
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 32 deletions.
29 changes: 15 additions & 14 deletions AT3/AT3RadarTargetDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
#include "Constant.hpp"
#include "EuroScopePlugIn.h"
#include "AT3RadarTargetDisplay.hpp"
#include <gdiplus.h>

using namespace Gdiplus;
using namespace EuroScopePlugIn;

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

colorAssumed.SetFromCOLORREF(colorA);
colorNotAssumed.SetFromCOLORREF(colorNA);
colorRedundant.SetFromCOLORREF(colorR);
}

void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display)
Expand Down Expand Up @@ -75,19 +76,19 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display)
GraphicsContainer gContainer = g.BeginContainer();

// Set brush color based on state
SolidBrush aircraftBrush(DEFAULT_UNCONCERNED);
dc.SetTextColor(DEFAULT_UNCONCERNED.ToCOLORREF());
SolidBrush aircraftBrush(colorRedundant);
dc.SetTextColor(colorRedundant.ToCOLORREF());
if (fp.GetState() == FLIGHT_PLAN_STATE_ASSUMED) {
aircraftBrush.SetColor(DEFAULT_ASSUMED);
dc.SetTextColor(DEFAULT_ASSUMED.ToCOLORREF());
aircraftBrush.SetColor(colorAssumed);
dc.SetTextColor(colorAssumed.ToCOLORREF());
}
else if (fp.GetState() == FLIGHT_PLAN_STATE_TRANSFER_FROM_ME_INITIATED) {
aircraftBrush.SetColor(DEFAULT_ASSUMED);
dc.SetTextColor(DEFAULT_REDUNDANT.ToCOLORREF());
aircraftBrush.SetColor(colorAssumed);
dc.SetTextColor(colorRedundant.ToCOLORREF());
}
else if (fp.GetState() == FLIGHT_PLAN_STATE_REDUNDANT || fp.GetState() == FLIGHT_PLAN_STATE_TRANSFER_TO_ME_INITIATED) {
aircraftBrush.SetColor(DEFAULT_REDUNDANT);
dc.SetTextColor(DEFAULT_REDUNDANT.ToCOLORREF());
aircraftBrush.SetColor(colorRedundant);
dc.SetTextColor(colorRedundant.ToCOLORREF());
}

// Override aircraft color conditions
Expand Down Expand Up @@ -154,23 +155,23 @@ 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());
dc.SetTextColor(DEFAULT_ASSUMED.ToCOLORREF());
dc.SetTextColor(colorAssumed.ToCOLORREF());
}
else {
CJSLabelText = fp.GetHandoffTargetControllerId();
}
} else if (fp.GetState() == FLIGHT_PLAN_STATE_ASSUMED) {
if (CJSLabelShowFreq[fp.GetCallsign()]) {
CJSLabelText = GetControllerFreqFromId(GetControllerIdFromCallsign(fp.GetCoordinatedNextController()));
dc.SetTextColor(DEFAULT_ASSUMED.ToCOLORREF());
dc.SetTextColor(colorAssumed.ToCOLORREF());
}
else {
CJSLabelText = GetControllerIdFromCallsign(fp.GetCoordinatedNextController());
}
} else {
if (CJSLabelShowFreq[fp.GetCallsign()]) {
CJSLabelText = GetControllerFreqFromId(fp.GetTrackingControllerId());
dc.SetTextColor(DEFAULT_ASSUMED.ToCOLORREF());
dc.SetTextColor(colorAssumed.ToCOLORREF());
} else {
CJSLabelText = fp.GetTrackingControllerId();
}
Expand Down
9 changes: 8 additions & 1 deletion AT3/AT3RadarTargetDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
#include <string>
#include <iostream>
#include <unordered_map>
#include <gdiplus.h>


using namespace std;
using namespace EuroScopePlugIn;
using namespace Gdiplus;

class HKCPDisplay;
class HKCPPlugin;

class AT3RadarTargetDisplay :
public EuroScopePlugIn::CRadarScreen
{
public:
AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, bool _CJSLabelShowWhenTracked, double _PlaneIconScale);
AT3RadarTargetDisplay(int _CJSLabelSize, int _CJSLabelOffset, bool _CJSLabelShowWhenTracked, double _PlaneIconScale, COLORREF colorA, COLORREF colorNA, COLORREF colorR);

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

Expand All @@ -44,5 +47,9 @@ class AT3RadarTargetDisplay :
bool CJSLabelShowWhenTracked;
double PlaneIconScale;
unordered_map<string, bool> CJSLabelShowFreq;

Color colorAssumed;
Color colorNotAssumed;
Color colorRedundant;
};

20 changes: 12 additions & 8 deletions AT3/AT3Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using namespace EuroScopePlugIn;

AT3Tags::AT3Tags() : CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_PLUGIN_VERSION, MY_PLUGIN_DEVELOPER, MY_PLUGIN_COPYRIGHT)
AT3Tags::AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR) : CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_PLUGIN_VERSION, MY_PLUGIN_DEVELOPER, MY_PLUGIN_COPYRIGHT)
{
RegisterTagItemType("AT3 Altitude", TAG_ITEM_AT3_ALTITUDE);
RegisterTagItemType("AT3 Assigned Altitude", TAG_ITEM_AT3_ALTITUDE_ASSIGNED);
Expand All @@ -31,6 +31,10 @@ AT3Tags::AT3Tags() : CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME
RegisterTagItemFunction("AT3 Approach Selection Menu", TAG_FUNC_APP_SEL_MENU);
RegisterTagItemFunction("AT3 Route Selection Menu", TAG_FUNC_RTE_SEL_MENU);

colorAssumed = colorA;
colorNotAssumed = colorNA;
colorRedundant = colorR;

char DllPathFile[_MAX_PATH];

GetModuleFileNameA(HINSTANCE(&__ImageBase), DllPathFile, sizeof(DllPathFile));
Expand Down Expand Up @@ -169,25 +173,25 @@ void AT3Tags::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int
*pColorCode = TAG_COLOR_RGB_DEFINED;
switch (FlightPlan.GetState()) {
case FLIGHT_PLAN_STATE_NON_CONCERNED:
*pRGB = RGB(117, 132, 142);
*pRGB = colorNotAssumed;
break;
case FLIGHT_PLAN_STATE_NOTIFIED:
*pRGB = RGB(117, 132, 142);
*pRGB = colorNotAssumed;
break;
case FLIGHT_PLAN_STATE_COORDINATED:
*pRGB = RGB(117, 132, 142);
*pRGB = colorNotAssumed;
break;
case FLIGHT_PLAN_STATE_TRANSFER_TO_ME_INITIATED:
*pRGB = RGB(229, 214, 130);
*pRGB = colorRedundant;
break;
case FLIGHT_PLAN_STATE_TRANSFER_FROM_ME_INITIATED:
*pRGB = RGB(241, 246, 255);
*pRGB = colorAssumed;
break;
case FLIGHT_PLAN_STATE_ASSUMED:
*pRGB = RGB(241, 246, 255);
*pRGB = colorAssumed;
break;
case FLIGHT_PLAN_STATE_REDUNDANT:
*pRGB = RGB(229, 214, 130);
*pRGB = colorRedundant;
break;
}

Expand Down
6 changes: 5 additions & 1 deletion AT3/AT3Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AT3Tags :

{
public:
AT3Tags();
AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR);

virtual void OnGetTagItem(CFlightPlan FlightPlan,
CRadarTarget RadarTarget,
Expand Down Expand Up @@ -91,4 +91,8 @@ class AT3Tags :
json appsJson;
json rteJson;
set<string> arptSet;

COLORREF colorAssumed;
COLORREF colorNotAssumed;
COLORREF colorRedundant;
};
6 changes: 3 additions & 3 deletions Constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ const COLORREF BUTTON_RED_OFF = RGB(120, 10, 10);
const COLORREF BUTTON_RED_ON = RGB(240, 50, 50);
const COLORREF BUTTON_GREY = RGB(140, 140, 140);

const Gdiplus::Color DEFAULT_ASSUMED = Gdiplus::Color(241, 246, 255);
const Gdiplus::Color DEFAULT_UNCONCERNED = Gdiplus::Color(117, 132, 142);
const Gdiplus::Color DEFAULT_REDUNDANT = Gdiplus::Color(229, 214, 130);
const COLORREF DEFAULT_ASSUMED = RGB(241, 246, 255);
const COLORREF DEFAULT_UNCONCERNED = RGB(117, 132, 142);
const COLORREF DEFAULT_REDUNDANT = RGB(229, 214, 130);
const Gdiplus::Color OVERRIDE_AIW = Gdiplus::Color(255, 158, 112);
const Gdiplus::Color OVERRIDE_EMER = Gdiplus::Color(255, 0, 0);

Expand Down
46 changes: 44 additions & 2 deletions HKCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ void __declspec (dllexport) EuroScopePlugInInit(EuroScopePlugIn::CPlugIn**
}

HKCPPlugin::HKCPPlugin() : CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_PLUGIN_VERSION, MY_PLUGIN_DEVELOPER, MY_PLUGIN_COPYRIGHT) {
colorAssumed = GetTopSkyColorSettings("Color_Assumed", RGB(241, 246, 255));
colorNotAssumed = GetTopSkyColorSettings("Color_Unconcerned", RGB(117, 132, 142));
colorRedundant = GetTopSkyColorSettings("Color_Redundant", RGB(229, 214, 130));

VFPC = new CVFPCPlugin();
Atis = new AtisPlugin();
Mapp = new MissedApproachPlugin();
tags = new AT3Tags();
tags = new AT3Tags(colorAssumed, colorNotAssumed, colorRedundant);
}

HKCPPlugin::~HKCPPlugin() {
Expand All @@ -38,6 +42,37 @@ HKCPPlugin::~HKCPPlugin() {
delete tags;
}

COLORREF HKCPPlugin::GetTopSkyColorSettings(string settingName, COLORREF defaultColor)
{
char DllPathFile[_MAX_PATH];

GetModuleFileNameA(HINSTANCE(&__ImageBase), DllPathFile, sizeof(DllPathFile));
string path = DllPathFile;
path.resize(path.size() - strlen("HKCP/HKCP.dll"));
string settingsPath = path + "TopSky/TopSkySettings.txt";

ifstream TopSkySettingsFile(settingsPath);
if (!TopSkySettingsFile) {
DisplayUserMessage("HKCP", "HKCP", "Unable to find TopSkySettings.txt for colors", true, true, false, false, false);
return defaultColor;
}

string line;
while (getline(TopSkySettingsFile, line)) {
if (line.find(settingName) != string::npos) {
break;
}
}

line.erase(0, settingName.length() + 1);
int r, g, b;
istringstream(line.substr(0, 3)) >> r;
istringstream(line.substr(4, 7)) >> g;
istringstream(line.substr(8, 11)) >> b;

return RGB(r, g, b);
}

CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool NeedRadarContent, bool GeoReferenced, bool CanBeSaved, bool CanBeCreated)
{
const char* buffer;
Expand Down Expand Up @@ -77,7 +112,14 @@ CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool Ne
SaveDataToSettings("PlaneIconScale", "PlaneIconScale", to_string(PlaneIconScale).c_str());
}

return new HKCPDisplay(CJSLabelSize, CJSLabelOffset, CJSLabelShowWhenTracked, PlaneIconScale, sDisplayName);
return new HKCPDisplay(CJSLabelSize,
CJSLabelOffset,
CJSLabelShowWhenTracked,
PlaneIconScale,
sDisplayName,
colorAssumed,
colorNotAssumed,
colorRedundant);
}

void HKCPPlugin::OnFunctionCall(int FunctionId, const char* ItemString, POINT Pt, RECT Area) {
Expand Down
6 changes: 6 additions & 0 deletions HKCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class HKCPPlugin :

~HKCPPlugin();

COLORREF GetTopSkyColorSettings(string settingName, COLORREF defaultColor);

virtual void OnFunctionCall(int FunctionId, const char* ItemString, POINT Pt, RECT Area);

virtual CRadarScreen* OnRadarScreenCreated(const char* sDisplayName, bool NeedRadarContent, bool GeoReferenced, bool CanBeSaved, bool CanBeCreated);
Expand All @@ -38,4 +40,8 @@ class HKCPPlugin :
virtual void OnTimer(int Count);

virtual void OnCompilePrivateChat(const char* sSenderCallsign, const char* sReceiverCallsign, const char* sChatMessage);

COLORREF colorAssumed;
COLORREF colorNotAssumed;
COLORREF colorRedundant;
};
11 changes: 9 additions & 2 deletions HKCPDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
#include "HKCPDisplay.hpp"


HKCPDisplay::HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, bool CJSLabelShowWhenTracked, double PlaneIconScale, string RadarDisplayType)
HKCPDisplay::HKCPDisplay(int CJSLabelSize,
int CJSLabelOffset,
bool CJSLabelShowWhenTracked,
double PlaneIconScale,
string RadarDisplayType,
COLORREF colorA,
COLORREF colorNA,
COLORREF colorR)
{
AtisDisp = new AtisDisplay();
MissAlarm = new MissedApproachAlarm();
RadarTargets = new AT3RadarTargetDisplay(CJSLabelSize, CJSLabelOffset, CJSLabelShowWhenTracked, PlaneIconScale);
RadarTargets = new AT3RadarTargetDisplay(CJSLabelSize, CJSLabelOffset, CJSLabelShowWhenTracked, PlaneIconScale, colorA, colorNA, colorR);

if (RadarDisplayType == "Standard ES radar screen") {
isESRadarDisplay = true;
Expand Down
10 changes: 9 additions & 1 deletion HKCPDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ class HKCPDisplay :
bool isESRadarDisplay;
public:

HKCPDisplay(int CJSLabelSize, int CJSLabelOffset, bool CJSLabelShowWhenTracked, double PlaneIconScale, string RadarDisplayType);
HKCPDisplay(int CJSLabelSize,
int CJSLabelOffset,
bool CJSLabelShowWhenTracked,
double PlaneIconScale,
string RadarDisplayType,
COLORREF colorA,
COLORREF colorNA,
COLORREF colorR);

virtual ~HKCPDisplay();

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

0 comments on commit c12c3f5

Please sign in to comment.