diff --git a/Broker_Equipment.lua b/Broker_Equipment.lua index 08a4bf6..16e44aa 100644 --- a/Broker_Equipment.lua +++ b/Broker_Equipment.lua @@ -64,8 +64,10 @@ local function OnLeave() end local function OnItemEnter(self) - GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') - GameTooltip:SetEquipmentSet(self.name) + if(Broker_EquipmentDB.showTooltipMenu) then + GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') + GameTooltip:SetEquipmentSet(self.name) + end OnEnter() end @@ -142,7 +144,9 @@ local function UpdateMenu(parent) end function LDB:OnTooltipShow() - self:SetEquipmentSet(LDB.text) + if(Broker_EquipmentDB.showTooltipDisplay) then + self:SetEquipmentSet(LDB.text) + end end local hooked = {} diff --git a/Broker_Equipment.toc b/Broker_Equipment.toc index afedd38..a90de5e 100644 --- a/Broker_Equipment.toc +++ b/Broker_Equipment.toc @@ -3,6 +3,7 @@ ## Version: @project-version@ ## Title: Broker Equipment ## Notes: LDB Equipment Manager plug-in +## SavedVariables: Broker_EquipmentDB ## OptionalDeps: LibStub, CallbackHandler-1.0, LibDataBroker-1.1 @@ -10,4 +11,5 @@ embeds\LibStub\LibStub.lua embeds\CallbackHandler\CallbackHandler-1.0.lua embeds\LibDataBroker\LibDataBroker-1.1.lua +Config.lua Broker_Equipment.lua diff --git a/Config.lua b/Config.lua new file mode 100644 index 0000000..da1515e --- /dev/null +++ b/Config.lua @@ -0,0 +1,96 @@ +local addonName = ... + +local objects = {} +local temporary = {} + +local defaults = { + showTooltipDisplay = true, + showTooltipMenu = true, +} + +local Panel = CreateFrame('Frame', nil, InterfaceOptionsFramePanelContainer) +Panel.name = addonName +Panel:Hide() + +Panel:RegisterEvent('PLAYER_LOGIN') +Panel:SetScript('OnEvent', function() + Broker_EquipmentDB = Broker_EquipmentDB or defaults +end) + +function Panel:okay() + for key, value in next, temporary do + Broker_EquipmentDB[key] = value + end + + table.wipe(temporary) +end + +function Panel:cancel() + table.wipe(temporary) +end + +function Panel:default() + for key, value in next, defaults do + Broker_EquipmentDB[key] = value + end + + table.wipe(temporary) +end + +function Panel:refresh() + for key, object in next, objects do + if(object:IsObjectType('CheckButton')) then + object:SetChecked(Broker_EquipmentDB[key]) + end + end +end + +local CreateCheckButton +do + local function ClickCheckButton(self) + if(self:GetChecked()) then + temporary[self.key] = true + else + temporary[self.key] = false + end + end + + function CreateCheckButton(parent, key, realParent) + local CheckButton = CreateFrame('CheckButton', nil, parent, 'InterfaceOptionsCheckButtonTemplate') + CheckButton:SetHitRectInsets(0, 0, 0, 0) + CheckButton:SetScript('OnClick', ClickCheckButton) + CheckButton.realParent = realParent + CheckButton.key = key + + objects[key] = CheckButton + + return CheckButton + end +end + +Panel:SetScript('OnShow', function(self) + local Title = self:CreateFontString(nil, nil, 'GameFontNormalLarge') + Title:SetPoint('TOPLEFT', 16, -16) + Title:SetText(addonName) + + local Description = self:CreateFontString(nil, nil, 'GameFontHighlightSmall') + Description:SetPoint('TOPLEFT', Title, 'BOTTOMLEFT', 0, -8) + Description:SetPoint('RIGHT', -32, 0) + Description:SetJustifyH('LEFT') + Description:SetText('Equipment sets!') + self.Description = Description + + local DisplayTooltip = CreateCheckButton(self, 'showTooltipDisplay') + DisplayTooltip:SetPoint('TOPLEFT', Description, 'BOTTOMLEFT', -2, -10) + DisplayTooltip.Text:SetText('Enable tooltips in display') + + local MenuTooltip = CreateCheckButton(self, 'showTooltipMenu') + MenuTooltip:SetPoint('TOPLEFT', DisplayTooltip, 'BOTTOMLEFT', 0, -8) + MenuTooltip.Text:SetText('Enable tooltips in menu') + + Panel:refresh() + + self:SetScript('OnShow', nil) +end) + +InterfaceOptions_AddCategory(Panel)