void AMyHUD::DrawConfirmButtons() { //Start Point float xStart = Canvas->SizeX / 2 - 100; float yStart = Canvas->SizeY / 2 - 40; //Highlighted? if (ActiveButton_Type == BUTTONTYPE_CONFIRM_YES) ColorPtr = &LC_Red; else ColorPtr = &LC_White; //Yes Text DrawHUDText( SketchFont, "Yes", xStart + 30, yStart + 20, *ColorPtr, DefaultFontScale, true, LC_White ); //Sets up the info for the button with the struct if (ButtonsConfirm.Num() < 1) { FHUDButtonStruct newButton = FHUDButtonStruct(); newButton.type = BUTTONTYPE_CONFIRM_YES; newButton.minX = xStart; newButton.maxX = xStart + 75; newButton.minY = yStart + 20; newButton.maxY = yStart + 60; //Add to correct array ButtonsConfirm.Add(newButton); } //Start Point xStart = Canvas->SizeX / 2 + 20; yStart = Canvas->SizeY / 2 - 40; //Highlighted? if (ActiveButton_Type == BUTTONTYPE_CONFIRM_NO) ColorPtr = &LC_Red; else ColorPtr = &LC_White; //No Text DrawHUDText( SketchFont, "No", xStart + 30, yStart + 20, *ColorPtr, DefaultFontScale, true, LC_White ); //Sets up the info for the button with the struct if (ButtonsConfirm.Num() < 2) { FHUDButtonStruct newButton = FHUDButtonStruct(); newButton.type = BUTTONTYPE_CONFIRM_NO; newButton.minX = xStart; newButton.maxX = xStart + 75; newButton.minY = yStart + 20; newButton.maxY = yStart + 60; //Add to correct array ButtonsConfirm.Add(newButton); } }
void CHud::DrawMyPlayerInfo(LPDIRECT3DDEVICE9 pd3dDevice){ int segmentWidth = m_nWidth / 2; int segmentHeight = m_nHeight / 5; // Draw Damage Bar DrawDamageBar(pd3dDevice, pMyPlayer, m_nX + segmentWidth / 8, // x segmentHeight / 4, // y segmentWidth); // width // Draw Charge Bar std::stringstream ss; ss << "Charge"; DrawProgressBar(pd3dDevice, m_nX + segmentWidth / 8, segmentHeight / 2, 16, segmentWidth * 3 / 4, pMyPlayer->fCurrCharge / pMyPlayer->fMaxCharge, SColor(0,0,255) , true); DrawHUDText(m_BigFont, ss.str().c_str(), m_nX + segmentWidth / 8, (segmentHeight / 2) - 12, 42, segmentWidth * 3 / 4, DT_CENTER | DT_VCENTER, SColor(255,255,255)); // Draw Lives DrawLiveIcons(pMyPlayer->nLives, m_nX + (segmentWidth / 8), // x m_nY + segmentHeight * 3 / 4, // y segmentWidth); }
void CHud::DrawDamageBar(LPDIRECT3DDEVICE9 pd3dDevice, const SPlayer* player, int x, int y, int segmentWidth){ float dmg = player->fCurrDamage; int width = segmentWidth * 3 / 4; std::stringstream ss; if (player->nLives > 0){ int div = (int) dmg / 100; for (int k = max(0,div-1); k <= div; k++){ dmg = player->fCurrDamage - 100.f * k; bool bDrawBack = (div == 0); DrawProgressBar(pd3dDevice, x, y, 16, width, min(dmg, 100.f) / 100.f, // percent SColor(153,max(0,255 - (51 * k)),0), //color bDrawBack); } ss << (int) player->fCurrDamage << "%"; } else { // Dead DrawProgressBar(pd3dDevice, x, y, 16, width, 1.f, // percent SColor(103, 103, 103), //color (gray) true); ss << "DEAD"; } // Write health amount over bar DrawHUDText(m_BigFont, ss.str().c_str(), x, y - 12, 42, width, DT_CENTER | DT_VCENTER, SColor(255,255,255)); }
// Called every frame that the "HUD" is drawn -- e.g. net status / packet loss bar PLUGIN_API VOID OnDrawHUD(VOID) { static int N=0; CHAR szBuffer[MAX_STRING]={0}; if (++N>CheckINI) { N=0; struct _stat now; if (Stat(INIFileName,now) && now.st_mtime!=LastRead.st_mtime) HandleINI(); // check for EQ in foreground HWND EQhWnd = *(HWND*)EQADDR_HWND; if (EQW_GetDisplayWindow) EQhWnd=EQW_GetDisplayWindow(); if (!bBGUpdate && GetForegroundWindow()!=EQhWnd) bEQHasFocus = false; else bEQHasFocus = true; } if (!bEQHasFocus) return; DWORD SX=0; DWORD SY=0; if (pScreenX && pScreenY) { SX=ScreenX; SY=ScreenY; } PHUDELEMENT pElement=pHud; DWORD X,Y; while(pElement) { if ((gGameState==GAMESTATE_CHARSELECT && pElement->Type&HUDTYPE_CHARSELECT) || (gGameState==GAMESTATE_INGAME && ( (pElement->Type&HUDTYPE_NORMAL && ScreenMode!=3) || (pElement->Type&HUDTYPE_FULLSCREEN && ScreenMode==3)))) { if (pElement->Type&HUDTYPE_CURSOR) { PMOUSEINFO pMouse = (PMOUSEINFO)EQADDR_MOUSE; X=pMouse->X+pElement->X; Y=pMouse->Y+pElement->Y; } else { X=SX+pElement->X; Y=SX+pElement->Y; } if (!(N%SkipParse)) { strcpy_s(pElement->PreParsed,pElement->Text); ParseMacroParameter(GetCharInfo()->pSpawn,pElement->PreParsed); } strcpy_s(szBuffer,pElement->PreParsed); if (szBuffer[0] && strcmp(szBuffer,"NULL")) { DrawHUDText(szBuffer,X,Y,pElement->Color,pElement->Size); } } pElement=pElement->pNext; } }
//Buttons void AMyHUD::DrawMainMenuButtons() { float xStart, yStart; //Only displays the resume button when it is not gameover or you won if (!gameover && !botsKilled){ //Start Point xStart = 100; yStart = 190; //Background //Tile imported into content browser with black border DrawHUDRect(xStart - 10, yStart - 10, 170, 80, FLinearColor(0, 0, 0, 1)); VDrawTile(ButtonBackground, xStart, yStart, 150, 60, FColor(255, 255, 255, 255)); //alpha 120/255 //Resume Text for Menu DrawHUDText( SketchFont, "Resume", xStart + 25, yStart + 10, FColorBlack, DefaultFontScale, false ); //Clear buttons with ButtonsMain.Empty() //Sets up the info for the button with the struct if (ButtonsMain.Num() < 1) { FHUDButtonStruct newButton = FHUDButtonStruct(); newButton.type = BUTTONTYPE_MAIN_RESUME; newButton.minX = xStart; newButton.maxX = xStart + 150; newButton.minY = yStart; newButton.maxY = yStart + 80; //Add to correct array ButtonsMain.Add(newButton); } } //Start Point xStart = 100; yStart = 280; //Background //Tile imported into content browser with black border DrawHUDRect(xStart - 10, yStart - 10, 170, 80, FLinearColor(0, 0, 0, 1)); VDrawTile(ButtonBackground, xStart, yStart, 150, 60, FColor(255, 255, 255, 255)); //Exit Text DrawHUDText( SketchFont, "Exit", xStart + 45, yStart + 10, FColorBlack, DefaultFontScale, false ); //Sets up the info for the button with the struct if (ButtonsMain.Num() < 2) { FHUDButtonStruct newButton = FHUDButtonStruct(); newButton.type = BUTTONTYPE_MAIN_EXIT; newButton.minX = xStart; newButton.maxX = xStart + 150; newButton.minY = yStart; newButton.maxY = yStart + 80; //Add to correct array ButtonsMain.Add(newButton); } //Start Point xStart = 100; yStart = 370; //Background //Tile imported into content browser with black border DrawHUDRect(xStart - 10, yStart - 10, 170, 80, FLinearColor(0, 0, 0, 1)); VDrawTile(ButtonBackground, xStart, yStart, 150, 60, FColor(255, 255, 255, 255)); //alpha 120/255 //Restart Text DrawHUDText( SketchFont, "Restart", xStart + 23, yStart + 10, FColorBlack, DefaultFontScale, false ); //Sets up the info for the button with the struct if (ButtonsMain.Num() < 3) { FHUDButtonStruct newButton = FHUDButtonStruct(); newButton.type = BUTTONTYPE_MAIN_RESTART; newButton.minX = xStart; newButton.maxX = xStart + 150; newButton.minY = yStart; newButton.maxY = yStart + 80; //Add to correct array ButtonsMain.Add(newButton); } }
//DrawHUD gets called every tick void AMyHUD::DrawHUD(){ //Have PC for Mouse Cursor? if (!ThePC) { //Attempt to Reacquire PC ThePC = GetOwningPlayerController(); //Could Not Obtain PC if (!ThePC) return; } //Display the Cursor ThePC->bShowMouseCursor = true; //Health Bar is always drawn on screen DrawHealthBar(); FVector2D ScreenSize = FVector2D(Canvas->SizeX, Canvas->SizeY); Super::DrawHUD(); //Display the instructions for until the timer hits zero if (d5){ if (GetWorldTimerManager().GetTimerRemaining(Handle5) > 0){ DrawHUDText(ToyFont, "Controls:", x, y, FColorRed, 1.0F,true); DrawHUDText(SketchFont, "WASD to Move", x, y+43, FColorRed, .5F, true, LC_Red); DrawHUDText(SketchFont, "Mouse to aim", x, y+63, FColorRed, .5F, true, LC_Red); DrawHUDText(SketchFont, "Click to shoot", x, y+83, FColorRed, .5F, true, LC_Red); DrawHUDText(SketchFont, "Some walls are breakable", x, y+103, FColorRed, .5F, true, LC_Red); DrawHUDText(SketchFont, "Shoot health packs to gain health", x, y+123, FColorRed, .5F, true, LC_Red); DrawHUDText(SketchFont, "Press M for Menu", x, y + 143, FColorRed, .5F, true, LC_Red); DrawHUDText(ToyFont, "-----------------", x, y+180, FColorRed, .5F, true, LC_Red); DrawHUDText(ToyFont, "Goal:", x, y+220, FColorRed, 1.0F, true); DrawHUDText(SketchFont, "Destroy every enemy", x, y+263, FColorRed, .5F, true,LC_Red); DrawHUDText(SketchFont, "Be the sole survivor", x, y+283, FColorRed, .5F, true,LC_Red); } else { GetWorldTimerManager().ClearTimer(Handle5); d5 = false; d1 = true; GetWorldTimerManager().SetTimer(Handle1, 1.0f, false); } } //When the instructions are finished display 3,2,1, Go! on the screen based on timers if (d1){ if (GetWorldTimerManager().GetTimerRemaining(Handle1) > 0) DrawText(TEXT("3"), FColor::Blue, Canvas->SizeX / 2 -70, Canvas->SizeY / 2 -50, SketchFont, 2.0F, false); else { GetWorldTimerManager().ClearTimer(Handle1); d1 = false; d2 = true; GetWorldTimerManager().SetTimer(Handle2, 1.0f, false); } } if (d2){ if (GetWorldTimerManager().GetTimerRemaining(Handle2) > 0) DrawText(TEXT("2"), FColor::Blue, Canvas->SizeX / 2-70, Canvas->SizeY / 2-50, SketchFont, 2.0F, false); else{ GetWorldTimerManager().ClearTimer(Handle2); d2 = false; d3 = true; GetWorldTimerManager().SetTimer(Handle3, 1.0f, false); } } if (d3){ if (GetWorldTimerManager().GetTimerRemaining(Handle3) > 0) DrawText(TEXT("1"), FColor::Blue, Canvas->SizeX / 2-70, Canvas->SizeY / 2-50, SketchFont, 2.0F, false); else{ GetWorldTimerManager().ClearTimer(Handle3); d3 = false; d4 = true; GetWorldTimerManager().SetTimer(Handle4, 1.0f, false); } } if (d4){ if (GetWorldTimerManager().GetTimerRemaining(Handle4) > 0) DrawText(TEXT("GO!"), FColor::Blue, (Canvas->SizeX / 2)-95, (Canvas->SizeY / 2)-50, SketchFont, 2.0F, false); else{ d4 = false; GetWorldTimerManager().ClearTimer(Handle4); canMove = true; } } //gameover text when gameover is reached if (gameover){ DrawText(TEXT("GAME OVER"), FColor::Red, (Canvas->SizeX / 2) - 250, (Canvas->SizeY / 2) - 30, ToyFont, 2.0F, false); DontDrawHUD = false; ThePC->ConsoleCommand("Pause"); } //win text when all the bots are killed if (botsKilled){ DrawText(TEXT("YOU WON!"), FColor::Red, (Canvas->SizeX / 2) - 250, (Canvas->SizeY / 2) - 30, ToyFont, 2.0F, false); DontDrawHUD = false; ThePC->ConsoleCommand("Pause"); } //Draw HUD? //DrawHUD is only turned on when the menu button is pressed if (DontDrawHUD) return; //Super Super::DrawHUD(); //No Canvas? if (!Canvas) return; //Reset States DrawHUD_Reset(); //Get New Mouse Position ThePC->GetMousePosition(MouseLocation.X, MouseLocation.Y); //Cursor In Buttons DrawHUD_CheckCursorInButtons(); //Draw Dialogs DrawHUD_DrawDialogs(); //} }
void AMyHUD::DrawHealthBar() { //Health Text DrawHUDText( ToyFont, "Health", 100, 50, FColor_White, DefaultFontScale, true ); //Tank Attack Text at the top of the screen DrawHUDText( ToyFont, "Tank Attack", 290, 20, FColor_White, 1.0F, true ); //Goes from left to right incrementing the health //when add is true and it is not gameover if (add && !gameover){ if (LC_Blue2.A == 0){ LC_Blue2.A = 1; add = false; } else if (LC_Blue3.A == 0){ LC_Blue3.A = 1; add = false; } else if (LC_Blue4.A == 0){ LC_Blue4.A = 1; add = false; } else if (LC_Blue5.A == 0){ LC_Blue5.A = 1; add = false; } } //when lose is true it decrements health if (lose){ if (LC_Blue5.A == 1){ LC_Blue5.A = 0; lose = false; } else if (LC_Blue4.A == 1){ LC_Blue4.A = 0; lose = false; } else if (LC_Blue3.A == 1){ LC_Blue3.A = 0; lose = false; } else if (LC_Blue2.A == 1){ LC_Blue2.A = 0; lose = false; } else if (LC_Blue1.A == 1){ LC_Blue1.A = 0; lose = false; gameover = true; } } //Draws the squares for the health bar DrawHUDRect(100, 100, 20, 20, LC_Blue1); DrawHUDRect(120, 100, 20, 20, LC_Blue2); DrawHUDRect(140, 100, 20, 20, LC_Blue3); DrawHUDRect(160, 100, 20, 20, LC_Blue4); DrawHUDRect(180, 100, 20, 20, LC_Blue5); }
void CHud::OnFrameRender(LPDIRECT3DDEVICE9 pd3dDevice, const PlayerHashMap &hmPlayers, const CGameEngine::SRoundInfo &roundInfo){ if (pMyPlayer == NULL) return; if (alpha < 10) // don't waste my time with a low alpha return; // Draw player stuff // Divide up the width between each of the players int segmentWidth = m_nWidth / max(4, (int)hmPlayers.size()); int segmentHeight = m_nHeight / 5; m_Sprite->Begin(D3DXSPRITE_ALPHABLEND); PlayerHashMap::const_iterator playerit = hmPlayers.begin(); int index = 0; for( ; playerit != hmPlayers.end(); playerit++) { const SPlayer* player = &playerit->second; if (player->charID == pMyPlayer->charID) DrawMyPlayerInfo(pd3dDevice); else DrawOtherPlayerInfo(pd3dDevice, player, segmentWidth, segmentHeight, index); index++; } // Draw Hud messages list<SHudMessage>::iterator hmIt = m_lMessages.begin(); int x, y, width, height; x = m_nX; width = m_nWidth; y = m_nY + (m_nHeight / 4); height = 22; while(hmIt != m_lMessages.end()){ LPD3DXFONT font; if (hmIt->bBigFont) { font = m_BigFont; height = 42; } else { font = m_SmallFont; height = 22; } DrawHUDText(font, hmIt->strText.c_str(), x, y, height, width, DT_CENTER | DT_VCENTER, SColor(255,0,0), hmIt->fTimeLeft / hmIt->fTimeToLive); y += height; hmIt++; } // Draw timer float fTimer = roundInfo.fRoundTimeLeft; int minutes = (int)fTimer / 60, seconds = (int)fTimer % 60; std::stringstream ss; if (!roundInfo.bRoundStarted) ss << "Time Until Next Round: "; else ss << "Round " << roundInfo.nRound << ": "; ss << minutes << ":"; if (seconds < 10) ss << "0"; ss << seconds; DrawHUDText(m_SmallFont, ss.str().c_str(), m_nWidth / 2, 0, segmentHeight, m_nWidth / 2, DT_CENTER | DT_VCENTER, SColor(0, 0, 255)); m_Sprite->End(); }