vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 TITAN_UISCALE_ID = "UIScale";
2 TITAN_UISCALE_FRAME_SHOW_TIME = 0.5;
3  
4 TITAN_UISCALE_MIN = 0.64;
5 TITAN_UISCALE_MAX = 1;
6 TITAN_UISCALE_STEP = 0.01;
7  
8 TITAN_PANELSCALE_MIN = 0.75;
9 TITAN_PANELSCALE_MAX = 1.25;
10 TITAN_PANELSCALE_STEP = 0.01;
11  
12 TITAN_FONTSCALE_MIN = 0.50;
13 TITAN_FONTSCALE_MAX = 2.00;
14 TITAN_FONTSCALE_STEP = 0.01;
15  
16 function TitanPanelUIScaleButton_OnLoad()
17 this.registry = {
18 id = TITAN_UISCALE_ID,
19 builtIn = 1,
20 version = TITAN_VERSION,
21 menuText = TITAN_UISCALE_MENU_TEXT,
22 tooltipTitle = TITAN_UISCALE_TOOLTIP,
23 tooltipTextFunction = "TitanPanelUIScaleButton_GetTooltipText",
24 icon = TITAN_ARTWORK_PATH.."TitanUIScale",
25 };
26 end
27  
28 function TitanPanelUIScaleButton_GetTooltipText()
29 local panelScaleText = TitanPanelUIScale_GetSCaleText(TitanPanelGetVar("Scale"));
30 local uiScaleText = TitanPanelUIScale_GetSCaleText(UIParent:GetScale());
31 local FontScaleText = TitanPanelUIScale_GetSCaleText(TitanPanelGetVar("FontScale"));
32  
33 return ""..
34 TITAN_UISCALE_TOOLTIP_VALUE_UI.."\t"..TitanUtils_GetHighlightText(uiScaleText).."\n"..
35 TITAN_UISCALE_TOOLTIP_VALUE_PANEL.."\t"..TitanUtils_GetHighlightText(panelScaleText).."\n"..
36 TITAN_UISCALE_TOOLTIP_VALUE_FONT.."\t"..TitanUtils_GetHighlightText(FontScaleText).."\n"..
37 TitanUtils_GetGreenText(TITAN_UISCALE_TOOLTIP_HINT1).."\n"..
38 TitanUtils_GetGreenText(TITAN_UISCALE_TOOLTIP_HINT2);
39 end
40  
41 function TitanPanelUIScaleControlSlider_OnEnter()
42 local uiScale = UIParent:GetScale();
43  
44 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_UI, TitanPanelUIScale_GetSCaleText(uiScale));
45 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
46 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
47 TitanUtils_StopFrameCounting(this:GetParent());
48 end
49  
50 function TitanPanelUIScaleControlSlider_OnLeave()
51 this.tooltipText = nil;
52 GameTooltip:Hide();
53 TitanUtils_StartFrameCounting(this:GetParent(), TITAN_UISCALE_FRAME_SHOW_TIME);
54 end
55  
56 function TitanPanelUIScaleControlSlider_OnShow()
57 local uiScale = UIParent:GetScale();
58 local min = TITAN_UISCALE_MIN;
59 local max = TITAN_UISCALE_MAX;
60 local step = TITAN_UISCALE_STEP;
61  
62 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(uiScale));
63 getglobal(this:GetName().."High"):SetText(TITAN_UISCALE_CONTROL_LOW_UI);
64 getglobal(this:GetName().."Low"):SetText(TITAN_UISCALE_CONTROL_HIGH_UI);
65 this:SetMinMaxValues(min, max);
66 this:SetValueStep(step);
67 this:SetValue(min + max - uiScale);
68 this.previousValue = this:GetValue();
69  
70 position = TitanUtils_GetRealPosition(TITAN_UISCALE_ID);
71  
72 TitanPanelUIScaleControlFrame:SetPoint("BOTTOMRIGHT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_UISCALE_ID) .."Button", "TOPRIGHT", 0, 0);
73 if (position == TITAN_PANEL_PLACE_TOP) then
74 TitanPanelUIScaleControlFrame:ClearAllPoints();
75 TitanPanelUIScaleControlFrame:SetPoint("TOPLEFT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_UISCALE_ID) .."Button", "BOTTOMLEFT", UIParent:GetRight() - TitanPanelUIScaleControlFrame:GetWidth(), -4);
76 else
77 TitanPanelUIScaleControlFrame:ClearAllPoints();
78 TitanPanelUIScaleControlFrame:SetPoint("BOTTOMLEFT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_UISCALE_ID) .."Button", "TOPLEFT", UIParent:GetRight() - TitanPanelUIScaleControlFrame:GetWidth(), 0);
79 end
80  
81 end
82  
83 function TitanPanelUIScaleControlSlider_OnValueChanged()
84 if (this:GetValue() ~= this.previousValue) then
85 this.previousValue = this:GetValue();
86  
87 -- Set UI scale
88 local min = TITAN_UISCALE_MIN;
89 local max = TITAN_UISCALE_MAX;
90 local uiScale = min + max - this:GetValue();
91 SetCVar("useUiScale", 1, USE_UISCALE);
92 SetCVar("uiScale", uiScale);
93  
94 -- Adjust panel scale
95 TitanPanel_SetScale();
96 TitanPanel_RefreshPanelButtons();
97  
98 -- Update slider value text
99 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(uiScale));
100  
101 -- Update GameTooltip
102 if (this.tooltipText) then
103 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_UI, TitanPanelUIScale_GetSCaleText(uiScale));
104 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
105 end
106 end
107 end
108  
109 function TitanPanelPanelScaleControlSlider_OnEnter()
110 local scale = TitanPanelGetVar("Scale");
111  
112 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_PANEL, TitanPanelUIScale_GetSCaleText(scale));
113 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
114 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
115 TitanUtils_StopFrameCounting(this:GetParent());
116 end
117  
118 function TitanPanelPanelScaleControlSlider_OnLeave()
119 this.tooltipText = nil;
120 GameTooltip:Hide();
121 TitanUtils_StartFrameCounting(this:GetParent(), TITAN_UISCALE_FRAME_SHOW_TIME);
122 end
123  
124 function TitanPanelPanelScaleControlSlider_OnShow()
125 local scale = TitanPanelGetVar("Scale");
126 local min = TITAN_PANELSCALE_MIN;
127 local max = TITAN_PANELSCALE_MAX;
128 local step = TITAN_PANELSCALE_STEP;
129  
130 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(scale));
131 getglobal(this:GetName().."High"):SetText(TITAN_UISCALE_CONTROL_LOW_PANEL);
132 getglobal(this:GetName().."Low"):SetText(TITAN_UISCALE_CONTROL_HIGH_PANEL);
133 this:SetMinMaxValues(min, max);
134 this:SetValueStep(step);
135 this:SetValue(min + max - scale);
136 this.previousValue = this:GetValue();
137 end
138  
139 function TitanPanelPanelScaleControlSlider_OnValueChanged()
140 if (this:GetValue() ~= this.previousValue) then
141 this.previousValue = this:GetValue();
142  
143 local position = 1;
144  
145 local i = TitanPanel_GetButtonNumber(TITAN_UISCALE_ID);
146 if TitanPanelSettings.Location[i] == "Bar" and TitanPanelGetVar("BothBars") then
147 position = 1;
148 elseif TitanPanelSettings.Location[i] == "Bar" then
149 position = TitanPanelGetVar("Position");
150 else
151 position = 2;
152 end
153  
154 -- Set panel scale
155 local min = TITAN_PANELSCALE_MIN;
156 local max = TITAN_PANELSCALE_MAX;
157 local scale = min + max - this:GetValue();
158 TitanPanelSetVar("Scale", scale);
159  
160 -- Adjust panel scale
161 TitanPanel_SetScale();
162 TitanPanel_RefreshPanelButtons();
163  
164 -- Adjust frame positions
165 TitanMovableFrame_MoveFrames(position);
166 TitanMovableFrame_AdjustBlizzardFrames();
167  
168 -- Update slider value text
169 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(scale));
170  
171 -- Update GameTooltip
172 if (this.tooltipText) then --??
173 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_PANEL, TitanPanelUIScale_GetSCaleText(scale));
174 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
175 end
176 end
177 end
178  
179 function TitanPanelFontScaleControlSlider_OnEnter()
180 local fontscale = TitanPanelGetVar("FontScale");
181  
182 if TitanPanelGetVar("DisableFont") then
183 fontscale = 1;
184 end
185 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_FONT, TitanPanelUIScale_GetSCaleText(fontscale));
186 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
187 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
188 TitanUtils_StopFrameCounting(this:GetParent());
189 end
190  
191 function TitanPanelFontScaleControlSlider_OnLeave()
192 if TitanPanelGetVar("DisableFont") then
193 fontscale = 1;
194 end
195 this.tooltipText = nil;
196 GameTooltip:Hide();
197 TitanUtils_StartFrameCounting(this:GetParent(), TITAN_UISCALE_FRAME_SHOW_TIME);
198 end
199  
200 function TitanPanelFontScaleControlSlider_OnShow()
201 local fontscale = TitanPanelGetVar("FontScale");
202 local min = TITAN_FONTSCALE_MIN;
203 local max = TITAN_FONTSCALE_MAX;
204 local step = TITAN_FONTSCALE_STEP;
205  
206 if TitanPanelGetVar("DisableFont") then
207 fontscale = 1;
208 end
209 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(fontscale));
210 getglobal(this:GetName().."High"):SetText(TITAN_UISCALE_CONTROL_LOW_FONT);
211 getglobal(this:GetName().."Low"):SetText(TITAN_UISCALE_CONTROL_HIGH_FONT);
212 this:SetMinMaxValues(min, max);
213 this:SetValueStep(step);
214 this:SetValue(min + max - fontscale);
215 this.previousValue = this:GetValue();
216 end
217  
218 function TitanPanelFontScaleControlSlider_OnValueChanged()
219 if TitanPanelGetVar("DisableFont") then
220 return;
221 end
222  
223 if (this:GetValue() ~= this.previousValue) then
224 this.previousValue = this:GetValue();
225  
226 local position = 1;
227  
228 local i = TitanPanel_GetButtonNumber(TITAN_UISCALE_ID);
229 if TitanPanelSettings.Location[i] == "Bar" and TitanPanelGetVar("BothBars") then
230 position = 1;
231 elseif TitanPanelSettings.Location[i] == "Bar" then
232 position = TitanPanelGetVar("Position");
233 else
234 position = 2;
235 end
236  
237 -- Set panel scale
238 local min = TITAN_FONTSCALE_MIN;
239 local max = TITAN_FONTSCALE_MAX;
240 local scale = min + max - this:GetValue();
241 TitanPanelSetVar("FontScale", scale);
242  
243 -- Adjust panel scale
244 TitanPanel_SetScale();
245 TitanPanel_RefreshPanelButtons();
246  
247 -- Adjust frame positions
248 TitanMovableFrame_MoveFrames(position);
249 TitanMovableFrame_AdjustBlizzardFrames();
250  
251 -- Update slider value text
252 getglobal(this:GetName().."Text"):SetText(TitanPanelUIScale_GetSCaleText(scale));
253  
254 -- Update GameTooltip
255 if (this.tooltipText) then --??
256 this.tooltipText = TitanOptionSlider_TooltipText(TITAN_UISCALE_CONTROL_TOOLTIP_FONT, TitanPanelUIScale_GetSCaleText(scale));
257 GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1);
258 end
259 end
260 end
261  
262  
263 function TitanPanelUIScale_GetSCaleText(scale)
264 return tostring(floor(100 * scale + 0.5)) .. "%";
265 end
266  
267 function TitanPanelUIScaleControlFrame_OnLoad()
268 getglobal(this:GetName().."UITitle"):SetText(TITAN_UISCALE_CONTROL_TITLE_UI);
269 getglobal(this:GetName().."PanelTitle"):SetText(TITAN_UISCALE_CONTROL_TITLE_PANEL);
270 getglobal(this:GetName().."FontTitle"):SetText(TITAN_UISCALE_CONTROL_TITLE_FONT);
271 this:SetBackdropBorderColor(1, 1, 1);
272 this:SetBackdropColor(0, 0, 0, 1);
273 end
274  
275 function TitanPanelUIScaleControlFrame_OnShow()
276 this:SetScale(UIParent:GetEffectiveScale());
277 end
278  
279 function TitanPanelUIScaleControlFrame_OnUpdate(elapsed)
280 TitanUtils_CheckFrameCounting(this, elapsed);
281 end
282  
283 function TitanPanelRightClickMenu_PrepareUIScaleMenu()
284 TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_UISCALE_ID].menuText);
285 TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_UISCALE_ID, TITAN_PANEL_MENU_FUNC_HIDE);
286 end