Advertisement
Guest User

Blizzard_BarberShopUI.lua

a guest
Mar 29th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | None | 0 0
  1. function BarberShop_OnLoad(self)
  2.     BarberShop_UpdateHairCustomization();
  3.     BarberShop_UpdateFacialHairCustomization();
  4.     self:RegisterEvent("BARBER_SHOP_APPEARANCE_APPLIED");
  5.     self:RegisterEvent("BARBER_SHOP_SUCCESS");
  6.    
  7.     if ( CanAlterSkin() ) then
  8.         BarberShop_ToFourAttributeFormat();
  9.     end
  10. end
  11.  
  12. function BarberShop_OnShow(self)
  13.     CloseAllBags();
  14.     BarberShop_ResetLabelColors();
  15.     BarberShop_UpdateCost();
  16.     if ( BarberShopBannerFrame ) then
  17.         BarberShopBannerFrame:Show();
  18.         BarberShopBannerFrame.caption:SetText(BARBERSHOP);
  19.     end
  20.     self:ClearAllPoints();
  21.     self:SetPoint("RIGHT", min(-50, -CONTAINER_OFFSET_X), -50);
  22.  
  23.     PlaySound("BarberShop_Sit");
  24.    
  25.     WatchFrame:Hide();
  26.  
  27.     --load the texture
  28.     BarberShopFrameBackground:SetTexture("Interface\\Barbershop\\UI-Barbershop");
  29. end
  30.  
  31. function BarberShop_OnHide(self)
  32.     BarberShopBannerFrame:Hide();
  33.  
  34.     WatchFrame:Show();
  35.    
  36.     --unload the texture to save memory
  37.     BarberShopFrameBackground:SetTexture(nil);
  38. end
  39.  
  40. function BarberShop_OnEvent(self, event, ...)
  41.     if(event == "BARBER_SHOP_SUCCESS") then
  42.         PlaySound("Barbershop_Haircut");
  43.     end
  44.     BarberShop_Update(self);
  45. end
  46.  
  47. function BarberShop_UpdateCost()
  48.     MoneyFrame_Update(BarberShopFrameMoneyFrame:GetName(), GetBarberShopTotalCost());
  49.     -- The 4th return from GetBarberShopStyleInfo is whether the selected style is the active character style
  50.     if ( select(4, GetBarberShopStyleInfo(1)) and select(4, GetBarberShopStyleInfo(2)) and select(4, GetBarberShopStyleInfo(3)) and ( not BarberShopFrameSelector4:IsShown() or select(4, GetBarberShopStyleInfo(4)) ) ) then
  51.         BarberShopFrameOkayButton:Disable();
  52.         BarberShopFrameResetButton:Disable();
  53.     else
  54.         BarberShopFrameOkayButton:Enable();
  55.         BarberShopFrameResetButton:Enable();
  56.     end
  57. end
  58.  
  59. function BarberShop_UpdateBanner(name)
  60.     if ( name ) then
  61.         BarberShopBannerFrameCaption:SetText(name);
  62.     end
  63. end
  64.  
  65. function BarberShop_Update(self)
  66.     BarberShop_UpdateCost();
  67.     BarberShop_UpdateSelector(BarberShopFrameSelector4);
  68.     BarberShop_UpdateSelector(BarberShopFrameSelector3);
  69.     BarberShop_UpdateSelector(BarberShopFrameSelector2);
  70.     BarberShop_UpdateSelector(BarberShopFrameSelector1);
  71. end
  72.  
  73. function BarberShop_UpdateSelector(self)
  74.     local name, _, _, isCurrent = GetBarberShopStyleInfo(self:GetID());
  75.     BarberShop_UpdateBanner(name);
  76.     local frameName = self:GetName();
  77.     BarberShop_SetLabelColor(_G[frameName.."Category"], isCurrent);
  78. end
  79.  
  80. function BarberShop_UpdateHairCustomization()
  81.     local hairCustomization = GetHairCustomization();
  82.     BarberShopFrameSelector1Category:SetText(_G["HAIR_"..hairCustomization.."_STYLE"]);
  83.     BarberShopFrameSelector2Category:SetText(_G["HAIR_"..hairCustomization.."_COLOR"]);
  84. end
  85.  
  86. function BarberShop_UpdateFacialHairCustomization()
  87.     BarberShopFrameSelector3Category:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]);
  88. end
  89.  
  90. function BarberShop_SetLabelColor(label, isCurrent)
  91.     if ( isCurrent ) then
  92.         label:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
  93.     else
  94.         label:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
  95.     end
  96. end
  97.  
  98. function BarberShop_ResetLabelColors()
  99.     BarberShop_SetLabelColor(BarberShopFrameSelector1Category, 1);
  100.     BarberShop_SetLabelColor(BarberShopFrameSelector2Category, 1);
  101.     BarberShop_SetLabelColor(BarberShopFrameSelector3Category, 1);
  102.     BarberShop_SetLabelColor(BarberShopFrameSelector4Category, 1);
  103. end
  104.  
  105. function BarberShop_ToFourAttributeFormat()
  106.     BarberShopFrameSelector2:SetPoint("TOPLEFT", BarberShopFrameSelector1, "BOTTOMLEFT", 0, 3);
  107.     BarberShopFrameSelector3:SetPoint("TOPLEFT", BarberShopFrameSelector2, "BOTTOMLEFT", 0, 3);
  108.     BarberShopFrameSelector4:Show();
  109.     BarberShopFrameMoneyFrame:SetPoint("TOP", BarberShopFrameSelector4, "BOTTOM", 7, -7);
  110.     BarberShopFrameOkayButton:SetPoint("RIGHT", BarberShopFrameSelector4, "BOTTOM", -2, -36);
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement