101 std::expected<void, DataError> ResourceRuntime::initialize(
105 std::span<const DataSourceOverride> overrides)
107 if (context.
board != BoardEdition::Usa &&
108 context.
board != BoardEdition::Europe)
111 DataErrorCode::InvalidBoardEdition, {}, std::nullopt,
112 "board edition must be USA or Europe" });
115 if (language ==
nullptr)
118 DataErrorCode::InvalidLanguage, {}, std::nullopt,
119 "language ID must be in the source-defined range 1..10" });
122 auto staged = std::shared_ptr<ResourceSnapshot>(
125 -> std::expected<void, DataError>
127 auto path =
staged->paths_.resolve(definition.legacyPath);
131 error.detail = std::string(definition.legacyPath) +
133 return std::unexpected(std::move(
error));
135 auto archive =
staged->banks_->mount(
139 return std::unexpected(archive.error());
146 auto result = mount(definition);
149 return std::unexpected(result.error());
152 for (
const auto* definition :
153 { &language->text, &language->graphics, &language->dialog })
155 auto result = mount(*definition);
158 return std::unexpected(result.error());
164 if (!overrides.empty())
166 auto layered = LayeredDataSource::create(
staged->data_, overrides);
169 return std::unexpected(
layered.error());
174 auto selected =
staged->language_.select(
180 return std::unexpected(selected.error());
183 std::scoped_lock lock(mutex_);
184 active_ = std::move(
staged);