MCPcopy Create free account
hub / github.com/bumptop/BumpTop / reloadWidgetActorOverrides

Method reloadWidgetActorOverrides

trunk/win/Source/BT_WidgetManager.cpp:386–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386bool 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

Callers 1

onFileModifiedMethod · 0.80

Calls 15

read_file_utf8Function · 0.85
make_fileFunction · 0.85
qstringFromValueFunction · 0.85
getFileSystemActorsMethod · 0.80
getDimsMethod · 0.80
nativeFunction · 0.70
LOGFunction · 0.50
minClass · 0.50
parseMethod · 0.45
constDataMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected