@@ -148,6 +148,15 @@ void VanillaTechTreeRenderer::Draw(DirectDrawBufferData *drawBuffer, int offsetX
148148 // Lock surface of draw buffer
149149 drawBuffer->LockAssociatedSurface (1 );
150150
151+ // Clear area that is probably not filled by background graphics (else there may be ridiculously looking parts of previously drawn elements)
152+ if (_legendFrameHeight - offsetY < _windowSize.Y )
153+ {
154+ // Get full tree height and determine size of area to be cleared
155+ int fullTreeHeight = GetFullHeight ();
156+ if (fullTreeHeight - _legendFrameHeight > 0 )
157+ drawBuffer->DrawFilledRectangle (0 , _legendFrameHeight - offsetY, _windowSize.X , _windowSize.Y , 125 ); // Clear area
158+ }
159+
151160 // Draw background tiles (only for visible area)
152161 int treeWidthInPixels = _treeWidth * (64 + ELEMENT_SPACING);
153162 int tileCount = treeWidthInPixels / _tileFrameWidth;
@@ -681,8 +690,8 @@ int VanillaTechTreeRenderer::GetFullWidth()
681690
682691int VanillaTechTreeRenderer::GetFullHeight ()
683692{
684- // TODO
685- return _legendFrameHeight;
693+ // Calculate estimated tree height
694+ return std::max ( _legendFrameHeight, _verticalDrawOffsets[_ageCount * 2 - 1 ] + 64 + ELEMENT_SPACING) ;
686695}
687696
688697const Rect* VanillaTechTreeRenderer::GetCivBonusLabelRectangle ()
@@ -790,7 +799,7 @@ void VanillaTechTreeRenderer::SetSelectedElement(TechTreeElement *element)
790799
791800 // Compute parent elements of selected element to draw the selection path
792801 std::function<bool (TechTreeElement *)> getElementPathRecursively;
793- getElementPathRecursively = [this , element, &getElementPathRecursively](TechTreeElement *currElement)
802+ getElementPathRecursively = [this , element, &getElementPathRecursively] (TechTreeElement *currElement)
794803 {
795804 // Push onto the path stack
796805 _selectedElementPath.push_back (currElement);
0 commit comments