-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.lua.bak
117 lines (104 loc) · 2.86 KB
/
config.lua.bak
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
local frame = CreateFrame("Frame", "ConfigFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
local fsTitle = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
local box = CreateFrame("EditBox", "EditBoxWidth", frame, "InputBoxTemplate")
local b = CreateFrame("Button", "ButtonClose", frame, "UIPanelButtonTemplate")
local s = CreateFrame("Slider", "SliderWidth", frame, "OptionsSliderTemplate")
local currentWidth = 60
-- function that sets friendly nameplates
function SetFriendlyNameplates(newWidth)
C_NamePlate.SetNamePlateFriendlySize(newWidth, 64.125)
end
-- function to open config interface menu
SLASH_CONFIG1 = "/tfp"
SlashCmdList["CONFIG"] = function(msg)
s:SetValue(currentWidth)
box:SetText(currentWidth)
frame:Show()
end
-- main frame
frame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Glues\\Common\\TextPanel-Border",
tile = true,
tileEdge = true,
tileSize = 32,
edgeSize = 32,
insets = { left = 8, right = 4, top = 4, bottom = 8 },
})
frame:SetWidth(200)
frame:SetHeight(150)
frame:SetPoint("CENTER",0,0)
-- title
frame.text = fsTitle
frame.text:SetPoint("TOP",0,16)
frame.text:SetText("TinyFriendlyPlates")
-- slider
s:SetWidth(144)
s:SetHeight(17)
s:SetOrientation("HORIZONTAL")
s:SetPoint("TOP",0,-16)
s:SetMinMaxValues(40,154)
s:SetValueStep(1)
s:SetValue(60)
s:SetObeyStepOnDrag(1)
s:SetScript("OnValueChanged", function(self,value)
local result = floor(value/1) * 1
box:SetText(result)
currentWidth = result
SetFriendlyNameplates(result)
end)
-- edit box
box:SetSize(30,17)
box:SetPoint("CENTER")
box:SetAutoFocus(false)
box:SetMaxLetters(3)
box:SetText("60")
box:SetScript("OnEscapePressed", function()
box:ClearFocus()
end)
box:SetScript("OnEnterPressed", function()
local width = box:GetNumber()
if(width >= 40 and width <= 154)
then
s:SetValue(width)
SetFriendlyNameplates(width)
else
box:SetText(currentWidth)
end
box:ClearFocus()
end)
-- close button
b:SetSize(80 ,22)
b:SetText("Close")
b:SetPoint("BOTTOM",0,16)
b:SetScript("OnClick", function()
TinyNameplatesWidth = currentWidth
frame:Hide()
end)
-- on login
frame:RegisterEvent("PLAYER_LOGIN")
-- on addon loaded
frame:RegisterEvent("ADDON_LOADED")
-- on logout
frame:RegisterEvent("PLAYER_LOGOUT")
function frame:OnEvent(event, arg1)
-- print(C_NamePlate.GetNamePlateFriendlySize())
-- SetFriendlyNameplates(154.00001525879, 64.125) -- default nameplate size
if event == "ADDON_LOADED" and arg1 == "TinyFriendlyPlates"
then
if TinyNameplatesNewCharacter ~= nil
then
-- saved character
currentWidth = TinyNameplatesNewCharacter
else
-- new character
TinyNameplatesNewCharacter = currentWidth
end
elseif event == "PLAYER_LOGOUT" then
-- save data
TinyNameplatesNewCharacter = currentWidth
end
SetFriendlyNameplates(TinyNameplatesNewCharacter)
frame:Hide()
end
frame:SetScript("OnEvent", frame.OnEvent)