Example #1
0
ExtensionInterface* ExtensionFactory::createInstance(const QString& kind,
	int keycode, int keymask)
{
	ExtensionInterface* ext;
	QString kindstr = kind.lower();

	ext = loadInstance(kindstr, keycode, keymask);
	if(ext != NULL){
		return(ext);
	}

	if(kindstr == "switch"){
		ext = new TaskSwitcher(kindstr);
	} else if(kindstr == "select"){
		ext = new TaskSelector(kindstr);
	} else if(kindstr.find("launch") == 0){
		ext = new KeyLauncher(kindstr);
	} else if(kindstr.find("menu") == 0){
		ext = new MenuLauncher(kindstr);
	} else {
		return(NULL);
	}
	ext->setKeycode(keycode);
	ext->setKeymask(keymask);

	m_oExtList.append(ext);
	return(ext);
}
Example #2
0
void Creature::load(const Aurora::GFF3Struct &creature) {
	Common::UString temp = creature.getString("ResRef");

	if (!temp.empty()) {
		try {
			Common::ScopedPtr<Aurora::GFF3File>
				cre(new Aurora::GFF3File(temp, Aurora::kFileTypeCRE, MKTAG('C', 'R', 'E', ' ')));

			loadBlueprint(cre->getTopLevel());

		} catch (Common::Exception &e) {
			e.add("Creature \"%s\" has no blueprint", temp.c_str());
			throw;
		}
	}

	// Tag
	_tag = creature.getString("Tag");

	// Appearance

	if (_appearance == Aurora::kFieldIDInvalid)
		throw Common::Exception("Creature without an appearance");

	loadAppearance();

	loadInstance(creature);
}
Example #3
0
void Trigger::load(const Aurora::GFF3Struct &trigger) {
	Common::UString temp = trigger.getString("ResRef");

	if (!temp.empty()) {
		Aurora::GFF3File *trg = 0;
		try {
			trg = new Aurora::GFF3File(temp, Aurora::kFileTypeTRG, MKTAG('T', 'R', 'G', ' '));
			loadBlueprint(trg->getTopLevel());
		} catch (...) {
			warning("Trigger \"%s\" has no blueprint", temp.c_str());
			delete trg;
			throw;
		}
		delete trg;
	}

	loadInstance(trigger);
}
Example #4
0
void Trigger::load(const Aurora::GFF3Struct &trigger) {
	Common::UString temp = trigger.getString("ResRef");

	if (!temp.empty()) {
		try {
			Common::ScopedPtr<Aurora::GFF3File>
				trg(new Aurora::GFF3File(temp, Aurora::kFileTypeTRG, MKTAG('T', 'R', 'G', ' ')));

			loadBlueprint(trg->getTopLevel());

		} catch (Common::Exception &e) {
			e.add("Trigger \"%s\" has no blueprint", temp.c_str());
			throw;
		}
	}

	loadInstance(trigger);
}
Example #5
0
const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& status) {
  // Make sure our cache exists.
  umtx_initOnce(gGenderInitOnce, &GenderInfo_initCache, status);
  if (U_FAILURE(status)) {
    return NULL;
  }

  const GenderInfo* result = NULL;
  const char* key = locale.getName();
  {
    Mutex lock(&gGenderMetaLock);
    result = (const GenderInfo*) uhash_get(gGenderInfoCache, key);
  }
  if (result) {
    return result;
  }

  // On cache miss, try to create GenderInfo from CLDR data
  result = loadInstance(locale, status);
  if (U_FAILURE(status)) {
    return NULL;
  }

  // Try to put our GenderInfo object in cache. If there is a race condition,
  // favor the GenderInfo object that is already in the cache.
  {
    Mutex lock(&gGenderMetaLock);
    GenderInfo* temp = (GenderInfo*) uhash_get(gGenderInfoCache, key);
    if (temp) {
      result = temp;
    } else {
      uhash_put(gGenderInfoCache, uprv_strdup(key), (void*) result, &status);
      if (U_FAILURE(status)) {
        return NULL;
      }
    }
  }
  return result;
}
Example #6
0
InstanceFactory::InstCreateError InstanceFactory::copyInstance(InstancePtr &newInstance,
															   InstancePtr &oldInstance,
															   const QString &instDir)
{
	QDir rootDir(instDir);

	QLOG_DEBUG() << instDir.toUtf8();
	if (!copyPath(oldInstance->instanceRoot(), instDir))
	{
		rootDir.removeRecursively();
		return InstanceFactory::CantCreateDir;
	}

	INISettingsObject settings_obj(PathCombine(instDir, "instance.cfg"));
	settings_obj.registerSetting("InstanceType", "Legacy");
	QString inst_type = settings_obj.get("InstanceType").toString();

	if (inst_type == "OneSixFTB")
		settings_obj.set("InstanceType", "OneSix");
	if (inst_type == "LegacyFTB")
		settings_obj.set("InstanceType", "Legacy");

	oldInstance->copy(instDir);

	auto error = loadInstance(newInstance, instDir);

	switch (error)
	{
	case NoLoadError:
		return NoCreateError;
	case NotAnInstance:
		rootDir.removeRecursively();
		return CantCreateDir;
	default:
	case UnknownLoadError:
		rootDir.removeRecursively();
		return UnknownCreateError;
	}
}
Example #7
0
void World::loadScene(string filename) {
    // for as4, you can optionally hard-code the scene.  For as5 and as6 it must be loaded from a file.

    if (_FINAL_PROJ) {
        vec4 eye(0.0, 0.0, 0, 1.0);
        vec4 LL(-1.0, -1.0, -3.0, 1.0);
        vec4 UL(-1.0, 1.0, -3.0, 1.0);
        vec4 LR(1.0, -1.0, -3.0, 1.0);
        vec4 UR(1.0, 1.0, -3.0, 1.0);

        _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, 1);

        _lights[LIGHT_DIRECTIONAL].push_back(
            Light(0, vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        _lights[LIGHT_POINT].push_back(
            Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        _ambientLight = vec3(.5,.2,.2);
        /*
        _spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        					MaterialInfo(vec3(.4, .5, .9),
        					.1, .5, .5, 150, 1.0)));
        _spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        					MaterialInfo(vec3(.9, .4, .5),
        					.4, .2, .5, 20, 0.0)));
        _spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        					MaterialInfo(vec3(.5, .9, .4),
        					.5, .5, .3, 4, .5)));
        */

        _cubes.push_back(Cube(vec4(-3.5,-3.5,-15.0,1.0), 1.5, MaterialInfo(vec3(.4, .5, .9),
                              .1, .5, .5, 150, 1.0)));

        _cubes.push_back(Cube(vec4(2.0, 1.5, -10,1.0), 1.5, MaterialInfo(vec3(.9, .4, .5),
                              .4, .2, .5, 20, 0.0)));

        _cubes.push_back(Cube(vec4(-3.5,4,-120.0,1.0), 3, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        _cubes.push_back(Cube(vec4(3.5,-4,-250.0,1.0), 3.5, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        ksmMod = kspMod = 1.0;
    }

    else if (_ASSIGNMENT >= 5) {
        scene = new Scene(filename);

        loadInstance(scene->getRoot());

        if (_ASSIGNMENT >= 6)
            _bb = new BoundingBox(_spheres, 0);
    }

    if (_ASSIGNMENT <= 4) {
        //vec4 eye(0.0, 0.0, 0, 1.0);
        //vec4 LL(-1.0, -1.0, -3.0, 1.0);
        //vec4 UL(-1.0, 1.0, -3.0, 1.0);
        //vec4 LR(1.0, -1.0, -3.0, 1.0);
        //vec4 UR(1.0, 1.0, -3.0, 1.0);

        //_view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT);

        //_lights[LIGHT_DIRECTIONAL].push_back(
        //						Light(0, vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        //_lights[LIGHT_POINT].push_back(
        //						Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        //_ambientLight = vec3(.5,.2,.2);

        //_spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        //					MaterialInfo(vec3(.4, .5, .9),
        //					.1, .5, .5, 150, 1.0)));
        //_spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        //					MaterialInfo(vec3(.9, .4, .5),
        //					.4, .2, .5, 20, 0.0)));
        //_spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        //					MaterialInfo(vec3(.5, .9, .4),
        //					.5, .5, .3, 4, .5)));

        //ksmMod = kspMod = 1.0;
    }
}
Example #8
0
void World::loadInstance(SceneInstance *si) {

    // Compute transform information. Should add a mat4 even if there is no transform.
    mat4 mTransform;
    if (!si->computeTransform(mTransform)) {
        mTransform = identity3D(); // if there is no transform, push an identity matrix.
    }
    if (!transformStack.empty() && transformStack.top() != identity3D()) {
        mat4 mPreviousTransform = transformStack.top();
        mTransform =  mPreviousTransform * mTransform;
    }
    transformStack.push(mTransform);

    SceneGroup *sg = si->getChild();

    // Get camera info, if any.
    CameraInfo camInfo;
    if (sg->computeCamera(camInfo)) {
        vec4 eye(0.0, 0.0, 0.0, 1.0);
        double left = camInfo.sides[FRUS_LEFT];
        double right = camInfo.sides[FRUS_RIGHT];
        double top = camInfo.sides[FRUS_TOP];
        double bottom = camInfo.sides[FRUS_BOTTOM];
        double depth = -1*camInfo.sides[FRUS_NEAR];
        vec4 LL(left, bottom, depth, 1.0);
        vec4 UL(left, top, depth, 1.0);
        vec4 LR(right, bottom, depth, 1.0);
        vec4 UR(right, top, depth, 1.0);
        eye = mTransform * eye;
        LL = mTransform * LL;
        UL = mTransform * UL;
        LR = mTransform * LR;
        UR = mTransform * UR;
        _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, camInfo.perspective);
    }

    // Compute light info, if any.
    LightInfo li;
    if (sg->computeLight(li)) {
        vec3 direction, position;
        switch (li.type) {
        case LIGHT_DIRECTIONAL:
        case LIGHT_POINT:
        case LIGHT_SPOT:
            direction = vec3(-1*mTransform[0][2],-1*mTransform[1][2],-1*mTransform[2][2]);
            position = mTransform * vec3(0.0);
            _lights[li.type].push_back(Light(position, direction, li));
            break;
        case LIGHT_AMBIENT:
            _ambientLight = li.color;
            break;
        }
    }

    // Computes sphere info, if any.
    double radius;
    MaterialInfo matInfo;
    if (sg->computeSphere(radius, matInfo, 0)) {
        _spheres.push_back(Sphere(vec4(0.0), radius, matInfo, mTransform));
    }

    // Recursively parse scene.
    for (int i = 0; i < sg->getChildCount(); i++) {
        loadInstance(sg->getChild(i));
    }

    // Pops the transformation matrix of this SceneGroup. This function should have added this matrix at the beginning.
    transformStack.pop();
}