Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void draw_text(int x, int y, unsigned long font, std::string string, bool text_centered, color colour)
- {
- DWORD const BuffSize = MultiByteToWideChar(CP_UTF8, 0, string.c_str(), string.length(), NULL, NULL);
- if (!BuffSize)
- return;
- std::vector<wchar_t> Buffer;
- Buffer.resize(BuffSize);
- if(!MultiByteToWideChar( CP_UTF8, 0, string.c_str(), -1, &Buffer[0], BuffSize ))
- return;
- int width, height;
- interfaces::surface->get_text_size( font, Buffer.data(), width, height );
- interfaces::surface->set_text_color( colour.r, colour.g, colour.b, colour.a );
- interfaces::surface->draw_text_font( font );
- if ( text_centered )
- interfaces::surface->draw_text_pos( x - ( width / 2 ), y );
- else
- interfaces::surface->draw_text_pos( x, y );
- interfaces::surface->draw_render_text( Buffer.data(), Buffer.size() );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement