ScreenFadeBackground.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. function ScreenFadeBackground::resetColor(%this)
  2. {
  3. if(getWord(%this.getImageColor(), 3) == 0)
  4. {
  5. %this.setImageColor(%this.transparentColor);
  6. %extent = Canvas.getExtent();
  7. %this.setExtent(getWord(%extent, 0), getWord(%extent, 1));
  8. }
  9. }
  10. function ScreenFadeBackground::startSwap(%this)
  11. {
  12. %this.resetColor();
  13. %this.clear();
  14. Canvas.pushDialog(%this);
  15. %this.fadeTo(%this.solidColor, %this.swapTime, "EaseInOut");
  16. %this.schedule(%this.swapTime, "doSwap");
  17. }
  18. function ScreenFadeBackground::doSwap(%this)
  19. {
  20. Canvas.setContent(%this.swapContent);
  21. Canvas.pushDialog(%this);
  22. %this.schedule(%this.swapTime/2, "fadeSwap");
  23. }
  24. function ScreenFadeBackground::fadeSwap(%this)
  25. {
  26. %this.fadeTo(%this.transparentColor, %this.swapTime, "EaseInOut");
  27. %this.schedule(%this.swapTime, "finishSwap");
  28. }
  29. function ScreenFadeBackground::finishSwap(%this)
  30. {
  31. Canvas.popDialog(%this);
  32. %this.Owner.postEvent("SwapComplete");
  33. }
  34. function ScreenFadeBackground::openDialog(%this)
  35. {
  36. %this.resetColor();
  37. %this.add(%this.dialog);
  38. Canvas.pushDialog(%this);
  39. %this.fadeTo(%this.solidColor, %this.dialogTime, "EaseInOut");
  40. %this.schedule(%this.dialogTime, "openDialogComplete");
  41. }
  42. function ScreenFadeBackground::openDialogComplete(%this)
  43. {
  44. %this.Owner.postEvent("OpenComplete");
  45. %this.startListening(%this.dialog);
  46. }
  47. function ScreenFadeBackground::onDialogClose(%this)
  48. {
  49. if(%this.isAwake())
  50. {
  51. if(isEventPending(%this.hideSchedule))
  52. {
  53. cancel(%this.hideSchedule);
  54. }
  55. %this.clear();
  56. %this.fadeTo(%this.transparentColor, %this.dialogTime, "EaseIn");
  57. %this.hideSchedule = %this.schedule(%this.dialogTime, "onCloseComplete");
  58. }
  59. }
  60. function ScreenFadeBackground::onDialogSwap(%this, %dialog)
  61. {
  62. if(%this.isAwake() && isObject(%this.dialog))
  63. {
  64. if(isEventPending(%this.hideSchedule))
  65. {
  66. cancel(%this.hideSchedule);
  67. }
  68. %this.setImageColor(%this.solidColor);
  69. %this.stopListening(%this.dialog);
  70. %this.removeIfMember(%this.dialog);
  71. %this.dialog = %dialog;
  72. %this.add(%this.dialog);
  73. %this.startListening(%this.dialog);
  74. }
  75. }
  76. function ScreenFadeBackground::onCloseComplete(%this)
  77. {
  78. if(isObject(%this.dialog))
  79. {
  80. %this.stopListening(%this.dialog);
  81. %this.removeIfMember(%this.dialog);
  82. }
  83. Canvas.popDialog(%this);
  84. %this.Owner.postEvent("CloseComplete");
  85. }