mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 07:31:21 +02:00
- added a few new chinese fonts and changed default to a new font
- fixed location of player title in menus - added better ftgl error checking
This commit is contained in:
@@ -330,7 +330,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||||||
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
|
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
|
||||||
|
|
||||||
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
|
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
|
||||||
labelPlayers[i].init(xoffset+0, setupPos-30-i*rowHeight);
|
labelPlayers[i].init(xoffset-20, setupPos-30-i*rowHeight);
|
||||||
labelPlayers[i].setEditable(false);
|
labelPlayers[i].setEditable(false);
|
||||||
|
|
||||||
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
||||||
|
@@ -427,7 +427,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||||||
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
|
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
|
||||||
|
|
||||||
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
|
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
|
||||||
labelPlayers[i].init(xoffset+0, setupPos-30-i*rowHeight);
|
labelPlayers[i].init(xoffset-20, setupPos-30-i*rowHeight);
|
||||||
|
|
||||||
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
||||||
labelPlayerNames[i].init(xoffset+50,setupPos-30-i*rowHeight);
|
labelPlayerNames[i].init(xoffset+50,setupPos-30-i*rowHeight);
|
||||||
|
@@ -82,7 +82,9 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
|||||||
|
|
||||||
ftFont->FaceSize(24,TextFTGL::faceResolution);
|
ftFont->FaceSize(24,TextFTGL::faceResolution);
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error setting face size");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
//ftFont->UseDisplayList(false);
|
//ftFont->UseDisplayList(false);
|
||||||
//ftFont->CharMap(ft_encoding_gb2312);
|
//ftFont->CharMap(ft_encoding_gb2312);
|
||||||
@@ -92,7 +94,9 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error setting encoding");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +157,9 @@ void TextFTGL::init(string fontName, int fontSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error setting face size");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ftFont->UseDisplayList(false);
|
//ftFont->UseDisplayList(false);
|
||||||
@@ -163,21 +169,32 @@ void TextFTGL::init(string fontName, int fontSize) {
|
|||||||
throw runtime_error("FTGL: error setting encoding");
|
throw runtime_error("FTGL: error setting encoding");
|
||||||
}
|
}
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error setting encoding");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a string containing common characters
|
// Create a string containing common characters
|
||||||
// and preload the chars without rendering them.
|
// and preload the chars without rendering them.
|
||||||
string preloadText = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-=!@#$%^&*()_+:\"{}[]/?.,<>\\';";
|
string preloadText = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-=!@#$%^&*()_+:\"{}[]/?.,<>\\';";
|
||||||
ftFont->Advance(preloadText.c_str());
|
ftFont->Advance(preloadText.c_str());
|
||||||
|
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error advancing(a), #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFTGL::SetFaceSize(int value) {
|
void TextFTGL::SetFaceSize(int value) {
|
||||||
ftFont->FaceSize(value,TextFTGL::faceResolution);
|
ftFont->FaceSize(value,TextFTGL::faceResolution);
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error setting face size");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextFTGL::GetFaceSize() {
|
int TextFTGL::GetFaceSize() {
|
||||||
return ftFont->FaceSize();
|
return ftFont->FaceSize();
|
||||||
}
|
}
|
||||||
@@ -192,13 +209,21 @@ void TextFTGL::Render(const char* str, const int len) {
|
|||||||
ftFont->Render(str, len);
|
ftFont->Render(str, len);
|
||||||
|
|
||||||
if(ftFont->Error()) {
|
if(ftFont->Error()) {
|
||||||
throw runtime_error("FTGL: error trying to render");
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float TextFTGL::Advance(const char* str, const int len) {
|
float TextFTGL::Advance(const char* str, const int len) {
|
||||||
return ftFont->Advance(str, len);
|
float result = ftFont->Advance(str, len);
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to advance(b), #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
//FTBBox box = ftFont->BBox(str);
|
//FTBBox box = ftFont->BBox(str);
|
||||||
//float urx = box.Upper().X();
|
//float urx = box.Upper().X();
|
||||||
@@ -242,6 +267,12 @@ float TextFTGL::LineHeight(const char* str, const int len) {
|
|||||||
}
|
}
|
||||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||||
}
|
}
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
||||||
// return result;
|
// return result;
|
||||||
@@ -281,6 +312,12 @@ float TextFTGL::LineHeight(const wchar_t* str, const int len) {
|
|||||||
}
|
}
|
||||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||||
}
|
}
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,11 +328,24 @@ void TextFTGL::Render(const wchar_t* str, const int len) {
|
|||||||
*/
|
*/
|
||||||
if(len != 0) {
|
if(len != 0) {
|
||||||
ftFont->Render(str, len);
|
ftFont->Render(str, len);
|
||||||
|
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float TextFTGL::Advance(const wchar_t* str, const int len) {
|
float TextFTGL::Advance(const wchar_t* str, const int len) {
|
||||||
return ftFont->Advance(str, len);
|
float result = ftFont->Advance(str, len);
|
||||||
|
if(ftFont->Error()) {
|
||||||
|
char szBuf[1024]="";
|
||||||
|
sprintf(szBuf,"FTGL: error trying to advance(c), #%d",ftFont->Error());
|
||||||
|
throw runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TextFTGL::findFont(const char *firstFontToTry) {
|
const char* TextFTGL::findFont(const char *firstFontToTry) {
|
||||||
|
Reference in New Issue
Block a user