1 QuestHelper_File
["textviewer.lua"] = "Development Version"
2 QuestHelper_Loadtime
["textviewer.lua"] = GetTime()
6 local function viewer_cancelmove(self
)
8 self
:StopMovingOrSizing()
13 local function viewer_mousedown(self
, button
)
14 if button
== "LeftButton" then
20 local function viewer_closebutton(self
)
21 viewer
.text
:SetText("")
27 function QuestHelper
:ShowText(text
, title
, width
, border
, divide
)
28 local border
= border
or 8
29 local divide
= divide
or 4
31 if not frammis
[border
] then frammis
[border
] = {} end
32 viewer
= frammis
[border
][divide
]
33 local suffix
= string.format("_%d_%d", border
, divide
)
36 viewer
= CreateFrame("Frame", "QuestHelperTextViewer", nil) -- With no parent, this will always be visible.
37 viewer
:SetFrameStrata("FULLSCREEN_DIALOG")
38 viewer
:SetPoint("CENTER", UIParent
)
39 viewer
:EnableMouse(true)
40 viewer
:SetMovable(true)
41 viewer
:SetScript("OnMouseDown", viewer_mousedown
)
42 viewer
:SetScript("OnMouseUp", viewer_cancelmove
)
43 viewer
:SetScript("OnHide", viewer_cancelmove
)
45 -- This will cause it to be hidden if Esc is pressed.
46 table.insert(UISpecialFrames
, viewer
:GetName())
48 viewer
.title
= viewer
:CreateFontString()
49 viewer
.title
:SetFont(self
.font
.serif
, 14)
50 viewer
.title
:SetPoint("TOPLEFT", viewer
, border
, -border
)
51 viewer
.title
:SetPoint("RIGHT", viewer
, -border
, 0)
54 bgFile
= "Interface/Tooltips/UI-Tooltip-Background",
55 edgeFile
= "Interface/Tooltips/UI-Tooltip-Border",
59 insets
= { left
= 4, right
= 4, top
= 4, bottom
= 4 }})
60 viewer
:SetBackdropColor(0, 0, 0, 0.8)
61 viewer
:SetBackdropBorderColor(1, 1, 1, 0.7)
63 viewer
.scrollframe
= CreateFrame("ScrollFrame", "QuestHelperTextViewer_ScrollFrame" .. suffix
, viewer
, "UIPanelScrollFrameTemplate")
64 viewer
.scrollframe
:SetPoint("LEFT", viewer
, "LEFT", border
, 0)
65 viewer
.scrollframe
:SetPoint("TOP", viewer
.title
, "BOTTOM", 0, -divide
)
67 viewer
.scrollbar
= _G
["QuestHelperTextViewer_ScrollFrame" .. suffix
.. "ScrollBar"]
68 viewer
.scrollbar
:SetBackdrop({ -- Note: These settings are coppied from UIPanelScrollBarTemplateLightBorder in UIPanelTemplates.xml
69 edgeFile
= "Interface/Tooltips/UI-Tooltip-Border",
72 insets
= { left
= 0, right
= 0, top
= 5, bottom
= 5 }})
73 viewer
.scrollbar
:SetThumbTexture(self
:CreateIconTexture(viewer
.scrollbar
, 26)) -- Use the snazzy blue thumb
75 viewer
.closebutton
= CreateFrame("Button", "QuestHelperTextViewer_CloseButton" .. suffix
, viewer
, "UIPanelCloseButton")
76 viewer
.closebutton
:SetPoint("TOPRIGHT", viewer
)
77 viewer
.closebutton
:SetScript("OnClick", viewer_closebutton
)
79 viewer
.frame
= CreateFrame("Frame", "QuestHelperTextViewer_Frame" .. suffix
, viewer
.scrollframe
)
80 viewer
.scrollframe
:SetScrollChild(viewer
.frame
)
82 viewer
.text
= viewer
.frame
:CreateFontString()
83 viewer
.text
:SetFont(self
.font
.sans
, 12)
84 viewer
.text
:SetJustifyH("LEFT")
85 viewer
.text
:SetPoint("TOPLEFT", viewer
.frame
)
89 viewer
.title
:SetText(title
or "QuestHelper")
90 viewer
.text
:SetText(text
or "No text.")
91 viewer
.scrollframe
:SetVerticalScroll(0)
93 local w
= width
or math
.min(600, math
.max(100, viewer
.text
:GetStringWidth()))
94 viewer
.text
:SetWidth(w
)
95 viewer
:SetWidth(w
+border
* 2)
96 viewer
.scrollframe
:SetWidth(w
)
97 viewer
.frame
:SetWidth(w
)
99 local h
= math
.max(10, viewer
.text
:GetHeight())
100 local title_h
= viewer
.title
:GetHeight()
103 viewer
.frame
:SetHeight(400)
104 viewer
.scrollframe
:SetHeight(400)
105 viewer
:SetHeight(420+title_h
+border
* 2+divide
)
106 viewer
:SetWidth(w
+border
* 2 + 22)
107 viewer
.scrollbar
:Show()
109 viewer
.frame
:SetHeight(h
)
110 viewer
.scrollframe
:SetHeight(h
)
111 viewer
:SetHeight(h
+border
* 2 + divide
+title_h
)
112 viewer
.scrollbar
:Hide()
114 WoW Bug: For some reason, setting the thumb texture on the scrollbar causes the following scenario:
115 1. Display the viewer with scrollable text (eg /qh)
116 2. Display the viewer with smaller text (eg /qh help filter)
117 The second time the viewer is displayed, the close button doesn't show its normal state.
118 When you hover over it, the glow appears. If you press the left button over it, the depressed state appears.
119 If you drag off of it, then release, the normal state appears, and the button is fine until you repeat 1 & 2.
121 viewer
.closebutton
:SetButtonState("PUSHED") -- Workaround: there's a wierd quirk that's causing it to not show sometimes...
122 viewer
.closebutton
:SetButtonState("NORMAL") -- Workaround, part 2
125 frammis
[border
][divide
] = viewer