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()
484485end
485486
486487function 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
674682end
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+
676699function TalentViewer :InitDropDown ()
677700 if self .dropDownButton then return end
678701 self .dropDownButton , self .dropDown = self :MakeDropDownButton ()
0 commit comments