2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
85 extern float bonusvalue;
86 extern float bonustotal;
87 extern float bonustime;
89 extern float startbonustotal;
90 extern float bonusnum[100];
91 extern int tutoriallevel;
92 extern float smoketex;
93 extern float tutorialstagetime;
94 extern float tutorialmaxtime;
95 extern int tutorialstage;
96 extern bool againbonus;
97 extern float damagedealt;
98 extern bool invertmouse;
100 extern int numhotspots;
101 extern int winhotspot;
102 extern int killhotspot;
103 extern XYZ hotspot[40];
104 extern int hotspottype[40];
105 extern float hotspotsize[40];
106 extern char hotspottext[40][256];
107 extern int currenthotspot;;
109 extern bool campaign;
110 extern bool winfreeze;
112 extern float menupulse;
114 extern bool gamestart;
116 extern int numdialogues;
117 extern int numdialogueboxes[max_dialogues];
118 extern int dialoguetype[max_dialogues];
119 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
120 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
121 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
122 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
123 extern char dialoguename[max_dialogues][max_dialoguelength][64];
124 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
125 extern XYZ participantlocation[max_dialogues][10];
126 extern int participantfocus[max_dialogues][max_dialoguelength];
127 extern int participantaction[max_dialogues][max_dialoguelength];
128 extern float participantrotation[max_dialogues][10];
129 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
130 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
131 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
132 extern int indialogue;
133 extern int whichdialogue;
134 extern int directing;
135 extern float dialoguetime;
136 extern int dialoguegonethrough[20];
138 extern bool gamestarted;
140 extern bool showdamagebar;
142 extern int channels[100];
143 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
145 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
152 /*********************> DrawGLScene() <*****/
153 int Game::DrawGLScene(StereoSide side)
155 static float texcoordwidth,texcoordheight;
156 static float texviewwidth, texviewheight;
158 static GLubyte color;
159 static float newbrightness;
160 static float changespeed;
161 static XYZ checkpoint;
162 static float tempmult;
164 static char string[256]="";
165 static char string2[256]="";
166 static char string3[256]="";
168 static float lastcheck;
170 lastcheck+=multiplier;
172 if ( stereomode == stereoAnaglyph ) {
174 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
175 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
178 glColorMask( 1.0, 1.0, 1.0, 1.0 );
180 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
181 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
185 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
192 numboundaries=mapradius*2;
193 if(numboundaries>360)numboundaries=360;
194 for(i=0;i<numboundaries;i++){
197 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
206 olddrawmode=drawmode;
207 if(ismotionblur&&!loading){
208 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
209 drawmode=motionblurmode;
210 motionbluramount=200/(findLengthfast(&player[0].velocity));
213 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
214 drawmode=doublevisionmode;
221 drawmode=motionblurmode;
223 slomodelay-=multiplier;
224 if(slomodelay<0)slomo=0;
228 if((!changed&&!slomo)||loading){
230 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
231 if(olddrawmode!=realmotionblurmode)change=1;
233 drawmode=realmotionblurmode;
235 else if(olddrawmode==realmotionblurmode)change=2;
239 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
240 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
242 if(winfreeze||mainmenu)drawmode=normalmode;
245 if(drawmode==glowmode){
250 DSpContext_FadeGamma(NULL,200,&color2);
254 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
258 texviewwidth=kTextureSize;
259 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
260 texviewheight=kTextureSize;
261 if(texviewheight>screenheight)texviewheight=screenheight;
263 texcoordwidth=screenwidth/kTextureSize;
264 texcoordheight=screenheight/kTextureSize;
265 if(texcoordwidth>1)texcoordwidth=1;
266 if(texcoordheight>1)texcoordheight=1;
269 glDrawBuffer(GL_BACK);
270 glReadBuffer(GL_BACK);
272 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
273 blurness=targetblurness;
274 targetblurness=(float)(abs(Random()%100))/40;
276 if(blurness<targetblurness)
277 blurness+=multiplier*5;
279 blurness-=multiplier*5;
282 static XYZ terrainlight;
283 static float distance;
284 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
285 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
286 glDepthFunc(GL_LEQUAL);
288 glAlphaFunc(GL_GREATER, 0.0001f);
289 glEnable(GL_ALPHA_TEST);
290 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
291 glClear(GL_DEPTH_BUFFER_BIT);
293 glMatrixMode (GL_MODELVIEW);
294 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
297 // Move the camera for the current eye's point of view.
298 // Reverse the movement if we're reversing stereo
299 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
301 if(!cameramode&&!freeze&&!winfreeze){
302 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
303 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
304 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
306 if(cameramode||freeze||winfreeze){
307 glRotatef(rotation2,1,0,0);
308 glRotatef(rotation,0,1,0);
311 if(environment==desertenvironment){
312 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
313 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
315 SetUpLight(&light,0);
317 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
318 if(environment==desertenvironment){
319 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
320 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
323 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
325 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
326 frustum.GetFrustum();
330 static float size,opacity,rotation;
332 for(k=0;k<numplayers;k++){
333 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
334 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)
335 for(i=0;i<player[k].skeleton.num_joints;i++){
336 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
337 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
339 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
340 if(k!=0&&tutoriallevel==1){
341 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
343 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
344 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
345 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
346 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
347 point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
350 if(k!=0&&tutoriallevel==1){
351 opacity=.2+.2*sin(smoketex*6+i);
353 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
358 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
359 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
360 for(i=0;i<player[k].skeleton.num_joints;i++){
361 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin||player[k].skeleton.joints[i].label==leftelbow||player[k].skeleton.joints[i].label==rightelbow||player[k].skeleton.joints[i].label==neck){
362 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
363 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
365 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
366 if(k!=0&&tutoriallevel==1){
367 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
369 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
370 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
371 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
372 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
373 if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
374 else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
377 if(k!=0&&tutoriallevel==1){
378 opacity=.2+.2*sin(smoketex*6+i);
380 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
386 if(!player[k].playerdetail)
387 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
389 point=player[k].coords;
391 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
392 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
393 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
394 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
395 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
398 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
404 glEnable(GL_TEXTURE_2D);
406 glEnable(GL_DEPTH_TEST);
407 glEnable(GL_CULL_FACE);
409 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
410 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
411 glBindTexture( GL_TEXTURE_2D, terraintexture);
413 glBindTexture( GL_TEXTURE_2D, terraintexture2);
415 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
416 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
419 terrain.drawdecals();
422 glEnable(GL_CULL_FACE);
423 glEnable(GL_LIGHTING);
425 glEnable(GL_TEXTURE_2D);
428 glEnable(GL_COLOR_MATERIAL);
443 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
444 glEnable(GL_CULL_FACE);
445 glCullFace(GL_FRONT);
447 for(k=0;k<numplayers;k++){
448 if(k==0||tutoriallevel!=1){
450 glEnable(GL_LIGHTING);
451 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
452 distance=findDistancefast(&viewer,&player[k].coords);
453 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
454 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
455 if(distance>=1)glDisable(GL_BLEND);
457 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;
459 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
460 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
462 player[k].occluded+=1;
463 player[k].lastoccluded=i;
465 else player[k].occluded=0;
466 if(player[k].occluded<25)player[k].DrawSkeleton();
472 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
473 else playerdist=-100;
476 glEnable(GL_TEXTURE_2D);
481 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
482 glAlphaFunc(GL_GREATER, 0.0001f);
484 glDisable(GL_CULL_FACE);
485 glDisable(GL_LIGHTING);
487 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
488 glRotatef(hawkrotation,0,1,0);
489 glTranslatef(25,0,0);
490 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
491 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
492 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
493 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
494 hawk.drawdifftex(hawktexture);
498 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
499 glEnable(GL_CULL_FACE);
500 glCullFace(GL_FRONT);
502 for(k=0;k<numplayers;k++){
503 if(!(k==0||tutoriallevel!=1)){
505 glEnable(GL_LIGHTING);
506 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
507 distance=findDistancefast(&viewer,&player[k].coords);
508 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
509 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
510 if(distance>=1)glDisable(GL_BLEND);
512 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;
514 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
515 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
517 player[k].occluded+=1;
518 player[k].lastoccluded=i;
520 else player[k].occluded=0;
521 if(player[k].occluded<25)player[k].DrawSkeleton();
527 glEnable(GL_TEXTURE_2D);
532 glDisable(GL_COLOR_MATERIAL);
534 glDisable(GL_LIGHTING);
535 glDisable(GL_TEXTURE_2D);
543 glDisable(GL_LIGHTING);
544 glDisable(GL_TEXTURE_2D);
545 glDisable(GL_COLOR_MATERIAL);
548 for(k=0;k<numplayers;k++){
549 if(player[k].numwaypoints>1){
550 glBegin(GL_LINE_LOOP);
551 for(i=0;i<player[k].numwaypoints;i++){
552 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
561 for(k=0;k<numpathpoints;k++){
562 if(numpathpointconnect[k]){
563 for(i=0;i<numpathpointconnect[k];i++){
564 glBegin(GL_LINE_LOOP);
565 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
566 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
574 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
581 glEnable(GL_TEXTURE_2D);
582 glColor4f(.5,.5,.5,1);
584 sprintf (string, " ",(int)(fps));
585 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
588 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
589 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
590 else if(bonus==backstab)sprintf (string, "Backstabber!");
591 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
592 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
593 else if(bonus==style)sprintf (string, "Style Bonus!");
594 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
595 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
596 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
597 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
598 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
599 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
600 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
601 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
602 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
603 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
604 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
605 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
606 else if(bonus==Reversal)sprintf (string, "Reversal!");
607 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
608 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
609 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
610 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
611 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
612 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
613 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
614 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
615 else sprintf (string, "Excellent!");
617 glColor4f(0,0,0,1-bonustime);
618 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
619 glColor4f(1,0,0,1-bonustime);
620 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
622 sprintf (string, "%d",(int)bonusvalue);
623 glColor4f(0,0,0,1-bonustime);
624 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
625 glColor4f(1,0,0,1-bonustime);
626 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
627 glColor4f(.5,.5,.5,1);
630 if(tutoriallevel==1){
631 tutorialopac=tutorialmaxtime-tutorialstagetime;
632 if(tutorialopac>1)tutorialopac=1;
633 if(tutorialopac<0)tutorialopac=0;
635 sprintf (string, " ");
636 sprintf (string2, " ");
637 sprintf (string3, " ");
638 if(tutorialstage==0){
639 sprintf (string, " ");
640 sprintf (string2, " ");
641 sprintf (string3, " ");
643 if(tutorialstage==1){
644 sprintf (string, "Welcome to the Lugaru training level!");
645 sprintf (string2, " ");
646 sprintf (string3, " ");
648 if(tutorialstage==2){
649 sprintf (string, "BASIC MOVEMENT:");
650 sprintf (string2, " ");
651 sprintf (string3, " ");
653 if(tutorialstage==3){
654 sprintf (string, "You can move the mouse to rotate the camera.");
655 sprintf (string2, " ");
656 sprintf (string3, " ");
658 if(tutorialstage==4){
659 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
660 sprintf (string2, "All movement is relative to the camera.");
661 sprintf (string3, " ");
663 if(tutorialstage==5){
664 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
665 sprintf (string2, "You can hold it longer to jump higher.");
666 sprintf (string3, " ");
668 if(tutorialstage==6){
669 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
670 sprintf (string2, "You can jump higher from a crouching position.");
671 sprintf (string3, " ");
673 if(tutorialstage==7){
674 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
675 sprintf (string2, " ");
676 sprintf (string3, " ");
678 if(tutorialstage==8){
679 sprintf (string, "While crouching, you can sneak around silently");
680 sprintf (string2, "using the movement keys.");
681 sprintf (string3, " ");
683 if(tutorialstage==9){
684 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
685 sprintf (string2, "to run animal-style.");
686 sprintf (string3, " ");
688 if(tutorialstage==10){
689 sprintf (string, "ADVANCED MOVEMENT:");
690 sprintf (string2, " ");
691 sprintf (string3, " ");
693 if(tutorialstage==11){
694 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
695 sprintf (string2, "during impact to perform a walljump.");
696 sprintf (string3, "Be sure to use the movement keys to press against the wall");
698 if(tutorialstage==12){
699 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
700 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
701 sprintf (string3, " ");
703 if(tutorialstage==13){
704 sprintf (string, "BASIC COMBAT:");
705 sprintf (string2, " ");
706 sprintf (string3, " ");
708 if(tutorialstage==14){
709 sprintf (string, "There is now an imaginary enemy");
710 sprintf (string2, "in the middle of the training area.");
711 sprintf (string3, " ");
713 if(tutorialstage==15){
714 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
715 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
716 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
717 sprintf (string3, " ");
719 if(tutorialstage==16){
720 sprintf (string, "If you are close, you will perform a weak punch.");
721 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
722 sprintf (string3, " ");
724 if(tutorialstage==17){
725 sprintf (string, "Attacking while running results in a spin kick.");
726 sprintf (string2, "This is one of your most powerful ground attacks.");
727 sprintf (string3, " ");
729 if(tutorialstage==18){
730 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
731 sprintf (string2, "This is a very fast attack, and easy to follow up.");
732 sprintf (string3, " ");
734 if(tutorialstage==19){
735 sprintf (string, "When an enemy is on the ground, you can deal some extra");
736 sprintf (string2, "damage by running up and drop-kicking him.");
737 sprintf (string3, "(Try knocking them down with a sweep first)");
739 if(tutorialstage==20){
740 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
741 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
742 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
743 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
745 if(tutorialstage==21){
746 sprintf (string, "This attack is devastating if timed correctly.");
747 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
748 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
749 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
751 if(tutorialstage==22){
752 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
753 sprintf (string2, "him instantly. Move close behind this enemy");
754 sprintf (string3, "and attack.");
756 if(tutorialstage==23){
757 sprintf (string, "Another important attack is the wall kick. When an enemy");
758 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
759 sprintf (string3, "the attack key during impact with the wall.");
761 if(tutorialstage==24){
762 sprintf (string, "You can tackle enemies by running at them animal-style");
763 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
764 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
765 sprintf (string3, "This is especially useful when they are running away.");
767 if(tutorialstage==25){
768 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
769 sprintf (string2, "against enemies with swords or other long weapons.");
770 sprintf (string3, " ");
772 if(tutorialstage==26){
773 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
774 sprintf (string2, " ");
775 sprintf (string3, " ");
777 if(tutorialstage==27){
778 sprintf (string, "The enemy can now reverse your attacks.");
779 sprintf (string2, " ");
780 sprintf (string3, " ");
782 if(tutorialstage==28){
783 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
784 sprintf (string2, "catches your attack and uses it against you. Hold");
785 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
787 if(tutorialstage==29){
788 sprintf (string, "Try escaping from two more reversals in a row.");
789 sprintf (string2, " ");
790 sprintf (string3, " ");
792 if(tutorialstage==30){
793 sprintf (string, "Good!");
794 sprintf (string2, " ");
795 sprintf (string3, " ");
797 if(tutorialstage==31){
798 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
799 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
800 sprintf (string3, "this is especially important against armed opponents.");
802 if(tutorialstage==32){
803 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
804 sprintf (string2, "This imaginary opponents attacks will be highlighted");
805 sprintf (string3, "to make this easier.");
807 if(tutorialstage==33){
808 sprintf (string, "Reverse three enemy attacks!");
809 sprintf (string2, " ");
810 sprintf (string3, " ");
812 if(tutorialstage==34){
813 sprintf (string, "Reverse two more enemy attacks!");
814 sprintf (string2, " ");
815 sprintf (string3, " ");
817 if(tutorialstage==35){
818 sprintf (string, "Reverse one more enemy attack!");
819 sprintf (string2, " ");
820 sprintf (string3, " ");
822 if(tutorialstage==36){
823 sprintf (string, "Excellent!");
824 sprintf (string2, " ");
825 sprintf (string3, " ");
827 if(tutorialstage==37){
828 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
829 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
830 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
832 if(tutorialstage==38){
833 sprintf (string, "WEAPONS:");
834 sprintf (string2, " ");
835 sprintf (string3, " ");
837 if(tutorialstage==39){
838 sprintf (string, "There is now an imaginary knife");
839 sprintf (string2, "in the center of the training area.");
840 sprintf (string3, " ");
842 if(tutorialstage==40){
843 sprintf (string, "Stand, roll or handspring over the knife");
844 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
845 sprintf (string3, "You can crouch and press the same key to drop it again.");
847 if(tutorialstage==41){
848 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
849 sprintf (string2, "Sometimes it is best to keep them unequipped to");
850 sprintf (string3, "prevent enemies from taking them. ");
852 if(tutorialstage==42){
853 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
854 sprintf (string2, "You can equip or unequip it while standing, crouching,");
855 sprintf (string3, "running or flipping.");
857 if(tutorialstage==43){
858 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
859 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
860 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
862 if(tutorialstage==44){
863 sprintf (string, "The enemy now has your knife!");
864 sprintf (string2, "Please reverse two of his knife attacks.");
865 sprintf (string3, " ");
867 if(tutorialstage==45){
868 sprintf (string, "Please reverse one more of his knife attacks.");
869 sprintf (string2, " ");
870 sprintf (string3, " ");
872 if(tutorialstage==46){
873 sprintf (string, "Now he has a sword!");
874 sprintf (string2, "The sword has longer reach than your arms, so you");
875 sprintf (string3, "must move close to reverse the sword slash.");
877 if(tutorialstage==47){
878 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
879 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
880 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
882 if(tutorialstage==48){
883 sprintf (string, "The staff is like the sword, but has two main attacks.");
884 sprintf (string2, "The standing smash is fast and effective, and the running");
885 sprintf (string3, "spin smash is slower and more powerful.");
887 if(tutorialstage==49){
888 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
889 sprintf (string2, "It is possible to throw the knife while flipping,");
890 sprintf (string3, "but it is very inaccurate.");
892 if(tutorialstage==50){
893 sprintf (string, "You now know everything you can learn from training.");
894 sprintf (string2, "Everything else you must learn from experience!");
895 sprintf (string3, " ");
897 if(tutorialstage==51){
898 sprintf (string, "Walk out of the training area to return to the main menu.");
899 sprintf (string2, " ");
900 sprintf (string3, " ");
903 glColor4f(0,0,0,tutorialopac);
904 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);
905 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);
906 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);
907 glColor4f(1,1,1,tutorialopac);
908 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
909 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);
910 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);
912 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
913 sprintf (string2, "Press escape at any time to");
914 sprintf (string3, "pause or exit the tutorial.");
917 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);
918 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);
919 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);
920 glColor4f(0.5,0.5,0.5,1);
921 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
922 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);
923 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);
927 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
929 float closestdist=-1;
931 closest=currenthotspot;
932 for(i=0;i<numhotspots;i++){
933 distance=findDistancefast(&player[0].coords,&hotspot[i]);
934 if(closestdist==-1||distance<closestdist){
935 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
936 closestdist=distance;
942 currenthotspot=closest;
943 if(currenthotspot!=-1){
944 if(hotspottype[closest]<=10){
945 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
948 tutorialopac=tutorialmaxtime-tutorialstagetime;
949 if(tutorialopac>1)tutorialopac=1;
950 if(tutorialopac<0)tutorialopac=0;
952 sprintf (string, "%s", hotspottext[closest]);
959 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
960 glColor4f(0,0,0,tutorialopac);
961 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);
962 glColor4f(1,1,1,tutorialopac);
963 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);
966 if(string[i]=='\0')done=1;
972 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
973 whichdialogue=hotspottype[closest]-20;
974 for(j=0;j<numdialogueboxes[whichdialogue];j++){
975 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
976 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
977 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
978 player[participantfocus[whichdialogue][j]].velocity=0;
979 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
980 player[participantfocus[whichdialogue][j]].targetframe=0;
984 dialoguegonethrough[whichdialogue]++;
985 if(dialogueboxsound[whichdialogue][indialogue]!=0){
986 static float gLoc[3];
988 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
989 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
990 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
995 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
996 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
997 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
998 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
999 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1000 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1001 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1002 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1003 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1004 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1005 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1006 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1007 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1008 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1009 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1010 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1011 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1012 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1013 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1014 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1015 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1016 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1017 OPENAL_SetVolume(channels[whichsoundplay], 256);
1018 OPENAL_SetPaused(channels[whichsoundplay], false);
1024 if(indialogue!=-1&&!mainmenu){
1025 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1026 glDisable(GL_CULL_FACE);
1027 glDisable(GL_LIGHTING);
1028 glDisable(GL_TEXTURE_2D);
1030 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1031 glPushMatrix(); // Store The Projection Matrix
1032 glLoadIdentity(); // Reset The Projection Matrix
1033 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1034 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1035 glPushMatrix(); // Store The Modelview Matrix
1036 glLoadIdentity(); // Reset The Modelview Matrix
1037 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1038 glScalef(screenwidth,screenheight/4,1);
1039 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1042 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1044 glVertex3f(0, 0, 0.0f);
1045 glVertex3f(1, 0, 0.0f);
1046 glVertex3f(1, 1, 0.0f);
1047 glVertex3f(0, 1, 0.0f);
1049 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1050 glPopMatrix(); // Restore The Old Projection Matrix
1051 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1052 glPopMatrix(); // Restore The Old Projection Matrix
1053 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1054 glEnable(GL_CULL_FACE);
1055 glDisable(GL_BLEND);
1057 glEnable(GL_TEXTURE_2D);
1064 startx=screenwidth*1/5;
1065 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1066 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1075 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1076 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1078 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1082 tempname[tempnum]='\0';
1085 sprintf (string, "%s: ", tempname);
1087 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1088 glColor4f(0,0,0,tutorialopac);
1089 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1090 glColor4f(0.7,0.7,0.7,tutorialopac);
1091 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1095 glColor4f(0,0,0,tutorialopac);
1096 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1100 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1101 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1102 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1105 sprintf (string, "%s", tempname);
1112 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1113 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1114 glColor4f(0,0,0,tutorialopac);
1115 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);
1116 glColor4f(1,1,1,tutorialopac);
1117 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1121 glColor4f(0,0,0,tutorialopac);
1122 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1126 if(string[i]=='\0')done=1;
1133 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1136 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1138 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1140 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1142 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1144 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1146 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1147 glDisable(GL_CULL_FACE);
1148 glDisable(GL_LIGHTING);
1149 glDisable(GL_TEXTURE_2D);
1151 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1152 glPushMatrix(); // Store The Projection Matrix
1153 glLoadIdentity(); // Reset The Projection Matrix
1154 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1155 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1156 glPushMatrix(); // Store The Modelview Matrix
1157 glLoadIdentity(); // Reset The Modelview Matrix
1158 glTranslatef(15,screenheight*17.5/20,0);
1159 glScalef(screenwidth/3+20,screenheight/20,1);
1160 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1162 glColor4f(0.0,0.4,0.0,0.7);
1163 float bar=((float)player[0].damage)/player[0].damagetolerance;
1165 glVertex3f((bar<1?bar:1),0,0.0f);
1166 glVertex3f(1,0,0.0f);
1167 glVertex3f(1,1,0.0f);
1168 glVertex3f((bar<1?bar:1),1,0.0f);
1170 glColor4f(0.1,0.0,0.0,1);
1171 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1173 glVertex3f(0,0,0.0f);
1174 glVertex3f((bar<1?bar:1),0,0.0f);
1175 glVertex3f((bar<1?bar:1),1,0.0f);
1176 glVertex3f(0,1,0.0f);
1178 glColor4f(0.4,0.0,0.0,0.7);
1179 bar = ((float)player[0].damage)/player[0].damagetolerance;
1181 glVertex3f(0,0,0.0f);
1182 glVertex3f((bar<1?bar:1),0,0.0f);
1183 glVertex3f((bar<1?bar:1),1,0.0f);
1184 glVertex3f(0,1,0.0f);
1186 glColor4f(0.4,0.0,0.0,0.7);
1187 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1189 glVertex3f(0,0,0.0f);
1190 glVertex3f((bar<1?bar:1),0,0.0f);
1191 glVertex3f((bar<1?bar:1),1,0.0f);
1192 glVertex3f(0,1,0.0f);
1194 glColor4f(0.4,0.0,0.0,0.7);
1195 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1197 glVertex3f(0,0,0.0f);
1198 glVertex3f((bar<1?bar:1),0,0.0f);
1199 glVertex3f((bar<1?bar:1),1,0.0f);
1200 glVertex3f(0,1,0.0f);
1202 glColor4f(0.0,0.0,0.0,0.7);
1204 glBegin(GL_LINE_STRIP);
1205 glVertex3f(0,0,0.0f);
1206 glVertex3f(1,0,0.0f);
1207 glVertex3f(1,1,0.0f);
1208 glVertex3f(0,1,0.0f);
1209 glVertex3f(0,0,0.0f);
1212 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1213 glPopMatrix(); // Restore The Old Projection Matrix
1214 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1215 glPopMatrix(); // Restore The Old Projection Matrix
1216 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1217 glEnable(GL_CULL_FACE);
1218 glDisable(GL_BLEND);
1220 glEnable(GL_TEXTURE_2D);
1222 // writing the numbers :
1223 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1225 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1227 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1231 glColor4f(.5,.5,.5,1);
1234 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1235 sprintf (string, "The framespersecond is %d.",(int)(fps));
1236 text.glPrint(10,30,string,0,.8,1024,768);
1238 sprintf (string, "Name: %s", registrationname);
1239 text.glPrint(10,260,string,0,.8,1024,768);
1243 sprintf (string, "Map editor enabled.");
1245 sprintf (string, "Map editor disabled.");
1246 text.glPrint(10,60,string,0,.8,1024,768);
1248 sprintf (string, "Object size: %f",editorsize);
1249 text.glPrint(10,75,string,0,.8,1024,768);
1250 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1251 else sprintf (string, "Object rotation: Random");
1252 text.glPrint(10,90,string,0,.8,1024,768);
1253 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1254 else sprintf (string, "Object rotation2: Random");
1255 text.glPrint(10,105,string,0,.8,1024,768);
1256 sprintf (string, "Object type: %d",editortype);
1257 text.glPrint(10,120,string,0,.8,1024,768);
1258 switch(editortype) {
1260 sprintf (string, "(box)");
1263 sprintf (string, "(tree)");
1266 sprintf (string, "(wall)");
1269 sprintf (string, "(weird)");
1272 sprintf (string, "(spike)");
1275 sprintf (string, "(rock)");
1278 sprintf (string, "(bush)");
1281 sprintf (string, "(tunnel)");
1284 sprintf (string, "(chimney)");
1287 sprintf (string, "(platform)");
1290 sprintf (string, "(cool)");
1293 sprintf (string, "(fire)");
1296 text.glPrint(130,120,string,0,.8,1024,768);
1298 sprintf (string, "Numplayers: %d",numplayers);
1299 text.glPrint(10,155,string,0,.8,1024,768);
1300 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1301 text.glPrint(10,140,string,0,.8,1024,768);
1303 sprintf (string, "Difficulty: %d",difficulty);
1304 text.glPrint(10,240,string,0,.8,1024,768);
1309 if(drawmode==glowmode){
1310 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1311 glDisable(GL_CULL_FACE);
1312 glDisable(GL_LIGHTING);
1313 glDisable(GL_TEXTURE_2D);
1315 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1316 glPushMatrix(); // Store The Projection Matrix
1317 glLoadIdentity(); // Reset The Projection Matrix
1318 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1319 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1320 glPushMatrix(); // Store The Modelview Matrix
1321 glLoadIdentity(); // Reset The Modelview Matrix
1322 glScalef(screenwidth,screenheight,1);
1323 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1325 glColor4f(0,0,0,.5);
1327 glVertex3f(0, 0, 0.0f);
1328 glVertex3f(256, 0, 0.0f);
1329 glVertex3f(256, 256, 0.0f);
1330 glVertex3f(0, 256, 0.0f);
1332 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1333 glPopMatrix(); // Restore The Old Projection Matrix
1334 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1335 glPopMatrix(); // Restore The Old Projection Matrix
1336 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1337 glEnable(GL_CULL_FACE);
1338 glDisable(GL_BLEND);
1342 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1343 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1344 glDisable(GL_CULL_FACE);
1345 glDisable(GL_LIGHTING);
1346 glDisable(GL_TEXTURE_2D);
1348 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1349 glPushMatrix(); // Store The Projection Matrix
1350 glLoadIdentity(); // Reset The Projection Matrix
1351 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1352 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1353 glPushMatrix(); // Store The Modelview Matrix
1354 glLoadIdentity(); // Reset The Modelview Matrix
1355 glScalef(screenwidth,screenheight,1);
1356 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1358 if(player[0].dead)blackout+=multiplier*3;
1359 if(player[0].dead==1)blackout=.4f;
1360 if(player[0].dead==2&&blackout>.6)blackout=.6;
1361 glColor4f(0,0,0,blackout);
1362 if(!player[0].dead){
1363 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1364 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1365 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1368 glColor4f(0,0,0,player[0].blooddimamount*.3);
1369 blackout=player[0].blooddimamount*.3;
1372 if(console)glColor4f(.7,0,0,.2);
1374 glVertex3f(0, 0, 0.0f);
1375 glVertex3f(256, 0, 0.0f);
1376 glVertex3f(256, 256, 0.0f);
1377 glVertex3f(0, 256, 0.0f);
1379 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1380 glPopMatrix(); // Restore The Old Projection Matrix
1381 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1382 glPopMatrix(); // Restore The Old Projection Matrix
1383 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1384 glEnable(GL_CULL_FACE);
1385 glDisable(GL_BLEND);
1389 if(flashamount>0&&damageeffects){
1390 if(flashamount>1)flashamount=1;
1391 if(flashdelay<=0)flashamount-=multiplier;
1393 if(flashamount<0)flashamount=0;
1394 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1395 glDisable(GL_CULL_FACE);
1396 glDisable(GL_LIGHTING);
1398 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1399 glPushMatrix(); // Store The Projection Matrix
1400 glLoadIdentity(); // Reset The Projection Matrix
1401 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1402 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1403 glPushMatrix(); // Store The Modelview Matrix
1404 glLoadIdentity(); // Reset The Modelview Matrix
1405 glScalef(screenwidth,screenheight,1);
1406 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1408 glColor4f(flashr,flashg,flashb,flashamount);
1410 glVertex3f(0, 0, 0.0f);
1411 glVertex3f(256, 0, 0.0f);
1412 glVertex3f(256, 256, 0.0f);
1413 glVertex3f(0, 256, 0.0f);
1415 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1416 glPopMatrix(); // Restore The Old Projection Matrix
1417 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1418 glPopMatrix(); // Restore The Old Projection Matrix
1419 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1420 glEnable(GL_CULL_FACE);
1421 glDisable(GL_BLEND);
1427 glEnable(GL_TEXTURE_2D);
1430 sprintf (string, " ]");
1431 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1433 sprintf (string, "_");
1434 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1438 if((i!=0||chatting)&&displaytime[i]<4)
1439 for(j=0;j<displaychars[i];j++){
1440 glColor4f(1,1,1,4-displaytime[i]);
1441 if(j<displaychars[i]){
1442 sprintf (string, "%c",displaytext[i][j]);
1443 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1449 if(minimap&&indialogue==-1){
1450 float mapviewdist = 20000;
1452 glDisable(GL_DEPTH_TEST);
1453 glColor3f (1.0, 1.0, 1.0); // no coloring
1455 glEnable(GL_TEXTURE_2D);
1456 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1457 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1458 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1459 glDisable(GL_CULL_FACE);
1460 glDisable(GL_LIGHTING);
1462 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1463 glPushMatrix(); // Store The Projection Matrix
1464 glLoadIdentity(); // Reset The Projection Matrix
1465 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1466 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1467 glPushMatrix(); // Store The Modelview Matrix
1468 glLoadIdentity(); // Reset The Modelview Matrix
1469 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1470 glTranslatef(1.75,.25,0);
1471 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1479 int numliveplayers=0;
1481 for(i=0;i<numplayers;i++){
1482 if(!player[i].dead) numliveplayers++;
1487 for(i=0;i<objects.numobjects;i++){
1488 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1489 center+=objects.position[i];
1493 for(i=0;i<numplayers;i++){
1494 if(!player[i].dead)center+=player[i].coords;
1496 center/=numadd+numliveplayers;
1498 center=player[0].coords;
1500 float maxdistance=0;
1503 for(i=0;i<objects.numobjects;i++){
1504 tempdist=findDistancefast(¢er,&objects.position[i]);
1505 if(tempdist>maxdistance){
1507 maxdistance=tempdist;
1510 for(i=0;i<numplayers;i++){
1511 if(!player[i].dead){
1512 tempdist=findDistancefast(¢er,&player[i].coords);
1513 if(tempdist>maxdistance){
1515 maxdistance=tempdist;
1519 radius=fast_sqrt(maxdistance);
1523 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1525 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1527 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1528 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1529 for(i=0;i<objects.numobjects;i++){
1530 if(objects.type[i]==treetrunktype){
1531 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1532 if(distcheck<mapviewdist){
1533 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1534 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1536 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1537 glRotatef(objects.rotation[i],0,0,1);
1538 glScalef(.003,.003,.003);
1541 glVertex3f(-1, -1, 0.0f);
1543 glVertex3f(1, -1, 0.0f);
1545 glVertex3f(1, 1, 0.0f);
1547 glVertex3f(-1, 1, 0.0f);
1552 if(objects.type[i]==boxtype){
1553 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1554 if(distcheck<mapviewdist){
1555 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1556 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1558 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1559 glRotatef(objects.rotation[i],0,0,1);
1560 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1563 glVertex3f(-1, -1, 0.0f);
1565 glVertex3f(1, -1, 0.0f);
1567 glVertex3f(1, 1, 0.0f);
1569 glVertex3f(-1, 1, 0.0f);
1576 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1577 for(i=0;i<numboundaries;i++){
1578 glColor4f(0,0,0,opac/3);
1580 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1581 glScalef(.002,.002,.002);
1584 glVertex3f(-1, -1, 0.0f);
1586 glVertex3f(1, -1, 0.0f);
1588 glVertex3f(1, 1, 0.0f);
1590 glVertex3f(-1, 1, 0.0f);
1595 for(i=0;i<numplayers;i++){
1596 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1597 if(distcheck<mapviewdist){
1599 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1600 if(i==0)glColor4f(1,1,1,opac);
1601 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1602 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1603 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1604 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1605 else glColor4f(1,1,0,1);
1606 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1607 glRotatef(player[i].rotation+180,0,0,1);
1608 glScalef(.005,.005,.005);
1611 glVertex3f(-1, -1, 0.0f);
1613 glVertex3f(1, -1, 0.0f);
1615 glVertex3f(1, 1, 0.0f);
1617 glVertex3f(-1, 1, 0.0f);
1623 glDisable(GL_TEXTURE_2D);
1624 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1625 glPopMatrix(); // Restore The Old Projection Matrix
1626 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1627 glPopMatrix(); // Restore The Old Projection Matrix
1628 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1629 glEnable(GL_CULL_FACE);
1630 glDisable(GL_BLEND);
1634 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1635 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1636 glDisable(GL_CULL_FACE);
1637 glDisable(GL_LIGHTING);
1638 glDisable(GL_TEXTURE_2D);
1640 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1641 glPushMatrix(); // Store The Projection Matrix
1642 glLoadIdentity(); // Reset The Projection Matrix
1643 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1644 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1645 glPushMatrix(); // Store The Modelview Matrix
1646 glLoadIdentity(); // Reset The Modelview Matrix
1647 glScalef(screenwidth,screenheight,1);
1648 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1650 glColor4f(0,0,0,.7);
1652 glVertex3f(0, 0, 0.0f);
1653 glVertex3f(256, 0, 0.0f);
1654 glVertex3f(256, 256, 0.0f);
1655 glVertex3f(0, 256, 0.0f);
1657 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1658 glPopMatrix(); // Restore The Old Projection Matrix
1659 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1660 glPopMatrix(); // Restore The Old Projection Matrix
1661 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1662 glEnable(GL_CULL_FACE);
1663 glDisable(GL_BLEND);
1667 glDisable(GL_DEPTH_TEST);
1668 glColor3f (1.0, 1.0, 1.0); // no coloring
1670 glEnable(GL_TEXTURE_2D);
1675 glEnable(GL_TEXTURE_2D);
1677 sprintf (string, "Loading...");
1678 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1681 //if(ismotionblur)drawmode=motionblurmode;
1682 drawmode=normalmode;
1685 if(winfreeze&&!campaign){
1686 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1687 glDisable(GL_CULL_FACE);
1688 glDisable(GL_LIGHTING);
1689 glDisable(GL_TEXTURE_2D);
1691 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1692 glPushMatrix(); // Store The Projection Matrix
1693 glLoadIdentity(); // Reset The Projection Matrix
1694 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1695 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1696 glPushMatrix(); // Store The Modelview Matrix
1697 glLoadIdentity(); // Reset The Modelview Matrix
1698 glScalef(screenwidth,screenheight,1);
1699 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1701 glColor4f(0,0,0,.4);
1703 glVertex3f(0, 0, 0.0f);
1704 glVertex3f(256, 0, 0.0f);
1705 glVertex3f(256, 256, 0.0f);
1706 glVertex3f(0, 256, 0.0f);
1708 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1709 glPopMatrix(); // Restore The Old Projection Matrix
1710 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1711 glPopMatrix(); // Restore The Old Projection Matrix
1712 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1713 glEnable(GL_CULL_FACE);
1714 glDisable(GL_BLEND);
1718 glDisable(GL_DEPTH_TEST);
1719 glColor3f (1.0, 1.0, 1.0); // no coloring
1721 glEnable(GL_TEXTURE_2D);
1723 //Win Screen Won Victory
1725 glEnable(GL_TEXTURE_2D);
1727 sprintf (string, "Level Cleared!");
1728 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1730 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1731 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1734 sprintf (string, "Press Escape or Space to continue");
1736 sprintf (string, "Press Escape to return to menu or Space to continue");
1737 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1741 for(i=0;i<255;i++)string[i]='\0';
1742 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1743 strcat(string,temp);
1744 if((int)(leveltime)%60<10)strcat(string,"0");
1745 sprintf (temp, "%d",(int)(leveltime)%60);
1746 strcat(string,temp);
1747 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1750 int awards[award_count];
1751 int numawards = award_awards(awards);
1753 for (i = 0; i < numawards && i < 6; i++)
1754 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1757 if(drawmode!=normalmode){
1758 glEnable(GL_TEXTURE_2D);
1760 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1763 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1764 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1765 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1766 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1767 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1768 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1769 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1771 glBindTexture( GL_TEXTURE_2D, screentexture);
1772 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1775 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1777 glBindTexture( GL_TEXTURE_2D, screentexture2);
1778 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1780 if(!screentexture2){
1781 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1783 glGenTextures( 1, &screentexture2 );
1784 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1786 glEnable(GL_TEXTURE_2D);
1787 glBindTexture( GL_TEXTURE_2D, screentexture2);
1788 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1789 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1791 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1797 glClear(GL_DEPTH_BUFFER_BIT);
1798 ReSizeGLScene(90,.1f);
1799 glViewport(0,0,screenwidth,screenheight);
1801 if(drawmode!=normalmode){
1802 glDisable(GL_DEPTH_TEST);
1803 if(drawmode==motionblurmode){
1804 glDrawBuffer(GL_FRONT);
1805 glReadBuffer(GL_BACK);
1807 glColor3f (1.0, 1.0, 1.0); // no coloring
1809 glEnable(GL_TEXTURE_2D);
1810 glBindTexture( GL_TEXTURE_2D, screentexture);
1811 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1812 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1813 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1814 glDisable(GL_CULL_FACE);
1815 glDisable(GL_LIGHTING);
1817 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1818 glPushMatrix(); // Store The Projection Matrix
1819 glLoadIdentity(); // Reset The Projection Matrix
1820 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1821 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1822 glPushMatrix(); // Store The Modelview Matrix
1823 glLoadIdentity(); // Reset The Modelview Matrix
1824 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1825 glTranslatef(1,1,0);
1826 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1828 if(drawmode==motionblurmode){
1829 if(motionbluramount<.2)motionbluramount=.2;
1830 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1831 glColor4f(1,1,1,motionbluramount);
1835 glVertex3f(-1, -1, 0.0f);
1836 glTexCoord2f(texcoordwidth,0);
1837 glVertex3f(1, -1, 0.0f);
1838 glTexCoord2f(texcoordwidth,texcoordheight);
1839 glVertex3f(1, 1, 0.0f);
1840 glTexCoord2f(0,texcoordheight);
1841 glVertex3f(-1, 1, 0.0f);
1845 if(drawmode==realmotionblurmode){
1846 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1847 glClear(GL_COLOR_BUFFER_BIT);
1848 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1849 glBindTexture( GL_TEXTURE_2D, screentexture);
1850 glColor4f(1,1,1,.5);
1854 glVertex3f(-1, -1, 0.0f);
1855 glTexCoord2f(texcoordwidth,0);
1856 glVertex3f(1, -1, 0.0f);
1857 glTexCoord2f(texcoordwidth,texcoordheight);
1858 glVertex3f(1, 1, 0.0f);
1859 glTexCoord2f(0,texcoordheight);
1860 glVertex3f(-1, 1, 0.0f);
1863 glBindTexture( GL_TEXTURE_2D, screentexture2);
1864 glColor4f(1,1,1,.5);
1868 glVertex3f(-1, -1, 0.0f);
1869 glTexCoord2f(texcoordwidth,0);
1870 glVertex3f(1, -1, 0.0f);
1871 glTexCoord2f(texcoordwidth,texcoordheight);
1872 glVertex3f(1, 1, 0.0f);
1873 glTexCoord2f(0,texcoordheight);
1874 glVertex3f(-1, 1, 0.0f);
1877 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1879 if(drawmode==doublevisionmode){
1880 static float crosseyedness;
1881 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1882 if(crosseyedness>1)crosseyedness=1;
1883 if(crosseyedness<0)crosseyedness=0;
1885 glDisable(GL_BLEND);
1890 glVertex3f(-1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth,0);
1892 glVertex3f(1, -1, 0.0f);
1893 glTexCoord2f(texcoordwidth,texcoordheight);
1894 glVertex3f(1, 1, 0.0f);
1895 glTexCoord2f(0,texcoordheight);
1896 glVertex3f(-1, 1, 0.0f);
1900 glColor4f(1,1,1,.5);
1903 glTranslatef(.015*crosseyedness,0,0);
1907 glVertex3f(-1, -1, 0.0f);
1908 glTexCoord2f(texcoordwidth,0);
1909 glVertex3f(1, -1, 0.0f);
1910 glTexCoord2f(texcoordwidth,texcoordheight);
1911 glVertex3f(1, 1, 0.0f);
1912 glTexCoord2f(0,texcoordheight);
1913 glVertex3f(-1, 1, 0.0f);
1918 if(drawmode==glowmode){
1919 glColor4f(.5,.5,.5,.5);
1921 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1923 glTranslatef(.01,0,0);
1926 glVertex3f(-1, -1, 0.0f);
1927 glTexCoord2f(texcoordwidth,0);
1928 glVertex3f(1, -1, 0.0f);
1929 glTexCoord2f(texcoordwidth,texcoordheight);
1930 glVertex3f(1, 1, 0.0f);
1931 glTexCoord2f(0,texcoordheight);
1932 glVertex3f(-1, 1, 0.0f);
1936 glTranslatef(-.01,0,0);
1939 glVertex3f(-1, -1, 0.0f);
1940 glTexCoord2f(texcoordwidth,0);
1941 glVertex3f(1, -1, 0.0f);
1942 glTexCoord2f(texcoordwidth,texcoordheight);
1943 glVertex3f(1, 1, 0.0f);
1944 glTexCoord2f(0,texcoordheight);
1945 glVertex3f(-1, 1, 0.0f);
1949 glTranslatef(.0,.01,0);
1952 glVertex3f(-1, -1, 0.0f);
1953 glTexCoord2f(texcoordwidth,0);
1954 glVertex3f(1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth,texcoordheight);
1956 glVertex3f(1, 1, 0.0f);
1957 glTexCoord2f(0,texcoordheight);
1958 glVertex3f(-1, 1, 0.0f);
1962 glTranslatef(0,-.01,0);
1965 glVertex3f(-1, -1, 0.0f);
1966 glTexCoord2f(texcoordwidth,0);
1967 glVertex3f(1, -1, 0.0f);
1968 glTexCoord2f(texcoordwidth,texcoordheight);
1969 glVertex3f(1, 1, 0.0f);
1970 glTexCoord2f(0,texcoordheight);
1971 glVertex3f(-1, 1, 0.0f);
1975 if(drawmode==radialzoommode){
1977 //glRotatef((float)i*.1,0,0,1);
1978 glColor4f(1,1,1,1/((float)i+1));
1980 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1983 glVertex3f(-1, -1, 0.0f);
1984 glTexCoord2f(texcoordwidth,0);
1985 glVertex3f(1, -1, 0.0f);
1986 glTexCoord2f(texcoordwidth,texcoordheight);
1987 glVertex3f(1, 1, 0.0f);
1988 glTexCoord2f(0,texcoordheight);
1989 glVertex3f(-1, 1, 0.0f);
1994 glDisable(GL_TEXTURE_2D);
1995 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1996 glPopMatrix(); // Restore The Old Projection Matrix
1997 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1998 glPopMatrix(); // Restore The Old Projection Matrix
1999 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2000 glEnable(GL_CULL_FACE);
2001 glDisable(GL_BLEND);
2006 glEnable(GL_TEXTURE_2D);
2009 if(consoleselected>=60)
2010 offset=consoleselected-60;
2011 sprintf (string, " ]");
2012 text.glPrint(10,30,string,0,1,1024,768);
2014 sprintf (string, "_");
2015 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2018 for(j=0;j<consolechars[i];j++){
2019 glColor4f(1,1,1,1-(float)(i)/16);
2020 if(j<consolechars[i]){
2021 sprintf (string, "%c",consoletext[i][j]);
2022 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2029 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2030 multiplier=tempmult;
2035 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2038 glDrawBuffer(GL_BACK);
2039 glReadBuffer(GL_BACK);
2040 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2041 ReSizeGLScene(90,.1f);
2044 temptexdetail=texdetail;
2045 if(texdetail>2)texdetail=2;
2046 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2048 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2049 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2052 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2053 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2056 if(lastcheck>.5||oldmainmenu!=mainmenu){
2058 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2059 ipstream.ignore(256,':');
2060 ipstream >> campaignnumlevels;
2061 for(i=0;i<campaignnumlevels;i++){
2062 ipstream.ignore(256,':');
2063 ipstream.ignore(256,':');
2064 ipstream.ignore(256,' ');
2065 ipstream >> campaignmapname[i];
2066 ipstream.ignore(256,':');
2067 ipstream >> campaigndescription[i];
2069 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2071 ipstream.ignore(256,':');
2072 ipstream >> campaignchoosenext[i];
2073 ipstream.ignore(256,':');
2074 ipstream >> campaignnumnext[i];
2075 for(j=0;j<campaignnumnext[i];j++){
2076 ipstream.ignore(256,':');
2077 ipstream >> campaignnextlevel[i][j];
2078 campaignnextlevel[i][j]-=1;
2080 ipstream.ignore(256,':');
2081 ipstream >> campaignlocationx[i];
2082 ipstream.ignore(256,':');
2083 ipstream >> campaignlocationy[i];
2087 for(i=0;i<campaignnumlevels;i++){
2089 levelhighlight[i]=0;
2094 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2095 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2096 levelvisible[levelorder[i+1]]=1;
2098 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2099 if(whichlevelstart<0){
2100 accountactive->setCampaignScore(0);
2101 accountactive->resetFasttime();
2102 campaignchoicenum=1;
2103 campaignchoicewhich[0]=0;
2107 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2108 for(i=0;i<campaignchoicenum;i++){
2109 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2110 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2111 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2120 texdetail=temptexdetail;
2122 oldmainmenu=mainmenu;
2124 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2125 glClear(GL_DEPTH_BUFFER_BIT);
2126 glEnable(GL_ALPHA_TEST);
2127 glAlphaFunc(GL_GREATER, 0.001f);
2128 glEnable(GL_TEXTURE_2D);
2129 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2130 glDisable(GL_CULL_FACE);
2131 glDisable(GL_LIGHTING);
2133 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2134 glPushMatrix(); // Store The Projection Matrix
2135 glLoadIdentity(); // Reset The Projection Matrix
2136 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2137 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2138 glPushMatrix(); // Store The Modelview Matrix
2139 glLoadIdentity(); // Reset The Modelview Matrix
2140 glTranslatef(screenwidth/2,screenheight/2,0);
2142 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2143 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2144 glDisable(GL_BLEND);
2145 glColor4f(0,0,0,1.0);
2146 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2147 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2148 glDisable(GL_TEXTURE_2D);
2150 //glScalef(.25,.25,.25);
2153 glVertex3f(-1, -1, 0.0f);
2155 glVertex3f(1, -1, 0.0f);
2157 glVertex3f(1, 1, 0.0f);
2159 glVertex3f(-1, 1, 0.0f);
2163 glColor4f(0.4,0.4,0.4,1.0);
2164 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2165 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2166 glEnable(GL_TEXTURE_2D);
2167 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2169 //glScalef(.25,.25,.25);
2172 glVertex3f(-1, -1, 0.0f);
2174 glVertex3f(1, -1, 0.0f);
2176 glVertex3f(1, 1, 0.0f);
2178 glVertex3f(-1, 1, 0.0f);
2183 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2185 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2189 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2190 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2193 endx[0]=startx[0]+strlen(menustring[0])*10;
2194 endy[0]=starty[0]+20;
2198 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2199 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2200 else sprintf (menustring[1], "Detail: Low");
2203 endx[1]=startx[1]+strlen(menustring[1])*10;
2204 endy[1]=starty[1]+20;
2208 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2209 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2210 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2213 endx[2]=startx[2]+strlen(menustring[2])*10;
2214 endy[2]=starty[2]+20;
2218 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2219 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2220 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2221 startx[3]=10+20-1000;
2223 endx[3]=startx[3]+strlen(menustring[3])*10;
2224 endy[3]=starty[3]+20;
2228 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2229 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2232 endx[4]=startx[4]+strlen(menustring[4])*10;
2233 endy[4]=starty[4]+20;
2237 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2238 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2241 endx[5]=startx[5]+strlen(menustring[5])*10;
2242 endy[5]=starty[5]+20;
2246 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2247 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2250 endx[6]=startx[6]+strlen(menustring[6])*10;
2251 endy[6]=starty[6]+20;
2255 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2256 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2259 endx[9]=startx[9]+strlen(menustring[9])*10;
2260 endy[9]=starty[9]+20;
2264 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2267 endx[10]=startx[10]+strlen(menustring[10])*10;
2268 endy[10]=starty[10]+20;
2272 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2275 endx[11]=startx[11]+strlen(menustring[11])*10;
2276 endy[11]=starty[11]+20;
2280 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2283 endx[13]=startx[13]+strlen(menustring[13])*10;
2284 endy[13]=starty[13]+20;
2288 sprintf (menustring[7], "-Configure Controls-");
2291 endx[7]=startx[7]+strlen(menustring[7])*10;
2292 endy[7]=starty[7]+20;
2296 sprintf (menustring[12], "-Configure Stereo -");
2299 endx[12]=startx[12]+strlen(menustring[7])*10;
2300 endy[12]=starty[12]+20;
2304 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2305 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2307 endx[8]=startx[8]+strlen(menustring[8])*10;
2309 endy[8]=starty[8]+20;
2316 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2317 else sprintf (menustring[0], "Forwards: _");
2320 endx[0]=startx[0]+strlen(menustring[0])*10;
2321 endy[0]=starty[0]+20;
2325 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2326 else sprintf (menustring[1], "Back: _");
2329 endx[1]=startx[1]+strlen(menustring[1])*10;
2330 endy[1]=starty[1]+20;
2334 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2335 else sprintf (menustring[2], "Left: _");
2338 endx[2]=startx[2]+strlen(menustring[2])*10;
2339 endy[2]=starty[2]+20;
2343 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2344 else sprintf (menustring[3], "Right: _");
2347 endx[3]=startx[3]+strlen(menustring[3])*10;
2348 endy[3]=starty[3]+20;
2352 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2353 else sprintf (menustring[4], "Crouch: _");
2356 endx[4]=startx[4]+strlen(menustring[4])*10;
2357 endy[4]=starty[4]+20;
2361 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2362 else sprintf (menustring[5], "Jump: _");
2365 endx[5]=startx[5]+strlen(menustring[5])*10;
2366 endy[5]=starty[5]+20;
2370 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2371 else sprintf (menustring[6], "Draw: _");
2374 endx[6]=startx[6]+strlen(menustring[6])*10;
2375 endy[6]=starty[6]+20;
2379 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2380 else sprintf (menustring[7], "Throw: _");
2383 endx[7]=startx[7]+strlen(menustring[7])*10;
2384 endy[7]=starty[7]+20;
2388 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2389 else sprintf (menustring[8], "Attack: _");
2392 endx[8]=startx[8]+strlen(menustring[8])*10;
2393 endy[8]=starty[8]+20;
2399 sprintf (menustring[9], "Back");
2401 endx[9]=startx[9]+strlen(menustring[9])*10;
2403 endy[9]=starty[9]+20;
2408 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2410 sprintf (menustring[0], "%s",accountactive->getName());
2413 endx[0]=startx[0]+strlen(menustring[0])*10;
2414 endy[0]=starty[0]+20;
2418 sprintf (menustring[1], "Tutorial");
2421 endx[1]=startx[1]+strlen(menustring[1])*10;
2422 endy[1]=starty[1]+20;
2426 sprintf (menustring[2], "Challenge");
2429 endx[2]=startx[2]+strlen(menustring[2])*10;
2430 endy[2]=starty[2]+20;
2434 sprintf (menustring[3], "Delete User");
2437 endx[3]=startx[3]+strlen(menustring[3])*10;
2438 endy[3]=starty[3]+20;
2442 sprintf (menustring[4], "Main Menu");
2445 endx[4]=startx[4]+strlen(menustring[4])*10;
2446 endy[4]=starty[4]+20;
2450 sprintf (menustring[5], "Change User");
2452 endx[5]=startx[5]+strlen(menustring[5])*10;
2454 endy[5]=starty[5]+20;
2460 sprintf (menustring[6], "World");
2462 starty[6]=30+480-400-50;
2463 endx[6]=startx[6]+400;
2468 if(accountactive->getCampaignChoicesMade())
2469 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2470 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2471 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2472 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2473 endx[7+i]=startx[7+i]+10;
2474 endy[7+i]=starty[7+i]+10;
2479 if(campaignchoicenum>0)
2480 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2481 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2482 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2483 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2484 endx[7+i]=startx[7+i]+10;
2485 endy[7+i]=starty[7+i]+10;
2490 /*sprintf (menustring[7], "Dot");
2491 startx[7]=120+260*400/512;
2492 starty[7]=30+(512-184)*400/512;
2493 endx[7]=startx[7]+10;
2494 endy[7]=starty[7]+10;
2498 sprintf (menustring[8], "Dot");
2499 startx[8]=120+129*400/512;
2500 starty[8]=30+(512-284)*400/512;
2501 endx[8]=startx[8]+10;
2502 endy[8]=starty[8]+10;
2506 sprintf (menustring[9], "Dot");
2507 startx[9]=120+358*400/512;
2508 starty[9]=30+(512-235)*400/512;
2509 endx[9]=startx[9]+10;
2510 endy[9]=starty[9]+10;
2514 sprintf (menustring[10], "Dot");
2515 startx[10]=120+359*400/512;
2516 starty[10]=30+(512-308)*400/512;
2517 endx[10]=startx[10]+10;
2518 endy[10]=starty[10]+10;
2522 sprintf (menustring[11], "Dot");
2523 startx[11]=120+288*400/512;
2524 starty[11]=30+(512-277)*400/512;
2525 endx[11]=startx[11]+10;
2526 endy[11]=starty[11]+10;
2534 sprintf (menustring[0], "Are you sure you want to delete this user?");
2537 endx[0]=startx[0]+strlen(menustring[0])*10;
2538 endy[0]=starty[0]+20;
2542 sprintf (menustring[1], "Yes");
2545 endx[1]=startx[1]+strlen(menustring[1])*10;
2546 endy[1]=starty[1]+20;
2550 sprintf (menustring[2], "No");
2553 endx[2]=startx[2]+strlen(menustring[2])*10;
2554 endy[2]=starty[2]+20;
2558 sprintf (menustring[3], "Extra 4");
2561 endx[3]=startx[3]+strlen(menustring[3])*10;
2562 endy[3]=starty[3]+20;
2566 sprintf (menustring[4], "Extra 5");
2569 endx[4]=startx[4]+strlen(menustring[4])*10;
2570 endy[4]=starty[4]+20;
2574 sprintf (menustring[5], "Back");
2576 endx[5]=startx[5]+strlen(menustring[5])*10;
2578 endy[5]=starty[5]+20;
2584 nummenuitems=Account::getNbAccounts()+2;
2588 if(Account::getNbAccounts()<8)
2589 sprintf (menustring[0], "New User");
2591 sprintf (menustring[0], "No More Users");
2594 endx[0]=startx[0]+strlen(menustring[0])*10;
2595 endy[0]=starty[0]+20;
2604 for(i=0;i<Account::getNbAccounts();i++){
2605 sprintf (menustring[num], "%s",Account::get(i)->getName());
2607 starty[num]=360-20-20*num;
2608 endx[num]=startx[num]+strlen(menustring[num])*10;
2609 endy[num]=starty[num]+20;
2616 sprintf (menustring[num], "Back");
2618 endx[num]=startx[num]+strlen(menustring[num])*10;
2620 endy[num]=starty[num]+20;
2627 sprintf (menustring[0], "Easier");
2630 endx[0]=startx[0]+strlen(menustring[0])*10;
2631 endy[0]=starty[0]+20;
2635 sprintf (menustring[1], "Difficult");
2638 endx[1]=startx[1]+strlen(menustring[1])*10;
2639 endy[1]=starty[1]+20;
2643 sprintf (menustring[2], "Insane");
2646 endx[2]=startx[2]+strlen(menustring[2])*10;
2647 endy[2]=starty[2]+20;
2653 //tempncl=numchallengelevels;
2654 //numchallengelevels=9;
2655 nummenuitems=2+numchallengelevels;
2658 for(j=0;j<numchallengelevels;j++){
2659 for(i=0;i<255;i++)menustring[j][i]='\0';
2660 sprintf (temp, "Level %d",j+1);
2661 strcpy(menustring[j],temp);
2662 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2663 menustring[j][17]='\0';
2664 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2665 strcat(menustring[j],temp);
2666 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2667 menustring[j][32]='\0';
2668 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2669 strcat(menustring[j],temp);
2670 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2671 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2672 strcat(menustring[j],temp);
2676 endx[j]=startx[j]+strlen(menustring[j])*10;
2677 endy[j]=starty[j]+20;
2682 sprintf (menustring[numchallengelevels], "Back");
2683 startx[numchallengelevels]=10;
2684 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2685 starty[numchallengelevels]=10;
2686 endy[numchallengelevels]=starty[numchallengelevels]+20;
2687 movex[numchallengelevels]=0;
2688 movey[numchallengelevels]=0;
2690 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2691 startx[numchallengelevels+1]=10;
2692 starty[numchallengelevels+1]=440;
2693 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2694 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2695 movex[numchallengelevels+1]=0;
2696 movey[numchallengelevels+1]=0;
2698 //numchallengelevels=tempncl;
2705 sprintf (menustring[0], "Congratulations!");
2708 endx[0]=startx[0]+strlen(menustring[0])*10;
2709 endy[0]=starty[0]+20;
2713 sprintf (menustring[1], "You have avenged your family and");
2716 endx[1]=startx[1]+strlen(menustring[1])*10;
2717 endy[1]=starty[1]+20;
2721 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2724 endx[2]=startx[2]+strlen(menustring[2])*10;
2725 endy[2]=starty[2]+20;
2729 sprintf (menustring[3], "Back");
2731 endx[3]=startx[3]+strlen(menustring[3])*10;
2733 endy[3]=starty[3]+20;
2737 for(i=0;i<255;i++)menustring[4][i]='\0';
2738 sprintf (temp, "Your score:");
2739 strcpy(menustring[4],temp);
2740 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2741 menustring[4][20]='\0';
2742 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2743 strcat(menustring[4],temp);
2745 endx[4]=startx[4]+strlen(menustring[4])*10;
2747 endy[4]=starty[4]+20;
2751 for(i=0;i<255;i++)menustring[5][i]='\0';
2752 sprintf (temp, "Your time:");
2753 strcpy(menustring[5],temp);
2754 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2755 menustring[5][20]='\0';
2756 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2757 strcat(menustring[5],temp);
2759 endx[5]=startx[5]+strlen(menustring[5])*10;
2761 endy[5]=starty[5]+20;
2765 for(i=0;i<255;i++)menustring[5][i]='\0';
2766 sprintf (temp, "Highest score:");
2767 strcpy(menustring[5],temp);
2768 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2769 menustring[5][20]='\0';
2770 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2771 strcat(menustring[5],temp);
2773 endx[5]=startx[5]+strlen(menustring[5])*10;
2775 endy[5]=starty[5]+20;
2779 for(i=0;i<255;i++)menustring[7][i]='\0';
2780 sprintf (temp, "Lowest time:");
2781 strcpy(menustring[7],temp);
2782 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2783 menustring[7][20]='\0';
2784 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2785 strcat(menustring[7],temp);
2787 endx[7]=startx[7]+strlen(menustring[7])*10;
2789 endy[7]=starty[7]+20;
2795 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2798 endx[0]=startx[0]+strlen(menustring[0])*10;
2799 endy[0]=starty[0]+20;
2803 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2806 endx[1]=startx[1]+strlen(menustring[1])*10;
2807 endy[1]=starty[1]+20;
2811 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2814 endx[2]=startx[2]+strlen(menustring[2])*10;
2815 endy[2]=starty[2]+20;
2819 sprintf (menustring[3], "Back");
2821 endx[3]=startx[3]+strlen(menustring[3])*10;
2823 endy[3]=starty[3]+20;
2829 if(mainmenu==1||mainmenu==2){
2839 starty[1]=480-152-32;
2846 starty[2]=480-228-32;
2854 starty[3]=480-306-32;
2863 starty[3]=480-306-32;
2877 starty[4]=480-140-256;
2884 starty[5]=480-138-256;
2891 starty[6]=480-144-256;
2899 starty[4]=480-140-256;
2906 starty[5]=480-138-256;
2913 starty[6]=480-144-256;
2921 starty[4]=480-140-256;
2928 starty[5]=480-150-256;
2935 starty[6]=480-144-256;
2943 starty[4]=480-140-256;
2950 starty[5]=480-150-256;
2957 starty[6]=480-144-256;
2965 starty[4]=480-100-256;
2972 starty[5]=480-120-256;
2979 starty[6]=480-144-256;
2989 if(mainmenu==1||mainmenu==2)
2991 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2996 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2997 for(i=0;i<nummenuitems;i++){
2998 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2999 if(mainmenu!=5)selected=i;
3000 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3001 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
3005 for(i=0;i<nummenuitems;i++){
3007 selectedlong[i]+=multiplier*5;
3008 if(selectedlong[i]>1) selectedlong[i]=1;
3010 selectedlong[i]-=multiplier*5;
3011 if(selectedlong[i]<0) selectedlong[i]=0;
3013 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3014 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3019 if(i>=4&&(mainmenu==1||mainmenu==2)){
3021 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3022 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3028 if(mainmenu==1||mainmenu==2){
3029 glClear(GL_DEPTH_BUFFER_BIT);
3030 glEnable(GL_ALPHA_TEST);
3031 glAlphaFunc(GL_GREATER, 0.001f);
3032 glEnable(GL_TEXTURE_2D);
3033 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3034 glDisable(GL_CULL_FACE);
3035 glDisable(GL_LIGHTING);
3037 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3038 glPushMatrix(); // Store The Projection Matrix
3039 glLoadIdentity(); // Reset The Projection Matrix
3040 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3041 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3042 glPushMatrix(); // Store The Modelview Matrix
3043 glLoadIdentity(); // Reset The Modelview Matrix
3044 glTranslatef(screenwidth/2,screenheight/2,0);
3046 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3047 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3048 glDisable(GL_BLEND);
3049 glColor4f(0,0,0,1.0);
3050 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3051 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3052 glDisable(GL_TEXTURE_2D);
3054 //glScalef(.25,.25,.25);
3057 glVertex3f(-1, -1, 0.0f);
3059 glVertex3f(1, -1, 0.0f);
3061 glVertex3f(1, 1, 0.0f);
3063 glVertex3f(-1, 1, 0.0f);
3067 glColor4f(0.4,0.4,0.4,1.0);
3068 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3069 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3070 glEnable(GL_TEXTURE_2D);
3071 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3073 //glScalef(.25,.25,.25);
3076 glVertex3f(-1, -1, 0.0f);
3078 glVertex3f(1, -1, 0.0f);
3080 glVertex3f(1, 1, 0.0f);
3082 glVertex3f(-1, 1, 0.0f);
3087 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3090 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3091 glPushMatrix(); // Store The Projection Matrix
3092 glLoadIdentity(); // Reset The Projection Matrix
3093 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3094 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3095 glPushMatrix(); // Store The Modelview Matrix
3096 glLoadIdentity(); // Reset The Modelview Matrix
3098 glDisable(GL_TEXTURE_2D);
3102 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3104 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3108 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3109 glPushMatrix(); // Store The Projection Matrix
3110 glLoadIdentity(); // Reset The Projection Matrix
3111 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3112 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3113 glPushMatrix(); // Store The Modelview Matrix
3114 glLoadIdentity(); // Reset The Modelview Matrix
3115 glEnable(GL_TEXTURE_2D);
3116 for(j=0;j<nummenuitems;j++)
3118 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3120 //glDisable(GL_BLEND);
3121 glEnable(GL_ALPHA_TEST);
3123 //glDisable(GL_ALPHA_TEST);
3124 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3125 if(mainmenu==1||mainmenu==2)
3128 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3129 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3130 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3131 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3132 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3136 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3138 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3140 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3142 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3146 //glDisable(GL_ALPHA_TEST);
3147 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3150 if(1-((float)i)/10-(1-selectedlong[j])>0)
3152 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3153 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3157 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3159 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3161 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3163 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3169 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3171 if(mainmenu!=5||j<6)
3174 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3175 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3177 if(mainmenu!=7||j!=0||!entername)
3178 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3182 sprintf (string, "_");
3183 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3185 for(l=0;l<displaychars[0];l++){
3186 sprintf (string, "%c",displaytext[0][l]);
3187 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3192 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3195 if(1-((float)i)/15-(1-selectedlong[j])>0)
3197 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3198 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3199 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3200 if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3201 if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3202 if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3203 if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3204 if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3205 if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3206 if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3207 if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3208 if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3214 glClear(GL_DEPTH_BUFFER_BIT);
3215 glEnable(GL_ALPHA_TEST);
3216 glAlphaFunc(GL_GREATER, 0.001f);
3217 glEnable(GL_TEXTURE_2D);
3218 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3219 glDisable(GL_CULL_FACE);
3220 glDisable(GL_LIGHTING);
3221 if(j==6)glColor4f(1,1,1,1);
3222 else glColor4f(1,0,0,1);
3224 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3225 glPushMatrix(); // Store The Projection Matrix
3226 glLoadIdentity(); // Reset The Projection Matrix
3227 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3228 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3229 glPushMatrix(); // Store The Modelview Matrix
3230 glLoadIdentity(); // Reset The Modelview Matrix
3233 //Draw world, draw map
3234 glTranslatef(2,-5,0);
3236 if(j>6&&j<nummenuitems-1)
3238 XYZ linestart,lineend,offset;
3245 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3246 linestart.x=(startx[j]+endx[j])/2;
3247 linestart.y=(starty[j]+endy[j])/2;
3248 if(j>=6+accountactive->getCampaignChoicesMade()){
3249 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3250 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3252 lineend.x=(startx[j+1]+endx[j+1])/2;
3253 lineend.y=(starty[j+1]+endy[j+1])/2;
3254 offset=lineend-linestart;
3257 offset=DoRotation(offset,0,0,90);
3259 glDisable(GL_TEXTURE_2D);
3261 if(j<6+accountactive->getCampaignChoicesMade()){
3262 glColor4f(0.5,0,0,1);
3270 linestart+=fac*4*startsize;
3271 lineend-=fac*4*endsize;
3273 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3274 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3278 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3280 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3282 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3284 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3288 glEnable(GL_TEXTURE_2D);
3292 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3293 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3294 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3295 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3296 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3297 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3298 if(j==6)glColor4f(1,1,1,1);
3301 itemsize=abs(startx[j]-endx[j])/2;
3303 midpoint.x=(startx[j]+endx[j])/2;
3304 midpoint.y=(starty[j]+endy[j])/2;
3305 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3306 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3308 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3312 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3314 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3316 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3318 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3322 //glDisable(GL_ALPHA_TEST);
3323 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3326 if(1-((float)i)/10-(1-selectedlong[j])>0)
3328 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3329 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3333 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3335 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3337 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3339 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3347 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3349 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3351 if(j-7>=accountactive->getCampaignChoicesMade()){
3352 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3353 glDisable(GL_DEPTH_TEST);
3359 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3361 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3364 if(mainmenu==1||mainmenu==2)
3365 if(transition<.1||transition>.9){
3366 glClear(GL_DEPTH_BUFFER_BIT);
3367 glEnable(GL_ALPHA_TEST);
3368 glAlphaFunc(GL_GREATER, 0.001f);
3369 glEnable(GL_TEXTURE_2D);
3370 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3371 glDisable(GL_CULL_FACE);
3372 glDisable(GL_LIGHTING);
3374 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3375 glPushMatrix(); // Store The Projection Matrix
3376 glLoadIdentity(); // Reset The Projection Matrix
3377 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3378 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3379 glPushMatrix(); // Store The Modelview Matrix
3380 glLoadIdentity(); // Reset The Modelview Matrix
3382 glDisable(GL_TEXTURE_2D);
3384 glColor4f(1,0,0,1-(transition*10));
3386 glColor4f(1,0,0,1-((1-transition)*10));
3389 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3393 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3394 glPushMatrix(); // Store The Projection Matrix
3395 glLoadIdentity(); // Reset The Projection Matrix
3396 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3397 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3398 glPushMatrix(); // Store The Modelview Matrix
3399 glLoadIdentity(); // Reset The Modelview Matrix
3400 glTranslatef(screenwidth/2,screenheight/2,0);
3402 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3403 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3405 glEnable(GL_TEXTURE_2D);
3407 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3408 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3410 if(!waiting) { // hide the cursor while waiting for a key
3412 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3413 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3414 glTranslatef(1,-1,0);
3415 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3417 glBindTexture( GL_TEXTURE_2D, cursortexture);
3419 //glScalef(.25,.25,.25);
3422 glVertex3f(-1, -1, 0.0f);
3424 glVertex3f(1, -1, 0.0f);
3426 glVertex3f(1, 1, 0.0f);
3428 glVertex3f(-1, 1, 0.0f);
3434 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3440 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3441 if(flashamount>1)flashamount=1;
3442 if(flashdelay<=0)flashamount-=multiplier;
3444 if(flashamount<0)flashamount=0;
3445 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3446 glDisable(GL_CULL_FACE);
3447 glDisable(GL_LIGHTING);
3448 glDisable(GL_TEXTURE_2D);
3450 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3451 glPushMatrix(); // Store The Projection Matrix
3452 glLoadIdentity(); // Reset The Projection Matrix
3453 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3454 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3455 glPushMatrix(); // Store The Modelview Matrix
3456 glLoadIdentity(); // Reset The Modelview Matrix
3457 glScalef(screenwidth,screenheight,1);
3458 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3460 glColor4f(flashr,flashg,flashb,flashamount);
3462 glVertex3f(0, 0, 0.0f);
3463 glVertex3f(256, 0, 0.0f);
3464 glVertex3f(256, 256, 0.0f);
3465 glVertex3f(0, 256, 0.0f);
3467 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3468 glPopMatrix(); // Restore The Old Projection Matrix
3469 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3470 glPopMatrix(); // Restore The Old Projection Matrix
3471 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3472 glEnable(GL_CULL_FACE);
3473 glDisable(GL_BLEND);
3478 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3479 tempmult=multiplier;
3484 if ( side == stereoRight || side == stereoCenter ) {
3485 if(drawmode!=motionblurmode||mainmenu){
3490 //myassert(glGetError() == GL_NO_ERROR);
3491 glDrawBuffer(GL_BACK);
3492 glReadBuffer(GL_BACK);
3497 if(drawtoggle==2)drawtoggle=0;
3499 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3500 multiplier=tempmult;
3502 //Jordan fixed your warning!