From 81202e4d2ae1d51024d085311af55fecfd3e6060 Mon Sep 17 00:00:00 2001 From: Merathilis Date: Tue, 20 Aug 2024 13:58:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Improved=20the=20Quic?= =?UTF-8?q?k=20Delte=20code.=20Its=20now=20an=20own=20Module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ElvUI_MerathilisUI/Core/Profile/Profile.lua | 9 +- ElvUI_MerathilisUI/Core/Update.lua | 6 + ElvUI_MerathilisUI/Init.lua | 1 + ElvUI_MerathilisUI/Locales/deDE.lua | 14 ++ ElvUI_MerathilisUI/Locales/enUS.lua | 12 ++ ElvUI_MerathilisUI/Locales/esMX.lua | 12 ++ ElvUI_MerathilisUI/Locales/frFR.lua | 12 ++ ElvUI_MerathilisUI/Locales/itIT.lua | 12 ++ ElvUI_MerathilisUI/Locales/koKR.lua | 12 ++ ElvUI_MerathilisUI/Locales/ptBR.lua | 12 ++ ElvUI_MerathilisUI/Locales/ruRU.lua | 12 ++ ElvUI_MerathilisUI/Locales/zhCN.lua | 12 ++ ElvUI_MerathilisUI/Locales/zhTW.lua | 12 ++ .../Modules/Item/DeleteItem.lua | 132 ++++++++++++++++++ ElvUI_MerathilisUI/Modules/Item/Load_Item.xml | 3 + ElvUI_MerathilisUI/Modules/Load_Modules.xml | 1 + ElvUI_MerathilisUI/Modules/Misc/Misc.lua | 10 -- ElvUI_MerathilisUI/Options/Modules/Item.lua | 59 ++++++++ .../Options/Modules/Load_Modules.xml | 1 + 19 files changed, 333 insertions(+), 11 deletions(-) create mode 100644 ElvUI_MerathilisUI/Modules/Item/DeleteItem.lua create mode 100644 ElvUI_MerathilisUI/Modules/Item/Load_Item.xml create mode 100644 ElvUI_MerathilisUI/Options/Modules/Item.lua diff --git a/ElvUI_MerathilisUI/Core/Profile/Profile.lua b/ElvUI_MerathilisUI/Core/Profile/Profile.lua index 1ea659ddf..70954b5e0 100644 --- a/ElvUI_MerathilisUI/Core/Profile/Profile.lua +++ b/ElvUI_MerathilisUI/Core/Profile/Profile.lua @@ -568,7 +568,6 @@ P.misc = { wowheadlinks = true, respec = true, hideBossBanner = false, - quickDelete = true, tradeTabs = true, alreadyKnown = { enable = true, @@ -1889,6 +1888,14 @@ P.tooltip = { }, } +P.item = { + delete = { + enable = true, + delKey = true, + fillIn = "CLICK", + }, +} + P.itemLevel = { enable = true, flyout = { diff --git a/ElvUI_MerathilisUI/Core/Update.lua b/ElvUI_MerathilisUI/Core/Update.lua index 7946b5c10..f170d3526 100644 --- a/ElvUI_MerathilisUI/Core/Update.lua +++ b/ElvUI_MerathilisUI/Core/Update.lua @@ -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 diff --git a/ElvUI_MerathilisUI/Init.lua b/ElvUI_MerathilisUI/Init.lua index 8a8a02411..353e79619 100644 --- a/ElvUI_MerathilisUI/Init.lua +++ b/ElvUI_MerathilisUI/Init.lua @@ -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") diff --git a/ElvUI_MerathilisUI/Locales/deDE.lua b/ElvUI_MerathilisUI/Locales/deDE.lua index f01bf849a..26d615eb0 100644 --- a/ElvUI_MerathilisUI/Locales/deDE.lua +++ b/ElvUI_MerathilisUI/Locales/deDE.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/enUS.lua b/ElvUI_MerathilisUI/Locales/enUS.lua index e93bd8285..03859e616 100644 --- a/ElvUI_MerathilisUI/Locales/enUS.lua +++ b/ElvUI_MerathilisUI/Locales/enUS.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/esMX.lua b/ElvUI_MerathilisUI/Locales/esMX.lua index 5e5f93fbf..5c50546d0 100644 --- a/ElvUI_MerathilisUI/Locales/esMX.lua +++ b/ElvUI_MerathilisUI/Locales/esMX.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/frFR.lua b/ElvUI_MerathilisUI/Locales/frFR.lua index 6e7d3e4a3..366453c13 100644 --- a/ElvUI_MerathilisUI/Locales/frFR.lua +++ b/ElvUI_MerathilisUI/Locales/frFR.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/itIT.lua b/ElvUI_MerathilisUI/Locales/itIT.lua index cfde58bd1..5c9dcacbb 100644 --- a/ElvUI_MerathilisUI/Locales/itIT.lua +++ b/ElvUI_MerathilisUI/Locales/itIT.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/koKR.lua b/ElvUI_MerathilisUI/Locales/koKR.lua index 35b5f63c5..794736b31 100644 --- a/ElvUI_MerathilisUI/Locales/koKR.lua +++ b/ElvUI_MerathilisUI/Locales/koKR.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/ptBR.lua b/ElvUI_MerathilisUI/Locales/ptBR.lua index 719df391a..a93327c99 100644 --- a/ElvUI_MerathilisUI/Locales/ptBR.lua +++ b/ElvUI_MerathilisUI/Locales/ptBR.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/ruRU.lua b/ElvUI_MerathilisUI/Locales/ruRU.lua index 2e8b665e4..27828b6bb 100644 --- a/ElvUI_MerathilisUI/Locales/ruRU.lua +++ b/ElvUI_MerathilisUI/Locales/ruRU.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Locales/zhCN.lua b/ElvUI_MerathilisUI/Locales/zhCN.lua index cde4ec91a..d463c80fa 100644 --- a/ElvUI_MerathilisUI/Locales/zhCN.lua +++ b/ElvUI_MerathilisUI/Locales/zhCN.lua @@ -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"] = [[这个部分将为某些插件创建配置文件. diff --git a/ElvUI_MerathilisUI/Locales/zhTW.lua b/ElvUI_MerathilisUI/Locales/zhTW.lua index 497410e7e..fc46ec44f 100644 --- a/ElvUI_MerathilisUI/Locales/zhTW.lua +++ b/ElvUI_MerathilisUI/Locales/zhTW.lua @@ -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. diff --git a/ElvUI_MerathilisUI/Modules/Item/DeleteItem.lua b/ElvUI_MerathilisUI/Modules/Item/DeleteItem.lua new file mode 100644 index 000000000..2eb551c27 --- /dev/null +++ b/ElvUI_MerathilisUI/Modules/Item/DeleteItem.lua @@ -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()) diff --git a/ElvUI_MerathilisUI/Modules/Item/Load_Item.xml b/ElvUI_MerathilisUI/Modules/Item/Load_Item.xml new file mode 100644 index 000000000..e748bd532 --- /dev/null +++ b/ElvUI_MerathilisUI/Modules/Item/Load_Item.xml @@ -0,0 +1,3 @@ + +