forked from VATSIM-UK/uk-controller-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandColourConfiguration.cpp
More file actions
59 lines (47 loc) · 2.17 KB
/
Copy pathStandColourConfiguration.cpp
File metadata and controls
59 lines (47 loc) · 2.17 KB
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
#include "StandColourConfiguration.h"
#include "StandAssignmentSource.h"
#include "euroscope/UserSetting.h"
#include "helper/HelperFunctions.h"
#include "log/LoggerFunctions.h"
#include <array>
namespace UKControllerPlugin::Stands {
StandColourConfiguration::StandColourConfiguration(UKControllerPlugin::Euroscope::UserSetting& setting)
: StandColourConfiguration(&setting)
{
}
StandColourConfiguration::StandColourConfiguration() : StandColourConfiguration(nullptr)
{
}
StandColourConfiguration::StandColourConfiguration(UKControllerPlugin::Euroscope::UserSetting* userSetting)
: userSetting(userSetting), sourceColours(
{{StandAssignment::Source::User, DEFAULT_USER_COLOUR},
{StandAssignment::Source::ReservationAllocator, DEFAULT_RESERVATION_COLOUR},
{StandAssignment::Source::VaaAllocator, DEFAULT_VAA_COLOUR},
{StandAssignment::Source::SystemAuto, DEFAULT_SYSTEM_COLOUR}})
{
LoadFromUserSettings();
}
auto StandColourConfiguration::GetColourForSource(StandAssignment::Source source) const -> COLORREF
{
if (auto it = sourceColours.find(source); it != sourceColours.cend()) {
return it->second;
}
return DEFAULT_COLOUR;
}
void StandColourConfiguration::LoadFromUserSettings()
{
if (!this->userSetting) {
return;
}
using enum UKControllerPlugin::Stands::StandAssignment::Source;
constexpr std::array<StandAssignment::Source, 5> sourceColourDefaults = {
{Unknown, User, ReservationAllocator, VaaAllocator, SystemAuto}};
for (const auto source : sourceColourDefaults) {
const std::string key = std::string(SETTING_PREFIX) + std::string(StandAssignment::ToString(source));
if (this->userSetting->HasEntry(key)) {
this->sourceColours[source] = this->userSetting->GetColourEntry(key);
}
}
LogInfo("Loaded stand assignment source colours from UserSettings");
}
} // namespace UKControllerPlugin::Stands