Skip to content

Commit 692178e

Browse files
committed
Added a button in the addon settins UI to open the Collections UI.
Added an option to the Collections UI, to treat "From Another Item" as collected
1 parent 3a3d701 commit 692178e

File tree

3 files changed

+122
-42
lines changed

3 files changed

+122
-42
lines changed

TransmogUpgradeMaster.lua

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ns.core = TUM
1212
TUM.data = ns.data
1313
--- @type TransmogUpgradeMasterConfig
1414
TUM.Config = ns.Config
15-
local settingKeys = TUM.Config.settingKeys
1615

1716
--- @alias TUM_LearnedFromOtherItem "learnedFromOtherItem"
1817
local LEARNED_FROM_OTHER_ITEM = 'learnedFromOtherItem'
@@ -72,14 +71,14 @@ EventUtil.ContinueOnAddOnLoaded(name, function()
7271
return;
7372
end
7473

75-
TUM.UI:SetShown(not TUM.UI:IsShown());
74+
TUM.UI:ToggleUI();
7675
end
7776
end)
7877

7978
do
8079
function TransmogUpgradeMaster_OnAddonCompartmentClick(_, mouseButton)
8180
if mouseButton == 'LeftButton' then
82-
TUM.UI:SetShown(not TUM.UI:IsShown());
81+
TUM.UI:ToggleUI();
8382
else
8483
TUM.Config:OpenSettings();
8584
end
@@ -296,9 +295,9 @@ local modifierFunctions = {
296295
--- @param isCollected boolean
297296
function TUM:AddTooltipLine(tooltip, text, isCollected, fromOtherItem)
298297
local modifierSetting =
299-
(isCollected and self.db[settingKeys.showCollectedModifierKey])
300-
or (fromOtherItem and self.db[settingKeys.showCollectedFromOtherItemModifierKey])
301-
or (self.db[settingKeys.showUncollectedModifierKey])
298+
(isCollected and self.db.showCollectedModifierKey)
299+
or (fromOtherItem and self.db.showCollectedFromOtherItemModifierKey)
300+
or (self.db.showUncollectedModifierKey)
302301
local modifierFunction = modifierFunctions[modifierSetting]
303302
if not modifierFunction or not modifierFunction() then
304303
return
@@ -313,7 +312,7 @@ end
313312
--- @param tooltip GameTooltip
314313
--- @param text string
315314
function TUM:AddDebugLine(tooltip, text)
316-
if not self.db[settingKeys.debug] then return end
315+
if not self.db.debug then return end
317316

318317
tooltip:AddDoubleLine('<TUM Debug>', text, 1, 0.5, 0, 1, 1, 1)
319318
end
@@ -561,11 +560,11 @@ function TUM:HandleTooltip(tooltip, tooltipData)
561560
end
562561
end
563562

564-
if modifierFunctions[self.db[settingKeys.showWarbandCatalystInfoModifierKey]]() and self:CanSendItemToAlt(itemLink, tooltipData) then
563+
if modifierFunctions[self.db.showWarbandCatalystInfoModifierKey]() and self:CanSendItemToAlt(itemLink, tooltipData) then
565564
local catalystClassList = {}
566565
local catalystUpgradeClassList = {}
567566
for classID = 1, GetNumClasses() do
568-
if classID ~= playerClassID and self.db[settingKeys.warbandCatalystClassList][classID] then
567+
if classID ~= playerClassID and self.db.warbandCatalystClassList[classID] then
569568
local classResult = self:IsAppearanceMissing(itemLink, classID)
570569
if classResult.catalystAppearanceMissing then
571570
table.insert(catalystClassList, classID)
@@ -709,7 +708,7 @@ function TUM:HandleCatalystInteraction()
709708
local isFree = not ItemInteractionFrame:UsesCharges() and not ItemInteractionFrame:CostsCurrency()
710709
if not isConversion then return end
711710

712-
local setting = self.db[settingKeys.autoConfirmCatalyst]
711+
local setting = self.db.autoConfirmCatalyst
713712
if
714713
setting == self.Config.autoConfirmCatalystOptions.always
715714
or (setting == self.Config.autoConfirmCatalystOptions.previousSeason and isFree)

collectionUi.lua

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,60 @@ function UI:Init()
7272
titleBar:SetPoint('BOTTOMRIGHT', self, 'TOPRIGHT', 0, -32);
7373
end
7474

75+
local settings = CreateFrame('DropdownButton', nil, self);
76+
self.Settings = settings;
77+
do
78+
settings:SetFrameStrata('HIGH');
79+
settings:SetPoint('RIGHT', self.TitleBar, 'RIGHT', -20, 3);
80+
settings:SetSize(32, 32);
81+
do -- icon
82+
settings.atlasKey = 'GM-icon-settings';
83+
settings:SetNormalAtlas(settings.atlasKey);
84+
Mixin(settings, ButtonStateBehaviorMixin);
85+
function settings:OnButtonStateChanged()
86+
local atlas = self.atlasKey;
87+
if self:IsDownOver() or self:IsOver() then
88+
atlas = atlas .. '-hover';
89+
elseif self:IsDown() then
90+
atlas = atlas .. '-pressed';
91+
end
92+
93+
self:GetNormalTexture():SetAtlas(atlas, TextureKitConstants.IgnoreAtlasSize);
94+
end
95+
96+
settings:OnLoad();
97+
settings:HookScript('OnEnter', settings.OnEnter);
98+
settings:HookScript('OnLeave', settings.OnLeave);
99+
settings:HookScript('OnMouseDown', settings.OnMouseDown);
100+
settings:HookScript('OnMouseUp', settings.OnMouseUp);
101+
end
102+
103+
settings:HookScript('OnEnter', function()
104+
GameTooltip:SetOwner(settings, 'ANCHOR_TOPRIGHT');
105+
GameTooltip:SetText('Settings');
106+
GameTooltip_AddInstructionLine(GameTooltip, CreateAtlasMarkup('NPE_LeftClick', 18, 18) .. ' to open settings');
107+
GameTooltip:Show();
108+
end);
109+
settings:HookScript('OnLeave', function()
110+
GameTooltip:Hide();
111+
end);
112+
--- @param rootDescription RootMenuDescriptionProxy
113+
settings:SetupMenu(function(_, rootDescription)
114+
rootDescription:CreateButton(CreateAtlasMarkup('GM-icon-settings', 20, 20) .. ' Open General TUM Settings', function() TUM.Config:OpenSettings(); end);
115+
rootDescription:CreateTitle('Collection UI Settings');
116+
rootDescription:CreateCheckbox(
117+
'Treat "From Another Item" as collected',
118+
function()
119+
return TUM.db.UI_treatOtherItemAsCollected;
120+
end,
121+
function()
122+
TUM.db.UI_treatOtherItemAsCollected = not TUM.db.UI_treatOtherItemAsCollected;
123+
UI.deferNewResult = true;
124+
end
125+
);
126+
end);
127+
end
128+
75129
local classDropdown = CreateFrame('DropdownButton', nil, self, 'WowStyle1DropdownTemplate');
76130
self.classDropdown = classDropdown;
77131
do
@@ -278,10 +332,6 @@ function UI:Init()
278332
headers:SetHeight(1);
279333
headers.Background:Hide();
280334
headers.TopTileStreaks:Hide();
281-
--[[
282-
Future ideas:
283-
- Add a spyglass icon to the header, clicking it will open Dressing Room showing the relevant item set
284-
--]]
285335

286336
local magnifyingGlassAtlas = 'common-search-magnifyingglass'
287337

@@ -337,10 +387,7 @@ function UI:Init()
337387
self.rows = {};
338388
--- @param column TUM_UI_Column
339389
local function OnEnter(column)
340-
--[[
341-
Future ideas:
342-
- Add a model viewer to the tooltip, to show the item appearance
343-
--]]
390+
if column.isCollected then return; end
344391
GameTooltip:SetOwner(column, 'ANCHOR_CURSOR_RIGHT');
345392
GameTooltip:AddLine('Transmog Upgrade Master');
346393
if column.results and next(column.results) then
@@ -393,6 +440,8 @@ function UI:Init()
393440
column.slot = slot;
394441
--- @type nil|TUM_UI_ResultData[]
395442
column.results = nil; -- will be filled later when results are available
443+
--- @type boolean|'learnedFromOtherItem'|nil
444+
column.isCollected = nil;
396445

397446
if j ~= 1 then
398447
column:SetScript('OnEnter', OnEnter)
@@ -424,6 +473,10 @@ function UI:Init()
424473
end
425474
end
426475

476+
function UI:ToggleUI()
477+
self:SetShown(not self:IsShown());
478+
end
479+
427480
function UI:RegisterIntoBlizzMove()
428481
--- @type BlizzMoveAPI?
429482
local BlizzMoveAPI = BlizzMoveAPI; ---@diagnostic disable-line: undefined-global
@@ -482,6 +535,9 @@ function UI:OnUpdate()
482535
local results = self.results and self.results[slot] and self.results[slot][tier];
483536
column.results = results;
484537
column.isCollected = TUM:IsCatalystItemCollected(self.currentSeason, self.currentClass, slot, tier);
538+
if TUM.db.UI_treatOtherItemAsCollected and 'learnedFromOtherItem' == column.isCollected then
539+
column.isCollected = true;
540+
end
485541

486542
column.Text:ClearPointsOffset()
487543
if true == column.isCollected then

config.lua

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local name, ns = ...;
44
local Config = {}
55
ns.Config = Config;
66

7+
--- @enum TUM_Config_ModifierKeyOptions
78
Config.modifierKeyOptions = {
89
always = "always",
910
shift = "shift",
@@ -12,6 +13,7 @@ Config.modifierKeyOptions = {
1213
never = "never",
1314
};
1415

16+
--- @enum TUM_Config_AutoConfirmCatalystOptions
1517
Config.autoConfirmCatalystOptions = {
1618
never = "never",
1719
previousSeason = "previousSeason",
@@ -27,34 +29,47 @@ Config.settingKeys = {
2729
warbandCatalystClassList = "warbandCatalystClassList",
2830
autoConfirmCatalyst = "autoConfirmCatalyst",
2931
debug = "debug",
32+
UI_treatOtherItemAsCollected = "UI_treatOtherItemAsCollected",
3033
};
3134

35+
--- @return TUM_DB
3236
function Config:Init()
33-
TransmogUpgradeMasterDB = TransmogUpgradeMasterDB or {};
34-
self.db = TransmogUpgradeMasterDB;
37+
--- @class TUM_DB
3538
local defaults = {
36-
[self.settingKeys.hideWhenCollected] = false,
37-
[self.settingKeys.debug] = false,
38-
[self.settingKeys.showCollectedModifierKey] = self.modifierKeyOptions.always,
39-
[self.settingKeys.showCollectedFromOtherItemModifierKey] = self.modifierKeyOptions.always,
40-
[self.settingKeys.showUncollectedModifierKey] = self.modifierKeyOptions.always,
41-
[self.settingKeys.showWarbandCatalystInfoModifierKey] = self.modifierKeyOptions.shift,
42-
[self.settingKeys.warbandCatalystClassList] = {},
43-
[self.settingKeys.autoConfirmCatalyst] = self.autoConfirmCatalystOptions.previousSeason,
39+
--- @type boolean
40+
hideWhenCollected = false,
41+
--- @type boolean
42+
debug = false,
43+
--- @type TUM_Config_ModifierKeyOptions
44+
showCollectedModifierKey = self.modifierKeyOptions.always,
45+
--- @type TUM_Config_ModifierKeyOptions
46+
showCollectedFromOtherItemModifierKey = self.modifierKeyOptions.always,
47+
--- @type TUM_Config_ModifierKeyOptions
48+
showUncollectedModifierKey = self.modifierKeyOptions.always,
49+
--- @type TUM_Config_ModifierKeyOptions
50+
showWarbandCatalystInfoModifierKey = self.modifierKeyOptions.shift,
51+
--- @type table<number, boolean> # [classID] = true/false
52+
warbandCatalystClassList = {},
53+
--- @type TUM_Config_AutoConfirmCatalystOptions
54+
autoConfirmCatalyst = self.autoConfirmCatalystOptions.previousSeason,
55+
--- @type boolean
56+
UI_treatOtherItemAsCollected = false,
4457
};
58+
TransmogUpgradeMasterDB = TransmogUpgradeMasterDB or {};
59+
self.db = TransmogUpgradeMasterDB;
4560
for k, v in pairs(defaults) do
4661
if self.db[k] == nil then
47-
if k == self.settingKeys.showCollectedFromOtherItemModifierKey then
48-
self.db[k] = (self.db[self.settingKeys.showUncollectedModifierKey] or v);
62+
if k == "showCollectedFromOtherItemModifierKey" then
63+
self.db[k] = (self.db.showUncollectedModifierKey or v);
4964
else
5065
self.db[k] = v;
5166
end
5267
end
5368
end
5469
for classID = 1, GetNumClasses() do
55-
defaults[self.settingKeys.warbandCatalystClassList][classID] = true;
56-
if self.db[self.settingKeys.warbandCatalystClassList][classID] == nil then
57-
self.db[self.settingKeys.warbandCatalystClassList][classID] = true;
70+
defaults.warbandCatalystClassList[classID] = true;
71+
if self.db.warbandCatalystClassList[classID] == nil then
72+
self.db.warbandCatalystClassList[classID] = true;
5873
end
5974
end
6075

@@ -120,7 +135,7 @@ function Config:Init()
120135
local expandInitializer, isExpanded = self:MakeExpandableSection("Displayed Classes")
121136

122137
local function isVisible()
123-
return self.db[self.settingKeys.showWarbandCatalystInfoModifierKey] ~= self.modifierKeyOptions.never;
138+
return self.db.showWarbandCatalystInfoModifierKey ~= self.modifierKeyOptions.never;
124139
end
125140
expandInitializer:AddShownPredicate(isVisible);
126141
layout:AddInitializer(expandInitializer);
@@ -134,9 +149,9 @@ function Config:Init()
134149
category,
135150
label,
136151
classID,
137-
defaults[self.settingKeys.warbandCatalystClassList][classID],
152+
defaults.warbandCatalystClassList[classID],
138153
tooltip:format(classColor:WrapTextInColorCode(className)),
139-
self.db[self.settingKeys.warbandCatalystClassList]
154+
self.db.warbandCatalystClassList
140155
);
141156
classCheckbox:SetParentInitializer(showWarbandInfo, isVisible);
142157
classCheckbox:AddShownPredicate(isVisible);
@@ -178,6 +193,19 @@ function Config:Init()
178193
"Reset the Transmog cache. This will cause the addon to re-cache all items, which may take a minute or so. This can fix rare situations when transmog changes are hotfixed in by blizzard."
179194
)
180195

196+
self:MakeButton(
197+
category,
198+
layout,
199+
"Open Collections UI",
200+
function()
201+
TUM.UI:ToggleUI();
202+
end,
203+
string.format(
204+
"Open the Collections UI, you can also type %s in chat, or click on the Addon Compartment button to open this UI.",
205+
GREEN_FONT_COLOR:WrapTextInColorCode("/tum")
206+
)
207+
)
208+
181209
Settings.RegisterAddOnCategory(category)
182210

183211
return self.db;
@@ -279,10 +307,6 @@ end
279307
--- @class TransmogUpgradeMaster_SettingsButtonControlMixin : SettingsControlMixin
280308
TransmogUpgradeMaster_SettingsButtonControlMixin = CreateFromMixins(SettingsControlMixin);
281309
do
282-
local function InitializeSettingTooltip(initializer)
283-
Settings.InitTooltip(initializer:GetName(), initializer:GetTooltip());
284-
end
285-
286310
local mixin = TransmogUpgradeMaster_SettingsButtonControlMixin;
287311
function mixin:OnLoad()
288312
SettingsControlMixin.OnLoad(self);
@@ -297,8 +321,9 @@ do
297321
self.Button:SetText(self.data.buttonText);
298322
self.Button:SetScript("OnClick", self.data.OnButtonClick);
299323
self.Button:SetScript("OnEnter", function(button)
300-
GameTooltip:SetOwner(button, "ANCHOR_RIGHT");
301-
InitializeSettingTooltip(initializer);
324+
GameTooltip:SetOwner(button, "ANCHOR_TOP");
325+
GameTooltip_AddHighlightLine(GameTooltip, initializer:GetName());
326+
GameTooltip_AddNormalLine(GameTooltip, initializer:GetTooltip());
302327
GameTooltip:Show();
303328
end);
304329
self.Button:SetScript("OnLeave", function() GameTooltip:Hide(); end);

0 commit comments

Comments
 (0)