From 5a2114009384796e51bb08cf8d0fad05ad392fe0 Mon Sep 17 00:00:00 2001 From: quantumstate Date: Sun, 18 Mar 2012 19:43:03 +0000 Subject: [PATCH] Added grayscale option for ui textures This was SVN commit r11364. --- source/gui/GUIRenderer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp index 89fa4d3803..7ffc0c6d70 100644 --- a/source/gui/GUIRenderer.cpp +++ b/source/gui/GUIRenderer.cpp @@ -76,6 +76,7 @@ void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, const CStr& SpriteName, { // Sprite not found. Check whether this a special sprite: // "stretched:filename.ext" - stretched image + // "stretched:grayscale:filename.ext" - stretched grayscale image // "colour:r g b a" - solid colour // // and if so, try to create it as a new sprite. @@ -83,8 +84,18 @@ void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, const CStr& SpriteName, { // TODO: Should check (nicely) that this is a valid file? SGUIImage Image; - - Image.m_TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.substr(10)); + + // Allow grayscale images for disabled portraits + if (SpriteName.substr(10, 10) == "grayscale:") + { + Image.m_TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.substr(20)); + Image.m_Effects = new SGUIImageEffects; + Image.m_Effects->m_Greyscale = true; + } + else + { + Image.m_TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.substr(10)); + } CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100)); Image.m_Size = ca;