Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
275 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "SquawkAssignmentMenu.h" | ||
#include "SquawkGeneratorInterface.h" | ||
#include "controller/ActiveCallsign.h" | ||
#include "controller/ActiveCallsignCollection.h" | ||
#include "euroscope/EuroScopeCFlightPlanInterface.h" | ||
#include "euroscope/EuroscopePluginLoopbackInterface.h" | ||
#include "euroscope/EuroscopeRadarLoopbackInterface.h" | ||
|
||
namespace UKControllerPlugin::Squawk { | ||
|
||
SquawkAssignmentMenu::SquawkAssignmentMenu( | ||
int callbackId, | ||
SquawkGeneratorInterface& squawkGenerator, | ||
Controller::ActiveCallsignCollection& activeCallsigns, | ||
Euroscope::EuroscopePluginLoopbackInterface& plugin) | ||
: callbackId(callbackId), squawkGenerator(squawkGenerator), activeCallsigns(activeCallsigns), plugin(plugin) | ||
{ | ||
} | ||
|
||
void SquawkAssignmentMenu::DisplaySquawkAssignmentMenu( | ||
Euroscope::EuroScopeCFlightPlanInterface& flightplan, const POINT& mousePos) | ||
{ | ||
// If the user doesn't have a callsign or the callsign isn't active, don't show the menu | ||
if (!this->activeCallsigns.UserHasCallsign()) { | ||
return; | ||
} | ||
|
||
// Trigger the menu | ||
plugin.TriggerPopupList( | ||
{mousePos.x, mousePos.y, mousePos.x + MENU_WIDTH, mousePos.y + MENU_HEIGHT}, "Assign Squawk", 1); | ||
|
||
// Add the options | ||
this->AddMenuOptions(); | ||
} | ||
|
||
void SquawkAssignmentMenu::AddMenuOptions() | ||
{ | ||
Plugin::PopupMenuItem item; | ||
item.firstValue = ""; | ||
item.secondValue = ""; | ||
item.callbackFunctionId = this->callbackId; | ||
item.checked = EuroScopePlugIn::POPUP_ELEMENT_NO_CHECKBOX; | ||
item.disabled = false; | ||
item.fixedPosition = false; | ||
this->plugin.AddItemToPopupList(item); | ||
|
||
for (const auto& menuItem : this->squawkOptions) { | ||
item.firstValue = menuItem; | ||
this->plugin.AddItemToPopupList(item); | ||
} | ||
} | ||
|
||
void SquawkAssignmentMenu::MenuOptionSelected( | ||
Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, | ||
const std::string& option, | ||
const POINT& mousePos, | ||
const RECT& tagItemArea) | ||
{ | ||
auto flightplan = this->plugin.GetSelectedFlightplan(); | ||
auto radarTarget = this->plugin.GetSelectedRadarTarget(); | ||
if (!flightplan || !radarTarget) { | ||
LogWarning("No flightplan selected, cant action squawk menu selection"); | ||
return; | ||
} | ||
|
||
if (option == GENERAL_SQUAWK) { | ||
this->squawkGenerator.ForceGeneralSquawkForAircraft(*flightplan, *radarTarget); | ||
return; | ||
} | ||
|
||
if (option == LOCAL_SQUAWK) { | ||
this->squawkGenerator.ForceLocalSquawkForAircraft(*flightplan, *radarTarget); | ||
return; | ||
} | ||
|
||
if (option == CONSPICUITY) { | ||
this->squawkGenerator.DeleteApiSquawkAndSetTo("7000", *flightplan); | ||
return; | ||
} | ||
|
||
if (option == CIRCUIT) { | ||
this->squawkGenerator.DeleteApiSquawkAndSetTo("7010", *flightplan); | ||
return; | ||
} | ||
|
||
if (option == EUROSCOPE) { | ||
radarScreen.ToggleEuroscopeTagFunction( | ||
EuroScopePlugIn::TAG_ITEM_FUNCTION_SQUAWK_POPUP, flightplan->GetCallsign(), mousePos, tagItemArea); | ||
return; | ||
} | ||
} | ||
} // namespace UKControllerPlugin::Squawk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin { | ||
namespace Controller { | ||
class ActiveCallsignCollection; | ||
} // namespace Controller | ||
namespace Euroscope { | ||
class EuroscopePluginLoopbackInterface; | ||
class EuroScopeCFlightPlanInterface; | ||
class EuroscopeRadarLoopbackInterface; | ||
} // namespace Euroscope | ||
} // namespace UKControllerPlugin | ||
|
||
namespace UKControllerPlugin::Squawk { | ||
|
||
class SquawkGeneratorInterface; | ||
|
||
/** | ||
* A popup menu for choosing a squawk code to assign to a flight. | ||
*/ | ||
class SquawkAssignmentMenu | ||
{ | ||
public: | ||
SquawkAssignmentMenu( | ||
int callbackId, | ||
SquawkGeneratorInterface& squawkGenerator, | ||
Controller::ActiveCallsignCollection& activeCallsigns, | ||
Euroscope::EuroscopePluginLoopbackInterface& plugin); | ||
void DisplaySquawkAssignmentMenu(Euroscope::EuroScopeCFlightPlanInterface& flightplan, const POINT& mousePos); | ||
void MenuOptionSelected( | ||
Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, | ||
const std::string& option, | ||
const POINT& mousePos, | ||
const RECT& tagItemArea); | ||
|
||
private: | ||
void AddMenuOptions(); | ||
|
||
// Menu options | ||
const char* GENERAL_SQUAWK = "General"; | ||
const char* LOCAL_SQUAWK = "Local"; | ||
const char* CONSPICUITY = "Conspicuity (7000)"; | ||
const char* CIRCUIT = "Circuit (7010)"; | ||
const char* EUROSCOPE = "Euroscope"; | ||
|
||
std::list<const char*> squawkOptions = {GENERAL_SQUAWK, LOCAL_SQUAWK, CONSPICUITY, CIRCUIT, EUROSCOPE}; | ||
|
||
// Menu sizes | ||
static const int MENU_WIDTH = 200; | ||
static const int MENU_HEIGHT = 200; | ||
|
||
// The callback id to use for when a menu item is clicked | ||
const int callbackId; | ||
|
||
// The squawk generator | ||
SquawkGeneratorInterface& squawkGenerator; | ||
|
||
// Who's active as a controller | ||
Controller::ActiveCallsignCollection& activeCallsigns; | ||
|
||
// The plugin instance, lets us make menus | ||
Euroscope::EuroscopePluginLoopbackInterface& plugin; | ||
}; | ||
|
||
} // namespace UKControllerPlugin::Squawk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin::Euroscope { | ||
class EuroScopeCFlightPlanInterface; | ||
class EuroScopeCRadarTargetInterface; | ||
} // namespace UKControllerPlugin::Euroscope | ||
|
||
namespace UKControllerPlugin::Squawk { | ||
|
||
/* | ||
Makes the relevant API calls to generate a squawk for an aircraft. | ||
*/ | ||
class SquawkGeneratorInterface | ||
{ | ||
public: | ||
virtual ~SquawkGeneratorInterface() = default; | ||
virtual auto DeleteApiSquawkAndSetTo( | ||
const std::string& squawk, UKControllerPlugin::Euroscope::EuroScopeCFlightPlanInterface& flightplan) | ||
-> bool = 0; | ||
virtual auto ForceGeneralSquawkForAircraft( | ||
UKControllerPlugin::Euroscope::EuroScopeCFlightPlanInterface& flightplan, | ||
UKControllerPlugin::Euroscope::EuroScopeCRadarTargetInterface& radarTarget) -> bool = 0; | ||
virtual auto ForceLocalSquawkForAircraft( | ||
UKControllerPlugin::Euroscope::EuroScopeCFlightPlanInterface& flightplan, | ||
UKControllerPlugin::Euroscope::EuroScopeCRadarTargetInterface& radarTarget) -> bool = 0; | ||
}; | ||
} // namespace UKControllerPlugin::Squawk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.