-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitMemo.lua
155 lines (138 loc) · 5.34 KB
/
UnitMemo.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
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
152
153
154
155
-- UnitMemo
-- by thekk
-- 06.10.2018
------------------------ Variablen --------------------------
local _coins = "|TInterface\\Icons\\INV_Misc_Coin_01:16|t "
local _skull = "|TInterface\\TargetingFrame\\UI-TargetingFrame-Skull:16|t "
showResCB = CreateFrame("CheckButton", nil, UnitMemoFrame, "UICheckButtonTemplate")
showResCB:SetWidth(12)
showResCB:SetHeight(12)
showResCB:SetPoint("TOPLEFT",-showResCB:GetWidth(), -16)
showResCB:SetFrameStrata("LOW")
showResCB:Hide()
showTypeCB = CreateFrame("CheckButton", nil, UnitMemoFrame, "UICheckButtonTemplate")
showTypeCB:SetWidth(12)
showTypeCB:SetHeight(12)
showTypeCB:SetPoint("TOPLEFT",-showResCB:GetWidth(), -30)
showTypeCB:SetFrameStrata("LOW")
showTypeCB:Hide()
showAlwaysCB = CreateFrame("CheckButton", nil, UnitMemoFrame, "UICheckButtonTemplate")
showAlwaysCB:SetWidth(12)
showAlwaysCB:SetHeight(12)
showAlwaysCB:SetPoint("TOPLEFT",-showResCB:GetWidth(), -40)
showAlwaysCB:SetFrameStrata("LOW")
showAlwaysCB:Hide()
------------------------ Variablen --------------------------
-------------------- help functions -----------------------
local function print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cffcccc33INFO: |cffffff55" .. ( msg or "nil" ))
end
local function Res(target)
local _,totalArmor = UnitResistance(target,0)
local calcArmor = tonumber(string.format("%.2f",(totalArmor/(totalArmor+400+85*UnitLevel("player")))*100))
local _,totalFr = UnitResistance(target,2)
local _,totalNr = UnitResistance(target,3)
local _,totalFrR = UnitResistance(target,4)
local _,totalSr = UnitResistance(target,5)
return ("\n|cffBDB76B"..totalArmor.." |cffBDB76B"..calcArmor.."% |cffFF0000"..totalFr.." |cff00FF00"..totalNr.." |cff4AE8F5"..totalFrR.." |cff800080"..totalSr)
end
function StartMoving()
UnitMemoFrame:StartMoving()
end
function StopMovingOrSizing()
UnitMemoFrame:StopMovingOrSizing()
posX = UnitMemoFrame:GetLeft()
posY = UnitMemoFrame:GetTop()-UIParent:GetTop()
end
local function setText(target)
local _titleTexture
local _title = UnitName(target)
local _res, _type
if showRes then _res = Res(target) else _res="" end
if showType then _type="\n|cffffffff"..UnitCreatureType(target) else _type="" end
local _text
for k,v in pairs(Notes) do
if k == _title then
if UnitLevel(target) == -1 then
_titleTexture = _skull
else
_titleTexture = _coins
end
--TODO: _titleTexture (UnitSkull)
return (_title.._res.._type.."\n|cffBDB76B"..v)
end
end
if showAlways then return (_title.._res.._type) else return nil end
end
local function setDemoText()
UnitMemoFrame_Text:SetText(setText("player").."\n- Das ist ein Testframe\n- Zieh das Fenster mit der linken Maustaste\n- wo du es hin haben möchtest.")
--UnitMemoFrame_Text:SetText("Loatheb".."\n|cffBDB76B3975 |cffBDB76B36,25% |cffFF000025 |cff00FF0025 |cff4AE8F525 |cff80008025".."\n|cffffffffUntoter".."\n|cff22FF22!Dunkelmondkarte und Schattenpot!\n|cffBDB76B- 2:40 Verbinden & neuer Pot!\n- 3:40 Verband/GS\n- 4:10 Kristallflicker\n- 4:40 Verband, neuer Pot\n- 5:40 Verband/GS")
UnitMemoFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", posX, posY)
UnitMemoFrame:SetWidth( UnitMemoFrame_Text:GetWidth()+6 )
UnitMemoFrame:SetHeight( UnitMemoFrame_Text:GetHeight()+8 )
end
function BMMove()
if UnitMemoFrame:IsMouseEnabled() then
UnitMemoFrame:Hide()
showResCB:Hide()
showTypeCB:Hide()
showAlwaysCB:Hide()
UnitMemoFrame:SetMovable(false)
UnitMemoFrame:EnableMouse(false)
else
setDemoText()
UnitMemoFrame:Show()
showResCB:Show()
showTypeCB:Show()
showAlwaysCB:Show()
UnitMemoFrame:SetMovable(true)
UnitMemoFrame:EnableMouse(true)
end
end
local function Update()
UnitMemoFrame:Hide()
local _text = setText("target")
if _text==nil then UnitMemoFrame:Hide(); return end
UnitMemoFrame_Text:SetText(_text)
UnitMemoFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", posX, posY)
UnitMemoFrame:SetWidth( UnitMemoFrame_Text:GetWidth()+6 )
UnitMemoFrame:SetHeight( UnitMemoFrame_Text:GetHeight()+8 )
UnitMemoFrame:Show()
end
-------------------- Register game event handlers ---------------------------
function UnitMemo_OnLoad()
UnitMemoFrame:RegisterEvent("ADDON_LOADED")
UnitMemoFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
UnitMemoFrame:RegisterForDrag("LeftButton")
UnitMemoFrame:SetScript("OnDragStart", StartMoving)
UnitMemoFrame:SetScript("OnDragStop", StopMovingOrSizing)
SLASH_BOSSMEMO_SLASH1 = '/bm'
SlashCmdList['BOSSMEMO_SLASH'] = BMMove
print("UnitMemo loaded. Type /bm to setup")
end
-------------------- Event Handler ----------------------
function UnitMemo_OnEvent(event)
if (event == "ADDON_LOADED") then
UnitMemoFrame:UnregisterEvent("ADDON_LOADED")
UnitMemoFrame:SetWidth(0)
UnitMemoFrame:SetHeight(0)
UnitMemoFrame:Hide()
UnitMemoFrame:SetMovable(false)
UnitMemoFrame:EnableMouse(false)
showResCB:SetChecked(showRes)
showTypeCB:SetChecked(showType)
showAlwaysCB:SetChecked(showAlways)
showResCB:SetScript("OnClick", function()
if showResCB:GetChecked() == nil then showRes=false else showRes=true end setDemoText() end)
showTypeCB:SetScript("OnClick", function()
if showTypeCB:GetChecked()==nil then showType=false else showType=true end setDemoText() end)
showAlwaysCB:SetScript("OnClick", function()
if showAlwaysCB:GetChecked()==nil then showAlways=false else showAlways=true end setDemoText() end)
selfNotes = Notes
end
if UnitExists("target") then
Update()
else
UnitMemoFrame:Hide()
end
end