void cMenuCore :: Draw( void ) { if( !pMenu_Data ) { return; } pMenu_Data->Draw(); // if no vsync limit the fps for not stressing CPU usage if( !pPreferences->m_video_vsync ) { Correct_Frame_Time( 100 ); } }
void Draw_Static_Text( const std::string &text, const Color *color_text /* = &white */, const Color *color_bg /* = NULL */, bool wait_for_input /* = 1 */ ) { // fixme : Can't handle multiple lines of text. Change to MultiLineEditbox or use HorzFormatting=WordWrapLeftAligned property. bool draw = 1; // Statictext window CEGUI::Window *window_statictext = CEGUI::WindowManager::getSingleton().loadWindowLayout( "statictext.layout" ); pGuiSystem->getGUISheet()->addChildWindow( window_statictext ); // get default text CEGUI::Window *text_default = static_cast<CEGUI::Window *>(CEGUI::WindowManager::getSingleton().getWindow( "text_default" )); // set text text_default->setProperty( "TextColours", CEGUI::PropertyHelper::colourToString( CEGUI::colour( static_cast<float>(color_text->red) / 255, static_cast<float>(color_text->green) / 255, static_cast<float>(color_text->blue) / 255, 1 ) ) ); CEGUI::String gui_text = reinterpret_cast<const CEGUI::utf8*>(text.c_str()); text_default->setText( gui_text ); // align text CEGUI::Font *font = &CEGUI::FontManager::getSingleton().get( "bluebold_medium" ); float text_width = font->getTextExtent( gui_text ) * global_downscalex; text_default->setWidth( CEGUI::UDim( 0, ( text_width + 15 ) * global_upscalex ) ); 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, text_height + ( 12 * global_upscaley ) ) ); while( draw ) { Draw_Game(); // draw background if( color_bg ) { // create request cRect_Request *request = new cRect_Request(); pVideo->Draw_Rect( NULL, 0.9f, color_bg, request ); request->m_render_count = wait_for_input ? 4 : 1; // add request pRenderer->Add( request ); } pVideo->Render(); if( wait_for_input ) { while( SDL_PollEvent( &input_event ) ) { if( input_event.type == SDL_KEYDOWN || input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_MOUSEBUTTONDOWN ) { draw = 0; } } // if vsync is disabled then limit the fps to reduce the CPU usage if( !pPreferences->m_video_vsync ) { Correct_Frame_Time( 100 ); } } else { draw = 0; } pFramerate->Update(); } // Clear possible active input if( wait_for_input ) { Clear_Input_Events(); } pGuiSystem->getGUISheet()->removeChildWindow( window_statictext ); CEGUI::WindowManager::getSingleton().destroyWindow( window_statictext ); }