StatusReport.lua 10.1 KB
Newer Older
1
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
Simpy's avatar
Simpy committed
2
local Skins = E:GetModule('Skins')
3
4

--WoW API / Variables
5
local CreateFrame = CreateFrame
6
7
8
9
10
11
12
local GetAddOnInfo = GetAddOnInfo
local GetCVar = GetCVar
local GetLocale = GetLocale
local GetNumAddOns = GetNumAddOns
local GetRealZoneText = GetRealZoneText
local GetSpecialization = GetSpecialization
local GetSpecializationInfo = GetSpecializationInfo
Azilroka's avatar
Azilroka committed
13

14
local function AreOtherAddOnsEnabled()
15
	local name
16
	for i = 1, GetNumAddOns() do
17
		name = GetAddOnInfo(i)
Azilroka's avatar
Azilroka committed
18
		if ((name ~= 'ElvUI' and name ~= 'ElvUI_OptionsUI') and E:IsAddOnEnabled(name)) then --Loaded or load on demand
Simpy's avatar
Simpy committed
19
			return 'Yes'
20
21
		end
	end
Simpy's avatar
Simpy committed
22
	return 'No'
23
end
24

25
local function GetDisplayMode()
Simpy's avatar
Simpy committed
26
	local window, maximize = GetCVar('gxWindow'), GetCVar('gxMaximize')
27
28
	local displayMode

Simpy's avatar
Simpy committed
29
30
31
	if window == '1' then
		if maximize == '1' then
			displayMode = 'Windowed (Fullscreen)'
32
		else
Simpy's avatar
Simpy committed
33
			displayMode = 'Windowed'
34
35
		end
	else
Simpy's avatar
Simpy committed
36
		displayMode = 'Fullscreen'
37
38
39
40
41
42
	end

	return displayMode
end

local EnglishClassName = {
Simpy's avatar
Simpy committed
43
44
45
46
47
48
49
50
51
52
53
54
	['DEATHKNIGHT'] = 'Death Knight',
	['DEMONHUNTER'] = 'Demon Hunter',
	['DRUID'] = 'Druid',
	['HUNTER'] = 'Hunter',
	['MAGE'] = 'Mage',
	['MONK'] = 'Monk',
	['PALADIN'] = 'Paladin',
	['PRIEST'] = 'Priest',
	['ROGUE'] = 'Rogue',
	['SHAMAN'] = 'Shaman',
	['WARLOCK'] = 'Warlock',
	['WARRIOR'] = 'Warrior',
55
56
57
}

local EnglishSpecName = {
Simpy's avatar
Simpy committed
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
	[250] = 'Blood',
	[251] = 'Frost',
	[252] = 'Unholy',
	[102] = 'Balance',
	[103] = 'Feral',
	[104] = 'Guardian',
	[105] = 'Restoration',
	[253] = 'Beast Mastery',
	[254] = 'Marksmanship',
	[255] = 'Survival',
	[62] = 'Arcane',
	[63] = 'Fire',
	[64] = 'Frost',
	[268] = 'Brewmaster',
	[270] = 'Mistweaver',
	[269] = 'Windwalker',
	[65] = 'Holy',
	[66] = 'Protection',
	[70] = 'Retribution',
	[256] = 'Discipline',
	[257] = 'Holy',
	[258] = 'Shadow',
	[259] = 'Assasination',
	[260] = 'Combat',
	[261] = 'Sublety',
	[262] = 'Elemental',
	[263] = 'Enhancement',
	[264] = 'Restoration',
	[265] = 'Affliction',
	[266] = 'Demonoligy',
	[267] = 'Destruction',
	[71] = 'Arms',
	[72] = 'Fury',
	[73] = 'Protection',
	[577] = 'Havoc',
	[581] = 'Vengeance',
94
95
96
97
98
99
}

local function GetSpecName()
	return EnglishSpecName[GetSpecializationInfo(GetSpecialization())]
end

100
101
102
103
local function CreateContentLines(num, parent, anchorTo)
	local content = CreateFrame('Frame', nil, parent)
	content:Size(260, (num * 20) + ((num-1)*5)) --20 height and 5 spacing
	content:Point('TOP', anchorTo, 'BOTTOM',0 , -5)
