Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

correct text window height for Draw_Static_Text and cDebugDisplay

  • Loading branch information...
commit 3007f7577f23e5c7c9b8933b88d5990bb652b05b 1 parent 9d85779
@FluXy authored
View
3  smc/data/gui/layout/debugtext.layout
@@ -9,7 +9,8 @@
<Window Type="TaharezLook/StaticText" Name="text_debugmessage" >
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.14,0},{0.75,0},{0.19,0}}" />
- <Property Name="MousePassThroughEnabled" Value="True" />
+ <Property Name="MousePassThroughEnabled" Value="True" />
+ <Property Name="HorzFormatting" Value="WordWrapLeftAligned" />
</Window>
</Window>
</GUILayout>
View
4 smc/src/gui/generic.cpp
@@ -374,8 +374,10 @@ void Draw_Static_Text( const std::string &text, const Color *color_text /* = &wh
text_default->setXPosition( CEGUI::UDim( 0, ( game_res_w * 0.5f - text_width * 0.5f ) * global_upscalex ) );
text_default->moveToFront();
+ float text_height = font->getLineSpacing();
+ text_height *= 1 + std::count(text.begin(), text.end(), '\n');
// set window height
- text_default->setHeight( CEGUI::UDim( 0, (font->getFontHeight() * 2) + ( 12 * global_upscaley ) ) );
+ text_default->setHeight( CEGUI::UDim( 0, text_height + ( 12 * global_upscaley ) ) );
while( draw )
{
View
9 smc/src/gui/hud.cpp
@@ -977,13 +977,20 @@ void cDebugDisplay :: Update( void )
// update position
CEGUI::Font *font = &CEGUI::FontManager::getSingleton().get( "bluebold_medium" );
float text_width = font->getTextExtent( gui_text ) * global_downscalex;
+ float text_height = font->getLineSpacing() * global_downscaley;
+ // fixme : works only correctly for one too long line
if( text_width > 800.0f )
{
+ // add wrapped newlines
+ text_height *= 1 + static_cast<int>(text_width / 800.0f);
text_width = 800.0f;
}
- m_text_debug_text->setWidth( CEGUI::UDim( 0, ( text_width + 15 ) * global_upscalex ) );
+ // add newlines
+ text_height *= 1 + std::count(m_text.begin(), m_text.end(), '\n');
+
+ m_text_debug_text->setSize( CEGUI::UVector2( CEGUI::UDim( 0, ( text_width + 15 ) * global_upscalex ), CEGUI::UDim( 0, ( text_height + 15 ) * global_upscaley ) ) );
m_text_debug_text->setXPosition( CEGUI::UDim( 0, ( ( game_res_w * 0.5f ) - text_width * 0.5f ) * global_upscalex ) );
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.