home *** CD-ROM | disk | FTP | other *** search
- #include "Hud.h"
-
- #include "log.h"
- #include "Tokenizer.h"
- #include "Game.h"
- #include "TextureHandler.h"
- #include "FontHandler.h"
-
- #include "LoadingMenu.h"
- #include "GuiInfo.h"
- #include "Gui.h"
- #include "Display.h"
- #include "Renderer.h"
- #include "RendererInfo.h"
- #include "Network.h"
-
- #ifndef WIN32
- #include <stdarg.h> // fr linux va_kram
- #define _vsnprintf vsnprintf
- #endif
-
-
- Hud::Hud(){
- //font=FontHandler::getFont("gui/fonts/courier_small_bold.font");
- font = FontHandler::getFont("gui/fonts/scifi_small.font");
- messagebox = new HudMessagebox();
- centerOfScreenMessages = new HudCenterOfScreenMessages();
- chatPrompt = new HudChatPrompt();
- crosshair = new HudCrosshair();
- statusbar = new HudStatusbar();
- debugInfo = new HudDebugInfo();
- scoreboard = new HudScoreboard();
- takeDamageIndicator = new HudTakeDamageIndicator();
-
- teamMarkerShader = new Shader("gui/hud/team_marker.shader");
- hudReferenceTexture = TextureHandler::getTexture("gui/hud/hud_reference.jpg");
- }
-
- Hud::~Hud(){
- delete debugInfo;
- delete messagebox;
- delete centerOfScreenMessages;
- delete chatPrompt;
- delete crosshair;
- delete statusbar;
- delete scoreboard;
-
- if(font!=NULL)
- FontHandler::releaseFont(font);
-
- delete teamMarkerShader;
- TextureHandler::releaseTexture(hudReferenceTexture);
- }
-
-
- void Hud::draw(){
-
- // if( Gui::info.var.hud_markTeamMembers ){ // jetzt in Renderer::renderScene!
- // renderTeamMarkers();
- // }
-
- Renderer::beginDrawing();
-
- if( Gui::info.var.hud_drawTakeDamageIndicator ){
- takeDamageIndicator->draw();
- }
-
- if( Gui::info.var.hud_drawMessagebox )
- messagebox->draw();
-
- if( Gui::info.var.hud_drawCrosshair )
- crosshair->draw();
-
- if( Gui::info.var.hud_drawStatusbar )
- statusbar->draw();
-
- if( Gui::info.var.hud_drawCenterOfScreenMessages )
- centerOfScreenMessages->draw();
-
- if( Gui::info.var.hud_drawMiniscoreboard && Network::client->ci.team != GAME_TEAM_SPECTATORS )
- scoreboard->drawMiniscoreboard();
-
- if( Gui::info.var.hud_identifyTarget )
- drawTarget();
-
- if( Gui::info.var.hud_drawScoreboard )
- scoreboard->draw();
-
- if( Gui::info.var.hud_drawFPS )
- drawFPS();
-
- if( Gui::info.var.hud_drawPing )
- drawPing();
-
- if( Gui::info.var.hud_drawDebugInfo )
- debugInfo->draw();
-
- if( chatPrompt->isActive )
- chatPrompt->draw();
-
- if( Gui::info.var.hud_drawHelp )
- drawHelp();
-
- Renderer::endDrawing();
- }
-
-
- void Hud::drawFPS(){
- glColor4fv(Gui::info.var.hud_activeColor);
- drawAlignedFormatString(790, 570, font, TEXT_ALIGN_RIGHT, "fps: %.1f", Renderer::info.var.fps);
- }
-
-
- void Hud::drawPing(){
- glColor4fv(Gui::info.var.hud_activeColor);
- // if(SDL_GetTicks() - Network::client->lastPingMillis > (unsigned long)Network::info.var.server_pingInterval){ // connection interrupted
- // glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- // drawAlignedString(790, 540, font, TEXT_ALIGN_RIGHT, "<connection interrupted>");
- // }else{
- drawAlignedFormatString(790, 540, font, TEXT_ALIGN_RIGHT, "ping: %i", Network::client->ci.ping);
- // }
- }
-
- void Hud::drawTarget(){
- // if( Game::cam.mode == CAMERA_MODE_THIRD_PERSON )
- // return;
-
- unsigned int i;
- trace_t trace;
- trace.ignoreFlags = 0 | COLLISION_FLAG_BACKFACES | COLLISION_FLAG_SHOOT_THROUGH;
-
- traceRay(Game::cam.pos, Game::cam.dir, &trace);
-
- Vehicle* target = NULL;
- for(i=0;i<trace.hits.size();i++){
- if( trace.hits[i].face != NULL ){ // hit a face of the arena
-
- break;
- }
- if( trace.hits[i].vehicle != NULL ){ // hit a vehicle
- if( trace.hits[i].vehicle == Game::cam.target && Game::cam.mode != CAMERA_MODE_FREE )
- continue;
-
- target = trace.hits[i].vehicle;
- break;
- }
- }
-
- if( target == NULL ) // no target
- return;
-
- texFont_t* font = Gui::hud->font;
- if( Game::info.var.mode == GAME_MODE_TEAM_DEATHMATCH ){
- if( target->client->ci.team == GAME_TEAM_RED ){
- glColor3f(1.0f, 0.0f, 0.0f);
- }else{
- glColor3f(0.0f, 0.0f, 1.0f);
- }
- }else{
- glColor4fv(Gui::info.var.hud_activeColor);
- }
-
- int y = 330;
- if( Gui::info.var.hud_identifyTarget == 2 ) // bottom
- y = 80;
-
-
- if( Game::cam.target == NULL || Game::cam.mode == CAMERA_MODE_FREE
- || (Game::info.var.mode == GAME_MODE_TEAM_DEATHMATCH && Game::cam.target != NULL && Game::cam.target->client->ci.team == target->client->ci.team)
- ){ // with health
- drawAlignedFormatString(400, y, font, TEXT_ALIGN_CENTER, "%s (%i)", target->client->ci.name, (int)( target->armor ) );
- }else{ // no health
- drawAlignedString(400, y, font, TEXT_ALIGN_CENTER, target->client->ci.name);
- }
-
- }
-
- void Hud::drawHelp(){
- texFont_t* font = Gui::info.var.menu_smallFont;
- float fontScale = 0.9f;
-
- Renderer::drawQuad(50, 80, 750, 520, Gui::info.var.hud_activeColor, Gui::info.var.hud_backgroundColor);
-
- glColor4fv(Gui::info.var.hud_activeColor);
- drawScaledAndAlignedString(400, 490, 1.1f, 1.1f, font, TEXT_ALIGN_CENTER, "[ QUICK REFERENCE (F1) ]");
-
- int y = 460;
- drawScaledAndAlignedString(70, y, 1.1f, 1.1f, font, TEXT_ALIGN_LEFT, "VEHICLE CONTROLS:");
- y-=25;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "mouse/cursor-keys - look");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "w - forward");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "s - backwards");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "a - left");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "d - right");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "space - up/jumpjets");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "left ctrl - down");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "left mouse - fire weapon 1");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "right mouse - fire weapon 2");
- y-=30;
-
- drawScaledAndAlignedString(70, y, 1.1f, 1.1f, font, TEXT_ALIGN_LEFT, "CAMERA CONTROLS:");
- y-=25;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_enter - toggle camera mode");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_ins - reset camera");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_arrows - rotate camera");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_plus - zoom in");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_minus - zoom out");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_multiply - chase next");
- y-=20;
- drawScaledAndAlignedString(70, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "kp_divide - chase previous");
-
- y = 460;
- drawScaledAndAlignedString(420, y, 1.1f, 1.1f, font, TEXT_ALIGN_LEFT, "MISC CONTROLS:");
- y-=25;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "tab - toggle scoreboard");
- y-=20;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "y - message to all");
- y-=20;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "t - message to team");
- y-=20;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "k - kill yourself");
- y-=20;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "esc - toggle in game menu");
- y-=20;
- drawScaledAndAlignedString(420, y, fontScale, fontScale, font, TEXT_ALIGN_LEFT, "~ - toggle console");
- y-=30;
-
- drawScaledAndAlignedString(420, y, 1.1f, 1.1f, font, TEXT_ALIGN_LEFT, "HUD:");
-
- glColor3f(1.0f, 1.0f, 1.0f);
- Renderer::drawTexturedQuad(420, 100, 730, 300, hudReferenceTexture);
- }
-
-
- void Hud::renderTeamMarkers(){
- for(int i=0;i<GAME_MAX_VEHICLES;i++){
- if( Game::vehicles[i] != NULL && Game::info.var.mode == GAME_MODE_TEAM_DEATHMATCH
- && Game::vehicles[i]->client->ci.team == Network::client->ci.team
- ){
-
- vec3_t p;
- vectorMA3d(Game::vehicles[i]->pos, 1.5f, Game::cam.up, p);
- if( Renderer::info.var.useTransparentPolysList ){
- Renderer::addBillboardToTransparentPolys(p, 1.0f, 1.0f, teamMarkerShader, SDL_GetTicks());
- }else{
- Renderer::renderBillboard(p, 1.0f, 1.0f, teamMarkerShader, SDL_GetTicks());
- }
- }
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // MESSAGE BOX
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
- Message::Message(const char* string){
- this->string=newString(string);
- spawntime=SDL_GetTicks();
- }
-
- Message::~Message(){
- delete[] string;
- }
-
-
- HudMessagebox::HudMessagebox(){
- for(int i=0;i<HUD_MESSAGE_BOX_MAX_MESSAGES;i++){
- messages[i]=NULL;
- }
-
- font=FontHandler::getFont("gui/fonts/eurasia_medium_normal_border.font");
-
- chatMessageSound = Sound::loadWAV("gui/hud/chat_beep.wav");
-
- // visible=true;
- }
-
- HudMessagebox::~HudMessagebox(){
- if(font!=NULL)
- FontHandler::releaseFont(font);
-
- for(int i=0;i<HUD_MESSAGE_BOX_MAX_MESSAGES;i++){
- if(messages[i]!=NULL)
- delete messages[i];
- }
-
- Mix_FreeChunk(chatMessageSound);
- }
-
- void HudMessagebox::addMessage(Message* message){
- if(messages[HUD_MESSAGE_BOX_MAX_MESSAGES-1]!=NULL){
- delete messages[HUD_MESSAGE_BOX_MAX_MESSAGES-1];
- }
- for(int i=HUD_MESSAGE_BOX_MAX_MESSAGES-1;i>0;i--){
- messages[i]=messages[i-1];
- }
- messages[0]=message;
- }
-
- void HudMessagebox::deleteMessage(Message* message){
- if(message==NULL)
- return;
-
- for(int i=0;i<HUD_MESSAGE_BOX_MAX_MESSAGES;i++){
- if(messages[i]==message){
- delete messages[i];
- for(int j=i;j<HUD_MESSAGE_BOX_MAX_MESSAGES-1;j++){
- messages[j]=messages[j+1];
-
- }
- messages[HUD_MESSAGE_BOX_MAX_MESSAGES-1]=NULL;
- }
- }
- }
-
- void HudMessagebox::addChatMessage(Client* fromClient, chatMessagePacket_t* cm){
- if( fromClient == NULL ){ // message from server
- log("^7%s: %s\n", "<server>", cm->message);
- }else{
- if( cm->mode == GAME_CHAT_MODE_TEAM ){
- log("^6[%s]: %s\n", fromClient->ci.name, cm->message);
- }else{
- log("^3%s: %s\n", fromClient->ci.name, cm->message);
- }
- }
-
- if(Sound::info.var.enabled && Sound::info.var.playSamples)
- Sound::playSample(SOUND_COMPUTER_CHANNEL, chatMessageSound);
- }
-
- void HudMessagebox::draw(){
- int i;
- int x = 10;
- int y = DISPLAY_VSCREEN_HEIGHT;
-
- float scale = 0.7f;
-
- for(i = Gui::info.var.hud_messagebox_numLines-1; i >= 0; i--){
- if(messages[i] != NULL){
- glColor4fv(Gui::info.var.hud_activeColor);
- y = (int)( y-(font->height+1)*scale );
- drawScaledAndAlignedString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, messages[i]->string);
- }
- }
-
- unsigned int currentTime = SDL_GetTicks();
- for(i = 0; i < HUD_MESSAGE_BOX_MAX_MESSAGES; i++){
- if(messages[i] != NULL && (currentTime - messages[i]->spawntime > (unsigned int)Gui::info.var.hud_messagebox_messageLifetime) ){
-
- delete messages[i];
- for(int j=i;j<HUD_MESSAGE_BOX_MAX_MESSAGES-1;j++){
- messages[j]=messages[j+1];
- }
- messages[HUD_MESSAGE_BOX_MAX_MESSAGES-1]=NULL;
- }
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // CENTER OF SCREEN MESSAGES
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- HudCenterOfScreenMessages::HudCenterOfScreenMessages(){
- message = NULL;
- lastMessageMillis = 0;
- }
-
- HudCenterOfScreenMessages::~HudCenterOfScreenMessages(){
- if( message != NULL )
- delete[] message;
- }
-
-
- void HudCenterOfScreenMessages::setMessage(const char* formatString, ...){
- if( message != NULL )
- delete[] message;
-
- va_list ap;
- char toStringBuffer[512];
-
- va_start (ap, formatString);
- _vsnprintf(toStringBuffer, 511, formatString, ap);
- va_end(ap);
- toStringBuffer[511]='\0';
-
- this->message = newString(toStringBuffer);
- this->lastMessageMillis = SDL_GetTicks();
- }
-
- void HudCenterOfScreenMessages::draw(){
- texFont_t* font = Gui::hud->font;
-
- if( message != NULL ){
- unsigned long currentMillis = SDL_GetTicks();
-
- if( currentMillis > lastMessageMillis + Gui::info.var.hud_messagebox_messageLifetime ){
- delete message;
- message = NULL;
- }else{
- vec4_t col;
- vectorCopy4d(Gui::info.var.hud_activeColor, col);
-
- col[3] = 1.0f;
- float q = (currentMillis - lastMessageMillis)/(float)Gui::info.var.hud_messagebox_messageLifetime;
- if( q > 0.75f ) {
- col[3] = -4.0f*q + 4.0f;
- }
-
- glColor4fv(col);
- drawScaledAndAlignedString(400, 350, 0.8f, 0.8f, Gui::info.var.menu_bigFont, TEXT_ALIGN_CENTER, message);
- }
- }
-
- // camera related stuff
- glColor4fv(Gui::info.var.hud_activeColor);
- if( Game::cam.target != NULL && Game::cam.target != Network::client->vehicle ){
- if( Game::cam.mode == CAMERA_MODE_FIRST_PERSON ){
- drawAlignedFormatString(400, 250, font, TEXT_ALIGN_CENTER, "chasing %s - first person view", Game::cam.target->client->ci.name);
- }else if( Game::cam.mode == CAMERA_MODE_THIRD_PERSON ){
- drawAlignedFormatString(400, 250, font, TEXT_ALIGN_CENTER, "chasing %s - third person view", Game::cam.target->client->ci.name);
- }else if( Game::cam.mode == CAMERA_MODE_FREE ){
- // drawAlignedFormatString(400, 250, font, TEXT_ALIGN_CENTER, "chasing %s - free camera", Game::cam.target->client->ci.name);
- drawAlignedString(400, 250, font, TEXT_ALIGN_CENTER, "free camera");
- }
- }else{
- if( Game::cam.mode == CAMERA_MODE_FREE || Game::cam.target == NULL ){
- drawAlignedString(400, 250, font, TEXT_ALIGN_CENTER, "free camera");
- }else if( Game::cam.mode == CAMERA_MODE_THIRD_PERSON ){
- drawAlignedString(400, 250, font, TEXT_ALIGN_CENTER, "third person view");
- }
- }
-
- // team related stuff
- if( Game::info.var.player_team != Game::info.cvar.game_player_team->getVal() && Network::client->vehicle == NULL ){ // waiting for team change
- drawAlignedFormatString(400, 200, font, TEXT_ALIGN_CENTER, "you will change teams in %i seconds.", (int)( (Network::client->nextSpawnMillis - SDL_GetTicks()) / 1000 + 1) );
- }else{
- if( Game::info.var.player_team == GAME_TEAM_SPECTATORS ){ // spectating
- drawAlignedFormatString(400, 200, font, TEXT_ALIGN_CENTER, "you are spectating - use the equipment menu to join the game.");
- }else{
- if( Network::client->vehicle == NULL ){ // dead
- drawAlignedFormatString(400, 200, font, TEXT_ALIGN_CENTER, "you will respawn in %i seconds.", (int)( (Network::client->nextSpawnMillis - SDL_GetTicks()) / 1000 + 1 ) );
- }
- }
- }
- }
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // CHAT PROMPT
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- HudChatPrompt::HudChatPrompt(){
- isActive = false;
- mode = -1;
-
- promptStr = NULL;
- inputStr = NULL;
- inputStrIndex = 0;
-
- font=FontHandler::getFont("gui/fonts/eurasia_medium_normal_border.font");
- }
-
- HudChatPrompt::~HudChatPrompt(){
- if(font!=NULL)
- FontHandler::releaseFont(font);
-
- if(inputStr != NULL)
- delete[] inputStr;
- }
-
- void HudChatPrompt::activate(int mode){
- this->mode = mode;
-
- SDL_EnableUNICODE(1);
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-
- inputStr = new char[CON_MAX_STRING_LENGTH];
- inputStr[0] = '\0';
- inputStrIndex = 0;
-
- if( mode == GAME_CHAT_MODE_TEAM ){
- promptStr = "^6[team]: ";
- }else{
- promptStr = "^3[all]: ";
- }
-
- isActive=true;
- }
-
-
- void HudChatPrompt::deactivate(){
- SDL_EnableUNICODE(0);
- SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
-
- delete[] inputStr;
- inputStr = NULL;
-
- mode = -1;
-
- isActive=false;
- }
-
- void HudChatPrompt::receiveKey(SDL_keysym* keysym){
- int i;
- SDLKey key=keysym->sym;
-
- if(key==SDLK_ESCAPE){
- deactivate();
- }else if(key==SDLK_RIGHT){
- if(inputStr[inputStrIndex]!='\0'){
- inputStrIndex++;
- }
- }else if(key==SDLK_LEFT){
- if(inputStrIndex>0){
- inputStrIndex--;
- }
- }else if(key==SDLK_HOME){
- inputStrIndex=0;
- }else if(key==SDLK_END){
- inputStrIndex=strlen(inputStr);
- }else if(key==SDLK_RETURN){ // enter
-
- if( mode == GAME_CHAT_MODE_TEAM ){
- Game::chatMessageTeam(inputStr);
- }else{
- Game::chatMessageAll(inputStr);
- }
-
- deactivate();
-
- }else if(key==SDLK_BACKSPACE){ // backspace
- if(inputStrIndex<=0)
- return;
-
- i=inputStrIndex-1;
- while(inputStr[i]!='\0'){
- inputStr[i]=inputStr[i+1];
- i++;
- }
- inputStrIndex-=1;
- }else if(key==SDLK_DELETE){ // del
- if(inputStr[inputStrIndex]=='\0')
- return;
-
- i=inputStrIndex;
- while(inputStr[i]!='\0'){
- inputStr[i]=inputStr[i+1];
- i++;
- }
- }else{ // add char to inputStr
- int l=strlen(inputStr);
- if(l < CON_MAX_STRING_LENGTH){
- char ch;
- if ( (keysym->unicode & 0xFF80) == 0 && keysym->unicode!=0) {
- ch = keysym->unicode & 0x7F;
- for(i=l+1;i>inputStrIndex;i--){
- inputStr[i]=inputStr[i-1];
- }
-
- inputStr[inputStrIndex]=ch;
- inputStrIndex++;
- //inputStr[inputStrIndex+1]='\0';
- //inputStrIndex = inputStrIndex >= CON_MAX_LINE_LENGTH-1 ? CON_MAX_LINE_LENGTH-1 : inputStrIndex+1;
- }else{
- // warn("(in ConsoleFrontEnd::recieveKey()): unicode of key not known!\n\n");
- }
- }
- }
-
- }
-
-
-
- void HudChatPrompt::draw(){
- int x = 10;
- int y = 80;
- float scale = 0.8f;
-
- //glColor4fv(Gui::info.var.hud_activeColor);
- // if( mode == GAME_CHAT_MODE_TEAM ){
- // }else{
- // }
-
- drawScaledFormatString(x, y, scale, scale,
- font, "%s%s", promptStr, inputStr);
-
- if((SDL_GetTicks()/500)%2){
- char buff[CON_MAX_STRING_LENGTH];
- strncpy(buff, inputStr, inputStrIndex);
- buff[inputStrIndex] = '\0';
- float xOffs = (getStringWidth(font, promptStr)+getStringWidth(font, buff))*scale;
- drawScaledString(x+(int)xOffs, y, scale, scale, font, "_");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // CROSSHAIR
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
- HudCrosshair::HudCrosshair(){
- crosshairTextures[0] = TextureHandler::getTexture("gui/hud/crosshair_01.tga");
- crosshairTextures[1] = TextureHandler::getTexture("gui/hud/crosshair_02.tga");
- crosshairTextures[2] = TextureHandler::getTexture("gui/hud/crosshair_03.tga");
- crosshairTextures[3] = TextureHandler::getTexture("gui/hud/crosshair_04.tga");
- crosshairTextures[4] = TextureHandler::getTexture("gui/hud/crosshair_05.tga");
- crosshairTextures[5] = TextureHandler::getTexture("gui/hud/crosshair_06.tga");
- crosshairTextures[6] = TextureHandler::getTexture("gui/hud/crosshair_07.tga");
- crosshairTextures[7] = TextureHandler::getTexture("gui/hud/crosshair_08.tga");
-
- // visible=true;
- }
-
- HudCrosshair::~HudCrosshair(){
- for(int i=0;i<8;i++){
- if(crosshairTextures[i]){
- TextureHandler::releaseTexture(crosshairTextures[i]);
- }
- }
- }
-
- void HudCrosshair::draw(){
- int size=30;
-
- glColor4fv(Gui::info.var.hud_activeColor);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, crosshairTextures[Gui::info.var.hud_crosshair]->texName);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex2f((400-size), (300-size));
- glTexCoord2f(1.0f, 0.0f); glVertex2f((400+size), (300-size));
- glTexCoord2f(1.0f, 1.0f); glVertex2f((400+size), (300+size));
- glTexCoord2f(0.0f, 1.0f); glVertex2f((400-size), (300+size));
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
- }
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // STATUSBAR
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- HudStatusbar::HudStatusbar(){
-
- min[0]=10;
- max[0]=522;
- min[1]=10;
- max[1]=74;
-
- background = TextureHandler::getTexture("gui/hud/status_info_background.tga");
- energyIcon = TextureHandler::getTexture("gui/hud/energy_icon.tga");
- armorIcon = TextureHandler::getTexture("gui/hud/armor_icon.tga");
-
- weaponThumbnails[GAME_WEAPON_NO_WEAPON] = NULL;
- weaponThumbnails[GAME_WEAPON_LASER] = TextureHandler::getTexture("weapons/laser/laser_thumbnail.tga");
- weaponThumbnails[GAME_WEAPON_CHAINGUN] = TextureHandler::getTexture("weapons/chaingun/chaingun_thumbnail.tga");
- weaponThumbnails[GAME_WEAPON_RAILGUN] = TextureHandler::getTexture("weapons/railgun/railgun_thumbnail.tga");
- weaponThumbnails[GAME_WEAPON_ROCKETLAUNCHER] = TextureHandler::getTexture("weapons/rocketlauncher/rocketlauncher_thumbnail.tga");
- weaponThumbnails[GAME_WEAPON_PLASMAGUN] = TextureHandler::getTexture("weapons/plasmagun/plasmagun_thumbnail.tga");
- }
-
- HudStatusbar::~HudStatusbar(){
- TextureHandler::releaseTexture(background);
- TextureHandler::releaseTexture(energyIcon);
- TextureHandler::releaseTexture(armorIcon);
-
- for(int i=0;i<GAME_NUM_WEAPONS;i++){
- if( weaponThumbnails[i] != NULL )
- TextureHandler::releaseTexture(weaponThumbnails[i]);
- }
- }
-
- void HudStatusbar::draw(){
-
- if( Game::cam.target == NULL || Game::cam.mode == CAMERA_MODE_FREE ){
- return;
- }
-
- Vehicle* v = Game::cam.target;
-
- // bars
- float armorPercent = v->armor/(float)v->maxArmor;
- float energyPercent = v->energy/(float)v->maxEnergy;
-
- vec4_t col;
- vectorInit4d(1.0f, 0.0f, 0.0f, 0.5f, col);
- Renderer::drawQuad(min[0]+35, min[1]+3, (int)( min[0]+35 + (217)*armorPercent ), min[1]+29, col, col);
-
- vectorInit4d(0.0f, 0.0f, 1.0f, 0.5f, col);
- Renderer::drawQuad(min[0]+35, min[1]+36, (int)( min[0]+35 + (217)*energyPercent ), min[1]+62, col, col);
-
-
- // weapons
- int x = min[0] + 259;
- int y = min[1] + 4;
- for(int k=0;k<4;k++){
- if( v->weapons[k] == NULL )
- continue;
-
- float weaponEnergyPercent = 1.0f;
- if( v->weapons[k]->maxEnergy > 0 ){ // bar is energy info
- weaponEnergyPercent = v->weapons[k]->energy/(float)v->weapons[k]->maxEnergy;
- }else if( v->weapons[k]->maxAmmo > 0 ){ // bar is ammo info
- weaponEnergyPercent = v->weapons[k]->ammo/(float)v->weapons[k]->maxAmmo;
- }
- vec4_t col;
- vectorInit4d(1.0f, 0.0f, 0.0f, 0.5f, col);
- vectorLinCombi3d(weaponEnergyPercent, Gui::info.var.hud_activeColor, 1.0f-weaponEnergyPercent, col, col);
- col[3] = 0.5f;
- Renderer::drawQuad(x, y, x+57, (int)(y+57*weaponEnergyPercent), col, col);
-
- if( v->weapons[k]->isReadyToFire() ){
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- }else{
- glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
- }
- Renderer::drawTexturedQuad(x, y, x+57, y+57, weaponThumbnails[v->weapons[k]->type]);
-
- if( v->weapons[k]->maxAmmo > 0 ){ // draw ammo info
- if( v->weapons[k]->ammo > v->weapons[k]->maxAmmo*0.2f ){
- glColor4f(0.1f, 0.6f, 1.0f, 1.0f);
- }else if( v->weapons[k]->ammo > v->weapons[k]->maxAmmo*0.1f ){
- glColor4f(1.0f, 0.8f, 0.1f, 1.0f);
- }else{
- glColor4f(1.0f, 0.1f, 0.1f, 1.0f);
- }
- drawShadowedFormatString(x+53, y+2, 1.0f, 1, Gui::info.var.menu_tinyFont, TEXT_ALIGN_RIGHT, "%i", v->weapons[k]->ammo);
- }
-
- x += 64;
- }
-
- drawBackground();
- }
-
- void HudStatusbar::drawBackground(){
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, background->texName);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glColor4fv(Gui::info.var.hud_activeColor);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex2f(min[0], min[1]);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(max[0], min[1]);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(max[0], max[1]);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(min[0], max[1]);
- glEnd();
- glDisable(GL_TEXTURE_2D);
-
- glColor3f(1.0f, 1.0f, 1.0f);
- int x = min[0]+3;
- int y = min[1]+4;
- Renderer::drawTexturedQuad(x, y, x+24, y+24, armorIcon);
- y+=32;
- Renderer::drawTexturedQuad(x, y, x+24, y+24, energyIcon);
- }
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // SCOREBOARD
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- HudScoreboard::HudScoreboard(){
- font=FontHandler::getFont("gui/fonts/courier_small_bold.font");
-
- }
-
- HudScoreboard::~HudScoreboard(){
- if(font!=NULL)
- FontHandler::releaseFont(font);
- }
-
- void HudScoreboard::draw(){
- drawBackground();
-
- if( Game::info.var.mode == GAME_MODE_DEATHMATCH ){
- drawDeathmatchScoreboard();
- }else if( Game::info.var.mode == GAME_MODE_TEAM_DEATHMATCH ){
- drawTeamDeathmatchScoreboard();
- }
-
-
- }
-
- void HudScoreboard::drawMiniscoreboard(){
- glColor4fv(Gui::info.var.hud_activeColor);
-
- if( Game::info.var.mode == GAME_MODE_DEATHMATCH ){
- int highestScore = -99;
- for(int i=0;i<Network::server->si.maxClients;i++){
- if( Network::server->clients[i] != NULL && Network::server->clients[i]->ci.team != GAME_TEAM_SPECTATORS ){
- if( Network::server->clients[i]->ci.score > highestScore ){
- highestScore = Network::server->clients[i]->ci.score;
- }
- }
- }
- drawAlignedFormatString(790, 30, Gui::hud->font, TEXT_ALIGN_RIGHT, "1st: %i", highestScore);
- drawAlignedFormatString(790, 5, Gui::hud->font, TEXT_ALIGN_RIGHT, "you: %i", Network::client->ci.score);
-
- }else if( Game::info.var.mode == GAME_MODE_TEAM_DEATHMATCH ){
- int redScore = 0;
- int blueScore = 0;
- for(int i=0;i<Network::server->si.maxClients;i++){
- if( Network::server->clients[i] != NULL ){
- if( Network::server->clients[i]->ci.team == GAME_TEAM_RED ){
- redScore += Network::server->clients[i]->ci.score;
- }else if( Network::server->clients[i]->ci.team == GAME_TEAM_BLUE ){
- blueScore += Network::server->clients[i]->ci.score;
- }
- }
- }
-
- drawAlignedFormatString(790, 30, Gui::hud->font, TEXT_ALIGN_RIGHT, "red: %i", redScore);
- drawAlignedFormatString(790, 5, Gui::hud->font, TEXT_ALIGN_RIGHT, "blue: %i", blueScore);
- }
-
- }
-
- void HudScoreboard::drawBackground(){
- //glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
- vec2_t min, max;
- vectorInit2d(20, 100, min);
- vectorInit2d(780, 500, max);
- glColor4fv(Gui::info.var.hud_backgroundColor);
- glBegin(GL_QUADS);
- glVertex2f(min[0], min[1]);
- glVertex2f(max[0], min[1]);
- glVertex2f(max[0], max[1]);
- glVertex2f(min[0], max[1]);
- glEnd();
-
- glColor4fv(Gui::info.var.hud_activeColor);
- glBegin(GL_LINE_LOOP);
- glVertex2f(min[0], min[1]);
- glVertex2f(max[0], min[1]);
- glVertex2f(max[0], max[1]);
- glVertex2f(min[0], max[1]);
- glEnd();
-
- }
-
- void HudScoreboard::drawDeathmatchScoreboard(){
- int i, j;
- Client** players = new Client*[Network::server->si.numClients];
- Client** spectators = new Client*[Network::server->si.numClients];
- int numPlayers = 0;
- int numSpectators = 0;
-
- for(i=0;i<Network::server->si.maxClients;i++){
- if( Network::server->clients[i] != NULL ){
- if( Network::server->clients[i]->ci.team == GAME_TEAM_SPECTATORS ){
- spectators[numSpectators] = Network::server->clients[i];
- numSpectators++;
- }else{
- players[numPlayers] = Network::server->clients[i];
- numPlayers++;
- }
- }
- }
-
- for(i=0;i<numPlayers;i++){
- for(j=i+1;j<numPlayers;j++){
- if( players[i]->ci.score < players[j]->ci.score ){
- Client* tmp = players[i];
- players[i] = players[j];
- players[j] = tmp;
- }
- }
- }
-
- // PLAYERS
- glColor4fv(Gui::info.var.hud_activeColor);
-
- float scale = 0.9f;
- int yUpper = 477;
- int y = yUpper;
- int ySpacing = 20;
- // first column (rank)
- int x = 29;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "RNK");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+25, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", i+1);
- }
-
- // second column (name)
- x += 40;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "NAME");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "%s (id:%i)", players[i]->ci.name, players[i]->clientId);
- }
-
- // third column (status)
- x += 350;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "STATE");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- if( players[i]->vehicle != NULL ){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", players[i]->cs.armor);
- }else{
- drawScaledAndAlignedString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "DEAD");
- }
- }
-
- // third column (score)
- x += 70;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "SCORE");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", players[i]->ci.score);
- }
-
- // fourth column (kills)
- x += 70;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "KILLS");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", players[i]->ci.kills);
- }
-
- // fifth column (deaths)
- x += 70;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "DEATHS");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", players[i]->ci.deaths);
- }
-
- // sixth column (time)
- x += 65;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "TIME");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- int mins = players[i]->ci.secondsOnServer / 60;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", mins);
- }
-
- // seventh column (ping)
- x += 55;
- y = yUpper;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "PING");
- for(i=0;i<numPlayers;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", players[i]->ci.ping);
- }
-
- // SPECTATORS
- int yLower = 105;
- if( numSpectators > 0 ){
- y = yLower + (numSpectators*ySpacing);
- x = 29;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "SPECTATORS:");
-
- // second column (name)
- x += 40;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "%s (id:%i)", spectators[i]->ci.name, spectators[i]->clientId);
- }
-
- // third column (status)
- x += 350;
-
- // third column (score)
- x += 70;
-
- // fourth column (kills)
- x += 70;
-
- // fifth column (deaths)
- x += 70;
-
- // sixth column (time)
- x += 65;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- int mins = spectators[i]->ci.secondsOnServer / 60;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", mins);
- }
-
- // seventh column (ping)
- x += 55;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", spectators[i]->ci.ping);
- }
- }
-
- // draw marker
- vec4_t transparent;
- vectorInit4d(0.0f, 0.0f, 0.0f, 0.0f, transparent);
- if( Network::client->ci.team == GAME_TEAM_PLAYERS ){
- y = yUpper - ySpacing;
- for(i=0;i<numPlayers;i++){
- if( players[i] == Network::client ){
- Renderer::drawQuad(25, y, 775, y+ySpacing-2, Gui::info.var.hud_activeColor, transparent);
- }
- y -= ySpacing;
- }
- }else{
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- if( spectators[i] == Network::client ){
- Renderer::drawQuad(25, y, 775, y+ySpacing-2, Gui::info.var.hud_activeColor, transparent);
- }
- }
- }
-
- delete[] players;
- delete[] spectators;
- }
-
- void HudScoreboard::drawTeamDeathmatchScoreboard(){
- int i, j;
- Client** reds = new Client*[Network::server->si.numClients];
- Client** blues = new Client*[Network::server->si.numClients];
- Client** spectators = new Client*[Network::server->si.numClients];
- int numReds = 0;
- int numBlues = 0;
- int numSpectators = 0;
- int redScore = 0;
- int blueScore = 0;
- int redKills = 0;
- int blueKills = 0;
- int redDeaths = 0;
- int blueDeaths = 0;
-
- for(i=0;i<Network::server->si.maxClients;i++){
- if( Network::server->clients[i] != NULL ){
- if( Network::server->clients[i]->ci.team == GAME_TEAM_SPECTATORS ){
- spectators[numSpectators] = Network::server->clients[i];
- numSpectators++;
- }else if( Network::server->clients[i]->ci.team == GAME_TEAM_RED ){
- reds[numReds] = Network::server->clients[i];
- numReds++;
- redScore += Network::server->clients[i]->ci.score;
- redKills += Network::server->clients[i]->ci.kills;
- redDeaths += Network::server->clients[i]->ci.deaths;
- }else if( Network::server->clients[i]->ci.team == GAME_TEAM_BLUE ){
- blues[numBlues] = Network::server->clients[i];
- numBlues++;
- blueScore += Network::server->clients[i]->ci.score;
- blueKills += Network::server->clients[i]->ci.kills;
- blueDeaths += Network::server->clients[i]->ci.deaths;
- }
- }
- }
-
- for(i=0;i<numReds;i++){
- for(j=i+1;j<numReds;j++){
- if( reds[i]->ci.score < reds[j]->ci.score ){
- Client* tmp = reds[i];
- reds[i] = reds[j];
- reds[j] = tmp;
- }
- }
- }
- for(i=0;i<numBlues;i++){
- for(j=i+1;j<numBlues;j++){
- if( blues[i]->ci.score < blues[j]->ci.score ){
- Client* tmp = blues[i];
- blues[i] = blues[j];
- blues[j] = tmp;
- }
- }
- }
-
- // HEADING
- glColor4fv(Gui::info.var.hud_activeColor);
-
- float scale = 0.9f;
- int yUpper = 477;
- int y = yUpper;
- int ySpacing = 20;
-
- int x = 400;
- if( redScore > blueScore ){
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "RED leads BLUE with %i to %i", redScore, blueScore);
- }else if( redScore < blueScore ){
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "BLUE leads RED with %i to %i", blueScore, redScore);
- }else{
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "Teams are TIED with %i", redScore);
- }
-
- y -= ySpacing;
-
- // first column (rank)
- x = 29;
- // drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "RNK");
- // second column (name)
- x += 40;
- // drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "NAME");
- // third column (status)
- x += 350;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "STATE");
- // third column (score)
- x += 70;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "SCORE");
- // fourth column (kills)
- x += 70;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "KILLS");
- // fifth column (deaths)
- x += 70;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "DEATHS");
- // sixth column (time)
- x += 65;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "TIME");
-
- // seventh column (ping)
- x += 55;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_CENTER, "PING");
-
- y -= ySpacing;
-
- // RED TEAM
- vec4_t fill, border;
- vectorInit4d(1.0f, 0.0f, 0.0f, 0.25f, fill);
- vectorInit4d(1.0f, 0.0f, 0.0f, 1.0f, border);
- Renderer::drawQuad(24, y - ySpacing*(numReds) - 2, 776, y + ySpacing, border, fill);
- glColor4fv(Gui::info.var.hud_activeColor);
-
- x = 29;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "RED Team (%i players):", numReds);
- x += 40;
- x += 350;
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", redScore);
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", redKills);
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", redDeaths);
-
- y -= ySpacing;
-
- // team members
- int ySave = y;
- // rank
- x = 29;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x+25, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", i+1);
- y -= ySpacing;
- }
- // second column (name)
- x += 40;
- y = ySave;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "%s (id:%i)", reds[i]->ci.name, reds[i]->clientId);
- y -= ySpacing;
- }
- // third column (status)
- x += 350;
- y = ySave;
- for(i=0;i<numReds;i++){
- if( reds[i]->vehicle != NULL ){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", reds[i]->cs.armor);
- }else{
- drawScaledAndAlignedString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "DEAD");
- }
- y -= ySpacing;
- }
- // third column (score)
- x += 70;
- y = ySave;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", reds[i]->ci.score);
- y -= ySpacing;
- }
- // fourth column (kills)
- x += 70;
- y = ySave;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", reds[i]->ci.kills);
- y -= ySpacing;
- }
- // fifth column (deaths)
- x += 70;
- y = ySave;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", reds[i]->ci.deaths);
- y -= ySpacing;
- }
- // sixth column (time)
- x += 65;
- y = ySave;
- for(i=0;i<numReds;i++){
- int mins = reds[i]->ci.secondsOnServer / 60;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", mins);
- y -= ySpacing;
- }
- // seventh column (ping)
- x += 55;
- y = ySave;
- for(i=0;i<numReds;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", reds[i]->ci.ping);
- y -= ySpacing;
- }
-
-
- y -= ySpacing;
-
-
- // BLUE TEAM
- // vec4_t fill, border;
- vectorInit4d(0.0f, 0.0f, 1.0f, 0.25f, fill);
- vectorInit4d(0.0f, 0.0f, 1.0f, 1.0f, border);
- Renderer::drawQuad(24, y - ySpacing*(numBlues) - 2, 776, y + ySpacing, border, fill);
- glColor4fv(Gui::info.var.hud_activeColor);
-
-
- x = 29;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "BLUE Team (%i players):", numBlues);
- x += 40;
- x += 350;
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blueScore);
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blueKills);
- x += 70;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blueDeaths);
-
- y -= ySpacing;
-
- // team members
- ySave = y;
- // rank
- x = 29;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x+25, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", i+1);
- y -= ySpacing;
- }
- // second column (name)
- x += 40;
- y = ySave;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "%s (id:%i)", blues[i]->ci.name, blues[i]->clientId);
- y -= ySpacing;
- }
- // third column (status)
- x += 350;
- y = ySave;
- for(i=0;i<numBlues;i++){
- if( blues[i]->vehicle != NULL ){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blues[i]->cs.armor);
- }else{
- drawScaledAndAlignedString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "DEAD");
- }
- y -= ySpacing;
- }
- // third column (score)
- x += 70;
- y = ySave;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blues[i]->ci.score);
- y -= ySpacing;
- }
- // fourth column (kills)
- x += 70;
- y = ySave;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blues[i]->ci.kills);
- y -= ySpacing;
- }
- // fifth column (deaths)
- x += 70;
- y = ySave;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blues[i]->ci.deaths);
- y -= ySpacing;
- }
- // sixth column (time)
- x += 65;
- y = ySave;
- for(i=0;i<numBlues;i++){
- int mins = blues[i]->ci.secondsOnServer / 60;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", mins);
- y -= ySpacing;
- }
- // seventh column (ping)
- x += 55;
- y = ySave;
- for(i=0;i<numBlues;i++){
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", blues[i]->ci.ping);
- y -= ySpacing;
- }
-
-
-
- // SPECTATORS
- int yLower = 105;
- if( numSpectators > 0 ){
- y = yLower + (numSpectators*ySpacing);
- x = 29;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "SPECTATORS:");
-
- // second column (name)
- x += 40;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x, y, scale, scale, font, TEXT_ALIGN_LEFT, "%s (id:%i)", spectators[i]->ci.name, spectators[i]->clientId);
- }
-
- // third column (status)
- x += 350;
-
- // third column (score)
- x += 70;
-
- // fourth column (kills)
- x += 70;
-
- // fifth column (deaths)
- x += 70;
-
- // sixth column (time)
- x += 65;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- int mins = spectators[i]->ci.secondsOnServer / 60;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", mins);
- }
-
- // seventh column (ping)
- x += 55;
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- drawScaledAndAlignedFormatString(x+20, y, scale, scale, font, TEXT_ALIGN_RIGHT, "%i", spectators[i]->ci.ping);
- }
- }
-
-
- // draw marker
- vec4_t transparent;
- vectorInit4d(0.0f, 0.0f, 0.0f, 0.0f, transparent);
- if( Network::client->ci.team == GAME_TEAM_RED ){
- y = yUpper - ySpacing;
- y -= ySpacing;
- y -= ySpacing;
- for(i=0;i<numReds;i++){
- if( reds[i] == Network::client ){
- Renderer::drawQuad(25, y, 775, y+ySpacing-2, Gui::info.var.hud_activeColor, transparent);
- }
- y -= ySpacing;
- }
- }else if( Network::client->ci.team == GAME_TEAM_BLUE ){
- y = yUpper - ySpacing;
- y -= ySpacing;
- y -= ySpacing;
- for(i=0;i<numReds;i++){
- y -= ySpacing;
- }
- y -= ySpacing;
- y -= ySpacing;
-
- for(i=0;i<numBlues;i++){
- if( blues[i] == Network::client ){
- Renderer::drawQuad(25, y, 775, y+ySpacing-2, Gui::info.var.hud_activeColor, transparent);
- }
- y -= ySpacing;
- }
-
- }else{
- y = yLower + (numSpectators*ySpacing);
- for(i=0;i<numSpectators;i++){
- y -= ySpacing;
- if( spectators[i] == Network::client ){
- Renderer::drawQuad(25, y, 775, y+ySpacing-2, Gui::info.var.hud_activeColor, transparent);
- }
- }
- }
-
- delete[] reds;
- delete[] blues;
- delete[] spectators;
- }
-
-
-
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // TAKE DAMAGE INDICATOR
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
- HudTakeDamageIndicator::HudTakeDamageIndicator(){
- texture = TextureHandler::getTexture("gui/hud/take_damage_indicator.tga");
-
- // visible=true;
- }
-
- HudTakeDamageIndicator::~HudTakeDamageIndicator(){
- if(texture)
- TextureHandler::releaseTexture(texture);
- }
-
- void HudTakeDamageIndicator::draw(){
- if( Game::cam.target == NULL || Game::cam.mode == CAMERA_MODE_FREE ){
- return;
- }
-
- Vehicle* v = Game::cam.target;
-
- unsigned long currentMillis = SDL_GetTicks();
- if( currentMillis < v->lastTakeDamageMillis + 1000 ){
-
- float alpha = 1.0f - (currentMillis - v->lastTakeDamageMillis)/1000.0f;
- glColor4f(1.0f, 1.0f, 1.0f, alpha);
- Renderer::drawTexturedQuad(0,0,800,600, texture);
- }
-
- }
-
-
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // DEBUG INFO
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- HudDebugInfo::HudDebugInfo(){
- font=FontHandler::getFont("gui/fonts/courier_tiny_bold.font");
-
- min[0]=530;
- max[0]=790;
- min[1]=10;
- max[1]=170;
-
- // visible=true;
- }
-
- HudDebugInfo::~HudDebugInfo(){
- if(font!=NULL)
- FontHandler::releaseFont(font);
- }
-
- void HudDebugInfo::draw(){
-
- drawBackground();
- glColor4fv(Gui::info.var.hud_activeColor);
-
- int y = (max[1]-10-font->height);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "RENDERER");
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "nodeCount: %i", Renderer::info.var.nodeCount);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "modelCount:%i", Renderer::info.var.modelCount);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "meshCount: %i", Renderer::info.var.meshCount);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "polyCount: %i", Renderer::info.var.polyCount);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "transCount:%i", Renderer::info.var.transPolyCount);
-
- y-=(font->height+3);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "CAMERA");
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "cam.pos:(%.1f, %.1f, %.1f)", Game::cam.pos[0], Game::cam.pos[1], Game::cam.pos[2]);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "cam.dir:(%.1f, %.1f, %.1f)", Game::cam.dir[0], Game::cam.dir[1], Game::cam.dir[2]);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "cam.up: (%.1f, %.1f, %.1f)", Game::cam.up[0], Game::cam.up[1], Game::cam.up[2]);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "cam.yaw: %.3f", Game::cam.yaw);
- y-=(font->height+1);
- drawAlignedFormatString(min[0]+10, y, font, TEXT_ALIGN_LEFT, "cam.pitch: %.3f", Game::cam.pitch);
- }
-
- void HudDebugInfo::drawBackground(){
- //glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
- glColor4fv(Gui::info.var.hud_backgroundColor);
- glBegin(GL_QUADS);
- glVertex2f(min[0], min[1]);
- glVertex2f(max[0], min[1]);
- glVertex2f(max[0], max[1]);
- glVertex2f(min[0], max[1]);
- glEnd();
-
- glColor4fv(Gui::info.var.hud_activeColor);
- glBegin(GL_LINE_LOOP);
- glVertex2f(min[0], min[1]);
- glVertex2f(max[0], min[1]);
- glVertex2f(max[0], max[1]);
- glVertex2f(min[0], max[1]);
- glEnd();
-
- }
-