Simpy's avatar
Simpy committed
104

105
106
107
108
	for i = 1, num do
		local line = CreateFrame('Frame', nil, content)
		line:Size(260, 20)

Simpy's avatar
Simpy committed
109
110
111
112
113
114
115
		local text = line:CreateFontString(nil, 'ARTWORK', 'SystemFont_Outline')
		text:SetAllPoints()
		text:SetJustifyH('LEFT')
		text:SetJustifyV('MIDDLE')
		line.Text = text

		local numLine = line
116
		if i == 1 then
Simpy's avatar
Simpy committed
117
			numLine:Point('TOP', content, 'TOP')
118
		else
Simpy's avatar
Simpy committed
119
			numLine:Point('TOP', content['Line'..(i-1)], 'BOTTOM', 0, -5)
120
		end
Simpy's avatar
Simpy committed
121
122

		content['Line'..i] = numLine
123
124
125
126
127
128
129
130
131
132
133
134
	end

	return content
end

local function CloseClicked()
	if E.StatusReportToggled then
		E.StatusReportToggled = nil
		E:ToggleOptionsUI()
	end
end

135
136
function E:CreateStatusFrame()
	local function CreateSection(width, height, parent, anchor1, anchorTo, anchor2, yOffset)
Simpy's avatar
Simpy committed
137
		local section = CreateFrame('Frame', nil, parent)
138
139
140
		section:Size(width, height)
		section:Point(anchor1, anchorTo, anchor2, 0, yOffset)

Simpy's avatar
Simpy committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		local header = CreateFrame('Frame', nil, section)
		header:Size(300, 30)
		header:Point('TOP', section)
		section.Header = header

		local text = section.Header:CreateFontString(nil, 'ARTWORK', 'SystemFont_Outline')
		text:Point('TOP')
		text:Point('BOTTOM')
		text:SetJustifyH('CENTER')
		text:SetJustifyV('MIDDLE')

		local font, fontHeight, fontFlags = text:GetFont()
		text:FontTemplate(font, fontHeight*1.3, fontFlags)
		section.Header.Text = text

		local leftDivider = section.Header:CreateTexture(nil, 'ARTWORK')
		leftDivider:Height(8)
		leftDivider:Point('LEFT', section.Header, 'LEFT', 5, 0)
		leftDivider:Point('RIGHT', section.Header.Text, 'LEFT', -5, 0)
		leftDivider:SetTexture('Interface\\Tooltips\\UI-Tooltip-Border')
		leftDivider:SetTexCoord(0.81, 0.94, 0.5, 1)
		section.Header.LeftDivider = leftDivider

		local rightDivider = section.Header:CreateTexture(nil, 'ARTWORK')
		rightDivider:Height(8)
		rightDivider:Point('RIGHT', section.Header, 'RIGHT', -5, 0)
		rightDivider:Point('LEFT', section.Header.Text, 'RIGHT', 5, 0)
		rightDivider:SetTexture('Interface\\Tooltips\\UI-Tooltip-Border')
		rightDivider:SetTexCoord(0.81, 0.94, 0.5, 1)
		section.Header.RightDivider = rightDivider
171
172
173
174

		return section
	end

175
	--Main frame
Simpy's avatar
Simpy committed
176
	local StatusFrame = CreateFrame('Frame', 'ElvUIStatusReport', E.UIParent)
177
	StatusFrame:Size(320, 555)
Simpy's avatar
Simpy committed
178
179
180
	StatusFrame:Point('CENTER', E.UIParent, 'CENTER')
	StatusFrame:SetFrameStrata('HIGH')
	StatusFrame:CreateBackdrop('Transparent', nil, true)
181
182
	StatusFrame.backdrop:SetBackdropColor(0, 0, 0, 0.6)
	StatusFrame:SetMovable(true)
Simpy's avatar
Simpy committed
183
	StatusFrame:Hide()
184

Simpy's avatar
Simpy committed
185
186
	--Close button and script to retoggle the options.
	StatusFrame:CreateCloseButton()
187
188
	StatusFrame.CloseButton:HookScript('OnClick', CloseClicked)

189
	--Title logo (drag to move frame)
Simpy's avatar
Simpy committed
190
191
192
193
194
195
196
197
198
199
	local titleLogoFrame = CreateFrame('Frame', nil, StatusFrame, 'TitleDragAreaTemplate')
	titleLogoFrame:Point('CENTER', StatusFrame, 'TOP')
	titleLogoFrame:Size(240, 80)
	StatusFrame.TitleLogoFrame = titleLogoFrame

	local titleTexture = StatusFrame.TitleLogoFrame:CreateTexture(nil, 'ARTWORK')
	titleTexture:Point('CENTER', titleLogoFrame, 'TOP', 0, -36)
	titleTexture:SetTexture(E.Media.Textures.LogoSmall)
	titleTexture:Size(128, 64)
	titleLogoFrame.Texture = titleTexture
200
201

	--Sections
Simpy's avatar
Simpy committed
202
203
204
205
	StatusFrame.Section1 = CreateSection(300, 125, StatusFrame, 'TOP', StatusFrame, 'TOP', -30)
	StatusFrame.Section2 = CreateSection(300, 150, StatusFrame, 'TOP', StatusFrame.Section1, 'BOTTOM', 0)
	StatusFrame.Section3 = CreateSection(300, 185, StatusFrame, 'TOP', StatusFrame.Section2, 'BOTTOM', 0)
	StatusFrame.Section4 = CreateSection(300, 60, StatusFrame, 'TOP', StatusFrame.Section3, 'BOTTOM', 0)
206

207
	--Section headers
Simpy's avatar
Simpy committed
208
209
210
211
	StatusFrame.Section1.Header.Text:SetText('|cfffe7b2cAddOn Info|r')
	StatusFrame.Section2.Header.Text:SetText('|cfffe7b2cWoW Info|r')
	StatusFrame.Section3.Header.Text:SetText('|cfffe7b2cCharacter Info|r')
	StatusFrame.Section4.Header.Text:SetText('|cfffe7b2cExport To|r')
212

213
	--Section content
214
	StatusFrame.Section1.Content = CreateContentLines(4, StatusFrame.Section1, StatusFrame.Section1.Header)
215
216
	StatusFrame.Section2.Content = CreateContentLines(5, StatusFrame.Section2, StatusFrame.Section2.Header)
	StatusFrame.Section3.Content = CreateContentLines(6, StatusFrame.Section3, StatusFrame.Section3.Header)
Simpy's avatar
Simpy committed
217
	StatusFrame.Section4.Content = CreateFrame('Frame', nil, StatusFrame.Section4)
218
	StatusFrame.Section4.Content:Size(240, 25)
Simpy's avatar
Simpy committed
219
	StatusFrame.Section4.Content:Point('TOP', StatusFrame.Section4.Header, 'BOTTOM', 0, 0)
220
221

	--Content lines
Simpy's avatar
Simpy committed
222
223
	StatusFrame.Section1.Content.Line1.Text:SetFormattedText('Version of ElvUI: |cff4beb2c%s|r', E.version)
	StatusFrame.Section1.Content.Line2.Text:SetFormattedText('Other AddOns Enabled: |cff4beb2c%s|r', AreOtherAddOnsEnabled())
Simpy's avatar
Simpy committed
224
	StatusFrame.Section1.Content.Line3.Text:SetFormattedText('Recommended Scale: |cff4beb2c%s|r', E:PixelBestSize())
Simpy's avatar
Simpy committed
225
226
227
228
	StatusFrame.Section1.Content.Line4.Text:SetFormattedText('UI Scale Is: |cff4beb2c%s|r', E.global.general.UIScale)
	StatusFrame.Section2.Content.Line1.Text:SetFormattedText('Version of WoW: |cff4beb2c%s (build %s)|r', E.wowpatch, E.wowbuild)
	StatusFrame.Section2.Content.Line2.Text:SetFormattedText('Client Language: |cff4beb2c%s|r', GetLocale())
	StatusFrame.Section2.Content.Line3.Text:SetFormattedText('Display Mode: |cff4beb2c%s|r', GetDisplayMode())
229
	StatusFrame.Section2.Content.Line4.Text:SetFormattedText('Resolution: |cff4beb2c%s|r', E.resolution)
Simpy's avatar
Simpy committed
230
231
232
233
234
235
236
	StatusFrame.Section2.Content.Line5.Text:SetFormattedText('Using Mac Client: |cff4beb2c%s|r', (E.isMacClient == true and 'Yes' or 'No'))
	StatusFrame.Section3.Content.Line1.Text:SetFormattedText('Faction: |cff4beb2c%s|r', E.myfaction)
	StatusFrame.Section3.Content.Line2.Text:SetFormattedText('Race: |cff4beb2c%s|r', E.myrace)
	StatusFrame.Section3.Content.Line3.Text:SetFormattedText('Class: |cff4beb2c%s|r', EnglishClassName[E.myclass])
	StatusFrame.Section3.Content.Line4.Text:SetFormattedText('Specialization: |cff4beb2c%s|r', GetSpecName())
	StatusFrame.Section3.Content.Line5.Text:SetFormattedText('Level: |cff4beb2c%s|r', E.mylevel)
	StatusFrame.Section3.Content.Line6.Text:SetFormattedText('Zone: |cff4beb2c%s|r', GetRealZoneText())
237
238

	--Export buttons
Simpy's avatar
Simpy committed
239
	StatusFrame.Section4.Content.Button1 = CreateFrame('Button', nil, StatusFrame.Section4.Content, 'UIPanelButtonTemplate')
240
	StatusFrame.Section4.Content.Button1:Size(100, 25)
Simpy's avatar
Simpy committed
241
242
243
244
	StatusFrame.Section4.Content.Button1:Point('LEFT', StatusFrame.Section4.Content, 'LEFT')
	StatusFrame.Section4.Content.Button1:SetText('Forum')
	StatusFrame.Section4.Content.Button1:SetButtonState('DISABLED')
	StatusFrame.Section4.Content.Button2 = CreateFrame('Button', nil, StatusFrame.Section4.Content, 'UIPanelButtonTemplate')
245
	StatusFrame.Section4.Content.Button2:Size(100, 25)
Simpy's avatar
Simpy committed
246
247
248
	StatusFrame.Section4.Content.Button2:Point('RIGHT', StatusFrame.Section4.Content, 'RIGHT')
	StatusFrame.Section4.Content.Button2:SetText('Ticket')
	StatusFrame.Section4.Content.Button2:SetButtonState('DISABLED')
Simpy's avatar
Simpy committed
249
250

	Skins:HandleButton(StatusFrame.Section4.Content.Button1, true)
251
	Skins:HandleButton(StatusFrame.Section4.Content.Button2, true)
252

Simpy's avatar
Simpy committed
253
	return StatusFrame
254
255
end

256
local function UpdateDynamicValues()
Simpy's avatar
Simpy committed
257
258
259
260
261
262
263
264
265
266
	local StatusFrame = E.StatusFrame

	local Section2 = StatusFrame.Section2
	Section2.Content.Line3.Text:SetFormattedText('Display Mode: |cff4beb2c%s|r', GetDisplayMode())
	Section2.Content.Line4.Text:SetFormattedText('Resolution: |cff4beb2c%s|r', E.resolution)

	local Section3 = StatusFrame.Section3
	Section3.Content.Line4.Text:SetFormattedText('Specialization: |cff4beb2c%s|r', GetSpecName())
	Section3.Content.Line5.Text:SetFormattedText('Level: |cff4beb2c%s|r', E.mylevel)
	Section3.Content.Line6.Text:SetFormattedText('Zone: |cff4beb2c%s|r', GetRealZoneText())
267
268
end

269
function E:ShowStatusReport()
Simpy's avatar
Simpy committed
270
271
	if not E.StatusFrame then
		E.StatusFrame = E:CreateStatusFrame()
272
273
	end

Simpy's avatar
Simpy committed
274
	if not E.StatusFrame:IsShown() then
275
		UpdateDynamicValues()
Simpy's avatar
Simpy committed
276
277
		E.StatusFrame:Raise() --Set framelevel above everything else
		E.StatusFrame:Show()
278
	else
Simpy's avatar
Simpy committed
279
		E.StatusFrame:Hide()
280
	end
Simpy's avatar
Simpy committed
281
end