mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-23 13:21:33 +00:00
Added a method to rasterfont, to parse strings for newlines. Fixes the statistics overlay in opengl plugin.
The string stuff is somewhat WIP, as I want to add support for TAB character handling (and maybe others). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@156 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
627695c667
commit
a1f48fee94
@ -353,7 +353,8 @@ void Renderer::ProcessMessages()
|
|||||||
int left = 25, top = 15;
|
int left = 25, top = 15;
|
||||||
list<MESSAGE>::iterator it = s_listMsgs.begin();
|
list<MESSAGE>::iterator it = s_listMsgs.begin();
|
||||||
|
|
||||||
while( it != s_listMsgs.end() ) {
|
while( it != s_listMsgs.end() )
|
||||||
|
{
|
||||||
DrawText(it->str, left+1, top+1, 0xff000000);
|
DrawText(it->str, left+1, top+1, 0xff000000);
|
||||||
DrawText(it->str, left, top, 0xffffff30);
|
DrawText(it->str, left, top, 0xffffff30);
|
||||||
top += 15;
|
top += 15;
|
||||||
@ -368,7 +369,7 @@ void Renderer::ProcessMessages()
|
|||||||
void Renderer::DrawText(const char* pstr, int left, int top, u32 color)
|
void Renderer::DrawText(const char* pstr, int left, int top, u32 color)
|
||||||
{
|
{
|
||||||
glColor3f(((color>>16) & 0xff)/255.0f, ((color>>8) & 0xff)/255.0f, (color & 0xff)/255.0f);
|
glColor3f(((color>>16) & 0xff)/255.0f, ((color>>8) & 0xff)/255.0f, (color & 0xff)/255.0f);
|
||||||
s_pfont->printString(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0);
|
s_pfont->printStuff(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0,nBackbufferHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetAA(int aa)
|
void Renderer::SetAA(int aa)
|
||||||
|
@ -172,3 +172,40 @@ void RasterFont::printCenteredString(const char *s, double y, int screen_width,
|
|||||||
printString(s, x, y, z);
|
printString(s, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RasterFont::printStuff(const char *text, double x, double start_y, double z, int bbHeight)
|
||||||
|
{
|
||||||
|
double y=start_y;
|
||||||
|
|
||||||
|
static char temp[1024];
|
||||||
|
char* t = temp;
|
||||||
|
|
||||||
|
while(*text)
|
||||||
|
{
|
||||||
|
if(*text=='\n')
|
||||||
|
{
|
||||||
|
*t=0;
|
||||||
|
printString(temp,x,y,z);
|
||||||
|
y-=char_height * 2.0f / bbHeight;
|
||||||
|
t=temp;
|
||||||
|
}
|
||||||
|
else if(*text=='\r')
|
||||||
|
{
|
||||||
|
t=temp;
|
||||||
|
}
|
||||||
|
else if(*text=='\t')
|
||||||
|
{
|
||||||
|
//todo: add tabs every something like 4*char_width
|
||||||
|
*(t++)=' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(t++)=*text;
|
||||||
|
}
|
||||||
|
text++;
|
||||||
|
}
|
||||||
|
if(t!=text)
|
||||||
|
{
|
||||||
|
*t=0;
|
||||||
|
printString(temp,x,y,z);
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,8 @@ public:
|
|||||||
// and the happy helper functions
|
// and the happy helper functions
|
||||||
void printString(const char *s, double x, double y, double z=0.0);
|
void printString(const char *s, double x, double y, double z=0.0);
|
||||||
void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
|
void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
|
||||||
|
|
||||||
|
void printStuff(const char *text, double x, double y, double z, int bbHeight);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user