Advertisement
ColinStroble

Untitled

Feb 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. void MultiBox::Render()
  2. {
  3. std::string format;
  4.  
  5. for (int i = 0; i < vecSelectables.size(); i++)
  6. {
  7. auto formatLen = format.length() < 20;
  8.  
  9. auto first = format.length() <= 0;
  10. if ((bEnabled[i]) && formatLen)
  11. {
  12. if (!first) {
  13. format.append(", ");
  14. }
  15.  
  16. format.append(vecSelectables.at(i));
  17. }
  18. else if (!formatLen) {
  19. format.append("...");
  20. break;
  21. }
  22. }
  23.  
  24. if (format.length() <= 0) {
  25. format += "";
  26. }
  27.  
  28. /* Render the selectable with the value in the middle */
  29. g_Render.RectFilled(this->rcBoundingBox, Color(39, 39, 39, settings.iAlpha));
  30. g_Render.String(this->rcBoundingBox.Button(), CD3DFONT_CENTERED_Y | CD3DFONT_DROPSHADOW, Color(160, 160, 160, settings.iAlpha), pFont.get(), format.c_str());
  31.  
  32. /* Render the selectable with the value in the middle and highlight if hovered */
  33. if (this->bIsHovered) {
  34. g_Render.RectFilled(this->rcBoundingBox, style.colHover);
  35. }
  36.  
  37. /* Render the small triangle */
  38. {
  39. SPoint ptPosMid, ptPosLeft, ptPosRight;
  40.  
  41. /* Draw two different versions (top-down, down-top) depending on activation */
  42. if (!this->bIsActive)
  43. {
  44. ptPosMid.x = this->rcBoundingBox.right - 8;
  45. ptPosRight.x = this->rcBoundingBox.right - 5;
  46. ptPosLeft.x = this->rcBoundingBox.right - 10;
  47.  
  48. ptPosRight.y = ptPosLeft.y = this->rcBoundingBox.top + 8;
  49. ptPosMid.y = this->rcBoundingBox.bottom - 7;
  50. }
  51. else
  52. {
  53. ptPosMid.x = this->rcBoundingBox.right - 8;
  54. ptPosRight.x = this->rcBoundingBox.right - 5;
  55. ptPosLeft.x = this->rcBoundingBox.right - 11;
  56.  
  57. ptPosRight.y = ptPosLeft.y = this->rcBoundingBox.bottom - 7;
  58. ptPosMid.y = this->rcBoundingBox.top + 7;
  59. }
  60.  
  61. g_Render.TriangleFilled(ptPosLeft, ptPosRight, ptPosMid, Color(162, 162, 162, settings.iAlpha));
  62. }/*-------------------------*/
  63.  
  64. /* Rectangle of the combo selectables, for scissorrect */
  65. const SRect vpCombo =
  66. {
  67. rcBoundingBox.left,
  68. rcBoundingBox.bottom,
  69. rcBoundingBox.right,
  70. rcBoundingBox.bottom + rcBoundingBox.Height() * int(vecSelectables.size())
  71. };
  72.  
  73. /* Render selectables only within the rect, useful for scroll usage (if implemented later on) */
  74. g_Render.SetCustomScissorRect(vpCombo);
  75. if (this->bIsActive)
  76. RenderSelectables();
  77. g_Render.RestoreOriginalScissorRect();
  78.  
  79. g_Render.Rect(this->rcBoundingBox, style.colSectionOutl(settings.iAlpha));
  80.  
  81. if (bIsActive) {
  82. g_Render.Rect({ this->rcBoundingBox.left, this->rcBoundingBox.bottom + 3 },
  83. { this->rcBoundingBox.right, this->rcBoundingBox.bottom + this->rcBoundingBox.Height() * int(this->vecSelectables.size()) },
  84. style.colSectionOutl(settings.iAlpha));
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement