X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameDraw.cpp;h=a6b02a5ff748f91cc2d64914da7cc0afcad63713;hb=26debbd380c6922e5a0b60d99567c6374a4fef9a;hp=ad674461ca94485f982766aecd10cb6d02ad0505;hpb=b757d628d06570c93feb2f485b7a9f9b8134ca25;p=lugaru.git diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index ad67446..a6b02a5 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -25,10 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Awards.h" #include "Menu.h" -#include - -using namespace std; - extern XYZ viewer; extern int environment; extern float texscale; @@ -76,7 +72,6 @@ extern bool vertexweird[6]; extern bool velocityblur; extern bool debugmode; extern int mainmenu; -extern int oldmainmenu; extern int bloodtoggle; extern int difficulty; extern bool decals; @@ -112,6 +107,15 @@ extern bool gamestarted; extern bool showdamagebar; + + +int drawtoggle = 0; +int numboundaries = 0; +XYZ boundary[360]; +int change = 0; + + + enum drawmodes { normalmode, motionblurmode, radialzoommode, realmotionblurmode, doublevisionmode, glowmode, @@ -124,9 +128,12 @@ void Game::flash() { // shouldn't be that way, these should be attributes and Pe flashamount=1; flashdelay=1; } + +void DrawMenu(); + /*********************> DrawGLScene() <*****/ int Game::DrawGLScene(StereoSide side) -{ +{ static float texcoordwidth,texcoordheight; static float texviewwidth, texviewheight; static int i,j,k,l; @@ -137,6 +144,7 @@ int Game::DrawGLScene(StereoSide side) static char string[256]=""; static char string2[256]=""; static char string3[256]=""; + static int drawmode = 0; if ( stereomode == stereoAnaglyph ) { switch(side) { @@ -172,7 +180,7 @@ int Game::DrawGLScene(StereoSide side) static int changed; changed=0; - olddrawmode=drawmode; + int olddrawmode=drawmode; if(ismotionblur&&!loading){ if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){ drawmode=motionblurmode; @@ -252,7 +260,7 @@ int Game::DrawGLScene(StereoSide side) static XYZ terrainlight; static float distance; if(drawmode==normalmode) - ReSizeGLScene(90,.1f); + Game::ReSizeGLScene(90,.1f); if(drawmode!=normalmode) glViewport(0,0,texviewwidth,texviewheight); glDepthFunc(GL_LEQUAL); @@ -275,12 +283,12 @@ int Game::DrawGLScene(StereoSide side) //shake glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1); //sway - glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0); - glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0); + glRotatef(pitch+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0); + glRotatef(yaw+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0); } if(cameramode||freeze||winfreeze){ - glRotatef(rotation2,1,0,0); - glRotatef(rotation,0,1,0); + glRotatef(pitch,1,0,0); + glRotatef(yaw,0,1,0); } if(environment==desertenvironment){ @@ -306,7 +314,7 @@ int Game::DrawGLScene(StereoSide side) glRotatef((float)(abs(Random()%100))/1000,1,0,0); glRotatef((float)(abs(Random()%100))/1000,0,1,0); } - skybox.draw(); + skybox->draw(); glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0); glPopMatrix(); glTranslatef(-viewer.x,-viewer.y,-viewer.z); @@ -321,7 +329,7 @@ int Game::DrawGLScene(StereoSide side) if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y+player[k].scale*3,player[k].coords.z,player[k].scale*7)&&player[k].occluded<25) for(i=0;i=1) glDisable(GL_BLEND); if(distance>=.5){ - checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords; + checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords; checkpoint.y+=1; if(!player[k].occluded==0) i=checkcollide(viewer,checkpoint,player[k].lastoccluded); @@ -480,7 +488,7 @@ int Game::DrawGLScene(StereoSide side) glDisable(GL_LIGHTING); glEnable(GL_BLEND); glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z); - glRotatef(hawkrotation,0,1,0); + glRotatef(hawkyaw,0,1,0); glTranslatef(25,0,0); distance=findDistancefast(&viewer,&realhawkcoords)*1.2; glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance); @@ -506,7 +514,7 @@ int Game::DrawGLScene(StereoSide side) if(distance>=1) glDisable(GL_BLEND); if(distance>=.5){ - checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords; + checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords; checkpoint.y+=1; if(!player[k].occluded==0) i=checkcollide(viewer,checkpoint,player[k].lastoccluded); @@ -583,7 +591,7 @@ int Game::DrawGLScene(StereoSide side) glColor4f(.5,.5,.5,1); if(!console) { sprintf (string, " ",(int)(fps)); - text.glPrint(10,30,string,0,.8,screenwidth,screenheight); + text->glPrint(10,30,string,0,.8,screenwidth,screenheight); if(!tutoriallevel) if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){ @@ -594,15 +602,15 @@ int Game::DrawGLScene(StereoSide side) bonus_name = "Excellent!"; // When does this happen? glColor4f(0,0,0,1-bonustime); - text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768); + text->glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768); glColor4f(1,0,0,1-bonustime); - text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768); + text->glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768); sprintf (string, "%d",(int)bonusvalue); glColor4f(0,0,0,1-bonustime); - text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768); + text->glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768); glColor4f(1,0,0,1-bonustime); - text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768); + text->glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768); glColor4f(.5,.5,.5,1); } @@ -880,26 +888,26 @@ int Game::DrawGLScene(StereoSide side) } glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); glColor4f(1,1,1,tutorialopac); - text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight); sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey)); sprintf (string2, "Press escape at any time to"); sprintf (string3, "pause or exit the tutorial."); glColor4f(0,0,0,1); - text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); glColor4f(0.5,0.5,0.5,1); - text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); } //Hot spots @@ -937,9 +945,9 @@ int Game::DrawGLScene(StereoSide side) while(!done){ if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){ glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); glColor4f(1,1,1,tutorialopac); - text.glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); lastline=i+1; line++; if(string[i]=='\0')done=1; @@ -951,8 +959,8 @@ int Game::DrawGLScene(StereoSide side) whichdialogue=hotspottype[closest]-20; for(j=0;jglPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); glColor4f(0.7,0.7,0.7,tutorialopac); - text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight); } else { glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); } tempnum=0; @@ -1081,14 +1089,14 @@ int Game::DrawGLScene(StereoSide side) if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){ if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){ glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/-4,starty-4-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/-4,starty-4-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); glColor4f(1,1,1,tutorialopac); - text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); } else { glColor4f(0,0,0,tutorialopac); - text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); } lastline=i+1; line++; @@ -1108,9 +1116,9 @@ int Game::DrawGLScene(StereoSide side) } if(!campaign)sprintf (string, "Score: %d", (int)bonustotal); glColor4f(0,0,0,1); - text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768); + text->glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768); glColor4f(1,0,0,1); - text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768); + text->glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768); if(showdamagebar) { glDisable(GL_DEPTH_TEST); // Disables Depth Testing glDisable(GL_CULL_FACE); @@ -1191,9 +1199,9 @@ int Game::DrawGLScene(StereoSide side) // writing the numbers : sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss)); glColor4f(0,0,0,1); - text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768); + text->glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768); glColor4f(1,0,0,1); - text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768); + text->glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768); } } @@ -1202,28 +1210,24 @@ int Game::DrawGLScene(StereoSide side) if((texttoggle||editorenabled)&&debugmode&&!mainmenu){ sprintf (string, "The framespersecond is %d.",(int)(fps)); - text.glPrint(10,30,string,0,.8,1024,768); - - sprintf (string, "Name: %s", registrationname); - text.glPrint(10,260,string,0,.8,1024,768); - + text->glPrint(10,30,string,0,.8,1024,768); if(editorenabled) sprintf (string, "Map editor enabled."); else sprintf (string, "Map editor disabled."); - text.glPrint(10,60,string,0,.8,1024,768); + text->glPrint(10,60,string,0,.8,1024,768); if(editorenabled){ sprintf (string, "Object size: %f",editorsize); - text.glPrint(10,75,string,0,.8,1024,768); - if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation); - else sprintf (string, "Object rotation: Random"); - text.glPrint(10,90,string,0,.8,1024,768); - if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2); - else sprintf (string, "Object rotation2: Random"); - text.glPrint(10,105,string,0,.8,1024,768); + text->glPrint(10,75,string,0,.8,1024,768); + if(editoryaw>=0)sprintf (string, "Object yaw: %f",editoryaw); + else sprintf (string, "Object yaw: Random"); + text->glPrint(10,90,string,0,.8,1024,768); + if(editorpitch>=0)sprintf (string, "Object pitch: %f",editorpitch); + else sprintf (string, "Object pitch: Random"); + text->glPrint(10,105,string,0,.8,1024,768); sprintf (string, "Object type: %d",editortype); - text.glPrint(10,120,string,0,.8,1024,768); + text->glPrint(10,120,string,0,.8,1024,768); switch(editortype) { case boxtype: sprintf (string, "(box)"); @@ -1262,15 +1266,15 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "(fire)"); break; } - text.glPrint(130,120,string,0,.8,1024,768); + text->glPrint(130,120,string,0,.8,1024,768); sprintf (string, "Numplayers: %d",numplayers); - text.glPrint(10,155,string,0,.8,1024,768); + text->glPrint(10,155,string,0,.8,1024,768); sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints); - text.glPrint(10,140,string,0,.8,1024,768); + text->glPrint(10,140,string,0,.8,1024,768); } sprintf (string, "Difficulty: %d",difficulty); - text.glPrint(10,240,string,0,.8,1024,768); + text->glPrint(10,240,string,0,.8,1024,768); } } @@ -1397,10 +1401,10 @@ int Game::DrawGLScene(StereoSide side) glColor4f(1,1,1,1); if(chatting){ sprintf (string, " ]"); - text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight); + text->glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight); if(displayblink){ sprintf (string, "_"); - text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight); + text->glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight); } } for(i=0;i<15;i++) @@ -1409,12 +1413,12 @@ int Game::DrawGLScene(StereoSide side) glColor4f(1,1,1,4-displaytime[i]); if(jglPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight); } } } - if(minimap&&indialogue==-1){ + if(difficulty<2&&indialogue==-1){ // minimap float mapviewdist = 20000; glDisable(GL_DEPTH_TEST); @@ -1492,17 +1496,17 @@ int Game::DrawGLScene(StereoSide side) glPushMatrix(); glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1); glPopMatrix(); - glRotatef(player[0].lookrotation*-1+180,0,0,1); + glRotatef(player[0].lookyaw*-1+180,0,0,1); glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0); for(i=0;itypesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist)); else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist)); @@ -1572,7 +1576,7 @@ int Game::DrawGLScene(StereoSide side) else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist)); else glColor4f(1,1,0,1); glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0); - glRotatef(player[i].rotation+180,0,0,1); + glRotatef(player[i].yaw+180,0,0,1); glScalef(.005,.005,.005); glBegin(GL_QUADS); glTexCoord2f(0,0); @@ -1643,7 +1647,7 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glColor4f(1,1,1,1); sprintf (string, "Loading..."); - text.glPrint(1024/2-90,768/2,string,1,2,1024,768); + text->glPrint(1024/2-90,768/2,string,1,2,1024,768); } loading=2; //if(ismotionblur)drawmode=motionblurmode; @@ -1693,16 +1697,16 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glColor4f(1,1,1,1); sprintf (string, "Level Cleared!"); - text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768); + text->glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768); sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal)); - text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768); if(campaign) sprintf (string, "Press Escape or Space to continue"); else sprintf (string, "Press Escape to return to menu or Space to continue"); - text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480); + text->glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480); char temp[255]; @@ -1712,14 +1716,14 @@ int Game::DrawGLScene(StereoSide side) if((int)(leveltime)%60<10)strcat(string,"0"); sprintf (temp, "%d",(int)(leveltime)%60); strcat(string,temp); - text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768); //Awards int awards[award_count]; int numawards = award_awards(awards); for (i = 0; i < numawards && i < 6; i++) - text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768); } if(drawmode!=normalmode){ @@ -1763,7 +1767,7 @@ int Game::DrawGLScene(StereoSide side) } glClear(GL_DEPTH_BUFFER_BIT); - ReSizeGLScene(90,.1f); + Game::ReSizeGLScene(90,.1f); glViewport(0,0,screenwidth,screenheight); if(drawmode!=normalmode){ @@ -1977,17 +1981,17 @@ int Game::DrawGLScene(StereoSide side) if(consoleselected>=60) offset=consoleselected-60; sprintf (string, " ]"); - text.glPrint(10,30,string,0,1,1024,768); + text->glPrint(10,30,string,0,1,1024,768); if(consoleblink){ sprintf (string, "_"); - text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); + text->glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); } for(i=0;i<15;i++) for(j=0;jglPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768); } } } @@ -2029,70 +2033,14 @@ int Game::DrawGLScene(StereoSide side) return 0; } -vector Game::ListCampaigns() { - DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns")); - struct dirent *campaign = NULL; - if(!campaigns) { - perror("Problem while loading campaigns"); - cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl; - exit(EXIT_FAILURE); - } - vector campaignNames; - while ((campaign = readdir(campaigns)) != NULL) { - string name(campaign->d_name); - if(name.length()<5) - continue; - if(!name.compare(name.length()-4,4,".txt")) { - campaignNames.push_back(name.substr(0,name.length()-4)); - } - } - closedir(campaigns); - return campaignNames; -} - -void Game::LoadCampaign() { - if(!accountactive) - return; - ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str())); - ipstream.ignore(256,':'); - int numlevels; - ipstream >> numlevels; - campaignlevels.clear(); - for(int i=0;i> cl; - campaignlevels.push_back(cl); - } - ipstream.close(); - - ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str())); - if(test.good()) { - LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0); - } else { - LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); - } - - if(accountactive->getCampaignChoicesMade()==0) { - accountactive->setCampaignScore(0); - accountactive->resetFasttime(); - } - oldmainmenu=0; //reload menu -} - -void Game::DrawMenu() { +void DrawMenu() { // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems. SDL_Delay(15); glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - ReSizeGLScene(90,.1f); - - if(oldmainmenu!=mainmenu){ - if(mainmenu==5){ - LoadCampaign(); - } - } + Game::ReSizeGLScene(90,.1f); //draw menu background glClear(GL_DEPTH_BUFFER_BIT); @@ -2130,7 +2078,7 @@ void Game::DrawMenu() { glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]); + Game::Mainmenuitems[4].bind(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(-1,-1,0); @@ -2147,257 +2095,7 @@ void Game::DrawMenu() { glPopMatrix(); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - /* - Values of mainmenu : - 1 Main menu - 2 Menu pause (resume/end game) - 3 Option menu - 4 Controls configuration menu - 5 Main game menu (choose level or challenge) - 6 Deleting user menu - 7 User managment menu (select/add) - 8 Choose difficulty menu - 9 Challenge level selection menu - 10 End of the campaign congratulation (is that really a menu?) - 11 Same that 9 ??? => unused - 18 stereo configuration - */ - - if(oldmainmenu!=mainmenu) - Menu::clearMenu(); - - switch(mainmenu) { - case 1: - case 2:{ - if(oldmainmenu!=mainmenu){ - Menu::addImage(0,Mainmenuitems[0],150,480-128,256,128); - Menu::addImageButton(1,Mainmenuitems[mainmenu==1?1:5],NULL,18,480-152-32,128,32); - Menu::addImageButton(2,Mainmenuitems[2],NULL,18,480-228-32,112,32); - Menu::addImageButton(3,Mainmenuitems[mainmenu==1?3:6],NULL,18,480-306-32,mainmenu==1?68:132,32); - } - } - break; - case 3: { - if(oldmainmenu!=mainmenu){ - Menu::addButton( 0,"",NULL,10+20,440,-1,-1); - Menu::addButton( 1,"",NULL,10+60,405,-1,-1); - Menu::addButton( 2,"",NULL,10+70,370,-1,-1); - Menu::addButton( 3,"",NULL,10+20-1000,335-1000,-1,-1); - Menu::addButton( 4,"",NULL,10 ,335,-1,-1); - Menu::addButton( 5,"",NULL,10+60,300,-1,-1); - Menu::addButton( 6,"",NULL,10+70,265,-1,-1); - Menu::addButton( 9,"",NULL,10 ,230,-1,-1); - Menu::addButton(10,"",NULL,20 ,195,-1,-1); - Menu::addButton(11,"",NULL,10+60,160,-1,-1); - Menu::addButton(13,"",NULL,30 ,125,-1,-1); - Menu::addButton( 7,"",NULL,10+15, 90,-1,-1); - Menu::addButton(12,"",NULL,10+15, 55,-1,-1); - Menu::addButton(8,"Back",NULL,10,10,-1,-1); - } - if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59) - sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight); - else - sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight); - - if(newdetail==2) sprintf (menustring[1], "Detail: High"); - else if(newdetail==1) sprintf (menustring[1], "Detail: Medium"); - else sprintf (menustring[1], "Detail: Low"); - - if(bloodtoggle==2) sprintf (menustring[2], "Blood: On, high detail (slower)"); - if(bloodtoggle==1) sprintf (menustring[2], "Blood: On, low detail"); - if(bloodtoggle==0) sprintf (menustring[2], "Blood: Off"); - - if(difficulty==2) sprintf (menustring[3], "Difficulty: Insane"); - if(difficulty==1) sprintf (menustring[3], "Difficulty: Difficult"); - if(difficulty==0) sprintf (menustring[3], "Difficulty: Easier"); - - if(ismotionblur==1) sprintf (menustring[4], "Blur Effects: Enabled (less compatible)"); - if(ismotionblur==0) sprintf (menustring[4], "Blur Effects: Disabled (more compatible)"); - - if(decals==1) sprintf (menustring[5], "Decals: Enabled (slower)"); - if(decals==0) sprintf (menustring[5], "Decals: Disabled"); - - if(musictoggle==1) sprintf (menustring[6], "Music: Enabled"); - if(musictoggle==0) sprintf (menustring[6], "Music: Disabled"); - - if(invertmouse==1) sprintf (menustring[9], "Invert mouse: Yes"); - if(invertmouse==0) sprintf (menustring[9], "Invert mouse: No"); - - sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5)); - - sprintf (menustring[11], "Volume: %d%%", (int)(volume*100)); - - sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off")); - - sprintf (menustring[7], "-Configure Controls-"); - - sprintf (menustring[12], "-Configure Stereo -"); - - if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back"); - else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)"); - - for(int i=0;i<=13;i++) - Menu::setButtonText(i,menustring[i]); - } - break; - case 4: { - if(oldmainmenu!=mainmenu){ - Menu::addButton(0,"",NULL,10 ,400,-1,-1); - Menu::addButton(1,"",NULL,10+40,360,-1,-1); - Menu::addButton(2,"",NULL,10+40,320,-1,-1); - Menu::addButton(3,"",NULL,10+30,280,-1,-1); - Menu::addButton(4,"",NULL,10+20,240,-1,-1); - Menu::addButton(5,"",NULL,10+40,200,-1,-1); - Menu::addButton(6,"",NULL,10+40,160,-1,-1); - Menu::addButton(7,"",NULL,10+30,120,-1,-1); - Menu::addButton(8,"",NULL,10+20,80,-1,-1); - if(debugmode) - Menu::addButton(9,"",NULL,10+10,40,-1,-1); - Menu::addButton(debugmode?10:9,"Back",NULL,10,10,-1,-1); - } - Menu::setButtonText(0,(string)"Forwards: "+(keyselect==0?"_":Input::keyToChar(forwardkey))); - Menu::setButtonText(1,(string)"Back: " +(keyselect==1?"_":Input::keyToChar(backkey))); - Menu::setButtonText(2,(string)"Left: " +(keyselect==2?"_":Input::keyToChar(leftkey))); - Menu::setButtonText(3,(string)"Right: " +(keyselect==3?"_":Input::keyToChar(rightkey))); - Menu::setButtonText(4,(string)"Crouch: " +(keyselect==4?"_":Input::keyToChar(crouchkey))); - Menu::setButtonText(5,(string)"Jump: " +(keyselect==5?"_":Input::keyToChar(jumpkey))); - Menu::setButtonText(6,(string)"Draw: " +(keyselect==6?"_":Input::keyToChar(drawkey))); - Menu::setButtonText(7,(string)"Throw: " +(keyselect==7?"_":Input::keyToChar(throwkey))); - Menu::setButtonText(8,(string)"Attack: " +(keyselect==8?"_":Input::keyToChar(attackkey))); - if(debugmode) - Menu::setButtonText(9,(string)"Console: "+(keyselect==9?"_":Input::keyToChar(consolekey))); - } - break; - case 5: { - if(oldmainmenu!=mainmenu){ - Menu::addLabel(-1,accountactive->getName(),5,400); - Menu::addButton(1,"Tutorial",NULL,5,300,-1,-1); - Menu::addButton(2,"Challenge",NULL,5,240,-1,-1); - Menu::addButton(3,"Delete User",NULL,400,10,-1,-1); - Menu::addButton(4,"Main Menu",NULL,5,10,-1,-1); - Menu::addButton(5,"Change User",NULL,5,180,-1,-1); - Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),NULL,200,420,-1,-1); - - //show campaign map - //with (2,-5) offset from old code - Menu::addImage(-1,Mainmenuitems[7],150+2,60-5,400,400); - //show levels - int numlevels = accountactive->getCampaignChoicesMade(); - numlevels += numlevels>0 ? campaignlevels[numlevels-1].nextlevel.size() : 1; - for(int i=0;i=accountactive->getCampaignChoicesMade(); - if(!active) - itemsize/=2; - - if(i>=1){ - XYZ start=campaignlevels[i-1].getCenter(); - Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0); - } - Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture, NULL, - midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0); - - if(active){ - Menu::addLabel(-2,campaignlevels[i].description, - campaignlevels[i].getStartX()+10, - campaignlevels[i].getStartY()-4); - Menu::setMapItem(-2); - } - } - } - } - break; - case 6: { - if(oldmainmenu!=mainmenu){ - Menu::addLabel(-1,"Are you sure you want to delete this user?",10,400); - Menu::addButton(1,"Yes",NULL,10,360,-1,-1); - Menu::addButton(2,"No",NULL,10,320,-1,-1); - } - } - break; - case 7: { - if(oldmainmenu!=mainmenu){ - Menu::addButton(0,Account::getNbAccounts()<8?"New User":"No More Users",NULL,10,400,-1,-1); - Menu::addLabel(-2,"",20,400); - Menu::addButton(Account::getNbAccounts()+1,"Back",NULL,10,10,-1,-1); - for(int i=0;igetName(),NULL,10,340-20*(i+1),-1,-1); - } - if(entername){ - Menu::setButtonText(0,displaytext[0],20,400,-1,-1); - Menu::setButtonText(-2,displayblink?"_":"",20+displayselected*10,400,-1,-1); - } - } - break; - case 8: { - if(oldmainmenu!=mainmenu){ - Menu::addButton(0,"Easier",NULL,10,400,-1,-1); - Menu::addButton(1,"Difficult",NULL,10,360,-1,-1); - Menu::addButton(2,"Insane",NULL,10,320,-1,-1); - } - } - break; - case 9: { - if(oldmainmenu!=mainmenu){ - for(int i=0;igetHighScore(i)); - for(int j=strlen(temp);j<(32-17);j++) - strcat(temp," "); - name+=temp; - sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60)); - if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0"); - name+=temp; - sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60); - name+=temp; - - Menu::addButton(i,name,NULL,10,400-i*25,-1,-1,i>accountactive->getProgress()?0.5:1,0,0); - } - - Menu::addButton(-1," High Score Best Time",NULL,10,440,-1,-1); - Menu::addButton(numchallengelevels,"Back",NULL,10,10,-1,-1); - } - } - break; - case 10: { - if(oldmainmenu!=mainmenu){ - Menu::addLabel(0,"Congratulations!",220,330); - Menu::addLabel(1,"You have avenged your family and",140,300); - Menu::addLabel(2,"restored peace to the island of Lugaru.",110,270); - Menu::addButton(3,"Back",NULL,10,10,-1,-1); - sprintf(menustring[4],"Your score: %d",(int)accountactive->getCampaignScore()); - sprintf(menustring[5],"Highest score: %d",(int)accountactive->getCampaignHighScore()); - Menu::addLabel(4,menustring[4],190,200); - Menu::addLabel(5,menustring[5],190,180); - } - } - break; - case 18: { - if(oldmainmenu!=mainmenu){ - Menu::addButton(0,"",NULL,70,400,-1,-1); - Menu::addButton(1,"",NULL,10,360,-1,-1); - Menu::addButton(2,"",NULL,40,320,-1,-1); - Menu::addButton(3,"Back",NULL,10,10,-1,-1); - } - sprintf(menustring[0], "Stereo mode: %s", StereoModeName(newstereomode)); - sprintf(menustring[1], "Stereo separation: %.3f", stereoseparation); - sprintf(menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No"); - Menu::setButtonText(0,menustring[0]); - Menu::setButtonText(1,menustring[1]); - Menu::setButtonText(2,menustring[2]); - } - } - - oldmainmenu=mainmenu; - selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight); - Menu::GUITick(this); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix @@ -2408,7 +2106,7 @@ void Game::DrawMenu() { glLoadIdentity(); // Reset The Modelview Matrix glEnable(GL_TEXTURE_2D); - Menu::drawItems(this); + Menu::drawItems(); //draw mouse cursor glMatrixMode(GL_PROJECTION); // Select The Projection Matrix @@ -2433,14 +2131,14 @@ void Game::DrawMenu() { glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glPopMatrix(); - if(!waiting) { // hide the cursor while waiting for a key + if(!Game::waiting) { // hide the cursor while waiting for a key glPushMatrix(); - glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0); + glTranslatef(Game::mousecoordh-screenwidth/2,Game::mousecoordv*-1+screenheight/2,0); glScalef((float)screenwidth/64,(float)screenwidth/64,1); glTranslatef(1,-1,0); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); - glBindTexture( GL_TEXTURE_2D, cursortexture); + Game::cursortexture.bind(); glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS);