Пример #1
0
//	.SetFont(ent, "face"<nil>, size<nil>, style<nil>) - Set displayed text of a text object entity
//		Any non-defined parameter will use user defaults
int entity_SetFont(lua_State* ls)
{
	luaCountArgs(ls, 1);

	int args = lua_gettop(ls);
	int size = 0, style = 0;
	string face;

	TextObject* o = (TextObject*)_getReferencedEntity(ls);
	if (!o || o->mType != ENTITY_TEXT)
	{
		return luaError(ls, "Entity.SetFont", "Invalid Entity type");
	}

	if (args > 1 && lua_isstring(ls, 2))
		face = lua_tostring(ls, 2);

	if (args > 2 && lua_isnumber(ls, 3))
		size = (int)lua_tonumber(ls, 3);

	if (args > 3 && lua_isnumber(ls, 4))
		style = (int)lua_tonumber(ls, 4);

	o->SetFont(face, size, style);
	return 0;
}
Пример #2
0
void GrimEngine::saveTextObjects(SaveGame *state) {
	PointerId ptr;

	state->beginSection('TEXT');

	state->writeLESint32(sayLineDefaults.disabled);
	state->writeByte(sayLineDefaults.fgColor.red());
	state->writeByte(sayLineDefaults.fgColor.green());
	state->writeByte(sayLineDefaults.fgColor.blue());
	ptr = makeIdFromPointer(sayLineDefaults.font);
	state->writeLEUint32(ptr.low);
	state->writeLEUint32(ptr.hi);
	state->writeLESint32(sayLineDefaults.height);
	state->writeLESint32(sayLineDefaults.justify);
	state->writeLESint32(sayLineDefaults.width);
	state->writeLESint32(sayLineDefaults.x);
	state->writeLESint32(sayLineDefaults.y);

	state->writeLESint32(_textObjects.size());
	for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); ++i) {
		TextObject *t = *i;
		ptr = makeIdFromPointer(t);
		state->writeLEUint32(ptr.low);
		state->writeLEUint32(ptr.hi);
		t->saveState(state);
	}

	state->endSection();
}
Пример #3
0
//	.SetText(ent, "text", r, g, b, maxWidth<0>) - Set displayed text of a text object entity
int entity_SetText(lua_State* ls)
{
	luaCountArgs(ls, 2);

	int args = lua_gettop(ls);
	int width = 0;
	color c;
	string text;

	TextObject* o = (TextObject*)_getReferencedEntity(ls);
	if (!o || o->mType != ENTITY_TEXT)
	{
		return luaError(ls, "Entity.SetText", "Invalid Entity type");
	}

	text = lua_tostring(ls, 2);
	c.r = (int)lua_tonumber(ls, 3);
	c.g = (int)lua_tonumber(ls, 4);
	c.b = (int)lua_tonumber(ls, 5);

	if (args > 5)
		width = (int)lua_tonumber(ls, 6);

	o->SetText(text, c, width);
	return 0;
}
Пример #4
0
bool Gwen::Utility::Strings::Wildcard( const TextObject& strWildcard, const TextObject& strHaystack )
{
	const UnicodeString& W = strWildcard.GetUnicode();
	const UnicodeString& H = strHaystack.GetUnicode();

	if ( strWildcard == "*" ) return true;

	int iPos = W.find( L"*", 0 );
	if ( iPos == UnicodeString::npos ) return strWildcard == strHaystack;

	// First half matches
	if ( iPos > 0 && W.substr( 0, iPos ) != H.substr( 0, iPos ) )
		return false;

	// Second half matches
	if ( iPos != W.length()-1 )
	{
		UnicodeString strEnd = W.substr( iPos+1, W.length() );

		if ( strEnd != H.substr( H.length() - strEnd.length(), H.length() ) )
			return false;
	}

	return true;
}
Пример #5
0
Task::ReportResult GTest_CheckStringExists::report() {
    TextObject *obj = getContext<TextObject>(this, objContextName);
    if (obj == NULL) {
        stateInfo.setError(QString("invalid object context"));
        return ReportResult_Finished;
    }

    QString stringToFind = QRegExp::escape(stringToCheck);
    if (wholeLine) {
        stringToFind = "^(.*\\n)?" + QRegExp::escape(stringToCheck) + "(\\n.*)?$";
    }

    const QString text = obj->getText();
    int index = text.indexOf(QRegExp(stringToFind));

    if (mustExist) {
        if (-1 == index) {
            stateInfo.setError(QString("String doesn't exist: '%1'").arg(stringToCheck));
        }
    } else {
        if (-1 != index) {
            stateInfo.setError(QString("String unexpectedly exists: '%1' at position %2").arg(stringToCheck).arg(index));
        }
    }

    return ReportResult_Finished;
}
Пример #6
0
void LetterHunter::shootCheck(wchar_t key)
{
	if (currentTextObject_)
	{
		BaseLetter* letterOjbect = currentTextObject_->getFirstActiveLetterObject();
		if (key == letterOjbect->getLetter())
		{
			// Set the bullet object based on the letter object.
			setBulletObject(letterOjbect);

			// Play sound for the bullet
			soundManager_->onShoot();
		}
		else
		{
			// Warn user where is the target text object is, may be need some highlight mechnism.
		}
	}

	else
	{
		TextObject* targetTextObject = findTarget(key);
		if(targetTextObject)
		{
			currentTextObject_ = targetTextObject;
			BaseLetter* letterOjbect = targetTextObject->getFirstActiveLetterObject();
			setBulletObject(letterOjbect);
			soundManager_->onShoot();
		}
	}
}
Пример #7
0
/* Make changes to a text object based on the parameters passed
 * in the table in the LUA parameter 2.
 */
