Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------
- --- Author: Ketho (EU-Boulderfist) ---
- --- License: Public Domain ---
- --- Created: 2011.11.21 ---
- --- Version: 0.7 [2012.08.28] ---
- -------------------------------------------
- --- Curse http://www.curse.com/addons/wow/autoconfirmroll
- --- WoWInterface http://www.wowinterface.com/downloads/info20516-AutoConfirmRoll.html
- local NAME = ...
- local VERSION = 0.7
- local BUILD = "Release"
- AutoConfirmRoll = LibStub("AceAddon-3.0"):NewAddon(NAME, "AceEvent-3.0", "AceConsole-3.0")
- local ACR = AutoConfirmRoll
- local ACR2 = LibStub("AceConfigRegistry-3.0")
- local ACD = LibStub("AceConfigDialog-3.0")
- local profile
- ---------------
- --- Options ---
- ---------------
- local rollTypes = {} -- cache
- local remap = {
- Need = 1,
- Greed = 2,
- Disenchant = 3,
- }
- local ITEM_QUALITY = {}
- for i = 2, 4 do
- ITEM_QUALITY[i] = format("%s%s|r", ITEM_QUALITY_COLORS[i].hex, _G["ITEM_QUALITY"..i.."_DESC"])
- end
- local defaults = {
- profile = {
- Need = true,
- Greed = true,
- Disenchant = true,
- Loot = true,
- Threshold = 4,
- Party = true,
- Raid = true,
- },
- }
- local options = {
- type = "group",
- name = format("%s |cffADFF2Fv%s|r", NAME, VERSION),
- handler = ACR,
- args = {
- inline1 = {
- type = "group", order = 1,
- name = " ",
- inline = true,
- get = "GetValue", set = "SetValueRoll",
- args = {
- Need = {
- type = "toggle", order = 1,
- width = "full", descStyle = "",
- name = "|TInterface\\Buttons\\UI-GroupLoot-Dice-Up:16:16|t "..NEED,
- },
- Greed = {
- type = "toggle", order = 2,
- width = "full", descStyle = "",
- name = "|TInterface\\Buttons\\UI-GroupLoot-Coin-Up:16:16|t "..GREED,
- },
- Disenchant = {
- type = "toggle", order = 3,
- width = "full", descStyle = "",
- name = "|TInterface\\Buttons\\UI-GroupLoot-DE-Up:16:16|t "..ROLL_DISENCHANT,
- },
- Loot = {
- type = "toggle", order = 4,
- width = "full", desc = "|cff71D5FFAutoConfirmLoot|r\n"..LOOT_NO_DROP,
- name = "|TInterface\\Cursor\\Pickup:16:16:1|t "..LOOT,
- set = "SetValue"
- },
- },
- },
- spacing = {type = "description", order = 2, name = ""},
- inline2 = {
- type = "group", order = 3,
- name = FILTERS,
- inline = true,
- get = "GetValue", set = "SetValue",
- args = {
- Threshold = {
- type = "select", order = 1,
- descStyle = "",
- name = " "..LOOT_THRESHOLD,
- values = ITEM_QUALITY,
- },
- spacing = {type = "description", order = 2, name = " "},
- Party = {
- type = "toggle", order = 3,
- width = "full", descStyle = "",
- name = " |cffA8A8FF"..PARTY.."|r",
- },
- Raid = {
- type = "toggle", order = 4,
- width = "full", descStyle = "",
- name = " |cffFF7F00"..RAID.."|r",
- },
- },
- },
- },
- }
- function ACR:GetValue(i)
- return profile[i[#i]]
- end
- function ACR:SetValue(i, v)
- profile[i[#i]] = v
- end
- function ACR:SetValueRoll(i, v)
- profile[i[#i]] = v
- rollTypes[remap[i[#i]]] = v
- end
- ---------------------------
- --- Ace3 Initialization ---
- ---------------------------
- local slashCmds = {"acr", "autoconfirm", "autoconfirmroll"}
- function ACR:OnInitialize()
- self.db = LibStub("AceDB-3.0"):New("AutoConfirmRollDB", defaults, true)
- self.db.RegisterCallback(self, "OnProfileChanged", "RefreshDB")
- self.db.RegisterCallback(self, "OnProfileCopied", "RefreshDB")
- self.db.RegisterCallback(self, "OnProfileReset", "RefreshDB")
- self:RefreshDB()
- self.db.global.version = VERSION
- self.db.global.build = BUILD
- ACR2:RegisterOptionsTable("AutoConfirmRoll_Main", options)
- local profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
- ACR2:RegisterOptionsTable("AutoConfirmRoll_Profiles", profiles)
- ACD:AddToBlizOptions("AutoConfirmRoll_Main", NAME)
- ACD:AddToBlizOptions("AutoConfirmRoll_Profiles", profiles.name, NAME)
- ACD:SetDefaultSize("AutoConfirmRoll_Main", 280, 385)
- for _, v in ipairs(slashCmds) do
- self:RegisterChatCommand(v, "SlashCommand")
- end
- end
- function ACR:OnEnable()
- self:RegisterEvent("CONFIRM_LOOT_ROLL", "CONFIRM_ROLL")
- self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", "CONFIRM_ROLL")
- self:RegisterEvent("LOOT_BIND_CONFIRM")
- end
- function ACR:RefreshDB()
- profile = self.db.profile
- rollTypes = {
- profile.Need,
- profile.Greed,
- profile.Disenchant,
- }
- end
- local enable = {
- ["1"] = true,
- on = true,
- enable = true,
- load = true,
- }
- local disable = {
- ["0"] = true,
- off = true,
- disable = true,
- unload = true,
- }
- function ACR:SlashCommand(input)
- if strtrim(input) == "" then
- ACD:Open("AutoConfirmRoll_Main")
- elseif enable[input] then
- self:Enable()
- self:Print("|cffADFF2F"..VIDEO_OPTIONS_ENABLED.."|r")
- elseif disable[input] then
- self:Disable()
- self:Print("|cffFF2424"..VIDEO_OPTIONS_DISABLED.."|r")
- end
- end
- --------------
- --- Events ---
- --------------
- local function IsGroup()
- local numParty = GetNumSubgroupMembers()
- local numRaid = GetNumGroupMembers()
- local isParty = profile.Party and (numRaid == 0 and numParty > 0)
- local isRaid = profile.Raid and numRaid > 0
- return isRaid or isParty
- end
- function ACR:CONFIRM_ROLL(event, id, lootType)
- print ("CONFIRM_ROLL event handed to ACR")
- local qualityThreshold = select(4, GetLootRollItemInfo(id)) <= profile.Threshold
- if rollTypes[lootType] and qualityThreshold and IsGroup() then
- ConfirmLootRoll(id, lootType)
- --Manually hiding StaticPopup for compatibility with ElvUI
- StaticPopup_Hide("CONFIRM_LOOT_ROLL")
- end
- end
- local f = CreateFrame("Frame")
- function ACR:LOOT_BIND_CONFIRM(event, slot)
- local qualityThreshold = select(4, GetLootSlotInfo(slot)) <= profile.Threshold
- if profile.Loot and qualityThreshold then
- -- delay by a single OnUpdate iteration
- f:SetScript("OnUpdate", function(self, elapsed)
- ConfirmLootSlot(slot)
- self:SetScript("OnUpdate", nil)
- end)
- -- in contrary to ConfirmLootRoll, ConfirmLootSlot doesn't include hiding the StaticPopup
- StaticPopup_Hide("LOOT_BIND")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement