Advertisement
Guest User

MiniBar Vanilla 1.12 Addon

a guest
Oct 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.41 KB | None | 0 0
  1. local MiniBar = CreateFrame("Frame")
  2. MiniBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. MiniBar:RegisterEvent("ADDON_LOADED")
  4. MiniBar:RegisterEvent("UPDATE_FACTION")
  5.  
  6. MiniBar:SetScript("OnEvent", function()
  7.     if event == "ADDON_LOADED" then
  8.         hook()
  9.         hide()
  10.     elseif event == "PLAYER_ENTERING_WORLD" or "UPDATE_FACTION" then
  11.         main()
  12.         MBColor()
  13.         ShapeShiftBarUpdate()
  14.         ShapeShiftBarButtons()
  15.     end
  16. end)
  17.  
  18. function hook()
  19.     --hook to allow moving Blizzard frames
  20.     OLD_UIParent_ManageFramePositions = UIParent_ManageFramePositions
  21.     function UIParent_ManageFramePositions()
  22.     end
  23.     -- changing standard blizzard functions by commenting out the petbar positioning parts so positioning does not get messed up
  24.     function PetActionBarFrame_OnUpdate(elapsed)
  25.     local yPos;
  26.     if ( this.slideTimer and (this.slideTimer < this.timeToSlide) ) then
  27.         this.completed = nil;
  28.         if ( this.mode == "show" ) then
  29.             yPos = (this.slideTimer/this.timeToSlide) * this.yTarget;
  30.             --this:SetPoint("TOPLEFT", this:GetParent(), "BOTTOMLEFT", PETACTIONBAR_XPOS, yPos);
  31.             this.state = "showing";
  32.             this:Show();
  33.         elseif ( this.mode == "hide" ) then
  34.             yPos = (1 - (this.slideTimer/this.timeToSlide)) * this.yTarget;
  35.             --this:SetPoint("TOPLEFT", this:GetParent(), "BOTTOMLEFT", PETACTIONBAR_XPOS, yPos);
  36.             this.state = "hiding";
  37.         end
  38.         this.slideTimer = this.slideTimer + elapsed;
  39.     else
  40.         this.completed = 1;
  41.         if ( this.mode == "show" ) then
  42.             --this:SetPoint("TOPLEFT", this:GetParent(), "BOTTOMLEFT", PETACTIONBAR_XPOS, this.yTarget);
  43.             this.state = "top";
  44.             --Move the chat frame and edit box up a bit
  45.         elseif ( this.mode == "hide" ) then
  46.             --this:SetPoint("TOPLEFT", this:GetParent(), "BOTTOMLEFT", PETACTIONBAR_XPOS, 0);
  47.             this.state = "bottom";
  48.             this:Hide();
  49.             --Move the chat frame and edit box back down to original position
  50.         end
  51.         this.mode = "none";
  52.     end
  53.     end
  54.     function ShowPetActionBar()
  55.     UIParent_ManageFramePositions();
  56.     if ( PetHasActionBar() and PetActionBarFrame.showgrid == 0 and (PetActionBarFrame.mode ~= "show") and not PetActionBarFrame.locked and not PetActionBarFrame.ctrlPressed ) then
  57.         PetActionBarFrame:Show();
  58.         if ( PetActionBarFrame.completed ) then
  59.             PetActionBarFrame.slideTimer = 0;
  60.         end
  61.         PetActionBarFrame.timeToSlide = PETACTIONBAR_SLIDETIME;
  62.         PetActionBarFrame.yTarget = PETACTIONBAR_YPOS;
  63.         PetActionBarFrame.mode = "show";
  64.  
  65.         -- Rare case
  66.         --if ( GetNumShapeshiftForms() > 0 ) then
  67.         --  PETACTIONBAR_XPOS = getglobal("ShapeshiftButton"..GetNumShapeshiftForms()):GetRight() +20;
  68.         --else
  69.         --  PETACTIONBAR_XPOS = 36
  70.         --end
  71.         if ( ChatFrameEditBox:IsShown() ) then
  72.             ChatFrameEditBox:Raise();
  73.         end
  74.     end
  75.     end
  76.     end
  77.    
  78. -- function will be passed frames to hide
  79. function hideFrame(frame)
  80.     -- move frame off screen
  81.     frame:ClearAllPoints()
  82.     frame:SetPoint('BOTTOM', UIParent, 'TOP', 0, -200)
  83.     local hideFrame = CreateFrame("Frame", "hideFrame", UIParent)
  84.     -- set parent to the hideFrame and hide the frame
  85.     frame:SetParent(hideFrame)
  86.     frame:Hide()
  87.     hideFrame:Hide()
  88. end
  89.  
  90. -- function to hide frames
  91. function hide()
  92.     hideFrame(MainMenuBarPageNumber)
  93.     hideFrame(ActionBarUpButton)
  94.     hideFrame(ActionBarDownButton)    
  95.     hideFrame(MainMenuXPBarTexture2)
  96.     hideFrame(MainMenuXPBarTexture3)
  97.     hideFrame(MainMenuBarTexture2)
  98.     hideFrame(MainMenuBarTexture3)
  99.     hideFrame(MainMenuMaxLevelBar2)
  100.     hideFrame(MainMenuMaxLevelBar3)
  101.     hideFrame(MainMenuBarPerformanceBarFrameButton)
  102.     -- Rep
  103.     hideFrame(ReputationXPBarTexture2)
  104.     hideFrame(ReputationXPBarTexture3)
  105.     hideFrame(ReputationWatchBarTexture2)
  106.     hideFrame(ReputationWatchBarTexture3)
  107.     hideFrame(ExhaustionTick)
  108.     -- Micro Buttons
  109.     hideFrame(CharacterMicroButton)
  110.     hideFrame(SpellbookMicroButton)
  111.     hideFrame(TalentMicroButton)
  112.     hideFrame(QuestLogMicroButton)
  113.     hideFrame(MainMenuMicroButton)
  114.     hideFrame(SocialsMicroButton)
  115.     hideFrame(WorldMapMicroButton)
  116.     -- Bags
  117.     hideFrame(CharacterBag3Slot)
  118.     hideFrame(CharacterBag2Slot)
  119.     hideFrame(CharacterBag1Slot)
  120.     hideFrame(CharacterBag0Slot)
  121.     hideFrame(MainMenuBarBackpackButton)
  122.     hideFrame(KeyRingButton)
  123.     -- PetAction
  124.     SlidingActionBarTexture0:SetTexture("")
  125.     SlidingActionBarTexture1:SetTexture("")
  126.     -- Shapeshift
  127.     hideFrame(ShapeshiftBarLeft)
  128.     hideFrame(ShapeshiftBarMiddle)
  129.     hideFrame(ShapeshiftBarRight)
  130. end
  131.  
  132. function main()
  133.     -- Setwidth
  134.     local width = 512
  135.     MainMenuBar:SetWidth(width)
  136.     MainMenuExpBar:SetWidth(width)    
  137.     MainMenuBarMaxLevelBar:SetWidth(width)
  138.     ReputationWatchBar:SetWidth(width)
  139.     ReputationWatchStatusBar:SetWidth(width)
  140.     MultiBarBottomLeft:SetWidth(width)
  141.     MultiBarBottomRight:SetWidth(width)
  142.  
  143.     -- Setpoint
  144.     local yOffset = 5
  145.  
  146.     -- HelpMicroButton
  147.     HelpMicroButton:ClearAllPoints()
  148.     HelpMicroButton:SetPoint("BOTTOM", "MainMenuBarRightEndCap", 0 , 11)
  149.  
  150.     -- XPBar
  151.     MainMenuXPBarTexture0:SetPoint("LEFT", MainMenuExpBar, "LEFT", -2, 0)
  152.     MainMenuXPBarTexture1:SetPoint("RIGHT", MainMenuExpBar, "RIGHT", -2, 0)
  153.     --ExhaustionTick:Show()
  154.     --ExhaustionTick:SetFrameStrata("MEDIUM")
  155.  
  156.     -- RepBar
  157.     ReputationWatchBar:SetPoint("BOTTOM", MainMenuExpBar, "TOP", 0, 0)
  158.     ReputationWatchBarTexture0:SetPoint("LEFT", ReputationWatchBar, "LEFT")
  159.     ReputationWatchBarTexture1:SetPoint("RIGHT", ReputationWatchBar, "RIGHT")
  160.  
  161.     -- XPBarArt
  162.     MainMenuMaxLevelBar0:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT")
  163.     MainMenuBarTexture0:SetPoint("LEFT", MainMenuBarArtFrame, "LEFT")
  164.     MainMenuBarTexture1:SetPoint("RIGHT", MainMenuBarArtFrame, "RIGHT")
  165.  
  166.     -- Endcaps
  167.     -- make sure that the strata level is right and the gryphons stay in the background of the other Actionbars
  168.     MainMenuBarArtFrame:SetFrameStrata("LOW")
  169.     MainMenuBar:SetFrameStrata("LOW")
  170.     MainMenuBarLeftEndCap:SetPoint("RIGHT", MainMenuBarArtFrame, "LEFT", 30, 0)
  171.     MainMenuBarRightEndCap:SetPoint("LEFT", MainMenuBarArtFrame, "RIGHT", -30, 0)
  172.  
  173.     -- MultiBarBottomLeft
  174.     MultiBarBottomLeft:ClearAllPoints()
  175.     -- Check if we are watching a reputation
  176.     local name = GetWatchedFactionInfo()    
  177.     if name then
  178.         MultiBarBottomLeft:SetPoint("BOTTOM", ReputationWatchBar, "TOP", 8, yOffset)
  179.     else    
  180.         MultiBarBottomLeft:SetPoint("BOTTOM", MainMenuExpBar, "TOP", 8, yOffset)
  181.     end
  182.  
  183.     -- MultiBarBottomRight
  184.     MultiBarBottomRight:ClearAllPoints()
  185.     MultiBarBottomRight:SetPoint("BOTTOM", MultiBarBottomLeft, "TOP", 0, yOffset)
  186.    
  187.     -- PetActionBarFrame
  188.     PetActionBarFrame:ClearAllPoints()
  189.     PetActionBarFrame:SetScale(0.73)
  190.     local PetAction_yOffset = 3
  191.     if MultiBarBottomRight:IsVisible() then
  192.     PetActionBarFrame:SetPoint("BOTTOMRIGHT", MultiBarBottomRight, "TOPRIGHT", 65, PetAction_yOffset)
  193.     elseif MultiBarBottomLeft:IsVisible() then
  194.         PetActionBarFrame:SetPoint("BOTTOMRIGHT", MultiBarBottomLeft, "TOPRIGHT", 65, PetAction_yOffset)
  195.     else
  196.        PetActionBarFrame:SetPoint("BOTTOMRIGHT", MainMenuBarArtFrame, "TOPRIGHT", 65, PetAction_yOffset)
  197.     end    
  198.  
  199.     -- FramerateLabel
  200.     FramerateLabel:ClearAllPoints()
  201.     FramerateLabel:SetPoint("TOPRIGHT", MultiBarBottomLeft, "TOPRIGHT", 21,-0)
  202.    
  203.     -- MultiBars
  204.     MultiBarLeft:SetScale(0.9)
  205.     MultiBarRight:SetScale(0.9)
  206.     MultiBarRight:ClearAllPoints()
  207.     MultiBarRight:SetPoint("RIGHT", WorldFrame, "RIGHT", 0, 13)
  208.    
  209.     -- QuestTimerFrame
  210.     QuestTimerFrame:ClearAllPoints()
  211.     QuestTimerFrame:SetPoint("BOTTOMRIGHT", Worldframe, "BOTTOMRIGHT", -10, 10)
  212.    
  213.     -- GroupLootFrame
  214.     GroupLootFrame1:ClearAllPoints()
  215.     GroupLootFrame1:SetPoint("CENTER", Worldframe, "CENTER", 0, -100)
  216.    
  217.     -- ShapeshiftBarFrame
  218.     -- fix icon borders
  219.     function ShapeShiftBarButtons()
  220.         ShapeshiftButton1:SetWidth(38);
  221.         ShapeshiftButton1:SetHeight(38);
  222.         ShapeshiftButton2:SetWidth(38);
  223.         ShapeshiftButton2:SetHeight(38);
  224.         ShapeshiftButton3:SetWidth(38);
  225.         ShapeshiftButton3:SetHeight(38);
  226.         ShapeshiftButton4:SetWidth(38);
  227.         ShapeshiftButton4:SetHeight(38);
  228.         ShapeshiftButton5:SetWidth(38);
  229.         ShapeshiftButton5:SetHeight(38);
  230.         ShapeshiftButton6:SetWidth(38);
  231.         ShapeshiftButton6:SetHeight(38);
  232.         ShapeshiftButton7:SetWidth(38);
  233.         ShapeshiftButton7:SetHeight(38);
  234.     end
  235.     -- Reposition ShapeshiftBarFrame
  236.     function ShapeShiftBarUpdate() 
  237.         local numForms = GetNumShapeshiftForms();
  238.         local Shapeshift_xOffset = ""
  239.         local Shapeshift_yOffset = 50
  240.     if  numForms == 1 then
  241.         Shapeshift_xOffset = -28
  242.     elseif numForms == 2 then
  243.         Shapeshift_xOffset = -51
  244.     elseif numForms == 3 then
  245.         Shapeshift_xOffset = -74
  246.     elseif numForms == 4 then
  247.         Shapeshift_xOffset = -96
  248.     elseif numForms == 5 then
  249.         Shapeshift_xOffset = -119
  250.     elseif numForms == 6 then
  251.         Shapeshift_xOffset = -141
  252.     elseif numForms == 7 then
  253.         Shapeshift_xOffset = -164
  254.     elseif numForms == 8 then
  255.     end
  256.     ShapeshiftBarFrame:ClearAllPoints()
  257.     ShapeshiftBarFrame:SetScale(0.60)
  258.     ShapeshiftBarFrame:SetFrameStrata("MEDIUM")
  259.     if UnitClass("player") == "Hunter" then
  260.         if MultiBarBottomRight:IsVisible() then
  261.             ShapeshiftBarFrame:SetPoint("BOTTOMLEFT", MultiBarBottomRight, "TOPLEFT", 7, 2)
  262.         elseif MultiBarBottomLeft:IsVisible() then
  263.             ShapeshiftBarFrame:SetPoint("BOTTOMLEFT", MultiBarBottomLeft, "TOPLEFT", 7, 2)
  264.         else
  265.             ShapeshiftBarFrame:SetPoint("BOTTOMLEFT", ActionButton1, "TOPLEFT", 22, 23)
  266.         end
  267.     else
  268.         if MultiBarBottomRight:IsVisible() then
  269.         ShapeshiftBarFrame:SetPoint("CENTER", MultiBarBottomRight, "CENTER", Shapeshift_xOffset, Shapeshift_yOffset)
  270.         elseif MultiBarBottomLeft:IsVisible() then
  271.         ShapeshiftBarFrame:SetPoint("CENTER", MultiBarBottomLeft, "CENTER", Shapeshift_xOffset, Shapeshift_yOffset)
  272.         else
  273.         ShapeshiftBarFrame:SetPoint("CENTER", MultiBarBottomLeft, "CENTER", Shapeshift_xOffset, -20)
  274.         end
  275.     end
  276.    
  277.     -- CastingBarFrame
  278.     CastingBarFrame:ClearAllPoints()
  279.     local castBar_yOffset = 35
  280.     local castBar_xOffset = -8
  281.     if MultiBarBottomRight:IsVisible() then
  282.         CastingBarFrame:SetPoint("BOTTOM", MultiBarBottomRight, "TOP", castBar_xOffset, castBar_yOffset)
  283.     elseif MultiBarBottomLeft:IsVisible() then
  284.         CastingBarFrame:SetPoint("BOTTOM", MultiBarBottomLeft, "TOP", castBar_xOffset, castBar_yOffset)
  285.     else
  286.         CastingBarFrame:SetPoint("BOTTOM", MainMenuBarArtFrame, "TOP", castBar_xOffset, castBar_yOffset)
  287.     end    
  288. end
  289.    
  290. function MBColor()
  291.  
  292.     local MBr, MBg, MBb = 1, 1, 1
  293.  
  294.     if UnitClass("player") == "Mage" then
  295.         MBr, MBg, MBb = 0.41, 0.80, 0.94    -- change these color codes for each class if you want another color for your ui
  296.     elseif UnitClass("player") == "Warrior" then
  297.         MBr, MBg, MBb = 0.78, 0.61, 0.43
  298.     elseif UnitClass("player") == "Druid" then
  299.         MBr, MBg, MBb = 1, 0.49, 0.04
  300.     elseif UnitClass("player") == "Hunter" then
  301.         MBr, MBg, MBb = 0.67, 0.83, 0.45
  302.     elseif UnitClass("player") == "Paladin" then
  303.         MBr, MBg, MBb = 0.96, 0.55, 0.73
  304.     elseif UnitClass("player") == "Priest" then
  305.         MBr, MBg, MBb = 1, 1, 1
  306.     elseif UnitClass("player") == "Rogue" then
  307.         MBr, MBg, MBb = 1, 0.96, 0.41
  308.     elseif UnitClass("player") == "Shaman" then
  309.         MBr, MBg, MBb = 0, 0.44, 0.87
  310.     elseif UnitClass("player") == "Warlock" then
  311.         MBr, MBg, MBb = 0.58, 0.51, 0.79
  312.     else
  313.     end
  314.        
  315.     -- Unit & Castbar
  316.     PlayerFrameTexture:SetVertexColor(MBr, MBg, MBb)
  317.     CastingBarBorder:SetVertexColor(MBr, MBg, MBb)
  318.     -- Mainbar
  319.     MainMenuBarTexture0:SetVertexColor(MBr, MBg, MBb)
  320.     MainMenuBarTexture1:SetVertexColor(MBr, MBg, MBb)
  321.     MainMenuBarTexture2:SetVertexColor(MBr, MBg, MBb)
  322.     MainMenuBarTexture3:SetVertexColor(MBr, MBg, MBb)
  323.     MainMenuMaxLevelBar0:SetVertexColor(MBr, MBg, MBb)
  324.     MainMenuMaxLevelBar1:SetVertexColor(MBr, MBg, MBb)
  325.     MainMenuMaxLevelBar2:SetVertexColor(MBr, MBg, MBb)
  326.     MainMenuMaxLevelBar3:SetVertexColor(MBr, MBg, MBb)
  327.     MainMenuXPBarTexture0:SetVertexColor(MBr, MBg, MBb)
  328.     MainMenuXPBarTexture1:SetVertexColor(MBr, MBg, MBb)
  329.     BonusActionBarTexture0:SetVertexColor(MBr, MBg, MBb)
  330.     BonusActionBarTexture1:SetVertexColor(MBr, MBg, MBb)
  331.     ReputationWatchBarTexture0:SetVertexColor(MBr, MBg, MBb)
  332.     ReputationWatchBarTexture1:SetVertexColor(MBr, MBg, MBb)
  333.     ReputationWatchBarTexture2:SetVertexColor(MBr, MBg, MBb)
  334.     ReputationWatchBarTexture3:SetVertexColor(MBr, MBg, MBb)
  335.     ReputationXPBarTexture0:SetVertexColor(MBr, MBg, MBb)
  336.     ReputationXPBarTexture1:SetVertexColor(MBr, MBg, MBb)
  337.     SlidingActionBarTexture0:SetVertexColor(MBr, MBg, MBb)
  338.     SlidingActionBarTexture1:SetVertexColor(MBr, MBg, MBb)
  339.     MainMenuBarLeftEndCap:SetVertexColor(MBr, MBg, MBb)
  340.     MainMenuBarRightEndCap:SetVertexColor(MBr, MBg, MBb)
  341.    
  342. end
  343. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement