Mercurial > fife-parpg
comparison engine/core/view/renderers/floatingtextrenderer.cpp @ 482:16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 29 Apr 2010 13:51:45 +0000 |
parents | 90005975cdbb |
children | 7b451e3b2439 |
comparison
equal
deleted
inserted
replaced
481:1f37adc9a685 | 482:16c2b3ee59ce |
---|---|
62 } | 62 } |
63 | 63 |
64 FloatingTextRenderer::~FloatingTextRenderer() { | 64 FloatingTextRenderer::~FloatingTextRenderer() { |
65 } | 65 } |
66 | 66 |
67 void FloatingTextRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { | 67 void FloatingTextRenderer::render(Camera* cam, Layer* layer, RenderList& instances) { |
68 if (!m_font) { | 68 if (!m_font) { |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 std::vector<Instance*>::const_iterator instance_it = instances.begin(); | 72 RenderList::const_iterator instance_it = instances.begin(); |
73 const std::string* saytext = NULL; | 73 const std::string* saytext = NULL; |
74 | 74 |
75 for (;instance_it != instances.end(); ++instance_it) { | 75 for (;instance_it != instances.end(); ++instance_it) { |
76 Instance* instance = *instance_it; | 76 Instance* instance = (*instance_it)->instance; |
77 saytext = instance->getSayText(); | 77 saytext = instance->getSayText(); |
78 if (saytext) { | 78 if (saytext) { |
79 InstanceVisual* visual = instance->getVisual<InstanceVisual>(); | 79 const Rect& ir = (*instance_it)->dimensions; |
80 const Rect& ir = visual->getCacheItem(cam).dimensions; | |
81 m_font->setColor(25,25,112); | 80 m_font->setColor(25,25,112); |
82 Image* img = m_font->getAsImageMultiline(*saytext); | 81 Image* img = m_font->getAsImageMultiline(*saytext); |
83 Rect r; | 82 Rect r; |
84 r.x = (ir.x + ir.w/2) - img->getWidth()/2; /// the center of the text rect is always aligned to the instance's rect center. | 83 r.x = (ir.x + ir.w/2) - img->getWidth()/2; /// the center of the text rect is always aligned to the instance's rect center. |
85 r.y = ir.y- img->getHeight(); /// make the text rect floating higher than the instance. | 84 r.y = ir.y- img->getHeight(); /// make the text rect floating higher than the instance. |