void Profile::Load(const ProfileMap &map, unsigned i, AirspaceClassRendererSettings &settings) { char name[64]; MakeAirspaceSettingName(name, "AirspaceDisplay", i); if (!map.Get(name, settings.display)) { // Load setting from legacy key-value pair MakeAirspaceSettingName(name, "AirspaceMode", i); unsigned value; if (map.Get(name, value)) settings.display = (value & 0x1) != 0; } #ifdef HAVE_HATCHED_BRUSH MakeAirspaceSettingName(name, "Brush", i); map.Get(name, settings.brush); if (settings.brush >= ARRAY_SIZE(AirspaceLook::brushes)) settings.brush = 0; #endif MakeAirspaceSettingName(name, "AirspaceBorderColor", i); if (!map.GetColor(name, settings.border_color)) GetAirspaceColor(map, i, settings.border_color); MakeAirspaceSettingName(name, "AirspaceFillColor", i); if (!map.GetColor(name, settings.fill_color)) GetAirspaceColor(map, i, settings.fill_color); MakeAirspaceSettingName(name, "AirspaceBorderWidth", i); map.Get(name, settings.border_width); MakeAirspaceSettingName(name, "AirspaceFillMode", i); map.GetEnum(name, settings.fill_mode); }
/** * This function and the "ColourXX" profile keys are deprecated and * are only used as a fallback for old profiles. * * @see Load(unsigned, AirspaceClassRendererSettings &) */ static bool GetAirspaceColor(const ProfileMap &map, unsigned i, RGB8Color &color) { char name[64]; MakeAirspaceSettingName(name, "Colour", i); // Try to load the hex color directly if (map.GetColor(name, color)) return true; // Try to load an indexed preset color (legacy, < 6.3) unsigned index; if (!map.Get(name, index)) return false; // Adjust index if the user has configured a preset color out of range if (index >= ARRAY_SIZE(AirspaceLook::preset_colors)) index = 0; // Assign configured preset color color = AirspaceLook::preset_colors[index]; return true; }