add a menu
This commit is contained in:
@@ -61,7 +61,7 @@ PlugIn::PlugIn() :
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
this->RegisterTagItemType("Delta time", static_cast<int>(PlugIn::TagItemElement::DeltaTime));
|
||||
this->RegisterTagItemFunction("Force planning", static_cast<int>(PlugIn::TagItemFunction::ForceToBackend));
|
||||
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);
|
||||
|
||||
@@ -498,17 +498,37 @@ void PlugIn::OnFunctionCall(int functionId, const char* itemString, POINT pt, RE
|
||||
std::string callsign(radarTarget.GetCallsign());
|
||||
|
||||
switch (static_cast<PlugIn::TagItemFunction>(functionId)) {
|
||||
case PlugIn::TagItemFunction::ForceToBackend:
|
||||
case PlugIn::TagItemFunction::ForceToBackendMenu:
|
||||
{
|
||||
this->OpenPopupList(area, "AMAN", 1);
|
||||
bool inList = this->m_forcedToBackendCallsigns.cend() != std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||
this->AddPopupListElement("Add to AMAN", "", static_cast<int>(PlugIn::TagItemFunction::ForceToBackendSelect),
|
||||
false, EuroScopePlugIn::POPUP_ELEMENT_NO_CHECKBOX, true == inList);
|
||||
this->AddPopupListElement("Remove from AMAN", "", static_cast<int>(PlugIn::TagItemFunction::ForceToBackendSelect),
|
||||
false, EuroScopePlugIn::POPUP_ELEMENT_NO_CHECKBOX, false == inList);
|
||||
break;
|
||||
}
|
||||
case PlugIn::TagItemFunction::ForceToBackendSelect:
|
||||
{
|
||||
std::string destination(radarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetDestination());
|
||||
std::transform(destination.begin(), destination.end(), destination.begin(), ::toupper);
|
||||
|
||||
std::lock_guard guard(this->m_updateQueueLock);
|
||||
auto it = this->m_updateQueue.find(destination);
|
||||
if (this->m_updateQueue.end() != it) {
|
||||
auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||
if (this->m_forcedToBackendCallsigns.cend() == cIt)
|
||||
this->m_forcedToBackendCallsigns.push_back(callsign);
|
||||
|
||||
if (0 == std::strcmp(itemString, "Add to AMAN")) {
|
||||
if (this->m_updateQueue.end() != it) {
|
||||
auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||
if (this->m_forcedToBackendCallsigns.cend() == cIt)
|
||||
this->m_forcedToBackendCallsigns.push_back(callsign);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->m_updateQueue.end() != it) {
|
||||
auto cIt = std::find(this->m_forcedToBackendCallsigns.begin(), this->m_forcedToBackendCallsigns.end(), callsign);
|
||||
if (this->m_forcedToBackendCallsigns.cend() != cIt)
|
||||
this->m_forcedToBackendCallsigns.erase(cIt);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace aman {
|
||||
* @brief Defines the different internal and external tag functions
|
||||
*/
|
||||
enum class TagItemFunction {
|
||||
ForceToBackend = 0,
|
||||
ForceToBackendMenu = 0, /**< Opens the menu to force tracks */
|
||||
ForceToBackendSelect = 1 /**< Reacts on controller selection */
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user