Skip to content

Commit

Permalink
feat(wake): Departure wake interval calculator (#417)
Browse files Browse the repository at this point in the history
* Add command to assign holds

* Docs

* Add callsign selection helpers

* Callsign provider for add to hold

* Make factory an object

* Forward declarations in holds

* Update display to handle right clicks

* Display title bar a11y

* Hook everything up

* Forward declarations

* Include order

* Docs

* Style

* Forward declarations

* Style

* Add wake category and scheme models

* Load categories from json

* Load schemes from json

* Scheme collection

* Add aircraft types via dependency

* Map flightplan to aircraft type

* Add wake mapper

* Implement new mapper

* Remove old code

* Style

* Get departure intervals from wake categories

* Make graphics easier to work with

* Graphics font manager

* Styles

* Basic calculator layout

* Start implementing finer details of calculator

* List abstraction

* Move callsign selection list to new list

* Tinkering

* Tests

* Allow ground and delivery to use

* Put wake list in place

* Intermediate clickspot

* Tests

* Display intervals

* Load position from ASR

* Position

* Generic toggle

* Menu toggle

* Store visibility on ASR

* Style
  • Loading branch information
AndyTWF committed Feb 5, 2022
1 parent ad0255f commit 92c6737
Show file tree
Hide file tree
Showing 84 changed files with 2,794 additions and 405 deletions.
20 changes: 16 additions & 4 deletions src/plugin/CMakeLists.txt
Expand Up @@ -10,7 +10,6 @@ set(resource
source_group("resource" FILES ${resource})

set(src__aircraft
aircraft/CallsignSelectionListInterface.h
aircraft/CallsignSelectionProviderInterface.h
aircraft/CallsignSelectionList.cpp aircraft/CallsignSelectionList.h
aircraft/CallsignSelectionListFactory.cpp aircraft/CallsignSelectionListFactory.h
Expand Down Expand Up @@ -244,7 +243,7 @@ set(src__graphics
"graphics/GdiGraphicsWrapper.cpp"
"graphics/GdiGraphicsWrapper.h"
"graphics/GdiplusBrushes.h"
)
graphics/FontManager.cpp graphics/FontManager.h graphics/StringFormatManager.cpp graphics/StringFormatManager.h)
source_group("src\\graphics" FILES ${src__graphics})

set(src__handoff
Expand Down Expand Up @@ -449,6 +448,16 @@ set(src__intention
)
source_group("src\\intention" FILES ${src__intention})

set(src__list
list/ListItemProviderInterface.h
list/PopupListInterface.h
list/PopupList.cpp list/PopupList.h
list/PopupListFactory.cpp list/PopupListFactory.h
list/ListItem.h
list/ListItemCheckedStatus.h
list/PopupListFactoryBootstrap.cpp list/PopupListFactoryBootstrap.h)
source_group("src\\list" FILES ${src__list})

set(src__login
"login/Login.cpp"
"login/Login.h"
Expand Down Expand Up @@ -706,7 +715,7 @@ set(src__radarscreen
"radarscreen/ScreenControlsBootstrap.h"
"radarscreen/UKRadarScreen.cpp"
"radarscreen/UKRadarScreen.h"
radarscreen/RadarRenderableInterface.cpp radarscreen/ConfigurableDisplayInterface.cpp)
radarscreen/RadarRenderableInterface.cpp radarscreen/ConfigurableDisplayInterface.cpp radarscreen/MenuToggleableDisplayInterface.h radarscreen/ToggleDisplayFromMenu.cpp radarscreen/ToggleDisplayFromMenu.h radarscreen/MenuToggleableDisplayFactory.cpp radarscreen/MenuToggleableDisplayFactory.h)
source_group("src\\radarscreen" FILES ${src__radarscreen})

set(src__regional
Expand Down Expand Up @@ -889,7 +898,9 @@ set(src__wake
wake/WakeSchemeCollectionFactory.cpp
wake/WakeSchemeCollectionFactory.h
wake/WakeCategoryMapperInterface.h
wake/FlightplanWakeCategoryMapper.cpp wake/FlightplanWakeCategoryMapper.h)
wake/FlightplanWakeCategoryMapper.cpp wake/FlightplanWakeCategoryMapper.h
wake/WakeCalculatorDisplay.cpp wake/WakeCalculatorDisplay.h
wake/WakeCalculatorOptions.cpp wake/WakeCalculatorOptions.h wake/LeadWakeCallsignProvider.cpp wake/LeadWakeCallsignProvider.h wake/FollowingWakeCallsignProvider.cpp wake/FollowingWakeCallsignProvider.h wake/WakeSchemeProvider.cpp wake/WakeSchemeProvider.h wake/WakeIntervalFormatter.cpp wake/WakeIntervalFormatter.h)
source_group("src\\wake" FILES ${src__wake})

set(ALL_FILES
Expand Down Expand Up @@ -918,6 +929,7 @@ set(ALL_FILES
${src__initialheading}
${src__integration}
${src__intention}
${src__list}
${src__login}
${src__message}
${src__metar}
Expand Down
44 changes: 19 additions & 25 deletions src/plugin/aircraft/CallsignSelectionList.cpp
@@ -1,42 +1,36 @@
#include "CallsignSelectionList.h"
#include "CallsignSelectionProviderInterface.h"
#include "euroscope/EuroscopePluginLoopbackInterface.h"
#include "plugin/PopupMenuItem.h"
#include "list/ListItem.h"

namespace UKControllerPlugin::Aircraft {

CallsignSelectionList::CallsignSelectionList(
std::shared_ptr<CallsignSelectionProviderInterface> callsignProvider,
Euroscope::EuroscopePluginLoopbackInterface& plugin,
int callbackFunctionId)
: callsignProvider(std::move(callsignProvider)), plugin(plugin), callbackFunctionId(callbackFunctionId)
CallsignSelectionList::CallsignSelectionList(std::shared_ptr<CallsignSelectionProviderInterface> callsignProvider)
: callsignProvider(std::move(callsignProvider))
{
}

void CallsignSelectionList::TriggerList(const POINT& location)
int CallsignSelectionList::ListColumns()
{
const auto callsigns = this->callsignProvider->GetCallsigns();
if (callsigns.empty()) {
return;
}

plugin.TriggerPopupList(RECT{location.x, location.y, location.x + 50, location.y + 100}, "Select Aircraft", 1);
return 1;
}

Plugin::PopupMenuItem menuItem;
menuItem.secondValue = "";
menuItem.callbackFunctionId = callbackFunctionId;
menuItem.fixedPosition = false;
menuItem.disabled = false;
menuItem.checked = EuroScopePlugIn::POPUP_ELEMENT_NO_CHECKBOX;
std::string CallsignSelectionList::ListName()
{
return "Select Aircraft";
}

for (const auto& callsign : callsigns) {
menuItem.firstValue = callsign;
plugin.AddItemToPopupList(menuItem);
std::list<std::shared_ptr<List::ListItem>> CallsignSelectionList::ListItems()
{
std::list<std::shared_ptr<List::ListItem>> items;
for (const auto& callsign : this->callsignProvider->GetCallsigns()) {
items.push_back(
std::make_shared<List::ListItem>(callsign, "", false, false, List::ListItemCheckedStatus::NoCheckbox));
}
return items;
}

void CallsignSelectionList::CallsignSelected(const std::string& callsign)
void CallsignSelectionList::ItemSelected(const std::string& item)
{
callsignProvider->CallsignSelected(callsign);
this->callsignProvider->CallsignSelected(item);
}
} // namespace UKControllerPlugin::Aircraft
21 changes: 7 additions & 14 deletions src/plugin/aircraft/CallsignSelectionList.h
@@ -1,5 +1,5 @@
#pragma once
#include "CallsignSelectionListInterface.h"
#include "list/ListItemProviderInterface.h"

namespace UKControllerPlugin::Euroscope {
class EuroscopePluginLoopbackInterface;
Expand All @@ -11,25 +11,18 @@ namespace UKControllerPlugin::Aircraft {
/**
* Implements a callsign selection list.
*/
class CallsignSelectionList : public CallsignSelectionListInterface
class CallsignSelectionList : public List::ListItemProviderInterface
{
public:
CallsignSelectionList(
std::shared_ptr<CallsignSelectionProviderInterface> callsignProvider,
Euroscope::EuroscopePluginLoopbackInterface& plugin,
int callbackFunctionId);
CallsignSelectionList(std::shared_ptr<CallsignSelectionProviderInterface> callsignProvider);
~CallsignSelectionList() = default;
void TriggerList(const POINT& location) override;
void CallsignSelected(const std::string& callsign);
auto ListColumns() -> int override;
auto ListName() -> std::string override;
auto ListItems() -> std::list<std::shared_ptr<List::ListItem>> override;
void ItemSelected(const std::string& item) override;

private:
// Provides the callsigns
std::shared_ptr<CallsignSelectionProviderInterface> callsignProvider;

// The plugin for triggering lists
Euroscope::EuroscopePluginLoopbackInterface& plugin;

// The callback function
int callbackFunctionId;
};
} // namespace UKControllerPlugin::Aircraft
24 changes: 5 additions & 19 deletions src/plugin/aircraft/CallsignSelectionListFactory.cpp
@@ -1,33 +1,19 @@
#include "CallsignSelectionList.h"
#include "CallsignSelectionListFactory.h"
#include "CallsignSelectionProviderInterface.h"
#include "euroscope/CallbackFunction.h"
#include "euroscope/EuroscopePluginLoopbackInterface.h"
#include "plugin/FunctionCallEventHandler.h"
#include "list/PopupListFactory.h"

namespace UKControllerPlugin::Aircraft {

CallsignSelectionListFactory::CallsignSelectionListFactory(
Plugin::FunctionCallEventHandler& functionHandler, Euroscope::EuroscopePluginLoopbackInterface& plugin)
: functionHandler(functionHandler), plugin(plugin)
CallsignSelectionListFactory::CallsignSelectionListFactory(List::PopupListFactory& listFactory)
: listFactory(listFactory)
{
}

auto CallsignSelectionListFactory::Create(
std::shared_ptr<CallsignSelectionProviderInterface> provider, const std::string& description) const
-> std::shared_ptr<CallsignSelectionList>
-> std::shared_ptr<List::PopupListInterface>
{
int callbackId = functionHandler.ReserveNextDynamicFunctionId();
auto selectionList = std::make_shared<CallsignSelectionList>(std::move(provider), plugin, callbackId);

Euroscope::CallbackFunction callback(
callbackId,
description,
[selectionList](int functionId, const std::string& subject, RECT screenObjectArea) {
selectionList->CallsignSelected(subject);
});
functionHandler.RegisterFunctionCall(callback);

return selectionList;
return listFactory.Create(std::make_shared<CallsignSelectionList>(provider), description);
}
} // namespace UKControllerPlugin::Aircraft
24 changes: 8 additions & 16 deletions src/plugin/aircraft/CallsignSelectionListFactory.h
@@ -1,13 +1,9 @@
#pragma once

namespace UKControllerPlugin {
namespace Euroscope {
class EuroscopePluginLoopbackInterface;
} // namespace Euroscope
namespace Plugin {
class FunctionCallEventHandler;
} // namespace Plugin
} // namespace UKControllerPlugin
namespace UKControllerPlugin::List {
class PopupListInterface;
class PopupListFactory;
} // namespace UKControllerPlugin::List

namespace UKControllerPlugin::Aircraft {
class CallsignSelectionProviderInterface;
Expand All @@ -16,17 +12,13 @@ namespace UKControllerPlugin::Aircraft {
class CallsignSelectionListFactory
{
public:
CallsignSelectionListFactory(
Plugin::FunctionCallEventHandler& functionHandler, Euroscope::EuroscopePluginLoopbackInterface& plugin);
CallsignSelectionListFactory(List::PopupListFactory& listFactory);
[[nodiscard]] auto
Create(std::shared_ptr<CallsignSelectionProviderInterface> provider, const std::string& description) const
-> std::shared_ptr<CallsignSelectionList>;
-> std::shared_ptr<List::PopupListInterface>;

private:
// For registering the callback function
Plugin::FunctionCallEventHandler& functionHandler;

// To pass to the list
Euroscope::EuroscopePluginLoopbackInterface& plugin;
// For creating lists
List::PopupListFactory& listFactory;
};
} // namespace UKControllerPlugin::Aircraft
Expand Up @@ -7,6 +7,6 @@ namespace UKControllerPlugin::Aircraft {
void BootstrapPlugin(Bootstrap::PersistenceContainer& container)
{
container.callsignSelectionListFactory =
std::make_unique<CallsignSelectionListFactory>(*container.pluginFunctionHandlers, *container.plugin);
std::make_unique<CallsignSelectionListFactory>(*container.popupListFactory);
}
} // namespace UKControllerPlugin::Aircraft
14 changes: 0 additions & 14 deletions src/plugin/aircraft/CallsignSelectionListInterface.h

This file was deleted.

2 changes: 2 additions & 0 deletions src/plugin/bootstrap/InitialisePlugin.cpp
Expand Up @@ -25,6 +25,7 @@
#include "initialheading/InitialHeadingModule.h"
#include "integration/IntegrationModule.h"
#include "intention/IntentionCodeModule.h"
#include "list/PopupListFactoryBootstrap.h"
#include "log/LoggerBootstrap.h"
#include "login/LoginModule.h"
#include "message/UserMessagerBootstrap.h"
Expand Down Expand Up @@ -186,6 +187,7 @@ namespace UKControllerPlugin {
}

Integration::BootstrapPlugin(*this->container, duplicatePlugin->Duplicate(), winsockInitialised);
List::BootstrapPlugin(*this->container);
Aircraft::BootstrapPlugin(*this->container);

// Boostrap all the modules at a plugin level
Expand Down
1 change: 1 addition & 0 deletions src/plugin/bootstrap/PersistenceContainer.cpp
Expand Up @@ -36,6 +36,7 @@
#include "intention/IntentionCodeCache.h"
#include "intention/IntentionCodeGenerator.h"
#include "intention/SectorExitRepository.h"
#include "list/PopupListFactory.h"
#include "login/Login.h"
#include "message/UserMessager.h"
#include "metar/MetarEventHandlerCollection.h"
Expand Down
4 changes: 4 additions & 0 deletions src/plugin/bootstrap/PersistenceContainer.h
Expand Up @@ -72,6 +72,9 @@ namespace UKControllerPlugin {
namespace InitialAltitude {
class InitialAltitudeEventHandler;
} // namespace InitialAltitude
namespace List {
class PopupListFactory;
} // namespace List
namespace Metar {
class MetarEventHandlerCollection;
} // namespace Metar
Expand Down Expand Up @@ -244,5 +247,6 @@ namespace UKControllerPlugin::Bootstrap {

// Some factories
std::unique_ptr<Aircraft::CallsignSelectionListFactory> callsignSelectionListFactory;
std::unique_ptr<List::PopupListFactory> popupListFactory;
};
} // namespace UKControllerPlugin::Bootstrap
20 changes: 18 additions & 2 deletions src/plugin/components/TitleBar.cpp
@@ -1,7 +1,7 @@
#include "components/TitleBar.h"
#include "ClickableArea.h"
#include "TitleBar.h"
#include "euroscope/EuroscopeRadarLoopbackInterface.h"
#include "graphics/GdiGraphicsInterface.h"
#include "components/ClickableArea.h"

namespace UKControllerPlugin::Components {
std::shared_ptr<TitleBar> TitleBar::Create(std::wstring title, Gdiplus::Rect area)
Expand Down Expand Up @@ -71,4 +71,20 @@ namespace UKControllerPlugin::Components {
TitleBar::TitleBar(std::wstring title, Gdiplus::Rect area) : title(std::move(title)), area(area)
{
}

std::shared_ptr<TitleBar> TitleBar::WithDefaultBackgroundBrush()
{
return this->WithBackgroundBrush(std::make_shared<Gdiplus::SolidBrush>(Gdiplus::Color(130, 50, 154)));
}

std::shared_ptr<TitleBar> TitleBar::WithDefaultTextBrush()
{
return this->WithTextBrush(std::make_shared<Gdiplus::SolidBrush>(Gdiplus::Color(227, 227, 227)));
}

std::shared_ptr<TitleBar> TitleBar::WithDefaultBorder()
{
return this->WithBorder(std::make_shared<Gdiplus::Pen>(Gdiplus::Color(255, 255, 255)));
}

} // namespace UKControllerPlugin::Components
3 changes: 3 additions & 0 deletions src/plugin/components/TitleBar.h
Expand Up @@ -18,9 +18,12 @@ namespace UKControllerPlugin::Components {
{
public:
static std::shared_ptr<TitleBar> Create(std::wstring title, Gdiplus::Rect area);
std::shared_ptr<TitleBar> WithDefaultBackgroundBrush();
std::shared_ptr<TitleBar> WithBackgroundBrush(std::shared_ptr<Gdiplus::Brush> brush);
std::shared_ptr<TitleBar> WithTextBrush(std::shared_ptr<Gdiplus::Brush> brush);
std::shared_ptr<TitleBar> WithDefaultTextBrush();
std::shared_ptr<TitleBar> WithBorder(std::shared_ptr<Gdiplus::Pen> pen);
std::shared_ptr<TitleBar> WithDefaultBorder();
std::shared_ptr<TitleBar> WithDrag(int screenObjectId);
std::shared_ptr<TitleBar> WithPosition(Gdiplus::Rect area);
std::shared_ptr<TitleBar> WithTitle(std::wstring title);
Expand Down
33 changes: 33 additions & 0 deletions src/plugin/graphics/FontManager.cpp
@@ -0,0 +1,33 @@
#include "FontManager.h"

namespace UKControllerPlugin::Graphics {

auto FontManager::Instance() -> FontManager&
{
static std::unique_ptr<FontManager> instance;
if (instance == nullptr) {
instance =
std::unique_ptr<FontManager>(new FontManager(std::make_unique<Gdiplus::FontFamily>(L"EuroScope")));
}

return *instance;
}

auto FontManager::GetDefault() -> const Gdiplus::Font&
{
return this->Get(9);
}

auto FontManager::Get(int size) -> const Gdiplus::Font&
{
if (this->fonts.count(size) == 0) {
this->fonts[size] = std::make_shared<Gdiplus::Font>(family.get(), size);
}

return *this->fonts.at(size);
}

FontManager::FontManager(std::unique_ptr<Gdiplus::FontFamily> family) : family(std::move(family))
{
}
} // namespace UKControllerPlugin::Graphics

0 comments on commit 92c6737

Please sign in to comment.