Skip to content

Commit fe0065e

Browse files
committed
Add checkbox to ignore talent restrictions
1 parent c49b066 commit fe0065e

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

TalentViewer.lua

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ do
360360
function TalentViewer_DFMain_OnLoad()
361361
table.insert(UISpecialFrames, 'TalentViewer_DF')
362362
TalentViewer:InitDropDown()
363+
TalentViewer:InitCheckbox()
363364
local specId
364365
local _, _, classId = UnitClass('player')
365366
local currentSpec = GetSpecialization()
@@ -484,17 +485,20 @@ function TalentViewer:OnPlayerEnteringWorld()
484485
end
485486

486487
function TalentViewer:OnInitialize()
488+
local defaults = {
489+
ldbOptions = { hide = false },
490+
ignoreRestrictions = true,
491+
}
492+
487493
TalentTreeViewerDB = TalentTreeViewerDB or {}
488494
self.db = TalentTreeViewerDB
489495

490-
if not self.db.ldbOptions then
491-
self.db.ldbOptions = {
492-
hide = false,
493-
}
494-
end
495-
if self.db.ignoreRestrictions == nil then
496-
self.db.ignoreRestrictions = true
496+
for key, value in pairs(defaults) do
497+
if self.db[key] == nil then
498+
self.db[key] = value
499+
end
497500
end
501+
498502
local dataObject = LibStub('LibDataBroker-1.1'):NewDataObject(
499503
name,
500504
{
@@ -518,6 +522,10 @@ function TalentViewer:OnInitialize()
518522
)
519523
LibDBIcon:Register(name, dataObject, self.db.ldbOptions)
520524

525+
if(self.ignoreRestrictionsCheckbox) then
526+
self.ignoreRestrictionsCheckbox:SetChecked(self.db.ignoreRestrictions)
527+
end
528+
521529
SLASH_TALENT_VIEWER1 = '/tv'
522530
SLASH_TALENT_VIEWER2 = '/talentviewer'
523531
SLASH_TALENT_VIEWER3 = '/talenttreeviewer'
@@ -673,6 +681,21 @@ function TalentViewer:BuildMenu(setValueFunc, isCheckedFunc)
673681
return menu
674682
end
675683

684+
function TalentViewer:InitCheckbox()
685+
if self.ignoreRestrictionsCheckbox then return end
686+
self.ignoreRestrictionsCheckbox = TalentViewer_DF.Talents.IgnoreRestrictions
687+
local checkbox = self.ignoreRestrictionsCheckbox
688+
checkbox.Text:SetText('Ignore Restrictions')
689+
checkbox.tooltip = 'Ignore restrictions when selecting talents'
690+
if self.db then
691+
checkbox:SetChecked(self.db.ignoreRestrictions)
692+
end
693+
checkbox:SetScript('OnClick', function(checkbox)
694+
self.db.ignoreRestrictions = checkbox:GetChecked()
695+
self:GetTalentFrame():UpdateTreeCurrencyInfo()
696+
end)
697+
end
698+
676699
function TalentViewer:InitDropDown()
677700
if self.dropDownButton then return end
678701
self.dropDownButton, self.dropDown = self:MakeDropDownButton()

TalentViewerUI.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@
278278
<OnClick function="TalentViewer_ExportButton_OnClick"/>
279279
</Scripts>
280280
</Button>
281+
<CheckButton parentKey="IgnoreRestrictions" inherits="UICheckButtonTemplate">
282+
<Size x="22" y="22"/>
283+
<Anchors>
284+
<Anchor point="RIGHT" relativeKey="$parent.ImportButton" relativePoint="LEFT" x="-110"/>
285+
</Anchors>
286+
<HitRectInsets left="0" right="-100" top="0" bottom="0"/>
287+
</CheckButton>
281288

282289
<Button parentKey="ResetButton" inherits="IconButtonTemplate">
283290
<KeyValues>

0 commit comments

Comments
 (0)