- bugfix for font height calc

- updated intro
This commit is contained in:
Mark Vejvoda
2011-10-07 19:53:07 +00:00
parent af2abb57b8
commit e090df259d
3 changed files with 82 additions and 30 deletions

View File

@@ -96,9 +96,16 @@ Intro::Intro(Program *program):
int showIntroPicsTime = showIntroPicturesNode->getAttribute("time")->getIntValue(); int showIntroPicsTime = showIntroPicturesNode->getAttribute("time")->getIntValue();
bool showIntroPicsRandom = showIntroPicturesNode->getAttribute("random")->getBoolValue(); bool showIntroPicsRandom = showIntroPicturesNode->getAttribute("random")->getBoolValue();
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), Intro::appearTime)); int displayItemNumber = 1;
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), Intro::appearTime, coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D())); int appear= Intro::appearTime;
texts.push_back(Text("www.megaglest.org", Vec2i(w/2, h/2), Intro::showTime+Intro::appearTime+Intro::disapearTime, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); int disappear= Intro::showTime+Intro::appearTime+Intro::disapearTime;
texts.push_back(new Text("based on the award winning Glest", Vec2i(w/2, h/2), appear, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
texts.push_back(new Text("the MegaGlest team presents...", Vec2i(w/2, h/2), disappear, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
texts.push_back(new Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), disappear *(++displayItemNumber)));
texts.push_back(new Text(glestVersionString, Vec2i(w/2+45, h/2-45), disappear *(displayItemNumber++), coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D()));
texts.push_back(new Text("www.megaglest.org", Vec2i(w/2, h/2), disappear *(displayItemNumber++), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
if(showIntroPics > 0 && coreData.getMiscTextureList().size() > 0) { if(showIntroPics > 0 && coreData.getMiscTextureList().size() > 0) {
const int showMiscTime = showIntroPicsTime; const int showMiscTime = showIntroPicsTime;
@@ -137,30 +144,33 @@ Intro::Intro(Program *program):
Texture2D *tex = intoTexList[i]; Texture2D *tex = intoTexList[i];
//printf("tex # %d [%s]\n",i,tex->getPath().c_str()); //printf("tex # %d [%s]\n",i,tex->getPath().c_str());
if(i == 0) { Vec2i texPlacement;
texts.push_back(Text(tex, Vec2i(1, h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); if(i == 0 || i % 9 == 0) {
texPlacement = Vec2i(1, h-tex->getTextureHeight());
} }
if(i == 1) { else if(i == 1 || i % 9 == 1) {
texts.push_back(Text(tex, Vec2i(1, 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(1, 1);
} }
if(i == 2) { else if(i == 2 || i % 9 == 2) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(w-tex->getTextureWidth(), 1);
} }
if(i == 3) { else if(i == 3 || i % 9 == 3) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(w-tex->getTextureWidth(), h-tex->getTextureHeight());
} }
if(i == 4) { else if(i == 4 || i % 9 == 4) {
texts.push_back(Text(tex, Vec2i(w/2 - tex->getTextureWidth()/2, h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(w/2 - tex->getTextureWidth()/2, h-tex->getTextureHeight());
} }
if(i == 5) { else if(i == 5 || i % 9 == 5) {
texts.push_back(Text(tex, Vec2i(w/2 - tex->getTextureWidth()/2, 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(w/2 - tex->getTextureWidth()/2, 1);
} }
if(i == 6) { else if(i == 6 || i % 9 == 6) {
texts.push_back(Text(tex, Vec2i(1, (h/2) - (tex->getTextureHeight()/2)), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(1, (h/2) - (tex->getTextureHeight()/2));
} }
if(i == 7) { else if(i == 7 || i % 9 == 7) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), (h/2) - (tex->getTextureHeight()/2)), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1)))); texPlacement = Vec2i(w-tex->getTextureWidth(), (h/2) - (tex->getTextureHeight()/2));
} }
texts.push_back(new Text(tex, texPlacement, Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), disappear *displayItemNumber+(showMiscTime*(i+1))));
} }
} }
@@ -173,6 +183,10 @@ Intro::Intro(Program *program):
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
Intro::~Intro() {
deleteValues(texts.begin(),texts.end());
}
void Intro::update(){ void Intro::update(){
timer++; timer++;
if(timer > introTime * GameConstants::updateFps / 1000){ if(timer > introTime * GameConstants::updateFps / 1000){
@@ -205,8 +219,21 @@ void Intro::render() {
renderer.reset2d(); renderer.reset2d();
renderer.clearBuffers(); renderer.clearBuffers();
// CoreData &coreData= CoreData::getInstance();
// renderer.renderTextureQuad(
// 1, 1,
// 1, 1,
// coreData.getLogoTexture(), 1.0);
// renderer.renderFPSWhenEnabled(lastFps);
// renderer.renderText3D(
// "test 123", coreData.getMenuFontVeryBig3D(), 1.0,
// 1, 1, true);
for(int i = 0; i < texts.size(); ++i) { for(int i = 0; i < texts.size(); ++i) {
Text *text= &texts[i]; Text *text= texts[i];
difTime= 1000 * timer / GameConstants::updateFps - text->getTime(); difTime= 1000 * timer / GameConstants::updateFps - text->getTime();

View File

@@ -72,7 +72,7 @@ private:
static int disapearTime; static int disapearTime;
private: private:
vector<Text> texts; vector<Text *> texts;
int timer; int timer;
int mouseX; int mouseX;
int mouseY; int mouseY;
@@ -80,6 +80,8 @@ private:
public: public:
Intro(Program *program); Intro(Program *program);
virtual ~Intro();
virtual void update(); virtual void update();
virtual void render(); virtual void render();
virtual void keyDown(char key); virtual void keyDown(char key);

View File

@@ -299,7 +299,8 @@ float TextFTGL::LineHeight(const char* str, const int len) {
//return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight(); //return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight();
//return ftFont->LineHeight(); //return ftFont->LineHeight();
static float result = -1000; //static float result = -1000;
float result = -1000;
if(result == -1000) { if(result == -1000) {
FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str()); FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str());
@@ -321,6 +322,28 @@ float TextFTGL::LineHeight(const char* str, const int len) {
} }
//printf("ftFont->BBox(''yW'')%f\n",result); //printf("ftFont->BBox(''yW'')%f\n",result);
} }
// else {
// FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str());
//
// GLenum error = glGetError();
// if(error != GL_NO_ERROR) {
// printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n",__FILE__,__FUNCTION__,__LINE__,error,gluErrorString(error),str);
// fflush(stdout);
// }
//
// int newresult = box.Upper().Y()- box.Lower().Y();
// if(newresult == 0) {
// newresult = ftFont->LineHeight();
//
// GLenum error = glGetError();
// if(error != GL_NO_ERROR) {
// printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n",__FILE__,__FUNCTION__,__LINE__,error,gluErrorString(error),str);
// fflush(stdout);
// }
// }
//
// printf("Height for [%s] result [%d] [%d]\n",str,result,newresult);
// }
if(ftFont->Error()) { if(ftFont->Error()) {
char szBuf[1024]=""; char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error()); sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());