finish assigned altitude in metric

This commit is contained in:
Zichao Lin 2022-05-07 23:50:50 +08:00
parent ccd82a4cc4
commit 303134c4a2
6 changed files with 86 additions and 26 deletions

@ -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 ;
}

@ -1,16 +1,60 @@
#include "StdAfx.h"
#include "TinyEurocat.h"
#include <cstring>
#include "stdlib.h"
#include <cstdio>
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)
{

@ -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 );
};

@ -108,6 +108,7 @@
<ClCompile Include="TinyEurocat.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\lib\EuroScopePlugIn.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="TinyEurocat.h" />
</ItemGroup>

@ -35,5 +35,8 @@
<ClInclude Include="TinyEurocat.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\lib\EuroScopePlugIn.h">
<Filter>资源文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -5,7 +5,7 @@
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
@ -14,24 +14,24 @@
#include <afxext.h> // MFC 扩展
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h> // MFC OLE 类
#include <afxodlgs.h> // MFC OLE 对话框类
#include <afxdisp.h> // MFC 自动化类
#include <afxole.h> // MFC OLE 类
#include <afxodlgs.h> // MFC OLE 对话框类
#include <afxdisp.h> // MFC 自动化类
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h> // MFC ODBC 数据库类
#include <afxdb.h> // MFC ODBC 数据库类
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO 数据库类
#include <afxdao.h> // MFC DAO 数据库类
#endif // _AFX_NO_DAO_SUPPORT
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
#endif // _AFX_NO_AFXCMN_SUPPORT