Пример #1
0
void WidgetCheckBox::load(const Aurora::GFF3Struct &gff) {
	KotORWidget::load(gff);

	Border border = createBorder(gff);
	Graphics::Aurora::TextureHandle texture = TextureMan.get(border.fill);

	float squareLength = _quad->getHeight();
	float _quadPosCorrect = (squareLength - (texture.getTexture().getHeight() * 0.625f)) / 2;
	float x, y, z;
	if (_quad) {
		_quad->getPosition(x, y, z);
		_quad->setPosition(x + _quadPosCorrect, y + _quadPosCorrect, z);
		_quad->setHeight(texture.getTexture().getHeight() * 0.625f);
		_quad->setWidth(texture.getTexture().getWidth() * 0.625f);
	}
	if (_text) {
		_text->getPosition(x, y, z);
		_text->setPosition(x + squareLength, y, z);
		_text->setSize(_text->getWidth() - squareLength, _text->getHeight());
	}

	if (getTextHighlightableComponent() != 0) {
		setTextHighlighting(getTextHighlightableComponent());
	}
	if (getQuadHighlightableComponent() != 0) {
		setQuadHighlighting(getQuadHighlightableComponent());
	}
}
Пример #2
0
void WidgetButton::setIcon(const Common::UString &icon) {
	if (_icon == icon)
		return;

	_icon = icon;

	if (icon.empty()) {
		if (_iconQuad) {
			_iconQuad->hide();
			_iconQuad.reset();
		}
		return;
	}

	Graphics::Aurora::TextureHandle textureHandle = TextureMan.get(icon);
	Graphics::Aurora::Texture &texture = textureHandle.getTexture();

	_iconQuad.reset(new Graphics::Aurora::GUIQuad(
			textureHandle,
			0.0f, 0.0f, texture.getWidth(), texture.getHeight()));

	float x, y, z;
	getPosition(x, y, z);

	_iconQuad->setPosition(
		x + getWidth() / 2.0f - texture.getWidth() / 2.0f,
		y + getHeight() / 2.0f - texture.getHeight() / 2.0f,
		z - 1.0f
	);

	if (isVisible())
		_iconQuad->show();
}
Пример #3
0
void Creature::loadModel() {
	if (_model)
		return;

	if (_appearanceID == Aurora::kFieldIDInvalid) {
		warning("Creature \"%s\" has no appearance", _tag.c_str());
		return;
	}

	const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearanceID);

	if (_portrait.empty())
		_portrait = appearance.getString("PORTRAIT");

	_environmentMap = appearance.getString("ENVMAP");

	if (appearance.getString("MODELTYPE") == "P") {
		getArmorModels();
		getPartModels();
		_model = loadModelObject(_partsSuperModelName);

		for (size_t i = 0; i < kBodyPartMAX; i++) {
			if (_bodyParts[i].modelName.empty())
				continue;

			TextureMan.startRecordNewTextures();

			// Try to load in the corresponding part model
			Graphics::Aurora::Model *partModel = loadModelObject(_bodyParts[i].modelName, _bodyParts[i].textureName);
			if (!partModel)
				continue;

			// Add the loaded model to the appropriate part node
			Graphics::Aurora::ModelNode *partNode = _model->getNode(kBodyPartNodes[i]);
			if (partNode)
				partNode->addChild(partModel);

			std::list<Common::UString> newTextures;
			TextureMan.stopRecordNewTextures(newTextures);

			for (std::list<Common::UString>::const_iterator t = newTextures.begin(); t != newTextures.end(); ++t) {
				Graphics::Aurora::TextureHandle texture = TextureMan.getIfExist(*t);
				if (texture.empty())
					continue;

				_bodyParts[i].textures.push_back(texture);
			}

			finishPLTs(_bodyParts[i].textures);
		}

	} else
		_model = loadModelObject(appearance.getString("RACE"));

	// Positioning

	float x, y, z, angle;

	getPosition(x, y, z);
	setPosition(x, y, z);

	getOrientation(x, y, z, angle);
	setOrientation(x, y, z, angle);

	// Clickable

	if (_model) {
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		_ids.push_back(_model->getID());

		if (!_environmentMap.empty()) {
			Common::UString environmentMap = _environmentMap;
			if (environmentMap.equalsIgnoreCase("default"))
				environmentMap = _area ? _area->getEnvironmentMap() : "";

			_model->setEnvironmentMap(environmentMap);
		}
	}
}