当前位置: 首页>>代码示例>>C++>>正文


C++ TextObject类代码示例

本文整理汇总了C++中TextObject的典型用法代码示例。如果您正苦于以下问题:C++ TextObject类的具体用法?C++ TextObject怎么用?C++ TextObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TextObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: entity_SetFont

//	.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;
}
开发者ID:McManning,项目名称:fro_client,代码行数:28,代码来源:EntityLib.cpp

示例2: makeIdFromPointer

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();
}
开发者ID:jvprat,项目名称:residual,代码行数:29,代码来源:grim.cpp

示例3: entity_SetText

//	.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;
}
开发者ID:McManning,项目名称:fro_client,代码行数:27,代码来源:EntityLib.cpp

示例4:

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;
}
开发者ID:charliesome,项目名称:battlecars,代码行数:25,代码来源:Utility.cpp

示例5: report

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;
}
开发者ID:m-angelov,项目名称:ugene,代码行数:27,代码来源:TextObjectTests.cpp

示例6: setBulletObject

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();
		}
	}
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:31,代码来源:LetterHunter.cpp

示例7: lua_getparam

/* 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());
		}
	}
}
开发者ID:Grimfan33,项目名称:residual,代码行数:30,代码来源:lua_v1_text.cpp

示例8: lua_getparam

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());
	}
}
开发者ID:salty-horse,项目名称:residualvm,代码行数:9,代码来源:lua_v1_text.cpp

示例9:

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);
}
开发者ID:bla-rs,项目名称:Experimental,代码行数:11,代码来源:HUD.cpp

示例10:

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;
}
开发者ID:chronweigle,项目名称:violetland,代码行数:11,代码来源:TextManager.cpp

示例11: RuntimeObject

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());
}
开发者ID:Lizard-13,项目名称:GD,代码行数:14,代码来源:TextObject.cpp

示例12: SetImage

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 );
}
开发者ID:DashAndSlash,项目名称:GWEN,代码行数:27,代码来源:Button.cpp

示例13: SetString

void Text::SetString( const TextObject& str )
{ 
	if ( m_String == str ) return;

	m_String = str.GetUnicode(); 
	m_bTextChanged = true;
	Invalidate();
}
开发者ID:r-lyeh,项目名称:moon9,代码行数:8,代码来源:Text.cpp

示例14: randomString

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);
	}
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:46,代码来源:LetterHunter.cpp

示例15: TextObject

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++;
		}
	}
}
开发者ID:Harrypoppins,项目名称:grim_mouse,代码行数:35,代码来源:bink.cpp


注:本文中的TextObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。