forked from stpain/guildbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextureViewer.lua
71 lines (64 loc) · 2.24 KB
/
TextureViewer.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
local fileID = 521743;
local itemsPerPage = 25;
local viewer = CreateFrame("Frame", "hslTextureViewer", UIParent, "BasicFrameTemplateWithInset")
viewer:SetSize(810, 550)
viewer:SetPoint("CENTER", 0, 0)
viewer:SetMovable(true)
viewer:EnableMouse(true)
viewer:RegisterForDrag("LeftButton")
viewer:SetScript("OnDragStart", viewer.StartMoving)
viewer:SetScript("OnDragStop", viewer.StopMovingOrSizing)
viewer:Hide()
viewer.editbox = CreateFrame("EDITBOX", nil, viewer, "InputBoxTemplate")
viewer.editbox:SetPoint("TOP", 0, 0)
viewer.editbox:SetSize(100, 20)
viewer.editbox:SetAutoFocus(false)
viewer.editbox:SetScript("OnTextChanged", function(self)
if tonumber(self:GetText()) then
fileID = self:GetText()
for i = 1, itemsPerPage do
viewer.textures[i].texture:SetTexture(fileID + i)
viewer.textures[i].text:SetText(fileID + i)
end
end
end)
viewer.prev = CreateFrame("BUTTON", nil, viewer, "UIPanelButtonTemplate")
viewer.prev:SetPoint("RIGHT", viewer.editbox, "LEFT", -20, 0)
viewer.prev:SetSize(80, 20)
viewer.prev:SetText("Prev")
viewer.prev:SetScript("OnClick", function(self)
fileID = fileID - itemsPerPage
for i = 1, itemsPerPage do
viewer.textures[i].texture:SetTexture(fileID + i)
viewer.textures[i].text:SetText(fileID + i)
end
viewer.editbox:ClearFocus()
end)
viewer.next = CreateFrame("BUTTON", nil, viewer, "UIPanelButtonTemplate")
viewer.next:SetPoint("LEFT", viewer.editbox, "RIGHT", 20, 0)
viewer.next:SetSize(80, 20)
viewer.next:SetText("Next")
viewer.next:SetScript("OnClick", function(self)
fileID = fileID + itemsPerPage
for i = 1, itemsPerPage do
viewer.textures[i].texture:SetTexture(fileID + i)
viewer.textures[i].text:SetText(fileID + i)
end
viewer.editbox:ClearFocus()
end)
viewer.textures = {}
local i = 1;
for row = 0, 4 do
for col = 0, 4 do
local t = viewer:CreateTexture(nil, "ARTWORK")
t:SetSize(155, 82.5)
t:SetPoint("TOPLEFT", (col * 155) + 20, (row * -100) - 30)
local f = viewer:CreateFontString(nil, "OVERLAY", "GameFontNormal")
f:SetPoint("BOTTOM", t, "BOTTOM", 0, -14)
viewer.textures[i] = {
texture = t,
text = f,
}
i = i + 1
end
end