From 303134c4a2df6ed0f1222f135a1b962139605da6 Mon Sep 17 00:00:00 2001 From: earthjasonlin Date: Sat, 7 May 2022 23:50:50 +0800 Subject: [PATCH] finish assigned altitude in metric --- TinyEurocat/Main.cpp | 11 ++--- TinyEurocat/TinyEurocat.cpp | 58 ++++++++++++++++++++++--- TinyEurocat/TinyEurocat.h | 23 ++++++++-- TinyEurocat/TinyEurocat.vcxproj | 1 + TinyEurocat/TinyEurocat.vcxproj.filters | 3 ++ TinyEurocat/stdafx.h | 16 +++---- 6 files changed, 86 insertions(+), 26 deletions(-) diff --git a/TinyEurocat/Main.cpp b/TinyEurocat/Main.cpp index 2f18eca..11974b3 100644 --- a/TinyEurocat/Main.cpp +++ b/TinyEurocat/Main.cpp @@ -3,16 +3,13 @@ TinyEurocat *pMyPlugIn = NULL; -void __declspec ( dllexport ) - EuroScopePlugInInit ( EuroScopePlugIn :: CPlugIn ** ppPlugInInstance ) +void __declspec ( dllexport ) EuroScopePlugInInit ( EuroScopePlugIn :: CPlugIn **ppPlugInInstance ) { - // allocate - * ppPlugInInstance = pMyPlugIn = - new TinyEurocat ; + // allocate + * ppPlugInInstance = pMyPlugIn = new TinyEurocat ; } -void __declspec ( dllexport ) - EuroScopePlugInExit ( void ) +void __declspec ( dllexport ) EuroScopePlugInExit ( void ) { delete pMyPlugIn ; } diff --git a/TinyEurocat/TinyEurocat.cpp b/TinyEurocat/TinyEurocat.cpp index 2b5718e..4914af5 100644 --- a/TinyEurocat/TinyEurocat.cpp +++ b/TinyEurocat/TinyEurocat.cpp @@ -1,16 +1,60 @@ #include "StdAfx.h" #include "TinyEurocat.h" +#include +#include "stdlib.h" +#include - -TinyEurocat::TinyEurocat(void) : CPlugIn ( EuroScopePlugIn::COMPATIBILITY_CODE, - "TinyEurocat", - "1.0.0", - "Future Sim", - "Open-source" ) +TinyEurocat::TinyEurocat(void) : CPlugIn ( COMPATIBILITY_CODE, + "TinyEurocat", + "1.0.0", + "Future Sim", + "Open-source" ) { - + RegisterTagItemType("Metric / Current Altitude", TAG_ITEM_MET_CURR_ALT); + RegisterTagItemType("Metric / Cleared Altitude", TAG_ITEM_MET_ASS_ALT); + RegisterTagItemType("Metric / Current Speed", TAG_ITEM_MET_CURR_SPD); } +void TinyEurocat::OnGetTagItem( CFlightPlan FlightPlan, + CRadarTarget RadarTarget, + int ItemCode, + int TagData, + char sItemString [ 16 ], + int *pColorCode, + COLORREF *pRGB, + double *pFontSize ) +{ + int maalt, mcalt, mcspd; + switch (ItemCode) + { + case TAG_ITEM_MET_ASS_ALT: + maalt = FlightPlan.GetClearedAltitude() * 0.3048; + if(maalt != 0) + { + maalt /= 100; + if(maalt % 3 == 1) + maalt -= 1; + else if(maalt % 3 == 2) + maalt += 1; + char tmpstr[15]; + itoa(maalt * 10, tmpstr, 10); + sprintf(sItemString, "%04s", tmpstr); + } + else + { + strcpy(sItemString, " "); + } + break; + case TAG_ITEM_MET_CURR_ALT: + mcalt = 1; + itoa(mcalt, sItemString, 10); + break; + case TAG_ITEM_MET_CURR_SPD: + mcspd = RadarTarget.GetGS() * 1.852; + itoa(mcspd, sItemString, 10); + break; + } +} TinyEurocat::~TinyEurocat(void) { diff --git a/TinyEurocat/TinyEurocat.h b/TinyEurocat/TinyEurocat.h index 6d3dd48..826ad44 100644 --- a/TinyEurocat/TinyEurocat.h +++ b/TinyEurocat/TinyEurocat.h @@ -1,10 +1,25 @@ #pragma once #include "..\lib\EuroScopePlugIn.h" -class TinyEurocat : public EuroScopePlugIn::CPlugIn +using namespace EuroScopePlugIn; + +const int TAG_ITEM_MET_CURR_ALT = 1; +const int TAG_ITEM_MET_ASS_ALT = 2; +const int TAG_ITEM_MET_CURR_SPD = 3; + +class TinyEurocat : public CPlugIn { -public: - TinyEurocat(void); - ~TinyEurocat(void); + public: + TinyEurocat(void); + ~TinyEurocat(void); + void OnGetTagItem( CFlightPlan FlightPlan, + CRadarTarget RadarTarget, + int ItemCode, + int TagData, + char sItemString [ 16 ], + int *pColorCode, + COLORREF *pRGB, + double *pFontSize ); + }; diff --git a/TinyEurocat/TinyEurocat.vcxproj b/TinyEurocat/TinyEurocat.vcxproj index 5d22e62..1cef9bb 100644 --- a/TinyEurocat/TinyEurocat.vcxproj +++ b/TinyEurocat/TinyEurocat.vcxproj @@ -108,6 +108,7 @@ + diff --git a/TinyEurocat/TinyEurocat.vcxproj.filters b/TinyEurocat/TinyEurocat.vcxproj.filters index 81ec64a..10f7cde 100644 --- a/TinyEurocat/TinyEurocat.vcxproj.filters +++ b/TinyEurocat/TinyEurocat.vcxproj.filters @@ -35,5 +35,8 @@ 头文件 + + 资源文件 + \ No newline at end of file diff --git a/TinyEurocat/stdafx.h b/TinyEurocat/stdafx.h index 47f49aa..87de902 100644 --- a/TinyEurocat/stdafx.h +++ b/TinyEurocat/stdafx.h @@ -5,7 +5,7 @@ #pragma once #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Windows ͷųʹõ + #define VC_EXTRALEAN // Windows ͷųʹõ #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ @@ -14,24 +14,24 @@ #include // MFC չ #ifndef _AFX_NO_OLE_SUPPORT -#include // MFC OLE -#include // MFC OLE Ի -#include // MFC Զ + #include // MFC OLE + #include // MFC OLE Ի + #include // MFC Զ #endif // _AFX_NO_OLE_SUPPORT #ifndef _AFX_NO_DB_SUPPORT -#include // MFC ODBC ݿ + #include // MFC ODBC ݿ #endif // _AFX_NO_DB_SUPPORT #ifndef _AFX_NO_DAO_SUPPORT -#include // MFC DAO ݿ + #include // MFC DAO ݿ #endif // _AFX_NO_DAO_SUPPORT #ifndef _AFX_NO_OLE_SUPPORT -#include // MFC Internet Explorer 4 ؼ֧ + #include // MFC Internet Explorer 4 ؼ֧ #endif #ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC Windows ؼ֧ + #include // MFC Windows ؼ֧ #endif // _AFX_NO_AFXCMN_SUPPORT