This commit is contained in:
Bunny67
2017-12-18 08:11:54 +03:00
parent 632349e6f0
commit ab0bcb8e91
5 changed files with 286 additions and 133 deletions
@@ -23,8 +23,8 @@ local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end if not lib then return end
-- ////////////////////////////////////////////////////////////// -- //////////////////////////////////////////////////////////////
L_UIDROPDOWNMENU_MINBUTTONS = 8; L_UIDROPDOWNMENU_MINBUTTONS = 32;
L_UIDROPDOWNMENU_MAXBUTTONS = 8; L_UIDROPDOWNMENU_MAXBUTTONS = 32;
L_UIDROPDOWNMENU_MAXLEVELS = 2; L_UIDROPDOWNMENU_MAXLEVELS = 2;
L_UIDROPDOWNMENU_BUTTON_HEIGHT = 16; L_UIDROPDOWNMENU_BUTTON_HEIGHT = 16;
L_UIDROPDOWNMENU_BORDER_HEIGHT = 15; L_UIDROPDOWNMENU_BORDER_HEIGHT = 15;
@@ -171,7 +171,6 @@ info.text = [STRING] -- The text of the button
info.value = [ANYTHING] -- The value that L_UIDROPDOWNMENU_MENU_VALUE is set to when the button is clicked info.value = [ANYTHING] -- The value that L_UIDROPDOWNMENU_MENU_VALUE is set to when the button is clicked
info.func = [function()] -- The function that is called when you click the button info.func = [function()] -- The function that is called when you click the button
info.checked = [nil, true, function] -- Check the button if true or function returns true info.checked = [nil, true, function] -- Check the button if true or function returns true
info.isNotRadio = [nil, true] -- Check the button uses radial image if false check box image if true
info.isTitle = [nil, true] -- If it's a title the button is disabled and the font color is set to yellow info.isTitle = [nil, true] -- If it's a title the button is disabled and the font color is set to yellow
info.disabled = [nil, true] -- Disable the button and show an invisible button that still traps the mouseover event so menu doesn't time out info.disabled = [nil, true] -- Disable the button and show an invisible button that still traps the mouseover event so menu doesn't time out
info.tooltipWhileDisabled = [nil, 1] -- Show the tooltip, even when the button is disabled. info.tooltipWhileDisabled = [nil, 1] -- Show the tooltip, even when the button is disabled.
@@ -196,7 +195,6 @@ info.tooltipOnButton = [nil, 1] -- Show the tooltip attached to the button inste
info.justifyH = [nil, "CENTER"] -- Justify button text info.justifyH = [nil, "CENTER"] -- Justify button text
info.arg1 = [ANYTHING] -- This is the first argument used by info.func info.arg1 = [ANYTHING] -- This is the first argument used by info.func
info.arg2 = [ANYTHING] -- This is the second argument used by info.func info.arg2 = [ANYTHING] -- This is the second argument used by info.func
info.fontObject = [FONT] -- font object replacement for Normal and Highlight
info.menuTable = [TABLE] -- This contains an array of info tables to be displayed as a child menu info.menuTable = [TABLE] -- This contains an array of info tables to be displayed as a child menu
info.noClickSound = [nil, 1] -- Set to 1 to suppress the sound when clicking the button. The sound only plays if .func is set. info.noClickSound = [nil, 1] -- Set to 1 to suppress the sound when clicking the button. The sound only plays if .func is set.
info.padding = [nil, NUMBER] -- Number of pixels to pad the text on the right side info.padding = [nil, NUMBER] -- Number of pixels to pad the text on the right side
@@ -312,20 +310,20 @@ function L_UIDropDownMenu_AddButton(info, level)
local invisibleButton = _G[button:GetName().."InvisibleButton"]; local invisibleButton = _G[button:GetName().."InvisibleButton"];
-- Default settings -- Default settings
button:SetDisabledFontObject(GameFontDisableSmallLeft); button:SetDisabledTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
invisibleButton:Hide(); invisibleButton:Hide();
button:Enable(); button:Enable();
-- If not clickable then disable the button and set it white -- If not clickable then disable the button and set it white
if ( info.notClickable ) then if ( info.notClickable ) then
info.disabled = true; info.disabled = true;
button:SetDisabledFontObject(GameFontHighlightSmallLeft); button:SetDisabledTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
end end
-- Set the text color and disable it if its a title -- Set the text color and disable it if its a title
if ( info.isTitle ) then if ( info.isTitle ) then
info.disabled = true; info.disabled = true;
button:SetDisabledFontObject(GameFontNormalSmallLeft); button:SetDisabledTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
end end
-- Disable the button if disabled and turn off the color code -- Disable the button if disabled and turn off the color code
@@ -351,11 +349,7 @@ function L_UIDropDownMenu_AddButton(info, level)
-- Set icon -- Set icon
if ( info.icon ) then if ( info.icon ) then
icon:SetSize(16,16);
icon:SetTexture(info.icon); icon:SetTexture(info.icon);
icon:ClearAllPoints();
icon:SetPoint("RIGHT");
if ( info.tCoordLeft ) then if ( info.tCoordLeft ) then
icon:SetTexCoord(info.tCoordLeft, info.tCoordRight, info.tCoordTop, info.tCoordBottom); icon:SetTexCoord(info.tCoordLeft, info.tCoordRight, info.tCoordTop, info.tCoordBottom);
else else
@@ -365,15 +359,6 @@ function L_UIDropDownMenu_AddButton(info, level)
else else
icon:Hide(); icon:Hide();
end end
-- Check to see if there is a replacement font
if ( info.fontObject ) then
button:SetNormalFontObject(info.fontObject);
button:SetHighlightFontObject(info.fontObject);
else
--button:SetNormalFontObject(STANDARD_TEXT_FONT);
--button:SetHighlightFontObject(STANDARD_TEXT_FONT);
end
else else
button:SetText(""); button:SetText("");
icon:Hide(); icon:Hide();
@@ -496,21 +481,9 @@ function L_UIDropDownMenu_AddButton(info, level)
if ( info.disabled ) then if ( info.disabled ) then
_G[listFrameName.."Button"..index.."Check"]:SetDesaturated(true); _G[listFrameName.."Button"..index.."Check"]:SetDesaturated(true);
_G[listFrameName.."Button"..index.."Check"]:SetAlpha(0.5); _G[listFrameName.."Button"..index.."Check"]:SetAlpha(0.5);
_G[listFrameName.."Button"..index.."UnCheck"]:SetDesaturated(true);
_G[listFrameName.."Button"..index.."UnCheck"]:SetAlpha(0.5);
else else
_G[listFrameName.."Button"..index.."Check"]:SetDesaturated(false); _G[listFrameName.."Button"..index.."Check"]:SetDesaturated(false);
_G[listFrameName.."Button"..index.."Check"]:SetAlpha(1); _G[listFrameName.."Button"..index.."Check"]:SetAlpha(1);
_G[listFrameName.."Button"..index.."UnCheck"]:SetDesaturated(false);
_G[listFrameName.."Button"..index.."UnCheck"]:SetAlpha(1);
end
if info.isNotRadio then
_G[listFrameName.."Button"..index.."Check"]:SetTexCoord(0.0, 0.5, 0.0, 0.5);
_G[listFrameName.."Button"..index.."UnCheck"]:SetTexCoord(0.5, 1.0, 0.0, 0.5);
else
_G[listFrameName.."Button"..index.."Check"]:SetTexCoord(0.0, 0.5, 0.5, 1.0);
_G[listFrameName.."Button"..index.."UnCheck"]:SetTexCoord(0.5, 1.0, 0.5, 1.0);
end end
-- Checked can be a function now -- Checked can be a function now
@@ -523,15 +496,12 @@ function L_UIDropDownMenu_AddButton(info, level)
if ( checked ) then if ( checked ) then
button:LockHighlight(); button:LockHighlight();
_G[listFrameName.."Button"..index.."Check"]:Show(); _G[listFrameName.."Button"..index.."Check"]:Show();
_G[listFrameName.."Button"..index.."UnCheck"]:Hide();
else else
button:UnlockHighlight(); button:UnlockHighlight();
_G[listFrameName.."Button"..index.."Check"]:Hide(); _G[listFrameName.."Button"..index.."Check"]:Hide();
_G[listFrameName.."Button"..index.."UnCheck"]:Show();
end end
else else
_G[listFrameName.."Button"..index.."Check"]:Hide(); _G[listFrameName.."Button"..index.."Check"]:Hide();
_G[listFrameName.."Button"..index.."UnCheck"]:Hide();
end end
button.checked = info.checked; button.checked = info.checked;
@@ -607,7 +577,7 @@ function L_UIDropDownMenu_GetButtonWidth(button)
end end
function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel)
local button, checked, checkImage, uncheckImage, normalText, width; local button, checked, checkImage, normalText, width;
local maxWidth = 0; local maxWidth = 0;
local somethingChecked = nil; local somethingChecked = nil;
if ( not dropdownLevel ) then if ( not dropdownLevel ) then
@@ -644,7 +614,6 @@ function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel)
if not button.notCheckable and button:IsShown() then if not button.notCheckable and button:IsShown() then
-- If checked show check image -- If checked show check image
checkImage = _G["L_DropDownList"..dropdownLevel.."Button"..i.."Check"]; checkImage = _G["L_DropDownList"..dropdownLevel.."Button"..i.."Check"];
uncheckImage = _G["L_DropDownList"..dropdownLevel.."Button"..i.."UnCheck"];
if ( checked ) then if ( checked ) then
somethingChecked = true; somethingChecked = true;
local icon = _G[frame:GetName().."Icon"]; local icon = _G[frame:GetName().."Icon"];
@@ -659,11 +628,9 @@ function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel)
end end
button:LockHighlight(); button:LockHighlight();
checkImage:Show(); checkImage:Show();
uncheckImage:Hide();
else else
button:UnlockHighlight(); button:UnlockHighlight();
checkImage:Hide(); checkImage:Hide();
uncheckImage:Show();
end end
end end
@@ -769,48 +736,46 @@ function L_UIDropDownMenu_GetSelectedValue(frame)
return frame.selectedValue; return frame.selectedValue;
end end
function L_UIDropDownMenuButton_OnClick(self) function L_UIDropDownMenuButton_OnClick()
local checked = self.checked; local checked = this.checked;
if ( type (checked) == "function" ) then if ( type (checked) == "function" ) then
checked = checked(self); checked = checked(this);
end end
if ( self.keepShownOnClick ) then if ( this.keepShownOnClick ) then
if not self.notCheckable then if not this.notCheckable then
if ( checked ) then if ( checked ) then
_G[self:GetName().."Check"]:Hide(); _G[this:GetName().."Check"]:Hide();
_G[self:GetName().."UnCheck"]:Show();
checked = false; checked = false;
else else
_G[self:GetName().."Check"]:Show(); _G[this:GetName().."Check"]:Show();
_G[self:GetName().."UnCheck"]:Hide();
checked = true; checked = true;
end end
end end
else else
self:GetParent():Hide(); this:GetParent():Hide();
end end
if ( type (self.checked) ~= "function" ) then if ( type (this.checked) ~= "function" ) then
self.checked = checked; this.checked = checked;
end end
-- saving this here because func might use a dropdown, changing this self's attributes -- saving this here because func might use a dropdown, changing this self's attributes
local playSound = true; local playSound = true;
if ( self.noClickSound ) then if ( this.noClickSound ) then
playSound = false; playSound = false;
end end
local func = self.func; local func = this.func;
if ( func ) then if ( func ) then
func(self, self.arg1, self.arg2, checked); func(this.arg1, this.arg2, checked);
else else
return; return;
end end
if ( playSound ) then if ( playSound ) then
PlaySound(PlaySoundKitID and "UChatScrollButton" or SOUNDKIT.U_CHAT_SCROLL_BUTTON); PlaySound("UChatScrollButton");
end end
end end
@@ -823,6 +788,7 @@ function L_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset,
if ( not level ) then if ( not level ) then
level = 1; level = 1;
end end
--UIDropDownMenuDelegate:SetAttribute("createframes-level", level); --UIDropDownMenuDelegate:SetAttribute("createframes-level", level);
--UIDropDownMenuDelegate:SetAttribute("createframes-index", 0); --UIDropDownMenuDelegate:SetAttribute("createframes-index", 0);
--UIDropDownMenuDelegate:SetAttribute("createframes", true); --UIDropDownMenuDelegate:SetAttribute("createframes", true);
@@ -862,7 +828,7 @@ function L_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset,
-- Display stuff -- Display stuff
-- Level specific stuff -- Level specific stuff
if ( level == 1 ) then if ( level == 1 ) then
--UIDropDownMenuDelegate:SetAttribute("openmenu", dropDownFrame); L_UIDROPDOWNMENU_OPEN_MENU = dropDownFrame;
listFrame:ClearAllPoints(); listFrame:ClearAllPoints();
-- If there's no specified anchorName then use left side of the dropdown menu -- If there's no specified anchorName then use left side of the dropdown menu
if ( not anchorName ) then if ( not anchorName ) then
@@ -1107,15 +1073,13 @@ function L_UIDropDownMenu_ClearAll(frame)
frame.selectedValue = nil; frame.selectedValue = nil;
L_UIDropDownMenu_SetText(frame, ""); L_UIDropDownMenu_SetText(frame, "");
local button, checkImage, uncheckImage; local button, checkImage;
for i=1, L_UIDROPDOWNMENU_MAXBUTTONS do for i=1, L_UIDROPDOWNMENU_MAXBUTTONS do
button = _G["L_DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL.."Button"..i]; button = _G["L_DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL.."Button"..i];
button:UnlockHighlight(); button:UnlockHighlight();
checkImage = _G["L_DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL.."Button"..i.."Check"]; checkImage = _G["L_DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL.."Button"..i.."Check"];
checkImage:Hide(); checkImage:Hide();
uncheckImage = _G["L_DropDownList"..L_UIDROPDOWNMENU_MENU_LEVEL.."Button"..i.."UnCheck"];
uncheckImage:Hide();
end end
end end
@@ -2,37 +2,35 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd"> ..\FrameXML\UI.xsd">
<Button name="L_UIDropDownMenuButtonTemplate" virtual="true"> <Button name="L_UIDropDownMenuButtonTemplate" virtual="true">
<Size x="100" y="16"/> <Size>
<AbsDimension x="128" y="16"/>
</Size>
<Layers> <Layers>
<Layer level="BACKGROUND"> <Layer level="BACKGROUND">
<Texture name="$parentHighlight" file="Interface\QuestFrame\UI-QuestTitleHighlight" alphaMode="ADD" setAllPoints="true" hidden="true"/> <Texture name="$parentHighlight" file="Interface\QuestFrame\UI-QuestTitleHighlight" alphaMode="ADD" setAllPoints="true" hidden="true"/>
</Layer> </Layer>
<Layer level="ARTWORK"> <Layer level="ARTWORK">
<Texture name="$parentCheck" file="Interface\Buttons\UI-CheckBox-Check"> <Texture name="$parentCheck" file="Interface\Buttons\UI-CheckBox-Check">
<Size x="16" y="16"/> <Size>
<AbsDimension x="24" y="24"/>
</Size>
<Anchors> <Anchors>
<Anchor point="LEFT"> <Anchor point="LEFT">
<Offset x="0" y="0"/> <Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor> </Anchor>
</Anchors> </Anchors>
<TexCoords left="0" right="0.5" top="0.5" bottom="1.0"/>
</Texture>
<Texture name="$parentUnCheck" file="Interface\Buttons\UI-CheckBox-Check">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="LEFT">
<Offset x="0" y="0"/>
</Anchor>
</Anchors>
<TexCoords left="0.5" right="1.0" top="0.5" bottom="1.0"/>
</Texture> </Texture>
<Texture name="$parentIcon" hidden="true"> <Texture name="$parentIcon" hidden="true">
<Size> <Size>
<AbsDimension x="16" y="16"/> <AbsDimension x="15" y="15"/>
</Size> </Size>
<Anchors> <Anchors>
<Anchor point="RIGHT"> <Anchor point="RIGHT">
<Offset x="0" y="0"/> <Offset>
<AbsDimension x="-5" y="0"/>
</Offset>
</Anchor> </Anchor>
</Anchors> </Anchors>
</Texture> </Texture>
@@ -69,17 +67,17 @@
</Layers> </Layers>
<Scripts> <Scripts>
<OnClick> <OnClick>
securecall("CloseMenus"); CloseMenus()
L_UIDropDownMenuButton_OpenColorPicker(this:GetParent()); L_UIDropDownMenuButton_OpenColorPicker(this:GetParent())
</OnClick> </OnClick>
<OnEnter> <OnEnter>
L_CloseDropDownMenus(this:GetParent():GetParent():GetID() + 1); L_CloseDropDownMenus(this:GetParent():GetParent():GetID() + 1)
getglobal(this:GetName().."SwatchBg"):SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); getglobal(this:GetName().."SwatchBg"):SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
L_UIDropDownMenu_StopCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StopCounting(this:GetParent():GetParent())
</OnEnter> </OnEnter>
<OnLeave> <OnLeave>
getglobal(this:GetName().."SwatchBg"):SetVertexColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); getglobal(this:GetName().."SwatchBg"):SetVertexColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
L_UIDropDownMenu_StartCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StartCounting(this:GetParent():GetParent())
</OnLeave> </OnLeave>
</Scripts> </Scripts>
<NormalTexture name="$parentNormalTexture" file="Interface\ChatFrame\ChatFrameColorSwatch"/> <NormalTexture name="$parentNormalTexture" file="Interface\ChatFrame\ChatFrameColorSwatch"/>
@@ -97,23 +95,23 @@
</Anchors> </Anchors>
<Scripts> <Scripts>
<OnClick> <OnClick>
L_ToggleDropDownMenu(this:GetParent():GetParent():GetID() + 1, this:GetParent().value, nil, nil, nil, nil, this:GetParent().menuList, this); L_ToggleDropDownMenu(this:GetParent():GetParent():GetID() + 1, this:GetParent().value, nil, nil, nil, nil, this:GetParent().menuList, this)
</OnClick> </OnClick>
<OnEnter> <OnEnter>
local level = this:GetParent():GetParent():GetID() + 1; local level = this:GetParent():GetParent():GetID() + 1
local listFrame = getglobal("L_DropDownList"..level); local listFrame = getglobal("L_DropDownList"..level)
if ( not listFrame or not listFrame:IsShown() or select(2, listFrame:GetPoint()) ~= this ) then if not listFrame or not listFrame:IsShown() or select(2, listFrame:GetPoint()) ~= this then
L_ToggleDropDownMenu(level, this:GetParent().value, nil, nil, nil, nil, this:GetParent().menuList, this); L_ToggleDropDownMenu(level, this:GetParent().value, nil, nil, nil, nil, this:GetParent().menuList, this)
end end
L_UIDropDownMenu_StopCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StopCounting(this:GetParent():GetParent())
</OnEnter> </OnEnter>
<OnLeave> <OnLeave>
L_UIDropDownMenu_StartCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StartCounting(this:GetParent():GetParent())
</OnLeave> </OnLeave>
</Scripts> </Scripts>
<NormalTexture file="Interface\ChatFrame\ChatFrameExpandArrow"/> <NormalTexture file="Interface\ChatFrame\ChatFrameExpandArrow"/>
</Button> </Button>
<Button name="$parentInvisibleButton" hidden="true" parentKey="invisibleButton"> <Button name="$parentInvisibleButton" hidden="true">
<Anchors> <Anchors>
<Anchor point="TOPLEFT"/> <Anchor point="TOPLEFT"/>
<Anchor point="BOTTOMLEFT"/> <Anchor point="BOTTOMLEFT"/>
@@ -125,76 +123,64 @@
</Anchors> </Anchors>
<Scripts> <Scripts>
<OnEnter> <OnEnter>
L_UIDropDownMenu_StopCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StopCounting(this:GetParent():GetParent())
L_CloseDropDownMenus(this:GetParent():GetParent():GetID() + 1); L_CloseDropDownMenus(this:GetParent():GetParent():GetID() + 1)
local parent = this:GetParent(); local parent = this:GetParent();
if ( parent.tooltipTitle and parent.tooltipWhileDisabled) then if parent.tooltipTitle and parent.tooltipWhileDisabled then
if ( parent.tooltipOnButton ) then if parent.tooltipOnButton then
GameTooltip:SetOwner(parent, "ANCHOR_RIGHT"); GameTooltip:SetOwner(parent, "ANCHOR_RIGHT")
GameTooltip:AddLine(parent.tooltipTitle, 1.0, 1.0, 1.0); GameTooltip:AddLine(parent.tooltipTitle, 1.0, 1.0, 1.0)
GameTooltip:AddLine(parent.tooltipText, nil, nil, nil, true); GameTooltip:AddLine(parent.tooltipText, nil, nil, nil, true)
GameTooltip:Show(); GameTooltip:Show()
else else
GameTooltip_AddNewbieTip(parent, parent.tooltipTitle, 1.0, 1.0, 1.0, parent.tooltipText, 1); GameTooltip_AddNewbieTip(parent, parent.tooltipTitle, 1.0, 1.0, 1.0, parent.tooltipText, 1)
end end
end end
</OnEnter> </OnEnter>
<OnLeave> <OnLeave>
L_UIDropDownMenu_StartCounting(this:GetParent():GetParent()); L_UIDropDownMenu_StartCounting(this:GetParent():GetParent())
GameTooltip:Hide(); GameTooltip:Hide()
</OnLeave> </OnLeave>
</Scripts> </Scripts>
</Button> </Button>
</Frames> </Frames>
<Scripts> <Scripts>
<OnLoad> <OnLoad>
this:SetFrameLevel(this:GetParent():GetFrameLevel()+2); this:SetFrameLevel(this:GetParent():GetFrameLevel()+2)
</OnLoad> </OnLoad>
<OnClick> <OnClick>
L_UIDropDownMenuButton_OnClick(this, arg1, arg2); L_UIDropDownMenuButton_OnClick(this, arg1, arg2)
</OnClick> </OnClick>
<OnEnter> <OnEnter>
if ( this.hasArrow ) then if this.hasArrow then
local level = this:GetParent():GetID() + 1; local level = this:GetParent():GetID() + 1
local listFrame = getglobal("L_DropDownList"..level); local listFrame = getglobal("L_DropDownList"..level)
if ( not listFrame or not listFrame:IsShown() or select(2, listFrame:GetPoint()) ~= this ) then if not listFrame or not listFrame:IsShown() or select(2, listFrame:GetPoint()) ~= this then
L_ToggleDropDownMenu(this:GetParent():GetID() + 1, this.value, nil, nil, nil, nil, this.menuList, this); L_ToggleDropDownMenu(this:GetParent():GetID() + 1, this.value, nil, nil, nil, nil, this.menuList, this)
end end
else else
L_CloseDropDownMenus(this:GetParent():GetID() + 1); L_CloseDropDownMenus(this:GetParent():GetID() + 1)
end end
getglobal(this:GetName().."Highlight"):Show(); getglobal(this:GetName().."Highlight"):Show()
L_UIDropDownMenu_StopCounting(this:GetParent()); L_UIDropDownMenu_StopCounting(this:GetParent())
if ( this.tooltipTitle ) then if this.tooltipTitle then
if ( this.tooltipOnButton ) then if this.tooltipOnButton then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(this.tooltipTitle, 1.0, 1.0, 1.0); GameTooltip:AddLine(this.tooltipTitle, 1.0, 1.0, 1.0)
GameTooltip:AddLine(this.tooltipText, nil, nil, nil, true); GameTooltip:AddLine(this.tooltipText, nil, nil, nil, true)
GameTooltip:Show(); GameTooltip:Show()
else else
GameTooltip_AddNewbieTip(this, this.tooltipTitle, 1.0, 1.0, 1.0, this.tooltipText, 1); GameTooltip_AddNewbieTip(this, this.tooltipTitle, 1.0, 1.0, 1.0, this.tooltipText, 1)
end end
end end
</OnEnter> </OnEnter>
<OnLeave> <OnLeave>
getglobal(this:GetName().."Highlight"):Hide(); getglobal(this:GetName().."Highlight"):Hide()
L_UIDropDownMenu_StartCounting(this:GetParent()); L_UIDropDownMenu_StartCounting(this:GetParent())
GameTooltip:Hide(); GameTooltip:Hide()
</OnLeave> </OnLeave>
<OnEnable>
this.invisibleButton:Hide();
</OnEnable>
<OnDisable>
this.invisibleButton:Show();
</OnDisable>
</Scripts> </Scripts>
<ButtonText name="$parentNormalText"> <ButtonText name="$parentNormalText"/>
<Anchors>
<Anchor point="LEFT">
<Offset x="-5" y="0"/>
</Anchor>
</Anchors>
</ButtonText>
<NormalFont inherits="GameFontHighlightSmall" justifyH="LEFT"/> <NormalFont inherits="GameFontHighlightSmall" justifyH="LEFT"/>
<HighlightFont inherits="GameFontHighlightSmall" justifyH="LEFT"/> <HighlightFont inherits="GameFontHighlightSmall" justifyH="LEFT"/>
<DisabledFont inherits="GameFontDisableSmall" justifyH="LEFT"/> <DisabledFont inherits="GameFontDisableSmall" justifyH="LEFT"/>
@@ -186,6 +186,10 @@ function DT:AssignPanelToDataText(panel, data)
if data["events"] then if data["events"] then
for _, event in pairs(data["events"]) do for _, event in pairs(data["events"]) do
-- random error 132
if event == "PLAYER_ENTERING_WORLD" then
event = "PLAYER_LOGIN"
end
panel:RegisterEvent(event) panel:RegisterEvent(event)
end end
end end
@@ -0,0 +1,198 @@
local E, L, V, P, G = unpack(ElvUI)
local DT = E:GetModule("DataTexts")
local type, pairs, select = type, pairs, select
local sort, wipe = table.sort, wipe
local format, find, join, gsub = string.format, string.find, string.join, string.gsub
local UnitIsAFK = UnitIsAFK
local UnitIsDND = UnitIsDND
local SendChatMessage = SendChatMessage
local InviteUnit = InviteUnit
local SetItemRef = SetItemRef
local GetFriendInfo = GetFriendInfo
local GetNumFriends = GetNumFriends
local GetQuestDifficultyColor = GetQuestDifficultyColor
local UnitInParty = UnitInParty
local UnitInRaid = UnitInRaid
local ToggleFriendsFrame = ToggleFriendsFrame
local L_EasyMenu = L_EasyMenu
local AFK = AFK
local DND = DND
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
local LOCALIZED_CLASS_NAMES_FEMALE = LOCALIZED_CLASS_NAMES_FEMALE
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local function GetNumberFriends()
local numFriends = GetNumFriends()
local onlineFriends = 0
local _, online
for i = 1, numFriends do
_, _, _, _, online = GetFriendInfo(i)
if online then
onlineFriends = onlineFriends + 1
end
end
return numFriends, onlineFriends
end
local menuFrame = CreateFrame("Frame", "FriendDatatextRightClickMenu", E.UIParent, "L_UIDropDownMenuTemplate")
local menuList = {
{text = "OPTIONS_MENU", isTitle = true, notCheckable = true},
{text = "INVITE", hasArrow = true, notCheckable = true},
{text = "CHAT_MSG_WHISPER_INFORM", hasArrow = true, notCheckable= true},
{text = "PLAYER_STATUS", hasArrow = true, notCheckable = true,
menuList = {
{text = "|cff2BC226" .. "AVAILABLE" .. "|r", notCheckable = true, func = function() end},
{text = "|cffE7E716" .. "AFK" .. "|r", notCheckable = true, func = function() end},
{text = "|cffFF0000" .. "DND" .. "|r", notCheckable = true, func = function() end}
}
}
}
local function inviteClick(name)
menuFrame:Hide()
if(type(name) ~= "number") then
InviteUnit(name)
end
end
local function whisperClick(name)
menuFrame:Hide()
SetItemRef("player:" .. name, format("|Hplayer:%1$s|h[%1$s]|h", name), "LeftButton")
end
local lastPanel
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s"
local worldOfWarcraftString = WORLD_OF_WARCRAFT
local totalOnlineString = join("", GUILD_ONLINE_LABEL, ": %s/%s")
local tthead = {r = 0.4, g = 0.78, b = 1}
local activezone, inactivezone = {r = 0.3, g = 1.0, b = 0.3}, {r = 0.65, g = 0.65, b = 0.65}
local displayString = ""
local groupedTable = {"|cffaaaaaa*|r", ""}
local friendTable = {}
local friendOnline, friendOffline = gsub(ERR_FRIEND_ONLINE_SS, "\124Hplayer:%%s\124h%[%%s%]\124h", ""), gsub(ERR_FRIEND_OFFLINE_S, "%%s", "")
local dataValid = false
local function SortAlphabeticName(a, b)
if(a[1] and b[1]) then
return a[1] < b[1]
end
end
local function BuildFriendTable(total)
wipe(friendTable)
local name, level, class, area, connected, status, note
for i = 1, total do
name, level, class, area, connected, status, note = GetFriendInfo(i)
if status == "<" .. "AFK" .. ">" then
status = "|cffFFFFFF[|r|cffFF0000" .. L["AFK"] .. "|r|cffFFFFFF]|r"
elseif status == "<" .. "DND" .. ">" then
status = "|cffFFFFFF[|r|cffFF0000" .. L["DND"] .. "|r|cffFFFFFF]|r"
end
if(connected) then
for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if(class == v) then class = k end end
for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if(class == v) then class = k end end
friendTable[i] = {name, level, class, area, connected, status, note}
end
end
sort(friendTable, SortAlphabeticName)
end
local function OnEvent(self, event, ...)
local _, onlineFriends = GetNumberFriends()
if event == "CHAT_MSG_SYSTEM" then
local message = arg1
if not (find(message, friendOnline) or find(message, friendOffline)) then return end
end
dataValid = false
self.text:SetText(format(displayString, L["Friends"], onlineFriends))
lastPanel = self
end
local function OnClick(_, btn)
DT.tooltip:Hide()
if btn == "RightButton" then
local menuCountWhispers = 0
local menuCountInvites = 0
local classc, levelc, info
menuList[2].menuList = {}
menuList[3].menuList = {}
if getn(friendTable) > 0 then
for i = 1, getn(friendTable) do
info = friendTable[i]
if (info[5]) then
menuCountInvites = menuCountInvites + 1
menuCountWhispers = menuCountWhispers + 1
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
classc = classc or GetQuestDifficultyColor(info[2])
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[2],classc.r*255,classc.g*255,classc.b*255, info[1]), arg1 = info[1], notCheckable = true, func = inviteClick}
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[2],classc.r*255,classc.g*255,classc.b*255, info[1]), arg1 = info[1], notCheckable = true, func = whisperClick}
end
end
end
L_EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
else
ToggleFriendsFrame(1)
end
end
local function OnEnter(self)
DT:SetupTooltip(self)
local numberOfFriends, onlineFriends = GetNumberFriends()
if onlineFriends == 0 then return end
if not dataValid then
if numberOfFriends > 0 then BuildFriendTable(numberOfFriends) end
dataValid = true
end
local zonec, classc, levelc, info
DT.tooltip:AddDoubleLine(L["Friends List"], format(totalOnlineString, onlineFriends, numberOfFriends), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
if onlineFriends > 0 then
DT.tooltip:AddLine(" ")
DT.tooltip:AddLine(worldOfWarcraftString)
for i = 1, getn(friendTable) do
info = friendTable[i]
if info[5] then
if(GetRealZoneText() == info[4]) then zonec = activezone else zonec = inactivezone end
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
classc = classc or GetQuestDifficultyColor(info[2])
DT.tooltip:AddDoubleLine(format(levelNameClassString, levelc.r*255,levelc.g*255,levelc.b*255, info[2], info[1], " " .. info[6]), info[4], classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
end
end
end
DT.tooltip:Show()
end
local function ValueColorUpdate(hex)
displayString = join("", "%s: ", hex, "%d|r")
if lastPanel ~= nil then
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
end
end
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
DT:RegisterDatatext("Friends", {"PLAYER_LOGIN", "FRIENDLIST_UPDATE", "CHAT_MSG_SYSTEM"}, OnEvent, nil, OnClick, OnEnter, nil, L["Friends"])
@@ -3,6 +3,7 @@
<Script file="Armor.lua"/> <Script file="Armor.lua"/>
<Script file="Avoidance.lua"/> <Script file="Avoidance.lua"/>
<Script file="Durability.lua"/> <Script file="Durability.lua"/>
<Script file="Friends.lua"/>
<Script file="Gold.lua"/> <Script file="Gold.lua"/>
<Script file="Guild.lua"/> <Script file="Guild.lua"/>
<Script file="System.lua"/> <Script file="System.lua"/>