Skip to content

Commit

Permalink
Fix visibility problems with 'New Feature' and some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hizuro committed Feb 10, 2024
1 parent d7264b0 commit 7b71288
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
11 changes: 2 additions & 9 deletions LibDropDownMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ function UIDropDownMenu_InitializeHelper(frame)
-- Hide all the buttons
local button, dropDownList;
for i = 1, UIDROPDOWNMENU_MAXLEVELS, 1 do
if not _G["LibDropDownMenu_List"..i] then
Create_DropDownList("LibDropDownMenu_List"..i,nil,{id=i});
end
dropDownList = _G["LibDropDownMenu_List"..i];
if ( i >= UIDROPDOWNMENU_MENU_LEVEL or frame ~= UIDROPDOWNMENU_OPEN_MENU ) then
dropDownList.numButtons = 0;
Expand Down Expand Up @@ -146,10 +143,6 @@ function UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, menu
level = 1;
end

if not _G["LibDropDownMenu_List"..level] then
Create_DropDownList("LibDropDownMenu_List"..level,nil,{id=level});
end

local dropDownList = _G["LibDropDownMenu_List"..level];
dropDownList.dropdown = frame;
dropDownList.shouldRefresh = true;
Expand Down Expand Up @@ -300,7 +293,7 @@ function UIDropDownMenuButton_OnEnter(self)
end

GetValueOrCallFunction(self, "funcOnEnter", self);
--self.NewFeature:Hide(); -- in retail, but why?
--self.NewFeature:Hide(); -- why should it disappear on mouse over? (found in retail code)
self.NewFeature:SetShown(self.showNewLabel);
end

Expand Down Expand Up @@ -1684,7 +1677,7 @@ function UIDropDownMenu_GetValue(id)
end
end

function OpenColorPicker(info)
function OpenColorPicker(info) -- deprecated in retail
ColorPickerFrame.func = info.swatchFunc;
ColorPickerFrame.hasOpacity = info.hasOpacity;
ColorPickerFrame.opacityFunc = info.opacityFunc;
Expand Down
48 changes: 35 additions & 13 deletions LibDropDownMenuTemplatesCreate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ if not PixelUtil then -- classic compatibilty
end
end

local function Create_NewFeature(parent)
local function Create_NewFeature(parent,frameStrata,frameLevel,width,height,scale,shown)
local NewFeature = CreateFrame("Frame",nil,parent); -- ResizeLayoutFrame template unusable
NewFeature:Hide();
--NewFeature:SetFrameStrata(frameStrata);
--NewFeature:SetFrameLevel(parent:GetFrameLevel()+frameLevel);
NewFeature:SetFrameLevel(frameLevel);
NewFeature:SetSize(width,height);
NewFeature:SetScale(scale);
NewFeature:SetShown(shown);

Mixin(NewFeature,NewFeatureLabelMixin);

-- <KeyValues>
Expand All @@ -92,21 +98,28 @@ local function Create_NewFeature(parent)
-- </KeyValues>
-- <Layers>
-- <Layer OVERLAY>
NewFeature.BGLabel = NewFeature:CreateFontString(nil,"OVERLAY","GameFontNormal_NoShadow",1);
NewFeature.BGLabel = NewFeature:CreateFontString(nil,"OVERLAY","GameFontNormal_NoShadow");
NewFeature.BGLabel.ignoreInLayout = true;
NewFeature.BGLabel:SetDrawLayer("OVERLAY",1)
NewFeature.BGLabel:SetMaxLines(1);
NewFeature.BGLabel:SetJustifyH("CENTER")
NewFeature.BGLabel:SetText(NEW_CAPS);
NewFeature.BGLabel:SetShadowColor(NEW_FEATURE_SHADOW_COLOR:GetRGBA())
NewFeature.BGLabel:SetTextColor(0.25,0.78,0.92,1 --[[NEW_FEATURE_SHADOW_COLOR:GetRGBA()]])
-- RAID_CLASS_COLORS.MAGE looks better on brighter backgrounds
NewFeature.BGLabel:SetPoint("CENTER",0.5,-0.5)
NewFeature.Label = NewFeature:CreateFontString(nil,"OVERLAY","GameFontHighlight",1);

NewFeature.Label = NewFeature:CreateFontString(nil,"OVERLAY","GameFontHighlight");
NewFeature.Label:SetDrawLayer("OVERLAY",1)
NewFeature.Label:SetMaxLines(1)
NewFeature.Label:SetJustifyH("CENTER")
NewFeature.Label:SetText(NEW_CAPS)
NewFeature.Label:SetShadowColor(NEW_FEATURE_SHADOW_COLOR:GetRGBA())
NewFeature.Label:SetTextColor(0.25,0.78,0.92,1 --[[NEW_FEATURE_SHADOW_COLOR:GetRGBA()]])
NewFeature.Label:SetPoint("CENTER")

NewFeature.Glow = NewFeature:CreateTexture(nil,"OVERLAY",nil,1)
NewFeature.Glow:SetPoint("TOPLEFT",NewFeature.Label,-20,10)
NewFeature.Glow:SetPoint("BOTTOMRIGHT",NewFeature.Label,20,-10)
NewFeature.Glow:SetAtlas("collections-newglow")
-- </Layer OVERLAY>
-- </Layers>

Expand All @@ -126,14 +139,14 @@ local function Create_NewFeature(parent)
A2:SetFromAlpha(0.5)
A2:SetToAlpha(1)
-- </Animations>
NewFeature.Fade:Play()

-- <Scripts>
NewFeature:SetScript("OnShow",NewFeature.OnShow);
--NewFeature:SetScript("OnLoad",NewFeature.OnLoad);
NewFeature:SetScript("OnHide",NewFeature.OnHide);
-- </Scripts>


return NewFeature
end

Expand Down Expand Up @@ -202,6 +215,14 @@ local function MenuButton_OnDisable(self)
self.invisibleButton:Show();
end

function Update_DropDownMenuButton(name)
local button = _G[name];
if not (button and button.NewFeature) then return end

button.NewFeature = Create_NewFeature(button,"FULLSCREEN_DIALOG",100,1,1,0.8,false);
button.NewFeature:SetPoint("LEFT", button.NormalText, "RIGHT", 20, 0);
end

function Create_DropDownMenuButton(name,parent,opts)
local button = CreateFrame("Button",name,parent);
button:SetSize(100,16);
Expand Down Expand Up @@ -291,12 +312,7 @@ function Create_DropDownMenuButton(name,parent,opts)
button.invisibleButton:SetScript("OnLeave",UIDropDownMenuButtonInvisibleButton_OnLeave);
-- </Button>
-- <Frame>
button.NewFeature = Create_NewFeature(button);
button.NewFeature:SetFrameStrata("HIGH");
button.NewFeature:SetScale(0.8);
button.NewFeature:SetFrameLevel(100);
button.NewFeature:SetSize(1,1);
button.NewFeature:Hide();
button.NewFeature = Create_NewFeature(button,"FULLSCREEN_DIALOG",100,1,1,0.8,false);
-- </Frame>
-- </Frames>

Expand Down Expand Up @@ -547,3 +563,9 @@ function Create_LargeDropDownMenu(name,parent)
return menu;
end

-- lua replacement of UIDropDownMenu.xml
if not _G.LibDropDownMenu_List1 then
for i=1, UIDROPDOWNMENU_MAXLEVELS, 1 do
Create_DropDownList("LibDropDownMenu_List"..i,nil,{id=i});
end
end

0 comments on commit 7b71288

Please sign in to comment.