-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSituPlugin.cpp
117 lines (104 loc) · 4 KB
/
SituPlugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "pch.h"
#include "SituPlugin.h"
#include "CSiTRadar.h"
#include "json.hpp"
#include "vatsimAPI.h"
using json = nlohmann::json;
const int TAG_ITEM_CTP_SLOT = 5000;
const int TAG_ITEM_CTP_CTOT = 5001;
const int TAG_ITEM_NAT_STATUS = 5002;
const int TAG_ITEM_NAT_NAT = 5003;
const int TAG_ITEM_NAT_FIX = 5004;
const int TAG_ITEM_NAT_LEVEL = 5005;
const int TAG_ITEM_NAT_MACH = 5006;
const int TAG_ITEM_NAT_ESTTIME = 5007;
const int TAG_ITEM_NAT_CLR = 5008;
const int TAG_ITEM_NAT_EXTRA = 5009;
SituPlugin::SituPlugin()
: EuroScopePlugIn::CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE,
"VATCAN Bookings",
"1.1.6-2022wb",
"VATCAN",
"Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)")
{
RegisterTagItemType("Slot", TAG_ITEM_CTP_SLOT);
RegisterTagItemType("CTOT", TAG_ITEM_CTP_CTOT);
RegisterTagItemType("status", TAG_ITEM_NAT_STATUS);
RegisterTagItemType("nat", TAG_ITEM_NAT_NAT);
RegisterTagItemType("fix", TAG_ITEM_NAT_FIX);
RegisterTagItemType("level", TAG_ITEM_NAT_LEVEL);
RegisterTagItemType("mach", TAG_ITEM_NAT_MACH);
RegisterTagItemType("estimating_time", TAG_ITEM_NAT_ESTTIME);
RegisterTagItemType("clearance_issued", TAG_ITEM_NAT_CLR);
RegisterTagItemType("extra_info", TAG_ITEM_NAT_EXTRA);
CSiTRadar::eventCode = "Enter Code";
try {
std::ifstream settings_file(".\\vatcan_bookings.json");
if (settings_file.is_open()) {
json j = json::parse(settings_file);
CSiTRadar::eventCode = j["evtCode"];
CDataHandler::tagLabel = j["evtLabel"];
}
else {
CSiTRadar::eventCode = "Enter Code";
CDataHandler::tagLabel = "EVT";
}
}
catch (std::ifstream::failure e) {
};
}
SituPlugin::~SituPlugin()
{
}
EuroScopePlugIn::CRadarScreen* SituPlugin::OnRadarScreenCreated(const char* sDisplayName, bool NeedRadarContent, bool GeoReferenced, bool CanBeSaved, bool CanBeCreated)
{
return new CSiTRadar;
}
void SituPlugin::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan,
EuroScopePlugIn::CRadarTarget RadarTarget,
int ItemCode,
int TagData,
char sItemString[16],
int* pColorCode,
COLORREF* pRGB,
double* pFontSize) {
if (ItemCode == TAG_ITEM_CTP_SLOT) {
if (CSiTRadar::mAcData[FlightPlan.GetCallsign()].hasCTP) {
strcpy_s(sItemString, 16,"X");
}
else {
strcpy_s(sItemString, 16, "");
}
}
if (ItemCode == TAG_ITEM_CTP_CTOT) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].slotTime.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_STATUS) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_STATUS.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_NAT) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_NAT.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_FIX) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_FIX.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_LEVEL) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_LEVEL.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_MACH) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_MACH.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_ESTTIME) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_ESTTIME.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_CLR) {
string clearedTime;
if (CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_CLR.length() > 16) {
clearedTime = CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_CLR.substr(11, 5);
}
strncpy_s(sItemString, 16, clearedTime.c_str(), 15);
}
if (ItemCode == TAG_ITEM_NAT_EXTRA) {
strncpy_s(sItemString, 16, CSiTRadar::mAcData[FlightPlan.GetCallsign()].TAG_ITEM_NAT_EXTRA.c_str(), 15);
}
}