Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. void MCategory::Draw()
  2. {
  3. if (gControls.OnClick(this->posX, this->posY, this->sizeW, this->sizeH))
  4. {
  5. if (gCurrentMCategory)
  6. gCurrentMCategory->active = false;
  7.  
  8. this->active = true;
  9. gCurrentMCategory = this;
  10. }
  11.  
  12. if (this->active)
  13. {
  14. //gPaint.DrawFilledRectWithBorder(this->posX, this->posY, this->sizeW, this->sizeH, this->borderSize, this->color, this->borderColorU, this->borderColorR, this->borderColorB, this->borderColorL);
  15.  
  16. gPaint.DrawFilledRect(this->posX, this->posY, this->sizeW, this->sizeH, this->color);
  17.  
  18. gPaint.DrawFilledRect(this->posX + this->borderSize, this->posY - this->borderSize, this->sizeW, this->borderSize, this->borderColorU);
  19. gPaint.DrawFilledRect(this->posX + this->sizeW, this->posY, this->borderSize, this->sizeH, this->borderColorR);
  20. gPaint.DrawFilledRect(this->posX + this->borderSize, this->posY + this->sizeH, this->sizeW, this->borderSize, this->borderColorB);
  21. gPaint.DrawFilledRect(this->posX, this->posY, this->borderSize, this->sizeH, this->borderColorL);
  22.  
  23. gPaint.DrawString(this->posX + this->sizeW / 2, this->posY + this->sizeH / 2, 'c', this->name, this->font, this->textColor);
  24.  
  25. for (const auto &child : this->children)
  26. child->Draw();
  27. }
  28. else
  29. gPaint.DrawString(this->posX + this->sizeW / 2, this->posY + this->sizeH / 2, 'c', this->name, this->font, this->nonActiveTextColor);
  30. }
  31.  
  32. void MCheckBox::Draw()
  33. {
  34. if (!this->variable)
  35. return;
  36.  
  37. if (gControls.OnClick(this->posX, this->posY, this->sizeW, this->sizeH))
  38. *this->variable = !*this->variable;
  39.  
  40. if (*this->variable)
  41. gPaint.DrawFilledRect(this->posX, this->posY, this->sizeW, this->sizeH, this->color);
  42. else
  43. gPaint.DrawFilledRect(this->posX, this->posY, this->sizeW, this->sizeH, this->nonActiveColor);
  44.  
  45. gPaint.DrawString(this->posX - this->sizeW, this->posY + this->sizeH / 2, 'r', this->name, this->font, this->textColor);
  46. }
  47.  
  48. inline virtual void Draw() override
  49. {
  50. if (!this->variable)
  51. return;
  52.  
  53. gPaint.DrawFilledRect(this->posX, this->posY, this->sizeW, this->sizeH, this->nonActiveColor);
  54. gPaint.DrawFilledRect(this->posX, this->posY, (int)(this->sizeW * (*this->variable - this->minValue) / (this->maxValue - this->minValue)), this->sizeH, this->color);
  55.  
  56. if (gControls.DraggingSlider(this->posX, this->posY, this->sizeW, this->sizeH))
  57. {
  58. int cursorPosX;
  59. int cursorPosY;
  60. INTERFACES::Surface->SurfaceGetCursorPos(cursorPosX, cursorPosY);
  61.  
  62. float difference = (float)(cursorPosX - this->posX);
  63. float percent = difference / this->sizeW;
  64. float range = (this->maxValue - this->minValue) * percent;
  65. *this->variable = UTILS::ClampValue<T>(this->minValue + (T)range, this->minValue, this->maxValue);
  66. }
  67.  
  68. gPaint.DrawString(this->posX - this->sizeH, this->posY + this->sizeH / 2, 'r', this->name, this->font, this->textColor);
  69. gPaint.DrawString(this->posX + this->sizeW + this->sizeH, this->posY + this->sizeH / 2, 'l', UTILS::ToStringWithPrecision(*variable, this->precision), this->font, this->textColor);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement