diff --git a/AT3/AT3RadarTargetDisplay.cpp b/AT3/AT3RadarTargetDisplay.cpp index 67cefe8a..209907d6 100644 --- a/AT3/AT3RadarTargetDisplay.cpp +++ b/AT3/AT3RadarTargetDisplay.cpp @@ -3,15 +3,16 @@ #include "Constant.hpp" #include "EuroScopePlugIn.h" #include "AT3RadarTargetDisplay.hpp" -#include 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) @@ -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 @@ -154,7 +155,7 @@ 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(); @@ -162,7 +163,7 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display) } 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()); @@ -170,7 +171,7 @@ void AT3RadarTargetDisplay::OnRefresh(HDC hDC, int Phase, HKCPDisplay* Display) } else { if (CJSLabelShowFreq[fp.GetCallsign()]) { CJSLabelText = GetControllerFreqFromId(fp.GetTrackingControllerId()); - dc.SetTextColor(DEFAULT_ASSUMED.ToCOLORREF()); + dc.SetTextColor(colorAssumed.ToCOLORREF()); } else { CJSLabelText = fp.GetTrackingControllerId(); } diff --git a/AT3/AT3RadarTargetDisplay.hpp b/AT3/AT3RadarTargetDisplay.hpp index c22fc817..392fcdb7 100644 --- a/AT3/AT3RadarTargetDisplay.hpp +++ b/AT3/AT3RadarTargetDisplay.hpp @@ -7,18 +7,21 @@ #include #include #include +#include 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); @@ -44,5 +47,9 @@ class AT3RadarTargetDisplay : bool CJSLabelShowWhenTracked; double PlaneIconScale; unordered_map CJSLabelShowFreq; + + Color colorAssumed; + Color colorNotAssumed; + Color colorRedundant; }; diff --git a/AT3/AT3Tags.cpp b/AT3/AT3Tags.cpp index 0d729b9c..20d719e5 100644 --- a/AT3/AT3Tags.cpp +++ b/AT3/AT3Tags.cpp @@ -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); @@ -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)); @@ -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; } diff --git a/AT3/AT3Tags.hpp b/AT3/AT3Tags.hpp index bd894702..347eba2d 100644 --- a/AT3/AT3Tags.hpp +++ b/AT3/AT3Tags.hpp @@ -21,7 +21,7 @@ class AT3Tags : { public: - AT3Tags(); + AT3Tags(COLORREF colorA, COLORREF colorNA, COLORREF colorR); virtual void OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, @@ -91,4 +91,8 @@ class AT3Tags : json appsJson; json rteJson; set arptSet; + + COLORREF colorAssumed; + COLORREF colorNotAssumed; + COLORREF colorRedundant; }; diff --git a/Constant.hpp b/Constant.hpp index 1cd1bb2e..bf967b59 100644 --- a/Constant.hpp +++ b/Constant.hpp @@ -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); diff --git a/HKCP.cpp b/HKCP.cpp index ee155c0e..0f51d334 100644 --- a/HKCP.cpp +++ b/HKCP.cpp @@ -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() { @@ -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; @@ -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) { diff --git a/HKCP.hpp b/HKCP.hpp index be87d78e..a6753582 100644 --- a/HKCP.hpp +++ b/HKCP.hpp @@ -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); @@ -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; }; diff --git a/HKCPDisplay.cpp b/HKCPDisplay.cpp index f67f7240..9ae6925d 100644 --- a/HKCPDisplay.cpp +++ b/HKCPDisplay.cpp @@ -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; diff --git a/HKCPDisplay.hpp b/HKCPDisplay.hpp index 4565c2cf..3c0ce96e 100644 --- a/HKCPDisplay.hpp +++ b/HKCPDisplay.hpp @@ -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--------------------------------------------