ActionBarController.lua

ActionBarController.lua (9.0.2.36294; unchanged since 9.0.1.36230)
  1. local CURRENT_ACTION_BAR_STATE
  2. function ActionBarController_GetCurrentActionBarState()
  3. return CURRENT_ACTION_BAR_STATE;
  4. end
  5. function ActionBarController_OnLoad(self)
  6. --ManyBars
  7. self:RegisterEvent("PLAYER_ENTERING_WORLD");
  8. self:RegisterEvent("ACTIONBAR_PAGE_CHANGED");
  9. -- This is used for shapeshifts/stances
  10. self:RegisterEvent("UPDATE_BONUS_ACTIONBAR");
  11. --Vehicle Only
  12. self:RegisterEvent("UNIT_DISPLAYPOWER");
  13. --MainBar Only
  14. --Alternate Only
  15. self:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR");
  16. self:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR");
  17. --Shapeshift/Stance Only
  18. self:RegisterEvent("UPDATE_SHAPESHIFT_FORM");
  19. self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS");
  20. self:RegisterEvent("UPDATE_SHAPESHIFT_USABLE");
  21. self:RegisterEvent("UPDATE_INVENTORY_ALERTS"); -- Wha?? Still Wha...
  22. -- Possess Bar
  23. self:RegisterEvent("UPDATE_POSSESS_BAR");
  24. --Extra Actionbar Only
  25. self:RegisterEvent("UPDATE_EXTRA_ACTIONBAR");
  26. -- MultiBarBottomLeft
  27. self:RegisterEvent("ACTIONBAR_SHOW_BOTTOMLEFT");
  28. -- Misc
  29. self:RegisterEvent("PET_BATTLE_CLOSE");
  30. CURRENT_ACTION_BAR_STATE = LE_ACTIONBAR_STATE_MAIN;
  31. -- hack to fix crasy animation on bars when action bar is also animating
  32. StatusTrackingBarManager:SetBarAnimation(ActionBarBusy);
  33. MainMenuMicroButton_Init();
  34. end
  35. function ActionBarController_OnEvent(self, event, ...)
  36. local arg1, arg2 = ...;
  37. if ( event == "PLAYER_ENTERING_WORLD" ) then
  38. ActionBarController_UpdateAll();
  39. end
  40. if ( event == "UPDATE_BONUS_ACTIONBAR"
  41. or event == "UPDATE_VEHICLE_ACTIONBAR"
  42. or event == "UPDATE_OVERRIDE_ACTIONBAR"
  43. or event == "ACTIONBAR_PAGE_CHANGED" ) then
  44. ActionBarController_UpdateAll();
  45. end
  46. if ( event == "UPDATE_BONUS_ACTIONBAR" ) then
  47. IconIntroTracker:ResetAll();
  48. end
  49. if ( event == "UNIT_DISPLAYPOWER" ) then
  50. UnitFrameManaBar_Update(OverrideActionBarPowerBar, "vehicle");
  51. end
  52. --shapeshift
  53. if ( event == "UPDATE_SHAPESHIFT_FORM"
  54. or event == "UPDATE_SHAPESHIFT_FORMS"
  55. or event == "UPDATE_SHAPESHIFT_USABLE" ) then
  56. StanceBar_Update();
  57. end
  58. --possess
  59. if ( event == "UPDATE_POSSESS_BAR" ) then
  60. PossessBar_Update();
  61. StanceBar_Update();
  62. end
  63. --Extra Action Bar
  64. if ( event == "UPDATE_EXTRA_ACTIONBAR" ) then
  65. ExtraActionBar_Update();
  66. end
  67. -- MultiBarBottomLeft
  68. if ( event == "ACTIONBAR_SHOW_BOTTOMLEFT") then
  69. SHOW_MULTI_ACTIONBAR_1 = true;
  70. InterfaceOptionsActionBarsPanelBottomLeft.value = nil;
  71. MultiActionBar_Update();
  72. UIParent_ManageFramePositions();
  73. end
  74. if ( event == "PET_BATTLE_CLOSE" ) then
  75. ValidateActionBarTransition();
  76. end
  77. end
  78. function ActionBarController_UpdateAll(force)
  79. PossessBar_Update();
  80. StanceBar_Update();
  81. CURRENT_ACTION_BAR_STATE = LE_ACTIONBAR_STATE_MAIN;
  82. -- If we have a skinned vehicle bar or skinned override bar, display the OverrideActionBar
  83. if ((HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
  84. or (HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= 0)) then
  85. OverrideActionBar_UpdateSkin();
  86. CURRENT_ACTION_BAR_STATE = LE_ACTIONBAR_STATE_OVERRIDE;
  87. -- If we have a non-skinned override bar of some sort, use the MainMenuBarArtFrame
  88. elseif ( HasBonusActionBar() or HasOverrideActionBar() or HasVehicleActionBar() or HasTempShapeshiftActionBar() or C_PetBattles.IsInBattle() ) then
  89. if (HasVehicleActionBar()) then
  90. MainMenuBarArtFrame:SetAttribute("actionpage", GetVehicleBarIndex());
  91. elseif (HasOverrideActionBar()) then
  92. MainMenuBarArtFrame:SetAttribute("actionpage", GetOverrideBarIndex());
  93. elseif (HasTempShapeshiftActionBar()) then
  94. MainMenuBarArtFrame:SetAttribute("actionpage", GetTempShapeshiftBarIndex());
  95. elseif (HasBonusActionBar() and GetActionBarPage() == 1) then
  96. MainMenuBarArtFrame:SetAttribute("actionpage", GetBonusBarIndex());
  97. else
  98. MainMenuBarArtFrame:SetAttribute("actionpage", GetActionBarPage());
  99. end
  100. for k, frame in pairs(ActionBarButtonEventsFrame.frames) do
  101. frame:UpdateAction(force);
  102. end
  103. else
  104. -- Otherwise, display the normal action bar
  105. ActionBarController_ResetToDefault(force);
  106. end
  107. ValidateActionBarTransition();
  108. end
  109. function ActionBarController_ResetToDefault(force)
  110. MainMenuBarArtFrame:SetAttribute("actionpage", GetActionBarPage());
  111. for k, frame in pairs(ActionBarButtonEventsFrame.frames) do
  112. frame:UpdateAction(force);
  113. end
  114. end
  115. ----------------------------------------------------
  116. ----------------- Animation Code -------------------
  117. ----------------------------------------------------
  118. function ActionBarBusy()
  119. return MainMenuBar.slideOut:IsPlaying() or OverrideActionBar.slideOut:IsPlaying() or C_PetBattles.IsInBattle();
  120. end
  121. function BeginActionBarTransition(bar, animIn)
  122. bar:Show();
  123. bar.hideOnFinish = not animIn;
  124. bar.slideOut:Play(animIn);
  125. end
  126. function ValidateActionBarTransition()
  127. if ActionBarBusy() then
  128. return; --Don't evluate and action bar state durring animations or while in Pet Battles
  129. end
  130. MultiActionBar_Update();
  131. UIParent_ManageFramePositions();
  132. if CURRENT_ACTION_BAR_STATE == LE_ACTIONBAR_STATE_MAIN then
  133. if OverrideActionBar:IsShown() then
  134. BeginActionBarTransition(OverrideActionBar, nil);
  135. elseif not MainMenuBar:IsShown() then
  136. BeginActionBarTransition(MainMenuBar, 1);
  137. if ( SHOW_MULTI_ACTIONBAR_3 ) then
  138. BeginActionBarTransition(MultiBarRight, 1);
  139. end
  140. if ( SHOW_MULTI_ACTIONBAR_4 ) then
  141. BeginActionBarTransition(MultiBarLeft, 1);
  142. end
  143. end
  144. elseif CURRENT_ACTION_BAR_STATE == LE_ACTIONBAR_STATE_OVERRIDE then
  145. if MainMenuBar:IsShown() then
  146. BeginActionBarTransition(MainMenuBar, nil);
  147. if ( SHOW_MULTI_ACTIONBAR_3 ) then
  148. BeginActionBarTransition(MultiBarRight, nil);
  149. end
  150. if ( SHOW_MULTI_ACTIONBAR_4 ) then
  151. BeginActionBarTransition(MultiBarLeft, nil);
  152. end
  153. elseif not OverrideActionBar:IsShown() then
  154. BeginActionBarTransition(OverrideActionBar, 1);
  155. end
  156. end
  157. end