-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDevTools.lua
541 lines (479 loc) · 15.9 KB
/
DevTools.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
DevTools = EasyUI.CreateAddon("DevTools")
local nViewType = nil
local szUitexPath = nil
local tImageTXTTitle = {
{f = "i", t = "Farme"},
{f = "i", t = "Left"},
{f = "i", t = "Top"},
{f = "i", t = "Width"},
{f = "i", t = "High"},
{f = "s", t = "File"},
}
local tImageFileList = {
Button = {
"UI/Image/Button/cgbutton",
"UI/Image/Button/CommonButton_1",
"UI/Image/Button/FrendnpartyButton",
"UI/Image/Button/ShopButton",
"UI/Image/Button/SystemButton",
"UI/Image/Button/SystemButton_1",
},
ChannelsPanel = {
"UI/Image/ChannelsPanel/NewChannels",
"UI/Image/ChannelsPanel/NewChannels2",
},
ChatPanel = {
"UI/Image/ChatPanel/editbox",
},
Common = {
"UI/Image/Common/Animate",
"UI/Image/Common/Box",
"UI/Image/Common/CommonPanel",
"UI/Image/Common/CoverShadow",
"UI/Image/Common/DialogueLabel",
"UI/Image/Common/KeynotesPanel",
"UI/Image/Common/Logo",
"UI/Image/Common/Mainpanel_1",
"UI/Image/Common/MatrixAni",
"UI/Image/Common/MatrixAni_1",
"UI/Image/Common/MatrixAni_2",
"UI/Image/Common/Money",
"UI/Image/Common/playerfight",
"UI/Image/Common/ProgressBar",
"UI/Image/Common/sprintgreenpower1",
"UI/Image/Common/sprintgreenpower2",
"UI/Image/Common/sprintnewpower",
"UI/Image/Common/sprintyellowpower1",
"UI/Image/Common/sprintyellowpower2",
"UI/Image/Common/TempBox",
"UI/Image/Common/TextShadow",
},
GMPanel = {
"UI/Image/GMPanel/gm1",
"UI/Image/GMPanel/gm2",
"UI/Image/GMPanel/gm3",
"UI/Image/GMPanel/gmbg",
},
Helper = {
"UI/Image/Helper/flopbg",
"UI/Image/Helper/help",
"UI/Image/Helper/help—bg",
"UI/Image/Helper/helpmsg",
"UI/Image/Helper/helpquest",
"UI/Image/Helper/test",
},
LootPanel = {
"UI/Image/LootPanel/lootpanel",
"UI/Image/LootPanel/playerview",
},
MiddleMap = {
"UI/Image/MiddleMap/mapwindow",
"UI/Image/MiddleMap/mapwindow2",
},
Minimap = {
"UI/Image/Minimap/battleminimap",
"UI/Image/Minimap/Mapmark",
"UI/Image/Minimap/Minimap",
"UI/Image/Minimap/Minimap2",
"UI/Image/Minimap/Minimap3",
},
QuestPanel = {
"UI/Image/QuestPanel/QuestPanel",
"UI/Image/QuestPanel/QuestPanelButton",
"UI/Image/QuestPanel/QuestPanelPart",
},
TargetPanel = {
"UI/Image/TargetPanel/CangjianAnimation1",
"UI/Image/TargetPanel/CangjianAnimation2",
"UI/Image/TargetPanel/frameplayer",
"UI/Image/TargetPanel/Player",
"UI/Image/TargetPanel/Target",
},
UICommon = {
"UI/Image/UICommon/achievementpanel",
"UI/Image/UICommon/achievementpanel2",
"UI/Image/UICommon/activepopularize",
"UI/Image/UICommon/activepopularize2",
"UI/Image/UICommon/arenaintroduction",
"UI/Image/UICommon/battlefiled",
"UI/Image/UICommon/blackmarket",
"UI/Image/UICommon/camp",
"UI/Image/UICommon/Commonpanel",
"UI/Image/UICommon/Commonpanel2",
"UI/Image/UICommon/Commonpanel3",
"UI/Image/UICommon/Commonpanel4",
"UI/Image/UICommon/Commonpanel5",
"UI/Image/UICommon/Commonpanel6",
"UI/Image/UICommon/Commonpanel7",
"UI/Image/UICommon/CompassPanel",
"UI/Image/UICommon/crossingpanel1",
"UI/Image/UICommon/crossingpanel4",
"UI/Image/UICommon/crossingpanel5",
"UI/Image/UICommon/crossingpanel6",
"UI/Image/UICommon/crossingpanel7",
"UI/Image/UICommon/exteriorbox",
"UI/Image/UICommon/exteriorbox3",
"UI/Image/UICommon/feedanimials",
"UI/Image/UICommon/FEPanel",
"UI/Image/UICommon/FEPanel3",
"UI/Image/UICommon/guildmainpanel1",
"UI/Image/UICommon/guildmainpanel2",
"UI/Image/UICommon/HelpPanel",
"UI/Image/UICommon/kuang_cyclopaedia_calender",
"UI/Image/UICommon/LoginCommon",
"UI/Image/UICommon/LoginSchool",
"UI/Image/UICommon/MailCommon",
"UI/Image/UICommon/new_cyclopaedia_calender",
"UI/Image/UICommon/newskills1",
"UI/Image/UICommon/newskills3",
"UI/Image/UICommon/rankingpanel",
"UI/Image/UICommon/PasswordPanel",
"UI/Image/UICommon/sciencetree",
"UI/Image/UICommon/ScienceTreeNode",
"UI/Image/UICommon/skills",
"UI/Image/UICommon/skills2",
"UI/Image/UICommon/theflop",
"UI/Image/UICommon/Talk_Face",
},
}
local tEventIndex = {
{"键盘按下", 13},
{"键盘弹起", 14},
{"左键按下", 1},
{"左键弹起", 3},
{"左键单击", 5},
{"左键双击", 7},
{"左键拖拽", 20},
{"右键按下", 2},
{"右键弹起", 4},
{"右键单击", 6},
{"右键双击", 8},
{"右键拖拽", 19},
{"中键按下", 15},
{"中键弹起", 16},
{"中键单击", 17},
{"中键双击", 18},
{"中键拖拽", 21},
{"鼠标进出", 9},
{"鼠标区域", 10},
{"鼠标移动", 11},
{"鼠标悬停", 22},
{"滚动事件", 12},
}
function DevTools:OnCreate()
this:RegisterEvent("UI_SCALED")
self:UpdateAnchor(this)
end
function DevTools:UpdateAnchor(frame)
frame:SetPoint("CENTER", 0, 0, "CENTER", 0, 0)
end
function DevTools:OnScript(event)
if event == "UI_SCALED" then
self:UpdateAnchor(this)
end
end
function DevTools:Init()
local frame = self:Append("Frame", "DevTools", {title = "开发者工具集", style = "NORMAL"})
local imgTab = self:Append("Image", frame,"TabImg",{w = 770,h = 33,x = 0,y = 50})
imgTab:SetImage("ui\\Image\\UICommon\\ActivePopularize2.UITex", 46)
imgTab:SetImageType(11)
local hPageSet = self:Append("PageSet", frame, "PageSet", {x = 0, y = 50, w = 768, h = 434})
--图像查看器
local hBtnUITexView = self:Append("UICheckBox", hPageSet, "BtnUITexView", {x = 50, y = 0, w = 100, h = 30, text = "图像查看", group = "DevClass", check = true})
local hWinUITexView = self:Append("Window", hPageSet, "WindowUITexView", {x = 0, y = 30, w = 768, h = 400})
hPageSet:AddPage(hWinUITexView:GetSelf(), hBtnUITexView:GetSelf())
hBtnUITexView.OnCheck = function(bCheck)
if bCheck then
hPageSet:ActivePage(0)
end
end
nViewType = 1
self:Append("Text", hWinUITexView, "ViewType", {x = 30, y = 10, text = "组件类型:"})
local hUITexViewRadioBox_Img = self:Append("RadioBox", hWinUITexView, "RB_1", {x = 100, y = 12, text = "图像", group = "ViewType", check = true})
hUITexViewRadioBox_Img.OnCheck = function(arg0)
if arg0 then
nViewType = 1
self:LoadUITex(szUitexPath)
end
end
local hUITexViewRadioBox_Ani = self:Append("RadioBox", hWinUITexView, "RB_2", {x = 170, y = 12, text = "动画", group = "ViewType"})
hUITexViewRadioBox_Ani.OnCheck = function(arg0)
if arg0 then
nViewType = 2
self:LoadUITex(szUitexPath)
end
end
self:Append("Text", hWinUITexView, "UITexPath", {x = 300, y = 10, text = "路径:"})
local hUITexViewComboBox_Path = self:Append("ComboBox", hWinUITexView, "CB_1", {x = 340, y = 12, w = 400})
hUITexViewComboBox_Path.OnClick = function(m)
PopupMenu(self:GetMenu(m))
end
local hUITexViewShadowBg = self:Append("Shadow", hWinUITexView, "BG", {x = 15, y = 50, w = 738, h = 365})
hUITexViewShadowBg:SetColorRGB(0, 0, 0)
local hUITexViewContentScroll = self:Append("Scroll", hWinUITexView ,"hUITexViewContentScroll",{ x = 15,y = 50,w = 755, h = 365})
local hUITexViewContent = self:Append("Handle", hUITexViewContentScroll, "UITexViewContent", {x = 5, y = 5, w = 738, h = 355})
hUITexViewContentScroll:UpdateList()
--事件和字体查看器
local hBtnFontView = self:Append("UICheckBox", hPageSet, "BtnFontView", {x = 150, y = 0, w = 150, h = 30, text = "事件和字体查看", group = "DevClass"})
local hWinFontView = self:Append("Window", hPageSet, "WindowFontView", {x = 0, y = 30, w = 758, h = 400})
hPageSet:AddPage(hWinFontView:GetSelf(), hBtnFontView:GetSelf())
hBtnFontView.OnCheck = function(bCheck)
if bCheck then
hPageSet:ActivePage(1)
end
end
self:Append("Image", hWinFontView, "imgDivide1", {w = 280, h = 8, x = 30, y = 45, image = "ui\\Image\\UICommon\\CommonPanel.UITex", frame = 45}):SetImageType(11)
self:Append("Image", hWinFontView, "imgDivide2", {w = 280, h = 8, x = 30, y = 370, image = "ui\\Image\\UICommon\\CommonPanel.UITex", frame = 45}):SetImageType(11)
self:LoadEventIDBox(hWinFontView)
self:Append("Image", hWinFontView, "SplitImg", {w = 5, h = 400, x = 340, y = 20, image = "ui\\Image\\UICommon\\CommonPanel.UITex", frame = 43})
local hTextViewContentScroll = self:Append("Scroll", hWinFontView ,"hTextViewContentScroll",{x = 370, y = 20, w = 380, h = 390})
self:LoadTextDummy(hTextViewContentScroll)
--图标查看器
local hBtnIconView = self:Append("UICheckBox", hPageSet, "BtnIconView", {x = 300, y = 0, w = 100, h = 30, text = "图标查看", group = "DevClass"})
local hWinIconView = self:Append("Window", hPageSet, "WindowIconView", {x = 0, y = 30, w = 758, h = 400})
hPageSet:AddPage(hWinIconView:GetSelf(), hBtnIconView:GetSelf())
hBtnIconView.OnCheck = function(bCheck)
if bCheck then
hPageSet:ActivePage(2)
end
end
self:LoadIconBox(hWinIconView)
return frame
end
function DevTools:GetMenu(menu)
for k, v in pairs(tImageFileList) do
local m_t = {szOption = k}
for kk, vv in pairs(v) do
local m_c = {
szOption = vv,
fnAction = function()
self:LoadUITex(vv)
szUitexPath = vv
self:Fetch("CB_1"):SetText(string.format("%s.UITex", vv))
end
}
table.insert(m_t, m_c)
end
table.insert(menu, m_t)
end
return menu
end
function DevTools:OutputTip(item)
local nMouseX, nMouseY = Cursor.GetPos()
local szTipInfo =
"<Text>text=" .. EncodeComponentsString("★ 帧编号:") .. " font=162 </text>" ..
"<Text>text=" .. EncodeComponentsString(item.nFrameIndex or item.nAniGroup) .. " font=100 </text>" ..
"<Text>text=" .. EncodeComponentsString("\n☆ 帧宽度:") .. " font=162 </text>" ..
"<Text>text=" .. EncodeComponentsString(item.nW) .. " font=162 </text>" ..
"<Text>text=" .. EncodeComponentsString("\n☆ 帧高度:") .. " font=162 </text>" ..
"<Text>text=" .. EncodeComponentsString(item.nH) .. " font=162 </text>"
OutputTip(szTipInfo, 1000, {nMouseX, nMouseY, 0, 0})
end
function DevTools:OutputIconTip(ID)
local nMouseX, nMouseY = Cursor.GetPos()
local szTipInfo =
"<Text>text=" .. EncodeComponentsString("★ 图标ID:") .. " font=162 </text>" ..
"<Text>text=" .. EncodeComponentsString(ID) .. " font=100 </text>"
OutputTip(szTipInfo, 1000, {nMouseX, nMouseY, 0, 0})
end
function DevTools:GetImageFrameInfo(szImageFile)
return KG_Table.Load(szImageFile, tImageTXTTitle, FILE_OPEN_MODE.NORMAL)
end
function DevTools:LoadUITex(szBaseName)
local hContent = self:Fetch("UITexViewContent")
hContent:ClearHandle()
local hHOver = self:Append("Image", hContent, "ImageHover", {x = 0, y = 0, w = 50, h = 50, image = "ui\\Image\\Common\\Box.UITex", frame = 1, lockshowhide=1})
hHOver:SetImageType(10)
hHOver:SetAlpha(150)
if not szBaseName then
return
end
local tInfo = self:GetImageFrameInfo(szBaseName .. ".txt")
if not tInfo then
return
end
if nViewType == 1 then
for i = 0, 256 do
local tLine = tInfo:Search(i)
if tLine then
if tonumber(tLine.Width) ~= 0 and tonumber(tLine.High) ~= 0 then
local img = self:Append("Image", hContent, "Image_" .. i, {x = tonumber(tLine.Left), y = tonumber(tLine.Top), w = tonumber(tLine.Width), h = tonumber(tLine.High), image = string.format("%s.UITex", szBaseName), frame = i, eventid = 277})
img.nFrameIndex = i
img.szBaseFileName = szBaseName
img.nX = tonumber(tLine.Left)
img.nY = tonumber(tLine.Top)
img.nW = tonumber(tLine.Width)
img.nH = tonumber(tLine.High)
img.OnEnter = function()
hHOver:Show()
hHOver:SetSize(img.nW + 2, img.nH + 2)
local x, y = img:GetAbsPos()
hHOver:SetAbsPos(x - 1, y - 1)
self:OutputTip(img)
end
img.OnLeave = function()
hHOver:Hide()
HideTip()
end
end
else
break
end
end
elseif nViewType == 2 then
local nAniX = 10
local nAniY = 10
local nAniNextY = nAniY
for i = 0, 99 do
local ani = self:Append("Animate", hContent,"Animate_" .. i, {w = 50,h = 50, x = nAniX, y = nAniY, image = string.format("%s.UITex", szBaseName), eventid = 277})
ani:SetGroup(i)
ani:SetLoopCount(-1)
ani:AutoSize()
local nAniW, nAniH = ani:GetSize()
ani.nAniGroup = i
ani.szBaseFileName = szBaseName
ani.nX = nAniX
ani.nY = nAniY
ani.nW = nAniW
ani.nH = nAniH
ani.OnEnter = function()
hHOver:Show()
hHOver:SetSize(ani.nW + 2, ani.nH + 2)
local x, y = ani:GetAbsPos()
hHOver:SetAbsPos(x - 1, y - 1)
self:OutputTip(ani)
end
ani.OnLeave = function()
hHOver:Hide()
HideTip()
end
nAniX = nAniX + nAniW + 10
if nAniNextY <= nAniY + nAniH then
nAniNextY = nAniY + nAniH + 10
end
if nAniX >= 500 then
nAniY = nAniNextY
nAniX = 10
end
end
end
hContent:FormatAllItemPos()
hContent:SetSizeByAllItemSize()
self:Fetch("hUITexViewContentScroll"):UpdateList()
end
function DevTools:LoadEventIDBox(hWin)
for k, v in ipairs(tEventIndex) do
self:Append("CheckBox", hWin, "CheckBox_" .. v[2], {x = ((k - 1) % 3) * 100 + 30, y = math.floor((k - 1) / 3) * 40 + 60, w = 100, text = v[1]})
end
self:Append("Text", hWin, "EventIDTexr", {x = 35, y = 10, text = "事件ID:"})
local hBtnCalc = self:Append("Button", hWin, "BtnCalc", {x = 200, y = 10, text = "计算"})
local hEventIDEdit = self:Append("Edit", hWin, "EventIDEdit", {w = 100, h = 25, x = 90, y = 11, text = "0"})
hBtnCalc.OnClick = function()
local tBitTab = {}
for i = 1, 22 do
tBitTab[i] = 0
if self:Fetch("CheckBox_" .. i):IsChecked() then
tBitTab[i] = 1
end
end
local nEventID = self:BitTable2UInt(tBitTab) or 0
hEventIDEdit:SetText(nEventID)
end
local hCheckAll = self:Append("CheckBox", hWin, "CheckBoxAll", {x = 130, y = 380, w = 100, text = "全选"})
hCheckAll.OnCheck = function(bCheck)
for i = 1, 22 do
self:Fetch("CheckBox_" .. i):Check(bCheck)
end
end
local hCheckRev = self:Append("CheckBox", hWin, "CheckBoxRev", {x = 230, y = 380, w = 100, text = "反选"})
hCheckRev.OnCheck = function(bCheck)
for i = 1, 22 do
local hCheck = self:Fetch("CheckBox_" .. i)
if hCheck:IsChecked() then
hCheck:Check(false)
else
hCheck:Check(true)
end
end
end
end
function DevTools:BitTable2UInt(tBitTab)
local nUInt = 0
for i = 1, 24 do
nUInt = nUInt + (tBitTab[i] or 0) * (2 ^ (i - 1))
end
return nUInt
end
function DevTools:LoadTextDummy(hScroll)
for i = 0, 255 do
local hBox = self:Append("Handle", hScroll, "hFont_" .. i, {w = 40, h = 30, postype = 8})
local text = self:Append("Text", hBox, "FontDummy_" .. i, {w = 10, h = 10})
text:SetFontScheme(i)
text.nFontScheme = i
local nFS = text:GetFontScheme()
if nFS == i then
text:SetText("#" .. nFS)
local nX = i % 10 * 39
local nY = math.floor(i / 10) * 25
text:SetRelPos(nX, nY)
else
text:SetText("")
text:SetRelPos(4000, 4000)
text:Hide()
end
end
hScroll:UpdateList()
end
function DevTools:LoadIconBox(hWin)
local hIconViewContent = self:Append("Handle", hWin, "IconViewContent", {x = 33, y = 33, w = 700, h = 300})
for i = 1, 84 do
local icon = self:Append("Image", hIconViewContent, "Icon_" .. i, {x = ((i - 1) % 14) * 50, y = math.floor((i - 1) / 14) * 50, w = 45, h = 45, eventid = 277})
icon:FromIconID(i)
icon.OnEnter = function() self:OutputIconTip(i) end
icon.OnLeave = function() HideTip() end
end
local hBtnPrev = self:Append("Button", hWin, "BtnIconPrev", {x = 200, y = 350, text = "上一页", enable = false})
local hBtnNext = self:Append("Button", hWin, "BtnIconNext", {x = 410, y = 350, text = "下一页"})
local n, nTol = 1, math.ceil(3481 / 84)
local hPage = self:Append("Text", hWin, "TextIconPage", {x = 340, y = 350, text = n .. "/" .. nTol})
hBtnPrev.OnClick = function()
n = math.max(1, n - 1)
hPage:SetText(n .. "/" .. nTol)
if n == 1 then
hBtnPrev:Enable(false)
else
hBtnPrev:Enable(true)
end
hBtnNext:Enable(true)
for i = 1, 84 do
local icon, k = self:Fetch("Icon_" .. i), (n - 1) * 84 + i
icon:FromIconID(k)
icon.OnEnter = function() self:OutputIconTip(k) end
icon.OnLeave = function() HideTip() end
end
end
hBtnNext.OnClick = function()
n = math.min(nTol, n + 1)
hPage:SetText(n .. "/" .. nTol)
if n == nTol then
hBtnNext:Enable(false)
else
hBtnNext:Enable(true)
end
hBtnPrev:Enable(true)
for i = 1, 84 do
local icon, k = self:Fetch("Icon_" .. i), (n - 1) * 84 + i
icon:FromIconID(k)
icon.OnEnter = function() self:OutputIconTip(k) end
icon.OnLeave = function() HideTip() end
end
end
end
function DevTools:OpenPanel()
local frame = self:Fetch("DevTools")
if frame and frame:IsVisible() then
frame:Destroy()
else
frame = self:Init()
end
end