| 373 | } |
| 374 | |
| 375 | void DifficultySettings::parseFromMapEntity(Entity* entity) { |
| 376 | // Construct the prefix for the desired difficulty level |
| 377 | std::string diffPrefix = "diff_" + string::to_string(_level) + "_"; |
| 378 | std::string prefix = diffPrefix + "change_"; |
| 379 | |
| 380 | Entity::KeyValuePairs spawnargs = entity->getKeyValuePairs(prefix); |
| 381 | |
| 382 | for (Entity::KeyValuePairs::iterator i = spawnargs.begin(); |
| 383 | i != spawnargs.end(); ++i) |
| 384 | { |
| 385 | const std::string& key = i->first; |
| 386 | const std::string& value = i->second; |
| 387 | |
| 388 | if (value.empty()) { |
| 389 | continue; // empty spawnarg attribute => invalid |
| 390 | } |
| 391 | |
| 392 | // Get the index from the string's tail |
| 393 | std::string indexStr = key.substr(prefix.length()); |
| 394 | |
| 395 | std::string className = entity->getKeyValue(diffPrefix + "class_" + indexStr); |
| 396 | SettingPtr setting = createSetting(className); |
| 397 | setting->spawnArg = value; |
| 398 | setting->argument = entity->getKeyValue(diffPrefix + "arg_" + indexStr); |
| 399 | |
| 400 | // This has been parsed from the default entityDef |
| 401 | setting->isDefault = false; |
| 402 | |
| 403 | // Interpret/parse the argument string |
| 404 | setting->parseAppType(); |
| 405 | } |
| 406 | |
| 407 | clearTreeModel(); |
| 408 | updateTreeModel(); |
| 409 | } |
| 410 | |
| 411 | void DifficultySettings::saveToEntity(DifficultyEntity& target) |
| 412 | { |
no test coverage detected