| 7 | namespace Star { |
| 8 | |
| 9 | StagehandDatabase::StagehandDatabase() { |
| 10 | auto assets = Root::singleton().assets(); |
| 11 | auto& files = assets->scanExtension("stagehand"); |
| 12 | assets->queueJsons(files); |
| 13 | for (auto& file : files) { |
| 14 | try { |
| 15 | auto config = assets->json(file); |
| 16 | |
| 17 | String typeName = config.getString("type"); |
| 18 | |
| 19 | if (m_stagehandTypes.contains(typeName)) |
| 20 | throw StagehandDatabaseException(strf("Repeat stagehand type name '{}'", typeName)); |
| 21 | |
| 22 | m_stagehandTypes[typeName] = config; |
| 23 | |
| 24 | } catch (StarException const& e) { |
| 25 | throw StagehandDatabaseException(strf("Error loading stagehand type '{}'", file), e); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | StagehandPtr StagehandDatabase::createStagehand(String const& stagehandType, Json const& extraConfig) const { |
| 31 | auto finalConfig = jsonMerge(m_stagehandTypes.get(stagehandType), extraConfig); |