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 for i
= 1, #viewer
.text
do
22 viewer
.text
[i
]:SetText("")
29 function QuestHelper
:ShowText(text
, title
, width
, border
, divide
)
30 local border
= border
or 8
31 local divide
= divide
or 4
33 if type(text
) == "string" then text
= {text
} end
35 if not frammis
[border
] then frammis
[border
] = {} end
36 viewer
= frammis
[border
][divide
]
37 local suffix
= string.format("_%d_%d", border
, divide
)
40 viewer
= CreateFrame("Frame", "QuestHelperTextViewer", nil) -- With no parent, this will always be visible.
41 viewer
:SetFrameStrata("FULLSCREEN_DIALOG")
42 viewer
:SetPoint("CENTER", UIParent
)
43 viewer
:EnableMouse(true)
44 viewer
:SetMovable(true)
45 QH_Hook(viewer
, "OnMouseDown", viewer_mousedown
)
46 QH_Hook(viewer
, "OnMouseUp", viewer_cancelmove
)
47 QH_Hook(viewer
, "OnHide", viewer_cancelmove
)
49 -- This will cause it to be hidden if Esc is pressed.
50 table.insert(UISpecialFrames
, viewer
:GetName())
52 viewer
.title
= viewer
:CreateFontString()
53 viewer
.title
:SetFont(self
.font
.serif
, 14)
54 viewer
.title
:SetPoint("TOPLEFT", viewer
, border
, -border
)
55 viewer
.title
:SetPoint("RIGHT", viewer
, -border
, 0)
58 bgFile
= "Interface/Tooltips/UI-Tooltip-Background",
59 edgeFile
= "Interface/Tooltips/UI-Tooltip-Border",
63 insets
= { left
= 4, right
= 4, top
= 4, bottom
= 4 }})
64 viewer
:SetBackdropColor(0, 0, 0, 0.8)
65 viewer
:SetBackdropBorderColor(1, 1, 1, 0.7)
67 viewer
.scrollframe
= CreateFrame("ScrollFrame", "QuestHelperTextViewer_ScrollFrame" .. suffix
, viewer
, "UIPanelScrollFrameTemplate")
69 viewer
.scrollframe
:SetPoint("LEFT", viewer
, "LEFT", border
, 0)
70 viewer
.scrollframe
:SetPoint("TOP", viewer
.title
, "BOTTOM", 0, -divide
)
72 viewer
.scrollbar
= _G
["QuestHelperTextViewer_ScrollFrame" .. suffix
.. "ScrollBar"]
73 --QuestHelperTextViewer_ScrollFrameThumbTexture = self:CreateIconTexture(viewer.scrollbar, 26) -- Use the snazzy blue thumb
74 viewer
.scrollbar
:SetBackdrop({ -- Note: These settings are coppied from UIPanelScrollBarTemplateLightBorder in UIPanelTemplates.xml
75 edgeFile
= "Interface/Tooltips/UI-Tooltip-Border",
78 insets
= { left
= 0, right
= 0, top
= 5, bottom
= 5 }})
80 viewer
.closebutton
= CreateFrame("Button", "QuestHelperTextViewer_CloseButton" .. suffix
, viewer
, "UIPanelCloseButton")
81 viewer
.closebutton
:SetPoint("TOPRIGHT", viewer
)
82 QH_Hook(viewer
.closebutton
, "OnClick", viewer_closebutton
)
84 viewer
.frame
= CreateFrame("Frame", "QuestHelperTextViewer_Frame" .. suffix
, viewer
.scrollframe
)
85 viewer
.scrollframe
:SetScrollChild(viewer
.frame
)
92 if not viewer
.text
[i
] then
93 viewer
.text
[i
] = viewer
.frame
:CreateFontString()
94 viewer
.text
[i
]:SetFont(self
.font
.sans
, 12)
95 viewer
.text
[i
]:SetJustifyH("LEFT")
97 viewer
.text
[i
]:SetPoint("TOPLEFT", viewer
.text
[i
- 1], "BOTTOMLEFT")
99 viewer
.text
[i
]:SetPoint("TOPLEFT", viewer
.frame
)
103 viewer
.text
[i
]:Show()
104 viewer
.text
[i
]:SetText(text
[i
] or "No text.")
106 maxw
= math
.max(maxw
, viewer
.text
[i
]:GetStringWidth())
109 for i
= #text
+ 1, #viewer
.text
do
110 viewer
.text
[i
]:Hide()
114 viewer
.title
:SetText(title
or "QuestHelper")
115 viewer
.scrollframe
:SetVerticalScroll(0)
117 local w
= width
or math
.min(600, math
.max(100, maxw
))
118 for i
= 1, #viewer
.text
do
119 viewer
.text
[i
]:SetWidth(w
)
121 viewer
:SetWidth(w
+border
* 2)
122 viewer
.scrollframe
:SetWidth(w
)
123 viewer
.frame
:SetWidth(w
)
127 toth
= toth
+ viewer
.text
[i
]:GetHeight()
129 local h
= math
.max(10, toth
)
130 local title_h
= viewer
.title
:GetHeight()
133 viewer
.frame
:SetHeight(400)
134 viewer
.scrollframe
:SetHeight(400)
135 viewer
:SetHeight(420+title_h
+border
* 2+divide
)
136 viewer
:SetWidth(w
+border
* 2 + 22)
137 viewer
.scrollbar
:Show()
139 viewer
.frame
:SetHeight(h
)
140 viewer
.scrollframe
:SetHeight(h
)
141 viewer
:SetHeight(h
+border
* 2 + divide
+title_h
)
142 viewer
.scrollbar
:Hide()
144 WoW Bug: For some reason, setting the thumb texture on the scrollbar causes the following scenario:
145 1. Display the viewer with scrollable text (eg /qh)
146 2. Display the viewer with smaller text (eg /qh help filter)
147 The second time the viewer is displayed, the close button doesn't show its normal state.
148 When you hover over it, the glow appears. If you press the left button over it, the depressed state appears.
149 If you drag off of it, then release, the normal state appears, and the button is fine until you repeat 1 & 2.
151 viewer
.closebutton
:SetButtonState("PUSHED") -- Workaround: there's a wierd quirk that's causing it to not show sometimes...
152 viewer
.closebutton
:SetButtonState("NORMAL") -- Workaround, part 2
155 frammis
[border
][divide
] = viewer