From: Côme BERNIGAUD Date: Sat, 15 May 2010 22:22:09 +0000 (+0200) Subject: Add a pretty and desactivable damage bar. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=56075fbed3c9b812e72fe93c99ac6c3f8d56d79d;p=lugaru.git Add a pretty and desactivable damage bar. --- diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index ea75d51..e01f46c 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -175,6 +175,8 @@ extern float accountcampaigntime[10]; extern bool gamestarted; +extern bool showdamagebar; + extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); @@ -1226,6 +1228,90 @@ int Game::DrawGLScene(void) text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768); glColor4f(1,0,0,1); text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768); + if(showdamagebar) { + glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_CULL_FACE); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glDepthMask(0); + glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glPushMatrix(); // Store The Projection Matrix + glLoadIdentity(); // Reset The Projection Matrix + glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glPushMatrix(); // Store The Modelview Matrix + glLoadIdentity(); // Reset The Modelview Matrix + glTranslatef(15,screenheight*17.5/20,0); + glScalef(screenwidth/3+20,screenheight/20,1); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glColor4f(0.0,0.4,0.0,0.7); + float bar=((float)player[0].damage)/player[0].damagetolerance; + glBegin(GL_QUADS); + glVertex3f((bar<1?bar:1),0,0.0f); + glVertex3f(1,0,0.0f); + glVertex3f(1,1,0.0f); + glVertex3f((bar<1?bar:1),1,0.0f); + glEnd(); + glColor4f(0.1,0.0,0.0,1); + bar = ((float)player[0].bloodloss)/player[0].damagetolerance; + glBegin(GL_QUADS); + glVertex3f(0,0,0.0f); + glVertex3f((bar<1?bar:1),0,0.0f); + glVertex3f((bar<1?bar:1),1,0.0f); + glVertex3f(0,1,0.0f); + glEnd(); + glColor4f(0.4,0.0,0.0,0.7); + bar = ((float)player[0].damage)/player[0].damagetolerance; + glBegin(GL_QUADS); + glVertex3f(0,0,0.0f); + glVertex3f((bar<1?bar:1),0,0.0f); + glVertex3f((bar<1?bar:1),1,0.0f); + glVertex3f(0,1,0.0f); + glEnd(); + glColor4f(0.4,0.0,0.0,0.7); + bar = ((float)player[0].permanentdamage)/player[0].damagetolerance; + glBegin(GL_QUADS); + glVertex3f(0,0,0.0f); + glVertex3f((bar<1?bar:1),0,0.0f); + glVertex3f((bar<1?bar:1),1,0.0f); + glVertex3f(0,1,0.0f); + glEnd(); + glColor4f(0.4,0.0,0.0,0.7); + bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance; + glBegin(GL_QUADS); + glVertex3f(0,0,0.0f); + glVertex3f((bar<1?bar:1),0,0.0f); + glVertex3f((bar<1?bar:1),1,0.0f); + glVertex3f(0,1,0.0f); + glEnd(); + glColor4f(0.0,0.0,0.0,0.7); + glLineWidth(2.0); + glBegin(GL_LINE_STRIP); + glVertex3f(0,0,0.0f); + glVertex3f(1,0,0.0f); + glVertex3f(1,1,0.0f); + glVertex3f(0,1,0.0f); + glVertex3f(0,0,0.0f); + glEnd(); + + glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glPopMatrix(); // Restore The Old Projection Matrix + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glPopMatrix(); // Restore The Old Projection Matrix + glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + glDepthMask(1); + glEnable(GL_TEXTURE_2D); + + // writing the numbers : + sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss)); + glColor4f(0,0,0,1); + text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768); + glColor4f(1,0,0,1); + text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768); + } } glColor4f(.5,.5,.5,1); diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 2e42476..ae0366d 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -100,6 +100,7 @@ extern bool foliage; extern bool trilinear; extern bool damageeffects; extern bool showpoints; +extern bool showdamagebar; // (des)activate the damage bar extern bool texttoggle; extern bool alwaysblur; extern float gamespeed; @@ -1899,6 +1900,8 @@ void Game::Tick() opstream << KeyToChar(attackkey); opstream << "\nChat key:\n"; opstream << KeyToChar(chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; opstream.close(); } if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){ @@ -2294,6 +2297,8 @@ void Game::Tick() opstream << KeyToChar(attackkey); opstream << "\nChat key:\n"; opstream << KeyToChar(chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; opstream.close(); if(mainmenu==3&&gameon)mainmenu=2; @@ -2922,6 +2927,8 @@ void Game::Tick() opstream << KeyToChar(attackkey); opstream << "\nChat key:\n"; opstream << KeyToChar(chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; opstream.close(); } } @@ -5364,6 +5371,8 @@ void Game::Tick() opstream << KeyToChar(attackkey); opstream << "\nChat key:\n"; opstream << KeyToChar(chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; opstream.close(); } } diff --git a/Source/Globals.cpp b/Source/Globals.cpp index 2eae6fb..dfb570d 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -119,6 +119,7 @@ char mapname[256] = {0}; bool loadingstuff = 0; bool stillloading = 0; bool showpoints = 0; +bool showdamagebar = 0; bool alwaysblur = 0; bool immediate = 0; bool velocityblur = 0; diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index da51185..2428472 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -97,6 +97,7 @@ extern Person player[maxplayers]; extern bool vblsync; extern bool stillloading; extern bool showpoints; +extern bool showdamagebar; extern bool alwaysblur; extern bool immediate; extern bool velocityblur; @@ -600,6 +601,7 @@ Boolean SetUp (Game & game) texttoggle=1; alwaysblur=0; showpoints=0; + showdamagebar=0; immediate=0; velocityblur=0; @@ -699,6 +701,8 @@ Boolean SetUp (Game & game) opstream << KeyToChar(game.attackkey); opstream << "\nChat key:\n"; opstream << KeyToChar(game.chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; opstream.close(); } if(ipstream){ @@ -845,6 +849,10 @@ Boolean SetUp (Game & game) ipstream.ignore(256,'\n'); ipstream >> string; game.chatkey=CharToKey(string); + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> i; + showdamagebar = (i != 0); ipstream.close(); if(detail>2)detail=2;