Guest User

Untitled

a guest
Nov 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.67 KB | None | 0 0
  1. void graphics::printExperienceBar(int nSurface, int index)
  2. {
  3.  
  4.  
  5.     int pos = tibiaClient::HUDItemInformation[index].position;
  6.  
  7.     int height, width, top, left; //the - 5 * 2 is because of spacing, so is - height * 2
  8.     if (pos == Consts::HUD_POSITION_MAIN_TOPLEFT || pos == Consts::HUD_POSITION_MAIN_TOPRIGHT)
  9.     {
  10.         top = tibiaClient::HUDItemInformation[index].yOffset;
  11.         width = 5;
  12.         if (pos == Consts::HUD_POSITION_MAIN_TOPRIGHT)
  13.             left = graphics::gameWindowInfo.left + graphics::gameWindowInfo.right - width - tibiaClient::HUDItemInformation[index].xOffset;
  14.         else
  15.             left = tibiaClient::HUDItemInformation[index].xOffset;
  16.  
  17.         height = (graphics::gameWindowInfo.bottom + graphics::gameWindowInfo.top) - tibiaClient::HUDItemInformation[index].yOffset * 2;
  18.     }
  19.     else if (pos == Consts::HUD_POSITION_GAME_TOPLEFT || pos == Consts::HUD_POSITION_GAME_TOPRIGHT)
  20.     {
  21.         top = graphics::gameWindowInfo.top + tibiaClient::HUDItemInformation[index].yOffset;
  22.         width = 5;
  23.         if (pos == Consts::HUD_POSITION_GAME_TOPRIGHT)
  24.             left = graphics::gameWindowInfo.right - width - tibiaClient::HUDItemInformation[index].xOffset;
  25.         else
  26.             left = graphics::gameWindowInfo.left + tibiaClient::HUDItemInformation[index].xOffset;
  27.  
  28.         height = graphics::gameWindowInfo.height - tibiaClient::HUDItemInformation[index].yOffset * 2;
  29.     }
  30.     else
  31.     {
  32.         height = 5;
  33.         if (pos == Consts::HUD_POSITION_GAME_BOTTOMMIDDLE)
  34.             top = graphics::gameWindowInfo.bottom - height - tibiaClient::HUDItemInformation[index].yOffset;
  35.         else
  36.             top = graphics::gameWindowInfo.top + tibiaClient::HUDItemInformation[index].yOffset;
  37.  
  38.         left = graphics::gameWindowInfo.left + tibiaClient::HUDItemInformation[index].xOffset;
  39.         width = graphics::gameWindowInfo.width - tibiaClient::HUDItemInformation[index].xOffset * 2;
  40.     }
  41.  
  42.     int barSize = (int)(((float)maxval(height, width) / 100.0f) * tibiaClient::Self->LevelPercent);
  43.     int markIncrement = (maxval(height, width) / 4);
  44.     tibiaClient::PrintSkin(1, left, top, width, height, Consts::Gui_Background_Regular); //back
  45.    
  46.     if (width > height) //bar
  47.         tibiaClient::PrintRect(1, left, top, barSize, height,
  48.                                 tibiaClient::HUDItemInformation[index].textColor.R,
  49.                                 tibiaClient::HUDItemInformation[index].textColor.G,
  50.                                 tibiaClient::HUDItemInformation[index].textColor.B);
  51.     else
  52.         tibiaClient::PrintRect(1, left, top + (height - barSize), width, barSize,
  53.                                 tibiaClient::HUDItemInformation[index].textColor.R,
  54.                                 tibiaClient::HUDItemInformation[index].textColor.G,
  55.                                 tibiaClient::HUDItemInformation[index].textColor.B); //bar
  56.  
  57.     tibiaClient::PrintSkin(1, left, top, width, 1, Consts::Gui_Border_Top_And_Left); //top
  58.     tibiaClient::PrintSkin(1, left, top+height, width, 1, Consts::Gui_Border_Bottom); //bottom
  59.     tibiaClient::PrintSkin(1, left, top, 1, height, Consts::Gui_Border_Top_And_Left); //left
  60.     tibiaClient::PrintSkin(1, left+width-1, top, 1, height, Consts::Gui_Border_Right); //right
  61.  
  62.     if (width > height) //bar
  63.     {
  64.         //mark 75%
  65.         tibiaClient::PrintSkin(1, left + markIncrement - 1, top, 1, height, Consts::Gui_Border_Right);
  66.         tibiaClient::PrintSkin(1, left + markIncrement, top, 1, height, Consts::Gui_Border_Top_And_Left);
  67.         //mark 50%
  68.         tibiaClient::PrintSkin(1, left + markIncrement*2 - 1, top, 1, height, Consts::Gui_Border_Right);
  69.         tibiaClient::PrintSkin(1, left + markIncrement*2, top, 1, height, Consts::Gui_Border_Top_And_Left);
  70.         //mark 25%
  71.         tibiaClient::PrintSkin(1, left + markIncrement*3 - 1, top, 1, height, Consts::Gui_Border_Right);
  72.         tibiaClient::PrintSkin(1, left + markIncrement*3, top, 1, height, Consts::Gui_Border_Top_And_Left);
  73.        
  74.         //std::stringstream str;
  75.         //str << tibiaClient::Self->LevelPercent << "%";
  76.         //tibiaClient::PrintText(nSurface,
  77.         //                      left + barSize - 3,
  78.         //                      top - 3,
  79.         //                      Consts::FONT_NORMALBORDER,
  80.         //                      tibiaClient::HUDItemInformation[index].textColor.R,
  81.         //                      tibiaClient::HUDItemInformation[index].textColor.G,
  82.         //                      tibiaClient::HUDItemInformation[index].textColor.B,
  83.         //                      stringToChar(str.str()),
  84.         //                      Consts::FONT_ALIGNMENT_RIGHT);
  85.     }
  86.     else
  87.     {
  88.         //mark 75%
  89.         tibiaClient::PrintSkin(1, left, top + markIncrement - 1, width, 1, Consts::Gui_Border_Bottom);
  90.         tibiaClient::PrintSkin(1, left, top + markIncrement, width, 1, Consts::Gui_Border_Top_And_Left);
  91.         //mark 50%
  92.         tibiaClient::PrintSkin(1, left, top + markIncrement*2 - 1, width, 1, Consts::Gui_Border_Bottom);
  93.         tibiaClient::PrintSkin(1, left, top + markIncrement*2, width, 1, Consts::Gui_Border_Top_And_Left);
  94.         //mark 25%
  95.         tibiaClient::PrintSkin(1, left, top + markIncrement*3 - 1, width, 1, Consts::Gui_Border_Bottom);
  96.         tibiaClient::PrintSkin(1, left, top + markIncrement*3, width, 1, Consts::Gui_Border_Top_And_Left);
  97.     }
  98. }
Add Comment
Please, Sign In to add comment