Blizzard_SubscriptionInterstitialUI/Blizzard_SubscriptionInterstitialUI.lua

Blizzard_SubscriptionInterstitialUI/Blizzard_SubscriptionInterstitialUI.lua (9.0.5.38134; unchanged since 9.0.2.36665)
  1. local MaximumBulletPoints = 10;
  2. UIPanelWindows["SubscriptionInterstitialFrame"] = { area = "center", pushable = 0, whileDead = 1 };
  3. SubscriptionInterstitialSubscribeButtonBaseMixin = {};
  4. function SubscriptionInterstitialSubscribeButtonBaseMixin:OnLoad()
  5. local useAtlasSize = true;
  6. self.Background:SetAtlas(self.backgroundAtlas, useAtlasSize);
  7. self.ButtonText:SetFontObjectsToTry("SystemFont_Med3", "SystemFont_Med2", "SystemFont_Small2", "SystemFont_Small", "SystemFont_Tiny");
  8. end
  9. function SubscriptionInterstitialSubscribeButtonBaseMixin:OnShow()
  10. self:ClearClickState();
  11. end
  12. function SubscriptionInterstitialSubscribeButtonBaseMixin:OnClick()
  13. PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
  14. self.wasClicked = true;
  15. if StoreInterfaceUtil.OpenToSubscriptionProduct() then
  16. SendSubscriptionInterstitialResponse(Enum.SubscriptionInterstitialResponseType.Clicked);
  17. else
  18. SendSubscriptionInterstitialResponse(Enum.SubscriptionInterstitialResponseType.WebRedirect)
  19. end
  20. HideUIPanel(self:GetParent());
  21. end
  22. function SubscriptionInterstitialSubscribeButtonBaseMixin:WasClicked()
  23. return self.wasClicked;
  24. end
  25. function SubscriptionInterstitialSubscribeButtonBaseMixin:ClearClickState()
  26. self.wasClicked = false;
  27. end
  28. SubscriptionInterstitialSubscribeButtonMixin = {};
  29. function SubscriptionInterstitialSubscribeButtonMixin:OnLoad()
  30. SubscriptionInterstitialSubscribeButtonBaseMixin.OnLoad(self);
  31. self.FirstLine:SetFontObjectsToTry("Game58Font_Shadow2", "Game52Font_Shadow2", "Game46Font_Shadow2", "Game40Font_Shadow2");
  32. self.SecondLine:SetFontObjectsToTry("Game52Font_Shadow2", "Game46Font_Shadow2", "Game40Font_Shadow2");
  33. self.ThirdLine:SetFontObjectsToTry("Game69Font_Shadow2", "Game58Font_Shadow2", "Game52Font_Shadow2", "Game46Font_Shadow2", "Game40Font_Shadow2");
  34. if self.SecondLine:GetStringHeight() > self.FirstLine:GetStringHeight() then
  35. self.SecondLine:SetFontObject(self.FirstLine:GetFontObject());
  36. end
  37. if self.SecondLine:GetStringHeight() > self.ThirdLine:GetStringHeight() then
  38. self.SecondLine:SetFontObject(self.FirstLine:GetFontObject());
  39. end
  40. end
  41. SubscriptionInterstitialUpgradeButtonMixin = {};
  42. function SubscriptionInterstitialUpgradeButtonMixin:OnLoad()
  43. SubscriptionInterstitialSubscribeButtonBaseMixin.OnLoad(self);
  44. self.TitleLine:SetFontObjectsToTry("Game40Font_Shadow2", "Game36Font_Shadow2", "Game32Font_Shadow2");
  45. self.TitleSubText:SetFontObjectsToTry("Game17Font_Shadow", "Game13FontShadow", "Game11Font_Shadow");
  46. self.bulletPointPool = CreateFramePool("FRAME", self, "SubscriptionInterstitialBulletPointTemplate");
  47. local function BulletPointFactoryFunction(index)
  48. local bulletPointText = _G["SUBSCRIPTION_INTERSTITIAL_UPGRADE_BULLET"..index];
  49. if not bulletPointText or (bulletPointText == "") then
  50. return nil;
  51. end
  52. local bulletPoint = self.bulletPointPool:Acquire();
  53. bulletPoint.Text:SetText(bulletPointText);
  54. bulletPoint:Show();
  55. return bulletPoint;
  56. end
  57. local stride = 1;
  58. local paddingX = 0;
  59. local paddingY = 22;
  60. local layout = AnchorUtil.CreateGridLayout(GridLayoutMixin.Direction.TopLeftToBottomRight, stride, paddingX, paddingY);
  61. local initialAnchor = AnchorUtil.CreateAnchor("TOP", self, "TOP", -141, -168);
  62. AnchorUtil.GridLayoutFactoryByCount(BulletPointFactoryFunction, MaximumBulletPoints, initialAnchor, layout);
  63. end
  64. SubscriptionInterstitialCloseButtonMixin = {};
  65. function SubscriptionInterstitialCloseButtonMixin:OnClick()
  66. PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE);
  67. HideUIPanel(self:GetParent());
  68. end
  69. SubscriptionInterstitialFrameMixin = {}
  70. function SubscriptionInterstitialFrameMixin:OnLoad()
  71. self:RegisterEvent("SHOW_SUBSCRIPTION_INTERSTITIAL");
  72. self.Inset.Bg:Hide();
  73. end
  74. function SubscriptionInterstitialFrameMixin:OnShow()
  75. self.cinematicIsShowing = nil;
  76. EventRegistry:RegisterCallback("CinematicFrame.CinematicStarting", self.OnCinematicStarting, self);
  77. end
  78. function SubscriptionInterstitialFrameMixin:OnHide()
  79. if self.cinematicIsShowing then
  80. return;
  81. end
  82. EventRegistry:UnregisterCallback("CinematicFrame.CinematicStarting", self);
  83. EventRegistry:UnregisterCallback("CinematicFrame.CinematicStopped", self);
  84. if not self.SubscribeButton:WasClicked() and not self.UpgradeButton:WasClicked() then
  85. SendSubscriptionInterstitialResponse(Enum.SubscriptionInterstitialResponseType.Closed);
  86. self.SubscribeButton:ClearClickState();
  87. self.UpgradeButton:ClearClickState();
  88. end
  89. end
  90. function SubscriptionInterstitialFrameMixin:OnEvent(event, ...)
  91. if event == "SHOW_SUBSCRIPTION_INTERSTITIAL" then
  92. local interstitialType = ...;
  93. self:SetInterstitialType(interstitialType);
  94. ShowUIPanel(self);
  95. end
  96. end
  97. function SubscriptionInterstitialFrameMixin:OnCinematicStarting()
  98. self.cinematicIsShowing = true;
  99. EventRegistry:UnregisterCallback("CinematicFrame.CinematicStarting", self);
  100. EventRegistry:RegisterCallback("CinematicFrame.CinematicStopped", self.OnCinematicStopped, self);
  101. end
  102. function SubscriptionInterstitialFrameMixin:OnCinematicStopped()
  103. self.cinematicIsShowing = nil;
  104. EventRegistry:UnregisterCallback("CinematicFrame.CinematicStopped", self);
  105. ShowUIPanel(self);
  106. end
  107. function SubscriptionInterstitialFrameMixin:SetInterstitialType(interstitialType)
  108. local isMaxLevel = interstitialType == Enum.SubscriptionInterstitialType.MaxLevel;
  109. self.SubscribeButton:SetShown(not isMaxLevel);
  110. self.UpgradeButton:SetShown(isMaxLevel);
  111. end