-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.lua
83 lines (73 loc) · 3.04 KB
/
core.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- set language display
local _, addon = ...
local L = addon.L
-- Create a frame called "GetInfoFrame"
local GetInfoFrame = CreateFrame("Frame", "GetInfoFrame", UIParent);
GetInfoFrame:SetFrameStrata("DIALOG");
GetInfoFrame:SetSize(250, 150);
GetInfoFrame:SetPoint("CENTER");
GetInfoFrame:SetClampedToScreen(true);
GetInfoFrame:Hide();
-- Create GetInfoFrame title tags
local GetInfoFrameLabel = GetInfoFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge");
GetInfoFrameLabel:SetPoint("TOPLEFT", GetInfoFrame, "TOPLEFT", 0, -8);
GetInfoFrameLabel:SetPoint("TOPRIGHT", GetInfoFrame, "TOPRIGHT", 0, -8);
GetInfoFrameLabel:SetText(L['main_label_text']);
GetInfoFrameLabel:SetJustifyH("CENTER");
-- Create GetInfoFrame title background texture
-- local GetInfoFrameLabelBg = GetInfoFrame:CreateTexture(nil, "BACKGROUND");
-- GetInfoFrameLabelBg:SetTexture(136548) --"Interface\\PaperDollInfoFrame\\UI-Character-CharacterTab-L1"
-- GetInfoFrameLabelBg:SetPoint("TOPLEFT", GetInfoFrameLabel, "TOPLEFT", -6, 20);
-- GetInfoFrameLabelBg:SetPoint("BOTTOMRIGHT", GetInfoFrameLabel, "BOTTOMRIGHT", 20, -6);
-- GetInfoFrameLabelBg:SetTexCoord(0.255, 1, 0.29, 1)
-- Create GetInfoFrame close button
local CloseButton = CreateFrame("Button", "GetInfoFrameCloseButton", GetInfoFrame, "UIPanelCloseButton");
CloseButton:SetPoint("TOPRIGHT", GetInfoFrame, "TOPRIGHT", 0, 0);
-- Set the click event of the GetInfoFrame close button
CloseButton:SetScript("OnClick", function()
GetInfoFrame:Hide();
end)
-- Create GetInfoFrame background
local GetInfoFramebg = GetInfoFrame:CreateTexture(nil, "BACKGROUND")
GetInfoFramebg:SetTexture(136548) --"Interface\\PaperDollInfoFrame\\UI-Character-CharacterTab-L1"
GetInfoFramebg:SetPoint("TOPLEFT", 0, 0)
GetInfoFramebg:SetPoint("BOTTOMRIGHT", 0, 0)
GetInfoFramebg:SetTexCoord(0.255, 1, 0.29, 1)
-- Set the drag of Get Info Frame
GetInfoFrame:SetMovable(true);
GetInfoFrame:EnableMouse(true);
GetInfoFrame:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" then
self:StartMoving();
end
end);
GetInfoFrame:SetScript("OnMouseUp", function(self, button)
self:StopMovingOrSizing();
end);
-- Show usage instructions in the chat box
local function ShowUsage()
print(L['usage_text']);
end
-- Create a minimap button
local miniButton = LibStub("LibDataBroker-1.1"):NewDataObject("GetInfoLinkButton", {
type = "data source",
text = "Get Info Link",
icon = "Interface/AddOns/GetInfoLink/Icon/getinfolink",
OnClick = function(self, btn)
if GetInfoFrame:IsVisible() then
GetInfoFrame:Hide();
else
GetInfoFrame:Show();
ShowUsage();
end
end,
OnTooltipShow = function(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:AddLine(L['mini_button_text']);
tooltip:AddLine(L['mini_button_click']);
end,
})
local icon = LibStub("LibDBIcon-1.0", true)
icon:Register("GetInfoLinkButton", miniButton, {
minimapPos = 220,
})