allow more tag entries to customize the views
This commit is contained in:
@@ -61,7 +61,10 @@ PlugIn::PlugIn() :
|
||||
m_playbackValid(false) {
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
this->RegisterTagItemType("ETA", static_cast<int>(PlugIn::TagItemElement::EstimatedTimeOfArrival));
|
||||
this->RegisterTagItemType("PTA", static_cast<int>(PlugIn::TagItemElement::PlannedTimeOfArrival));
|
||||
this->RegisterTagItemType("Delta time", static_cast<int>(PlugIn::TagItemElement::DeltaTime));
|
||||
this->RegisterTagItemType("Fixed plan indicator", static_cast<int>(PlugIn::TagItemElement::FixedPlanIndicator));
|
||||
this->RegisterTagItemFunction("Force planning", static_cast<int>(PlugIn::TagItemFunction::ForceToBackendMenu));
|
||||
|
||||
this->DisplayUserMessage(PLUGIN_NAME, "INFO", (std::string("Loaded ") + PLUGIN_NAME + " " + PLUGIN_VERSION).c_str(), true, true, false, false, false);
|
||||
@@ -444,44 +447,64 @@ void PlugIn::OnGetTagItem(EuroScopePlugIn::CFlightPlan flightPlan, EuroScopePlug
|
||||
this->m_updateQueueLock.lock();
|
||||
|
||||
/* check if the inbound is forced */
|
||||
const auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||
forced = this->m_forcedToBackendCallsigns.cend() != cIt;
|
||||
if (0 != this->m_forcedToBackendCallsigns.size()) {
|
||||
const auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||
forced = this->m_forcedToBackendCallsigns.cend() != cIt;
|
||||
}
|
||||
|
||||
/* check if the inbound is expected to be planned */
|
||||
planExpected = this->m_updateQueue.cend() != this->m_updateQueue.find(destination);
|
||||
|
||||
this->m_updateQueueLock.unlock();
|
||||
|
||||
if (TagItemElement::DeltaTime == static_cast<TagItemElement>(itemCode)) {
|
||||
if (true == this->m_compatible) {
|
||||
std::lock_guard guard(this->m_inboundsQueueLock);
|
||||
auto it = this->m_inbounds.find(callsign);
|
||||
std::lock_guard guard(this->m_inboundsQueueLock);
|
||||
auto it = this->m_inbounds.find(callsign);
|
||||
|
||||
/* inbound expected, but not available */
|
||||
if (this->m_inbounds.cend() == it && (true == forced || true == planExpected)) {
|
||||
std::strcpy(itemString, "* ??:??");
|
||||
}
|
||||
/* inbound is available */
|
||||
else if (this->m_inbounds.cend() != it) {
|
||||
const auto ttl = static_cast<int>(std::roundf(it->second.timeToLose().convert(second)));
|
||||
const auto minutes = ttl / 60;
|
||||
const auto seconds = std::abs(ttl) % 60;
|
||||
|
||||
std::stringstream stream;
|
||||
stream << (true == it->second.fixedPlan() ? "" : "* ") << std::setw(2) << std::setfill('0') << minutes << ":"
|
||||
<< std::setw(2) << std::setfill('0') << seconds;
|
||||
std::strcpy(itemString, stream.str().c_str());
|
||||
}
|
||||
else {
|
||||
gsl::at(tagString, 0) = '\0';
|
||||
}
|
||||
std::string message;
|
||||
switch (static_cast<TagItemElement>(itemCode)) {
|
||||
case TagItemElement::EstimatedTimeOfArrival:
|
||||
{
|
||||
if (this->m_inbounds.cend() != it)
|
||||
message = UtcTime::timeToString(it->second.eta(), "%H:%M");
|
||||
else if (true == forced || true == planExpected)
|
||||
message = "??:??";
|
||||
break;
|
||||
}
|
||||
case TagItemElement::PlannedTimeOfArrival:
|
||||
{
|
||||
if (this->m_inbounds.cend() != it)
|
||||
message = UtcTime::timeToString(it->second.pta(), "%H:%M");
|
||||
else if (true == forced || true == planExpected)
|
||||
message = "??:??";
|
||||
break;
|
||||
}
|
||||
case TagItemElement::DeltaTime:
|
||||
{
|
||||
if (this->m_inbounds.cend() != it) {
|
||||
const auto ttl = static_cast<int>(std::roundf(it->second.timeToLose().convert(second)));
|
||||
std::stringstream stream;
|
||||
stream << ttl;
|
||||
message = stream.str();
|
||||
}
|
||||
else {
|
||||
std::strcpy(itemString, "N/A");
|
||||
else if (true == forced || true == planExpected) {
|
||||
message = "??";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TagItemElement::FixedPlanIndicator:
|
||||
if (this->m_inbounds.cend() != it && false == it->second.fixedPlan())
|
||||
message = "*";
|
||||
else if (this->m_inbounds.cend() == it && (true == forced || true == planExpected))
|
||||
message = "*";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
*colorCode = EuroScopePlugIn::TAG_COLOR_DEFAULT;
|
||||
if (0 != message.length()) {
|
||||
std::strcpy(itemString, message.c_str());
|
||||
*colorCode = EuroScopePlugIn::TAG_COLOR_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
void PlugIn::OnFunctionCall(int functionId, const char* itemString, POINT pt, RECT area) {
|
||||
|
||||
@@ -42,7 +42,10 @@ namespace aman {
|
||||
|
||||
private:
|
||||
enum class TagItemElement {
|
||||
DeltaTime = 0
|
||||
EstimatedTimeOfArrival = 0,
|
||||
PlannedTimeOfArrival = 1,
|
||||
DeltaTime = 2,
|
||||
FixedPlanIndicator = 3
|
||||
};
|
||||
|
||||
void validateBackendData();
|
||||
|
||||
Reference in New Issue
Block a user