Skip to content

Commit

Permalink
👌 IMPROVE: Improved the Quick Delte code. Its now an own Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Merathilis committed Aug 20, 2024
1 parent 6120f26 commit 81202e4
Show file tree
Hide file tree
Showing 19 changed files with 333 additions and 11 deletions.
9 changes: 8 additions & 1 deletion ElvUI_MerathilisUI/Core/Profile/Profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ P.misc = {
wowheadlinks = true,
respec = true,
hideBossBanner = false,
quickDelete = true,
tradeTabs = true,
alreadyKnown = {
enable = true,
Expand Down Expand Up @@ -1889,6 +1888,14 @@ P.tooltip = {
},
}

P.item = {
delete = {
enable = true,
delKey = true,
fillIn = "CLICK",
},
}

P.itemLevel = {
enable = true,
flyout = {
Expand Down
6 changes: 6 additions & 0 deletions ElvUI_MerathilisUI/Core/Update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ function MER:UpdateScripts() -- DB Convert

UpdateMessage(L["Misc"] .. " - " .. L["Highest Quest Reward"], profileVersion)

if E.db.mui.misc.quickDelete then
E.db.mui.misc.quickDelete = nil
end

UpdateMessage(L["Misc"] .. " - " .. L["Quick Delete"], profileVersion)

updated = true
end

Expand Down
1 change: 1 addition & 0 deletions ElvUI_MerathilisUI/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MER.Modules.CVars = MER:NewModule("MER_CVars")
MER.Modules.DashBoard = MER:NewModule("MER_DashBoard", "AceEvent-3.0", "AceHook-3.0")
MER.Modules.DataBars = MER:NewModule("MER_DataBars")
MER.Modules.DataTexts = MER:NewModule("MER_DataTexts", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
MER.Modules.DeleteItem = MER:NewModule("MER_DeleteItem", "AceEvent-3.0")
MER.Modules.DropDown = MER:NewModule("MER_DropDown", "AceEvent-3.0", "AceHook-3.0")
MER.Modules.Emotes = MER:NewModule("MER_Emotes")
MER.Modules.EventTracker = MER:NewModule("MER_EventTracker", "AceEvent-3.0", "AceHook-3.0")
Expand Down
14 changes: 14 additions & 0 deletions ElvUI_MerathilisUI/Locales/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,20 @@ L["Animations"] = "Animationen"
L["Animation Speed"] = "Animations Geschwindigkeit"
L["Skyriding Bar"] = "Flugleiste"

-- Delete Item
L["Delete Item"] = "Lösche Item"
L["This module provides several easy-to-use methods of deleting items."] =
"Dieses Modul bietet verschiedene benutzerfreundliche Methoden zum Löschen von Elementen."
L["Use Delete Key"] = "Verwende Löschtaste"
L["Allow you to use Delete Key for confirming deleting."] =
"Ermöglicht die Verwendung der Entf-Taste zum Bestätigen des Löschens."
L["Fill In"] = "Füllen"
L["Disable"] = "Deaktivieren"
L["Fill by click"] = "Mit Klick einfügen"
L["Auto Fill"] = "Auto Einfügen"
L["Press the |cffffd200Delete|r key as confirmation."] = "Drücke zur Bestätigung die Taste |cffffd200Entfernen|r."
L["Click to confirm"] = "Klicke zur Bestätigung"

-- Profiles
L["MER_PROFILE_DESC"] = [[Dieser Abschnitt erstellt Profile für einige AddOns.
Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/esMX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/ptBR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[这个部分将为某些插件创建配置文件.

Expand Down
12 changes: 12 additions & 0 deletions ElvUI_MerathilisUI/Locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,18 @@ L["Animations"] = true
L["Animation Speed"] = true
L["Skyriding Bar"] = true

-- Delete Item
L["Delete Item"] = true
L["This module provides several easy-to-use methods of deleting items."] = true
L["Use Delete Key"] = true
L["Allow you to use Delete Key for confirming deleting."] = true
L["Fill In"] = true
L["Disable"] = true
L["Fill by click"] = true
L["Auto Fill"] = true
L["Press the |cffffd200Delete|r key as confirmation."] = true
L["Click to confirm"] = true

-- Profiles
L["MER_PROFILE_DESC"] = [[This section creates Profiles for some AddOns.

Expand Down
132 changes: 132 additions & 0 deletions ElvUI_MerathilisUI/Modules/Item/DeleteItem.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
local MER, F, E, I, V, P, G, L = unpack(ElvUI_MerathilisUI)
local module = MER:GetModule("MER_DeleteItem")
local S = E:GetModule("Skins")

local _G = _G

local strmatch = strmatch
local strsplit = strsplit
local pairs = pairs

local CreateFrame = CreateFrame
local StaticPopupDialogs = _G.StaticPopupDialogs

local STATICPOPUP_NUMDIALOGS = STATICPOPUP_NUMDIALOGS
local DELETE_ITEM_CONFIRM_STRING = DELETE_ITEM_CONFIRM_STRING

local dialogs = {
["DELETE_ITEM"] = true,
["DELETE_GOOD_ITEM"] = true,
["DELETE_QUEST_ITEM"] = true,
["DELETE_GOOD_QUEST_ITEM"] = true,
}

function module:AddKeySupport(dialog)
local targetFrame = dialog

if self.db.fillIn == "AUTO" and dialog.editBox then
targetFrame = dialog.editBox
end

if dialog.which ~= "DELETE_ITEM" then
local msg = dialog.text:GetText()
local msgTable = { strsplit("\n\n", msg) }

msg = ""

for k, v in pairs(msgTable) do
if (v ~= "") and (not strmatch(v, DELETE_ITEM_CONFIRM_STRING)) then
msg = msg .. v .. "\n\n"
end
end

msg = msg .. L["Press the |cffffd200Delete|r key as confirmation."]
dialog.text:SetText(msg)
end

targetFrame:SetScript("OnKeyDown", function(self, key)
if key == "DELETE" then
dialog.button1:Enable()
end
end)

targetFrame:HookScript("OnHide", function(self)
self:SetScript("OnKeyDown", nil)
end)
end

function module:ShowFillInButton(dialog)
local editBoxFrame = dialog.editBox
local yesButton = dialog.button1
if not editBoxFrame or not yesButton then
return
end

if not self.fillInButton then
local button = CreateFrame("Button", "MER_DeleteButton", E.UIParent, "UIPanelButtonTemplate")
button:SetFrameStrata("TOOLTIP")
S:HandleButton(button)
self.fillInButton = button
end

editBoxFrame:Hide()
self.fillInButton:SetPoint("TOPLEFT", editBoxFrame, "TOPLEFT", -2, -4)
self.fillInButton:SetPoint("BOTTOMRIGHT", editBoxFrame, "BOTTOMRIGHT", 2, 4)

self.fillInButton:SetText("|cffe74c3c" .. L["Click to confirm"] .. "|r")
self.fillInButton:SetScript("OnClick", function(self)
yesButton:Enable()
self:SetText("|cff2ecc71" .. L["Confirmed"] .. "|r")
end)
self.fillInButton:Show()
end

function module.HideFillInButton()
if module.fillInButton then
module.fillInButton:Hide()
module.fillInButton:SetScript("OnClick", nil)
end
end

function module:DELETE_ITEM_CONFIRM()
for i = 1, STATICPOPUP_NUMDIALOGS do
local dialog = _G["StaticPopup" .. i]
local type = dialog.which
if not dialogs[type] then
return
end

if self.db.delKey then
self:AddKeySupport(dialog)
end

if StaticPopupDialogs[type].hasEditBox == 1 then
if self.db.fillIn == "CLICK" then
self:ShowFillInButton(dialog)
dialog:HookScript("OnHide", module.HideFillInButton)
elseif self.db.fillIn == "AUTO" then
dialog.editBox:SetText(DELETE_ITEM_CONFIRM_STRING)
end
end
end
end

function module:Initialize()
if not E.db.mui.item.delete.enable then
return
end

self.db = E.db.mui.item.delete

self:RegisterEvent("DELETE_ITEM_CONFIRM")
end

function module:ProfileUpdate()
if not E.db.mui.item.delete.enable then
self:UnregisterEvent("DELETE_ITEM_CONFIRM")
else
self:Initialize()
end
end

MER:RegisterModule(module:GetName())
3 changes: 3 additions & 0 deletions ElvUI_MerathilisUI/Modules/Item/Load_Item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="DeleteItem.lua"/>
</Ui>
1 change: 1 addition & 0 deletions ElvUI_MerathilisUI/Modules/Load_Modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Include file="Datatexts\Load_Datatexts.xml"/>
<Include file="Databars\Load_Databars.xml"/>
<Include file="ExtendedVendor\Load_ExtendedVendor.xml"/>
<Include file="Item\Load_Item.xml"/>
<Include file="ItemLevel\Load_ItemLevel.xml"/>
<Include file="Mail\Load_Mail.xml"/>
<Include file="Maps\Load_Maps.xml"/>
Expand Down
10 changes: 0 additions & 10 deletions ElvUI_MerathilisUI/Modules/Misc/Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ end
function module:Misc()
self.db = E.db.mui.misc

-- Quick delete
local deleteDialog = StaticPopupDialogs["DELETE_GOOD_ITEM"]
if deleteDialog.OnShow then
hooksecurefunc(deleteDialog, "OnShow", function(self)
if E.db.mui.misc.quickDelete then
self.editBox:SetText(_G.DELETE_ITEM_CONFIRM_STRING)
end
end)
end

E.RegisterCallback(module, "RoleChanged", "SetRole")
module:RegisterEvent("GROUP_ROSTER_UPDATE", "SetRole")
module:RegisterEvent("GROUP_INVITE_CONFIRMATION", "BlockRequest")
Expand Down
Loading

0 comments on commit 81202e4

Please sign in to comment.