| 151 | } |
| 152 | |
| 153 | Root::Settings RootLoader::rootSettingsForOptions(Options const& options) const { |
| 154 | try { |
| 155 | String bootConfigFile = options.parameters.value("bootconfig").maybeFirst().value("sbinit.config"); |
| 156 | Json bootConfig = Json::parseJson(File::readFileString(bootConfigFile)); |
| 157 | |
| 158 | Json assetsSettings = jsonMerge( |
| 159 | BaseAssetsSettings, |
| 160 | m_defaults.additionalAssetsSettings, |
| 161 | bootConfig.get("assetsSettings", {}) |
| 162 | ); |
| 163 | |
| 164 | Root::Settings rootSettings; |
| 165 | rootSettings.assetsSettings.assetTimeToLive = assetsSettings.getInt("assetTimeToLive"); |
| 166 | rootSettings.assetsSettings.audioDecompressLimit = assetsSettings.getFloat("audioDecompressLimit"); |
| 167 | rootSettings.assetsSettings.workerPoolSize = assetsSettings.getUInt("workerPoolSize"); |
| 168 | rootSettings.assetsSettings.missingImage = assetsSettings.optString("missingImage"); |
| 169 | rootSettings.assetsSettings.missingAudio = assetsSettings.optString("missingAudio"); |
| 170 | rootSettings.assetsSettings.pathIgnore = jsonToStringList(assetsSettings.get("pathIgnore")); |
| 171 | rootSettings.assetsSettings.digestIgnore = jsonToStringList(assetsSettings.get("digestIgnore")); |
| 172 | |
| 173 | rootSettings.assetDirectories = jsonToStringList(bootConfig.get("assetDirectories", JsonArray())); |
| 174 | rootSettings.assetSources = jsonToStringList(bootConfig.get("assetSources", JsonArray())); |
| 175 | |
| 176 | rootSettings.defaultConfiguration = jsonMerge( |
| 177 | BaseDefaultConfiguration, |
| 178 | m_defaults.additionalDefaultConfiguration, |
| 179 | bootConfig.get("defaultConfiguration", {}) |
| 180 | ); |
| 181 | |
| 182 | rootSettings.storageDirectory = bootConfig.getString("storageDirectory"); |
| 183 | rootSettings.logDirectory = bootConfig.optString("logDirectory"); |
| 184 | rootSettings.logFile = options.parameters.value("logfile").maybeFirst().orMaybe(m_defaults.logFile); |
| 185 | rootSettings.logFileBackups = bootConfig.getUInt("logFileBackups", 10); |
| 186 | rootSettings.includeUGC = bootConfig.getBool("includeUGC", true); |
| 187 | |
| 188 | if (auto ll = options.parameters.value("loglevel").maybeFirst()) |
| 189 | rootSettings.logLevel = LogLevelNames.getLeft(*ll); |
| 190 | else |
| 191 | rootSettings.logLevel = m_defaults.logLevel; |
| 192 | |
| 193 | if (options.switches.contains("quiet")) |
| 194 | rootSettings.quiet = true; |
| 195 | else if (options.switches.contains("verbose")) |
| 196 | rootSettings.quiet = false; |
| 197 | else |
| 198 | rootSettings.quiet = m_defaults.quiet; |
| 199 | |
| 200 | if (auto rc = options.parameters.value("runtimeconfig").maybeFirst()) |
| 201 | rootSettings.runtimeConfigFile = *rc; |
| 202 | else |
| 203 | rootSettings.runtimeConfigFile = m_defaults.runtimeConfigFile; |
| 204 | |
| 205 | return rootSettings; |
| 206 | |
| 207 | } catch (std::exception const& e) { |
| 208 | throw StarException("Could not perform initial Root load", e); |
| 209 | } |
| 210 | } |
nothing calls this directly
no test coverage detected