void Lua_V1::ChangeTextObject() {
	const char *line;
	lua_Object textObj = lua_getparam(1);
	int paramId = 2;
	if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
		TextObject *textObject = gettextobject(textObj);
		for (;;) {
			lua_Object paramObj = lua_getparam(paramId++);
			if (!paramObj)
				break;
			if (!lua_isstring(paramObj)) {
				if (!lua_istable(paramObj))
					break;
				setTextObjectParams(textObject, paramObj);
				textObject->destroy();
			} else {
				line = lua_getstring(paramObj);
				textObject->setText(line);
				lua_getstring(paramObj);

			}

			lua_pushnumber(textObject->getBitmapWidth());
			lua_pushnumber(textObject->getBitmapHeight());
		}
	}
}
Пример #8
0
void Lua_V1::GetTextCharPosition() {
	lua_Object textObj = lua_getparam(1);
	if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
		TextObject *textObject = gettextobject(textObj);
		int pos = (int)lua_getnumber(lua_getparam(2));
		lua_pushnumber(textObject->getTextCharPosition(pos));
	}
}
Пример #9
0
void Lua_V1::GetTextObjectDimensions() {
	lua_Object textObj = lua_getparam(1);

	if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
		TextObject *textObject = gettextobject(textObj);
		lua_pushnumber(textObject->getBitmapWidth());
		lua_pushnumber(textObject->getBitmapHeight());
	}
}
Пример #10
0
void violet::HUD::addMessage(std::string message) {
	std::cout << message << std::endl;

	TextObject* msg = m_videoManager->SmallText->getObject(message, 0, 0,
			TextManager::LEFT, TextManager::MIDDLE);

	// Here scale is the variable for control over animation sequence
	msg->Scale = m_videoManager->getVideoMode().Width + msg->getWidth();

	m_messages.push_back(msg);
}
Пример #11
0
void violet::TextManager::draw(const std::string& textBuf, float x, float y,
		TextHAlignFlag halign, TextVAlignFlag valign) {
	if (textBuf.size() == 0)
		return;

	TextObject *textObject = TextManager::getObject(textBuf, x, y, halign,
			valign);

	textObject->draw(true, textObject->X, textObject->Y);
	delete textObject;
}
Пример #12
0
RuntimeTextObject::RuntimeTextObject(RuntimeScene& scene,
                                     const TextObject& textObject)
    : RuntimeObject(scene, textObject), opacity(255), angle(0) {
  ChangeFont(textObject.GetFontName());
  SetSmooth(textObject.IsSmoothed());
  SetColor(
      textObject.GetColorR(), textObject.GetColorG(), textObject.GetColorB());
  SetString(textObject.GetString());
  SetCharacterSize(textObject.GetCharacterSize());
  SetAngle(0);
  SetBold(textObject.IsBold());
  SetItalic(textObject.IsItalic());
  SetUnderlined(textObject.IsUnderlined());
}
Пример #13
0
void Button::SetImage( const TextObject & strName, bool bCenter )
{
	if ( strName.GetUnicode() == L"" )
	{
		if ( m_Image )
		{
			delete m_Image;
			m_Image = NULL;
		}

		return;
	}

	if ( !m_Image )
	{
		m_Image = new ImagePanel( this );
	}

	m_Image->SetImage( strName );
	m_Image->SizeToContents();
	m_Image->SetMargin( Margin( 2, 0, 2, 0 ) );
	m_bCenterImage = bCenter;
	// Ugh.
	Padding padding = GetTextPadding();
	padding.left = m_Image->Right() + 2;
	SetTextPadding( padding );
}
Пример #14
0
void Text::SetString( const TextObject& str )
{ 
	if ( m_String == str ) return;

	m_String = str.GetUnicode(); 
	m_bTextChanged = true;
	Invalidate();
}
Пример #15
0
void LetterHunter::initializeText()
{
	ID2D1Factory*			D2DFactory		= d2d_->getD2DFactory();
	ID2D1HwndRenderTarget*	renderTarget	= d2d_->getD2DHwndRenderTarget();
	IDWriteFactory*			DWriteFactory	= d2d_->getDWriteFactory();

	for(int i = 0; i < TEXTCOUNT; ++i)
	{
		// Geneate a random string
		const int strLength = 1;
		wchar_t* strBuffer = new wchar_t[strLength + 1];
		randomString(strBuffer, strLength);

		TextObject* textObj = new TextObject(
			D2DFactory,
			renderTarget,
			DWriteFactory,
			strBuffer,
			100
			);

		SAFE_DELETE(strBuffer);

		// Generate 10 random numbers between 1 and 100
		float a[10] = {0};
		float velocityY = randomFloat(10.0f, 50.0f);
		D2D_VECTOR_2F velocity = {0, velocityY};

		// Set text position
		float windowWidth = (float)getwindowWidth();
		D2D1_RECT_F textBoundRect = textObj->getBoundaryRect();
		float maxRight = windowWidth - (textBoundRect.right -textBoundRect.left);

		float positionX = randomFloat(0, maxRight);
		D2D1_POINT_2F position = {positionX, 0};
		textObj->setPosition(position);

		// Set text velocity
		textObj->setVelocity(velocity);

		D2D1_COLOR_F fillColor = randomColor();
		textObj->setFillColor(fillColor);

		textBuffer_.push_back(textObj);
	}
}
Пример #16
0
void BinkPlayer::handleFrame() {
	MoviePlayer::handleFrame();

	if (!_showSubtitles || _subtitleIndex == _subtitles.end())
		return;

	unsigned int startFrame, endFrame, curFrame;
	startFrame = _subtitleIndex->_startFrame;
	endFrame = _subtitleIndex->_endFrame;
	curFrame = _videoDecoder->getCurFrame();
	if (startFrame <= curFrame && curFrame <= endFrame) {
		if (!_subtitleIndex->active) {
			TextObject *textObject = new TextObject();
			textObject->setDefaults(&g_grim->_sayLineDefaults);
			Color c(255, 255, 255);
			textObject->setFGColor(c);
			textObject->setIsSpeech();
			if (g_grim->getMode() == GrimEngine::SmushMode) {
				// TODO: How to center exactly and put the text exactly
				// at the bottom  even if there are multiple lines?
				textObject->setX(640 / 2);
				textObject->setY(40);
			}
			textObject->setText(g_localizer->localize(_subtitleIndex->_textId.c_str()));
			g_grim->setMovieSubtitle(textObject);
			_subtitleIndex->active = true;
		}
	} else if (endFrame < curFrame) {
		if (_subtitleIndex->active) {
			g_grim->setMovieSubtitle(NULL);
			_subtitleIndex->active = false;
			_subtitleIndex++;
		}
	}
}
void TextComponent_BullShit::Render()
{
	int charIndex = 0;
	TextObject* textObj;
	SpriteComponent * textSprite;
	while (text[charIndex] != '\0')
	{
		textObj = OpenGLRenderer::GetRenderer()->GetCharacterImage(text[charIndex]);
		
		textSprite = textObj->GetTextSprite();

		textSprite->SetHidden(false);
		textSprite->SetPosition(GetPosition() + Vect2(charIndex * CHAR_WIDTH, 0));
		textSprite->Render();
		textSprite->SetHidden(true);
	
		++charIndex;
	}
}
Пример #18
0
void Lua_V1::BlastText() {
	lua_Object textObj = lua_getparam(1);
	if (!lua_isstring(textObj)) {
		return;
	}

	const char *line = lua_getstring(textObj);
	if (!line || line[0] == 0)
		return;

	TextObject *textObject = new TextObject(true);
	textObject->setDefaults(&g_grim->_blastTextDefaults);
	lua_Object tableObj = lua_getparam(2);
	if (lua_istable(tableObj))
		setTextObjectParams(textObject, tableObj);

	textObject->setText(line);
	textObject->draw();
	delete textObject;
}
	void OverlayRenderer::drawText(const TextObject & text)
	{
		glDisable(GL_DEPTH_TEST);

		text.getFont().getTexture().bind(0);

		textShader.enable();
		textShader.setUniformVec2f("offset", text.getPosition());
		textShader.setUniformVec4f("tint", text.getColor());
		textShader.setUniformInt("overlayTexture", 0);
		textShader.setUniformMatrix4x4f("projectionMatrix", projection);

		text.draw();

		textShader.disable();
		
		text.getFont().getTexture().unbind();

		glEnable(GL_DEPTH_TEST);


	}
Пример #20
0
void MenuItem::SetAccelerator( const TextObject& strAccelerator )
{
	if ( m_Accelerator ) 
	{
		m_Accelerator->DelayedDelete();
		m_Accelerator = NULL;
	}
#ifndef GWEN_NO_UNICODE
	if ( strAccelerator.GetUnicode() == L"" )
		return;
#else
	if ( strAccelerator.Get() == "" )
		return;
#endif


	m_Accelerator = new Controls::Label( this );
	m_Accelerator->Dock( Pos::Right );
	m_Accelerator->SetAlignment( Pos::Right | Pos::CenterV );
	m_Accelerator->SetText( strAccelerator );
	m_Accelerator->SetMargin( Margin( 0, 0, 16, 0 ) );
	// TODO.
}
Пример #21
0
void Lua_V1::MakeTextObject() {
	lua_Object textObj = lua_getparam(1);
	if (!lua_isstring(textObj)) {
		return;
	}

	TextObject *textObject = new TextObject(false);
	const char *line = lua_getstring(textObj);
	Common::String text = line;

	textObject->setDefaults(&g_grim->_blastTextDefaults);
	lua_Object tableObj = lua_getparam(2);
	if (lua_istable(tableObj))
		setTextObjectParams(textObject, tableObj);

	textObject->setText(text.c_str());

	lua_pushusertag(textObject->getId(), MKTAG('T', 'E', 'X', 'T'));
	if (!(g_grim->getGameFlags() & ADGF_DEMO)) {
		lua_pushnumber(textObject->getBitmapWidth());
		lua_pushnumber(textObject->getBitmapHeight());
	}
}
Пример #22
0
void recursiveSearch( GroupObject* group, ofstream &out )
{
    if (!group) return;

    for( unsigned i=0; i<group->objectCount(); i++ )
        {
	    Object* object = group->object(i);
	    if( object->isText() )
	        {
	    	    TextObject* T = static_cast<TextObject*>(object);
		    if(T)
			{
//			    out << "  " << T->typeAsString() << " (" << T->listSize() << "): ";

			    bool	written = false;
			    for (int j=0; j<T->listSize(); j++)
				{
				    if (T->text(j).cstring().c_str()!=NULL
					&& T->text(j).cstring().c_str()[0]!='\0'
					&& strncmp(T->text(j).cstring().c_str(),"Click to edit",13)
					&& strncmp(T->text(j).cstring().c_str(),"Klikk for å redigere",20))
					{
					    if (!written)
						{
						    if (!textonly)
							{
							    if (T->type()==TextObject::Body || T->type()==TextObject::CenterBody
								|| T->type()==TextObject::HalfBody || T->type()==TextObject::QuarterBody)
								out << "<p>";
							    else if (T->type()==TextObject::Title || T->type()==TextObject::CenterTitle)
								out << "<h2>";
							    else out << "<div>";
							}

						    written = true;
						}

					    if (!textonly) out << "<span>";
					    out << T->text(j).cstring().c_str();
					    if (!textonly) out << "</span> ";
					}
				}

			    if (written && !textonly)
				{
				    if (T->type()==TextObject::Body || T->type()==TextObject::CenterBody
					|| T->type()==TextObject::HalfBody || T->type()==TextObject::QuarterBody)
					out << "</p>";
				    else if (T->type()==TextObject::Title || T->type()==TextObject::CenterTitle)
					out << "</h2>";
				    else out << "</div>";
				    out << endl;
				}
			    else
				out << endl;
			}
    		}

	    if( object->isGroup() )
	        recursiveSearch( static_cast<GroupObject*>(object), out );
	}
}
Пример #23
0
void Actor::draw() {
	for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
		Costume *c = *i;
		c->setupTextures();
	}

	if (!g_driver->isHardwareAccelerated() && g_grim->getFlagRefreshShadowMask()) {
		for (int l = 0; l < MAX_SHADOWS; l++) {
			if (!_shadowArray[l].active)
				continue;
			g_driver->setShadow(&_shadowArray[l]);
			g_driver->drawShadowPlanes();
			g_driver->setShadow(NULL);
		}
	}

	// FIXME: if isAttached(), factor in the joint & actor rotation as well.
	Math::Vector3d absPos = getWorldPos();
	if (!_costumeStack.empty()) {
		g_grim->getCurrSet()->setupLights(absPos);

		Costume *costume = _costumeStack.back();
		for (int l = 0; l < MAX_SHADOWS; l++) {
			if (!shouldDrawShadow(l))
				continue;
			g_driver->setShadow(&_shadowArray[l]);
			g_driver->setShadowMode();
			if (g_driver->isHardwareAccelerated())
				g_driver->drawShadowPlanes();
			g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, _alphaMode != AlphaOff ? _globalAlpha : 1.f);
			costume->draw();
			g_driver->finishActorDraw();
			g_driver->clearShadowMode();
			g_driver->setShadow(NULL);
		}

		bool isShadowCostume = costume->getFilename().equals("fx/dumbshadow.cos");
		if (!isShadowCostume || _shadowActive) {
			// normal draw actor
			g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, _alphaMode != AlphaOff ? _globalAlpha : 1.f);
			costume->draw();
			g_driver->finishActorDraw();
		}
	}

	if (_mustPlaceText) {
		int x1, y1, x2, y2;
		x1 = y1 = 1000;
		x2 = y2 = -1000;
		if (!_costumeStack.empty()) {
			g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, 1.f);
			_costumeStack.back()->getBoundingBox(&x1, &y1, &x2, &y2);
			g_driver->finishActorDraw();
		}

		TextObject *textObject = TextObject::getPool().getObject(_sayLineText);
		if (textObject) {
			if (x1 == 1000 || x2 == -1000 || y2 == -1000) {
				textObject->setX(640 / 2);
				textObject->setY(463);
			} else {
				textObject->setX((x1 + x2) / 2);
				textObject->setY(y1);
			}
			textObject->reset();
		}
		_mustPlaceText = false;
	}
}
Пример #24
0
void Actor::sayLine(const char *msgId, bool background) {
	assert(msgId);

	char id[50];
	Common::String msg = LuaBase::instance()->parseMsgText(msgId, id);

	if (msgId[0] == 0) {
		error("Actor::sayLine: No message ID for text");
		return;
	}

	// During Fullscreen movies SayLine is usually called for text display only.
	// The movie with Charlie screaming after Manny put the sheet on him instead
	// uses sayLine for the voice too.
	// However, normal SMUSH movies may call SayLine, for example:
	// When Domino yells at Manny (a SMUSH movie) he does it with
	// a SayLine request rather than as part of the movie!

	Common::String soundName = id;

	if (g_grim->getGameType() == GType_GRIM) {
		soundName += ".wav";
	} else if (g_grim->getGameType() == GType_MONKEY4 && g_grim->getGamePlatform() == Common::kPlatformPS2) {
		soundName += ".scx";
	} else {
		soundName += ".wVC";
	}
	if (_talkSoundName == soundName)
		return;

	if (_talking || msg.empty())
		shutUp();

	_talkSoundName = soundName;
	if (g_grim->getSpeechMode() != GrimEngine::TextOnly) {
		_talkDelay = 500;
		if (g_sound->startVoice(_talkSoundName.c_str()) && g_grim->getCurrSet()) {
			g_grim->getCurrSet()->setSoundPosition(_talkSoundName.c_str(), _pos);
		}
	}

	// If the actor is clearly not visible then don't try to play the lip sync
	if (_visible && (!g_movie->isPlaying() || g_grim->getMode() == GrimEngine::NormalMode)) {
		Common::String soundLip = id;
		soundLip += ".lip";

		if (!_talkChore[0].isPlaying()) {
			// _talkChore[0] is *_stop_talk
			_talkChore[0].setLastFrame();
		}
		// Sometimes actors speak offscreen before they, including their
		// talk chores are initialized.
		// For example, when reading the work order (a LIP file exists for no reason).
		// Also, some lip sync files have no entries
		// In these cases, revert to using the mumble chore.
		if (g_grim->getSpeechMode() != GrimEngine::TextOnly)
			_lipSync = g_resourceloader->getLipSync(soundLip);
		// If there's no lip sync file then load the mumble chore if it exists
		// (the mumble chore doesn't exist with the cat races announcer)
		if (!_lipSync)
			_mumbleChore.playLooping();

		_talkAnim = -1;
	}

	_talking = true;
	g_grim->addTalkingActor(this);

	_backgroundTalk = background;
	if (background)
		_isTalkingBackground = true;

	if (_sayLineText && g_grim->getMode() != GrimEngine::SmushMode) {
		delete TextObject::getPool().getObject(_sayLineText);
		_sayLineText = 0;
	}

	if (!msg.empty()) {
		GrimEngine::SpeechMode m = g_grim->getSpeechMode();
		if (!g_grim->_sayLineDefaults.getFont() || m == GrimEngine::VoiceOnly)
			return;

		TextObject *textObject = new TextObject(false, true);
		textObject->setDefaults(&g_grim->_sayLineDefaults);
		textObject->setFGColor(_talkColor);
		if (m == GrimEngine::TextOnly || g_grim->getMode() == GrimEngine::SmushMode) {
			textObject->setDuration(500 + msg.size() * 15 * (11 - g_grim->getTextSpeed()));
		}
		if (g_grim->getMode() == GrimEngine::SmushMode) {
			textObject->setX(640 / 2);
			textObject->setY(456);
			g_grim->setMovieSubtitle(textObject);
		} else {
			if (_visible && isInSet(g_grim->getCurrSet()->getName())) {
				_mustPlaceText = true;
			} else {
				_mustPlaceText = false;
				textObject->setX(640 / 2);
				textObject->setY(463);
			}
		}
		textObject->setText(msgId);
		if (g_grim->getMode() != GrimEngine::SmushMode)
			_sayLineText = textObject->getId();
	}
}