UISpriteData.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. [Serializable]
  3. public class UISpriteData
  4. {
  5. public bool hasBorder
  6. {
  7. get
  8. {
  9. return (this.borderLeft | this.borderRight | this.borderTop | this.borderBottom) != 0;
  10. }
  11. }
  12. public bool hasPadding
  13. {
  14. get
  15. {
  16. return (this.paddingLeft | this.paddingRight | this.paddingTop | this.paddingBottom) != 0;
  17. }
  18. }
  19. public void SetRect(int x, int y, int width, int height)
  20. {
  21. this.x = x;
  22. this.y = y;
  23. this.width = width;
  24. this.height = height;
  25. }
  26. public void SetPadding(int left, int bottom, int right, int top)
  27. {
  28. this.paddingLeft = left;
  29. this.paddingBottom = bottom;
  30. this.paddingRight = right;
  31. this.paddingTop = top;
  32. }
  33. public void SetBorder(int left, int bottom, int right, int top)
  34. {
  35. this.borderLeft = left;
  36. this.borderBottom = bottom;
  37. this.borderRight = right;
  38. this.borderTop = top;
  39. }
  40. public void CopyFrom(UISpriteData sd)
  41. {
  42. this.name = sd.name;
  43. this.x = sd.x;
  44. this.y = sd.y;
  45. this.width = sd.width;
  46. this.height = sd.height;
  47. this.borderLeft = sd.borderLeft;
  48. this.borderRight = sd.borderRight;
  49. this.borderTop = sd.borderTop;
  50. this.borderBottom = sd.borderBottom;
  51. this.paddingLeft = sd.paddingLeft;
  52. this.paddingRight = sd.paddingRight;
  53. this.paddingTop = sd.paddingTop;
  54. this.paddingBottom = sd.paddingBottom;
  55. }
  56. public void CopyBorderFrom(UISpriteData sd)
  57. {
  58. this.borderLeft = sd.borderLeft;
  59. this.borderRight = sd.borderRight;
  60. this.borderTop = sd.borderTop;
  61. this.borderBottom = sd.borderBottom;
  62. }
  63. public string name = "Sprite";
  64. public int x;
  65. public int y;
  66. public int width;
  67. public int height;
  68. public int borderLeft;
  69. public int borderRight;
  70. public int borderTop;
  71. public int borderBottom;
  72. public int paddingLeft;
  73. public int paddingRight;
  74. public int paddingTop;
  75. public int paddingBottom;
  76. }