addVenue method

String addVenue(
  1. DomeManifest manifest, {
  2. Map<String, Uint8List> files = const {},
  3. bool makeDefault = false,
})

Adds (or replaces) the venue of manifest (kind venue / bundle) with its calibration files; the first venue added becomes default. Returns the venue id.

Implementation

String addVenue(
  DomeManifest manifest, {
  Map<String, Uint8List> files = const {},
  bool makeDefault = false,
}) {
  final j = manifest.toJson();
  const sections = {
    'meta',
    'dome',
    'displays',
    'calibration',
    'audio',
    'compat',
  };
  final body = {
    for (final e in j.entries)
      if (sections.contains(e.key) || e.key.startsWith('x-')) e.key: e.value,
  };
  final id = manifest.meta.id;
  final rec = _VenueRec(body, 1)..files.addAll(files);
  _venues[id] = rec;
  _syncDisplays(rec);
  if (_defaultVenue == null || makeDefault) _defaultVenue = id;
  if (manifest.kind == DomeKind.bundle && manifest.show != null) {
    _shows[id] = _Show({
      'meta': j['meta'],
      'assets': j['assets'] ?? const <Object?>[],
      'show': j['show'],
    }, 1);
  }
  return id;
}