ScreenFadeBackground.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. Canvas.pushDialog(%this);
  14. %this.fadeTo(%this.solidColor, %this.swapTime, "EaseInOut");
  15. %this.schedule(%this.swapTime, "doSwap");
  16. }
  17. function ScreenFadeBackground::doSwap(%this)
  18. {
  19. Canvas.setContent(%this.swapContent);
  20. Canvas.pushDialog(%this);
  21. %this.schedule(%this.swapTime/2, "fadeSwap");
  22. }
  23. function ScreenFadeBackground::fadeSwap(%this)
  24. {
  25. %this.fadeTo(%this.transparentColor, %this.swapTime, "EaseInOut");
  26. %this.schedule(%this.swapTime, "finishSwap");
  27. }
  28. function ScreenFadeBackground::finishSwap(%this)
  29. {
  30. Canvas.popDialog(%this);
  31. %this.Owner.postEvent("SwapComplete");
  32. }
  33. function ScreenFadeBackground::openDialog(%this)
  34. {
  35. %this.resetColor();
  36. %this.add(%this.dialog);
  37. Canvas.pushDialog(%this);
  38. %this.fadeTo(%this.solidColor, %this.dialogTime, "EaseInOut");
  39. %this.schedule(%this.dialogTime, "openDialogComplete");
  40. }
  41. function ScreenFadeBackground::openDialogComplete(%this)
  42. {
  43. %this.Owner.postEvent("OpenComplete");
  44. %this.startListening(%this.dialog);
  45. }
  46. function ScreenFadeBackground::onDialogClose(%this)
  47. {
  48. if(%this.isAwake())
  49. {
  50. if(isEventPending(%this.hideSchedule))
  51. {
  52. cancel(%this.hideSchedule);
  53. }
  54. %this.fadeTo(%this.transparentColor, %this.dialogTime, "EaseIn");
  55. %this.hideSchedule = %this.schedule(%this.dialogTime, "onCloseComplete");
  56. }
  57. }
  58. function ScreenFadeBackground::onCloseComplete(%this)
  59. {
  60. if(isObject(%this.dialog))
  61. {
  62. %this.stopListening(%this.dialog);
  63. %this.removeIfMember(%this.dialog);
  64. }
  65. Canvas.popDialog(%this);
  66. %this.Owner.postEvent("CloseComplete");
  67. }