1
0

glow.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: glow.m
  4. Version: 1.0
  5. Type: maki/glow class
  6. Date: 16. Jun. 2007 - 23:13
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. Usage: 1: #include glow.m
  12. 2: #define GLOW_OBJECT MyGlow
  13. 3: call _MyGlow_GlowInit (someObj, otherObj)
  14. to init the objects.
  15. You can also call _MyGlow_GlowInit (NULL, otherObj)
  16. and load a bunch of GuiObjects in _MyGlow_GlowTrigger
  17. or load up to 5 objects via _MyGlow_addTarget(obj);
  18. -----------------------------------------------------
  19. ---------------------------------------------------*/
  20. #ifndef included
  21. #error This script can only be compiled as a #include
  22. #endif
  23. #ifndef GLOW_OBJECT
  24. #error GLOW_OBJECT not defined!
  25. #endif
  26. Class GuiObject _##GLOW_OBJECT##_GlowTrigger;
  27. Global _##GLOW_OBJECT##_GlowTrigger _##GLOW_OBJECT##_trigger0, _##GLOW_OBJECT##_trigger1, _##GLOW_OBJECT##_trigger2, _##GLOW_OBJECT##_trigger3, _##GLOW_OBJECT##_trigger4, _##GLOW_OBJECT##_trigger5;
  28. Global GuiObject _##GLOW_OBJECT##_glow;
  29. Global float _##GLOW_OBJECT##_fdoutspeed;
  30. Global boolean _##GLOW_OBJECT##_mouseDown;
  31. Function _##GLOW_OBJECT##_GlowInit (GuiObject triggerObject, GuiObject glowObject, float fdoutspeed);
  32. Function _##GLOW_OBJECT##_addTrigger (GuiObject triggerObject);
  33. _##GLOW_OBJECT##_GlowInit (GuiObject triggerObject, GuiObject glowObject, float fdoutspeed)
  34. {
  35. if (triggerObject) _##GLOW_OBJECT##_trigger0 = triggerObject;
  36. if (glowObject) _##GLOW_OBJECT##_glow = glowObject;
  37. _##GLOW_OBJECT##_fdoutspeed = fdoutspeed;
  38. }
  39. _##GLOW_OBJECT##_addTrigger(GuiObject triggerObject)
  40. {
  41. if (triggerObject)
  42. {
  43. if (!_##GLOW_OBJECT##_trigger1)
  44. {
  45. _##GLOW_OBJECT##_trigger1 = triggerObject;
  46. return;
  47. }
  48. if (!_##GLOW_OBJECT##_trigger2)
  49. {
  50. _##GLOW_OBJECT##_trigger2 = triggerObject;
  51. return;
  52. }
  53. if (!_##GLOW_OBJECT##_trigger3)
  54. {
  55. _##GLOW_OBJECT##_trigger3 = triggerObject;
  56. return;
  57. }
  58. if (!_##GLOW_OBJECT##_trigger4)
  59. {
  60. _##GLOW_OBJECT##_trigger4 = triggerObject;
  61. return;
  62. }
  63. if (!_##GLOW_OBJECT##_trigger5)
  64. {
  65. _##GLOW_OBJECT##_trigger5 = triggerObject;
  66. return;
  67. }
  68. }
  69. }
  70. _##GLOW_OBJECT##_GlowTrigger.onEnterArea ()
  71. {
  72. _##GLOW_OBJECT##_glow.cancelTarget();
  73. _##GLOW_OBJECT##_glow.setAlpha(255);
  74. }
  75. _##GLOW_OBJECT##_GlowTrigger.onLeftButtonDown (int x, int y)
  76. {
  77. _##GLOW_OBJECT##_mouseDown = 1;
  78. _##GLOW_OBJECT##_glow.cancelTarget();
  79. _##GLOW_OBJECT##_glow.setAlpha(0);
  80. }
  81. _##GLOW_OBJECT##_GlowTrigger.onLeftButtonUp (int x, int y)
  82. {
  83. _##GLOW_OBJECT##_mouseDown = 0;
  84. _##GLOW_OBJECT##_glow.cancelTarget();
  85. if (_##GLOW_OBJECT##_GlowTrigger.isMouseOverRect()) _##GLOW_OBJECT##_glow.setAlpha(255);
  86. }
  87. _##GLOW_OBJECT##_GlowTrigger.onLeaveArea ()
  88. {
  89. if (_##GLOW_OBJECT##_mouseDown) return;
  90. _##GLOW_OBJECT##_glow.cancelTarget();
  91. _##GLOW_OBJECT##_glow.setTargetA(0);
  92. _##GLOW_OBJECT##_glow.setTargetX(_##GLOW_OBJECT##_glow.getGuiX());
  93. _##GLOW_OBJECT##_glow.setTargetSpeed(_##GLOW_OBJECT##_fdoutspeed);
  94. _##GLOW_OBJECT##_glow.gotoTarget();
  95. }
  96. #undef GLOW_OBJECT