diff --git a/Core.lua b/Core.lua index 3804535..ab59139 100644 --- a/Core.lua +++ b/Core.lua @@ -100,7 +100,7 @@ local function itemListInitializer(frame, data) frame.Name:SetTextColor(rowColor:GetRGBA()) if isHeader then local used, maxS = gemUtil:GetSocketsInfo(name) - local col = misc:getPercentColor(used / maxS * 100) + local col = misc:GetPercentColor(used / maxS * 100) frame.Icon:SetDesaturated(false) frame.Name:SetFontObject(const.FONT_OBJECTS.HEADING) frame.Name:SetText(string.format("%s (%s%d/%d|r)", name, col:GenerateHexColorMarkup(), used, maxS)) diff --git a/Misc.lua b/Misc.lua index 62a8a3d..268a717 100644 --- a/Misc.lua +++ b/Misc.lua @@ -2,10 +2,14 @@ local Private = select(2, ...) local const = Private.constants -local misc = {} +local misc = { + clickThrottles = {} +} Private.Misc = misc -function misc:getPercentColor(percent) +---@param percent number +---@return ColorMixin +function misc:GetPercentColor(percent) if percent == 100 then return const.COLORS.POSITIVE end @@ -15,14 +19,18 @@ function misc:getPercentColor(percent) return const.COLORS.NEGATIVE end -function misc:MuteSounds() -- This doesn't seem to work on PlaySound() rn - MuteSoundFile(SOUNDKIT.IG_CHARACTER_INFO_OPEN) - MuteSoundFile(SOUNDKIT.IG_CHARACTER_INFO_CLOSE) - MuteSoundFile(SOUNDKIT.MAP_PING) -end - -function misc:UnmuteSounds() - UnmuteSoundFile(SOUNDKIT.IG_CHARACTER_INFO_OPEN) - UnmuteSoundFile(SOUNDKIT.IG_CHARACTER_INFO_CLOSE) - UnmuteSoundFile(SOUNDKIT.MAP_PING) +---@param clickType any +---@return boolean +function misc:IsAllowedForClick(clickType) + local currentTime = GetTime() + if not self.clickThrottles[clickType] then + self.clickThrottles[clickType] = currentTime + return true + end + if self.clickThrottles[clickType] + .5 < currentTime then + self.clickThrottles[clickType] = currentTime + return true + end + UIErrorsFrame:AddExternalErrorMessage("You're clicking too fast") + return false end diff --git a/UIElements.lua b/UIElements.lua index 1bdd580..9d1e7bb 100644 --- a/UIElements.lua +++ b/UIElements.lua @@ -2,10 +2,12 @@ local Private = select(2, ...) local const = Private.constants local gemUtil = Private.GemUtil +local misc = Private.Misc local uiElements = {} Private.UIElements = uiElements local function extractPreClick(self) + if not misc:IsAllowedForClick("EXTRACT_PRECLICK") then return end if not self.info then return end local info = self.info if info.locType == "SOCKET" then @@ -19,6 +21,7 @@ local function extractPreClick(self) end local function extractPostClick(self) + if not misc:IsAllowedForClick("EXTRACT_POSTCLICK") then return end if not self.info then return end local info = self.info if info.locType == "BAG" then @@ -41,7 +44,7 @@ function uiElements:CreateExtractButton(parent) extractButton:SetAllPoints() extractButton:SetScript("PreClick", extractPreClick) extractButton:SetScript("PostClick", extractPostClick) - extractButton:RegisterForClicks("AnyDown") + extractButton:RegisterForClicks("AnyDown", "AnyUp") extractButton:SetAttribute("type", "macro") function extractButton:UpdateInfo(newType, newIndex, newSlot, newGemType)