| 384 | } |
| 385 | |
| 386 | bool WidgetManager::reloadWidgetActorOverrides( Widget * w, bool reloadProperties ) |
| 387 | { |
| 388 | if (reloadProperties) |
| 389 | { |
| 390 | // re-read the properties file |
| 391 | QString widgetDescStr = read_file_utf8(w->widgetPropertiesPath); |
| 392 | |
| 393 | // load the description file |
| 394 | LOG("Parsing widget json file..."); |
| 395 | QByteArray tmp = widgetDescStr.toUtf8(); |
| 396 | _loaded = _reader.parse(tmp.constData(), _root); |
| 397 | } |
| 398 | |
| 399 | if (_loaded) |
| 400 | { |
| 401 | try |
| 402 | { |
| 403 | // read all the actor overrides |
| 404 | w->actorOverrides.clear(); |
| 405 | Json::Value iconOverrides = getValue("widget.icons"); |
| 406 | for (int i = 0; i < iconOverrides.size(); ++i) |
| 407 | { |
| 408 | WidgetActorOverride ovr; |
| 409 | ovr.filePath = native(make_file(w->workingDirectory, qstringFromValue(iconOverrides[i]["filename"]))); |
| 410 | QString launchApp = qstringFromValue(iconOverrides[i]["launchApplication"]["path"]); |
| 411 | if (!launchApp.isEmpty()) |
| 412 | ovr.launchOverride = native(make_file(w->widgetDirectory, launchApp)); |
| 413 | ovr.launchOverrideParams = qstringFromValue(iconOverrides[i]["launchApplication"]["args"]); |
| 414 | ovr.label = qstringFromValue(iconOverrides[i]["label"]); |
| 415 | ovr.scale = -1.0f; |
| 416 | if (iconOverrides[i].isMember("scale")) |
| 417 | { |
| 418 | ovr.scale = NxMath::min(6.0f, (float) iconOverrides[i]["scale"].asDouble()); |
| 419 | } |
| 420 | |
| 421 | // update scene objects depending on override |
| 422 | // - move the object if it already exists |
| 423 | if (reloadProperties) |
| 424 | { |
| 425 | vector<FileSystemActor *> actors = scnManager->getFileSystemActors(ovr.filePath, false, false); |
| 426 | for (int j = 0; j < actors.size(); ++j) |
| 427 | { |
| 428 | actors[j]->setText(ovr.label); |
| 429 | Vec3 actorDims = actors[j]->getDims(); |
| 430 | float aspect = (actorDims.x / actorDims.y); |
| 431 | Vec3 dims(GLOBAL(settings).xDist, GLOBAL(settings).zDist / aspect, GLOBAL(settings).yDist); |
| 432 | if (ovr.scale > 0.0f) |
| 433 | { |
| 434 | dims *= ovr.scale; |
| 435 | actors[j]->setSizeAnim(actors[j]->getDims(), dims, 25); |
| 436 | |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | w->actorOverrides.push_back(ovr); |
| 442 | } |
| 443 |
no test coverage detected