Skip to content

Commit 61cc66c

Browse files
committed
Minor visual improvements to the config UI
1 parent d6f13b9 commit 61cc66c

15 files changed

+149
-81
lines changed

ImportExportUtilV2.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if C_Traits.GetLoadoutSerializationVersion() ~= LOADOUT_SERIALIZATION_VERSION th
44
--- @class TTT_NS
55
local ns = select(2, ...);
66

7-
--- @class TalentTreeTweaks_ImportExportUtilV2
7+
--- @class TTT_ImportExportUtilV2
88
local ImportExportUtil = {};
99
ns.ImportExportUtil = ImportExportUtil;
1010

SharedUtil.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--- @class TTT_NS
22
local ns = select(2, ...);
33

4-
--- @class TalentTreeTweaks_Util
4+
--- @class TTT_Util
55
local Util = {};
66
ns.Util = Util;
77
local L = ns.L;

config.lua

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,20 @@ do
226226

227227
--- @param text string
228228
--- @param tooltip string?
229+
--- @param indent number? # default 0
229230
--- @return SettingsListElementInitializer initializer
230-
function ConfigBuilderMixin:MakeHeader(text, tooltip)
231-
local initializer = Config:MakeHeader(text, tooltip);
231+
function ConfigBuilderMixin:MakeHeader(text, tooltip, indent)
232+
local initializer = Config:MakeHeader(text, tooltip, indent);
232233
initializer:AddShownPredicate(self.isExpanded);
233234

234235
return initializer;
235236
end
236237

237238
--- @param text string
239+
--- @param indent number? # default 0
238240
--- @return SettingsListElementInitializer initializer
239-
function ConfigBuilderMixin:MakeText(text)
240-
local initializer = Config:MakeText(text);
241+
function ConfigBuilderMixin:MakeText(text, indent)
242+
local initializer = Config:MakeText(text, indent);
241243
initializer:AddShownPredicate(self.isExpanded);
242244

243245
return initializer;
@@ -365,26 +367,55 @@ end
365367
do
366368
--- @param text string
367369
--- @param tooltip string?
370+
--- @param indent number? # default 0
368371
--- @return SettingsListElementInitializer
369-
function Config:MakeHeader(text, tooltip)
370-
local headerInitializer = CreateSettingsListSectionHeaderInitializer(text, tooltip);
372+
function Config:MakeHeader(text, tooltip, indent)
373+
local data = { name = text, tooltip = tooltip, indent = indent or 0 };
374+
--- @type SettingsListElementInitializer
375+
local headerInitializer = Settings.CreateElementInitializer("TalentTreeTweaks_SettingsHeaderTemplate", data);
376+
371377
self.layout:AddInitializer(headerInitializer);
372378

373379
return headerInitializer;
374380
end
375381

376-
local heightCalculator = UIParent:CreateFontString(nil, "ARTWORK", "GameFontNormal");
377-
heightCalculator:SetWidth(635);
382+
local calculateHeight;
383+
do
384+
local heightCalculator = UIParent:CreateFontString(nil, "ARTWORK", "GameFontNormal");
385+
local deferrer = CreateFrame("Frame");
386+
deferrer:Hide();
387+
deferrer.callbacks = {};
388+
deferrer:SetScript("OnUpdate", function()
389+
for _, callback in pairs(deferrer.callbacks) do
390+
securecallfunction(callback);
391+
end
392+
deferrer.callbacks = {};
393+
end);
394+
function deferrer:Defer(callback)
395+
table.insert(self.callbacks, callback);
396+
self:Show();
397+
end
398+
calculateHeight = function(data, deferred)
399+
local text, indent = data.name, data.indent;
400+
heightCalculator:SetWidth(635 - (indent * 15));
401+
heightCalculator:SetText(text);
402+
403+
data.extent = heightCalculator:GetStringHeight();
404+
if not deferred then
405+
deferrer:Defer(function() calculateHeight(data, true); end);
406+
end
407+
end
408+
end
378409

379410
--- @param text string
411+
--- @param indent number? # default 0
380412
--- @return SettingsListElementInitializer
381-
function Config:MakeText(text)
382-
heightCalculator:SetText(text);
383-
413+
function Config:MakeText(text, indent)
384414
local data = {
385415
name = text,
386-
extent = heightCalculator:GetStringHeight(),
416+
indent = indent or 0,
387417
};
418+
calculateHeight(data);
388419
--- @type SettingsListElementInitializer
389420
local textInitializer = Settings.CreateElementInitializer("TalentTreeTweaks_SettingsTextTemplate", data);
390421

@@ -564,6 +595,8 @@ do
564595

565596
return initializer:GetExtent();
566597
end
598+
599+
frame:EvaluateVisibility(self.data.expanded);
567600
end
568601

569602
self.layout:AddInitializer(expandInitializer);
@@ -606,7 +639,7 @@ do
606639
function Config:MakeDonationPrompt(layout)
607640
self:MakeText(L["Addon development takes a large amount of time and effort. If you enjoy using Talent Tree Tweaks, please consider supporting its development by donating. Your support helps ensure the continued improvement and maintenance of the addon. Thank you for your generosity!"]);
608641

609-
local function onClick(buttonIndex)
642+
local function onClick(_, buttonIndex)
610643
if buttonIndex == 1 then
611644
ns.Util:CopyText("https://www.paypal.com/cgi-bin/webscr?hosted_button_id=C8HP9WVKPCL8C&item_name=Talent+Tree+Tweaks&cmd=_s-xclick");
612645
else
@@ -784,6 +817,25 @@ do
784817
self.Text:SetText(data.name);
785818
self.Text:SetHeight(data.extent);
786819
self:SetHeight(data.extent);
820+
local indent = data.indent or 0;
821+
self.Text:SetPoint('TOPLEFT', (7 + (indent * 15)), 0);
822+
end
823+
end
824+
825+
TalentTreeTweaks_SettingsHeaderMixin = CreateFromMixins(DefaultTooltipMixin);
826+
do
827+
--- @class TTT_Config_HeaderMixin
828+
local mixin = TalentTreeTweaks_SettingsHeaderMixin;
829+
830+
function mixin:Init(initializer)
831+
local data = initializer:GetData();
832+
self.Title:SetTextToFit(data.name);
833+
local indent = data.indent or 0;
834+
self.Title:SetPoint('TOPLEFT', (7 + (indent * 15)), -16);
835+
836+
self:SetCustomTooltipAnchoring(self.Title, "ANCHOR_RIGHT");
837+
838+
self:SetTooltipFunc(function() Settings.InitTooltip(initializer:GetName(), initializer:GetTooltip()) end);
787839
end
788840
end
789841
end

core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _G.TalentTreeTweaks = ns;
77
if not _G.TTT then _G.TTT = ns; end
88
--@end-debug@
99

10-
--- @class TalentTreeTweaks_Main: AceAddon, AceConsole-3.0, AceHook-3.0, AceEvent-3.0
10+
--- @class TTT_Main: AceAddon, AceConsole-3.0, AceHook-3.0, AceEvent-3.0
1111
local Main = LibStub('AceAddon-3.0'):NewAddon(name, 'AceConsole-3.0', 'AceHook-3.0', 'AceEvent-3.0');
1212
if not Main then return; end
1313
ns.Main = Main;

modules/autoPurchaseGenericTalents.lua

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -180,131 +180,136 @@ function Module:BuildConfig(configBuilder, db)
180180
do
181181
local function isLoaded() return not not self.skyridingConfigID; end;
182182
local function isNotLoaded() return not isLoaded; end;
183-
configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_DRAGONRIDING_TITLE);
184-
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the Skyriding system on this character yet.']);
183+
local header = configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_DRAGONRIDING_TITLE, nil, 2);
184+
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the Skyriding system on this character yet.'], 2);
185185
loading:AddShownPredicate(isNotLoaded);
186186
configBuilder:MakeCheckbox(
187187
ENABLE,
188188
'skyridingEnabled',
189189
L['Automatically purchase %s talents when you have enough currency.']:format(GENERIC_TRAIT_FRAME_DRAGONRIDING_TITLE)
190-
);
190+
):SetParentInitializer(header);
191191
configBuilder:MakeButton(
192192
L['Toggle UI'],
193193
function() self:ToggleTreeUI(SKYRIDING_TREE_ID); end,
194194
L['Toggle the %s UI to view and adjust talents.']:format(GENERIC_TRAIT_FRAME_DRAGONRIDING_TITLE)
195-
):AddModifyPredicate(isLoaded);
195+
):SetParentInitializer(header, isLoaded);
196196
configBuilder:MakeDropdown(
197197
L['Auto Ride Along'],
198198
'rideAlong',
199199
L['Automatically enable/disable Ride Along the first time you log in on a character.'],
200200
{
201-
{ value = CHOICE_NODE_OPTION_1, text = L['Enable Ride Along'], },
202-
{ value = CHOICE_NODE_OPTION_2, text = L['Disable Ride Along'], },
203-
{ value = CHOICE_NODE_NOT_SET, text = L['Do Nothing'], },
201+
{ value = CHOICE_NODE_OPTION_1, text = L['Enable Ride Along'] },
202+
{ value = CHOICE_NODE_OPTION_2, text = L['Disable Ride Along'] },
203+
{ value = CHOICE_NODE_NOT_SET, text = L['Do Nothing'] },
204204
},
205205
setEnabledTreeIDs
206-
);
206+
):SetParentInitializer(header);
207207
configBuilder:MakeButton(
208208
L['Reset Ride Along Cache'],
209209
function()
210210
self.db.rideAlongCache = {};
211211
self:DefferPurchase();
212212
end,
213213
L['Reset the Ride Along cache, so all characters will match the current setting on login.']
214-
);
214+
):SetParentInitializer(header);
215215
configBuilder:MakeDropdown(
216216
L['Auto Surge Choice'],
217217
'surge',
218218
L['Automatically pick Whirling Surge/Lightning Surge the first time you log in on a character.'],
219219
{
220-
{ value = CHOICE_NODE_OPTION_1, text = StripHyperlinks(C_Spell.GetSpellLink(WHIRLING_SURGE_SPELL_ID)) or 'Whirling Surge', },
221-
{ value = CHOICE_NODE_OPTION_2, text = StripHyperlinks(C_Spell.GetSpellLink(LIGHTNING_SURGE_SPELL_ID)) or 'Lightning Surge', },
222-
{ value = CHOICE_NODE_NOT_SET, text = L['Do Nothing'], },
220+
{ value = CHOICE_NODE_OPTION_1, text = StripHyperlinks(C_Spell.GetSpellLink(WHIRLING_SURGE_SPELL_ID)) or 'Whirling Surge' },
221+
{ value = CHOICE_NODE_OPTION_2, text = StripHyperlinks(C_Spell.GetSpellLink(LIGHTNING_SURGE_SPELL_ID)) or 'Lightning Surge' },
222+
{ value = CHOICE_NODE_NOT_SET, text = L['Do Nothing'] },
223223
},
224224
setEnabledTreeIDs
225-
);
225+
):SetParentInitializer(header);
226226
configBuilder:MakeButton(
227227
L['Reset Surge Cache'],
228228
function()
229229
self.db.surgeCache = {};
230230
self:DefferPurchase();
231231
end,
232232
L['Reset the Surge cache, so all characters will match the current setting on login.']
233-
);
233+
):SetParentInitializer(header);
234234
end
235235
do
236236
local function isLoaded() return not not self:GetLemixConfigID(); end;
237237
local function isNotLoaded() return not isLoaded(); end;
238238
local function isLemix() return IS_LEMIX; end;
239-
configBuilder:MakeHeader(L['Legion Remix: Limits Unbound']):AddShownPredicate(isLemix);
240-
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked Legion Remix artifact traits yet.']);
239+
local header = configBuilder:MakeHeader(L['Legion Remix: Limits Unbound'], nil, 2)
240+
header:AddShownPredicate(isLemix);
241+
242+
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked Legion Remix artifact traits yet.'], 2);
241243
loading:AddShownPredicate(isNotLoaded);
242244
loading:AddShownPredicate(isLemix);
243245

244-
configBuilder:MakeCheckbox(
246+
local enabled = configBuilder:MakeCheckbox(
245247
ENABLE,
246248
'lemixLimitsUnboundEnabled',
247249
L['Automatically upgrade the final Limits Unbound talent when you have enough currency.']
248-
):AddShownPredicate(isLemix);
250+
);
251+
enabled:AddShownPredicate(isLemix);
252+
enabled:SetParentInitializer(header);
253+
249254
local openUI = configBuilder:MakeButton(
250255
L['Open Artifact Traits UI'],
251256
function() SocketInventoryItem(16); end,
252257
L['Open the Legion Remix Artifact traits UI to view and adjust talents.']
253258
);
254-
openUI:AddModifyPredicate(isLoaded)
259+
openUI:SetParentInitializer(header, isLoaded)
255260
openUI:AddShownPredicate(isLemix);
256261
end
257262
do
258263
local function isLoaded() return not not self.reshiiWrapsConfigID; end;
259264
local function isNotLoaded() return not isLoaded(); end;
260-
configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE);
261-
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the %s system on this character yet.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE));
265+
local header = configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE, nil, 2);
266+
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the %s system on this character yet.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE), 2);
262267
loading:AddShownPredicate(isNotLoaded);
263268
configBuilder:MakeCheckbox(
264269
ENABLE,
265270
'reshiiWrapsEnabled',
266271
L['Automatically purchase %s talents when you have enough currency.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE)
267-
);
272+
):SetParentInitializer(header);
268273
configBuilder:MakeButton(
269274
L['Toggle UI'],
270275
function() self:ToggleTreeUI(RESHII_WRAPS_TREE_ID); end,
271276
L['Toggle the %s UI to view and adjust talents.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE)
272-
):AddModifyPredicate(isLoaded);
277+
):SetParentInitializer(header, isLoaded);
273278
end
274279
do
275280
local HORRIFIC_VISIONS_TITLE = SPLASH_BATTLEFORAZEROTH_8_3_0_FEATURE1_TITLE or L['Horrific Visions'];
276281
local function isLoaded() return not not self.horrificVisionsConfigID; end;
277282
local function isNotLoaded() return not isLoaded(); end;
278-
configBuilder:MakeHeader(HORRIFIC_VISIONS_TITLE);
279-
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the Horrific Visions system on this character yet.']);
283+
local header = configBuilder:MakeHeader(HORRIFIC_VISIONS_TITLE, nil, 2);
284+
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the Horrific Visions system on this character yet.'], 2);
280285
loading:AddShownPredicate(isNotLoaded);
281286
configBuilder:MakeCheckbox(
282287
ENABLE,
283288
'horrificVisionsEnabled',
284289
L['Automatically purchase Horrific Visions talents when you have enough currency.']
285-
);
290+
):SetParentInitializer(header);
286291
configBuilder:MakeButton(
287292
L['Toggle UI'],
288293
function() self:ToggleTreeUI(HORRIFIC_VISIONS_TREE_ID); end,
289294
L['Toggle the %s UI to view and adjust talents.']:format(HORRIFIC_VISIONS_TITLE)
290-
):AddModifyPredicate(isLoaded);
295+
):SetParentInitializer(header, isLoaded);
291296
end
292297
do
293298
local function isLoaded() return not not self.overchargedTitanConsoleConfigID; end;
294299
local function isNotLoaded() return not isLoaded(); end;
295-
configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE);
296-
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the %s system on this character yet.']:format(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE));
300+
local header = configBuilder:MakeHeader(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE, nil, 2);
301+
local loading = configBuilder:MakeText(L['Loading...'] .. '\n' .. L['You have not unlocked the %s system on this character yet.']:format(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE), 2);
297302
loading:AddShownPredicate(isNotLoaded);
298303
configBuilder:MakeCheckbox(
299304
ENABLE,
300305
'overchargedTitanConsoleEnabled',
301306
L['Automatically purchase %s talents when you have enough currency.']:format(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE)
302-
);
307+
):SetParentInitializer(header);
303308
configBuilder:MakeButton(
304309
L['Toggle UI'],
305310
function() self:ToggleTreeUI(OVERCHARGED_TITAN_CONSOLE_TREE_ID); end,
306311
L['Toggle the %s UI to view and adjust talents.']:format(GENERIC_TRAIT_FRAME_TITAN_CONSOLE_TITLE)
307-
):AddModifyPredicate(isLoaded);
312+
):SetParentInitializer(header, isLoaded);
308313
end
309314
end
310315

modules/copyTalentButtonInfo.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local Main = TTT.Main;
55
local Util = TTT.Util;
66
local L = TTT.L;
77

8-
--- @class TalentTreeTweaks_CopyTalentButtonInfo: TTT_Module, AceHook-3.0, AceEvent-3.0
8+
--- @class TTT_CopyTalentButtonInfo: TTT_Module, AceHook-3.0, AceEvent-3.0
99
local Module = Main:NewModule('CopyTalentButtonInfo', 'AceHook-3.0', 'AceEvent-3.0');
1010

1111
function Module:OnInitialize()

modules/debugNodeInfo.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function Module:BuildConfig(configBuilder, db)
7979
};
8080
configBuilder:SetDefaults(defaults, true);
8181

82-
configBuilder:MakeText(L['You can toggle any of the following on/off to enable/disable the integration with that debug tool.']);
82+
configBuilder:MakeText(L['You can toggle any of the following on/off to enable/disable the integration with that debug tool.'], 2);
8383

8484
configBuilder:MakeCheckbox(
8585
'/tinspect',

modules/exportInspectedBuild.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
--- @class TTT_NS
22
local TTT = select(2, ...);
33

4-
--- @type TalentTreeTweaks_Main
54
local Main = TTT.Main;
6-
--- @type TalentTreeTweaks_Util
75
local Util = TTT.Util;
86
local L = TTT.L;
97

@@ -12,7 +10,7 @@ local ChatFrame_OpenChat = ChatFrameUtil and ChatFrameUtil.OpenChat or ChatFrame
1210

1311
local LEVEL_CAP = 80;
1412

15-
--- @class TTT_ExportInspectedBuild: AceModule, AceHook-3.0, AceEvent-3.0
13+
--- @class TTT_ExportInspectedBuild: TTT_Module, AceHook-3.0, AceEvent-3.0
1614
local Module = Main:NewModule('ExportInspectedBuild', 'AceHook-3.0', 'AceEvent-3.0');
1715

1816
--- @param unit UnitToken

modules/heroTalents.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local Main = TTT.Main;
55
local Util = TTT.Util;
66
local L = TTT.L;
77

8-
--- @class TTT_HeroTalents: AceModule, AceHook-3.0
8+
--- @class TTT_HeroTalents: TTT_Module, AceHook-3.0
99
local Module = Main:NewModule('HeroTalents', 'AceHook-3.0');
1010

1111
local function RunScript(frame, script, ...)

0 commit comments

Comments
 (0)