Skip to content

Commit

Permalink
Fixed Okay button for alert prompts.
Browse files Browse the repository at this point in the history
Keybind warning only appears once.
  • Loading branch information
Cidan committed Mar 23, 2024
1 parent 8aec2a9 commit e3769fd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ function AceItemList:SetList(values) end

---@class MoneyFrameButtonTemplate

---@class DefaultPanelFlatTemplate

---@class UIPanelButtonTemplate

---@class InputBoxTemplate

-- Legacy UpdateCooldown function for Classic.
---@param id number
---@param button Button
Expand Down
1 change: 1 addition & 0 deletions core/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const.DATABASE_DEFAULTS = {
showBagButton = true,
debug = false,
inBagSearch = false,
showKeybindWarning = true,
stacking = {
[const.BAG_KIND.BACKPACK] = {
mergeStacks = true,
Expand Down
8 changes: 8 additions & 0 deletions core/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ function DB:SetDontMergePartial(kind, value)
DB.data.profile.stacking[kind].dontMergePartial = value
end

function DB:GetShowKeybindWarning()
return DB.data.profile.showKeybindWarning
end

function DB:SetShowKeybindWarning(value)
DB.data.profile.showKeybindWarning = value
end

function DB:Migrate()
--[[
Migration of the custom category filters from single filter to per-bag filter.
Expand Down
2 changes: 2 additions & 0 deletions core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ function addon:HideBlizzardBags()
end

local function CheckKeyBindings()
if not database:GetShowKeybindWarning() then return end
if GetBindingKey("OPENALLBAGS") == nil then
question:Alert("No Binding Set", [[
Better Bags does not have a key binding set for opening all bags.
Please set a key binding for "Open All Bags" in the key bindings menu.
]])
database:SetShowKeybindWarning(false)
end
end
-- OnEnable is called when the addon is enabled.
Expand Down
1 change: 1 addition & 0 deletions debug/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ end

---@param item Item
function debug:HideItemTooltip(item)
_ = item
tooltipLines = 0
self.tooltip:Hide()
end
12 changes: 9 additions & 3 deletions frames/question.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local question = addon:NewModule('Question')
---@field text FontString
---@field yes Button|UIPanelButtonTemplate
---@field no Button|UIPanelButtonTemplate
---@field ok Button|UIPanelButtonTemplate
---@field input EditBox|InputBoxTemplate
local questionProto = {}

Expand All @@ -39,11 +40,13 @@ function question:_OnCreate()

q.yes = CreateFrame('Button', nil, q.frame, "UIPanelButtonTemplate")
q.no = CreateFrame('Button', nil, q.frame, "UIPanelButtonTemplate")
q.ok = CreateFrame('Button', nil, q.frame, "UIPanelButtonTemplate")
q.yes:SetWidth(100)
q.no:SetWidth(100)
q.ok:SetWidth(100)
q.yes:SetPoint("BOTTOMLEFT", 10, 10)
q.no:SetPoint("BOTTOMRIGHT", -10, 10)

q.ok:SetPoint("BOTTOM", 0, 10)
return q
end

Expand All @@ -56,6 +59,7 @@ function question:_OnReset(q)
q.no:SetScript("OnClick", nil)
q.yes:Show()
q.no:Show()
q.ok:Hide()
q.input:ClearFocus()
q.input:SetText("")
q.input:SetScript("OnEscapePressed", nil)
Expand Down Expand Up @@ -106,12 +110,14 @@ function question:Alert(title, text)
local q = self._pool:Acquire() --[[@as QuestionFrame]]
q.frame:SetTitle(title)
q.text:SetText(text)
q.yes:SetText("Okay")
q.no:Hide()
q.yes:SetScript("OnClick", function()
q.yes:Hide()
q.ok:SetText("Okay")
q.ok:SetScript("OnClick", function()
self._pool:Release(q)
self.open = false
end)
q.ok:Show()
q.input:Hide()
q:Resize()
q.frame:SetPoint('CENTER')
Expand Down

0 comments on commit e3769fd

Please sign in to comment.