本文整理汇总了C++中CStr::AfterLast方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::AfterLast方法的具体用法?C++ CStr::AfterLast怎么用?C++ CStr::AfterLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStr
的用法示例。
在下文中一共展示了CStr::AfterLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDrawCallCache
void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName, const CRect& Size, int CellID, std::map<CStr, CGUISprite*>& Sprites)
{
// This is called only when something has changed (like the size of the
// sprite), so it doesn't need to be particularly efficient.
// Clean up the old data
Calls.clear();
// If this object has zero size, there's nothing to render. (This happens
// with e.g. tooltips that have zero size before they're first drawn, so
// it isn't necessarily an error.)
if (Size.left == Size.right && Size.top == Size.bottom)
return;
std::map<CStr, CGUISprite*>::iterator it(Sprites.find(SpriteName));
if (it == Sprites.end())
{
/*
* Sprite not found. Check whether this a special sprite,
* and if so create a new sprite:
* "stretched:filename.ext" - stretched image
* "stretched:grayscale:filename.ext" - stretched grayscale image.
* "cropped:0.5, 0.25" - stretch this ratio (x,y) of the top left of the image
* "color:r g b a" - solid color
* > "textureAsMask" - when using color, use the (optional) texture alpha channel as mask.
* These can be combined, but they must be separated by a ":"
* so you can have a white overlay over an stretched grayscale image with:
* "grayscale:color:255 255 255 100:stretched:filename.ext"
*/
// Check that this can be a special sprite.
if (SpriteName.ReverseFind(":") == -1 && SpriteName.Find("color(") == -1)
{
LOGERROR("Trying to use a sprite that doesn't exist (\"%s\").", SpriteName.c_str());
return;
}
CGUISprite* Sprite = new CGUISprite;
VfsPath TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.AfterLast(":"));
if (SpriteName.Find("stretched:") != -1)
{
// TODO: Should check (nicely) that this is a valid file?
SGUIImage* Image = new SGUIImage;
Image->m_TextureName = TextureName;
// Allow grayscale images for disabled portraits
if (SpriteName.Find("grayscale:") != -1)
{
Image->m_Effects = new SGUIImageEffects;
Image->m_Effects->m_Greyscale = true;
}
CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
Image->m_Size = ca;
Image->m_TextureSize = ca;
Sprite->AddImage(Image);
Sprites[SpriteName] = Sprite;
}
else if (SpriteName.Find("cropped:") != -1)
{
// TODO: Should check (nicely) that this is a valid file?
SGUIImage* Image = new SGUIImage;
CStr info = SpriteName.AfterLast("cropped:").BeforeFirst(":");
double xRatio = info.BeforeFirst(",").ToDouble();
double yRatio = info.AfterLast(",").ToDouble();
Image->m_TextureName = TextureName;
CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
CClientArea cb(CRect(0, 0, 0, 0), CRect(0, 0, 100/xRatio, 100/yRatio));
Image->m_Size = ca;
Image->m_TextureSize = cb;
Sprite->AddImage(Image);
Sprites[SpriteName] = Sprite;
}
if (SpriteName.Find("color:") != -1)
{
CStrW value = wstring_from_utf8(SpriteName.AfterLast("color:").BeforeFirst(":"));
CColor color;
// Check color is valid
if (!GUI<CColor>::ParseString(value, color))
{
LOGERROR("GUI: Error parsing sprite 'color' (\"%s\")", utf8_from_wstring(value));
return;
}
SGUIImage* Image = new SGUIImage;
// If we are using a mask, this is an effect.
// Otherwise we can fallback to the "back color" attribute
// TODO: we are assuming there is a filename here.
if (SpriteName.Find("textureAsMask:") != -1)
{
Image->m_TextureName = TextureName;
Image->m_Effects = new SGUIImageEffects;
//.........这里部分代码省略.........