Advertisement
Guest User

Untitled

a guest
Apr 27th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s32 count, v2s32 offset) {
  2. const video::SColor color(255, 255, 255, 255);
  3. const video::SColor colors[] = {color, color, color, color};
  4.  
  5. video::ITexture *stat_texture = tsrc->getTexture(texture);
  6. if (!stat_texture)
  7. return;
  8.  
  9. core::dimension2di srcd(stat_texture->getOriginalSize());
  10. v2s32 p = pos;
  11. if (corner & HUD_CORNER_LOWER)
  12. p -= 16;
  13.  
  14. p += offset;
  15.  
  16. v2s32 steppos;
  17. switch (drawdir) {
  18. case HUD_DIR_RIGHT_LEFT:
  19. steppos = v2s32(-1, 0);
  20. break;
  21. case HUD_DIR_TOP_BOTTOM:
  22. steppos = v2s32(0, 1);
  23. break;
  24. case HUD_DIR_BOTTOM_TOP:
  25. steppos = v2s32(0, -1);
  26. break;
  27. default:
  28. steppos = v2s32(1, 0);
  29. }
  30. steppos.X *= 16;
  31. steppos.Y *= 16;
  32.  
  33. for (s32 i = 0; i < count / 2; i++)
  34. {
  35. core::rect<s32> srcrect(0, 0, srcd.Width, srcd.Height);
  36. core::rect<s32> dstrect(0,0,16,16);
  37.  
  38. dstrect += p;
  39. driver->draw2DImage(stat_texture, dstrect, srcrect, NULL, colors, true);
  40. p += steppos;
  41. }
  42.  
  43. if (count % 2 == 1)
  44. {
  45. core::rect<s32> srcrect(0, 0, srcd.Width / 2, srcd.Height);
  46. core::rect<s32> dstrect(0,0,8,16);
  47.  
  48. dstrect += p;
  49. driver->draw2DImage(stat_texture, dstrect, srcrect, NULL, colors, true);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement