This repository was archived by the owner on Apr 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWidgets.lua
More file actions
151 lines (137 loc) · 5.32 KB
/
Widgets.lua
File metadata and controls
151 lines (137 loc) · 5.32 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
local AceLocale = LibStub("AceLocale-3.0")
local L = AceLocale:GetLocale("Spy")
function Spy:CreateFrame(Name, Title, Height, Width, ShowFunc, HideFunc)
local theFrame = CreateFrame("Frame", Name, UIParent)
theFrame:ClearAllPoints()
theFrame:SetPoint("TOPLEFT", UIParent)
theFrame:SetHeight(Height)
theFrame:SetWidth(Width)
-- Select texture based on InvertSpy setting
local titleTexture = "Interface\\AddOns\\Spy\\Textures\\title-industrial.tga"
local backdropInsets = {left = 0, right = 0, top = 31, bottom = 0}
if Spy.db.profile.InvertSpy then
titleTexture = "Interface\\AddOns\\Spy\\Textures\\title-industrial2.tga"
backdropInsets = {left = 0, right = 0, top = 0, bottom = 31}
end
theFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
edgeFile = titleTexture, edgeSize = 32,
insets = backdropInsets,
})
if Name == "Spy_MainWindow" then
Spy.Colors:RegisterBorder("Window", "Title", theFrame)
Spy.Colors:RegisterBackground("Window", "Background", theFrame)
else
Spy.Colors:RegisterBorder("Other Windows", "Title", theFrame)
Spy.Colors:RegisterBackground("Other Windows", "Background", theFrame)
end
theFrame:EnableMouse(true)
theFrame:SetMovable(true)
theFrame:SetScript("OnMouseDown",
function()
if (((not this.isLocked) or (this.isLocked == 0)) and (arg1 == "LeftButton")) then
Spy:SetWindowTop(this)
this:StartMoving();
this.isMoving = true;
end
end)
theFrame:SetScript("OnMouseUp",
function()
if (this.isMoving) then
this:StopMovingOrSizing();
this.isMoving = false;
Spy:SaveMainWindowPosition()
end
end)
theFrame.ShowFunc = ShowFunc
theFrame:SetScript("OnShow",
function()
Spy:SetWindowTop(this)
if (this.ShowFunc) then
this:ShowFunc()
end
end)
theFrame.HideFunc = HideFunc
theFrame:SetScript("OnHide",
function()
if (this.isMoving) then
this:StopMovingOrSizing();
this.isMoving = false;
end
if (this.HideFunc) then
this:HideFunc()
end
end)
theFrame.Background = theFrame:CreateTexture(nil, "BACKGROUND")
theFrame.Background:ClearAllPoints()
theFrame.Background:SetTexture("Interface\\CHARACTERFRAME\\UI-Party-Background")
if not Spy.db.profile.InvertSpy then
theFrame.Background:SetPoint("TOPLEFT", theFrame, "TOPLEFT", 0, -32)
theFrame.Background:SetPoint("BOTTOMRIGHT", theFrame, "BOTTOMRIGHT", 0, 2)
theFrame.Background:SetHeight(Height)
else
-- Invert: Background goes ABOVE the frame (players are above)
theFrame.Background:SetPoint("BOTTOMLEFT", theFrame, "TOPLEFT", 0, 1)
theFrame.Background:SetPoint("BOTTOMRIGHT", theFrame, "TOPRIGHT", 0, 0)
theFrame.Background:SetHeight(1) -- Will be resized dynamically in List.lua
end
theFrame.Background:SetWidth(Width)
theFrame.Background:SetAlpha(1)
theFrame.TitleBar = CreateFrame("Frame", "TestFrame", theFrame)
theFrame.TitleBar:SetFrameStrata("BACKGROUND")
if not Spy.db.profile.InvertSpy then
theFrame.TitleBar:SetPoint("TOPLEFT", theFrame, "TOPLEFT", 0, -11)
theFrame.TitleBar:SetPoint("TOPRIGHT", theFrame, "TOPRIGHT", 0, -11)
else
theFrame.TitleBar:SetPoint("BOTTOMLEFT", theFrame, "BOTTOMLEFT", 0, 11)
theFrame.TitleBar:SetPoint("BOTTOMRIGHT", theFrame, "BOTTOMRIGHT", 0, 11)
end
theFrame.TitleBar:SetHeight(22)
theFrame.TitleBar:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 8,
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 12,
insets = {left = 2, right = 2, top = 2, bottom = 2},
})
theFrame.TitleBar:SetBackdropColor(0,0,0,1)
theFrame.TitleBar:SetBackdropBorderColor(1,1,1,1)
theFrame.Title = theFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
if not Spy.db.profile.InvertSpy then
theFrame.Title:SetPoint("TOPLEFT", theFrame, "TOPLEFT", 8, -18.25)
else
theFrame.Title:SetPoint("BOTTOMLEFT", theFrame, "BOTTOMLEFT", 8, 18.25)
end
theFrame.Title:SetJustifyH("LEFT")
theFrame.Title:SetTextColor(1.0, 1.0, 1.0, 1.0)
theFrame.Title:SetText(Title)
theFrame.Title:SetHeight(Spy.db.profile.MainWindow.TextHeight)
Spy:AddFontString(theFrame.Title)
if Name == "Spy_MainWindow" then
Spy.Colors:UnregisterItem(theFrame.Title)
Spy.Colors:RegisterFont("Window", "Title Text", theFrame.Title)
else
Spy.Colors:UnregisterItem(theFrame.Title)
Spy.Colors:RegisterFont("Other Windows", "Title Text", theFrame.Title)
end
theFrame.CloseButton = CreateFrame("Button", nil, theFrame)
theFrame.CloseButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up.blp")
theFrame.CloseButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down.blp")
theFrame.CloseButton:SetHighlightTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight.blp")
theFrame.CloseButton:SetWidth(20)
theFrame.CloseButton:SetHeight(20)
if not Spy.db.profile.InvertSpy then
theFrame.CloseButton:SetPoint("TOPRIGHT", theFrame, "TOPRIGHT", -4, -12)
else
theFrame.CloseButton:SetPoint("BOTTOMRIGHT", theFrame, "BOTTOMRIGHT", -4, 12)
end
theFrame.CloseButton:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Close"], 1, 0.82, 0, 1)
GameTooltip:AddLine(L["CloseDescription"],0,0,0,1)
GameTooltip:Show()
end)
theFrame.CloseButton:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
theFrame.CloseButton:SetScript("OnClick", function() this:GetParent():Hide() end)
return theFrame
end