Ticket #616: colour_special_sprite.patch
File colour_special_sprite.patch, 1.9 KB (added by , 14 years ago) |
---|
-
source/gui/GUIRenderer.cpp
20 20 #include "GUIRenderer.h" 21 21 22 22 #include "graphics/TextureManager.h" 23 #include "gui/GUIutil.h" 23 24 #include "lib/ogl.h" 24 25 #include "lib/utf8.h" 25 26 #include "lib/res/h_mgr.h" … … 371 372 if (it == Sprites.end()) 372 373 { 373 374 // Sprite not found. Check whether this a special sprite: 374 // stretched:filename.ext 375 // <currently that's the only one> 375 // stretched:filename.ext - stretched image 376 // colour:r g b a - solid color 377 // 376 378 // and if so, try to create it as a new sprite. 377 379 if (SpriteName.substr(0, 10) == "stretched:") 378 380 { 381 // TODO: Should check (nicely) that this is a valid file? 379 382 SGUIImage Image; 380 383 Image.m_TextureName = VfsPath(L"art/textures/ui")/wstring_from_utf8(SpriteName.substr(10)); 381 384 CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100)); … … 390 393 it = Sprites.find(SpriteName); 391 394 debug_assert(it != Sprites.end()); // The insertion above shouldn't fail 392 395 } 396 else if(SpriteName.substr(0, 7) == "colour:") 397 { 398 SGUIImage image; 399 CStrW value = wstring_from_utf8(SpriteName.substr(7)); 400 CColor color; 401 402 // Check color is valid 403 if (!GUI<CColor>::ParseString(value, color)) 404 { 405 LOGERROR(L"GUI: Error parsing sprite 'colour' (\"%ls\")", value.c_str()); 406 return; 407 } 408 else 409 { 410 image.m_BackColor = color; 411 412 CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100)); 413 image.m_Size = ca; 414 image.m_TextureSize = ca; 415 416 CGUISprite Sprite; 417 Sprite.AddImage(image); 418 419 Sprites[SpriteName] = Sprite; 420 421 it = Sprites.find(SpriteName); 422 debug_assert(it != Sprites.end()); // The insertion above shouldn't fail 423 } 424 } 393 425 else 394 426 { 395 427 // Otherwise, just complain and give up: