Skip to content

Commit 22b9774

Browse files
committed
Minor visual improvements to the config UI
1 parent 388e985 commit 22b9774

File tree

5 files changed

+76
-13
lines changed

5 files changed

+76
-13
lines changed

config.lua

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ do
218218

219219
--- @param text string
220220
--- @param tooltip string?
221+
--- @param indent number? # default 0
221222
--- @return SettingsListElementInitializer initializer
222-
function ConfigBuilderMixin:MakeHeader(text, tooltip)
223-
local initializer = Config:MakeHeader(text, tooltip);
223+
function ConfigBuilderMixin:MakeHeader(text, tooltip, indent)
224+
local initializer = Config:MakeHeader(text, tooltip, indent);
224225
initializer:AddShownPredicate(self.isExpanded);
225226

226227
return initializer;
@@ -358,28 +359,53 @@ end
358359
do
359360
--- @param text string
360361
--- @param tooltip string?
362+
--- @param indent number? # default 0
361363
--- @return SettingsListElementInitializer
362-
function Config:MakeHeader(text, tooltip)
363-
local headerInitializer = CreateSettingsListSectionHeaderInitializer(text, tooltip);
364-
self.layout:AddInitializer(headerInitializer);
364+
function Config:MakeHeader(text, tooltip, indent)
365+
local data = { name = text, tooltip = tooltip, indent = indent or 0 };
366+
--- @type SettingsListElementInitializer
367+
local headerInitializer = Settings.CreateElementInitializer("MythicPlusTweaks_SettingsHeaderTemplate", data);
365368

366369
return headerInitializer;
367370
end
368371

369-
local heightCalculator = UIParent:CreateFontString(nil, "ARTWORK", "GameFontNormal");
372+
local calculateHeight;
373+
do
374+
local heightCalculator = UIParent:CreateFontString(nil, "ARTWORK", "GameFontNormal");
375+
local deferrer = CreateFrame("Frame");
376+
deferrer:Hide();
377+
deferrer.callbacks = {};
378+
deferrer:SetScript("OnUpdate", function()
379+
for _, callback in pairs(deferrer.callbacks) do
380+
securecallfunction(callback);
381+
end
382+
deferrer.callbacks = {};
383+
end);
384+
function deferrer:Defer(callback)
385+
table.insert(self.callbacks, callback);
386+
self:Show();
387+
end
388+
calculateHeight = function(data, deferred)
389+
local text, indent = data.name, data.indent;
390+
heightCalculator:SetWidth(635 - (indent * 15));
391+
heightCalculator:SetText(text);
392+
393+
data.extent = heightCalculator:GetStringHeight();
394+
if not deferred then
395+
deferrer:Defer(function() calculateHeight(data, true); end);
396+
end
397+
end
398+
end
370399

371400
--- @param text string
372401
--- @param indent number? # default 0
373402
--- @return SettingsListElementInitializer
374403
function Config:MakeText(text, indent)
375-
heightCalculator:SetWidth(635 - (indent or 0));
376-
heightCalculator:SetText(text);
377-
378404
local data = {
379405
name = text,
380-
extent = heightCalculator:GetStringHeight(),
381406
indent = indent or 0,
382407
};
408+
calculateHeight(data);
383409
--- @type SettingsListElementInitializer
384410
local textInitializer = Settings.CreateElementInitializer("MythicPlusTweaks_SettingsTextTemplate", data);
385411

@@ -785,4 +811,21 @@ do
785811
self.Text:SetPoint('TOPLEFT', (7 + (indent * 15)), 0);
786812
end
787813
end
814+
815+
MythicPlusTweaks_SettingsHeaderMixin = CreateFromMixins(DefaultTooltipMixin);
816+
do
817+
--- @class MPT_Config_HeaderMixin
818+
local mixin = MythicPlusTweaks_SettingsHeaderMixin;
819+
820+
function mixin:Init(initializer)
821+
local data = initializer:GetData();
822+
self.Title:SetTextToFit(data.name);
823+
local indent = data.indent or 0;
824+
self.Title:SetPoint('TOPLEFT', (7 + (indent * 15)), -16);
825+
826+
self:SetCustomTooltipAnchoring(self.Title, "ANCHOR_RIGHT");
827+
828+
self:SetTooltipFunc(function() Settings.InitTooltip(initializer:GetName(), initializer:GetTooltip()) end);
829+
end
830+
end
788831
end

modules/dungeonTeleports.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ function Module:BuildConfig(configBuilder, db)
126126
}
127127
);
128128
initializer:AddModifyPredicate(function() return self.db.showAlternates; end);
129+
130+
return initializer;
129131
end
130132
addAlternateOption(
131133
TYPE_DUNGEON_PORTAL,
@@ -142,7 +144,7 @@ function Module:BuildConfig(configBuilder, db)
142144
'Class teleports',
143145
'Show class teleports as an alternative teleport. (Mage portals, Druid Dreamwalk, etc.)'
144146
);
145-
addAlternateOption(
147+
local hearthstone = addAlternateOption(
146148
TYPE_HEARTHSTONE,
147149
'Hearthstone',
148150
'Show hearthstone as an alternative teleport. Only some specific locations are supported. Includes Shaman Astral Recall.'
@@ -151,7 +153,7 @@ function Module:BuildConfig(configBuilder, db)
151153
'Show a random hearthstone',
152154
'shuffleSharedCooldown',
153155
'Shows a random hearthstone, if a hearthstone would show up, and you have multiple toys'
154-
);
156+
):SetParentInitializer(hearthstone);
155157
end
156158

157159
function Module:InitializeButtonPools()

modules/keystoneSharingAddons/_keystoneSharing-core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Module:BuildConfig(configBuilder, db)
6161
):AddShownPredicate(function() return not self:IsEnabled(); end);
6262
configBuilder:MakeText(WHITE_FONT_COLOR:WrapTextInColorCode(
6363
'LibOpenRaid has been embedded into this addon, which allows various addons to use the same data sharing that Details! includes by default. This makes it a popular choice for fetching keystone information from your party/raid and guild members. Addons making use of this, include REKeys, PortaParty, and others.'
64-
), 1);
64+
), 2);
6565
configBuilder:MakeCheckbox(
6666
'Share alt keystones',
6767
'shareAlts',

settingsTemplates.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,19 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
5858
</Layer>
5959
</Layers>
6060
</Frame>
61+
<Frame name="MythicPlusTweaks_SettingsHeaderTemplate" mixin="MythicPlusTweaks_SettingsHeaderMixin" virtual="true">
62+
<Size y="45"/>
63+
<Layers>
64+
<Layer level="OVERLAY">
65+
<FontString parentKey="Title" inherits="GameFontHighlightLarge" justifyH="LEFT" justifyV="TOP">
66+
<Anchors>
67+
<Anchor point="TOPLEFT" x="7" y="-16"/>
68+
</Anchors>
69+
</FontString>
70+
</Layer>
71+
</Layers>
72+
<Scripts>
73+
<OnLoad method="OnLoad"/>
74+
</Scripts>
75+
</Frame>
6176
</Ui>

types.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
--- @class MPT_Config_TextMixin: Frame, DefaultTooltipMixin
3333
--- @field Text FontString
3434

35+
--- @class MPT_Config_HeaderMixin: Frame, DefaultTooltipMixin
36+
--- @field Title FontString
37+
3538
--- @class MPT_Config_SettingData
3639
--- @field setting AddOnSettingMixin
3740
--- @field name string

0 commit comments

Comments
 (0)