Exemplo n.º 1
0
bool CGUIString::TextChunk::Tag::SetTagType(const CStrW& tagtype)
{
	TagType t = GetTagType(tagtype);
	if (t == TAG_INVALID)
		return false;

	m_TagType = t;
	return true;
}
Exemplo n.º 2
0
	int SkipTags(const char* text, TextTags::Enum* tag = 0, int* imgLen = 0)
	{
		if (tag)
		{
			*tag = TextTags::Num;
		}

		if (text[0] == 0)
		{
			return 0;
		}

		if (text[0] == '[' && text[2] == '$')
		{
			// found end
			int pos = 4;
			for (; text[pos] != 0; pos += 2)
			{
				if (text[pos] == '$' && text[pos + 2] == ']')
				{
					int endLen = pos + 4;
					char buf[256];
					TextTags::Enum tagType = GetTagType(text, endLen, buf);

					if (tag)
					{
						*tag = tagType;
					}
					if (tagType == TextTags::Img){
						if (imgLen){
							*imgLen = 24;
							if (mTextureAtlas){
								auto region = mTextureAtlas->GetRegion(buf);
								if (region)
								{
									auto& regionSize = region->GetSize();
									*imgLen = regionSize.x;
								}
							}
						}						
					}
					return endLen;
				}
			}
		}
		return 0;
	}