diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/FlashTaskBar.lua b/FlashTaskBar.lua
new file mode 100644
index 0000000..e6a5337
--- /dev/null
+++ b/FlashTaskBar.lua
@@ -0,0 +1,1299 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF) then
+ print ("|cFFFFAA00FlashTaskBar: framework not found, if you just installed or updated the addon, please restart your client.|r")
+ return
+end
+
+local _
+
+local L = LibStub ("AceLocale-3.0"):GetLocale ("FlashTaskbarLocales", true)
+if (not L) then
+ DF:ShowPanicWarning ("FlashTaskbar Locale failed to load, restart your game client to finish addon updates.")
+ return
+end
+
+--> when true it will print what triggered the flash
+local FlashDebug = false
+
+do
+ local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+ SharedMedia:Register ("sound", "d_whip1", [[Interface\Addons\FlashTaskBar\sounds\sound_whip1.ogg]])
+end
+
+local default_config = {
+ profile = {
+ readycheck = true,
+ arena_queue = true,
+ group_queue = true,
+ petbattle_queue = true,
+ brawlers_queue = true,
+ pull_timers = true,
+ enter_combat = false,
+ end_taxi = false,
+ chat_scan = false,
+ chat_scan_keywords = {},
+ combat_log = false,
+ combat_log_keywords = {},
+ rare_scan = true,
+ any_rare = true,
+ rare_names = {},
+ disconnect_logout = false,
+ invite = true,
+ invite_ignore_on_autoaccept = false,
+ trade = true,
+ bags_full = false,
+ worldpvp = true,
+ duel_request = true,
+ summon = true,
+ fatigue = true,
+ on_chat_player_name = false,
+ whisper_blink = true,
+ battleground_end = false,
+ timer_start = false,
+ low_health = false,
+ lost_health = false,
+ player_died = true,
+
+ sound_enabled = {
+ readycheck = {enabled = false, sound = "d_whip1"},
+ arena_queue = {enabled = false, sound = "d_whip1"},
+ group_queue = {enabled = false, sound = "d_whip1"},
+ petbattle_queue = {enabled = false, sound = "d_whip1"},
+ brawlers_queue = {enabled = false, sound = "d_whip1"},
+ pull_timers = {enabled = false, sound = "d_whip1"},
+ enter_combat = {enabled = false, sound = "d_whip1"},
+ end_taxi = {enabled = false, sound = "d_whip1"},
+ chat_scan = {enabled = false, sound = "d_whip1"},
+ combat_log = {enabled = false, sound = "d_whip1"},
+ rare_scan = {enabled = false, sound = "d_whip1"},
+ disconnect_logout = {enabled = false, sound = "d_whip1"},
+ invite = {enabled = false, sound = "d_whip1"},
+ trade = {enabled = false, sound = "d_whip1"},
+ bags_full = {enabled = false, sound = "d_whip1"},
+ worldpvp = {enabled = false, sound = "d_whip1"},
+ duel_request = {enabled = false, sound = "d_whip1"},
+ summon = {enabled = false, sound = "d_whip1"},
+ fatigue = {enabled = false, sound = "d_whip1"},
+ on_chat_player_name = {enabled = false, sound = "d_whip1"},
+ whisper_blink = {enabled = false, sound = "d_whip1"},
+ battleground_end = {enabled = false, sound = "d_whip1"},
+ timer_start = {enabled = false, sound = "d_whip1"},
+ low_health = {enabled = false, sound = "d_whip1"},
+ lost_health = {enabled = false, sound = "d_whip1"},
+ player_died = {enabled = false, sound = "d_whip1"},
+ },
+ }
+}
+
+local options_table = {
+ name = "FlashTaskBar",
+ type = "group",
+ args = {
+
+ }
+}
+local FlashTaskBar = DF:CreateAddOn ("FlashTaskBar", "FlashTaskbarDB", default_config, options_table)
+local lower = string.lower
+
+--store the address of the original chat func
+local ChatFrame_MessageEventHandler_Original = ChatFrame_MessageEventHandler
+
+FlashTaskBar.last_flash = 0
+
+function FlashTaskBar:DoFlash (config_key)
+
+ if (FlashTaskBar.last_flash + 5 < GetTime()) then
+ if (FlashDebug) then
+ FlashTaskBar:Msg ("Flash Reason: " .. (config_key or "unknown"))
+ end
+
+ FlashClientIcon()
+ local has_sound = FlashTaskBar.db.profile.sound_enabled
+ if (has_sound and has_sound [config_key] and has_sound [config_key].enabled) then
+ local file = LibStub:GetLibrary("LibSharedMedia-3.0"):Fetch ("sound", has_sound [config_key].sound)
+ PlaySoundFile (file, "Master")
+ end
+ FlashTaskBar.last_flash = GetTime()
+ end
+end
+
+function FlashTaskBar.OnInit (self)
+
+ --register slash
+ SLASH_FLASHTASKBAR1 = "/flashtaskbar"
+ function SlashCmdList.FLASHTASKBAR (msg, editbox)
+
+ if (msg == "reason") then
+ FlashDebug = not FlashDebug
+ FlashTaskBar:Msg ("Flash Reason " .. (FlashDebug and "Enabled" or "Disabled"))
+ return
+ end
+
+ InterfaceOptionsFrame_OpenToCategory ("FlashTaskBar")
+ InterfaceOptionsFrame_OpenToCategory ("FlashTaskBar")
+ end
+
+ --invite
+ function FlashTaskBar:DelayInviteCheck()
+ --if already in a group, ignore the invite call
+ --but the player might have received a request to join the group
+ --may be in the future this might need a flash as well
+ if (IsInGroup() or IsInRaid()) then
+ return
+ else
+ FlashTaskBar:DoFlash("invite")
+ end
+ end
+
+ --> wait 2 seconds before flash, other addons may auto answer the group invite
+ function FlashTaskBar:CheckForGroupInvite()
+ if (StaticPopup1 and StaticPopup1:IsShown()) then
+ FlashTaskBar:DoFlash("invite")
+ end
+ end
+
+ function FlashTaskBar:PARTY_INVITE_REQUEST()
+ if (FlashTaskBar.db.profile.invite) then
+ if (FlashTaskBar.db.profile.invite_ignore_on_autoaccept) then
+ FlashTaskBar:ScheduleTimer ("DelayInviteCheck", 1.0)
+ else
+ FlashTaskBar:ScheduleTimer ("CheckForGroupInvite", 2.0)
+ end
+ end
+ end
+ FlashTaskBar:RegisterEvent ("PARTY_INVITE_REQUEST")
+
+ --pet battle queue
+ function FlashTaskBar:CheckPetBattleQueue()
+ if (PetBattleQueueReadyFrame and PetBattleQueueReadyFrame:IsShown()) then
+ FlashTaskBar:DoFlash("petbattle_queue")
+ end
+ end
+ function FlashTaskBar:PET_BATTLE_QUEUE_STATUS (...)
+ if (FlashTaskBar.db.profile.petbattle_queue) then
+ FlashTaskBar:ScheduleTimer ("CheckPetBattleQueue", 1.5)
+ end
+ end
+ FlashTaskBar:RegisterEvent ("PET_BATTLE_QUEUE_STATUS")
+
+ function FlashTaskBar:UPDATE_BATTLEFIELD_STATUS()
+ if (FlashTaskBar.db.profile.battleground_end) then
+ if (WorldStateScoreFrame and WorldStateScoreFrame:IsShown()) then
+ FlashTaskBar:DoFlash("battleground_end")
+ end
+ end
+ end
+ FlashTaskBar:RegisterEvent ("UPDATE_BATTLEFIELD_STATUS")
+
+ --premade groups ready
+ hooksecurefunc ("LFGListInviteDialog_Show", function()
+ if (FlashTaskBar.db.profile.group_queue) then
+ FlashTaskBar:DoFlash("group_queue")
+ FlashTaskBar.last_flash = 0
+ end
+ end)
+
+ --lfg lfpvp windows
+ hooksecurefunc ("LFGDungeonReadyStatus_ResetReadyStates", function()
+ if (FlashTaskBar.db.profile.group_queue) then
+ FlashTaskBar:DoFlash("group_queue")
+ FlashTaskBar.last_flash = 0
+ end
+ end)
+ hooksecurefunc ("PVPReadyDialog_Display", function()
+ if (FlashTaskBar.db.profile.arena_queue) then
+ FlashTaskBar:DoFlash("arena_queue")
+ FlashTaskBar.last_flash = 0
+ end
+ end)
+
+ --game master
+ hooksecurefunc ("HelpFrame_OnEvent", function (self, token)
+ if (token == "GMRESPONSE_RECEIVED") then
+ FlashTaskBar:DoFlash("gm_response")
+ end
+ end)
+
+ --general alerts
+ hooksecurefunc ("StaticPopup_Show", function (token, text_arg1, text_arg2, data, insertedFrame)
+ if (token == "BFMGR_INVITED_TO_ENTER") then --> generic world pvp alert
+ if (FlashTaskBar.db.profile.worldpvp) then
+ FlashTaskBar:DoFlash("worldpvp")
+ end
+
+ elseif (token == "DUEL_REQUESTED" or token == "PET_BATTLE_PVP_DUEL_REQUESTED") then
+ if (FlashTaskBar.db.profile.duel_request) then
+ FlashTaskBar:DoFlash("duel_request")
+ end
+
+ elseif (token == "CONFIRM_SUMMON" or token == "CONFIRM_SUMMON_STARTING_AREA") then
+ if (FlashTaskBar.db.profile.summon) then
+ FlashTaskBar:DoFlash("summon")
+ end
+
+ elseif (token == "CHANNEL_INVITE" or token == "CHAT_CHANNEL_INVITE") then
+ FlashTaskBar:DoFlash("chat_channel_invite")
+
+ elseif (token == "PARTY_INVITE" or token == "PARTY_INVITE_XREALM") then
+ if (not FlashTaskBar.db.profile.invite) then
+ return
+ end
+ if (FlashTaskBar.db.profile.invite_ignore_on_autoaccept) then
+ FlashTaskBar:ScheduleTimer ("DelayInviteCheck", 1.5)
+ else
+ FlashTaskBar:DoFlash("invite")
+ end
+
+ elseif (token == "TRADE_WITH_QUESTION") then
+ if (FlashTaskBar.db.profile.trade) then
+ FlashTaskBar:DoFlash("trade")
+ end
+ end
+
+ end)
+
+ --brawlers guild
+ function FlashTaskBar:CHAT_MSG_MONSTER_YELL (event, msg, source, _, _, player_name)
+ if (player_name == UnitName ("player")) then
+ if (FlashTaskBar.db.profile.brawlers_queue) then
+ FlashTaskBar:DoFlash("brawlers_queue")
+ end
+ end
+ end
+ function FlashTaskBar:CheckForBrawlersGuild()
+ local zoneName, zoneType, _, _, _, _, _, zoneMapID = GetInstanceInfo()
+ if (zoneMapID == 369 or zoneMapID == 1043) then
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_YELL")
+ else
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_YELL")
+ end
+ end
+ function FlashTaskBar:PLAYER_ENTERING_WORLD()
+ FlashTaskBar:ScheduleTimer ("CheckForBrawlersGuild", 3)
+ end
+ function FlashTaskBar:ZONE_CHANGED_NEW_AREA()
+ FlashTaskBar:ScheduleTimer ("CheckForBrawlersGuild", 3)
+ end
+ FlashTaskBar:RegisterEvent ("PLAYER_ENTERING_WORLD")
+ FlashTaskBar:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
+
+ --pull timers
+ function FlashTaskBar:CommReceived (_, prefix)
+ if (not FlashTaskBar.db.profile.pull_timers) then
+ return
+ end
+ if (prefix:find ("PT")) then
+ FlashTaskBar:DoFlash("pull_timers")
+ elseif (prefix:find ("BWPull")) then
+ FlashTaskBar:DoFlash("pull_timers")
+ end
+ end
+ FlashTaskBar:RegisterComm ("D4", "CommReceived")
+ FlashTaskBar:RegisterComm ("BigWigs", "CommReceived")
+
+ --readycheck
+ function FlashTaskBar:READY_CHECK()
+ if (FlashTaskBar.db.profile.readycheck) then
+ FlashTaskBar:DoFlash("readycheck")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("READY_CHECK")
+
+ --combat
+ function FlashTaskBar:PLAYER_REGEN_DISABLED()
+ if (FlashTaskBar.db.profile.enter_combat) then
+ FlashTaskBar:DoFlash("enter_combat")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("PLAYER_REGEN_DISABLED")
+
+ --taxi
+ --after a true for UnitOnTaxi, wait until it is false again
+ local CheckIfFlyingEnded = function (tickObject)
+ if (not UnitOnTaxi ("player")) then
+ tickObject:Cancel()
+ FlashTaskBar:DoFlash("end_taxi")
+ FlashTaskBar:Msg (L["STRING_CHAT_FLYPOINTENDED"])
+ end
+ end
+
+ --after closing, check if the player is on a taxi
+ local CheckIfIsFlying = function (tickObject)
+ if (UnitOnTaxi ("player")) then
+ if (FlashTaskBar.FlyingHasEndedCheck) then
+ FlashTaskBar.FlyingHasEndedCheck:Cancel()
+ end
+ FlashTaskBar.FlyingHasEndedCheck = C_Timer.NewTicker (1, CheckIfFlyingEnded)
+ tickObject:Cancel()
+ end
+ end
+
+ --run when the player closes the taxi map
+ function FlashTaskBar:TAXIMAP_CLOSED()
+ if (FlashTaskBar.db.profile.end_taxi) then
+ if (FlashTaskBar.IsFlyingTaxiCheck) then
+ FlashTaskBar.IsFlyingTaxiCheck:Cancel()
+ end
+ FlashTaskBar.IsFlyingTaxiCheck = C_Timer.NewTicker (1, CheckIfIsFlying, 5) --only check for 5 seconds
+ end
+ end
+ FlashTaskBar:RegisterEvent ("TAXIMAP_CLOSED")
+
+ --disconenct
+ GameMenuButtonLogout:HookScript ("OnClick", function()
+ FlashTaskBar.LogoutTolerance = GetTime()+30
+ end)
+ function FlashTaskBar:PLAYER_LOGOUT()
+ if (FlashTaskBar.db.profile.disconnect_logout) then
+ if (FlashTaskBar.LogoutTolerance and FlashTaskBar.LogoutTolerance > GetTime()) then
+ return
+ end
+ FlashTaskBar:DoFlash("disconnect_logout")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("PLAYER_LOGOUT")
+
+ --trade
+ function FlashTaskBar:TRADE_SHOW()
+ if (FlashTaskBar.db.profile.trade) then
+ FlashTaskBar:Msg ("somebody opened a trade with you!")
+ FlashTaskBar:DoFlash("trade")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("TRADE_SHOW")
+
+ --bags full
+ function FlashTaskBar:BAG_UPDATE()
+ if (FlashTaskBar.db.profile.bags_full) then
+ for backpack = 0, 4 do
+ for slot = 1, GetContainerNumSlots (backpack) do
+ local itemId = GetContainerItemID (backpack, slot)
+ if (not itemId) then
+ return
+ end
+ end
+ end
+ FlashTaskBar:DoFlash("bags_full")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("BAG_UPDATE")
+
+ --fatigue
+ function FlashTaskBar:MIRROR_TIMER_START (event, name, value, maxvalue, step, pause, label)
+ if (FlashTaskBar.db.profile.fatigue) then
+ if (name == "EXHAUSTION" and step == -1) then
+ FlashTaskBar:DoFlash ("fatigue")
+ end
+ end
+ end
+ FlashTaskBar:RegisterEvent ("MIRROR_TIMER_START")
+
+ --timer start
+ function FlashTaskBar:START_TIMER()
+ if (FlashTaskBar.db.profile.timer_start) then
+ FlashTaskBar:DoFlash ("timer_start")
+ end
+ end
+ FlashTaskBar:RegisterEvent ("START_TIMER")
+
+ --low health
+ FlashTaskBar.LastHealthBlink = time() - 30
+ function FlashTaskBar.CheckTargetHealth()
+ local targetHealth = UnitHealth ("target")
+ if (targetHealth > 1) then
+ local targetMaxHealth = UnitHealthMax ("target")
+ if (targetMaxHealth) then
+ if (FlashTaskBar.db.profile.low_health) then
+ local percent = targetHealth / targetMaxHealth
+ if (percent < 0.17) then
+ if (FlashTaskBar.LastHealthBlink + 30 < time()) then
+ FlashTaskBar:DoFlash ("low_health")
+ FlashTaskBar.LastHealthBlink = time()
+ end
+ end
+ end
+ if (FlashTaskBar.db.profile.lost_health) then
+ local percent = targetHealth / targetMaxHealth
+ if (percent < 0.95) then
+ if (FlashTaskBar.LastHealthBlink + 30 < time()) then
+ FlashTaskBar:DoFlash ("lost_health")
+ FlashTaskBar.LastHealthBlink = time()
+ end
+ end
+ end
+ end
+ end
+ end
+ function FlashTaskBar:EnableCheckHealth (state)
+ if (FlashTaskBar.HealthTicker) then
+ FlashTaskBar.HealthTicker:Cancel()
+ end
+ if (state) then
+ FlashTaskBar.HealthTicker = C_Timer.NewTicker (2, FlashTaskBar.CheckTargetHealth)
+ else
+ FlashTaskBar.HealthTicker = nil
+ end
+ end
+ if (FlashTaskBar.db.profile.low_health) then
+ FlashTaskBar:EnableCheckHealth (true)
+ end
+ if (FlashTaskBar.db.profile.lost_health) then
+ FlashTaskBar:EnableCheckHealth (true)
+ end
+
+--------> chat scan
+
+ local player_name = lower (UnitName ("player"))
+ local do_chat_scan = function (_, message)
+ message = lower (message)
+ if (FlashTaskBar.db.profile.chat_scan) then
+ for _, keyword in ipairs (FlashTaskBar.db.profile.chat_scan_keywords) do
+ if (message:find (lower (keyword))) then
+ FlashTaskBar:DoFlash ("chat_scan")
+ FlashTaskBar:Msg ("work " .. keyword .. " found in chat!")
+ return
+ end
+ end
+ end
+
+ if (FlashTaskBar.db.profile.on_chat_player_name) then
+ if (message:find (player_name)) then
+ FlashTaskBar:Msg ("somebody mentioned your name in the chat!")
+ FlashTaskBar:DoFlash("on_chat_player_name")
+ end
+ end
+ end
+
+ function FlashTaskBar:EnableChatScan()
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_EMOTE", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_EMOTE", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_SAY", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_WHISPER", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_YELL", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_BOSS_EMOTE", do_chat_scan)
+ --FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_BOSS_WHISPER", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_SYSTEM", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_SAY", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_YELL", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_CHANNEL", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_PARTY", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_GUILD", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_INSTANCE_CHAT", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_OFFICER", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_PARTY_LEADER", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_LEADER", do_chat_scan)
+ FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_WARNING", do_chat_scan)
+
+ player_name = lower (UnitName ("player"))
+ end
+
+ function FlashTaskBar:DisableChatScan()
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_EMOTE")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_EMOTE")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_SAY")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_WHISPER")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_YELL")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_BOSS_EMOTE")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_BOSS_WHISPER")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_SYSTEM")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_SAY")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_YELL")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_CHANNEL")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_PARTY")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_GUILD")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_INSTANCE_CHAT")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_OFFICER")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_PARTY_LEADER")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_LEADER")
+ FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_WARNING")
+ end
+
+ --> player died
+ local healthFrame = CreateFrame ("frame", nil, UIParent)
+ healthFrame:SetScript ("OnEvent", function (self, unit)
+ local health = UnitHealth ("player")
+ if (health < 1) then
+ if (FlashTaskBar.db.profile.player_died) then
+ FlashTaskBar:DoFlash ("player_died")
+ end
+ end
+ end)
+
+ function FlashTaskBar:EnablePlayerHealthMonitor()
+ healthFrame:RegisterUnitEvent ("UNIT_HEALTH", "player")
+ end
+
+ function FlashTaskBar:DisablePlayerHealthMonitor()
+ healthFrame:UnregisterEvent ("UNIT_HEALTH", "player")
+ end
+
+ if (FlashTaskBar.db.profile.player_died) then
+ FlashTaskBar:EnablePlayerHealthMonitor()
+ end
+
+ --need a cleanup in the future
+ function FlashTaskBar:DoNotFlashOnWhisper()
+ --_G.ChatFrame_MessageEventHandler = ChatFrame_MessageEventHandler_WithNoFlash
+ end
+
+ function FlashTaskBar:EnableFlashOnWhisper()
+ --_G.ChatFrame_MessageEventHandler = ChatFrame_MessageEventHandler_Original
+ end
+
+ if (FlashTaskBar.db.profile.whisper_blink) then
+ --FlashTaskBar:EnableFlashOnWhisper()
+ else
+ --FlashTaskBar:DoNotFlashOnWhisper()
+ end
+
+--------> combat log scan
+
+ local combat_log_keywords = {}
+ local do_combat_log_scan = function (self, event)
+ local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2 = CombatLogGetCurrentEventInfo()
+ if (target_name and combat_log_keywords [lower (target_name)]) then
+ FlashTaskBar:DoFlash("combat_log")
+ end
+ end
+
+ function FlashTaskBar:BuildCombatLogKeywordTable()
+ wipe (combat_log_keywords)
+ for _, keyword in ipairs (FlashTaskBar.db.profile.combat_log_keywords) do
+ combat_log_keywords [lower (keyword)] = true
+ end
+ end
+
+ function FlashTaskBar:EnableCombatLogScan()
+ FlashTaskBar:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED", do_combat_log_scan)
+ FlashTaskBar:BuildCombatLogKeywordTable()
+ end
+
+ function FlashTaskBar:DisableCombatLogScan()
+ FlashTaskBar:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
+ end
+
+--------> rare mob scan
+
+ --> store the timers for flash for each rare
+ FlashTaskBar.RareFlashCooldown = {}
+
+ local do_rare_mob_scan = function()
+
+ --/dump C_VignetteInfo.GetVignetteInfo (C_VignetteInfo.GetVignettes()[1])
+ --/dump C_VignetteInfo.GetVignettes()
+
+ for index, GUID in ipairs (C_VignetteInfo.GetVignettes()) do
+ local vignetteInfo = C_VignetteInfo.GetVignetteInfo (GUID)
+ if (vignetteInfo and vignetteInfo.onMinimap and not vignetteInfo.isDead and vignetteInfo.atlasName == "VignetteKill") then --vignetteID == 2004
+
+ local objectGUID = vignetteInfo.objectGUID
+ if (FlashTaskBar.db.profile.any_rare) then
+ if (not UnitOnTaxi ("player")) then
+ if (not FlashTaskBar.RareFlashCooldown [objectGUID] or FlashTaskBar.RareFlashCooldown [objectGUID] < time()) then
+ FlashTaskBar:DoFlash ("rare_scan")
+ FlashTaskBar.RareFlashCooldown [objectGUID] = time() + 180
+ end
+ end
+
+ elseif (vignetteInfo.name) then
+ for _, npc_name in ipairs (FlashTaskBar.db.profile.rare_names) do
+ npc_name = lower (npc_name)
+ name = lower (name)
+ if (npc_name == name) then
+ if (not FlashTaskBar.RareFlashCooldown [objectGUID] or FlashTaskBar.RareFlashCooldown [objectGUID] < time()) then
+ FlashTaskBar:DoFlash ("rare_scan")
+ FlashTaskBar.RareFlashCooldown [objectGUID] = time() + 180
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ function FlashTaskBar:EnableRareMobScan()
+ FlashTaskBar:RegisterEvent ("VIGNETTES_UPDATED", do_rare_mob_scan)
+ end
+
+ function FlashTaskBar:DisableRareMobScan()
+ FlashTaskBar:UnregisterEvent ("VIGNETTES_UPDATED")
+ end
+
+--> overrides
+ --replace the built-in flash function from the game client to flash when the player enters in combat
+ if (LowHealthFrame) then
+ function LowHealthFrame:SetInCombat(inCombat)
+ if self.inCombat ~= inCombat then
+ self.inCombat = inCombat;
+ if ( self.inCombat ) then
+ --FlashClientIcon();
+ end
+ self:EvaluateVisibleState();
+ end
+ end
+ end
+
+--> build options panel
+
+ local options = {
+ {
+ type = "toggle",
+ name = L["STRING_READYCHECK"],
+ desc = L["STRING_READYCHECK_DESC"],
+ order = 1,
+ get = function() return FlashTaskBar.db.profile.readycheck end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.readycheck = not FlashTaskBar.db.profile.readycheck
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_PVPQUEUES"],
+ desc = L["STRING_PVPQUEUES_DESC"],
+ order = 2,
+ get = function() return FlashTaskBar.db.profile.arena_queue end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.arena_queue = not FlashTaskBar.db.profile.arena_queue
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_FINDERQUEUES"],
+ desc = L["STRING_FINDERQUEUES_DESC"],
+ order = 3,
+ get = function() return FlashTaskBar.db.profile.group_queue end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.group_queue = not FlashTaskBar.db.profile.group_queue
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_PETBATTLES"] ,
+ desc = L["STRING_PETBATTLES_DESC"] ,
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.petbattle_queue end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.petbattle_queue = not FlashTaskBar.db.profile.petbattle_queue
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_BRAWLERS"],
+ desc = L["STRING_BRAWLERS_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.brawlers_queue end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.brawlers_queue = not FlashTaskBar.db.profile.brawlers_queue
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_PULL"],
+ desc = L["STRING_PULL_DESC"],
+ order = 4,
+ get = function() return FlashTaskBar.db.profile.pull_timers end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.pull_timers = not FlashTaskBar.db.profile.pull_timers
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_ENTERCOMBAT"],
+ desc = L["STRING_ENTERCOMBAT_DESC"],
+ order = 5,
+ get = function() return FlashTaskBar.db.profile.enter_combat end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.enter_combat = not FlashTaskBar.db.profile.enter_combat
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_FLYPOINT"],
+ desc = L["STRING_FLYPOINT_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.end_taxi end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.end_taxi = not FlashTaskBar.db.profile.end_taxi
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_DISCONNECT"],
+ desc = L["STRING_DISCONNECT_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.disconnect_logout end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.disconnect_logout = not FlashTaskBar.db.profile.disconnect_logout
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_INVITES"],
+ desc = L["STRING_INVITES_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.invite end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.invite = not FlashTaskBar.db.profile.invite
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_INVITEIGNORE"],
+ desc = L["STRING_INVITEIGNORE_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.invite_ignore_on_autoaccept end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.invite_ignore_on_autoaccept = not FlashTaskBar.db.profile.invite_ignore_on_autoaccept
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_TRADE"],
+ desc = L["STRING_TRADE_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.trade end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.trade = not FlashTaskBar.db.profile.trade
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_BAGSFULL"],
+ desc = L["STRING_BAGSFULL_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.bags_full end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.bags_full = not FlashTaskBar.db.profile.bags_full
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_WORLDPVP"],
+ desc = L["STRING_WORLDPVP_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.worldpvp end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.worldpvp = not FlashTaskBar.db.profile.worldpvp
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_DUELREQUEST"] ,
+ desc = L["STRING_DUELREQUEST_DESC"] ,
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.duel_request end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.duel_request = not FlashTaskBar.db.profile.duel_request
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_SUMMON"],
+ desc = L["STRING_SUMMON_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.summon end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.summon = not FlashTaskBar.db.profile.summon
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_FATIGUE"],
+ desc = L["STRING_FATIGUE_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.fatigue end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.fatigue = not FlashTaskBar.db.profile.fatigue
+ end,
+ },
+ {
+ type = "toggle",
+ name = L["STRING_PLAYERNAME"],
+ desc = L["STRING_PLAYERNAME_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.on_chat_player_name end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.on_chat_player_name = not FlashTaskBar.db.profile.on_chat_player_name
+ if (FlashTaskBar.db.profile.on_chat_player_name) then
+ FlashTaskBar:EnableChatScan()
+ else
+ --ver se tem alguma outra funo usando o chat scan
+ if (not FlashTaskBar.db.profile.chat_scan) then
+ FlashTaskBar:DisableChatScan()
+ end
+ end
+ end,
+ },
+
+ --[=[
+ {
+ type = "toggle",
+ name = L["STRING_ONWHISPER"],
+ desc = L["STRING_ONWHISPER_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.whisper_blink end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.whisper_blink = not FlashTaskBar.db.profile.whisper_blink
+ if (FlashTaskBar.db.profile.whisper_blink) then
+ FlashTaskBar:EnableFlashOnWhisper()
+ else
+ FlashTaskBar:DoNotFlashOnWhisper()
+ end
+ end,
+ },
+ --]=]
+
+ {
+ type = "toggle",
+ name = L["STRING_BATTLEGROUND"],
+ desc = L["STRING_BATTLEGROUND_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.battleground_end end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.battleground_end = not FlashTaskBar.db.profile.battleground_end
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_ONCOUNTDOWN"],
+ desc = L["STRING_ONCOUNTDOWN_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.timer_start end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.timer_start = not FlashTaskBar.db.profile.timer_start
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_TARGETLOWHEALTH"],
+ desc = L["STRING_TARGETLOWHEALTH_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.low_health end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.low_health = not FlashTaskBar.db.profile.low_health
+ if (FlashTaskBar.db.profile.low_health) then
+ FlashTaskBar:EnableCheckHealth (true)
+ else
+ FlashTaskBar:EnableCheckHealth (false)
+ end
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_TARGETLOSTHEALTH"],
+ desc = L["STRING_TARGETLOSTHEALTH_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.lost_health end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.lost_health = not FlashTaskBar.db.profile.lost_health
+ if (FlashTaskBar.db.profile.lost_health) then
+ FlashTaskBar:EnableCheckHealth (true)
+ else
+ FlashTaskBar:EnableCheckHealth (false)
+ end
+ end,
+ },
+
+ {
+ type = "toggle",
+ name = L["STRING_ONPLAYERDEATH"],
+ desc = L["STRING_ONPLAYERDEATH_DESC"],
+ order = 6,
+ get = function() return FlashTaskBar.db.profile.player_died end,
+ set = function (self, val)
+ FlashTaskBar.db.profile.player_died = not FlashTaskBar.db.profile.player_died
+ if (FlashTaskBar.db.profile.player_died) then
+ FlashTaskBar:EnablePlayerHealthMonitor()
+ else
+ FlashTaskBar:DisablePlayerHealthMonitor()
+ end
+ end,
+ },
+ }
+
+ local options_text_template = FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+ local options_switch_template = FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
+ local options_slider_template = FlashTaskBar:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
+ local options_button_template = FlashTaskBar:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
+
+ local general_text1 = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_GENERALSETTINGS"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ general_text1:SetPoint ("topleft", main_frame, "topleft", 10, -50)
+ FlashTaskBar:SetFontSize (general_text1, 16)
+
+ local general_settings_frame = CreateFrame ("frame", "FlashTaskBarGeneralOptionsFrame", FlashTaskBar.OptionsFrame1)
+ general_settings_frame:SetPoint ("topleft", 0, 0)
+ general_settings_frame:SetSize (1, 1)
+
+ FlashTaskBar:BuildMenu (general_settings_frame, options, 15, -77, 280, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
+
+ local y_chat_scan = -250
+
+ local camping_text1 = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_CAMPINGSETTINGS"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ camping_text1:SetPoint ("topleft", main_frame, "topleft", 10, y_chat_scan)
+ local sound_button_y = y_chat_scan
+ FlashTaskBar:SetFontSize (camping_text1, 16)
+ y_chat_scan = y_chat_scan - 30
+
+ --> chat scan settings
+
+ --> title label
+ local blink_on_chat = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_CHATSCAN"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ blink_on_chat:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan)
+
+ --> enabled
+ local enable_chat_filter = function (_, _, value)
+ FlashTaskBar.db.profile.chat_scan = value
+ if (value) then
+ FlashTaskBar:EnableChatScan()
+ else
+ --ver se tem alguma outra funo usando o chat scan
+ if (not FlashTaskBar.db.profile.on_chat_player_name) then
+ FlashTaskBar:DisableChatScan()
+ end
+ end
+ end
+ local chat_scan_switch, chat_scan_label = FlashTaskBar:CreateSwitch (FlashTaskBar.OptionsFrame1, enable_chat_filter, FlashTaskBar.db.profile.chat_scan, _, _, _, _, "switch_enable_chat_scan", _, _, _, _, L["STRING_CHATSCAN_ENABLED"] .. ":", FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ chat_scan_switch:SetAsCheckBox()
+ chat_scan_switch.tooltip = L["STRING_CHATSCAN_ENABLED_DESC"]
+ chat_scan_label:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-20)
+
+ --> key words
+ --add
+ local chat_scan_keyword, label_chat_scan_keyword = FlashTaskBar:CreateTextEntry (FlashTaskBar.OptionsFrame1, function()end, 120, 20, "entry_add_keyword", _, L["STRING_ADDKEYWORD"] .. ":", FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ label_chat_scan_keyword:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-40)
+
+ local add_key_word_func = function()
+ local keyword = chat_scan_keyword.text
+ if (keyword ~= "") then
+ tinsert (FlashTaskBar.db.profile.chat_scan_keywords, keyword)
+ end
+ chat_scan_keyword.text = ""
+ chat_scan_keyword:ClearFocus()
+ FlashTaskBar.OptionsFrame1.dropdown_keyword_remove:Refresh()
+ FlashTaskBar.OptionsFrame1.dropdown_keyword_remove:Select (1, true)
+ end
+ local button_add_keyword = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, add_key_word_func, 60, 18, L["STRING_ADD"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_add_keyword:SetPoint ("left", chat_scan_keyword, "right", 2, 0)
+
+ --remove
+ local dropdown_keyword_erase_fill = function()
+ local t = {}
+ for i, keyword in ipairs (FlashTaskBar.db.profile.chat_scan_keywords) do
+ t [#t+1] = {value = i, label = keyword, onclick = empty_func}
+ end
+ return t
+ end
+ local label_keyword_remove = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_ERASEKEYWORD"] .. ": ", FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ local dropdown_keyword_remove = FlashTaskBar:CreateDropDown (FlashTaskBar.OptionsFrame1, dropdown_keyword_erase_fill, _, 160, 20, "dropdown_keyword_remove", _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ dropdown_keyword_remove:SetPoint ("left", label_keyword_remove, "right", 2, 0)
+
+ local keyword_remove = function()
+ local value = dropdown_keyword_remove.value
+ tremove (FlashTaskBar.db.profile.chat_scan_keywords, value)
+ dropdown_keyword_remove:Refresh()
+ dropdown_keyword_remove:Select (1, true)
+ end
+ local button_keyword_remove = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, keyword_remove, 60, 18, L["STRING_REMOVE"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_keyword_remove:SetPoint ("left", dropdown_keyword_remove, "right", 2, 0)
+ label_keyword_remove:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-60)
+
+ --ativar o chat scan se necessrio
+ if (FlashTaskBar.db.profile.chat_scan or FlashTaskBar.db.profile.on_chat_player_name) then
+ FlashTaskBar:EnableChatScan()
+ end
+
+ --> combat log scan settings
+ --> title label
+ local blink_on_combatlog = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_COMBATLOGSCAN"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ blink_on_combatlog:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-90)
+
+ --> enabled
+ local enable_combatlog_filter = function (_, _, value)
+ FlashTaskBar.db.profile.combat_log = value
+ if (value) then
+ FlashTaskBar:EnableCombatLogScan()
+ else
+ FlashTaskBar:DisableCombatLogScan()
+ end
+ end
+ local combatlog_scan_switch, combatlog_scan_label = FlashTaskBar:CreateSwitch (FlashTaskBar.OptionsFrame1, enable_combatlog_filter, FlashTaskBar.db.profile.combat_log, _, _, _, _, "switch_enable_combatlog_scan", _, _, _, _, L["STRING_COMBATLOGSCAN_ENABLED"] .. ":", FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ combatlog_scan_switch.tooltip = L["STRING_COMBATLOGSCAN_ENABLED_DESC"]
+ combatlog_scan_switch:SetAsCheckBox()
+ combatlog_scan_label:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-110)
+
+ --> key words
+ --add
+ local combatlog_scan_keyword, label_combatlog_scan_keyword = FlashTaskBar:CreateTextEntry (FlashTaskBar.OptionsFrame1, function()end, 120, 20, "entry_add_keyword", _, L["STRING_RARENPCSCAN_NPCNAME"] .. ":", FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ label_combatlog_scan_keyword:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-130)
+
+ local add_key_word_func = function()
+ local keyword = combatlog_scan_keyword.text
+ if (keyword ~= "") then
+ tinsert (FlashTaskBar.db.profile.combat_log_keywords, keyword)
+ end
+ combatlog_scan_keyword.text = ""
+ combatlog_scan_keyword:ClearFocus()
+ FlashTaskBar.OptionsFrame1.dropdown_combatlog_keyword_remove:Refresh()
+ FlashTaskBar.OptionsFrame1.dropdown_combatlog_keyword_remove:Select (1, true)
+ FlashTaskBar:BuildCombatLogKeywordTable()
+ end
+ local button_add_keyword = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, add_key_word_func, 60, 18, L["STRING_ADD"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_add_keyword:SetPoint ("left", combatlog_scan_keyword, "right", 2, 0)
+
+ --remove
+ local dropdown_keyword_erase_fill = function()
+ local t = {}
+ for i, keyword in ipairs (FlashTaskBar.db.profile.combat_log_keywords) do
+ t [#t+1] = {value = i, label = keyword, onclick = empty_func}
+ end
+ return t
+ end
+ local label_keyword_remove = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_REMOVE_TITLE"] .. ": ", FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ local dropdown_keyword_remove = FlashTaskBar:CreateDropDown (FlashTaskBar.OptionsFrame1, dropdown_keyword_erase_fill, _, 160, 20, "dropdown_combatlog_keyword_remove", _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ dropdown_keyword_remove:SetPoint ("left", label_keyword_remove, "right", 2, 0)
+
+ local keyword_remove = function()
+ local value = dropdown_keyword_remove.value
+ tremove (FlashTaskBar.db.profile.combat_log_keywords, value)
+ dropdown_keyword_remove:Refresh()
+ dropdown_keyword_remove:Select (1, true)
+ FlashTaskBar:BuildCombatLogKeywordTable()
+ end
+ local button_keyword_remove = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, keyword_remove, 60, 18, L["STRING_REMOVE"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_keyword_remove:SetPoint ("left", dropdown_keyword_remove, "right", 2, 0)
+ label_keyword_remove:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-150)
+
+ if (FlashTaskBar.db.profile.combat_log) then
+ FlashTaskBar:EnableCombatLogScan()
+ end
+
+ --> rare mob scan settings
+ --> title label
+ local blink_on_raremob = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_RARENPCSCAN"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ blink_on_raremob:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-180)
+
+ --> enabled
+ local enable_raremob_filter = function (_, _, value)
+ FlashTaskBar.db.profile.rare_scan = value
+ if (value) then
+ FlashTaskBar:EnableRareMobScan()
+ else
+ FlashTaskBar:DisableRareMobScan()
+ end
+ end
+ local raremob_scan_switch, raremob_scan_label = FlashTaskBar:CreateSwitch (FlashTaskBar.OptionsFrame1, enable_raremob_filter, FlashTaskBar.db.profile.rare_scan, _, _, _, _, "switch_enable_raremob_scan", _, _, _, _, L["STRING_RARENPCSCAN_ENABLED"] .. ":", FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ raremob_scan_switch:SetAsCheckBox()
+ raremob_scan_switch.tooltip = L["STRING_RARENPCSCAN_DESC"]
+ raremob_scan_label:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-200)
+
+ --> all rares
+ local enable_raremob_all_filter = function (_, _, value)
+ FlashTaskBar.db.profile.any_rare = value
+ end
+ local raremob_all_scan_switch, raremob_all_scan_label = FlashTaskBar:CreateSwitch (FlashTaskBar.OptionsFrame1, enable_raremob_all_filter, FlashTaskBar.db.profile.any_rare, _, _, _, _, "switch_enable_raremob_all_scan", _, _, _, _, L["STRING_RARENPCSCAN_ANYNPC"] .. ":", FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ raremob_all_scan_switch:SetAsCheckBox()
+ raremob_all_scan_label:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-220)
+
+ --> key words
+ --add
+ local raremob_scan_keyword, label_raremob_scan_keyword = FlashTaskBar:CreateTextEntry (FlashTaskBar.OptionsFrame1, function()end, 120, 20, "raremob_add_keyword", _, L["STRING_RARENPCSCAN_NPCNAME"] .. ":", FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ label_raremob_scan_keyword:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-240)
+
+ local add_key_word_func = function()
+ local keyword = raremob_scan_keyword.text
+ if (keyword ~= "") then
+ tinsert (FlashTaskBar.db.profile.rare_names, keyword)
+ end
+ raremob_scan_keyword.text = ""
+ raremob_scan_keyword:ClearFocus()
+ FlashTaskBar.OptionsFrame1.dropdown_rare_keyword_remove:Refresh()
+ FlashTaskBar.OptionsFrame1.dropdown_rare_keyword_remove:Select (1, true)
+ end
+ local button_add_keyword = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, add_key_word_func, 60, 18, L["STRING_ADD"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_add_keyword:SetPoint ("left", raremob_scan_keyword, "right", 2, 0)
+
+ --remove
+ local dropdown_keyword_erase_fill = function()
+ local t = {}
+ for i, keyword in ipairs (FlashTaskBar.db.profile.rare_names) do
+ t [#t+1] = {value = i, label = keyword, onclick = empty_func}
+ end
+ return t
+ end
+ local label_keyword_remove = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_REMOVE_TITLE"] .. ": ", FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ local dropdown_keyword_remove = FlashTaskBar:CreateDropDown (FlashTaskBar.OptionsFrame1, dropdown_keyword_erase_fill, _, 160, 20, "dropdown_rare_keyword_remove", _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ dropdown_keyword_remove:SetPoint ("left", label_keyword_remove, "right", 2, 0)
+
+ local keyword_remove = function()
+ local value = dropdown_keyword_remove.value
+ tremove (FlashTaskBar.db.profile.rare_names, value)
+ dropdown_keyword_remove:Refresh()
+ dropdown_keyword_remove:Select (1, true)
+ end
+ local button_keyword_remove = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, keyword_remove, 60, 20, L["STRING_REMOVE"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ button_keyword_remove:SetPoint ("left", dropdown_keyword_remove, "right", 2, 0)
+ label_keyword_remove:SetPoint ("topleft", FlashTaskBar.OptionsFrame1, "topleft", 10, y_chat_scan-260)
+
+ if (FlashTaskBar.db.profile.rare_scan) then
+ FlashTaskBar:EnableRareMobScan()
+ end
+
+ --> sound options
+ local sound_x = 380
+ local sound_text1 = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_SOUNDSETTINGS"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ sound_text1:SetPoint ("topleft", main_frame, "topleft", sound_x, sound_button_y)
+ FlashTaskBar:SetFontSize (sound_text1, 16)
+
+ local open_sound_panel = function()
+ if (_G.FlashTaskbarSoundSettings) then
+ _G.FlashTaskbarSoundSettings:Show()
+ return
+ end
+
+ local f = DF:Create1PxPanel (FlashTaskBar.OptionsFrame1, 450, 300, "", "FlashTaskbarSoundSettings", nil, nil, nil)
+ f:SetPoint ("center", FlashTaskBar.OptionsFrame1, "center")
+ f:SetSize (FlashTaskBar.OptionsFrame1:GetSize())
+ f:SetFrameLevel (FlashTaskBar.OptionsFrame1:GetFrameLevel()+5)
+ f:SetLocked (true)
+
+ f:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], tile = true, tileSize = 64})
+ f:SetBackdropColor (0, 0, 0, 1)
+
+ local close_sound_settings = FlashTaskBar:CreateButton (f, function() f:Hide() end, 160, 20, L["STRING_CLOSESOUNDPANEL"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ close_sound_settings:SetPoint ("topleft", f, "topleft", 10, -520)
+ close_sound_settings:SetIcon ([[Interface\Scenarios\ScenarioIcon-Check]], 16, 16, "overlay", {0, 1, 0, 1}, nil, 6, nil, 1)
+
+ local sound_title = FlashTaskBar:CreateLabel (f, L["STRING_SOUNDSETTINGS"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ sound_title:SetPoint ("topleft", f, "topleft", 10, -50)
+ FlashTaskBar:SetFontSize (sound_title, 16)
+ local sound_title_desc = FlashTaskBar:CreateLabel (f, L["STRING_SOUNDSETTINGS_DESC"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ sound_title_desc:SetPoint ("topleft", f, "topleft", 10, -70)
+
+ local localize_key = {
+ readycheck = "READYCHECK",
+ arena_queue = "PVPQUEUES",
+ group_queue = "FINDERQUEUES",
+ petbattle_queue = "PETBATTLES",
+ brawlers_queue = "BRAWLERS",
+ pull_timers = "PULL",
+ enter_combat = "ENTERCOMBAT",
+ end_taxi = "FLYPOINT",
+ chat_scan = "CHATSCAN",
+ combat_log = "COMBATLOGSCAN",
+ rare_scan = "RARENPCSCAN",
+ disconnect_logout = "DISCONNECT",
+ invite = "INVITES",
+ trade = "TRADE",
+ bags_full = "BAGSFULL",
+ worldpvp = "WORLDPVP",
+ duel_request = "DUELREQUEST",
+ summon = "SUMMON",
+ fatigue = "FATIGUE",
+ battleground_end = "BATTLEGROUND",
+ on_chat_player_name = "PLAYERNAME",
+ player_died = "ONPLAYERDEATH",
+ }
+
+ --the game cannot play sounds when logging off
+ local settings = {
+ "rare_scan",
+ "arena_queue",
+ "group_queue",
+ "readycheck",
+ "petbattle_queue",
+ "brawlers_queue",
+ "pull_timers",
+ "enter_combat",
+ "end_taxi",
+ "chat_scan",
+ "combat_log",
+ "invite",
+ "trade",
+ "bags_full",
+ "worldpvp",
+ "duel_request",
+ "summon",
+ "fatigue",
+ "on_chat_player_name",
+ "battleground_end",
+ "player_died"
+ }
+
+ local sound_options = {}
+ local y = -95
+ local x = 10
+
+ local checkbox_ontoggle = function (self, _, value)
+ self.MyConfigTable.enabled = not self.MyConfigTable.enabled
+ end
+ local sound_dropdown_selected = function (self, _, value)
+ self.MyConfigTable.sound = value
+ PlaySoundFile (LibStub:GetLibrary("LibSharedMedia-3.0"):Fetch ("sound", value), "Master")
+ end
+ local SoundTable
+ local sound_dropdown_fill = function (capsule)
+ if (not SoundTable) then
+ SoundTable = {}
+ local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+ for name, _ in pairs (SharedMedia:HashTable ("sound")) do
+ tinsert (SoundTable, {value = name, label = name, onclick = sound_dropdown_selected})
+ end
+ end
+ return SoundTable
+ end
+
+ local switch_name = 999
+ for index, config_key in ipairs (settings) do
+ local name_locale = L["STRING_" .. localize_key [config_key]] .. ":"
+ local desc_locale = L["STRING_" .. localize_key [config_key] .. "_DESC"]
+ local config_table = FlashTaskBar.db.profile.sound_enabled [config_key]
+
+ local label = FlashTaskBar:CreateLabel (f, name_locale, FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ label.color = "yellow"
+ label:SetPoint (x, y)
+
+ local checkbox = FlashTaskBar:CreateSwitch (f, checkbox_ontoggle, config_table.enabled, _, _, _, _, _, nil, _, _, _, _, FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
+ checkbox:SetAsCheckBox()
+ checkbox.tooltip = desc_locale
+ checkbox.MyConfigTable = config_table
+ checkbox:SetPoint (x + 120, y)
+
+ local dropdown = FlashTaskBar:CreateDropDown (f, sound_dropdown_fill, config_table.sound, 160, 20, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ dropdown.MyConfigTable = config_table
+ dropdown:SetPoint (x + 180, y)
+
+ y = y - 20
+
+ switch_name = switch_name + 1
+ end
+
+ FlashTaskBar.NoBGSound = FlashTaskBar:CreateLabel (f, L["STRING_BACKGROUND_SOUND"], FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ FlashTaskBar.NoBGSound.color = "red"
+ FlashTaskBar.NoBGSound.fontsize = 12
+ FlashTaskBar.NoBGSound.align = "center"
+ FlashTaskBar.NoBGSound:SetPoint (415, -150)
+
+ f:SetScript ("OnShow", function()
+ local isBGSoundDisabled = GetCVar ("Sound_EnableSoundWhenGameIsInBG")
+ if (isBGSoundDisabled == "0") then
+ FlashTaskBar.NoBGSound:Show()
+ else
+ FlashTaskBar.NoBGSound:Hide()
+ end
+ end)
+ end
+
+ local open_sound_settings = FlashTaskBar:CreateButton (FlashTaskBar.OptionsFrame1, open_sound_panel, 160, 18, L["STRING_OPENSOUNDPANEL"], _, _, _, _, _, _, FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ open_sound_settings:SetPoint ("topleft", main_frame, "topleft", sound_x-1, sound_button_y-30)
+ open_sound_settings:SetIcon ([[Interface\Buttons\UI-GuildButton-MOTD-Up]], 16, 15, "overlay", {1, 0, 0, 1}, nil, 6, nil, 1)
+end
+
diff --git a/FlashTaskBar.toc b/FlashTaskBar.toc
new file mode 100644
index 0000000..e42414f
--- /dev/null
+++ b/FlashTaskBar.toc
@@ -0,0 +1,22 @@
+## Interface: 80200
+## Title: Flash Task Bar
+## Notes: Flashes the taskbar when you are alt-tabbed and queue for raid finder, battleground pops up.
+## SavedVariables: FlashTaskbarDB
+
+#@no-lib-strip@
+libs\libs.xml
+#@end-no-lib-strip@
+
+locales\enUS.lua
+locales\deDE.lua
+locales\esES.lua
+locales\esMX.lua
+locales\frFR.lua
+locales\itIT.lua
+locales\koKR.lua
+locales\ptBR.lua
+locales\ruRU.lua
+locales\zhCN.lua
+locales\zhTW.lua
+
+FlashTaskBar.lua
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e62ec04
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/libs/AceAddon-3.0/AceAddon-3.0.lua b/libs/AceAddon-3.0/AceAddon-3.0.lua
new file mode 100644
index 0000000..a7f7279
--- /dev/null
+++ b/libs/AceAddon-3.0/AceAddon-3.0.lua
@@ -0,0 +1,674 @@
+--- **AceAddon-3.0** provides a template for creating addon objects.
+-- It'll provide you with a set of callback functions that allow you to simplify the loading
+-- process of your addon.\\
+-- Callbacks provided are:\\
+-- * **OnInitialize**, which is called directly after the addon is fully loaded.
+-- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.
+-- * **OnDisable**, which is only called when your addon is manually being disabled.
+-- @usage
+-- -- A small (but complete) addon, that doesn't do anything,
+-- -- but shows usage of the callbacks.
+-- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
+--
+-- function MyAddon:OnInitialize()
+-- -- do init tasks here, like loading the Saved Variables,
+-- -- or setting up slash commands.
+-- end
+--
+-- function MyAddon:OnEnable()
+-- -- Do more initialization here, that really enables the use of your addon.
+-- -- Register Events, Hook functions, Create Frames, Get information from
+-- -- the game that wasn't available in OnInitialize
+-- end
+--
+-- function MyAddon:OnDisable()
+-- -- Unhook, Unregister Events, Hide frames that you created.
+-- -- You would probably only use an OnDisable if you want to
+-- -- build a "standby" mode, or be able to toggle modules on/off.
+-- end
+-- @class file
+-- @name AceAddon-3.0.lua
+-- @release $Id: AceAddon-3.0.lua 1084 2013-04-27 20:14:11Z nevcairiel $
+
+local MAJOR, MINOR = "AceAddon-3.0", 12
+local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceAddon then return end -- No Upgrade needed.
+
+AceAddon.frame = AceAddon.frame or CreateFrame("Frame", "AceAddon30Frame") -- Our very own frame
+AceAddon.addons = AceAddon.addons or {} -- addons in general
+AceAddon.statuses = AceAddon.statuses or {} -- statuses of addon.
+AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new and not initialized
+AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled
+AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon
+
+-- Lua APIs
+local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
+local fmt, tostring = string.format, tostring
+local select, pairs, next, type, unpack = select, pairs, next, type, unpack
+local loadstring, assert, error = loadstring, assert, error
+local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: LibStub, IsLoggedIn, geterrorhandler
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function CreateDispatcher(argCount)
+ local code = [[
+ local xpcall, eh = ...
+ local method, ARGS
+ local function call() return method(ARGS) end
+
+ local function dispatch(func, ...)
+ method = func
+ if not method then return end
+ ARGS = ...
+ return xpcall(call, eh)
+ end
+
+ return dispatch
+ ]]
+
+ local ARGS = {}
+ for i = 1, argCount do ARGS[i] = "arg"..i end
+ code = code:gsub("ARGS", tconcat(ARGS, ", "))
+ return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
+end
+
+local Dispatchers = setmetatable({}, {__index=function(self, argCount)
+ local dispatcher = CreateDispatcher(argCount)
+ rawset(self, argCount, dispatcher)
+ return dispatcher
+end})
+Dispatchers[0] = function(func)
+ return xpcall(func, errorhandler)
+end
+
+local function safecall(func, ...)
+ -- we check to see if the func is passed is actually a function here and don't error when it isn't
+ -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not
+ -- present execution should continue without hinderance
+ if type(func) == "function" then
+ return Dispatchers[select('#', ...)](func, ...)
+ end
+end
+
+-- local functions that will be implemented further down
+local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype
+
+-- used in the addon metatable
+local function addontostring( self ) return self.name end
+
+-- Check if the addon is queued for initialization
+local function queuedForInitialization(addon)
+ for i = 1, #AceAddon.initializequeue do
+ if AceAddon.initializequeue[i] == addon then
+ return true
+ end
+ end
+ return false
+end
+
+--- Create a new AceAddon-3.0 addon.
+-- Any libraries you specified will be embeded, and the addon will be scheduled for
+-- its OnInitialize and OnEnable callbacks.
+-- The final addon object, with all libraries embeded, will be returned.
+-- @paramsig [object ,]name[, lib, ...]
+-- @param object Table to use as a base for the addon (optional)
+-- @param name Name of the addon object to create
+-- @param lib List of libraries to embed into the addon
+-- @usage
+-- -- Create a simple addon object
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0")
+--
+-- -- Create a Addon object based on the table of a frame
+-- local MyFrame = CreateFrame("Frame")
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0")
+function AceAddon:NewAddon(objectorname, ...)
+ local object,name
+ local i=1
+ if type(objectorname)=="table" then
+ object=objectorname
+ name=...
+ i=2
+ else
+ name=objectorname
+ end
+ if type(name)~="string" then
+ error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2)
+ end
+ if self.addons[name] then
+ error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2)
+ end
+
+ object = object or {}
+ object.name = name
+
+ local addonmeta = {}
+ local oldmeta = getmetatable(object)
+ if oldmeta then
+ for k, v in pairs(oldmeta) do addonmeta[k] = v end
+ end
+ addonmeta.__tostring = addontostring
+
+ setmetatable( object, addonmeta )
+ self.addons[name] = object
+ object.modules = {}
+ object.orderedModules = {}
+ object.defaultModuleLibraries = {}
+ Embed( object ) -- embed NewModule, GetModule methods
+ self:EmbedLibraries(object, select(i,...))
+
+ -- add to queue of addons to be initialized upon ADDON_LOADED
+ tinsert(self.initializequeue, object)
+ return object
+end
+
+
+--- Get the addon object by its name from the internal AceAddon registry.
+-- Throws an error if the addon object cannot be found (except if silent is set).
+-- @param name unique name of the addon object
+-- @param silent if true, the addon is optional, silently return nil if its not found
+-- @usage
+-- -- Get the Addon
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+function AceAddon:GetAddon(name, silent)
+ if not silent and not self.addons[name] then
+ error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2)
+ end
+ return self.addons[name]
+end
+
+-- - Embed a list of libraries into the specified addon.
+-- This function will try to embed all of the listed libraries into the addon
+-- and error if a single one fails.
+--
+-- **Note:** This function is for internal use by :NewAddon/:NewModule
+-- @paramsig addon, [lib, ...]
+-- @param addon addon object to embed the libs in
+-- @param lib List of libraries to embed into the addon
+function AceAddon:EmbedLibraries(addon, ...)
+ for i=1,select("#", ... ) do
+ local libname = select(i, ...)
+ self:EmbedLibrary(addon, libname, false, 4)
+ end
+end
+
+-- - Embed a library into the addon object.
+-- This function will check if the specified library is registered with LibStub
+-- and if it has a :Embed function to call. It'll error if any of those conditions
+-- fails.
+--
+-- **Note:** This function is for internal use by :EmbedLibraries
+-- @paramsig addon, libname[, silent[, offset]]
+-- @param addon addon object to embed the library in
+-- @param libname name of the library to embed
+-- @param silent marks an embed to fail silently if the library doesn't exist (optional)
+-- @param offset will push the error messages back to said offset, defaults to 2 (optional)
+function AceAddon:EmbedLibrary(addon, libname, silent, offset)
+ local lib = LibStub:GetLibrary(libname, true)
+ if not lib and not silent then
+ error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of %q."):format(tostring(libname)), offset or 2)
+ elseif lib and type(lib.Embed) == "function" then
+ lib:Embed(addon)
+ tinsert(self.embeds[addon], libname)
+ return true
+ elseif lib then
+ error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Library '%s' is not Embed capable"):format(libname), offset or 2)
+ end
+end
+
+--- Return the specified module from an addon object.
+-- Throws an error if the addon object cannot be found (except if silent is set)
+-- @name //addon//:GetModule
+-- @paramsig name[, silent]
+-- @param name unique name of the module
+-- @param silent if true, the module is optional, silently return nil if its not found (optional)
+-- @usage
+-- -- Get the Addon
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- -- Get the Module
+-- MyModule = MyAddon:GetModule("MyModule")
+function GetModule(self, name, silent)
+ if not self.modules[name] and not silent then
+ error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2)
+ end
+ return self.modules[name]
+end
+
+local function IsModuleTrue(self) return true end
+
+--- Create a new module for the addon.
+-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.\\
+-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as
+-- an addon object.
+-- @name //addon//:NewModule
+-- @paramsig name[, prototype|lib[, lib, ...]]
+-- @param name unique name of the module
+-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional)
+-- @param lib List of libraries to embed into the addon
+-- @usage
+-- -- Create a module with some embeded libraries
+-- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0")
+--
+-- -- Create a module with a prototype
+-- local prototype = { OnEnable = function(self) print("OnEnable called!") end }
+-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0")
+function NewModule(self, name, prototype, ...)
+ if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end
+ if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end
+
+ if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end
+
+ -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well.
+ -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is.
+ local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name))
+
+ module.IsModule = IsModuleTrue
+ module:SetEnabledState(self.defaultModuleState)
+ module.moduleName = name
+
+ if type(prototype) == "string" then
+ AceAddon:EmbedLibraries(module, prototype, ...)
+ else
+ AceAddon:EmbedLibraries(module, ...)
+ end
+ AceAddon:EmbedLibraries(module, unpack(self.defaultModuleLibraries))
+
+ if not prototype or type(prototype) == "string" then
+ prototype = self.defaultModulePrototype or nil
+ end
+
+ if type(prototype) == "table" then
+ local mt = getmetatable(module)
+ mt.__index = prototype
+ setmetatable(module, mt) -- More of a Base class type feel.
+ end
+
+ safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy.
+ self.modules[name] = module
+ tinsert(self.orderedModules, module)
+
+ return module
+end
+
+--- Returns the real name of the addon or module, without any prefix.
+-- @name //addon//:GetName
+-- @paramsig
+-- @usage
+-- print(MyAddon:GetName())
+-- -- prints "MyAddon"
+function GetName(self)
+ return self.moduleName or self.name
+end
+
+--- Enables the Addon, if possible, return true or false depending on success.
+-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback
+-- and enabling all modules of the addon (unless explicitly disabled).\\
+-- :Enable() also sets the internal `enableState` variable to true
+-- @name //addon//:Enable
+-- @paramsig
+-- @usage
+-- -- Enable MyModule
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyModule = MyAddon:GetModule("MyModule")
+-- MyModule:Enable()
+function Enable(self)
+ self:SetEnabledState(true)
+
+ -- nevcairiel 2013-04-27: don't enable an addon/module if its queued for init still
+ -- it'll be enabled after the init process
+ if not queuedForInitialization(self) then
+ return AceAddon:EnableAddon(self)
+ end
+end
+
+--- Disables the Addon, if possible, return true or false depending on success.
+-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback
+-- and disabling all modules of the addon.\\
+-- :Disable() also sets the internal `enableState` variable to false
+-- @name //addon//:Disable
+-- @paramsig
+-- @usage
+-- -- Disable MyAddon
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyAddon:Disable()
+function Disable(self)
+ self:SetEnabledState(false)
+ return AceAddon:DisableAddon(self)
+end
+
+--- Enables the Module, if possible, return true or false depending on success.
+-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object.
+-- @name //addon//:EnableModule
+-- @paramsig name
+-- @usage
+-- -- Enable MyModule using :GetModule
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyModule = MyAddon:GetModule("MyModule")
+-- MyModule:Enable()
+--
+-- -- Enable MyModule using the short-hand
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyAddon:EnableModule("MyModule")
+function EnableModule(self, name)
+ local module = self:GetModule( name )
+ return module:Enable()
+end
+
+--- Disables the Module, if possible, return true or false depending on success.
+-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object.
+-- @name //addon//:DisableModule
+-- @paramsig name
+-- @usage
+-- -- Disable MyModule using :GetModule
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyModule = MyAddon:GetModule("MyModule")
+-- MyModule:Disable()
+--
+-- -- Disable MyModule using the short-hand
+-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
+-- MyAddon:DisableModule("MyModule")
+function DisableModule(self, name)
+ local module = self:GetModule( name )
+ return module:Disable()
+end
+
+--- Set the default libraries to be mixed into all modules created by this object.
+-- Note that you can only change the default module libraries before any module is created.
+-- @name //addon//:SetDefaultModuleLibraries
+-- @paramsig lib[, lib, ...]
+-- @param lib List of libraries to embed into the addon
+-- @usage
+-- -- Create the addon object
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
+-- -- Configure default libraries for modules (all modules need AceEvent-3.0)
+-- MyAddon:SetDefaultModuleLibraries("AceEvent-3.0")
+-- -- Create a module
+-- MyModule = MyAddon:NewModule("MyModule")
+function SetDefaultModuleLibraries(self, ...)
+ if next(self.modules) then
+ error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2)
+ end
+ self.defaultModuleLibraries = {...}
+end
+
+--- Set the default state in which new modules are being created.
+-- Note that you can only change the default state before any module is created.
+-- @name //addon//:SetDefaultModuleState
+-- @paramsig state
+-- @param state Default state for new modules, true for enabled, false for disabled
+-- @usage
+-- -- Create the addon object
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
+-- -- Set the default state to "disabled"
+-- MyAddon:SetDefaultModuleState(false)
+-- -- Create a module and explicilty enable it
+-- MyModule = MyAddon:NewModule("MyModule")
+-- MyModule:Enable()
+function SetDefaultModuleState(self, state)
+ if next(self.modules) then
+ error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2)
+ end
+ self.defaultModuleState = state
+end
+
+--- Set the default prototype to use for new modules on creation.
+-- Note that you can only change the default prototype before any module is created.
+-- @name //addon//:SetDefaultModulePrototype
+-- @paramsig prototype
+-- @param prototype Default prototype for the new modules (table)
+-- @usage
+-- -- Define a prototype
+-- local prototype = { OnEnable = function(self) print("OnEnable called!") end }
+-- -- Set the default prototype
+-- MyAddon:SetDefaultModulePrototype(prototype)
+-- -- Create a module and explicitly Enable it
+-- MyModule = MyAddon:NewModule("MyModule")
+-- MyModule:Enable()
+-- -- should print "OnEnable called!" now
+-- @see NewModule
+function SetDefaultModulePrototype(self, prototype)
+ if next(self.modules) then
+ error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2)
+ end
+ if type(prototype) ~= "table" then
+ error(("Usage: SetDefaultModulePrototype(prototype): 'prototype' - table expected got '%s'."):format(type(prototype)), 2)
+ end
+ self.defaultModulePrototype = prototype
+end
+
+--- Set the state of an addon or module
+-- This should only be called before any enabling actually happend, e.g. in/before OnInitialize.
+-- @name //addon//:SetEnabledState
+-- @paramsig state
+-- @param state the state of an addon or module (enabled=true, disabled=false)
+function SetEnabledState(self, state)
+ self.enabledState = state
+end
+
+
+--- Return an iterator of all modules associated to the addon.
+-- @name //addon//:IterateModules
+-- @paramsig
+-- @usage
+-- -- Enable all modules
+-- for name, module in MyAddon:IterateModules() do
+-- module:Enable()
+-- end
+local function IterateModules(self) return pairs(self.modules) end
+
+-- Returns an iterator of all embeds in the addon
+-- @name //addon//:IterateEmbeds
+-- @paramsig
+local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end
+
+--- Query the enabledState of an addon.
+-- @name //addon//:IsEnabled
+-- @paramsig
+-- @usage
+-- if MyAddon:IsEnabled() then
+-- MyAddon:Disable()
+-- end
+local function IsEnabled(self) return self.enabledState end
+local mixins = {
+ NewModule = NewModule,
+ GetModule = GetModule,
+ Enable = Enable,
+ Disable = Disable,
+ EnableModule = EnableModule,
+ DisableModule = DisableModule,
+ IsEnabled = IsEnabled,
+ SetDefaultModuleLibraries = SetDefaultModuleLibraries,
+ SetDefaultModuleState = SetDefaultModuleState,
+ SetDefaultModulePrototype = SetDefaultModulePrototype,
+ SetEnabledState = SetEnabledState,
+ IterateModules = IterateModules,
+ IterateEmbeds = IterateEmbeds,
+ GetName = GetName,
+}
+local function IsModule(self) return false end
+local pmixins = {
+ defaultModuleState = true,
+ enabledState = true,
+ IsModule = IsModule,
+}
+-- Embed( target )
+-- target (object) - target object to embed aceaddon in
+--
+-- this is a local function specifically since it's meant to be only called internally
+function Embed(target, skipPMixins)
+ for k, v in pairs(mixins) do
+ target[k] = v
+ end
+ if not skipPMixins then
+ for k, v in pairs(pmixins) do
+ target[k] = target[k] or v
+ end
+ end
+end
+
+
+-- - Initialize the addon after creation.
+-- This function is only used internally during the ADDON_LOADED event
+-- It will call the **OnInitialize** function on the addon object (if present),
+-- and the **OnEmbedInitialize** function on all embeded libraries.
+--
+-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
+-- @param addon addon object to intialize
+function AceAddon:InitializeAddon(addon)
+ safecall(addon.OnInitialize, addon)
+
+ local embeds = self.embeds[addon]
+ for i = 1, #embeds do
+ local lib = LibStub:GetLibrary(embeds[i], true)
+ if lib then safecall(lib.OnEmbedInitialize, lib, addon) end
+ end
+
+ -- we don't call InitializeAddon on modules specifically, this is handled
+ -- from the event handler and only done _once_
+end
+
+-- - Enable the addon after creation.
+-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED,
+-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons.
+-- It will call the **OnEnable** function on the addon object (if present),
+-- and the **OnEmbedEnable** function on all embeded libraries.\\
+-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.
+--
+-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
+-- Use :Enable on the addon itself instead.
+-- @param addon addon object to enable
+function AceAddon:EnableAddon(addon)
+ if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
+ if self.statuses[addon.name] or not addon.enabledState then return false end
+
+ -- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable.
+ self.statuses[addon.name] = true
+
+ safecall(addon.OnEnable, addon)
+
+ -- make sure we're still enabled before continueing
+ if self.statuses[addon.name] then
+ local embeds = self.embeds[addon]
+ for i = 1, #embeds do
+ local lib = LibStub:GetLibrary(embeds[i], true)
+ if lib then safecall(lib.OnEmbedEnable, lib, addon) end
+ end
+
+ -- enable possible modules.
+ local modules = addon.orderedModules
+ for i = 1, #modules do
+ self:EnableAddon(modules[i])
+ end
+ end
+ return self.statuses[addon.name] -- return true if we're disabled
+end
+
+-- - Disable the addon
+-- Note: This function is only used internally.
+-- It will call the **OnDisable** function on the addon object (if present),
+-- and the **OnEmbedDisable** function on all embeded libraries.\\
+-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.
+--
+-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
+-- Use :Disable on the addon itself instead.
+-- @param addon addon object to enable
+function AceAddon:DisableAddon(addon)
+ if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
+ if not self.statuses[addon.name] then return false end
+
+ -- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable.
+ self.statuses[addon.name] = false
+
+ safecall( addon.OnDisable, addon )
+
+ -- make sure we're still disabling...
+ if not self.statuses[addon.name] then
+ local embeds = self.embeds[addon]
+ for i = 1, #embeds do
+ local lib = LibStub:GetLibrary(embeds[i], true)
+ if lib then safecall(lib.OnEmbedDisable, lib, addon) end
+ end
+ -- disable possible modules.
+ local modules = addon.orderedModules
+ for i = 1, #modules do
+ self:DisableAddon(modules[i])
+ end
+ end
+
+ return not self.statuses[addon.name] -- return true if we're disabled
+end
+
+--- Get an iterator over all registered addons.
+-- @usage
+-- -- Print a list of all installed AceAddon's
+-- for name, addon in AceAddon:IterateAddons() do
+-- print("Addon: " .. name)
+-- end
+function AceAddon:IterateAddons() return pairs(self.addons) end
+
+--- Get an iterator over the internal status registry.
+-- @usage
+-- -- Print a list of all enabled addons
+-- for name, status in AceAddon:IterateAddonStatus() do
+-- if status then
+-- print("EnabledAddon: " .. name)
+-- end
+-- end
+function AceAddon:IterateAddonStatus() return pairs(self.statuses) end
+
+-- Following Iterators are deprecated, and their addon specific versions should be used
+-- e.g. addon:IterateEmbeds() instead of :IterateEmbedsOnAddon(addon)
+function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end
+function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end
+
+-- Event Handling
+local function onEvent(this, event, arg1)
+ -- 2011-08-17 nevcairiel - ignore the load event of Blizzard_DebugTools, so a potential startup error isn't swallowed up
+ if (event == "ADDON_LOADED" and arg1 ~= "Blizzard_DebugTools") or event == "PLAYER_LOGIN" then
+ -- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration
+ while(#AceAddon.initializequeue > 0) do
+ local addon = tremove(AceAddon.initializequeue, 1)
+ -- this might be an issue with recursion - TODO: validate
+ if event == "ADDON_LOADED" then addon.baseName = arg1 end
+ AceAddon:InitializeAddon(addon)
+ tinsert(AceAddon.enablequeue, addon)
+ end
+
+ if IsLoggedIn() then
+ while(#AceAddon.enablequeue > 0) do
+ local addon = tremove(AceAddon.enablequeue, 1)
+ AceAddon:EnableAddon(addon)
+ end
+ end
+ end
+end
+
+AceAddon.frame:RegisterEvent("ADDON_LOADED")
+AceAddon.frame:RegisterEvent("PLAYER_LOGIN")
+AceAddon.frame:SetScript("OnEvent", onEvent)
+
+-- upgrade embeded
+for name, addon in pairs(AceAddon.addons) do
+ Embed(addon, true)
+end
+
+-- 2010-10-27 nevcairiel - add new "orderedModules" table
+if oldminor and oldminor < 10 then
+ for name, addon in pairs(AceAddon.addons) do
+ addon.orderedModules = {}
+ for module_name, module in pairs(addon.modules) do
+ tinsert(addon.orderedModules, module)
+ end
+ end
+end
diff --git a/libs/AceAddon-3.0/AceAddon-3.0.xml b/libs/AceAddon-3.0/AceAddon-3.0.xml
new file mode 100644
index 0000000..dcf24c7
--- /dev/null
+++ b/libs/AceAddon-3.0/AceAddon-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceComm-3.0/AceComm-3.0.lua b/libs/AceComm-3.0/AceComm-3.0.lua
new file mode 100644
index 0000000..9a38979
--- /dev/null
+++ b/libs/AceComm-3.0/AceComm-3.0.lua
@@ -0,0 +1,305 @@
+--- **AceComm-3.0** allows you to send messages of unlimited length over the addon comm channels.
+-- It'll automatically split the messages into multiple parts and rebuild them on the receiving end.\\
+-- **ChatThrottleLib** is of course being used to avoid being disconnected by the server.
+--
+-- **AceComm-3.0** can be embeded into your addon, either explicitly by calling AceComm:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceComm itself.\\
+-- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceComm.
+-- @class file
+-- @name AceComm-3.0
+-- @release $Id: AceComm-3.0.lua 1174 2018-05-14 17:29:49Z h.leppkes@gmail.com $
+
+--[[ AceComm-3.0
+
+TODO: Time out old data rotting around from dead senders? Not a HUGE deal since the number of possible sender names is somewhat limited.
+
+]]
+
+local CallbackHandler = LibStub("CallbackHandler-1.0")
+local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib")
+
+local MAJOR, MINOR = "AceComm-3.0", 12
+local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceComm then return end
+
+-- Lua APIs
+local type, next, pairs, tostring = type, next, pairs, tostring
+local strsub, strfind = string.sub, string.find
+local match = string.match
+local tinsert, tconcat = table.insert, table.concat
+local error, assert = error, assert
+
+-- WoW APIs
+local Ambiguate = Ambiguate
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: LibStub, DEFAULT_CHAT_FRAME, geterrorhandler, RegisterAddonMessagePrefix
+
+AceComm.embeds = AceComm.embeds or {}
+
+-- for my sanity and yours, let's give the message type bytes some names
+local MSG_MULTI_FIRST = "\001"
+local MSG_MULTI_NEXT = "\002"
+local MSG_MULTI_LAST = "\003"
+local MSG_ESCAPE = "\004"
+
+-- remove old structures (pre WoW 4.0)
+AceComm.multipart_origprefixes = nil
+AceComm.multipart_reassemblers = nil
+
+-- the multipart message spool: indexed by a combination of sender+distribution+
+AceComm.multipart_spool = AceComm.multipart_spool or {}
+
+--- Register for Addon Traffic on a specified prefix
+-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent), max 16 characters
+-- @param method Callback to call on message reception: Function reference, or method name (string) to call on self. Defaults to "OnCommReceived"
+function AceComm:RegisterComm(prefix, method)
+ if method == nil then
+ method = "OnCommReceived"
+ end
+
+ if #prefix > 16 then -- TODO: 15?
+ error("AceComm:RegisterComm(prefix,method): prefix length is limited to 16 characters")
+ end
+ if C_ChatInfo then
+ C_ChatInfo.RegisterAddonMessagePrefix(prefix)
+ else
+ RegisterAddonMessagePrefix(prefix)
+ end
+
+ return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler
+end
+
+local warnedPrefix=false
+
+--- Send a message over the Addon Channel
+-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent)
+-- @param text Data to send, nils (\000) not allowed. Any length.
+-- @param distribution Addon channel, e.g. "RAID", "GUILD", etc; see SendAddonMessage API
+-- @param target Destination for some distributions; see SendAddonMessage API
+-- @param prio OPTIONAL: ChatThrottleLib priority, "BULK", "NORMAL" or "ALERT". Defaults to "NORMAL".
+-- @param callbackFn OPTIONAL: callback function to be called as each chunk is sent. receives 3 args: the user supplied arg (see next), the number of bytes sent so far, and the number of bytes total to send.
+-- @param callbackArg: OPTIONAL: first arg to the callback function. nil will be passed if not specified.
+function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg)
+ prio = prio or "NORMAL" -- pasta's reference implementation had different prio for singlepart and multipart, but that's a very bad idea since that can easily lead to out-of-sequence delivery!
+ if not( type(prefix)=="string" and
+ type(text)=="string" and
+ type(distribution)=="string" and
+ (target==nil or type(target)=="string" or type(target)=="number") and
+ (prio=="BULK" or prio=="NORMAL" or prio=="ALERT")
+ ) then
+ error('Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])', 2)
+ end
+
+ local textlen = #text
+ local maxtextlen = 255 -- Yes, the max is 255 even if the dev post said 256. I tested. Char 256+ get silently truncated. /Mikk, 20110327
+ local queueName = prefix..distribution..(target or "")
+
+ local ctlCallback = nil
+ if callbackFn then
+ ctlCallback = function(sent)
+ return callbackFn(callbackArg, sent, textlen)
+ end
+ end
+
+ local forceMultipart
+ if match(text, "^[\001-\009]") then -- 4.1+: see if the first character is a control character
+ -- we need to escape the first character with a \004
+ if textlen+1 > maxtextlen then -- would we go over the size limit?
+ forceMultipart = true -- just make it multipart, no escape problems then
+ else
+ text = "\004" .. text
+ end
+ end
+
+ if not forceMultipart and textlen <= maxtextlen then
+ -- fits all in one message
+ CTL:SendAddonMessage(prio, prefix, text, distribution, target, queueName, ctlCallback, textlen)
+ else
+ maxtextlen = maxtextlen - 1 -- 1 extra byte for part indicator in prefix(4.0)/start of message(4.1)
+
+ -- first part
+ local chunk = strsub(text, 1, maxtextlen)
+ CTL:SendAddonMessage(prio, prefix, MSG_MULTI_FIRST..chunk, distribution, target, queueName, ctlCallback, maxtextlen)
+
+ -- continuation
+ local pos = 1+maxtextlen
+
+ while pos+maxtextlen <= textlen do
+ chunk = strsub(text, pos, pos+maxtextlen-1)
+ CTL:SendAddonMessage(prio, prefix, MSG_MULTI_NEXT..chunk, distribution, target, queueName, ctlCallback, pos+maxtextlen-1)
+ pos = pos + maxtextlen
+ end
+
+ -- final part
+ chunk = strsub(text, pos)
+ CTL:SendAddonMessage(prio, prefix, MSG_MULTI_LAST..chunk, distribution, target, queueName, ctlCallback, textlen)
+ end
+end
+
+
+----------------------------------------
+-- Message receiving
+----------------------------------------
+
+do
+ local compost = setmetatable({}, {__mode = "k"})
+ local function new()
+ local t = next(compost)
+ if t then
+ compost[t]=nil
+ for i=#t,3,-1 do -- faster than pairs loop. don't even nil out 1/2 since they'll be overwritten
+ t[i]=nil
+ end
+ return t
+ end
+
+ return {}
+ end
+
+ local function lostdatawarning(prefix,sender,where)
+ DEFAULT_CHAT_FRAME:AddMessage(MAJOR..": Warning: lost network data regarding '"..tostring(prefix).."' from '"..tostring(sender).."' (in "..where..")")
+ end
+
+ function AceComm:OnReceiveMultipartFirst(prefix, message, distribution, sender)
+ local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
+ local spool = AceComm.multipart_spool
+
+ --[[
+ if spool[key] then
+ lostdatawarning(prefix,sender,"First")
+ -- continue and overwrite
+ end
+ --]]
+
+ spool[key] = message -- plain string for now
+ end
+
+ function AceComm:OnReceiveMultipartNext(prefix, message, distribution, sender)
+ local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
+ local spool = AceComm.multipart_spool
+ local olddata = spool[key]
+
+ if not olddata then
+ --lostdatawarning(prefix,sender,"Next")
+ return
+ end
+
+ if type(olddata)~="table" then
+ -- ... but what we have is not a table. So make it one. (Pull a composted one if available)
+ local t = new()
+ t[1] = olddata -- add old data as first string
+ t[2] = message -- and new message as second string
+ spool[key] = t -- and put the table in the spool instead of the old string
+ else
+ tinsert(olddata, message)
+ end
+ end
+
+ function AceComm:OnReceiveMultipartLast(prefix, message, distribution, sender)
+ local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
+ local spool = AceComm.multipart_spool
+ local olddata = spool[key]
+
+ if not olddata then
+ --lostdatawarning(prefix,sender,"End")
+ return
+ end
+
+ spool[key] = nil
+
+ if type(olddata) == "table" then
+ -- if we've received a "next", the spooled data will be a table for rapid & garbage-free tconcat
+ tinsert(olddata, message)
+ AceComm.callbacks:Fire(prefix, tconcat(olddata, ""), distribution, sender)
+ compost[olddata] = true
+ else
+ -- if we've only received a "first", the spooled data will still only be a string
+ AceComm.callbacks:Fire(prefix, olddata..message, distribution, sender)
+ end
+ end
+end
+
+
+
+
+
+
+----------------------------------------
+-- Embed CallbackHandler
+----------------------------------------
+
+if not AceComm.callbacks then
+ AceComm.callbacks = CallbackHandler:New(AceComm,
+ "_RegisterComm",
+ "UnregisterComm",
+ "UnregisterAllComm")
+end
+
+AceComm.callbacks.OnUsed = nil
+AceComm.callbacks.OnUnused = nil
+
+local function OnEvent(self, event, prefix, message, distribution, sender)
+ if event == "CHAT_MSG_ADDON" then
+ sender = Ambiguate(sender, "none")
+ local control, rest = match(message, "^([\001-\009])(.*)")
+ if control then
+ if control==MSG_MULTI_FIRST then
+ AceComm:OnReceiveMultipartFirst(prefix, rest, distribution, sender)
+ elseif control==MSG_MULTI_NEXT then
+ AceComm:OnReceiveMultipartNext(prefix, rest, distribution, sender)
+ elseif control==MSG_MULTI_LAST then
+ AceComm:OnReceiveMultipartLast(prefix, rest, distribution, sender)
+ elseif control==MSG_ESCAPE then
+ AceComm.callbacks:Fire(prefix, rest, distribution, sender)
+ else
+ -- unknown control character, ignore SILENTLY (dont warn unnecessarily about future extensions!)
+ end
+ else
+ -- single part: fire it off immediately and let CallbackHandler decide if it's registered or not
+ AceComm.callbacks:Fire(prefix, message, distribution, sender)
+ end
+ else
+ assert(false, "Received "..tostring(event).." event?!")
+ end
+end
+
+AceComm.frame = AceComm.frame or CreateFrame("Frame", "AceComm30Frame")
+AceComm.frame:SetScript("OnEvent", OnEvent)
+AceComm.frame:UnregisterAllEvents()
+AceComm.frame:RegisterEvent("CHAT_MSG_ADDON")
+
+
+----------------------------------------
+-- Base library stuff
+----------------------------------------
+
+local mixins = {
+ "RegisterComm",
+ "UnregisterComm",
+ "UnregisterAllComm",
+ "SendCommMessage",
+}
+
+-- Embeds AceComm-3.0 into the target object making the functions from the mixins list available on target:..
+-- @param target target object to embed AceComm-3.0 in
+function AceComm:Embed(target)
+ for k, v in pairs(mixins) do
+ target[v] = self[v]
+ end
+ self.embeds[target] = true
+ return target
+end
+
+function AceComm:OnEmbedDisable(target)
+ target:UnregisterAllComm()
+end
+
+-- Update embeds
+for target, v in pairs(AceComm.embeds) do
+ AceComm:Embed(target)
+end
diff --git a/libs/AceComm-3.0/AceComm-3.0.xml b/libs/AceComm-3.0/AceComm-3.0.xml
new file mode 100644
index 0000000..24fb43b
--- /dev/null
+++ b/libs/AceComm-3.0/AceComm-3.0.xml
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/libs/AceComm-3.0/ChatThrottleLib.lua b/libs/AceComm-3.0/ChatThrottleLib.lua
new file mode 100644
index 0000000..01088f6
--- /dev/null
+++ b/libs/AceComm-3.0/ChatThrottleLib.lua
@@ -0,0 +1,534 @@
+--
+-- ChatThrottleLib by Mikk
+--
+-- Manages AddOn chat output to keep player from getting kicked off.
+--
+-- ChatThrottleLib:SendChatMessage/:SendAddonMessage functions that accept
+-- a Priority ("BULK", "NORMAL", "ALERT") as well as prefix for SendChatMessage.
+--
+-- Priorities get an equal share of available bandwidth when fully loaded.
+-- Communication channels are separated on extension+chattype+destination and
+-- get round-robinned. (Destination only matters for whispers and channels,
+-- obviously)
+--
+-- Will install hooks for SendChatMessage and SendAddonMessage to measure
+-- bandwidth bypassing the library and use less bandwidth itself.
+--
+--
+-- Fully embeddable library. Just copy this file into your addon directory,
+-- add it to the .toc, and it's done.
+--
+-- Can run as a standalone addon also, but, really, just embed it! :-)
+--
+-- LICENSE: ChatThrottleLib is released into the Public Domain
+--
+
+local CTL_VERSION = 24
+
+local _G = _G
+
+if _G.ChatThrottleLib then
+ if _G.ChatThrottleLib.version >= CTL_VERSION then
+ -- There's already a newer (or same) version loaded. Buh-bye.
+ return
+ elseif not _G.ChatThrottleLib.securelyHooked then
+ print("ChatThrottleLib: Warning: There's an ANCIENT ChatThrottleLib.lua (pre-wow 2.0, =v16) in it!")
+ -- ATTEMPT to unhook; this'll behave badly if someone else has hooked...
+ -- ... and if someone has securehooked, they can kiss that goodbye too... >.<
+ _G.SendChatMessage = _G.ChatThrottleLib.ORIG_SendChatMessage
+ if _G.ChatThrottleLib.ORIG_SendAddonMessage then
+ _G.SendAddonMessage = _G.ChatThrottleLib.ORIG_SendAddonMessage
+ end
+ end
+ _G.ChatThrottleLib.ORIG_SendChatMessage = nil
+ _G.ChatThrottleLib.ORIG_SendAddonMessage = nil
+end
+
+if not _G.ChatThrottleLib then
+ _G.ChatThrottleLib = {}
+end
+
+ChatThrottleLib = _G.ChatThrottleLib -- in case some addon does "local ChatThrottleLib" above us and we're copypasted (AceComm-2, sigh)
+local ChatThrottleLib = _G.ChatThrottleLib
+
+ChatThrottleLib.version = CTL_VERSION
+
+
+
+------------------ TWEAKABLES -----------------
+
+ChatThrottleLib.MAX_CPS = 800 -- 2000 seems to be safe if NOTHING ELSE is happening. let's call it 800.
+ChatThrottleLib.MSG_OVERHEAD = 40 -- Guesstimate overhead for sending a message; source+dest+chattype+protocolstuff
+
+ChatThrottleLib.BURST = 4000 -- WoW's server buffer seems to be about 32KB. 8KB should be safe, but seen disconnects on _some_ servers. Using 4KB now.
+
+ChatThrottleLib.MIN_FPS = 20 -- Reduce output CPS to half (and don't burst) if FPS drops below this value
+
+
+local setmetatable = setmetatable
+local table_remove = table.remove
+local tostring = tostring
+local GetTime = GetTime
+local math_min = math.min
+local math_max = math.max
+local next = next
+local strlen = string.len
+local GetFramerate = GetFramerate
+local strlower = string.lower
+local unpack,type,pairs,wipe = unpack,type,pairs,wipe
+local UnitInRaid,UnitInParty = UnitInRaid,UnitInParty
+
+
+-----------------------------------------------------------------------
+-- Double-linked ring implementation
+
+local Ring = {}
+local RingMeta = { __index = Ring }
+
+function Ring:New()
+ local ret = {}
+ setmetatable(ret, RingMeta)
+ return ret
+end
+
+function Ring:Add(obj) -- Append at the "far end" of the ring (aka just before the current position)
+ if self.pos then
+ obj.prev = self.pos.prev
+ obj.prev.next = obj
+ obj.next = self.pos
+ obj.next.prev = obj
+ else
+ obj.next = obj
+ obj.prev = obj
+ self.pos = obj
+ end
+end
+
+function Ring:Remove(obj)
+ obj.next.prev = obj.prev
+ obj.prev.next = obj.next
+ if self.pos == obj then
+ self.pos = obj.next
+ if self.pos == obj then
+ self.pos = nil
+ end
+ end
+end
+
+
+
+-----------------------------------------------------------------------
+-- Recycling bin for pipes
+-- A pipe is a plain integer-indexed queue of messages
+-- Pipes normally live in Rings of pipes (3 rings total, one per priority)
+
+ChatThrottleLib.PipeBin = nil -- pre-v19, drastically different
+local PipeBin = setmetatable({}, {__mode="k"})
+
+local function DelPipe(pipe)
+ PipeBin[pipe] = true
+end
+
+local function NewPipe()
+ local pipe = next(PipeBin)
+ if pipe then
+ wipe(pipe)
+ PipeBin[pipe] = nil
+ return pipe
+ end
+ return {}
+end
+
+
+
+
+-----------------------------------------------------------------------
+-- Recycling bin for messages
+
+ChatThrottleLib.MsgBin = nil -- pre-v19, drastically different
+local MsgBin = setmetatable({}, {__mode="k"})
+
+local function DelMsg(msg)
+ msg[1] = nil
+ -- there's more parameters, but they're very repetetive so the string pool doesn't suffer really, and it's faster to just not delete them.
+ MsgBin[msg] = true
+end
+
+local function NewMsg()
+ local msg = next(MsgBin)
+ if msg then
+ MsgBin[msg] = nil
+ return msg
+ end
+ return {}
+end
+
+
+-----------------------------------------------------------------------
+-- ChatThrottleLib:Init
+-- Initialize queues, set up frame for OnUpdate, etc
+
+
+function ChatThrottleLib:Init()
+
+ -- Set up queues
+ if not self.Prio then
+ self.Prio = {}
+ self.Prio["ALERT"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
+ self.Prio["NORMAL"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
+ self.Prio["BULK"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
+ end
+
+ -- v4: total send counters per priority
+ for _, Prio in pairs(self.Prio) do
+ Prio.nTotalSent = Prio.nTotalSent or 0
+ end
+
+ if not self.avail then
+ self.avail = 0 -- v5
+ end
+ if not self.nTotalSent then
+ self.nTotalSent = 0 -- v5
+ end
+
+
+ -- Set up a frame to get OnUpdate events
+ if not self.Frame then
+ self.Frame = CreateFrame("Frame")
+ self.Frame:Hide()
+ end
+ self.Frame:SetScript("OnUpdate", self.OnUpdate)
+ self.Frame:SetScript("OnEvent", self.OnEvent) -- v11: Monitor P_E_W so we can throttle hard for a few seconds
+ self.Frame:RegisterEvent("PLAYER_ENTERING_WORLD")
+ self.OnUpdateDelay = 0
+ self.LastAvailUpdate = GetTime()
+ self.HardThrottlingBeginTime = GetTime() -- v11: Throttle hard for a few seconds after startup
+
+ -- Hook SendChatMessage and SendAddonMessage so we can measure unpiped traffic and avoid overloads (v7)
+ if not self.securelyHooked then
+ -- Use secure hooks as of v16. Old regular hook support yanked out in v21.
+ self.securelyHooked = true
+ --SendChatMessage
+ hooksecurefunc("SendChatMessage", function(...)
+ return ChatThrottleLib.Hook_SendChatMessage(...)
+ end)
+ --SendAddonMessage
+ if _G.C_ChatInfo then
+ hooksecurefunc(_G.C_ChatInfo, "SendAddonMessage", function(...)
+ return ChatThrottleLib.Hook_SendAddonMessage(...)
+ end)
+ else
+ hooksecurefunc("SendAddonMessage", function(...)
+ return ChatThrottleLib.Hook_SendAddonMessage(...)
+ end)
+ end
+ end
+ self.nBypass = 0
+end
+
+
+-----------------------------------------------------------------------
+-- ChatThrottleLib.Hook_SendChatMessage / .Hook_SendAddonMessage
+
+local bMyTraffic = false
+
+function ChatThrottleLib.Hook_SendChatMessage(text, chattype, language, destination, ...)
+ if bMyTraffic then
+ return
+ end
+ local self = ChatThrottleLib
+ local size = strlen(tostring(text or "")) + strlen(tostring(destination or "")) + self.MSG_OVERHEAD
+ self.avail = self.avail - size
+ self.nBypass = self.nBypass + size -- just a statistic
+end
+function ChatThrottleLib.Hook_SendAddonMessage(prefix, text, chattype, destination, ...)
+ if bMyTraffic then
+ return
+ end
+ local self = ChatThrottleLib
+ local size = tostring(text or ""):len() + tostring(prefix or ""):len();
+ size = size + tostring(destination or ""):len() + self.MSG_OVERHEAD
+ self.avail = self.avail - size
+ self.nBypass = self.nBypass + size -- just a statistic
+end
+
+
+
+-----------------------------------------------------------------------
+-- ChatThrottleLib:UpdateAvail
+-- Update self.avail with how much bandwidth is currently available
+
+function ChatThrottleLib:UpdateAvail()
+ local now = GetTime()
+ local MAX_CPS = self.MAX_CPS;
+ local newavail = MAX_CPS * (now - self.LastAvailUpdate)
+ local avail = self.avail
+
+ if now - self.HardThrottlingBeginTime < 5 then
+ -- First 5 seconds after startup/zoning: VERY hard clamping to avoid irritating the server rate limiter, it seems very cranky then
+ avail = math_min(avail + (newavail*0.1), MAX_CPS*0.5)
+ self.bChoking = true
+ elseif GetFramerate() < self.MIN_FPS then -- GetFrameRate call takes ~0.002 secs
+ avail = math_min(MAX_CPS, avail + newavail*0.5)
+ self.bChoking = true -- just a statistic
+ else
+ avail = math_min(self.BURST, avail + newavail)
+ self.bChoking = false
+ end
+
+ avail = math_max(avail, 0-(MAX_CPS*2)) -- Can go negative when someone is eating bandwidth past the lib. but we refuse to stay silent for more than 2 seconds; if they can do it, we can.
+
+ self.avail = avail
+ self.LastAvailUpdate = now
+
+ return avail
+end
+
+
+-----------------------------------------------------------------------
+-- Despooling logic
+-- Reminder:
+-- - We have 3 Priorities, each containing a "Ring" construct ...
+-- - ... made up of N "Pipe"s (1 for each destination/pipename)
+-- - and each pipe contains messages
+
+function ChatThrottleLib:Despool(Prio)
+ local ring = Prio.Ring
+ while ring.pos and Prio.avail > ring.pos[1].nSize do
+ local msg = table_remove(ring.pos, 1)
+ if not ring.pos[1] then -- did we remove last msg in this pipe?
+ local pipe = Prio.Ring.pos
+ Prio.Ring:Remove(pipe)
+ Prio.ByName[pipe.name] = nil
+ DelPipe(pipe)
+ else
+ Prio.Ring.pos = Prio.Ring.pos.next
+ end
+ local didSend=false
+ local lowerDest = strlower(msg[3] or "")
+ if lowerDest == "raid" and not UnitInRaid("player") then
+ -- do nothing
+ elseif lowerDest == "party" and not UnitInParty("player") then
+ -- do nothing
+ else
+ Prio.avail = Prio.avail - msg.nSize
+ bMyTraffic = true
+ msg.f(unpack(msg, 1, msg.n))
+ bMyTraffic = false
+ Prio.nTotalSent = Prio.nTotalSent + msg.nSize
+ DelMsg(msg)
+ didSend = true
+ end
+ -- notify caller of delivery (even if we didn't send it)
+ if msg.callbackFn then
+ msg.callbackFn (msg.callbackArg, didSend)
+ end
+ -- USER CALLBACK MAY ERROR
+ end
+end
+
+
+function ChatThrottleLib.OnEvent(this,event)
+ -- v11: We know that the rate limiter is touchy after login. Assume that it's touchy after zoning, too.
+ local self = ChatThrottleLib
+ if event == "PLAYER_ENTERING_WORLD" then
+ self.HardThrottlingBeginTime = GetTime() -- Throttle hard for a few seconds after zoning
+ self.avail = 0
+ end
+end
+
+
+function ChatThrottleLib.OnUpdate(this,delay)
+ local self = ChatThrottleLib
+
+ self.OnUpdateDelay = self.OnUpdateDelay + delay
+ if self.OnUpdateDelay < 0.08 then
+ return
+ end
+ self.OnUpdateDelay = 0
+
+ self:UpdateAvail()
+
+ if self.avail < 0 then
+ return -- argh. some bastard is spewing stuff past the lib. just bail early to save cpu.
+ end
+
+ -- See how many of our priorities have queued messages (we only have 3, don't worry about the loop)
+ local n = 0
+ for prioname,Prio in pairs(self.Prio) do
+ if Prio.Ring.pos or Prio.avail < 0 then
+ n = n + 1
+ end
+ end
+
+ -- Anything queued still?
+ if n<1 then
+ -- Nope. Move spillover bandwidth to global availability gauge and clear self.bQueueing
+ for prioname, Prio in pairs(self.Prio) do
+ self.avail = self.avail + Prio.avail
+ Prio.avail = 0
+ end
+ self.bQueueing = false
+ self.Frame:Hide()
+ return
+ end
+
+ -- There's stuff queued. Hand out available bandwidth to priorities as needed and despool their queues
+ local avail = self.avail/n
+ self.avail = 0
+
+ for prioname, Prio in pairs(self.Prio) do
+ if Prio.Ring.pos or Prio.avail < 0 then
+ Prio.avail = Prio.avail + avail
+ if Prio.Ring.pos and Prio.avail > Prio.Ring.pos[1].nSize then
+ self:Despool(Prio)
+ -- Note: We might not get here if the user-supplied callback function errors out! Take care!
+ end
+ end
+ end
+
+end
+
+
+
+
+-----------------------------------------------------------------------
+-- Spooling logic
+
+function ChatThrottleLib:Enqueue(prioname, pipename, msg)
+ local Prio = self.Prio[prioname]
+ local pipe = Prio.ByName[pipename]
+ if not pipe then
+ self.Frame:Show()
+ pipe = NewPipe()
+ pipe.name = pipename
+ Prio.ByName[pipename] = pipe
+ Prio.Ring:Add(pipe)
+ end
+
+ pipe[#pipe + 1] = msg
+
+ self.bQueueing = true
+end
+
+function ChatThrottleLib:SendChatMessage(prio, prefix, text, chattype, language, destination, queueName, callbackFn, callbackArg)
+ if not self or not prio or not prefix or not text or not self.Prio[prio] then
+ error('Usage: ChatThrottleLib:SendChatMessage("{BULK||NORMAL||ALERT}", "prefix", "text"[, "chattype"[, "language"[, "destination"]]]', 2)
+ end
+ if callbackFn and type(callbackFn)~="function" then
+ error('ChatThrottleLib:ChatMessage(): callbackFn: expected function, got '..type(callbackFn), 2)
+ end
+
+ local nSize = text:len()
+
+ if nSize>255 then
+ error("ChatThrottleLib:SendChatMessage(): message length cannot exceed 255 bytes", 2)
+ end
+
+ nSize = nSize + self.MSG_OVERHEAD
+
+ -- Check if there's room in the global available bandwidth gauge to send directly
+ if not self.bQueueing and nSize < self:UpdateAvail() then
+ self.avail = self.avail - nSize
+ bMyTraffic = true
+ _G.SendChatMessage(text, chattype, language, destination)
+ bMyTraffic = false
+ self.Prio[prio].nTotalSent = self.Prio[prio].nTotalSent + nSize
+ if callbackFn then
+ callbackFn (callbackArg, true)
+ end
+ -- USER CALLBACK MAY ERROR
+ return
+ end
+
+ -- Message needs to be queued
+ local msg = NewMsg()
+ msg.f = _G.SendChatMessage
+ msg[1] = text
+ msg[2] = chattype or "SAY"
+ msg[3] = language
+ msg[4] = destination
+ msg.n = 4
+ msg.nSize = nSize
+ msg.callbackFn = callbackFn
+ msg.callbackArg = callbackArg
+
+ self:Enqueue(prio, queueName or (prefix..(chattype or "SAY")..(destination or "")), msg)
+end
+
+
+function ChatThrottleLib:SendAddonMessage(prio, prefix, text, chattype, target, queueName, callbackFn, callbackArg)
+ if not self or not prio or not prefix or not text or not chattype or not self.Prio[prio] then
+ error('Usage: ChatThrottleLib:SendAddonMessage("{BULK||NORMAL||ALERT}", "prefix", "text", "chattype"[, "target"])', 2)
+ end
+ if callbackFn and type(callbackFn)~="function" then
+ error('ChatThrottleLib:SendAddonMessage(): callbackFn: expected function, got '..type(callbackFn), 2)
+ end
+
+ local nSize = text:len();
+
+ if C_ChatInfo or RegisterAddonMessagePrefix then
+ if nSize>255 then
+ error("ChatThrottleLib:SendAddonMessage(): message length cannot exceed 255 bytes", 2)
+ end
+ else
+ nSize = nSize + prefix:len() + 1
+ if nSize>255 then
+ error("ChatThrottleLib:SendAddonMessage(): prefix + message length cannot exceed 254 bytes", 2)
+ end
+ end
+
+ nSize = nSize + self.MSG_OVERHEAD;
+
+ -- Check if there's room in the global available bandwidth gauge to send directly
+ if not self.bQueueing and nSize < self:UpdateAvail() then
+ self.avail = self.avail - nSize
+ bMyTraffic = true
+ if _G.C_ChatInfo then
+ _G.C_ChatInfo.SendAddonMessage(prefix, text, chattype, target)
+ else
+ _G.SendAddonMessage(prefix, text, chattype, target)
+ end
+ bMyTraffic = false
+ self.Prio[prio].nTotalSent = self.Prio[prio].nTotalSent + nSize
+ if callbackFn then
+ callbackFn (callbackArg, true)
+ end
+ -- USER CALLBACK MAY ERROR
+ return
+ end
+
+ -- Message needs to be queued
+ local msg = NewMsg()
+ msg.f = _G.C_ChatInfo and _G.C_ChatInfo.SendAddonMessage or _G.SendAddonMessage
+ msg[1] = prefix
+ msg[2] = text
+ msg[3] = chattype
+ msg[4] = target
+ msg.n = (target~=nil) and 4 or 3;
+ msg.nSize = nSize
+ msg.callbackFn = callbackFn
+ msg.callbackArg = callbackArg
+
+ self:Enqueue(prio, queueName or (prefix..chattype..(target or "")), msg)
+end
+
+
+
+
+-----------------------------------------------------------------------
+-- Get the ball rolling!
+
+ChatThrottleLib:Init()
+
+--[[ WoWBench debugging snippet
+if(WOWB_VER) then
+ local function SayTimer()
+ print("SAY: "..GetTime().." "..arg1)
+ end
+ ChatThrottleLib.Frame:SetScript("OnEvent", SayTimer)
+ ChatThrottleLib.Frame:RegisterEvent("CHAT_MSG_SAY")
+end
+]]
+
+
diff --git a/libs/AceConfig-3.0/AceConfig-3.0.lua b/libs/AceConfig-3.0/AceConfig-3.0.lua
new file mode 100644
index 0000000..a99ddf7
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfig-3.0.lua
@@ -0,0 +1,58 @@
+--- AceConfig-3.0 wrapper library.
+-- Provides an API to register an options table with the config registry,
+-- as well as associate it with a slash command.
+-- @class file
+-- @name AceConfig-3.0
+-- @release $Id: AceConfig-3.0.lua 1161 2017-08-12 14:30:16Z funkydude $
+
+--[[
+AceConfig-3.0
+
+Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
+
+]]
+
+local cfgreg = LibStub("AceConfigRegistry-3.0")
+local cfgcmd = LibStub("AceConfigCmd-3.0")
+
+local MAJOR, MINOR = "AceConfig-3.0", 3
+local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfig then return end
+
+--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
+--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
+
+-- Lua APIs
+local pcall, error, type, pairs = pcall, error, type, pairs
+
+-- -------------------------------------------------------------------
+-- :RegisterOptionsTable(appName, options, slashcmd, persist)
+--
+-- - appName - (string) application name
+-- - options - table or function ref, see AceConfigRegistry
+-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
+
+--- Register a option table with the AceConfig registry.
+-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
+-- @paramsig appName, options [, slashcmd]
+-- @param appName The application name for the config table.
+-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/
+-- @param slashcmd A slash command to register for the option table, or a table of slash commands.
+-- @usage
+-- local AceConfig = LibStub("AceConfig-3.0")
+-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
+function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
+ local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
+ if not ok then error(msg, 2) end
+
+ if slashcmd then
+ if type(slashcmd) == "table" then
+ for _,cmd in pairs(slashcmd) do
+ cfgcmd:CreateChatCommand(cmd, appName)
+ end
+ else
+ cfgcmd:CreateChatCommand(slashcmd, appName)
+ end
+ end
+end
diff --git a/libs/AceConfig-3.0/AceConfig-3.0.xml b/libs/AceConfig-3.0/AceConfig-3.0.xml
new file mode 100644
index 0000000..a3569b7
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfig-3.0.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua b/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
new file mode 100644
index 0000000..33f9fe1
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
@@ -0,0 +1,794 @@
+--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames.
+-- @class file
+-- @name AceConfigCmd-3.0
+-- @release $Id: AceConfigCmd-3.0.lua 1161 2017-08-12 14:30:16Z funkydude $
+
+--[[
+AceConfigCmd-3.0
+
+Handles commandline optionstable access
+
+REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
+
+]]
+
+-- TODO: plugin args
+
+local cfgreg = LibStub("AceConfigRegistry-3.0")
+
+local MAJOR, MINOR = "AceConfigCmd-3.0", 14
+local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigCmd then return end
+
+AceConfigCmd.commands = AceConfigCmd.commands or {}
+local commands = AceConfigCmd.commands
+
+local AceConsole -- LoD
+local AceConsoleName = "AceConsole-3.0"
+
+-- Lua APIs
+local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim
+local format, tonumber, tostring = string.format, tonumber, tostring
+local tsort, tinsert = table.sort, table.insert
+local select, pairs, next, type = select, pairs, next, type
+local error, assert = error, assert
+
+-- WoW APIs
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME
+
+
+local L = setmetatable({}, { -- TODO: replace with proper locale
+ __index = function(self,k) return k end
+})
+
+
+
+local function print(msg)
+ (SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME):AddMessage(msg)
+end
+
+-- constants used by getparam() calls below
+
+local handlertypes = {["table"]=true}
+local handlermsg = "expected a table"
+
+local functypes = {["function"]=true, ["string"]=true}
+local funcmsg = "expected function or member name"
+
+
+-- pickfirstset() - picks the first non-nil value and returns it
+
+local function pickfirstset(...)
+ for i=1,select("#",...) do
+ if select(i,...)~=nil then
+ return select(i,...)
+ end
+ end
+end
+
+
+-- err() - produce real error() regarding malformed options tables etc
+
+local function err(info,inputpos,msg )
+ local cmdstr=" "..strsub(info.input, 1, inputpos-1)
+ error(MAJOR..": /" ..info[0] ..cmdstr ..": "..(msg or "malformed options table"), 2)
+end
+
+
+-- usererr() - produce chatframe message regarding bad slash syntax etc
+
+local function usererr(info,inputpos,msg )
+ local cmdstr=strsub(info.input, 1, inputpos-1);
+ print("/" ..info[0] .. " "..cmdstr ..": "..(msg or "malformed options table"))
+end
+
+
+-- callmethod() - call a given named method (e.g. "get", "set") with given arguments
+
+local function callmethod(info, inputpos, tab, methodtype, ...)
+ local method = info[methodtype]
+ if not method then
+ err(info, inputpos, "'"..methodtype.."': not set")
+ end
+
+ info.arg = tab.arg
+ info.option = tab
+ info.type = tab.type
+
+ if type(method)=="function" then
+ return method(info, ...)
+ elseif type(method)=="string" then
+ if type(info.handler[method])~="function" then
+ err(info, inputpos, "'"..methodtype.."': '"..method.."' is not a member function of "..tostring(info.handler))
+ end
+ return info.handler[method](info.handler, info, ...)
+ else
+ assert(false) -- type should have already been checked on read
+ end
+end
+
+-- callfunction() - call a given named function (e.g. "name", "desc") with given arguments
+
+local function callfunction(info, tab, methodtype, ...)
+ local method = tab[methodtype]
+
+ info.arg = tab.arg
+ info.option = tab
+ info.type = tab.type
+
+ if type(method)=="function" then
+ return method(info, ...)
+ else
+ assert(false) -- type should have already been checked on read
+ end
+end
+
+-- do_final() - do the final step (set/execute) along with validation and confirmation
+
+local function do_final(info, inputpos, tab, methodtype, ...)
+ if info.validate then
+ local res = callmethod(info,inputpos,tab,"validate",...)
+ if type(res)=="string" then
+ usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
+ return
+ end
+ end
+ -- console ignores .confirm
+
+ callmethod(info,inputpos,tab,methodtype, ...)
+end
+
+
+-- getparam() - used by handle() to retreive and store "handler", "get", "set", etc
+
+local function getparam(info, inputpos, tab, depth, paramname, types, errormsg)
+ local old,oldat = info[paramname], info[paramname.."_at"]
+ local val=tab[paramname]
+ if val~=nil then
+ if val==false then
+ val=nil
+ elseif not types[type(val)] then
+ err(info, inputpos, "'" .. paramname.. "' - "..errormsg)
+ end
+ info[paramname] = val
+ info[paramname.."_at"] = depth
+ end
+ return old,oldat
+end
+
+
+-- iterateargs(tab) - custom iterator that iterates both t.args and t.plugins.*
+local dummytable={}
+
+local function iterateargs(tab)
+ if not tab.plugins then
+ return pairs(tab.args)
+ end
+
+ local argtabkey,argtab=next(tab.plugins)
+ local v
+
+ return function(_, k)
+ while argtab do
+ k,v = next(argtab, k)
+ if k then return k,v end
+ if argtab==tab.args then
+ argtab=nil
+ else
+ argtabkey,argtab = next(tab.plugins, argtabkey)
+ if not argtabkey then
+ argtab=tab.args
+ end
+ end
+ end
+ end
+end
+
+local function checkhidden(info, inputpos, tab)
+ if tab.cmdHidden~=nil then
+ return tab.cmdHidden
+ end
+ local hidden = tab.hidden
+ if type(hidden) == "function" or type(hidden) == "string" then
+ info.hidden = hidden
+ hidden = callmethod(info, inputpos, tab, 'hidden')
+ info.hidden = nil
+ end
+ return hidden
+end
+
+local function showhelp(info, inputpos, tab, depth, noHead)
+ if not noHead then
+ print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
+ end
+
+ local sortTbl = {} -- [1..n]=name
+ local refTbl = {} -- [name]=tableref
+
+ for k,v in iterateargs(tab) do
+ if not refTbl[k] then -- a plugin overriding something in .args
+ tinsert(sortTbl, k)
+ refTbl[k] = v
+ end
+ end
+
+ tsort(sortTbl, function(one, two)
+ local o1 = refTbl[one].order or 100
+ local o2 = refTbl[two].order or 100
+ if type(o1) == "function" or type(o1) == "string" then
+ info.order = o1
+ info[#info+1] = one
+ o1 = callmethod(info, inputpos, refTbl[one], "order")
+ info[#info] = nil
+ info.order = nil
+ end
+ if type(o2) == "function" or type(o1) == "string" then
+ info.order = o2
+ info[#info+1] = two
+ o2 = callmethod(info, inputpos, refTbl[two], "order")
+ info[#info] = nil
+ info.order = nil
+ end
+ if o1<0 and o2<0 then return o1 4) and not _G["KEY_" .. text] then
+ return false
+ end
+ local s = text
+ if shift then
+ s = "SHIFT-" .. s
+ end
+ if ctrl then
+ s = "CTRL-" .. s
+ end
+ if alt then
+ s = "ALT-" .. s
+ end
+ return s
+end
+
+-- handle() - selfrecursing function that processes input->optiontable
+-- - depth - starts at 0
+-- - retfalse - return false rather than produce error if a match is not found (used by inlined groups)
+
+local function handle(info, inputpos, tab, depth, retfalse)
+
+ if not(type(tab)=="table" and type(tab.type)=="string") then err(info,inputpos) end
+
+ -------------------------------------------------------------------
+ -- Grab hold of handler,set,get,func,etc if set (and remember old ones)
+ -- Note that we do NOT validate if method names are correct at this stage,
+ -- the handler may change before they're actually used!
+
+ local oldhandler,oldhandler_at = getparam(info,inputpos,tab,depth,"handler",handlertypes,handlermsg)
+ local oldset,oldset_at = getparam(info,inputpos,tab,depth,"set",functypes,funcmsg)
+ local oldget,oldget_at = getparam(info,inputpos,tab,depth,"get",functypes,funcmsg)
+ local oldfunc,oldfunc_at = getparam(info,inputpos,tab,depth,"func",functypes,funcmsg)
+ local oldvalidate,oldvalidate_at = getparam(info,inputpos,tab,depth,"validate",functypes,funcmsg)
+ --local oldconfirm,oldconfirm_at = getparam(info,inputpos,tab,depth,"confirm",functypes,funcmsg)
+
+ -------------------------------------------------------------------
+ -- Act according to .type of this table
+
+ if tab.type=="group" then
+ ------------ group --------------------------------------------
+
+ if type(tab.args)~="table" then err(info, inputpos) end
+ if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
+
+ -- grab next arg from input
+ local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos)
+ if not arg then
+ showhelp(info, inputpos, tab, depth)
+ return
+ end
+ nextpos=nextpos+1
+
+ -- loop .args and try to find a key with a matching name
+ for k,v in iterateargs(tab) do
+ if not(type(k)=="string" and type(v)=="table" and type(v.type)=="string") then err(info,inputpos, "options table child '"..tostring(k).."' is malformed") end
+
+ -- is this child an inline group? if so, traverse into it
+ if v.type=="group" and pickfirstset(v.cmdInline, v.inline, false) then
+ info[depth+1] = k
+ if handle(info, inputpos, v, depth+1, true)==false then
+ info[depth+1] = nil
+ -- wasn't found in there, but that's ok, we just keep looking down here
+ else
+ return -- done, name was found in inline group
+ end
+ -- matching name and not a inline group
+ elseif strlower(arg)==strlower(k:gsub(" ", "_")) then
+ info[depth+1] = k
+ return handle(info,nextpos,v,depth+1)
+ end
+ end
+
+ -- no match
+ if retfalse then
+ -- restore old infotable members and return false to indicate failure
+ info.handler,info.handler_at = oldhandler,oldhandler_at
+ info.set,info.set_at = oldset,oldset_at
+ info.get,info.get_at = oldget,oldget_at
+ info.func,info.func_at = oldfunc,oldfunc_at
+ info.validate,info.validate_at = oldvalidate,oldvalidate_at
+ --info.confirm,info.confirm_at = oldconfirm,oldconfirm_at
+ return false
+ end
+
+ -- couldn't find the command, display error
+ usererr(info, inputpos, "'"..arg.."' - " .. L["unknown argument"])
+ return
+ end
+
+ local str = strsub(info.input,inputpos);
+
+ if tab.type=="execute" then
+ ------------ execute --------------------------------------------
+ do_final(info, inputpos, tab, "func")
+
+
+
+ elseif tab.type=="input" then
+ ------------ input --------------------------------------------
+
+ local res = true
+ if tab.pattern then
+ if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end
+ if not strmatch(str, tab.pattern) then
+ usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
+ return
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", str)
+
+
+
+ elseif tab.type=="toggle" then
+ ------------ toggle --------------------------------------------
+ local b
+ local str = strtrim(strlower(str))
+ if str=="" then
+ b = callmethod(info, inputpos, tab, "get")
+
+ if tab.tristate then
+ --cycle in true, nil, false order
+ if b then
+ b = nil
+ elseif b == nil then
+ b = false
+ else
+ b = true
+ end
+ else
+ b = not b
+ end
+
+ elseif str==L["on"] then
+ b = true
+ elseif str==L["off"] then
+ b = false
+ elseif tab.tristate and str==L["default"] then
+ b = nil
+ else
+ if tab.tristate then
+ usererr(info, inputpos, format(L["'%s' - expected 'on', 'off' or 'default', or no argument to toggle."], str))
+ else
+ usererr(info, inputpos, format(L["'%s' - expected 'on' or 'off', or no argument to toggle."], str))
+ end
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", b)
+
+
+ elseif tab.type=="range" then
+ ------------ range --------------------------------------------
+ local val = tonumber(str)
+ if not val then
+ usererr(info, inputpos, "'"..str.."' - "..L["expected number"])
+ return
+ end
+ if type(info.step)=="number" then
+ val = val- (val % info.step)
+ end
+ if type(info.min)=="number" and valinfo.max then
+ usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(info.max)) )
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", val)
+
+
+ elseif tab.type=="select" then
+ ------------ select ------------------------------------
+ local str = strtrim(strlower(str))
+
+ local values = tab.values
+ if type(values) == "function" or type(values) == "string" then
+ info.values = values
+ values = callmethod(info, inputpos, tab, "values")
+ info.values = nil
+ end
+
+ if str == "" then
+ local b = callmethod(info, inputpos, tab, "get")
+ local fmt = "|cffffff78- [%s]|r %s"
+ local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
+ print(L["Options for |cffffff78"..info[#info].."|r:"])
+ for k, v in pairs(values) do
+ if b == k then
+ print(fmt_sel:format(k, v))
+ else
+ print(fmt:format(k, v))
+ end
+ end
+ return
+ end
+
+ local ok
+ for k,v in pairs(values) do
+ if strlower(k)==str then
+ str = k -- overwrite with key (in case of case mismatches)
+ ok = true
+ break
+ end
+ end
+ if not ok then
+ usererr(info, inputpos, "'"..str.."' - "..L["unknown selection"])
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", str)
+
+ elseif tab.type=="multiselect" then
+ ------------ multiselect -------------------------------------------
+ local str = strtrim(strlower(str))
+
+ local values = tab.values
+ if type(values) == "function" or type(values) == "string" then
+ info.values = values
+ values = callmethod(info, inputpos, tab, "values")
+ info.values = nil
+ end
+
+ if str == "" then
+ local fmt = "|cffffff78- [%s]|r %s"
+ local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
+ print(L["Options for |cffffff78"..info[#info].."|r (multiple possible):"])
+ for k, v in pairs(values) do
+ if callmethod(info, inputpos, tab, "get", k) then
+ print(fmt_sel:format(k, v))
+ else
+ print(fmt:format(k, v))
+ end
+ end
+ return
+ end
+
+ --build a table of the selections, checking that they exist
+ --parse for =on =off =default in the process
+ --table will be key = true for options that should toggle, key = [on|off|default] for options to be set
+ local sels = {}
+ for v in str:gmatch("[^ ]+") do
+ --parse option=on etc
+ local opt, val = v:match('(.+)=(.+)')
+ --get option if toggling
+ if not opt then
+ opt = v
+ end
+
+ --check that the opt is valid
+ local ok
+ for k,v in pairs(values) do
+ if strlower(k)==opt then
+ opt = k -- overwrite with key (in case of case mismatches)
+ ok = true
+ break
+ end
+ end
+
+ if not ok then
+ usererr(info, inputpos, "'"..opt.."' - "..L["unknown selection"])
+ return
+ end
+
+ --check that if val was supplied it is valid
+ if val then
+ if val == L["on"] or val == L["off"] or (tab.tristate and val == L["default"]) then
+ --val is valid insert it
+ sels[opt] = val
+ else
+ if tab.tristate then
+ usererr(info, inputpos, format(L["'%s' '%s' - expected 'on', 'off' or 'default', or no argument to toggle."], v, val))
+ else
+ usererr(info, inputpos, format(L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."], v, val))
+ end
+ return
+ end
+ else
+ -- no val supplied, toggle
+ sels[opt] = true
+ end
+ end
+
+ for opt, val in pairs(sels) do
+ local newval
+
+ if (val == true) then
+ --toggle the option
+ local b = callmethod(info, inputpos, tab, "get", opt)
+
+ if tab.tristate then
+ --cycle in true, nil, false order
+ if b then
+ b = nil
+ elseif b == nil then
+ b = false
+ else
+ b = true
+ end
+ else
+ b = not b
+ end
+ newval = b
+ else
+ --set the option as specified
+ if val==L["on"] then
+ newval = true
+ elseif val==L["off"] then
+ newval = false
+ elseif val==L["default"] then
+ newval = nil
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", opt, newval)
+ end
+
+
+ elseif tab.type=="color" then
+ ------------ color --------------------------------------------
+ local str = strtrim(strlower(str))
+ if str == "" then
+ --TODO: Show current value
+ return
+ end
+
+ local r, g, b, a
+
+ local hasAlpha = tab.hasAlpha
+ if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
+ info.hasAlpha = hasAlpha
+ hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha')
+ info.hasAlpha = nil
+ end
+
+ if hasAlpha then
+ if str:len() == 8 and str:find("^%x*$") then
+ --parse a hex string
+ r,g,b,a = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255, tonumber(str:sub(7, 8), 16) / 255
+ else
+ --parse seperate values
+ r,g,b,a = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
+ r,g,b,a = tonumber(r), tonumber(g), tonumber(b), tonumber(a)
+ end
+ if not (r and g and b and a) then
+ usererr(info, inputpos, format(L["'%s' - expected 'RRGGBBAA' or 'r g b a'."], str))
+ return
+ end
+
+ if r >= 0.0 and r <= 1.0 and g >= 0.0 and g <= 1.0 and b >= 0.0 and b <= 1.0 and a >= 0.0 and a <= 1.0 then
+ --values are valid
+ elseif r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 and a >= 0 and a <= 255 then
+ --values are valid 0..255, convert to 0..1
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ a = a / 255
+ else
+ --values are invalid
+ usererr(info, inputpos, format(L["'%s' - values must all be either in the range 0..1 or 0..255."], str))
+ end
+ else
+ a = 1.0
+ if str:len() == 6 and str:find("^%x*$") then
+ --parse a hex string
+ r,g,b = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255
+ else
+ --parse seperate values
+ r,g,b = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
+ r,g,b = tonumber(r), tonumber(g), tonumber(b)
+ end
+ if not (r and g and b) then
+ usererr(info, inputpos, format(L["'%s' - expected 'RRGGBB' or 'r g b'."], str))
+ return
+ end
+ if r >= 0.0 and r <= 1.0 and g >= 0.0 and g <= 1.0 and b >= 0.0 and b <= 1.0 then
+ --values are valid
+ elseif r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 then
+ --values are valid 0..255, convert to 0..1
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ else
+ --values are invalid
+ usererr(info, inputpos, format(L["'%s' - values must all be either in the range 0-1 or 0-255."], str))
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", r,g,b,a)
+
+ elseif tab.type=="keybinding" then
+ ------------ keybinding --------------------------------------------
+ local str = strtrim(strlower(str))
+ if str == "" then
+ --TODO: Show current value
+ return
+ end
+ local value = keybindingValidateFunc(str:upper())
+ if value == false then
+ usererr(info, inputpos, format(L["'%s' - Invalid Keybinding."], str))
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", value)
+
+ elseif tab.type=="description" then
+ ------------ description --------------------
+ -- ignore description, GUI config only
+ else
+ err(info, inputpos, "unknown options table item type '"..tostring(tab.type).."'")
+ end
+end
+
+--- Handle the chat command.
+-- This is usually called from a chat command handler to parse the command input as operations on an aceoptions table.\\
+-- AceConfigCmd uses this function internally when a slash command is registered with `:CreateChatCommand`
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param input The commandline input (as given by the WoW handler, i.e. without the command itself)
+-- @usage
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
+-- -- Use AceConsole-3.0 to register a Chat Command
+-- MyAddon:RegisterChatCommand("mychat", "ChatCommand")
+--
+-- -- Show the GUI if no input is supplied, otherwise handle the chat input.
+-- function MyAddon:ChatCommand(input)
+-- -- Assuming "MyOptions" is the appName of a valid options table
+-- if not input or input:trim() == "" then
+-- LibStub("AceConfigDialog-3.0"):Open("MyOptions")
+-- else
+-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
+-- end
+-- end
+function AceConfigCmd:HandleCommand(slashcmd, appName, input)
+
+ local optgetter = cfgreg:GetOptionsTable(appName)
+ if not optgetter then
+ error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'appName' - no options table "]]..tostring(appName)..[[" has been registered]], 2)
+ end
+ local options = assert( optgetter("cmd", MAJOR) )
+
+ local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
+ [0] = slashcmd,
+ appName = appName,
+ options = options,
+ input = input,
+ self = self,
+ handler = self,
+ uiType = "cmd",
+ uiName = MAJOR,
+ }
+
+ handle(info, 1, options, 0) -- (info, inputpos, table, depth)
+end
+
+--- Utility function to create a slash command handler.
+-- Also registers tab completion with AceTab
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigCmd:CreateChatCommand(slashcmd, appName)
+ if not AceConsole then
+ AceConsole = LibStub(AceConsoleName)
+ end
+ if AceConsole.RegisterChatCommand(self, slashcmd, function(input)
+ AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
+ end,
+ true) then -- succesfully registered so lets get the command -> app table in
+ commands[slashcmd] = appName
+ end
+end
+
+--- Utility function that returns the options table that belongs to a slashcommand.
+-- Designed to be used for the AceTab interface.
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @return The options table associated with the slash command (or nil if the slash command was not registered)
+function AceConfigCmd:GetChatCommandOptions(slashcmd)
+ return commands[slashcmd]
+end
diff --git a/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml b/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml
new file mode 100644
index 0000000..9e157b5
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
new file mode 100644
index 0000000..66416e8
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
@@ -0,0 +1,1983 @@
+--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables.
+-- @class file
+-- @name AceConfigDialog-3.0
+-- @release $Id: AceConfigDialog-3.0.lua 1169 2018-02-27 16:18:28Z nevcairiel $
+
+local LibStub = LibStub
+local gui = LibStub("AceGUI-3.0")
+local reg = LibStub("AceConfigRegistry-3.0")
+
+local MAJOR, MINOR = "AceConfigDialog-3.0", 66
+local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigDialog then return end
+
+AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
+AceConfigDialog.Status = AceConfigDialog.Status or {}
+AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
+
+AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
+AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
+AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
+
+-- Lua APIs
+local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort
+local strmatch, format = string.match, string.format
+local assert, loadstring, error = assert, loadstring, error
+local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs
+local rawset, tostring, tonumber = rawset, tostring, tonumber
+local math_min, math_max, math_floor = math.min, math.max, math.floor
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
+-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
+-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
+
+local emptyTbl = {}
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function CreateDispatcher(argCount)
+ local code = [[
+ local xpcall, eh = ...
+ local method, ARGS
+ local function call() return method(ARGS) end
+
+ local function dispatch(func, ...)
+ method = func
+ if not method then return end
+ ARGS = ...
+ return xpcall(call, eh)
+ end
+
+ return dispatch
+ ]]
+
+ local ARGS = {}
+ for i = 1, argCount do ARGS[i] = "arg"..i end
+ code = code:gsub("ARGS", tconcat(ARGS, ", "))
+ return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
+end
+
+local Dispatchers = setmetatable({}, {__index=function(self, argCount)
+ local dispatcher = CreateDispatcher(argCount)
+ rawset(self, argCount, dispatcher)
+ return dispatcher
+end})
+Dispatchers[0] = function(func)
+ return xpcall(func, errorhandler)
+end
+
+local function safecall(func, ...)
+ return Dispatchers[select("#", ...)](func, ...)
+end
+
+local width_multiplier = 170
+
+--[[
+Group Types
+ Tree - All Descendant Groups will all become nodes on the tree, direct child options will appear above the tree
+ - Descendant Groups with inline=true and thier children will not become nodes
+
+ Tab - Direct Child Groups will become tabs, direct child options will appear above the tab control
+ - Grandchild groups will default to inline unless specified otherwise
+
+ Select- Same as Tab but with entries in a dropdown rather than tabs
+
+
+ Inline Groups
+ - Will not become nodes of a select group, they will be effectivly part of thier parent group seperated by a border
+ - If declared on a direct child of a root node of a select group, they will appear above the group container control
+ - When a group is displayed inline, all descendants will also be inline members of the group
+
+]]
+
+-- Recycling functions
+local new, del, copy
+--newcount, delcount,createdcount,cached = 0,0,0
+do
+ local pool = setmetatable({},{__mode="k"})
+ function new()
+ --newcount = newcount + 1
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ return t
+ else
+ --createdcount = createdcount + 1
+ return {}
+ end
+ end
+ function copy(t)
+ local c = new()
+ for k, v in pairs(t) do
+ c[k] = v
+ end
+ return c
+ end
+ function del(t)
+ --delcount = delcount + 1
+ wipe(t)
+ pool[t] = true
+ end
+-- function cached()
+-- local n = 0
+-- for k in pairs(pool) do
+-- n = n + 1
+-- end
+-- return n
+-- end
+end
+
+-- picks the first non-nil value and returns it
+local function pickfirstset(...)
+ for i=1,select("#",...) do
+ if select(i,...)~=nil then
+ return select(i,...)
+ end
+ end
+end
+
+--gets an option from a given group, checking plugins
+local function GetSubOption(group, key)
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ if t[key] then
+ return t[key]
+ end
+ end
+ end
+
+ return group.args[key]
+end
+
+--Option member type definitions, used to decide how to access it
+
+--Is the member Inherited from parent options
+local isInherited = {
+ set = true,
+ get = true,
+ func = true,
+ confirm = true,
+ validate = true,
+ disabled = true,
+ hidden = true
+}
+
+--Does a string type mean a literal value, instead of the default of a method of the handler
+local stringIsLiteral = {
+ name = true,
+ desc = true,
+ icon = true,
+ usage = true,
+ width = true,
+ image = true,
+ fontSize = true,
+}
+
+--Is Never a function or method
+local allIsLiteral = {
+ type = true,
+ descStyle = true,
+ imageWidth = true,
+ imageHeight = true,
+}
+
+--gets the value for a member that could be a function
+--function refs are called with an info arg
+--every other type is returned
+local function GetOptionsMemberValue(membername, option, options, path, appName, ...)
+ --get definition for the member
+ local inherits = isInherited[membername]
+
+
+ --get the member of the option, traversing the tree if it can be inherited
+ local member
+
+ if inherits then
+ local group = options
+ if group[membername] ~= nil then
+ member = group[membername]
+ end
+ for i = 1, #path do
+ group = GetSubOption(group, path[i])
+ if group[membername] ~= nil then
+ member = group[membername]
+ end
+ end
+ else
+ member = option[membername]
+ end
+
+ --check if we need to call a functon, or if we have a literal value
+ if ( not allIsLiteral[membername] ) and ( type(member) == "function" or ((not stringIsLiteral[membername]) and type(member) == "string") ) then
+ --We have a function to call
+ local info = new()
+ --traverse the options table, picking up the handler and filling the info with the path
+ local handler
+ local group = options
+ handler = group.handler or handler
+
+ for i = 1, #path do
+ group = GetSubOption(group, path[i])
+ info[i] = path[i]
+ handler = group.handler or handler
+ end
+
+ info.options = options
+ info.appName = appName
+ info[0] = appName
+ info.arg = option.arg
+ info.handler = handler
+ info.option = option
+ info.type = option.type
+ info.uiType = "dialog"
+ info.uiName = MAJOR
+
+ local a, b, c ,d
+ --using 4 returns for the get of a color type, increase if a type needs more
+ if type(member) == "function" then
+ --Call the function
+ a,b,c,d = member(info, ...)
+ else
+ --Call the method
+ if handler and handler[member] then
+ a,b,c,d = handler[member](handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type %s", member, membername))
+ end
+ end
+ del(info)
+ return a,b,c,d
+ else
+ --The value isnt a function to call, return it
+ return member
+ end
+end
+
+--[[calls an options function that could be inherited, method name or function ref
+local function CallOptionsFunction(funcname ,option, options, path, appName, ...)
+ local info = new()
+
+ local func
+ local group = options
+ local handler
+
+ --build the info table containing the path
+ -- pick up functions while traversing the tree
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+
+ for i, v in ipairs(path) do
+ group = GetSubOption(group, v)
+ info[i] = v
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+ end
+
+ info.options = options
+ info[0] = appName
+ info.arg = option.arg
+
+ local a, b, c ,d
+ if type(func) == "string" then
+ if handler and handler[func] then
+ a,b,c,d = handler[func](handler, info, ...)
+ else
+ error(string.format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ a,b,c,d = func(info, ...)
+ end
+ del(info)
+ return a,b,c,d
+end
+--]]
+
+--tables to hold orders and names for options being sorted, will be created with new()
+--prevents needing to call functions repeatedly while sorting
+local tempOrders
+local tempNames
+
+local function compareOptions(a,b)
+ if not a then
+ return true
+ end
+ if not b then
+ return false
+ end
+ local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100
+ if OrderA == OrderB then
+ local NameA = (type(tempNames[a]) == "string") and tempNames[a] or ""
+ local NameB = (type(tempNames[b]) == "string") and tempNames[b] or ""
+ return NameA:upper() < NameB:upper()
+ end
+ if OrderA < 0 then
+ if OrderB > 0 then
+ return false
+ end
+ else
+ if OrderB < 0 then
+ return true
+ end
+ end
+ return OrderA < OrderB
+end
+
+
+
+--builds 2 tables out of an options group
+-- keySort, sorted keys
+-- opts, combined options from .plugins and args
+local function BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+ tempOrders = new()
+ tempNames = new()
+
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ for k, v in pairs(t) do
+ if not opts[k] then
+ tinsert(keySort, k)
+ opts[k] = v
+
+ path[#path+1] = k
+ tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
+ tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ path[#path] = nil
+ end
+ end
+ end
+ end
+
+ for k, v in pairs(group.args) do
+ if not opts[k] then
+ tinsert(keySort, k)
+ opts[k] = v
+
+ path[#path+1] = k
+ tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
+ tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ path[#path] = nil
+ end
+ end
+
+ tsort(keySort, compareOptions)
+
+ del(tempOrders)
+ del(tempNames)
+end
+
+local function DelTree(tree)
+ if tree.children then
+ local childs = tree.children
+ for i = 1, #childs do
+ DelTree(childs[i])
+ del(childs[i])
+ end
+ del(childs)
+ end
+end
+
+local function CleanUserData(widget, event)
+
+ local user = widget:GetUserDataTable()
+
+ if user.path then
+ del(user.path)
+ end
+
+ if widget.type == "TreeGroup" then
+ local tree = user.tree
+ widget:SetTree(nil)
+ if tree then
+ for i = 1, #tree do
+ DelTree(tree[i])
+ del(tree[i])
+ end
+ del(tree)
+ end
+ end
+
+ if widget.type == "TabGroup" then
+ widget:SetTabs(nil)
+ if user.tablist then
+ del(user.tablist)
+ end
+ end
+
+ if widget.type == "DropdownGroup" then
+ widget:SetGroupList(nil)
+ if user.grouplist then
+ del(user.grouplist)
+ end
+ if user.orderlist then
+ del(user.orderlist)
+ end
+ end
+end
+
+-- - Gets a status table for the given appname and options path.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param path The path to the options (a table with all group keys)
+-- @return
+function AceConfigDialog:GetStatusTable(appName, path)
+ local status = self.Status
+
+ if not status[appName] then
+ status[appName] = {}
+ status[appName].status = {}
+ status[appName].children = {}
+ end
+
+ status = status[appName]
+
+ if path then
+ for i = 1, #path do
+ local v = path[i]
+ if not status.children[v] then
+ status.children[v] = {}
+ status.children[v].status = {}
+ status.children[v].children = {}
+ end
+ status = status.children[v]
+ end
+ end
+
+ return status.status
+end
+
+--- Selects the specified path in the options window.
+-- The path specified has to match the keys of the groups in the table.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param ... The path to the key that should be selected
+function AceConfigDialog:SelectGroup(appName, ...)
+ local path = new()
+
+
+ local app = reg:GetOptionsTable(appName)
+ if not app then
+ error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
+ end
+ local options = app("dialog", MAJOR)
+ local group = options
+ local status = self:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ status = status.groups
+ local treevalue
+ local treestatus
+
+ for n = 1, select("#",...) do
+ local key = select(n, ...)
+
+ if group.childGroups == "tab" or group.childGroups == "select" then
+ --if this is a tab or select group, select the group
+ status.selected = key
+ --children of this group are no longer extra levels of a tree
+ treevalue = nil
+ else
+ --tree group by default
+ if treevalue then
+ --this is an extra level of a tree group, build a uniquevalue for it
+ treevalue = treevalue.."\001"..key
+ else
+ --this is the top level of a tree group, the uniquevalue is the same as the key
+ treevalue = key
+ if not status.groups then
+ status.groups = {}
+ end
+ --save this trees status table for any extra levels or groups
+ treestatus = status
+ end
+ --make sure that the tree entry is open, and select it.
+ --the selected group will be overwritten if a child is the final target but still needs to be open
+ treestatus.selected = treevalue
+ treestatus.groups[treevalue] = true
+
+ end
+
+ --move to the next group in the path
+ group = GetSubOption(group, key)
+ if not group then
+ break
+ end
+ tinsert(path, key)
+ status = self:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ status = status.groups
+ end
+
+ del(path)
+ reg:NotifyChange(appName)
+end
+
+local function OptionOnMouseOver(widget, event)
+ --show a tooltip/set the status bar to the desc text
+ local user = widget:GetUserDataTable()
+ local opt = user.option
+ local options = user.options
+ local path = user.path
+ local appName = user.appName
+
+ GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
+ local name = GetOptionsMemberValue("name", opt, options, path, appName)
+ local desc = GetOptionsMemberValue("desc", opt, options, path, appName)
+ local usage = GetOptionsMemberValue("usage", opt, options, path, appName)
+ local descStyle = opt.descStyle
+
+ if descStyle and descStyle ~= "tooltip" then return end
+
+ GameTooltip:SetText(name, 1, .82, 0, true)
+
+ if opt.type == "multiselect" then
+ GameTooltip:AddLine(user.text, 0.5, 0.5, 0.8, true)
+ end
+ if type(desc) == "string" then
+ GameTooltip:AddLine(desc, 1, 1, 1, true)
+ end
+ if type(usage) == "string" then
+ GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
+ end
+
+ GameTooltip:Show()
+end
+
+local function OptionOnMouseLeave(widget, event)
+ GameTooltip:Hide()
+end
+
+local function GetFuncName(option)
+ local type = option.type
+ if type == "execute" then
+ return "func"
+ else
+ return "set"
+ end
+end
+local function confirmPopup(appName, rootframe, basepath, info, message, func, ...)
+ if not StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] then
+ StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"]
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t.text = message
+ t.button1 = ACCEPT
+ t.button2 = CANCEL
+ t.preferredIndex = STATICPOPUP_NUMDIALOGS
+ local dialog, oldstrata
+ t.OnAccept = function()
+ safecall(func, unpack(t))
+ if dialog and oldstrata then
+ dialog:SetFrameStrata(oldstrata)
+ end
+ AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
+ del(info)
+ end
+ t.OnCancel = function()
+ if dialog and oldstrata then
+ dialog:SetFrameStrata(oldstrata)
+ end
+ AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
+ del(info)
+ end
+ for i = 1, select("#", ...) do
+ t[i] = select(i, ...) or false
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ dialog = StaticPopup_Show("ACECONFIGDIALOG30_CONFIRM_DIALOG")
+ if dialog then
+ oldstrata = dialog:GetFrameStrata()
+ dialog:SetFrameStrata("TOOLTIP")
+ end
+end
+
+local function validationErrorPopup(message)
+ if not StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] then
+ StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"]
+ t.text = message
+ t.button1 = OKAY
+ t.preferredIndex = STATICPOPUP_NUMDIALOGS
+ local dialog, oldstrata
+ t.OnAccept = function()
+ if dialog and oldstrata then
+ dialog:SetFrameStrata(oldstrata)
+ end
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ dialog = StaticPopup_Show("ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG")
+ if dialog then
+ oldstrata = dialog:GetFrameStrata()
+ dialog:SetFrameStrata("TOOLTIP")
+ end
+end
+
+local function ActivateControl(widget, event, ...)
+ --This function will call the set / execute handler for the widget
+ --widget:GetUserDataTable() contains the needed info
+ local user = widget:GetUserDataTable()
+ local option = user.option
+ local options = user.options
+ local path = user.path
+ local info = new()
+
+ local func
+ local group = options
+ local funcname = GetFuncName(option)
+ local handler
+ local confirm
+ local validate
+ --build the info table containing the path
+ -- pick up functions while traversing the tree
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+ confirm = group.confirm
+ validate = group.validate
+ for i = 1, #path do
+ local v = path[i]
+ group = GetSubOption(group, v)
+ info[i] = v
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+ if group.confirm ~= nil then
+ confirm = group.confirm
+ end
+ if group.validate ~= nil then
+ validate = group.validate
+ end
+ end
+
+ info.options = options
+ info.appName = user.appName
+ info.arg = option.arg
+ info.handler = handler
+ info.option = option
+ info.type = option.type
+ info.uiType = "dialog"
+ info.uiName = MAJOR
+
+ local name
+ if type(option.name) == "function" then
+ name = option.name(info)
+ elseif type(option.name) == "string" then
+ name = option.name
+ else
+ name = ""
+ end
+ local usage = option.usage
+ local pattern = option.pattern
+
+ local validated = true
+
+ if option.type == "input" then
+ if type(pattern)=="string" then
+ if not strmatch(..., pattern) then
+ validated = false
+ end
+ end
+ end
+
+ local success
+ if validated and option.type ~= "execute" then
+ if type(validate) == "string" then
+ if handler and handler[validate] then
+ success, validated = safecall(handler[validate], handler, info, ...)
+ if not success then validated = false end
+ else
+ error(format("Method %s doesn't exist in handler for type execute", validate))
+ end
+ elseif type(validate) == "function" then
+ success, validated = safecall(validate, info, ...)
+ if not success then validated = false end
+ end
+ end
+
+ local rootframe = user.rootframe
+ if not validated or type(validated) == "string" then
+ if not validated then
+ if usage then
+ validated = name..": "..usage
+ else
+ if pattern then
+ validated = name..": Expected "..pattern
+ else
+ validated = name..": Invalid Value"
+ end
+ end
+ end
+
+ -- show validate message
+ if rootframe.SetStatusText then
+ rootframe:SetStatusText(validated)
+ else
+ validationErrorPopup(validated)
+ end
+ PlaySound(882) -- SOUNDKIT.IG_PLAYER_INVITE_DECLINE || _DECLINE is actually missing from the table
+ del(info)
+ return true
+ else
+
+ local confirmText = option.confirmText
+ --call confirm func/method
+ if type(confirm) == "string" then
+ if handler and handler[confirm] then
+ success, confirm = safecall(handler[confirm], handler, info, ...)
+ if success and type(confirm) == "string" then
+ confirmText = confirm
+ confirm = true
+ elseif not success then
+ confirm = false
+ end
+ else
+ error(format("Method %s doesn't exist in handler for type confirm", confirm))
+ end
+ elseif type(confirm) == "function" then
+ success, confirm = safecall(confirm, info, ...)
+ if success and type(confirm) == "string" then
+ confirmText = confirm
+ confirm = true
+ elseif not success then
+ confirm = false
+ end
+ end
+
+ --confirm if needed
+ if type(confirm) == "boolean" then
+ if confirm then
+ if not confirmText then
+ local name, desc = option.name, option.desc
+ if type(name) == "function" then
+ name = name(info)
+ end
+ if type(desc) == "function" then
+ desc = desc(info)
+ end
+ confirmText = name
+ if desc then
+ confirmText = confirmText.." - "..desc
+ end
+ end
+
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local rootframe
+
+ if iscustom then
+ rootframe = user.rootframe
+ end
+ local basepath = user.rootframe:GetUserData("basepath")
+ if type(func) == "string" then
+ if handler and handler[func] then
+ confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...)
+ end
+ --func will be called and info deleted when the confirm dialog is responded to
+ return
+ end
+ end
+
+ --call the function
+ if type(func) == "string" then
+ if handler and handler[func] then
+ safecall(handler[func],handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ safecall(func,info, ...)
+ end
+
+
+
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ --full refresh of the frame, some controls dont cause this on all events
+ if option.type == "color" then
+ if event == "OnValueConfirmed" then
+
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+ elseif option.type == "range" then
+ if event == "OnMouseUp" then
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+ --multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed'
+ elseif option.type == "multiselect" then
+ user.valuechanged = true
+ else
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+
+ end
+ del(info)
+end
+
+local function ActivateSlider(widget, event, value)
+ local option = widget:GetUserData("option")
+ local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step
+ if min then
+ if step then
+ value = math_floor((value - min) / step + 0.5) * step + min
+ end
+ value = math_max(value, min)
+ end
+ if max then
+ value = math_min(value, max)
+ end
+ ActivateControl(widget,event,value)
+end
+
+--called from a checkbox that is part of an internally created multiselect group
+--this type is safe to refresh on activation of one control
+local function ActivateMultiControl(widget, event, ...)
+ ActivateControl(widget, event, widget:GetUserData("value"), ...)
+ local user = widget:GetUserDataTable()
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+end
+
+local function MultiControlOnClosed(widget, event, ...)
+ local user = widget:GetUserDataTable()
+ if user.valuechanged then
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+end
+
+local function FrameOnClose(widget, event)
+ local appName = widget:GetUserData("appName")
+ AceConfigDialog.OpenFrames[appName] = nil
+ gui:Release(widget)
+end
+
+local function CheckOptionHidden(option, options, path, appName)
+ --check for a specific boolean option
+ local hidden = pickfirstset(option.dialogHidden,option.guiHidden)
+ if hidden ~= nil then
+ return hidden
+ end
+
+ return GetOptionsMemberValue("hidden", option, options, path, appName)
+end
+
+local function CheckOptionDisabled(option, options, path, appName)
+ --check for a specific boolean option
+ local disabled = pickfirstset(option.dialogDisabled,option.guiDisabled)
+ if disabled ~= nil then
+ return disabled
+ end
+
+ return GetOptionsMemberValue("disabled", option, options, path, appName)
+end
+--[[
+local function BuildTabs(group, options, path, appName)
+ local tabs = new()
+ local text = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ tinsert(tabs, k)
+ text[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(keySort)
+ del(opts)
+
+ return tabs, text
+end
+]]
+local function BuildSelect(group, options, path, appName)
+ local groups = new()
+ local order = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ groups[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ tinsert(order, k)
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(opts)
+ del(keySort)
+
+ return groups, order
+end
+
+local function BuildSubGroups(group, tree, options, path, appName)
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ local entry = new()
+ entry.value = k
+ entry.text = GetOptionsMemberValue("name", v, options, path, appName)
+ entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
+ entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName)
+ entry.disabled = CheckOptionDisabled(v, options, path, appName)
+ if not tree.children then tree.children = new() end
+ tinsert(tree.children,entry)
+ if (v.childGroups or "tree") == "tree" then
+ BuildSubGroups(v,entry, options, path, appName)
+ end
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(keySort)
+ del(opts)
+end
+
+local function BuildGroups(group, options, path, appName, recurse)
+ local tree = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ local entry = new()
+ entry.value = k
+ entry.text = GetOptionsMemberValue("name", v, options, path, appName)
+ entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
+ entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName)
+ entry.disabled = CheckOptionDisabled(v, options, path, appName)
+ tinsert(tree,entry)
+ if recurse and (v.childGroups or "tree") == "tree" then
+ BuildSubGroups(v,entry, options, path, appName)
+ end
+ end
+ path[#path] = nil
+ end
+ end
+ del(keySort)
+ del(opts)
+ return tree
+end
+
+local function InjectInfo(control, options, option, path, rootframe, appName)
+ local user = control:GetUserDataTable()
+ for i = 1, #path do
+ user[i] = path[i]
+ end
+ user.rootframe = rootframe
+ user.option = option
+ user.options = options
+ user.path = copy(path)
+ user.appName = appName
+ control:SetCallback("OnRelease", CleanUserData)
+ control:SetCallback("OnLeave", OptionOnMouseLeave)
+ control:SetCallback("OnEnter", OptionOnMouseOver)
+end
+
+
+--[[
+ options - root of the options table being fed
+ container - widget that controls will be placed in
+ rootframe - Frame object the options are in
+ path - table with the keys to get to the group being fed
+--]]
+
+local function FeedOptions(appName, options,container,rootframe,path,group,inline)
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ tinsert(path, k)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ local name = GetOptionsMemberValue("name", v, options, path, appName)
+ if not hidden then
+ if v.type == "group" then
+ if inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
+ --Inline group
+ local GroupContainer
+ if name and name ~= "" then
+ GroupContainer = gui:Create("InlineGroup")
+ GroupContainer:SetTitle(name or "")
+ else
+ GroupContainer = gui:Create("SimpleGroup")
+ end
+
+ GroupContainer.width = "fill"
+ GroupContainer:SetLayout("flow")
+ container:AddChild(GroupContainer)
+ FeedOptions(appName,options,GroupContainer,rootframe,path,v,true)
+ end
+ else
+ --Control to feed
+ local control
+
+ local name = GetOptionsMemberValue("name", v, options, path, appName)
+
+ if v.type == "execute" then
+
+ local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
+ local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
+
+ if type(image) == "string" or type(image) == "number" then
+ control = gui:Create("Icon")
+ if not width then
+ width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
+ end
+ if not height then
+ height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
+ end
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ if type(width) ~= "number" then
+ width = 32
+ end
+ if type(height) ~= "number" then
+ height = 32
+ end
+ control:SetImageSize(width, height)
+ control:SetLabel(name)
+ else
+ control = gui:Create("Button")
+ control:SetText(name)
+ end
+ control:SetCallback("OnClick",ActivateControl)
+
+ elseif v.type == "input" then
+ local controlType = v.dialogControl or v.control or (v.multiline and "MultiLineEditBox") or "EditBox"
+ control = gui:Create(controlType)
+ if not control then
+ geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
+ control = gui:Create(v.multiline and "MultiLineEditBox" or "EditBox")
+ end
+
+ if v.multiline and control.SetNumLines then
+ control:SetNumLines(tonumber(v.multiline) or 4)
+ end
+ control:SetLabel(name)
+ control:SetCallback("OnEnterPressed",ActivateControl)
+ local text = GetOptionsMemberValue("get",v, options, path, appName)
+ if type(text) ~= "string" then
+ text = ""
+ end
+ control:SetText(text)
+
+ elseif v.type == "toggle" then
+ control = gui:Create("CheckBox")
+ control:SetLabel(name)
+ control:SetTriState(v.tristate)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged",ActivateControl)
+
+ if v.descStyle == "inline" then
+ local desc = GetOptionsMemberValue("desc", v, options, path, appName)
+ control:SetDescription(desc)
+ end
+
+ local image = GetOptionsMemberValue("image", v, options, path, appName)
+ local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName)
+
+ if type(image) == "string" or type(image) == "number" then
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ end
+ elseif v.type == "range" then
+ control = gui:Create("Slider")
+ control:SetLabel(name)
+ control:SetSliderValues(v.softMin or v.min or 0, v.softMax or v.max or 100, v.bigStep or v.step or 0)
+ control:SetIsPercent(v.isPercent)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ if type(value) ~= "number" then
+ value = 0
+ end
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged",ActivateSlider)
+ control:SetCallback("OnMouseUp",ActivateSlider)
+
+ elseif v.type == "select" then
+ local values = GetOptionsMemberValue("values", v, options, path, appName)
+ if v.style == "radio" then
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ control = gui:Create("InlineGroup")
+ control:SetLayout("Flow")
+ control:SetTitle(name)
+ control.width = "fill"
+
+ control:PauseLayout()
+ local optionValue = GetOptionsMemberValue("get",v, options, path, appName)
+ local t = {}
+ for value, text in pairs(values) do
+ t[#t+1]=value
+ end
+ tsort(t)
+ for k, value in ipairs(t) do
+ local text = values[value]
+ local radio = gui:Create("CheckBox")
+ radio:SetLabel(text)
+ radio:SetUserData("value", value)
+ radio:SetUserData("text", text)
+ radio:SetDisabled(disabled)
+ radio:SetType("radio")
+ radio:SetValue(optionValue == value)
+ radio:SetCallback("OnValueChanged", ActivateMultiControl)
+ InjectInfo(radio, options, v, path, rootframe, appName)
+ control:AddChild(radio)
+ if width == "double" then
+ radio:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ radio:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ radio:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ radio.width = "fill"
+ else
+ radio:SetWidth(width_multiplier)
+ end
+ end
+ control:ResumeLayout()
+ control:DoLayout()
+ else
+ local controlType = v.dialogControl or v.control or "Dropdown"
+ control = gui:Create(controlType)
+ if not control then
+ geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
+ control = gui:Create("Dropdown")
+ end
+ local itemType = v.itemControl
+ if itemType and not gui:GetWidgetVersion(itemType) then
+ geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType)))
+ itemType = nil
+ end
+ control:SetLabel(name)
+ control:SetList(values, nil, itemType)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ if not values[value] then
+ value = nil
+ end
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged", ActivateControl)
+ end
+
+ elseif v.type == "multiselect" then
+ local values = GetOptionsMemberValue("values", v, options, path, appName)
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+
+ local controlType = v.dialogControl or v.control
+
+ local valuesort = new()
+ if values then
+ for value, text in pairs(values) do
+ tinsert(valuesort, value)
+ end
+ end
+ tsort(valuesort)
+
+ if controlType then
+ control = gui:Create(controlType)
+ if not control then
+ geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
+ end
+ end
+ if control then
+ control:SetMultiselect(true)
+ control:SetLabel(name)
+ control:SetList(values)
+ control:SetDisabled(disabled)
+ control:SetCallback("OnValueChanged",ActivateControl)
+ control:SetCallback("OnClosed", MultiControlOnClosed)
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ if width == "double" then
+ control:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ control:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ control:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ control.width = "fill"
+ else
+ control:SetWidth(width_multiplier)
+ end
+ --check:SetTriState(v.tristate)
+ for i = 1, #valuesort do
+ local key = valuesort[i]
+ local value = GetOptionsMemberValue("get",v, options, path, appName, key)
+ control:SetItemValue(key,value)
+ end
+ else
+ control = gui:Create("InlineGroup")
+ control:SetLayout("Flow")
+ control:SetTitle(name)
+ control.width = "fill"
+
+ control:PauseLayout()
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ for i = 1, #valuesort do
+ local value = valuesort[i]
+ local text = values[value]
+ local check = gui:Create("CheckBox")
+ check:SetLabel(text)
+ check:SetUserData("value", value)
+ check:SetUserData("text", text)
+ check:SetDisabled(disabled)
+ check:SetTriState(v.tristate)
+ check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, value))
+ check:SetCallback("OnValueChanged",ActivateMultiControl)
+ InjectInfo(check, options, v, path, rootframe, appName)
+ control:AddChild(check)
+ if width == "double" then
+ check:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ check:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ control:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ check.width = "fill"
+ else
+ check:SetWidth(width_multiplier)
+ end
+ end
+ control:ResumeLayout()
+ control:DoLayout()
+
+
+ end
+
+ del(valuesort)
+
+ elseif v.type == "color" then
+ control = gui:Create("ColorPicker")
+ control:SetLabel(name)
+ control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName))
+ control:SetColor(GetOptionsMemberValue("get",v, options, path, appName))
+ control:SetCallback("OnValueChanged",ActivateControl)
+ control:SetCallback("OnValueConfirmed",ActivateControl)
+
+ elseif v.type == "keybinding" then
+ control = gui:Create("Keybinding")
+ control:SetLabel(name)
+ control:SetKey(GetOptionsMemberValue("get",v, options, path, appName))
+ control:SetCallback("OnKeyChanged",ActivateControl)
+
+ elseif v.type == "header" then
+ control = gui:Create("Heading")
+ control:SetText(name)
+ control.width = "fill"
+
+ elseif v.type == "description" then
+ control = gui:Create("Label")
+ control:SetText(name)
+
+ local fontSize = GetOptionsMemberValue("fontSize",v, options, path, appName)
+ if fontSize == "medium" then
+ control:SetFontObject(GameFontHighlight)
+ elseif fontSize == "large" then
+ control:SetFontObject(GameFontHighlightLarge)
+ else -- small or invalid
+ control:SetFontObject(GameFontHighlightSmall)
+ end
+
+ local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
+ local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
+
+ if type(image) == "string" or type(image) == "number" then
+ if not width then
+ width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
+ end
+ if not height then
+ height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
+ end
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ if type(width) ~= "number" then
+ width = 32
+ end
+ if type(height) ~= "number" then
+ height = 32
+ end
+ control:SetImageSize(width, height)
+ end
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ control.width = not width and "fill"
+ end
+
+ --Common Init
+ if control then
+ if control.width ~= "fill" then
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ if width == "double" then
+ control:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ control:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ control:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ control.width = "fill"
+ else
+ control:SetWidth(width_multiplier)
+ end
+ end
+ if control.SetDisabled then
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+ control:SetDisabled(disabled)
+ end
+
+ InjectInfo(control, options, v, path, rootframe, appName)
+ container:AddChild(control)
+ end
+
+ end
+ end
+ tremove(path)
+ end
+ container:ResumeLayout()
+ container:DoLayout()
+ del(keySort)
+ del(opts)
+end
+
+local function BuildPath(path, ...)
+ for i = 1, select("#",...) do
+ tinsert(path, (select(i,...)))
+ end
+end
+
+
+local function TreeOnButtonEnter(widget, event, uniquevalue, button)
+ local user = widget:GetUserDataTable()
+ if not user then return end
+ local options = user.options
+ local option = user.option
+ local path = user.path
+ local appName = user.appName
+
+ local feedpath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+ local group = options
+ for i = 1, #feedpath do
+ if not group then return end
+ group = GetSubOption(group, feedpath[i])
+ end
+
+ local name = GetOptionsMemberValue("name", group, options, feedpath, appName)
+ local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName)
+
+ GameTooltip:SetOwner(button, "ANCHOR_NONE")
+ if widget.type == "TabGroup" then
+ GameTooltip:SetPoint("BOTTOM",button,"TOP")
+ else
+ GameTooltip:SetPoint("LEFT",button,"RIGHT")
+ end
+
+ GameTooltip:SetText(name, 1, .82, 0, true)
+
+ if type(desc) == "string" then
+ GameTooltip:AddLine(desc, 1, 1, 1, true)
+ end
+
+ GameTooltip:Show()
+end
+
+local function TreeOnButtonLeave(widget, event, value, button)
+ GameTooltip:Hide()
+end
+
+
+local function GroupExists(appName, options, path, uniquevalue)
+ if not uniquevalue then return false end
+
+ local feedpath = new()
+ local temppath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+
+ local group = options
+ for i = 1, #feedpath do
+ local v = feedpath[i]
+ temppath[i] = v
+ group = GetSubOption(group, v)
+
+ if not group or group.type ~= "group" or CheckOptionHidden(group, options, temppath, appName) then
+ del(feedpath)
+ del(temppath)
+ return false
+ end
+ end
+ del(feedpath)
+ del(temppath)
+ return true
+end
+
+local function GroupSelected(widget, event, uniquevalue)
+
+ local user = widget:GetUserDataTable()
+
+ local options = user.options
+ local option = user.option
+ local path = user.path
+ local rootframe = user.rootframe
+
+ local feedpath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+ local group = options
+ for i = 1, #feedpath do
+ group = GetSubOption(group, feedpath[i])
+ end
+ widget:ReleaseChildren()
+ AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
+
+ del(feedpath)
+end
+
+
+
+--[[
+-- INTERNAL --
+This function will feed one group, and any inline child groups into the given container
+Select Groups will only have the selection control (tree, tabs, dropdown) fed in
+and have a group selected, this event will trigger the feeding of child groups
+
+Rules:
+ If the group is Inline, FeedOptions
+ If the group has no child groups, FeedOptions
+
+ If the group is a tab or select group, FeedOptions then add the Group Control
+ If the group is a tree group FeedOptions then
+ its parent isnt a tree group: then add the tree control containing this and all child tree groups
+ if its parent is a tree group, its already a node on a tree
+--]]
+
+function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
+ local group = options
+ --follow the path to get to the curent group
+ local inline
+ local grouptype, parenttype = options.childGroups, "none"
+
+
+ for i = 1, #path do
+ local v = path[i]
+ group = GetSubOption(group, v)
+ inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ parenttype = grouptype
+ grouptype = group.childGroups
+ end
+
+ if not parenttype then
+ parenttype = "tree"
+ end
+
+ --check if the group has child groups
+ local hasChildGroups
+ for k, v in pairs(group.args) do
+ if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
+ hasChildGroups = true
+ end
+ end
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ for k, v in pairs(t) do
+ if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
+ hasChildGroups = true
+ end
+ end
+ end
+ end
+
+ container:SetLayout("flow")
+ local scroll
+
+ --Add a scrollframe if we are not going to add a group control, this is the inverse of the conditions for that later on
+ if (not (hasChildGroups and not inline)) or (grouptype ~= "tab" and grouptype ~= "select" and (parenttype == "tree" and not isRoot)) then
+ if container.type ~= "InlineGroup" and container.type ~= "SimpleGroup" then
+ scroll = gui:Create("ScrollFrame")
+ scroll:SetLayout("flow")
+ scroll.width = "fill"
+ scroll.height = "fill"
+ container:SetLayout("fill")
+ container:AddChild(scroll)
+ container = scroll
+ end
+ end
+
+ FeedOptions(appName,options,container,rootframe,path,group,nil)
+
+ if scroll then
+ container:PerformLayout()
+ local status = self:GetStatusTable(appName, path)
+ if not status.scroll then
+ status.scroll = {}
+ end
+ scroll:SetStatusTable(status.scroll)
+ end
+
+ if hasChildGroups and not inline then
+ local name = GetOptionsMemberValue("name", group, options, path, appName)
+ if grouptype == "tab" then
+
+ local tab = gui:Create("TabGroup")
+ InjectInfo(tab, options, group, path, rootframe, appName)
+ tab:SetCallback("OnGroupSelected", GroupSelected)
+ tab:SetCallback("OnTabEnter", TreeOnButtonEnter)
+ tab:SetCallback("OnTabLeave", TreeOnButtonLeave)
+
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ tab:SetStatusTable(status.groups)
+ tab.width = "fill"
+ tab.height = "fill"
+
+ local tabs = BuildGroups(group, options, path, appName)
+ tab:SetTabs(tabs)
+ tab:SetUserData("tablist", tabs)
+
+ for i = 1, #tabs do
+ local entry = tabs[i]
+ if not entry.disabled then
+ tab:SelectTab((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
+ break
+ end
+ end
+
+ container:AddChild(tab)
+
+ elseif grouptype == "select" then
+
+ local select = gui:Create("DropdownGroup")
+ select:SetTitle(name)
+ InjectInfo(select, options, group, path, rootframe, appName)
+ select:SetCallback("OnGroupSelected", GroupSelected)
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ select:SetStatusTable(status.groups)
+ local grouplist, orderlist = BuildSelect(group, options, path, appName)
+ select:SetGroupList(grouplist, orderlist)
+ select:SetUserData("grouplist", grouplist)
+ select:SetUserData("orderlist", orderlist)
+
+ local firstgroup = orderlist[1]
+ if firstgroup then
+ select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
+ end
+
+ select.width = "fill"
+ select.height = "fill"
+
+ container:AddChild(select)
+
+ --assume tree group by default
+ --if parenttype is tree then this group is already a node on that tree
+ elseif (parenttype ~= "tree") or isRoot then
+ local tree = gui:Create("TreeGroup")
+ InjectInfo(tree, options, group, path, rootframe, appName)
+ tree:EnableButtonTooltips(false)
+
+ tree.width = "fill"
+ tree.height = "fill"
+
+ tree:SetCallback("OnGroupSelected", GroupSelected)
+ tree:SetCallback("OnButtonEnter", TreeOnButtonEnter)
+ tree:SetCallback("OnButtonLeave", TreeOnButtonLeave)
+
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ local treedefinition = BuildGroups(group, options, path, appName, true)
+ tree:SetStatusTable(status.groups)
+
+ tree:SetTree(treedefinition)
+ tree:SetUserData("tree",treedefinition)
+
+ for i = 1, #treedefinition do
+ local entry = treedefinition[i]
+ if not entry.disabled then
+ tree:SelectByValue((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
+ break
+ end
+ end
+
+ container:AddChild(tree)
+ end
+ end
+end
+
+local old_CloseSpecialWindows
+
+
+local function RefreshOnUpdate(this)
+ for appName in pairs(this.closing) do
+ if AceConfigDialog.OpenFrames[appName] then
+ AceConfigDialog.OpenFrames[appName]:Hide()
+ end
+ if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
+ for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
+ if not widget:IsVisible() then
+ widget:ReleaseChildren()
+ end
+ end
+ end
+ this.closing[appName] = nil
+ end
+
+ if this.closeAll then
+ for k, v in pairs(AceConfigDialog.OpenFrames) do
+ if not this.closeAllOverride[k] then
+ v:Hide()
+ end
+ end
+ this.closeAll = nil
+ wipe(this.closeAllOverride)
+ end
+
+ for appName in pairs(this.apps) do
+ if AceConfigDialog.OpenFrames[appName] then
+ local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable()
+ AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl))
+ end
+ if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
+ for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
+ local user = widget:GetUserDataTable()
+ if widget:IsVisible() then
+ AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(user.basepath or emptyTbl))
+ end
+ end
+ end
+ this.apps[appName] = nil
+ end
+ this:SetScript("OnUpdate", nil)
+end
+
+-- Upgrade the OnUpdate script as well, if needed.
+if AceConfigDialog.frame:GetScript("OnUpdate") then
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+--- Close all open options windows
+function AceConfigDialog:CloseAll()
+ AceConfigDialog.frame.closeAll = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+ if next(self.OpenFrames) then
+ return true
+ end
+end
+
+--- Close a specific options window.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigDialog:Close(appName)
+ if self.OpenFrames[appName] then
+ AceConfigDialog.frame.closing[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+ return true
+ end
+end
+
+-- Internal -- Called by AceConfigRegistry
+function AceConfigDialog:ConfigTableChanged(event, appName)
+ AceConfigDialog.frame.apps[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+reg.RegisterCallback(AceConfigDialog, "ConfigTableChange", "ConfigTableChanged")
+
+--- Sets the default size of the options window for a specific application.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param width The default width
+-- @param height The default height
+function AceConfigDialog:SetDefaultSize(appName, width, height)
+ local status = AceConfigDialog:GetStatusTable(appName)
+ if type(width) == "number" and type(height) == "number" then
+ status.width = width
+ status.height = height
+ end
+end
+
+--- Open an option window at the specified path (if any).
+-- This function can optionally feed the group into a pre-created container
+-- instead of creating a new container frame.
+-- @paramsig appName [, container][, ...]
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param container An optional container frame to feed the options into
+-- @param ... The path to open after creating the options window (see `:SelectGroup` for details)
+function AceConfigDialog:Open(appName, container, ...)
+ if not old_CloseSpecialWindows then
+ old_CloseSpecialWindows = CloseSpecialWindows
+ CloseSpecialWindows = function()
+ local found = old_CloseSpecialWindows()
+ return self:CloseAll() or found
+ end
+ end
+ local app = reg:GetOptionsTable(appName)
+ if not app then
+ error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
+ end
+ local options = app("dialog", MAJOR)
+
+ local f
+
+ local path = new()
+ local name = GetOptionsMemberValue("name", options, options, path, appName)
+
+ --If an optional path is specified add it to the path table before feeding the options
+ --as container is optional as well it may contain the first element of the path
+ if type(container) == "string" then
+ tinsert(path, container)
+ container = nil
+ end
+ for n = 1, select("#",...) do
+ tinsert(path, (select(n, ...)))
+ end
+
+ local option = options
+ if type(container) == "table" and container.type == "BlizOptionsGroup" and #path > 0 then
+ for i = 1, #path do
+ option = options.args[path[i]]
+ end
+ name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
+ end
+
+ --if a container is given feed into that
+ if container then
+ f = container
+ f:ReleaseChildren()
+ f:SetUserData("appName", appName)
+ f:SetUserData("iscustom", true)
+ if #path > 0 then
+ f:SetUserData("basepath", copy(path))
+ end
+ local status = AceConfigDialog:GetStatusTable(appName)
+ if not status.width then
+ status.width = 700
+ end
+ if not status.height then
+ status.height = 500
+ end
+ if f.SetStatusTable then
+ f:SetStatusTable(status)
+ end
+ if f.SetTitle then
+ f:SetTitle(name or "")
+ end
+ else
+ if not self.OpenFrames[appName] then
+ f = gui:Create("Frame")
+ self.OpenFrames[appName] = f
+ else
+ f = self.OpenFrames[appName]
+ end
+ f:ReleaseChildren()
+ f:SetCallback("OnClose", FrameOnClose)
+ f:SetUserData("appName", appName)
+ if #path > 0 then
+ f:SetUserData("basepath", copy(path))
+ end
+ f:SetTitle(name or "")
+ local status = AceConfigDialog:GetStatusTable(appName)
+ f:SetStatusTable(status)
+ end
+
+ self:FeedGroup(appName,options,f,f,path,true)
+ if f.Show then
+ f:Show()
+ end
+ del(path)
+
+ if AceConfigDialog.frame.closeAll then
+ -- close all is set, but thats not good, since we're just opening here, so force it
+ AceConfigDialog.frame.closeAllOverride[appName] = true
+ end
+end
+
+-- convert pre-39 BlizOptions structure to the new format
+if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
+ local old = AceConfigDialog.BlizOptions
+ local new = {}
+ for key, widget in pairs(old) do
+ local appName = widget:GetUserData("appName")
+ if not new[appName] then new[appName] = {} end
+ new[appName][key] = widget
+ end
+ AceConfigDialog.BlizOptions = new
+else
+ AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {}
+end
+
+local function FeedToBlizPanel(widget, event)
+ local path = widget:GetUserData("path")
+ AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(path or emptyTbl))
+end
+
+local function ClearBlizPanel(widget, event)
+ local appName = widget:GetUserData("appName")
+ AceConfigDialog.frame.closing[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+--- Add an option table into the Blizzard Interface Options panel.
+-- You can optionally supply a descriptive name to use and a parent frame to use,
+-- as well as a path in the options table.\\
+-- If no name is specified, the appName will be used instead.
+--
+-- If you specify a proper `parent` (by name), the interface options will generate a
+-- tree layout. Note that only one level of children is supported, so the parent always
+-- has to be a head-level note.
+--
+-- This function returns a reference to the container frame registered with the Interface
+-- Options. You can use this reference to open the options with the API function
+-- `InterfaceOptionsFrame_OpenToCategory`.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param name A descriptive name to display in the options tree (defaults to appName)
+-- @param parent The parent to use in the interface options tree.
+-- @param ... The path in the options table to feed into the interface options panel.
+-- @return The reference to the frame registered into the Interface Options.
+function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
+ local BlizOptions = AceConfigDialog.BlizOptions
+
+ local key = appName
+ for n = 1, select("#", ...) do
+ key = key.."\001"..select(n, ...)
+ end
+
+ if not BlizOptions[appName] then
+ BlizOptions[appName] = {}
+ end
+
+ if not BlizOptions[appName][key] then
+ local group = gui:Create("BlizOptionsGroup")
+ BlizOptions[appName][key] = group
+ group:SetName(name or appName, parent)
+
+ group:SetTitle(name or appName)
+ group:SetUserData("appName", appName)
+ if select("#", ...) > 0 then
+ local path = {}
+ for n = 1, select("#",...) do
+ tinsert(path, (select(n, ...)))
+ end
+ group:SetUserData("path", path)
+ end
+ group:SetCallback("OnShow", FeedToBlizPanel)
+ group:SetCallback("OnHide", ClearBlizPanel)
+ InterfaceOptions_AddCategory(group.frame)
+ return group.frame
+ else
+ error(("%s has already been added to the Blizzard Options Window with the given path"):format(appName), 2)
+ end
+end
diff --git a/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml
new file mode 100644
index 0000000..8e1e606
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua b/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
new file mode 100644
index 0000000..f8ac3f9
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
@@ -0,0 +1,350 @@
+--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\
+-- Options tables can be registered as raw tables, OR as function refs that return a table.\\
+-- Such functions receive three arguments: "uiType", "uiName", "appName". \\
+-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\
+-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\
+-- * The **appName** field is the options table name as given at registration time \\
+--
+-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
+-- @class file
+-- @name AceConfigRegistry-3.0
+-- @release $Id: AceConfigRegistry-3.0.lua 1169 2018-02-27 16:18:28Z nevcairiel $
+local CallbackHandler = LibStub("CallbackHandler-1.0")
+
+local MAJOR, MINOR = "AceConfigRegistry-3.0", 18
+local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigRegistry then return end
+
+AceConfigRegistry.tables = AceConfigRegistry.tables or {}
+
+if not AceConfigRegistry.callbacks then
+ AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
+end
+
+-- Lua APIs
+local tinsert, tconcat = table.insert, table.concat
+local strfind, strmatch = string.find, string.match
+local type, tostring, select, pairs = type, tostring, select, pairs
+local error, assert = error, assert
+
+-----------------------------------------------------------------------
+-- Validating options table consistency:
+
+
+AceConfigRegistry.validated = {
+ -- list of options table names ran through :ValidateOptionsTable automatically.
+ -- CLEARED ON PURPOSE, since newer versions may have newer validators
+ cmd = {},
+ dropdown = {},
+ dialog = {},
+}
+
+
+
+local function err(msg, errlvl, ...)
+ local t = {}
+ for i=select("#",...),1,-1 do
+ tinsert(t, (select(i, ...)))
+ end
+ error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
+end
+
+
+local isstring={["string"]=true, _="string"}
+local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
+local istable={["table"]=true, _="table"}
+local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
+local optstring={["nil"]=true,["string"]=true, _="string"}
+local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
+local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"}
+local optnumber={["nil"]=true,["number"]=true, _="number"}
+local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"}
+local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"}
+local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"}
+local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
+local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"}
+local opttable={["nil"]=true,["table"]=true, _="table"}
+local optbool={["nil"]=true,["boolean"]=true, _="boolean"}
+local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"}
+local optstringnumber={["nil"]=true,["string"]=true,["number"]=true, _="string or number"}
+
+local basekeys={
+ type=isstring,
+ name=isstringfunc,
+ desc=optstringfunc,
+ descStyle=optstring,
+ order=optmethodnumber,
+ validate=optmethodfalse,
+ confirm=optmethodbool,
+ confirmText=optstring,
+ disabled=optmethodbool,
+ hidden=optmethodbool,
+ guiHidden=optmethodbool,
+ dialogHidden=optmethodbool,
+ dropdownHidden=optmethodbool,
+ cmdHidden=optmethodbool,
+ icon=optstringnumberfunc,
+ iconCoords=optmethodtable,
+ handler=opttable,
+ get=optmethodfalse,
+ set=optmethodfalse,
+ func=optmethodfalse,
+ arg={["*"]=true},
+ width=optstringnumber,
+}
+
+local typedkeys={
+ header={},
+ description={
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ imageHeight=optnumber,
+ imageWidth=optnumber,
+ fontSize=optstringfunc,
+ },
+ group={
+ args=istable,
+ plugins=opttable,
+ inline=optbool,
+ cmdInline=optbool,
+ guiInline=optbool,
+ dropdownInline=optbool,
+ dialogInline=optbool,
+ childGroups=optstring,
+ },
+ execute={
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ imageHeight=optnumber,
+ imageWidth=optnumber,
+ },
+ input={
+ pattern=optstring,
+ usage=optstring,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ multiline=optboolnumber,
+ },
+ toggle={
+ tristate=optbool,
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ },
+ tristate={
+ },
+ range={
+ min=optnumber,
+ softMin=optnumber,
+ max=optnumber,
+ softMax=optnumber,
+ step=optnumber,
+ bigStep=optnumber,
+ isPercent=optbool,
+ },
+ select={
+ values=ismethodtable,
+ style={
+ ["nil"]=true,
+ ["string"]={dropdown=true,radio=true},
+ _="string: 'dropdown' or 'radio'"
+ },
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ itemControl=optstring,
+ },
+ multiselect={
+ values=ismethodtable,
+ style=optstring,
+ tristate=optbool,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ color={
+ hasAlpha=optmethodbool,
+ },
+ keybinding={
+ -- TODO
+ },
+}
+
+local function validateKey(k,errlvl,...)
+ errlvl=(errlvl or 0)+1
+ if type(k)~="string" then
+ err("["..tostring(k).."] - key is not a string", errlvl,...)
+ end
+ if strfind(k, "[%c\127]") then
+ err("["..tostring(k).."] - key name contained control characters", errlvl,...)
+ end
+end
+
+local function validateVal(v, oktypes, errlvl,...)
+ errlvl=(errlvl or 0)+1
+ local isok=oktypes[type(v)] or oktypes["*"]
+
+ if not isok then
+ err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...)
+ end
+ if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
+ if not isok[v] then
+ err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...)
+ end
+ end
+end
+
+local function validate(options,errlvl,...)
+ errlvl=(errlvl or 0)+1
+ -- basic consistency
+ if type(options)~="table" then
+ err(": expected a table, got a "..type(options), errlvl,...)
+ end
+ if type(options.type)~="string" then
+ err(".type: expected a string, got a "..type(options.type), errlvl,...)
+ end
+
+ -- get type and 'typedkeys' member
+ local tk = typedkeys[options.type]
+ if not tk then
+ err(".type: unknown type '"..options.type.."'", errlvl,...)
+ end
+
+ -- make sure that all options[] are known parameters
+ for k,v in pairs(options) do
+ if not (tk[k] or basekeys[k]) then
+ err(": unknown parameter", errlvl,tostring(k),...)
+ end
+ end
+
+ -- verify that required params are there, and that everything is the right type
+ for k,oktypes in pairs(basekeys) do
+ validateVal(options[k], oktypes, errlvl,k,...)
+ end
+ for k,oktypes in pairs(tk) do
+ validateVal(options[k], oktypes, errlvl,k,...)
+ end
+
+ -- extra logic for groups
+ if options.type=="group" then
+ for k,v in pairs(options.args) do
+ validateKey(k,errlvl,"args",...)
+ validate(v, errlvl,k,"args",...)
+ end
+ if options.plugins then
+ for plugname,plugin in pairs(options.plugins) do
+ if type(plugin)~="table" then
+ err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...)
+ end
+ for k,v in pairs(plugin) do
+ validateKey(k,errlvl,tostring(plugname),"plugins",...)
+ validate(v, errlvl,k,tostring(plugname),"plugins",...)
+ end
+ end
+ end
+ end
+end
+
+
+--- Validates basic structure and integrity of an options table \\
+-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
+-- @param options The table to be validated
+-- @param name The name of the table to be validated (shown in any error message)
+-- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
+function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl)
+ errlvl=(errlvl or 0)+1
+ name = name or "Optionstable"
+ if not options.name then
+ options.name=name -- bit of a hack, the root level doesn't really need a .name :-/
+ end
+ validate(options,errlvl,name)
+end
+
+--- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh.
+-- You should call this function if your options table changed from any outside event, like a game event
+-- or a timer.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigRegistry:NotifyChange(appName)
+ if not AceConfigRegistry.tables[appName] then return end
+ AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
+end
+
+-- -------------------------------------------------------------------
+-- Registering and retreiving options tables:
+
+
+-- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it)
+
+local function validateGetterArgs(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+2
+ if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
+ error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
+ end
+ if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
+ error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
+ end
+end
+
+--- Register an options table with the config registry.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param options The options table, OR a function reference that generates it on demand. \\
+-- See the top of the page for info on arguments passed to such functions.
+-- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown)
+function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation)
+ if type(options)=="table" then
+ if options.type~="group" then -- quick sanity checker
+ error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
+ end
+ AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+1
+ validateGetterArgs(uiType, uiName, errlvl)
+ if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
+ AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
+ AceConfigRegistry.validated[uiType][appName] = true
+ end
+ return options
+ end
+ elseif type(options)=="function" then
+ AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+1
+ validateGetterArgs(uiType, uiName, errlvl)
+ local tab = assert(options(uiType, uiName, appName))
+ if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
+ AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
+ AceConfigRegistry.validated[uiType][appName] = true
+ end
+ return tab
+ end
+ else
+ error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2)
+ end
+end
+
+--- Returns an iterator of ["appName"]=funcref pairs
+function AceConfigRegistry:IterateOptionsTables()
+ return pairs(AceConfigRegistry.tables)
+end
+
+
+
+
+--- Query the registry for a specific options table.
+-- If only appName is given, a function is returned which you
+-- can call with (uiType,uiName) to get the table.\\
+-- If uiType&uiName are given, the table is returned.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog"
+-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0"
+function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
+ local f = AceConfigRegistry.tables[appName]
+ if not f then
+ return nil
+ end
+
+ if uiType then
+ return f(uiType,uiName,1) -- get the table for us
+ else
+ return f -- return the function
+ end
+end
diff --git a/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml b/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml
new file mode 100644
index 0000000..4ea69ca
--- /dev/null
+++ b/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceConsole-3.0/AceConsole-3.0.lua b/libs/AceConsole-3.0/AceConsole-3.0.lua
new file mode 100644
index 0000000..0567a65
--- /dev/null
+++ b/libs/AceConsole-3.0/AceConsole-3.0.lua
@@ -0,0 +1,250 @@
+--- **AceConsole-3.0** provides registration facilities for slash commands.
+-- You can register slash commands to your custom functions and use the `GetArgs` function to parse them
+-- to your addons individual needs.
+--
+-- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceConsole itself.\\
+-- It is recommended to embed AceConsole, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceConsole.
+-- @class file
+-- @name AceConsole-3.0
+-- @release $Id: AceConsole-3.0.lua 1143 2016-07-11 08:52:03Z nevcairiel $
+local MAJOR,MINOR = "AceConsole-3.0", 7
+
+local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConsole then return end -- No upgrade needed
+
+AceConsole.embeds = AceConsole.embeds or {} -- table containing objects AceConsole is embedded in.
+AceConsole.commands = AceConsole.commands or {} -- table containing commands registered
+AceConsole.weakcommands = AceConsole.weakcommands or {} -- table containing self, command => func references for weak commands that don't persist through enable/disable
+
+-- Lua APIs
+local tconcat, tostring, select = table.concat, tostring, select
+local type, pairs, error = type, pairs, error
+local format, strfind, strsub = string.format, string.find, string.sub
+local max = math.max
+
+-- WoW APIs
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList
+
+local tmp={}
+local function Print(self,frame,...)
+ local n=0
+ if self ~= AceConsole then
+ n=n+1
+ tmp[n] = "|cff33ff99"..tostring( self ).."|r:"
+ end
+ for i=1, select("#", ...) do
+ n=n+1
+ tmp[n] = tostring(select(i, ...))
+ end
+ frame:AddMessage( tconcat(tmp," ",1,n) )
+end
+
+--- Print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
+-- @paramsig [chatframe ,] ...
+-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
+-- @param ... List of any values to be printed
+function AceConsole:Print(...)
+ local frame = ...
+ if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
+ return Print(self, frame, select(2,...))
+ else
+ return Print(self, DEFAULT_CHAT_FRAME, ...)
+ end
+end
+
+
+--- Formatted (using format()) print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
+-- @paramsig [chatframe ,] "format"[, ...]
+-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
+-- @param format Format string - same syntax as standard Lua format()
+-- @param ... Arguments to the format string
+function AceConsole:Printf(...)
+ local frame = ...
+ if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
+ return Print(self, frame, format(select(2,...)))
+ else
+ return Print(self, DEFAULT_CHAT_FRAME, format(...))
+ end
+end
+
+
+
+
+--- Register a simple chat command
+-- @param command Chat command to be registered WITHOUT leading "/"
+-- @param func Function to call when the slash command is being used (funcref or methodname)
+-- @param persist if false, the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true)
+function AceConsole:RegisterChatCommand( command, func, persist )
+ if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist ]): 'command' - expected a string]], 2) end
+
+ if persist==nil then persist=true end -- I'd rather have my addon's "/addon enable" around if the author screws up. Having some extra slash regged when it shouldnt be isn't as destructive. True is a better default. /Mikk
+
+ local name = "ACECONSOLE_"..command:upper()
+
+ if type( func ) == "string" then
+ SlashCmdList[name] = function(input, editBox)
+ self[func](self, input, editBox)
+ end
+ else
+ SlashCmdList[name] = func
+ end
+ _G["SLASH_"..name.."1"] = "/"..command:lower()
+ AceConsole.commands[command] = name
+ -- non-persisting commands are registered for enabling disabling
+ if not persist then
+ if not AceConsole.weakcommands[self] then AceConsole.weakcommands[self] = {} end
+ AceConsole.weakcommands[self][command] = func
+ end
+ return true
+end
+
+--- Unregister a chatcommand
+-- @param command Chat command to be unregistered WITHOUT leading "/"
+function AceConsole:UnregisterChatCommand( command )
+ local name = AceConsole.commands[command]
+ if name then
+ SlashCmdList[name] = nil
+ _G["SLASH_" .. name .. "1"] = nil
+ hash_SlashCmdList["/" .. command:upper()] = nil
+ AceConsole.commands[command] = nil
+ end
+end
+
+--- Get an iterator over all Chat Commands registered with AceConsole
+-- @return Iterator (pairs) over all commands
+function AceConsole:IterateChatCommands() return pairs(AceConsole.commands) end
+
+
+local function nils(n, ...)
+ if n>1 then
+ return nil, nils(n-1, ...)
+ elseif n==1 then
+ return nil, ...
+ else
+ return ...
+ end
+end
+
+
+--- Retreive one or more space-separated arguments from a string.
+-- Treats quoted strings and itemlinks as non-spaced.
+-- @param str The raw argument string
+-- @param numargs How many arguments to get (default 1)
+-- @param startpos Where in the string to start scanning (default 1)
+-- @return Returns arg1, arg2, ..., nextposition\\
+-- Missing arguments will be returned as nils. 'nextposition' is returned as 1e9 at the end of the string.
+function AceConsole:GetArgs(str, numargs, startpos)
+ numargs = numargs or 1
+ startpos = max(startpos or 1, 1)
+
+ local pos=startpos
+
+ -- find start of new arg
+ pos = strfind(str, "[^ ]", pos)
+ if not pos then -- whoops, end of string
+ return nils(numargs, 1e9)
+ end
+
+ if numargs<1 then
+ return pos
+ end
+
+ -- quoted or space separated? find out which pattern to use
+ local delim_or_pipe
+ local ch = strsub(str, pos, pos)
+ if ch=='"' then
+ pos = pos + 1
+ delim_or_pipe='([|"])'
+ elseif ch=="'" then
+ pos = pos + 1
+ delim_or_pipe="([|'])"
+ else
+ delim_or_pipe="([| ])"
+ end
+
+ startpos = pos
+
+ while true do
+ -- find delimiter or hyperlink
+ local ch,_
+ pos,_,ch = strfind(str, delim_or_pipe, pos)
+
+ if not pos then break end
+
+ if ch=="|" then
+ -- some kind of escape
+
+ if strsub(str,pos,pos+1)=="|H" then
+ -- It's a |H....|hhyper link!|h
+ pos=strfind(str, "|h", pos+2) -- first |h
+ if not pos then break end
+
+ pos=strfind(str, "|h", pos+2) -- second |h
+ if not pos then break end
+ elseif strsub(str,pos, pos+1) == "|T" then
+ -- It's a |T....|t texture
+ pos=strfind(str, "|t", pos+2)
+ if not pos then break end
+ end
+
+ pos=pos+2 -- skip past this escape (last |h if it was a hyperlink)
+
+ else
+ -- found delimiter, done with this arg
+ return strsub(str, startpos, pos-1), AceConsole:GetArgs(str, numargs-1, pos+1)
+ end
+
+ end
+
+ -- search aborted, we hit end of string. return it all as one argument. (yes, even if it's an unterminated quote or hyperlink)
+ return strsub(str, startpos), nils(numargs-1, 1e9)
+end
+
+
+--- embedding and embed handling
+
+local mixins = {
+ "Print",
+ "Printf",
+ "RegisterChatCommand",
+ "UnregisterChatCommand",
+ "GetArgs",
+}
+
+-- Embeds AceConsole into the target object making the functions from the mixins list available on target:..
+-- @param target target object to embed AceBucket in
+function AceConsole:Embed( target )
+ for k, v in pairs( mixins ) do
+ target[v] = self[v]
+ end
+ self.embeds[target] = true
+ return target
+end
+
+function AceConsole:OnEmbedEnable( target )
+ if AceConsole.weakcommands[target] then
+ for command, func in pairs( AceConsole.weakcommands[target] ) do
+ target:RegisterChatCommand( command, func, false, true ) -- nonpersisting and silent registry
+ end
+ end
+end
+
+function AceConsole:OnEmbedDisable( target )
+ if AceConsole.weakcommands[target] then
+ for command, func in pairs( AceConsole.weakcommands[target] ) do
+ target:UnregisterChatCommand( command ) -- TODO: this could potentially unregister a command from another application in case of command conflicts. Do we care?
+ end
+ end
+end
+
+for addon in pairs(AceConsole.embeds) do
+ AceConsole:Embed(addon)
+end
diff --git a/libs/AceConsole-3.0/AceConsole-3.0.xml b/libs/AceConsole-3.0/AceConsole-3.0.xml
new file mode 100644
index 0000000..4f4699a
--- /dev/null
+++ b/libs/AceConsole-3.0/AceConsole-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceDB-3.0/AceDB-3.0.lua b/libs/AceDB-3.0/AceDB-3.0.lua
new file mode 100644
index 0000000..b42b442
--- /dev/null
+++ b/libs/AceDB-3.0/AceDB-3.0.lua
@@ -0,0 +1,746 @@
+--- **AceDB-3.0** manages the SavedVariables of your addon.
+-- It offers profile management, smart defaults and namespaces for modules.\\
+-- Data can be saved in different data-types, depending on its intended usage.
+-- The most common data-type is the `profile` type, which allows the user to choose
+-- the active profile, and manage the profiles of all of his characters.\\
+-- The following data types are available:
+-- * **char** Character-specific data. Every character has its own database.
+-- * **realm** Realm-specific data. All of the players characters on the same realm share this database.
+-- * **class** Class-specific data. All of the players characters of the same class share this database.
+-- * **race** Race-specific data. All of the players characters of the same race share this database.
+-- * **faction** Faction-specific data. All of the players characters of the same faction share this database.
+-- * **factionrealm** Faction and realm specific data. All of the players characters on the same realm and of the same faction share this database.
+-- * **locale** Locale specific data, based on the locale of the players game client.
+-- * **global** Global Data. All characters on the same account share this database.
+-- * **profile** Profile-specific data. All characters using the same profile share this database. The user can control which profile should be used.
+--
+-- Creating a new Database using the `:New` function will return a new DBObject. A database will inherit all functions
+-- of the DBObjectLib listed here. \\
+-- If you create a new namespaced child-database (`:RegisterNamespace`), you'll get a DBObject as well, but note
+-- that the child-databases cannot individually change their profile, and are linked to their parents profile - and because of that,
+-- the profile related APIs are not available. Only `:RegisterDefaults` and `:ResetProfile` are available on child-databases.
+--
+-- For more details on how to use AceDB-3.0, see the [[AceDB-3.0 Tutorial]].
+--
+-- You may also be interested in [[libdualspec-1-0|LibDualSpec-1.0]] to do profile switching automatically when switching specs.
+--
+-- @usage
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("DBExample")
+--
+-- -- declare defaults to be used in the DB
+-- local defaults = {
+-- profile = {
+-- setting = true,
+-- }
+-- }
+--
+-- function MyAddon:OnInitialize()
+-- -- Assuming the .toc says ## SavedVariables: MyAddonDB
+-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
+-- end
+-- @class file
+-- @name AceDB-3.0.lua
+-- @release $Id: AceDB-3.0.lua 1142 2016-07-11 08:36:19Z nevcairiel $
+local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 26
+local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
+
+if not AceDB then return end -- No upgrade needed
+
+-- Lua APIs
+local type, pairs, next, error = type, pairs, next, error
+local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
+
+-- WoW APIs
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: LibStub
+
+AceDB.db_registry = AceDB.db_registry or {}
+AceDB.frame = AceDB.frame or CreateFrame("Frame")
+
+local CallbackHandler
+local CallbackDummy = { Fire = function() end }
+
+local DBObjectLib = {}
+
+--[[-------------------------------------------------------------------------
+ AceDB Utility Functions
+---------------------------------------------------------------------------]]
+
+-- Simple shallow copy for copying defaults
+local function copyTable(src, dest)
+ if type(dest) ~= "table" then dest = {} end
+ if type(src) == "table" then
+ for k,v in pairs(src) do
+ if type(v) == "table" then
+ -- try to index the key first so that the metatable creates the defaults, if set, and use that table
+ v = copyTable(v, dest[k])
+ end
+ dest[k] = v
+ end
+ end
+ return dest
+end
+
+-- Called to add defaults to a section of the database
+--
+-- When a ["*"] default section is indexed with a new key, a table is returned
+-- and set in the host table. These tables must be cleaned up by removeDefaults
+-- in order to ensure we don't write empty default tables.
+local function copyDefaults(dest, src)
+ -- this happens if some value in the SV overwrites our default value with a non-table
+ --if type(dest) ~= "table" then return end
+ for k, v in pairs(src) do
+ if k == "*" or k == "**" then
+ if type(v) == "table" then
+ -- This is a metatable used for table defaults
+ local mt = {
+ -- This handles the lookup and creation of new subtables
+ __index = function(t,k)
+ if k == nil then return nil end
+ local tbl = {}
+ copyDefaults(tbl, v)
+ rawset(t, k, tbl)
+ return tbl
+ end,
+ }
+ setmetatable(dest, mt)
+ -- handle already existing tables in the SV
+ for dk, dv in pairs(dest) do
+ if not rawget(src, dk) and type(dv) == "table" then
+ copyDefaults(dv, v)
+ end
+ end
+ else
+ -- Values are not tables, so this is just a simple return
+ local mt = {__index = function(t,k) return k~=nil and v or nil end}
+ setmetatable(dest, mt)
+ end
+ elseif type(v) == "table" then
+ if not rawget(dest, k) then rawset(dest, k, {}) end
+ if type(dest[k]) == "table" then
+ copyDefaults(dest[k], v)
+ if src['**'] then
+ copyDefaults(dest[k], src['**'])
+ end
+ end
+ else
+ if rawget(dest, k) == nil then
+ rawset(dest, k, v)
+ end
+ end
+ end
+end
+
+-- Called to remove all defaults in the default table from the database
+local function removeDefaults(db, defaults, blocker)
+ -- remove all metatables from the db, so we don't accidentally create new sub-tables through them
+ setmetatable(db, nil)
+ -- loop through the defaults and remove their content
+ for k,v in pairs(defaults) do
+ if k == "*" or k == "**" then
+ if type(v) == "table" then
+ -- Loop through all the actual k,v pairs and remove
+ for key, value in pairs(db) do
+ if type(value) == "table" then
+ -- if the key was not explicitly specified in the defaults table, just strip everything from * and ** tables
+ if defaults[key] == nil and (not blocker or blocker[key] == nil) then
+ removeDefaults(value, v)
+ -- if the table is empty afterwards, remove it
+ if next(value) == nil then
+ db[key] = nil
+ end
+ -- if it was specified, only strip ** content, but block values which were set in the key table
+ elseif k == "**" then
+ removeDefaults(value, v, defaults[key])
+ end
+ end
+ end
+ elseif k == "*" then
+ -- check for non-table default
+ for key, value in pairs(db) do
+ if defaults[key] == nil and v == value then
+ db[key] = nil
+ end
+ end
+ end
+ elseif type(v) == "table" and type(db[k]) == "table" then
+ -- if a blocker was set, dive into it, to allow multi-level defaults
+ removeDefaults(db[k], v, blocker and blocker[k])
+ if next(db[k]) == nil then
+ db[k] = nil
+ end
+ else
+ -- check if the current value matches the default, and that its not blocked by another defaults table
+ if db[k] == defaults[k] and (not blocker or blocker[k] == nil) then
+ db[k] = nil
+ end
+ end
+ end
+end
+
+-- This is called when a table section is first accessed, to set up the defaults
+local function initSection(db, section, svstore, key, defaults)
+ local sv = rawget(db, "sv")
+
+ local tableCreated
+ if not sv[svstore] then sv[svstore] = {} end
+ if not sv[svstore][key] then
+ sv[svstore][key] = {}
+ tableCreated = true
+ end
+
+ local tbl = sv[svstore][key]
+
+ if defaults then
+ copyDefaults(tbl, defaults)
+ end
+ rawset(db, section, tbl)
+
+ return tableCreated, tbl
+end
+
+-- Metatable to handle the dynamic creation of sections and copying of sections.
+local dbmt = {
+ __index = function(t, section)
+ local keys = rawget(t, "keys")
+ local key = keys[section]
+ if key then
+ local defaultTbl = rawget(t, "defaults")
+ local defaults = defaultTbl and defaultTbl[section]
+
+ if section == "profile" then
+ local new = initSection(t, section, "profiles", key, defaults)
+ if new then
+ -- Callback: OnNewProfile, database, newProfileKey
+ t.callbacks:Fire("OnNewProfile", t, key)
+ end
+ elseif section == "profiles" then
+ local sv = rawget(t, "sv")
+ if not sv.profiles then sv.profiles = {} end
+ rawset(t, "profiles", sv.profiles)
+ elseif section == "global" then
+ local sv = rawget(t, "sv")
+ if not sv.global then sv.global = {} end
+ if defaults then
+ copyDefaults(sv.global, defaults)
+ end
+ rawset(t, section, sv.global)
+ else
+ initSection(t, section, section, key, defaults)
+ end
+ end
+
+ return rawget(t, section)
+ end
+}
+
+local function validateDefaults(defaults, keyTbl, offset)
+ if not defaults then return end
+ offset = offset or 0
+ for k in pairs(defaults) do
+ if not keyTbl[k] or k == "profiles" then
+ error(("Usage: AceDBObject:RegisterDefaults(defaults): '%s' is not a valid datatype."):format(k), 3 + offset)
+ end
+ end
+end
+
+local preserve_keys = {
+ ["callbacks"] = true,
+ ["RegisterCallback"] = true,
+ ["UnregisterCallback"] = true,
+ ["UnregisterAllCallbacks"] = true,
+ ["children"] = true,
+}
+
+local realmKey = GetRealmName()
+local charKey = UnitName("player") .. " - " .. realmKey
+local _, classKey = UnitClass("player")
+local _, raceKey = UnitRace("player")
+local factionKey = UnitFactionGroup("player")
+local factionrealmKey = factionKey .. " - " .. realmKey
+local localeKey = GetLocale():lower()
+
+local regionTable = { "US", "KR", "EU", "TW", "CN" }
+local regionKey = regionTable[GetCurrentRegion()]
+local factionrealmregionKey = factionrealmKey .. " - " .. regionKey
+
+-- Actual database initialization function
+local function initdb(sv, defaults, defaultProfile, olddb, parent)
+ -- Generate the database keys for each section
+
+ -- map "true" to our "Default" profile
+ if defaultProfile == true then defaultProfile = "Default" end
+
+ local profileKey
+ if not parent then
+ -- Make a container for profile keys
+ if not sv.profileKeys then sv.profileKeys = {} end
+
+ -- Try to get the profile selected from the char db
+ profileKey = sv.profileKeys[charKey] or defaultProfile or charKey
+
+ -- save the selected profile for later
+ sv.profileKeys[charKey] = profileKey
+ else
+ -- Use the profile of the parents DB
+ profileKey = parent.keys.profile or defaultProfile or charKey
+
+ -- clear the profileKeys in the DB, namespaces don't need to store them
+ sv.profileKeys = nil
+ end
+
+ -- This table contains keys that enable the dynamic creation
+ -- of each section of the table. The 'global' and 'profiles'
+ -- have a key of true, since they are handled in a special case
+ local keyTbl= {
+ ["char"] = charKey,
+ ["realm"] = realmKey,
+ ["class"] = classKey,
+ ["race"] = raceKey,
+ ["faction"] = factionKey,
+ ["factionrealm"] = factionrealmKey,
+ ["factionrealmregion"] = factionrealmregionKey,
+ ["profile"] = profileKey,
+ ["locale"] = localeKey,
+ ["global"] = true,
+ ["profiles"] = true,
+ }
+
+ validateDefaults(defaults, keyTbl, 1)
+
+ -- This allows us to use this function to reset an entire database
+ -- Clear out the old database
+ if olddb then
+ for k,v in pairs(olddb) do if not preserve_keys[k] then olddb[k] = nil end end
+ end
+
+ -- Give this database the metatable so it initializes dynamically
+ local db = setmetatable(olddb or {}, dbmt)
+
+ if not rawget(db, "callbacks") then
+ -- try to load CallbackHandler-1.0 if it loaded after our library
+ if not CallbackHandler then CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0", true) end
+ db.callbacks = CallbackHandler and CallbackHandler:New(db) or CallbackDummy
+ end
+
+ -- Copy methods locally into the database object, to avoid hitting
+ -- the metatable when calling methods
+
+ if not parent then
+ for name, func in pairs(DBObjectLib) do
+ db[name] = func
+ end
+ else
+ -- hack this one in
+ db.RegisterDefaults = DBObjectLib.RegisterDefaults
+ db.ResetProfile = DBObjectLib.ResetProfile
+ end
+
+ -- Set some properties in the database object
+ db.profiles = sv.profiles
+ db.keys = keyTbl
+ db.sv = sv
+ --db.sv_name = name
+ db.defaults = defaults
+ db.parent = parent
+
+ -- store the DB in the registry
+ AceDB.db_registry[db] = true
+
+ return db
+end
+
+-- handle PLAYER_LOGOUT
+-- strip all defaults from all databases
+-- and cleans up empty sections
+local function logoutHandler(frame, event)
+ if event == "PLAYER_LOGOUT" then
+ for db in pairs(AceDB.db_registry) do
+ db.callbacks:Fire("OnDatabaseShutdown", db)
+ db:RegisterDefaults(nil)
+
+ -- cleanup sections that are empty without defaults
+ local sv = rawget(db, "sv")
+ for section in pairs(db.keys) do
+ if rawget(sv, section) then
+ -- global is special, all other sections have sub-entrys
+ -- also don't delete empty profiles on main dbs, only on namespaces
+ if section ~= "global" and (section ~= "profiles" or rawget(db, "parent")) then
+ for key in pairs(sv[section]) do
+ if not next(sv[section][key]) then
+ sv[section][key] = nil
+ end
+ end
+ end
+ if not next(sv[section]) then
+ sv[section] = nil
+ end
+ end
+ end
+ end
+ end
+end
+
+AceDB.frame:RegisterEvent("PLAYER_LOGOUT")
+AceDB.frame:SetScript("OnEvent", logoutHandler)
+
+
+--[[-------------------------------------------------------------------------
+ AceDB Object Method Definitions
+---------------------------------------------------------------------------]]
+
+--- Sets the defaults table for the given database object by clearing any
+-- that are currently set, and then setting the new defaults.
+-- @param defaults A table of defaults for this database
+function DBObjectLib:RegisterDefaults(defaults)
+ if defaults and type(defaults) ~= "table" then
+ error("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected.", 2)
+ end
+
+ validateDefaults(defaults, self.keys)
+
+ -- Remove any currently set defaults
+ if self.defaults then
+ for section,key in pairs(self.keys) do
+ if self.defaults[section] and rawget(self, section) then
+ removeDefaults(self[section], self.defaults[section])
+ end
+ end
+ end
+
+ -- Set the DBObject.defaults table
+ self.defaults = defaults
+
+ -- Copy in any defaults, only touching those sections already created
+ if defaults then
+ for section,key in pairs(self.keys) do
+ if defaults[section] and rawget(self, section) then
+ copyDefaults(self[section], defaults[section])
+ end
+ end
+ end
+end
+
+--- Changes the profile of the database and all of it's namespaces to the
+-- supplied named profile
+-- @param name The name of the profile to set as the current profile
+function DBObjectLib:SetProfile(name)
+ if type(name) ~= "string" then
+ error("Usage: AceDBObject:SetProfile(name): 'name' - string expected.", 2)
+ end
+
+ -- changing to the same profile, dont do anything
+ if name == self.keys.profile then return end
+
+ local oldProfile = self.profile
+ local defaults = self.defaults and self.defaults.profile
+
+ -- Callback: OnProfileShutdown, database
+ self.callbacks:Fire("OnProfileShutdown", self)
+
+ if oldProfile and defaults then
+ -- Remove the defaults from the old profile
+ removeDefaults(oldProfile, defaults)
+ end
+
+ self.profile = nil
+ self.keys["profile"] = name
+
+ -- if the storage exists, save the new profile
+ -- this won't exist on namespaces.
+ if self.sv.profileKeys then
+ self.sv.profileKeys[charKey] = name
+ end
+
+ -- populate to child namespaces
+ if self.children then
+ for _, db in pairs(self.children) do
+ DBObjectLib.SetProfile(db, name)
+ end
+ end
+
+ -- Callback: OnProfileChanged, database, newProfileKey
+ self.callbacks:Fire("OnProfileChanged", self, name)
+end
+
+--- Returns a table with the names of the existing profiles in the database.
+-- You can optionally supply a table to re-use for this purpose.
+-- @param tbl A table to store the profile names in (optional)
+function DBObjectLib:GetProfiles(tbl)
+ if tbl and type(tbl) ~= "table" then
+ error("Usage: AceDBObject:GetProfiles(tbl): 'tbl' - table or nil expected.", 2)
+ end
+
+ -- Clear the container table
+ if tbl then
+ for k,v in pairs(tbl) do tbl[k] = nil end
+ else
+ tbl = {}
+ end
+
+ local curProfile = self.keys.profile
+
+ local i = 0
+ for profileKey in pairs(self.profiles) do
+ i = i + 1
+ tbl[i] = profileKey
+ if curProfile and profileKey == curProfile then curProfile = nil end
+ end
+
+ -- Add the current profile, if it hasn't been created yet
+ if curProfile then
+ i = i + 1
+ tbl[i] = curProfile
+ end
+
+ return tbl, i
+end
+
+--- Returns the current profile name used by the database
+function DBObjectLib:GetCurrentProfile()
+ return self.keys.profile
+end
+
+--- Deletes a named profile. This profile must not be the active profile.
+-- @param name The name of the profile to be deleted
+-- @param silent If true, do not raise an error when the profile does not exist
+function DBObjectLib:DeleteProfile(name, silent)
+ if type(name) ~= "string" then
+ error("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected.", 2)
+ end
+
+ if self.keys.profile == name then
+ error("Cannot delete the active profile in an AceDBObject.", 2)
+ end
+
+ if not rawget(self.profiles, name) and not silent then
+ error("Cannot delete profile '" .. name .. "'. It does not exist.", 2)
+ end
+
+ self.profiles[name] = nil
+
+ -- populate to child namespaces
+ if self.children then
+ for _, db in pairs(self.children) do
+ DBObjectLib.DeleteProfile(db, name, true)
+ end
+ end
+
+ -- switch all characters that use this profile back to the default
+ if self.sv.profileKeys then
+ for key, profile in pairs(self.sv.profileKeys) do
+ if profile == name then
+ self.sv.profileKeys[key] = nil
+ end
+ end
+ end
+
+ -- Callback: OnProfileDeleted, database, profileKey
+ self.callbacks:Fire("OnProfileDeleted", self, name)
+end
+
+--- Copies a named profile into the current profile, overwriting any conflicting
+-- settings.
+-- @param name The name of the profile to be copied into the current profile
+-- @param silent If true, do not raise an error when the profile does not exist
+function DBObjectLib:CopyProfile(name, silent)
+ if type(name) ~= "string" then
+ error("Usage: AceDBObject:CopyProfile(name): 'name' - string expected.", 2)
+ end
+
+ if name == self.keys.profile then
+ error("Cannot have the same source and destination profiles.", 2)
+ end
+
+ if not rawget(self.profiles, name) and not silent then
+ error("Cannot copy profile '" .. name .. "'. It does not exist.", 2)
+ end
+
+ -- Reset the profile before copying
+ DBObjectLib.ResetProfile(self, nil, true)
+
+ local profile = self.profile
+ local source = self.profiles[name]
+
+ copyTable(source, profile)
+
+ -- populate to child namespaces
+ if self.children then
+ for _, db in pairs(self.children) do
+ DBObjectLib.CopyProfile(db, name, true)
+ end
+ end
+
+ -- Callback: OnProfileCopied, database, sourceProfileKey
+ self.callbacks:Fire("OnProfileCopied", self, name)
+end
+
+--- Resets the current profile to the default values (if specified).
+-- @param noChildren if set to true, the reset will not be populated to the child namespaces of this DB object
+-- @param noCallbacks if set to true, won't fire the OnProfileReset callback
+function DBObjectLib:ResetProfile(noChildren, noCallbacks)
+ local profile = self.profile
+
+ for k,v in pairs(profile) do
+ profile[k] = nil
+ end
+
+ local defaults = self.defaults and self.defaults.profile
+ if defaults then
+ copyDefaults(profile, defaults)
+ end
+
+ -- populate to child namespaces
+ if self.children and not noChildren then
+ for _, db in pairs(self.children) do
+ DBObjectLib.ResetProfile(db, nil, noCallbacks)
+ end
+ end
+
+ -- Callback: OnProfileReset, database
+ if not noCallbacks then
+ self.callbacks:Fire("OnProfileReset", self)
+ end
+end
+
+--- Resets the entire database, using the string defaultProfile as the new default
+-- profile.
+-- @param defaultProfile The profile name to use as the default
+function DBObjectLib:ResetDB(defaultProfile)
+ if defaultProfile and type(defaultProfile) ~= "string" then
+ error("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected.", 2)
+ end
+
+ local sv = self.sv
+ for k,v in pairs(sv) do
+ sv[k] = nil
+ end
+
+ local parent = self.parent
+
+ initdb(sv, self.defaults, defaultProfile, self)
+
+ -- fix the child namespaces
+ if self.children then
+ if not sv.namespaces then sv.namespaces = {} end
+ for name, db in pairs(self.children) do
+ if not sv.namespaces[name] then sv.namespaces[name] = {} end
+ initdb(sv.namespaces[name], db.defaults, self.keys.profile, db, self)
+ end
+ end
+
+ -- Callback: OnDatabaseReset, database
+ self.callbacks:Fire("OnDatabaseReset", self)
+ -- Callback: OnProfileChanged, database, profileKey
+ self.callbacks:Fire("OnProfileChanged", self, self.keys["profile"])
+
+ return self
+end
+
+--- Creates a new database namespace, directly tied to the database. This
+-- is a full scale database in it's own rights other than the fact that
+-- it cannot control its profile individually
+-- @param name The name of the new namespace
+-- @param defaults A table of values to use as defaults
+function DBObjectLib:RegisterNamespace(name, defaults)
+ if type(name) ~= "string" then
+ error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - string expected.", 2)
+ end
+ if defaults and type(defaults) ~= "table" then
+ error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected.", 2)
+ end
+ if self.children and self.children[name] then
+ error ("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace with that name already exists.", 2)
+ end
+
+ local sv = self.sv
+ if not sv.namespaces then sv.namespaces = {} end
+ if not sv.namespaces[name] then
+ sv.namespaces[name] = {}
+ end
+
+ local newDB = initdb(sv.namespaces[name], defaults, self.keys.profile, nil, self)
+
+ if not self.children then self.children = {} end
+ self.children[name] = newDB
+ return newDB
+end
+
+--- Returns an already existing namespace from the database object.
+-- @param name The name of the new namespace
+-- @param silent if true, the addon is optional, silently return nil if its not found
+-- @usage
+-- local namespace = self.db:GetNamespace('namespace')
+-- @return the namespace object if found
+function DBObjectLib:GetNamespace(name, silent)
+ if type(name) ~= "string" then
+ error("Usage: AceDBObject:GetNamespace(name): 'name' - string expected.", 2)
+ end
+ if not silent and not (self.children and self.children[name]) then
+ error ("Usage: AceDBObject:GetNamespace(name): 'name' - namespace does not exist.", 2)
+ end
+ if not self.children then self.children = {} end
+ return self.children[name]
+end
+
+--[[-------------------------------------------------------------------------
+ AceDB Exposed Methods
+---------------------------------------------------------------------------]]
+
+--- Creates a new database object that can be used to handle database settings and profiles.
+-- By default, an empty DB is created, using a character specific profile.
+--
+-- You can override the default profile used by passing any profile name as the third argument,
+-- or by passing //true// as the third argument to use a globally shared profile called "Default".
+--
+-- Note that there is no token replacement in the default profile name, passing a defaultProfile as "char"
+-- will use a profile named "char", and not a character-specific profile.
+-- @param tbl The name of variable, or table to use for the database
+-- @param defaults A table of database defaults
+-- @param defaultProfile The name of the default profile. If not set, a character specific profile will be used as the default.
+-- You can also pass //true// to use a shared global profile called "Default".
+-- @usage
+-- -- Create an empty DB using a character-specific default profile.
+-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB")
+-- @usage
+-- -- Create a DB using defaults and using a shared default profile
+-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
+function AceDB:New(tbl, defaults, defaultProfile)
+ if type(tbl) == "string" then
+ local name = tbl
+ tbl = _G[name]
+ if not tbl then
+ tbl = {}
+ _G[name] = tbl
+ end
+ end
+
+ if type(tbl) ~= "table" then
+ error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected.", 2)
+ end
+
+ if defaults and type(defaults) ~= "table" then
+ error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected.", 2)
+ end
+
+ if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then
+ error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected.", 2)
+ end
+
+ return initdb(tbl, defaults, defaultProfile)
+end
+
+-- upgrade existing databases
+for db in pairs(AceDB.db_registry) do
+ if not db.parent then
+ for name,func in pairs(DBObjectLib) do
+ db[name] = func
+ end
+ else
+ db.RegisterDefaults = DBObjectLib.RegisterDefaults
+ db.ResetProfile = DBObjectLib.ResetProfile
+ end
+end
diff --git a/libs/AceDB-3.0/AceDB-3.0.xml b/libs/AceDB-3.0/AceDB-3.0.xml
new file mode 100644
index 0000000..108fc70
--- /dev/null
+++ b/libs/AceDB-3.0/AceDB-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceDBOptions-3.0/AceDBOptions-3.0.lua b/libs/AceDBOptions-3.0/AceDBOptions-3.0.lua
new file mode 100644
index 0000000..5028fef
--- /dev/null
+++ b/libs/AceDBOptions-3.0/AceDBOptions-3.0.lua
@@ -0,0 +1,460 @@
+--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
+-- @class file
+-- @name AceDBOptions-3.0
+-- @release $Id: AceDBOptions-3.0.lua 1140 2016-07-03 07:53:29Z nevcairiel $
+local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
+local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
+
+if not AceDBOptions then return end -- No upgrade needed
+
+-- Lua APIs
+local pairs, next = pairs, next
+
+-- WoW APIs
+local UnitClass = UnitClass
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: NORMAL_FONT_COLOR_CODE, FONT_COLOR_CODE_CLOSE
+
+AceDBOptions.optionTables = AceDBOptions.optionTables or {}
+AceDBOptions.handlers = AceDBOptions.handlers or {}
+
+--[[
+ Localization of AceDBOptions-3.0
+]]
+
+local L = {
+ choose = "Existing Profiles",
+ choose_desc = "You can either create a new profile by entering a name in the editbox, or choose one of the already existing profiles.",
+ choose_sub = "Select one of your currently available profiles.",
+ copy = "Copy From",
+ copy_desc = "Copy the settings from one existing profile into the currently active profile.",
+ current = "Current Profile:",
+ default = "Default",
+ delete = "Delete a Profile",
+ delete_confirm = "Are you sure you want to delete the selected profile?",
+ delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.",
+ delete_sub = "Deletes a profile from the database.",
+ intro = "You can change the active database profile, so you can have different settings for every character.",
+ new = "New",
+ new_sub = "Create a new empty profile.",
+ profiles = "Profiles",
+ profiles_sub = "Manage Profiles",
+ reset = "Reset Profile",
+ reset_desc = "Reset the current profile back to its default values, in case your configuration is broken, or you simply want to start over.",
+ reset_sub = "Reset the current profile to the default",
+}
+
+local LOCALE = GetLocale()
+if LOCALE == "deDE" then
+ L["choose"] = "Vorhandene Profile"
+ L["choose_desc"] = "Du kannst ein neues Profil erstellen, indem du einen neuen Namen in der Eingabebox 'Neu' eingibst, oder wähle eines der vorhandenen Profile aus."
+ L["choose_sub"] = "Wählt ein bereits vorhandenes Profil aus."
+ L["copy"] = "Kopieren von..."
+ L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil."
+ L["current"] = "Aktuelles Profil:"
+ L["default"] = "Standard"
+ L["delete"] = "Profil löschen"
+ L["delete_confirm"] = "Willst du das ausgewählte Profil wirklich löschen?"
+ L["delete_desc"] = "Lösche vorhandene oder unbenutzte Profile aus der Datenbank, um Platz zu sparen und die SavedVariables-Datei 'sauber' zu halten."
+ L["delete_sub"] = "Löscht ein Profil aus der Datenbank."
+ L["intro"] = "Hier kannst du das aktive Datenbankprofil ändern, damit du verschiedene Einstellungen für jeden Charakter erstellen kannst, wodurch eine sehr flexible Konfiguration möglich wird."
+ L["new"] = "Neu"
+ L["new_sub"] = "Ein neues Profil erstellen."
+ L["profiles"] = "Profile"
+ L["profiles_sub"] = "Profile verwalten"
+ L["reset"] = "Profil zurücksetzen"
+ L["reset_desc"] = "Setzt das momentane Profil auf Standardwerte zurück, für den Fall, dass mit der Konfiguration etwas schief lief oder weil du einfach neu starten willst."
+ L["reset_sub"] = "Das aktuelle Profil auf Standard zurücksetzen."
+elseif LOCALE == "frFR" then
+ L["choose"] = "Profils existants"
+ L["choose_desc"] = "Vous pouvez créer un nouveau profil en entrant un nouveau nom dans la boîte de saisie, ou en choississant un des profils déjà existants."
+ L["choose_sub"] = "Permet de choisir un des profils déjà disponibles."
+ L["copy"] = "Copier à partir de"
+ L["copy_desc"] = "Copie les paramètres d'un profil déjà existant dans le profil actuellement actif."
+ L["current"] = "Profil actuel :"
+ L["default"] = "Défaut"
+ L["delete"] = "Supprimer un profil"
+ L["delete_confirm"] = "Etes-vous sûr de vouloir supprimer le profil sélectionné ?"
+ L["delete_desc"] = "Supprime les profils existants inutilisés de la base de données afin de gagner de la place et de nettoyer le fichier SavedVariables."
+ L["delete_sub"] = "Supprime un profil de la base de données."
+ L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des paramètres différents pour chaque personnage, permettant ainsi d'avoir une configuration très flexible."
+ L["new"] = "Nouveau"
+ L["new_sub"] = "Créée un nouveau profil vierge."
+ L["profiles"] = "Profils"
+ L["profiles_sub"] = "Gestion des profils"
+ L["reset"] = "Réinitialiser le profil"
+ L["reset_desc"] = "Réinitialise le profil actuel au cas où votre configuration est corrompue ou si vous voulez tout simplement faire table rase."
+ L["reset_sub"] = "Réinitialise le profil actuel avec les paramètres par défaut."
+elseif LOCALE == "koKR" then
+ L["choose"] = "저장 중인 프로필"
+ L["choose_desc"] = "입력창에 새로운 이름을 입력하거나 저장 중인 프로필 중 하나를 선택하여 새로운 프로필을 만들 수 있습니다."
+ L["choose_sub"] = "현재 이용할 수 있는 프로필 중 하나를 선택합니다."
+ L["copy"] = "복사해오기"
+ L["copy_desc"] = "현재 사용 중인 프로필에 선택한 프로필의 설정을 복사합니다."
+ L["current"] = "현재 프로필:"
+ L["default"] = "기본값"
+ L["delete"] = "프로필 삭제"
+ L["delete_confirm"] = "정말로 선택한 프로필을 삭제할까요?"
+ L["delete_desc"] = "저장 공간 절약과 SavedVariables 파일의 정리를 위해 데이터베이스에서 사용하지 않는 프로필을 삭제하세요."
+ L["delete_sub"] = "데이터베이스의 프로필을 삭제합니다."
+ L["intro"] = "활성 데이터베이스 프로필을 변경할 수 있고, 각 캐릭터 별로 다른 설정을 할 수 있습니다."
+ L["new"] = "새로운 프로필"
+ L["new_sub"] = "새로운 프로필을 만듭니다."
+ L["profiles"] = "프로필"
+ L["profiles_sub"] = "프로필 관리"
+ L["reset"] = "프로필 초기화"
+ L["reset_desc"] = "설정이 깨졌거나 처음부터 다시 설정을 원하는 경우, 현재 프로필을 기본값으로 초기화하세요."
+ L["reset_sub"] = "현재 프로필을 기본값으로 초기화합니다"
+elseif LOCALE == "esES" or LOCALE == "esMX" then
+ L["choose"] = "Perfiles existentes"
+ L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes."
+ L["choose_sub"] = "Selecciona uno de los perfiles disponibles."
+ L["copy"] = "Copiar de"
+ L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual."
+ L["current"] = "Perfil actual:"
+ L["default"] = "Por defecto"
+ L["delete"] = "Borrar un Perfil"
+ L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?"
+ L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables."
+ L["delete_sub"] = "Borra un perfil de la base de datos."
+ L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones."
+ L["new"] = "Nuevo"
+ L["new_sub"] = "Crear un nuevo perfil vacio."
+ L["profiles"] = "Perfiles"
+ L["profiles_sub"] = "Manejar Perfiles"
+ L["reset"] = "Reiniciar Perfil"
+ L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo."
+ L["reset_sub"] = "Reinicar el perfil actual al de por defecto"
+elseif LOCALE == "zhTW" then
+ L["choose"] = "現有的設定檔"
+ L["choose_desc"] = "您可以在文字方塊內輸入名字以建立新的設定檔,或是選擇一個現有的設定檔使用。"
+ L["choose_sub"] = "從當前可用的設定檔裡面選擇一個。"
+ L["copy"] = "複製自"
+ L["copy_desc"] = "從一個現有的設定檔,將設定複製到現在使用中的設定檔。"
+ L["current"] = "目前設定檔:"
+ L["default"] = "預設"
+ L["delete"] = "刪除一個設定檔"
+ L["delete_confirm"] = "確定要刪除所選擇的設定檔嗎?"
+ L["delete_desc"] = "從資料庫裡刪除不再使用的設定檔,以節省空間,並且清理 SavedVariables 檔案。"
+ L["delete_sub"] = "從資料庫裡刪除一個設定檔。"
+ L["intro"] = "您可以從資料庫中選擇一個設定檔來使用,如此就可以讓每個角色使用不同的設定。"
+ L["new"] = "新建"
+ L["new_sub"] = "新建一個空的設定檔。"
+ L["profiles"] = "設定檔"
+ L["profiles_sub"] = "管理設定檔"
+ L["reset"] = "重置設定檔"
+ L["reset_desc"] = "將現用的設定檔重置為預設值;用於設定檔損壞,或者單純想要重來的情況。"
+ L["reset_sub"] = "將目前的設定檔重置為預設值"
+elseif LOCALE == "zhCN" then
+ L["choose"] = "现有的配置文件"
+ L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。"
+ L["choose_sub"] = "从当前可用的配置文件里面选择一个。"
+ L["copy"] = "复制自"
+ L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。"
+ L["current"] = "当前配置文件:"
+ L["default"] = "默认"
+ L["delete"] = "删除一个配置文件"
+ L["delete_confirm"] = "你确定要删除所选择的配置文件么?"
+ L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。"
+ L["delete_sub"] = "从数据库里删除一个配置文件。"
+ L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。"
+ L["new"] = "新建"
+ L["new_sub"] = "新建一个空的配置文件。"
+ L["profiles"] = "配置文件"
+ L["profiles_sub"] = "管理配置文件"
+ L["reset"] = "重置配置文件"
+ L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。"
+ L["reset_sub"] = "将当前的配置文件恢复为默认值"
+elseif LOCALE == "ruRU" then
+ L["choose"] = "Существующие профили"
+ L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей."
+ L["choose_sub"] = "Выбор одиного из уже доступных профилей"
+ L["copy"] = "Скопировать из"
+ L["copy_desc"] = "Скопировать настройки из выбранного профиля в активный."
+ L["current"] = "Текущий профиль:"
+ L["default"] = "По умолчанию"
+ L["delete"] = "Удалить профиль"
+ L["delete_confirm"] = "Вы уверены, что вы хотите удалить выбранный профиль?"
+ L["delete_desc"] = "Удалить существующий и неиспользуемый профиль из БД для сохранения места, и очистить SavedVariables файл."
+ L["delete_sub"] = "Удаление профиля из БД"
+ L["intro"] = "Изменяя активный профиль, вы можете задать различные настройки модификаций для каждого персонажа."
+ L["new"] = "Новый"
+ L["new_sub"] = "Создать новый чистый профиль"
+ L["profiles"] = "Профили"
+ L["profiles_sub"] = "Управление профилями"
+ L["reset"] = "Сброс профиля"
+ L["reset_desc"] = "Сбросить текущий профиль к стандартным настройкам, если ваша конфигурация испорчена или вы хотите настроить всё заново."
+ L["reset_sub"] = "Сброс текущего профиля на стандартный"
+elseif LOCALE == "itIT" then
+ L["choose"] = "Profili Esistenti"
+ L["choose_desc"] = "Puoi creare un nuovo profilo digitando il nome della casella di testo, oppure scegliendone uno tra i profili già esistenti."
+ L["choose_sub"] = "Seleziona uno dei profili attualmente disponibili."
+ L["copy"] = "Copia Da"
+ L["copy_desc"] = "Copia le impostazioni da un profilo esistente, nel profilo attivo in questo momento."
+ L["current"] = "Profilo Attivo:"
+ L["default"] = "Standard"
+ L["delete"] = "Cancella un Profilo"
+ L["delete_confirm"] = "Sei sicuro di voler cancellare il profilo selezionato?"
+ L["delete_desc"] = "Cancella i profili non utilizzati dal database per risparmiare spazio e mantenere puliti i file di configurazione SavedVariables."
+ L["delete_sub"] = "Cancella un profilo dal Database."
+ L["intro"] = "Puoi cambiare il profilo attivo, in modo da usare impostazioni diverse per ogni personaggio."
+ L["new"] = "Nuovo"
+ L["new_sub"] = "Crea un nuovo profilo vuoto."
+ L["profiles"] = "Profili"
+ L["profiles_sub"] = "Gestisci Profili"
+ L["reset"] = "Reimposta Profilo"
+ L["reset_desc"] = "Riporta il tuo profilo attivo alle sue impostazioni predefinite, nel caso in cui la tua configurazione si sia corrotta, o semplicemente tu voglia re-inizializzarla."
+ L["reset_sub"] = "Reimposta il profilo ai suoi valori predefiniti."
+elseif LOCALE == "ptBR" then
+ L["choose"] = "Perfis Existentes"
+ L["choose_desc"] = "Você pode tanto criar um perfil novo tanto digitando um nome na caixa de texto, quanto escolher um dos perfis já existentes."
+ L["choose_sub"] = "Selecione um de seus perfis atualmente disponíveis."
+ L["copy"] = "Copiar De"
+ L["copy_desc"] = "Copia as definições de um perfil existente no perfil atualmente ativo."
+ L["current"] = "Perfil Autal:"
+ L["default"] = "Padrão"
+ L["delete"] = "Remover um Perfil"
+ L["delete_confirm"] = "Tem certeza que deseja remover o perfil selecionado?"
+ L["delete_desc"] = "Remove perfis existentes e inutilizados do banco de dados para economizar espaço, e limpar o arquivo SavedVariables."
+ L["delete_sub"] = "Remove um perfil do banco de dados."
+ L["intro"] = "Você pode alterar o perfil do banco de dados ativo, para que possa ter definições diferentes para cada personagem."
+ L["new"] = "Novo"
+ L["new_sub"] = "Cria um novo perfil vazio."
+ L["profiles"] = "Perfis"
+ L["profiles_sub"] = "Gerenciar Perfis"
+ L["reset"] = "Resetar Perfil"
+ L["reset_desc"] = "Reseta o perfil atual para os valores padrões, no caso de sua configuração estar quebrada, ou simplesmente se deseja começar novamente."
+ L["reset_sub"] = "Resetar o perfil atual ao padrão"
+end
+
+local defaultProfiles
+local tmpprofiles = {}
+
+-- Get a list of available profiles for the specified database.
+-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
+-- @param db The db object to retrieve the profiles from
+-- @param common If true, getProfileList will add the default profiles to the return list, even if they have not been created yet
+-- @param nocurrent If true, then getProfileList will not display the current profile in the list
+-- @return Hashtable of all profiles with the internal name as keys and the display name as value.
+local function getProfileList(db, common, nocurrent)
+ local profiles = {}
+
+ -- copy existing profiles into the table
+ local currentProfile = db:GetCurrentProfile()
+ for i,v in pairs(db:GetProfiles(tmpprofiles)) do
+ if not (nocurrent and v == currentProfile) then
+ profiles[v] = v
+ end
+ end
+
+ -- add our default profiles to choose from ( or rename existing profiles)
+ for k,v in pairs(defaultProfiles) do
+ if (common or profiles[k]) and not (nocurrent and k == currentProfile) then
+ profiles[k] = v
+ end
+ end
+
+ return profiles
+end
+
+--[[
+ OptionsHandlerPrototype
+ prototype class for handling the options in a sane way
+]]
+local OptionsHandlerPrototype = {}
+
+--[[ Reset the profile ]]
+function OptionsHandlerPrototype:Reset()
+ self.db:ResetProfile()
+end
+
+--[[ Set the profile to value ]]
+function OptionsHandlerPrototype:SetProfile(info, value)
+ self.db:SetProfile(value)
+end
+
+--[[ returns the currently active profile ]]
+function OptionsHandlerPrototype:GetCurrentProfile()
+ return self.db:GetCurrentProfile()
+end
+
+--[[
+ List all active profiles
+ you can control the output with the .arg variable
+ currently four modes are supported
+
+ (empty) - return all available profiles
+ "nocurrent" - returns all available profiles except the currently active profile
+ "common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
+ "both" - common except the active profile
+]]
+function OptionsHandlerPrototype:ListProfiles(info)
+ local arg = info.arg
+ local profiles
+ if arg == "common" and not self.noDefaultProfiles then
+ profiles = getProfileList(self.db, true, nil)
+ elseif arg == "nocurrent" then
+ profiles = getProfileList(self.db, nil, true)
+ elseif arg == "both" then -- currently not used
+ profiles = getProfileList(self.db, (not self.noDefaultProfiles) and true, true)
+ else
+ profiles = getProfileList(self.db)
+ end
+
+ return profiles
+end
+
+function OptionsHandlerPrototype:HasNoProfiles(info)
+ local profiles = self:ListProfiles(info)
+ return ((not next(profiles)) and true or false)
+end
+
+--[[ Copy a profile ]]
+function OptionsHandlerPrototype:CopyProfile(info, value)
+ self.db:CopyProfile(value)
+end
+
+--[[ Delete a profile from the db ]]
+function OptionsHandlerPrototype:DeleteProfile(info, value)
+ self.db:DeleteProfile(value)
+end
+
+--[[ fill defaultProfiles with some generic values ]]
+local function generateDefaultProfiles(db)
+ defaultProfiles = {
+ ["Default"] = L["default"],
+ [db.keys.char] = db.keys.char,
+ [db.keys.realm] = db.keys.realm,
+ [db.keys.class] = UnitClass("player")
+ }
+end
+
+--[[ create and return a handler object for the db, or upgrade it if it already existed ]]
+local function getOptionsHandler(db, noDefaultProfiles)
+ if not defaultProfiles then
+ generateDefaultProfiles(db)
+ end
+
+ local handler = AceDBOptions.handlers[db] or { db = db, noDefaultProfiles = noDefaultProfiles }
+
+ for k,v in pairs(OptionsHandlerPrototype) do
+ handler[k] = v
+ end
+
+ AceDBOptions.handlers[db] = handler
+ return handler
+end
+
+--[[
+ the real options table
+]]
+local optionsTable = {
+ desc = {
+ order = 1,
+ type = "description",
+ name = L["intro"] .. "\n",
+ },
+ descreset = {
+ order = 9,
+ type = "description",
+ name = L["reset_desc"],
+ },
+ reset = {
+ order = 10,
+ type = "execute",
+ name = L["reset"],
+ desc = L["reset_sub"],
+ func = "Reset",
+ },
+ current = {
+ order = 11,
+ type = "description",
+ name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
+ width = "default",
+ },
+ choosedesc = {
+ order = 20,
+ type = "description",
+ name = "\n" .. L["choose_desc"],
+ },
+ new = {
+ name = L["new"],
+ desc = L["new_sub"],
+ type = "input",
+ order = 30,
+ get = false,
+ set = "SetProfile",
+ },
+ choose = {
+ name = L["choose"],
+ desc = L["choose_sub"],
+ type = "select",
+ order = 40,
+ get = "GetCurrentProfile",
+ set = "SetProfile",
+ values = "ListProfiles",
+ arg = "common",
+ },
+ copydesc = {
+ order = 50,
+ type = "description",
+ name = "\n" .. L["copy_desc"],
+ },
+ copyfrom = {
+ order = 60,
+ type = "select",
+ name = L["copy"],
+ desc = L["copy_desc"],
+ get = false,
+ set = "CopyProfile",
+ values = "ListProfiles",
+ disabled = "HasNoProfiles",
+ arg = "nocurrent",
+ },
+ deldesc = {
+ order = 70,
+ type = "description",
+ name = "\n" .. L["delete_desc"],
+ },
+ delete = {
+ order = 80,
+ type = "select",
+ name = L["delete"],
+ desc = L["delete_sub"],
+ get = false,
+ set = "DeleteProfile",
+ values = "ListProfiles",
+ disabled = "HasNoProfiles",
+ arg = "nocurrent",
+ confirm = true,
+ confirmText = L["delete_confirm"],
+ },
+}
+
+--- Get/Create a option table that you can use in your addon to control the profiles of AceDB-3.0.
+-- @param db The database object to create the options table for.
+-- @return The options table to be used in AceConfig-3.0
+-- @usage
+-- -- Assuming `options` is your top-level options table and `self.db` is your database:
+-- options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
+function AceDBOptions:GetOptionsTable(db, noDefaultProfiles)
+ local tbl = AceDBOptions.optionTables[db] or {
+ type = "group",
+ name = L["profiles"],
+ desc = L["profiles_sub"],
+ }
+
+ tbl.handler = getOptionsHandler(db, noDefaultProfiles)
+ tbl.args = optionsTable
+
+ AceDBOptions.optionTables[db] = tbl
+ return tbl
+end
+
+-- upgrade existing tables
+for db,tbl in pairs(AceDBOptions.optionTables) do
+ tbl.handler = getOptionsHandler(db)
+ tbl.args = optionsTable
+end
diff --git a/libs/AceDBOptions-3.0/AceDBOptions-3.0.xml b/libs/AceDBOptions-3.0/AceDBOptions-3.0.xml
new file mode 100644
index 0000000..51305f9
--- /dev/null
+++ b/libs/AceDBOptions-3.0/AceDBOptions-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceEvent-3.0/AceEvent-3.0.lua b/libs/AceEvent-3.0/AceEvent-3.0.lua
new file mode 100644
index 0000000..bbf55c2
--- /dev/null
+++ b/libs/AceEvent-3.0/AceEvent-3.0.lua
@@ -0,0 +1,126 @@
+--- AceEvent-3.0 provides event registration and secure dispatching.
+-- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around
+-- CallbackHandler, and dispatches all game events or addon message to the registrees.
+--
+-- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceEvent itself.\\
+-- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceEvent.
+-- @class file
+-- @name AceEvent-3.0
+-- @release $Id: AceEvent-3.0.lua 1161 2017-08-12 14:30:16Z funkydude $
+local CallbackHandler = LibStub("CallbackHandler-1.0")
+
+local MAJOR, MINOR = "AceEvent-3.0", 4
+local AceEvent = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceEvent then return end
+
+-- Lua APIs
+local pairs = pairs
+
+AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame
+AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib
+
+-- APIs and registry for blizzard events, using CallbackHandler lib
+if not AceEvent.events then
+ AceEvent.events = CallbackHandler:New(AceEvent,
+ "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents")
+end
+
+function AceEvent.events:OnUsed(target, eventname)
+ AceEvent.frame:RegisterEvent(eventname)
+end
+
+function AceEvent.events:OnUnused(target, eventname)
+ AceEvent.frame:UnregisterEvent(eventname)
+end
+
+
+-- APIs and registry for IPC messages, using CallbackHandler lib
+if not AceEvent.messages then
+ AceEvent.messages = CallbackHandler:New(AceEvent,
+ "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages"
+ )
+ AceEvent.SendMessage = AceEvent.messages.Fire
+end
+
+--- embedding and embed handling
+local mixins = {
+ "RegisterEvent", "UnregisterEvent",
+ "RegisterMessage", "UnregisterMessage",
+ "SendMessage",
+ "UnregisterAllEvents", "UnregisterAllMessages",
+}
+
+--- Register for a Blizzard Event.
+-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied)
+-- Any arguments to the event will be passed on after that.
+-- @name AceEvent:RegisterEvent
+-- @class function
+-- @paramsig event[, callback [, arg]]
+-- @param event The event to register for
+-- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name)
+-- @param arg An optional argument to pass to the callback function
+
+--- Unregister an event.
+-- @name AceEvent:UnregisterEvent
+-- @class function
+-- @paramsig event
+-- @param event The event to unregister
+
+--- Register for a custom AceEvent-internal message.
+-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied)
+-- Any arguments to the event will be passed on after that.
+-- @name AceEvent:RegisterMessage
+-- @class function
+-- @paramsig message[, callback [, arg]]
+-- @param message The message to register for
+-- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name)
+-- @param arg An optional argument to pass to the callback function
+
+--- Unregister a message
+-- @name AceEvent:UnregisterMessage
+-- @class function
+-- @paramsig message
+-- @param message The message to unregister
+
+--- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message.
+-- @name AceEvent:SendMessage
+-- @class function
+-- @paramsig message, ...
+-- @param message The message to send
+-- @param ... Any arguments to the message
+
+
+-- Embeds AceEvent into the target object making the functions from the mixins list available on target:..
+-- @param target target object to embed AceEvent in
+function AceEvent:Embed(target)
+ for k, v in pairs(mixins) do
+ target[v] = self[v]
+ end
+ self.embeds[target] = true
+ return target
+end
+
+-- AceEvent:OnEmbedDisable( target )
+-- target (object) - target object that is being disabled
+--
+-- Unregister all events messages etc when the target disables.
+-- this method should be called by the target manually or by an addon framework
+function AceEvent:OnEmbedDisable(target)
+ target:UnregisterAllEvents()
+ target:UnregisterAllMessages()
+end
+
+-- Script to fire blizzard events into the event listeners
+local events = AceEvent.events
+AceEvent.frame:SetScript("OnEvent", function(this, event, ...)
+ events:Fire(event, ...)
+end)
+
+--- Finally: upgrade our old embeds
+for target, v in pairs(AceEvent.embeds) do
+ AceEvent:Embed(target)
+end
diff --git a/libs/AceEvent-3.0/AceEvent-3.0.xml b/libs/AceEvent-3.0/AceEvent-3.0.xml
new file mode 100644
index 0000000..41ef791
--- /dev/null
+++ b/libs/AceEvent-3.0/AceEvent-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceGUI-3.0/AceGUI-3.0.lua b/libs/AceGUI-3.0/AceGUI-3.0.lua
new file mode 100644
index 0000000..9853644
--- /dev/null
+++ b/libs/AceGUI-3.0/AceGUI-3.0.lua
@@ -0,0 +1,813 @@
+--- **AceGUI-3.0** provides access to numerous widgets which can be used to create GUIs.
+-- AceGUI is used by AceConfigDialog to create the option GUIs, but you can use it by itself
+-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3
+-- stand-alone distribution.
+--
+-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly,
+-- as any "unknown" change to the widgets will cause addons that get your widget out of the widget pool
+-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we"ll
+-- implement a proper API to modify it.
+-- @usage
+-- local AceGUI = LibStub("AceGUI-3.0")
+-- -- Create a container frame
+-- local f = AceGUI:Create("Frame")
+-- f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
+-- f:SetTitle("AceGUI-3.0 Example")
+-- f:SetStatusText("Status Bar")
+-- f:SetLayout("Flow")
+-- -- Create a button
+-- local btn = AceGUI:Create("Button")
+-- btn:SetWidth(170)
+-- btn:SetText("Button !")
+-- btn:SetCallback("OnClick", function() print("Click!") end)
+-- -- Add the button to the container
+-- f:AddChild(btn)
+-- @class file
+-- @name AceGUI-3.0
+-- @release $Id: AceGUI-3.0.lua 1102 2013-10-25 14:15:23Z nevcairiel $
+local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 34
+local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
+
+if not AceGUI then return end -- No upgrade needed
+
+-- Lua APIs
+local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
+local select, pairs, next, type = select, pairs, next, type
+local error, assert, loadstring = error, assert, loadstring
+local setmetatable, rawget, rawset = setmetatable, rawget, rawset
+local math_max = math.max
+
+-- WoW APIs
+local UIParent = UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: geterrorhandler, LibStub
+
+--local con = LibStub("AceConsole-3.0",true)
+
+AceGUI.WidgetRegistry = AceGUI.WidgetRegistry or {}
+AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {}
+AceGUI.WidgetBase = AceGUI.WidgetBase or {}
+AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
+AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
+
+-- local upvalues
+local WidgetRegistry = AceGUI.WidgetRegistry
+local LayoutRegistry = AceGUI.LayoutRegistry
+local WidgetVersions = AceGUI.WidgetVersions
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function CreateDispatcher(argCount)
+ local code = [[
+ local xpcall, eh = ...
+ local method, ARGS
+ local function call() return method(ARGS) end
+
+ local function dispatch(func, ...)
+ method = func
+ if not method then return end
+ ARGS = ...
+ return xpcall(call, eh)
+ end
+
+ return dispatch
+ ]]
+
+ local ARGS = {}
+ for i = 1, argCount do ARGS[i] = "arg"..i end
+ code = code:gsub("ARGS", tconcat(ARGS, ", "))
+ return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
+end
+
+local Dispatchers = setmetatable({}, {__index=function(self, argCount)
+ local dispatcher = CreateDispatcher(argCount)
+ rawset(self, argCount, dispatcher)
+ return dispatcher
+end})
+Dispatchers[0] = function(func)
+ return xpcall(func, errorhandler)
+end
+
+local function safecall(func, ...)
+ return Dispatchers[select("#", ...)](func, ...)
+end
+
+-- Recycling functions
+local newWidget, delWidget
+do
+ -- Version Upgrade in Minor 29
+ -- Internal Storage of the objects changed, from an array table
+ -- to a hash table, and additionally we introduced versioning on
+ -- the widgets which would discard all widgets from a pre-29 version
+ -- anyway, so we just clear the storage now, and don't try to
+ -- convert the storage tables to the new format.
+ -- This should generally not cause *many* widgets to end up in trash,
+ -- since once dialogs are opened, all addons should be loaded already
+ -- and AceGUI should be on the latest version available on the users
+ -- setup.
+ -- -- nevcairiel - Nov 2nd, 2009
+ if oldminor and oldminor < 29 and AceGUI.objPools then
+ AceGUI.objPools = nil
+ end
+
+ AceGUI.objPools = AceGUI.objPools or {}
+ local objPools = AceGUI.objPools
+ --Returns a new instance, if none are available either returns a new table or calls the given contructor
+ function newWidget(type)
+ if not WidgetRegistry[type] then
+ error("Attempt to instantiate unknown widget type", 2)
+ end
+
+ if not objPools[type] then
+ objPools[type] = {}
+ end
+
+ local newObj = next(objPools[type])
+ if not newObj then
+ newObj = WidgetRegistry[type]()
+ newObj.AceGUIWidgetVersion = WidgetVersions[type]
+ else
+ objPools[type][newObj] = nil
+ -- if the widget is older then the latest, don't even try to reuse it
+ -- just forget about it, and grab a new one.
+ if not newObj.AceGUIWidgetVersion or newObj.AceGUIWidgetVersion < WidgetVersions[type] then
+ return newWidget(type)
+ end
+ end
+ return newObj
+ end
+ -- Releases an instance to the Pool
+ function delWidget(obj,type)
+ if not objPools[type] then
+ objPools[type] = {}
+ end
+ if objPools[type][obj] then
+ error("Attempt to Release Widget that is already released", 2)
+ end
+ objPools[type][obj] = true
+ end
+end
+
+
+-------------------
+-- API Functions --
+-------------------
+
+-- Gets a widget Object
+
+--- Create a new Widget of the given type.
+-- This function will instantiate a new widget (or use one from the widget pool), and call the
+-- OnAcquire function on it, before returning.
+-- @param type The type of the widget.
+-- @return The newly created widget.
+function AceGUI:Create(type)
+ if WidgetRegistry[type] then
+ local widget = newWidget(type)
+
+ if rawget(widget, "Acquire") then
+ widget.OnAcquire = widget.Acquire
+ widget.Acquire = nil
+ elseif rawget(widget, "Aquire") then
+ widget.OnAcquire = widget.Aquire
+ widget.Aquire = nil
+ end
+
+ if rawget(widget, "Release") then
+ widget.OnRelease = rawget(widget, "Release")
+ widget.Release = nil
+ end
+
+ if widget.OnAcquire then
+ widget:OnAcquire()
+ else
+ error(("Widget type %s doesn't supply an OnAcquire Function"):format(type))
+ end
+ -- Set the default Layout ("List")
+ safecall(widget.SetLayout, widget, "List")
+ safecall(widget.ResumeLayout, widget)
+ return widget
+ end
+end
+
+--- Releases a widget Object.
+-- This function calls OnRelease on the widget and places it back in the widget pool.
+-- Any data on the widget is being erased, and the widget will be hidden.\\
+-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
+-- @param widget The widget to release
+function AceGUI:Release(widget)
+ safecall(widget.PauseLayout, widget)
+ widget:Fire("OnRelease")
+ safecall(widget.ReleaseChildren, widget)
+
+ if widget.OnRelease then
+ widget:OnRelease()
+-- else
+-- error(("Widget type %s doesn't supply an OnRelease Function"):format(widget.type))
+ end
+ for k in pairs(widget.userdata) do
+ widget.userdata[k] = nil
+ end
+ for k in pairs(widget.events) do
+ widget.events[k] = nil
+ end
+ widget.width = nil
+ widget.relWidth = nil
+ widget.height = nil
+ widget.relHeight = nil
+ widget.noAutoHeight = nil
+ widget.frame:ClearAllPoints()
+ widget.frame:Hide()
+ widget.frame:SetParent(UIParent)
+ widget.frame.width = nil
+ widget.frame.height = nil
+ if widget.content then
+ widget.content.width = nil
+ widget.content.height = nil
+ end
+ delWidget(widget, widget.type)
+end
+
+-----------
+-- Focus --
+-----------
+
+
+--- Called when a widget has taken focus.
+-- e.g. Dropdowns opening, Editboxes gaining kb focus
+-- @param widget The widget that should be focused
+function AceGUI:SetFocus(widget)
+ if self.FocusedWidget and self.FocusedWidget ~= widget then
+ safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
+ end
+ self.FocusedWidget = widget
+end
+
+
+--- Called when something has happened that could cause widgets with focus to drop it
+-- e.g. titlebar of a frame being clicked
+function AceGUI:ClearFocus()
+ if self.FocusedWidget then
+ safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
+ self.FocusedWidget = nil
+ end
+end
+
+-------------
+-- Widgets --
+-------------
+--[[
+ Widgets must provide the following functions
+ OnAcquire() - Called when the object is acquired, should set everything to a default hidden state
+
+ And the following members
+ frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
+ type - the type of the object, same as the name given to :RegisterWidget()
+
+ Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
+ It will be cleared automatically when a widget is released
+ Placing values directly into a widget object should be avoided
+
+ If the Widget can act as a container for other Widgets the following
+ content - frame or derivitive that children will be anchored to
+
+ The Widget can supply the following Optional Members
+ :OnRelease() - Called when the object is Released, should remove any additional anchors and clear any data
+ :OnWidthSet(width) - Called when the width of the widget is changed
+ :OnHeightSet(height) - Called when the height of the widget is changed
+ Widgets should not use the OnSizeChanged events of thier frame or content members, use these methods instead
+ AceGUI already sets a handler to the event
+ :LayoutFinished(width, height) - called after a layout has finished, the width and height will be the width and height of the
+ area used for controls. These can be nil if the layout used the existing size to layout the controls.
+
+]]
+
+--------------------------
+-- Widget Base Template --
+--------------------------
+do
+ local WidgetBase = AceGUI.WidgetBase
+
+ WidgetBase.SetParent = function(self, parent)
+ local frame = self.frame
+ frame:SetParent(nil)
+ frame:SetParent(parent.content)
+ self.parent = parent
+ end
+
+ WidgetBase.SetCallback = function(self, name, func)
+ if type(func) == "function" then
+ self.events[name] = func
+ end
+ end
+
+ WidgetBase.Fire = function(self, name, ...)
+ if self.events[name] then
+ local success, ret = safecall(self.events[name], self, name, ...)
+ if success then
+ return ret
+ end
+ end
+ end
+
+ WidgetBase.SetWidth = function(self, width)
+ self.frame:SetWidth(width)
+ self.frame.width = width
+ if self.OnWidthSet then
+ self:OnWidthSet(width)
+ end
+ end
+
+ WidgetBase.SetRelativeWidth = function(self, width)
+ if width <= 0 or width > 1 then
+ error(":SetRelativeWidth(width): Invalid relative width.", 2)
+ end
+ self.relWidth = width
+ self.width = "relative"
+ end
+
+ WidgetBase.SetHeight = function(self, height)
+ self.frame:SetHeight(height)
+ self.frame.height = height
+ if self.OnHeightSet then
+ self:OnHeightSet(height)
+ end
+ end
+
+ --[[ WidgetBase.SetRelativeHeight = function(self, height)
+ if height <= 0 or height > 1 then
+ error(":SetRelativeHeight(height): Invalid relative height.", 2)
+ end
+ self.relHeight = height
+ self.height = "relative"
+ end ]]
+
+ WidgetBase.IsVisible = function(self)
+ return self.frame:IsVisible()
+ end
+
+ WidgetBase.IsShown= function(self)
+ return self.frame:IsShown()
+ end
+
+ WidgetBase.Release = function(self)
+ AceGUI:Release(self)
+ end
+
+ WidgetBase.SetPoint = function(self, ...)
+ return self.frame:SetPoint(...)
+ end
+
+ WidgetBase.ClearAllPoints = function(self)
+ return self.frame:ClearAllPoints()
+ end
+
+ WidgetBase.GetNumPoints = function(self)
+ return self.frame:GetNumPoints()
+ end
+
+ WidgetBase.GetPoint = function(self, ...)
+ return self.frame:GetPoint(...)
+ end
+
+ WidgetBase.GetUserDataTable = function(self)
+ return self.userdata
+ end
+
+ WidgetBase.SetUserData = function(self, key, value)
+ self.userdata[key] = value
+ end
+
+ WidgetBase.GetUserData = function(self, key)
+ return self.userdata[key]
+ end
+
+ WidgetBase.IsFullHeight = function(self)
+ return self.height == "fill"
+ end
+
+ WidgetBase.SetFullHeight = function(self, isFull)
+ if isFull then
+ self.height = "fill"
+ else
+ self.height = nil
+ end
+ end
+
+ WidgetBase.IsFullWidth = function(self)
+ return self.width == "fill"
+ end
+
+ WidgetBase.SetFullWidth = function(self, isFull)
+ if isFull then
+ self.width = "fill"
+ else
+ self.width = nil
+ end
+ end
+
+-- local function LayoutOnUpdate(this)
+-- this:SetScript("OnUpdate",nil)
+-- this.obj:PerformLayout()
+-- end
+
+ local WidgetContainerBase = AceGUI.WidgetContainerBase
+
+ WidgetContainerBase.PauseLayout = function(self)
+ self.LayoutPaused = true
+ end
+
+ WidgetContainerBase.ResumeLayout = function(self)
+ self.LayoutPaused = nil
+ end
+
+ WidgetContainerBase.PerformLayout = function(self)
+ if self.LayoutPaused then
+ return
+ end
+ safecall(self.LayoutFunc, self.content, self.children)
+ end
+
+ --call this function to layout, makes sure layed out objects get a frame to get sizes etc
+ WidgetContainerBase.DoLayout = function(self)
+ self:PerformLayout()
+-- if not self.parent then
+-- self.frame:SetScript("OnUpdate", LayoutOnUpdate)
+-- end
+ end
+
+ WidgetContainerBase.AddChild = function(self, child, beforeWidget)
+ if beforeWidget then
+ local siblingIndex = 1
+ for _, widget in pairs(self.children) do
+ if widget == beforeWidget then
+ break
+ end
+ siblingIndex = siblingIndex + 1
+ end
+ tinsert(self.children, siblingIndex, child)
+ else
+ tinsert(self.children, child)
+ end
+ child:SetParent(self)
+ child.frame:Show()
+ self:DoLayout()
+ end
+
+ WidgetContainerBase.AddChildren = function(self, ...)
+ for i = 1, select("#", ...) do
+ local child = select(i, ...)
+ tinsert(self.children, child)
+ child:SetParent(self)
+ child.frame:Show()
+ end
+ self:DoLayout()
+ end
+
+ WidgetContainerBase.ReleaseChildren = function(self)
+ local children = self.children
+ for i = 1,#children do
+ AceGUI:Release(children[i])
+ children[i] = nil
+ end
+ end
+
+ WidgetContainerBase.SetLayout = function(self, Layout)
+ self.LayoutFunc = AceGUI:GetLayout(Layout)
+ end
+
+ WidgetContainerBase.SetAutoAdjustHeight = function(self, adjust)
+ if adjust then
+ self.noAutoHeight = nil
+ else
+ self.noAutoHeight = true
+ end
+ end
+
+ local function FrameResize(this)
+ local self = this.obj
+ if this:GetWidth() and this:GetHeight() then
+ if self.OnWidthSet then
+ self:OnWidthSet(this:GetWidth())
+ end
+ if self.OnHeightSet then
+ self:OnHeightSet(this:GetHeight())
+ end
+ end
+ end
+
+ local function ContentResize(this)
+ if this:GetWidth() and this:GetHeight() then
+ this.width = this:GetWidth()
+ this.height = this:GetHeight()
+ this.obj:DoLayout()
+ end
+ end
+
+ setmetatable(WidgetContainerBase, {__index=WidgetBase})
+
+ --One of these function should be called on each Widget Instance as part of its creation process
+
+ --- Register a widget-class as a container for newly created widgets.
+ -- @param widget The widget class
+ function AceGUI:RegisterAsContainer(widget)
+ widget.children = {}
+ widget.userdata = {}
+ widget.events = {}
+ widget.base = WidgetContainerBase
+ widget.content.obj = widget
+ widget.frame.obj = widget
+ widget.content:SetScript("OnSizeChanged", ContentResize)
+ widget.frame:SetScript("OnSizeChanged", FrameResize)
+ setmetatable(widget, {__index = WidgetContainerBase})
+ widget:SetLayout("List")
+ return widget
+ end
+
+ --- Register a widget-class as a widget.
+ -- @param widget The widget class
+ function AceGUI:RegisterAsWidget(widget)
+ widget.userdata = {}
+ widget.events = {}
+ widget.base = WidgetBase
+ widget.frame.obj = widget
+ widget.frame:SetScript("OnSizeChanged", FrameResize)
+ setmetatable(widget, {__index = WidgetBase})
+ return widget
+ end
+end
+
+
+
+
+------------------
+-- Widget API --
+------------------
+
+--- Registers a widget Constructor, this function returns a new instance of the Widget
+-- @param Name The name of the widget
+-- @param Constructor The widget constructor function
+-- @param Version The version of the widget
+function AceGUI:RegisterWidgetType(Name, Constructor, Version)
+ assert(type(Constructor) == "function")
+ assert(type(Version) == "number")
+
+ local oldVersion = WidgetVersions[Name]
+ if oldVersion and oldVersion >= Version then return end
+
+ WidgetVersions[Name] = Version
+ WidgetRegistry[Name] = Constructor
+end
+
+--- Registers a Layout Function
+-- @param Name The name of the layout
+-- @param LayoutFunc Reference to the layout function
+function AceGUI:RegisterLayout(Name, LayoutFunc)
+ assert(type(LayoutFunc) == "function")
+ if type(Name) == "string" then
+ Name = Name:upper()
+ end
+ LayoutRegistry[Name] = LayoutFunc
+end
+
+--- Get a Layout Function from the registry
+-- @param Name The name of the layout
+function AceGUI:GetLayout(Name)
+ if type(Name) == "string" then
+ Name = Name:upper()
+ end
+ return LayoutRegistry[Name]
+end
+
+AceGUI.counts = AceGUI.counts or {}
+
+--- A type-based counter to count the number of widgets created.
+-- This is used by widgets that require a named frame, e.g. when a Blizzard
+-- Template requires it.
+-- @param type The widget type
+function AceGUI:GetNextWidgetNum(type)
+ if not self.counts[type] then
+ self.counts[type] = 0
+ end
+ self.counts[type] = self.counts[type] + 1
+ return self.counts[type]
+end
+
+--- Return the number of created widgets for this type.
+-- In contrast to GetNextWidgetNum, the number is not incremented.
+-- @param type The widget type
+function AceGUI:GetWidgetCount(type)
+ return self.counts[type] or 0
+end
+
+--- Return the version of the currently registered widget type.
+-- @param type The widget type
+function AceGUI:GetWidgetVersion(type)
+ return WidgetVersions[type]
+end
+
+-------------
+-- Layouts --
+-------------
+
+--[[
+ A Layout is a func that takes 2 parameters
+ content - the frame that widgets will be placed inside
+ children - a table containing the widgets to layout
+]]
+
+-- Very simple Layout, Children are stacked on top of each other down the left side
+AceGUI:RegisterLayout("List",
+ function(content, children)
+ local height = 0
+ local width = content.width or content:GetWidth() or 0
+ for i = 1, #children do
+ local child = children[i]
+
+ local frame = child.frame
+ frame:ClearAllPoints()
+ frame:Show()
+ if i == 1 then
+ frame:SetPoint("TOPLEFT", content)
+ else
+ frame:SetPoint("TOPLEFT", children[i-1].frame, "BOTTOMLEFT")
+ end
+
+ if child.width == "fill" then
+ child:SetWidth(width)
+ frame:SetPoint("RIGHT", content)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ elseif child.width == "relative" then
+ child:SetWidth(width * child.relWidth)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ end
+
+ height = height + (frame.height or frame:GetHeight() or 0)
+ end
+ safecall(content.obj.LayoutFinished, content.obj, nil, height)
+ end)
+
+-- A single control fills the whole content area
+AceGUI:RegisterLayout("Fill",
+ function(content, children)
+ if children[1] then
+ children[1]:SetWidth(content:GetWidth() or 0)
+ children[1]:SetHeight(content:GetHeight() or 0)
+ children[1].frame:SetAllPoints(content)
+ children[1].frame:Show()
+ safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
+ end
+ end)
+
+local layoutrecursionblock = nil
+local function safelayoutcall(object, func, ...)
+ layoutrecursionblock = true
+ object[func](object, ...)
+ layoutrecursionblock = nil
+end
+
+AceGUI:RegisterLayout("Flow",
+ function(content, children)
+ if layoutrecursionblock then return end
+ --used height so far
+ local height = 0
+ --width used in the current row
+ local usedwidth = 0
+ --height of the current row
+ local rowheight = 0
+ local rowoffset = 0
+ local lastrowoffset
+
+ local width = content.width or content:GetWidth() or 0
+
+ --control at the start of the row
+ local rowstart
+ local rowstartoffset
+ local lastrowstart
+ local isfullheight
+
+ local frameoffset
+ local lastframeoffset
+ local oversize
+ for i = 1, #children do
+ local child = children[i]
+ oversize = nil
+ local frame = child.frame
+ local frameheight = frame.height or frame:GetHeight() or 0
+ local framewidth = frame.width or frame:GetWidth() or 0
+ lastframeoffset = frameoffset
+ -- HACK: Why did we set a frameoffset of (frameheight / 2) ?
+ -- That was moving all widgets half the widgets size down, is that intended?
+ -- Actually, it seems to be neccessary for many cases, we'll leave it in for now.
+ -- If widgets seem to anchor weirdly with this, provide a valid alignoffset for them.
+ -- TODO: Investigate moar!
+ frameoffset = child.alignoffset or (frameheight / 2)
+
+ if child.width == "relative" then
+ framewidth = width * child.relWidth
+ end
+
+ frame:Show()
+ frame:ClearAllPoints()
+ if i == 1 then
+ -- anchor the first control to the top left
+ frame:SetPoint("TOPLEFT", content)
+ rowheight = frameheight
+ rowoffset = frameoffset
+ rowstart = frame
+ rowstartoffset = frameoffset
+ usedwidth = framewidth
+ if usedwidth > width then
+ oversize = true
+ end
+ else
+ -- if there isn't available width for the control start a new row
+ -- if a control is "fill" it will be on a row of its own full width
+ if usedwidth == 0 or ((framewidth) + usedwidth > width) or child.width == "fill" then
+ if isfullheight then
+ -- a previous row has already filled the entire height, there's nothing we can usefully do anymore
+ -- (maybe error/warn about this?)
+ break
+ end
+ --anchor the previous row, we will now know its height and offset
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3))
+ height = height + rowheight + 3
+ --save this as the rowstart so we can anchor it after the row is complete and we have the max height and offset of controls in it
+ rowstart = frame
+ rowstartoffset = frameoffset
+ rowheight = frameheight
+ rowoffset = frameoffset
+ usedwidth = framewidth
+ if usedwidth > width then
+ oversize = true
+ end
+ -- put the control on the current row, adding it to the width and checking if the height needs to be increased
+ else
+ --handles cases where the new height is higher than either control because of the offsets
+ --math.max(rowheight-rowoffset+frameoffset, frameheight-frameoffset+rowoffset)
+
+ --offset is always the larger of the two offsets
+ rowoffset = math_max(rowoffset, frameoffset)
+ rowheight = math_max(rowheight, rowoffset + (frameheight / 2))
+
+ frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT", 0, frameoffset - lastframeoffset)
+ usedwidth = framewidth + usedwidth
+ end
+ end
+
+ if child.width == "fill" then
+ safelayoutcall(child, "SetWidth", width)
+ frame:SetPoint("RIGHT", content)
+
+ usedwidth = 0
+ rowstart = frame
+ rowstartoffset = frameoffset
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ rowheight = frame.height or frame:GetHeight() or 0
+ rowoffset = child.alignoffset or (rowheight / 2)
+ rowstartoffset = rowoffset
+ elseif child.width == "relative" then
+ safelayoutcall(child, "SetWidth", width * child.relWidth)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ elseif oversize then
+ if width > 1 then
+ frame:SetPoint("RIGHT", content)
+ end
+ end
+
+ if child.height == "fill" then
+ frame:SetPoint("BOTTOM", content)
+ isfullheight = true
+ end
+ end
+
+ --anchor the last row, if its full height needs a special case since its height has just been changed by the anchor
+ if isfullheight then
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -height)
+ elseif rowstart then
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3))
+ end
+
+ height = height + rowheight + 3
+ safecall(content.obj.LayoutFinished, content.obj, nil, height)
+ end)
diff --git a/libs/AceGUI-3.0/AceGUI-3.0.xml b/libs/AceGUI-3.0/AceGUI-3.0.xml
new file mode 100644
index 0000000..b515077
--- /dev/null
+++ b/libs/AceGUI-3.0/AceGUI-3.0.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua
new file mode 100644
index 0000000..9a48f8b
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua
@@ -0,0 +1,138 @@
+--[[-----------------------------------------------------------------------------
+BlizOptionsGroup Container
+Simple container widget for the integration of AceGUI into the Blizzard Interface Options
+-------------------------------------------------------------------------------]]
+local Type, Version = "BlizOptionsGroup", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame = CreateFrame
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+
+local function OnShow(frame)
+ frame.obj:Fire("OnShow")
+end
+
+local function OnHide(frame)
+ frame.obj:Fire("OnHide")
+end
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+local function okay(frame)
+ frame.obj:Fire("okay")
+end
+
+local function cancel(frame)
+ frame.obj:Fire("cancel")
+end
+
+local function default(frame)
+ frame.obj:Fire("default")
+end
+
+local function refresh(frame)
+ frame.obj:Fire("refresh")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetName()
+ self:SetTitle()
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 63
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 26
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetName"] = function(self, name, parent)
+ self.frame.name = name
+ self.frame.parent = parent
+ end,
+
+ ["SetTitle"] = function(self, title)
+ local content = self.content
+ content:ClearAllPoints()
+ if not title or title == "" then
+ content:SetPoint("TOPLEFT", 10, -10)
+ self.label:SetText("")
+ else
+ content:SetPoint("TOPLEFT", 10, -40)
+ self.label:SetText(title)
+ end
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame")
+ frame:Hide()
+
+ -- support functions for the Blizzard Interface Options
+ frame.okay = okay
+ frame.cancel = cancel
+ frame.default = default
+ frame.refresh = refresh
+
+ frame:SetScript("OnHide", OnHide)
+ frame:SetScript("OnShow", OnShow)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
+ label:SetPoint("TOPLEFT", 10, -15)
+ label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
+ label:SetJustifyH("LEFT")
+ label:SetJustifyV("TOP")
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ label = label,
+ frame = frame,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua
new file mode 100644
index 0000000..b0f81b7
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua
@@ -0,0 +1,157 @@
+--[[-----------------------------------------------------------------------------
+DropdownGroup Container
+Container controlled by a dropdown on the top.
+-------------------------------------------------------------------------------]]
+local Type, Version = "DropdownGroup", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local assert, pairs, type = assert, pairs, type
+
+-- WoW APIs
+local CreateFrame = CreateFrame
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function SelectedGroup(self, event, value)
+ local group = self.parentgroup
+ local status = group.status or group.localstatus
+ status.selected = value
+ self.parentgroup:Fire("OnGroupSelected", value)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.dropdown:SetText("")
+ self:SetDropdownWidth(200)
+ self:SetTitle("")
+ end,
+
+ ["OnRelease"] = function(self)
+ self.dropdown.list = nil
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ end,
+
+ ["SetTitle"] = function(self, title)
+ self.titletext:SetText(title)
+ self.dropdown.frame:ClearAllPoints()
+ if title and title ~= "" then
+ self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0)
+ else
+ self.dropdown.frame:SetPoint("TOPLEFT", -1, 0)
+ end
+ end,
+
+ ["SetGroupList"] = function(self,list,order)
+ self.dropdown:SetList(list,order)
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ end,
+
+ ["SetGroup"] = function(self,group)
+ self.dropdown:SetValue(group)
+ local status = self.status or self.localstatus
+ status.selected = group
+ self:Fire("OnGroupSelected", group)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 26
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 63
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ self:SetHeight((height or 0) + 63)
+ end,
+
+ ["SetDropdownWidth"] = function(self, width)
+ self.dropdown:SetWidth(width)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame")
+ frame:SetHeight(100)
+ frame:SetWidth(100)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 4, -5)
+ titletext:SetPoint("TOPRIGHT", -4, -5)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+
+ local dropdown = AceGUI:Create("Dropdown")
+ dropdown.frame:SetParent(frame)
+ dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
+ dropdown:SetCallback("OnValueChanged", SelectedGroup)
+ dropdown.frame:SetPoint("TOPLEFT", -1, 0)
+ dropdown.frame:Show()
+ dropdown:SetLabel("")
+
+ local border = CreateFrame("Frame", nil, frame)
+ border:SetPoint("TOPLEFT", 0, -26)
+ border:SetPoint("BOTTOMRIGHT", 0, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1,0.1,0.1,0.5)
+ border:SetBackdropBorderColor(0.4,0.4,0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ localstatus = {},
+ titletext = titletext,
+ dropdown = dropdown,
+ border = border,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ dropdown.parentgroup = widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua
new file mode 100644
index 0000000..80fd582
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua
@@ -0,0 +1,316 @@
+--[[-----------------------------------------------------------------------------
+Frame Container
+-------------------------------------------------------------------------------]]
+local Type, Version = "Frame", 26
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+local wipe = table.wipe
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: CLOSE
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Button_OnClick(frame)
+ PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
+ frame.obj:Hide()
+end
+
+local function Frame_OnShow(frame)
+ frame.obj:Fire("OnShow")
+end
+
+local function Frame_OnClose(frame)
+ frame.obj:Fire("OnClose")
+end
+
+local function Frame_OnMouseDown(frame)
+ AceGUI:ClearFocus()
+end
+
+local function Title_OnMouseDown(frame)
+ frame:GetParent():StartMoving()
+ AceGUI:ClearFocus()
+end
+
+local function MoverSizer_OnMouseUp(mover)
+ local frame = mover:GetParent()
+ frame:StopMovingOrSizing()
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.width = frame:GetWidth()
+ status.height = frame:GetHeight()
+ status.top = frame:GetTop()
+ status.left = frame:GetLeft()
+end
+
+local function SizerSE_OnMouseDown(frame)
+ frame:GetParent():StartSizing("BOTTOMRIGHT")
+ AceGUI:ClearFocus()
+end
+
+local function SizerS_OnMouseDown(frame)
+ frame:GetParent():StartSizing("BOTTOM")
+ AceGUI:ClearFocus()
+end
+
+local function SizerE_OnMouseDown(frame)
+ frame:GetParent():StartSizing("RIGHT")
+ AceGUI:ClearFocus()
+end
+
+local function StatusBar_OnEnter(frame)
+ frame.obj:Fire("OnEnterStatusBar")
+end
+
+local function StatusBar_OnLeave(frame)
+ frame.obj:Fire("OnLeaveStatusBar")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.frame:SetParent(UIParent)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ self:SetTitle()
+ self:SetStatusText()
+ self:ApplyStatus()
+ self:Show()
+ self:EnableResize(true)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ wipe(self.localstatus)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 34
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 57
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetTitle"] = function(self, title)
+ self.titletext:SetText(title)
+ self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
+ end,
+
+ ["SetStatusText"] = function(self, text)
+ self.statustext:SetText(text)
+ end,
+
+ ["Hide"] = function(self)
+ self.frame:Hide()
+ end,
+
+ ["Show"] = function(self)
+ self.frame:Show()
+ end,
+
+ ["EnableResize"] = function(self, state)
+ local func = state and "Show" or "Hide"
+ self.sizer_se[func](self.sizer_se)
+ self.sizer_s[func](self.sizer_s)
+ self.sizer_e[func](self.sizer_e)
+ end,
+
+ -- called to set an external table to store status in
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ self:ApplyStatus()
+ end,
+
+ ["ApplyStatus"] = function(self)
+ local status = self.status or self.localstatus
+ local frame = self.frame
+ self:SetWidth(status.width or 700)
+ self:SetHeight(status.height or 500)
+ frame:ClearAllPoints()
+ if status.top and status.left then
+ frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
+ frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
+ else
+ frame:SetPoint("CENTER")
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local FrameBackdrop = {
+ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
+ edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
+ tile = true, tileSize = 32, edgeSize = 32,
+ insets = { left = 8, right = 8, top = 8, bottom = 8 }
+}
+
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetMovable(true)
+ frame:SetResizable(true)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetBackdrop(FrameBackdrop)
+ frame:SetBackdropColor(0, 0, 0, 1)
+ frame:SetMinResize(400, 200)
+ frame:SetToplevel(true)
+ frame:SetScript("OnShow", Frame_OnShow)
+ frame:SetScript("OnHide", Frame_OnClose)
+ frame:SetScript("OnMouseDown", Frame_OnMouseDown)
+
+ local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
+ closebutton:SetScript("OnClick", Button_OnClick)
+ closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
+ closebutton:SetHeight(20)
+ closebutton:SetWidth(100)
+ closebutton:SetText(CLOSE)
+
+ local statusbg = CreateFrame("Button", nil, frame)
+ statusbg:SetPoint("BOTTOMLEFT", 15, 15)
+ statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
+ statusbg:SetHeight(24)
+ statusbg:SetBackdrop(PaneBackdrop)
+ statusbg:SetBackdropColor(0.1,0.1,0.1)
+ statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
+ statusbg:SetScript("OnEnter", StatusBar_OnEnter)
+ statusbg:SetScript("OnLeave", StatusBar_OnLeave)
+
+ local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ statustext:SetPoint("TOPLEFT", 7, -2)
+ statustext:SetPoint("BOTTOMRIGHT", -7, 2)
+ statustext:SetHeight(20)
+ statustext:SetJustifyH("LEFT")
+ statustext:SetText("")
+
+ local titlebg = frame:CreateTexture(nil, "OVERLAY")
+ titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
+ titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
+ titlebg:SetPoint("TOP", 0, 12)
+ titlebg:SetWidth(100)
+ titlebg:SetHeight(40)
+
+ local title = CreateFrame("Frame", nil, frame)
+ title:EnableMouse(true)
+ title:SetScript("OnMouseDown", Title_OnMouseDown)
+ title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+ title:SetAllPoints(titlebg)
+
+ local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
+
+ local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
+ titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
+ titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
+ titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
+ titlebg_l:SetWidth(30)
+ titlebg_l:SetHeight(40)
+
+ local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
+ titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
+ titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
+ titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
+ titlebg_r:SetWidth(30)
+ titlebg_r:SetHeight(40)
+
+ local sizer_se = CreateFrame("Frame", nil, frame)
+ sizer_se:SetPoint("BOTTOMRIGHT")
+ sizer_se:SetWidth(25)
+ sizer_se:SetHeight(25)
+ sizer_se:EnableMouse()
+ sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
+ sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ line1:SetWidth(14)
+ line1:SetHeight(14)
+ line1:SetPoint("BOTTOMRIGHT", -8, 8)
+ line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 14/17
+ line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ line2:SetWidth(8)
+ line2:SetHeight(8)
+ line2:SetPoint("BOTTOMRIGHT", -8, 8)
+ line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 8/17
+ line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local sizer_s = CreateFrame("Frame", nil, frame)
+ sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
+ sizer_s:SetPoint("BOTTOMLEFT")
+ sizer_s:SetHeight(25)
+ sizer_s:EnableMouse(true)
+ sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
+ sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ local sizer_e = CreateFrame("Frame", nil, frame)
+ sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
+ sizer_e:SetPoint("TOPRIGHT")
+ sizer_e:SetWidth(25)
+ sizer_e:EnableMouse(true)
+ sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
+ sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT", 17, -27)
+ content:SetPoint("BOTTOMRIGHT", -17, 40)
+
+ local widget = {
+ localstatus = {},
+ titletext = titletext,
+ statustext = statustext,
+ titlebg = titlebg,
+ sizer_se = sizer_se,
+ sizer_s = sizer_s,
+ sizer_e = sizer_e,
+ content = content,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ closebutton.obj, statusbg.obj = widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua
new file mode 100644
index 0000000..f3db7d6
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua
@@ -0,0 +1,103 @@
+--[[-----------------------------------------------------------------------------
+InlineGroup Container
+Simple container widget that creates a visible "box" with an optional title.
+-------------------------------------------------------------------------------]]
+local Type, Version = "InlineGroup", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(300)
+ self:SetHeight(100)
+ self:SetTitle("")
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetTitle"] = function(self,title)
+ self.titletext:SetText(title)
+ end,
+
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + 40)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 20
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 20
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 14, 0)
+ titletext:SetPoint("TOPRIGHT", -14, 0)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+
+ local border = CreateFrame("Frame", nil, frame)
+ border:SetPoint("TOPLEFT", 0, -17)
+ border:SetPoint("BOTTOMRIGHT", -1, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ content = content,
+ titletext = titletext,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua
new file mode 100644
index 0000000..9afb54b
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua
@@ -0,0 +1,204 @@
+--[[-----------------------------------------------------------------------------
+ScrollFrame Container
+Plain container that scrolls its content and doesn't grow in height.
+-------------------------------------------------------------------------------]]
+local Type, Version = "ScrollFrame", 24
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+local min, max, floor, abs = math.min, math.max, math.floor, math.abs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function FixScrollOnUpdate(frame)
+ frame:SetScript("OnUpdate", nil)
+ frame.obj:FixScroll()
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function ScrollFrame_OnMouseWheel(frame, value)
+ frame.obj:MoveScroll(value)
+end
+
+local function ScrollFrame_OnSizeChanged(frame)
+ frame:SetScript("OnUpdate", FixScrollOnUpdate)
+end
+
+local function ScrollBar_OnScrollValueChanged(frame, value)
+ frame.obj:SetScroll(value)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetScroll(0)
+ self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ self.scrollframe:SetPoint("BOTTOMRIGHT")
+ self.scrollbar:Hide()
+ self.scrollBarShown = nil
+ self.content.height, self.content.width = nil, nil
+ end,
+
+ ["SetScroll"] = function(self, value)
+ local status = self.status or self.localstatus
+ local viewheight = self.scrollframe:GetHeight()
+ local height = self.content:GetHeight()
+ local offset
+
+ if viewheight > height then
+ offset = 0
+ else
+ offset = floor((height - viewheight) / 1000.0 * value)
+ end
+ self.content:ClearAllPoints()
+ self.content:SetPoint("TOPLEFT", 0, offset)
+ self.content:SetPoint("TOPRIGHT", 0, offset)
+ status.offset = offset
+ status.scrollvalue = value
+ end,
+
+ ["MoveScroll"] = function(self, value)
+ local status = self.status or self.localstatus
+ local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
+
+ if self.scrollBarShown then
+ local diff = height - viewheight
+ local delta = 1
+ if value < 0 then
+ delta = -1
+ end
+ self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
+ end
+ end,
+
+ ["FixScroll"] = function(self)
+ if self.updateLock then return end
+ self.updateLock = true
+ local status = self.status or self.localstatus
+ local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
+ local offset = status.offset or 0
+ local curvalue = self.scrollbar:GetValue()
+ -- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
+ -- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
+ if viewheight < height + 2 then
+ if self.scrollBarShown then
+ self.scrollBarShown = nil
+ self.scrollbar:Hide()
+ self.scrollbar:SetValue(0)
+ self.scrollframe:SetPoint("BOTTOMRIGHT")
+ self:DoLayout()
+ end
+ else
+ if not self.scrollBarShown then
+ self.scrollBarShown = true
+ self.scrollbar:Show()
+ self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
+ self:DoLayout()
+ end
+ local value = (offset / (viewheight - height) * 1000)
+ if value > 1000 then value = 1000 end
+ self.scrollbar:SetValue(value)
+ self:SetScroll(value)
+ if value < 1000 then
+ self.content:ClearAllPoints()
+ self.content:SetPoint("TOPLEFT", 0, offset)
+ self.content:SetPoint("TOPRIGHT", 0, offset)
+ status.offset = offset
+ end
+ end
+ self.updateLock = nil
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ self.content:SetHeight(height or 0 + 20)
+ self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ if not status.scrollvalue then
+ status.scrollvalue = 0
+ end
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ content.width = width
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ content.height = height
+ end
+}
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local num = AceGUI:GetNextWidgetNum(Type)
+
+ local scrollframe = CreateFrame("ScrollFrame", nil, frame)
+ scrollframe:SetPoint("TOPLEFT")
+ scrollframe:SetPoint("BOTTOMRIGHT")
+ scrollframe:EnableMouseWheel(true)
+ scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
+ scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
+
+ local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
+ scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
+ scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
+ scrollbar:SetMinMaxValues(0, 1000)
+ scrollbar:SetValueStep(1)
+ scrollbar:SetValue(0)
+ scrollbar:SetWidth(16)
+ scrollbar:Hide()
+ -- set the script as the last step, so it doesn't fire yet
+ scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
+
+ local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
+ scrollbg:SetAllPoints(scrollbar)
+ scrollbg:SetColorTexture(0, 0, 0, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, scrollframe)
+ content:SetPoint("TOPLEFT")
+ content:SetPoint("TOPRIGHT")
+ content:SetHeight(400)
+ scrollframe:SetScrollChild(content)
+
+ local widget = {
+ localstatus = { scrollvalue = 0 },
+ scrollframe = scrollframe,
+ scrollbar = scrollbar,
+ content = content,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ scrollframe.obj, scrollbar.obj = widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua
new file mode 100644
index 0000000..57512c3
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua
@@ -0,0 +1,69 @@
+--[[-----------------------------------------------------------------------------
+SimpleGroup Container
+Simple container widget that just groups widgets.
+-------------------------------------------------------------------------------]]
+local Type, Version = "SimpleGroup", 20
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(300)
+ self:SetHeight(100)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight(height or 0)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ content:SetWidth(width)
+ content.width = width
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ content:SetHeight(height)
+ content.height = height
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT")
+ content:SetPoint("BOTTOMRIGHT")
+
+ local widget = {
+ frame = frame,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua
new file mode 100644
index 0000000..95544c5
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua
@@ -0,0 +1,350 @@
+--[[-----------------------------------------------------------------------------
+TabGroup Container
+Container that uses tabs on top to switch between groups.
+-------------------------------------------------------------------------------]]
+local Type, Version = "TabGroup", 36
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: PanelTemplates_TabResize, PanelTemplates_SetDisabledTabState, PanelTemplates_SelectTab, PanelTemplates_DeselectTab
+
+-- local upvalue storage used by BuildTabs
+local widths = {}
+local rowwidths = {}
+local rowends = {}
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function UpdateTabLook(frame)
+ if frame.disabled then
+ PanelTemplates_SetDisabledTabState(frame)
+ elseif frame.selected then
+ PanelTemplates_SelectTab(frame)
+ else
+ PanelTemplates_DeselectTab(frame)
+ end
+end
+
+local function Tab_SetText(frame, text)
+ frame:_SetText(text)
+ local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
+ PanelTemplates_TabResize(frame, 0, nil, nil, width, frame:GetFontString():GetStringWidth())
+end
+
+local function Tab_SetSelected(frame, selected)
+ frame.selected = selected
+ UpdateTabLook(frame)
+end
+
+local function Tab_SetDisabled(frame, disabled)
+ frame.disabled = disabled
+ UpdateTabLook(frame)
+end
+
+local function BuildTabsOnUpdate(frame)
+ local self = frame.obj
+ self:BuildTabs()
+ frame:SetScript("OnUpdate", nil)
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Tab_OnClick(frame)
+ if not (frame.selected or frame.disabled) then
+ PlaySound(841) -- SOUNDKIT.IG_CHARACTER_INFO_TAB
+ frame.obj:SelectTab(frame.value)
+ end
+end
+
+local function Tab_OnEnter(frame)
+ local self = frame.obj
+ self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
+end
+
+local function Tab_OnLeave(frame)
+ local self = frame.obj
+ self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
+end
+
+local function Tab_OnShow(frame)
+ _G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetTitle()
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ self.tablist = nil
+ for _, tab in pairs(self.tabs) do
+ tab:Hide()
+ end
+ end,
+
+ ["CreateTab"] = function(self, id)
+ local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
+ local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
+ tab.obj = self
+ tab.id = id
+
+ tab.text = _G[tabname .. "Text"]
+ tab.text:ClearAllPoints()
+ tab.text:SetPoint("LEFT", 14, -3)
+ tab.text:SetPoint("RIGHT", -12, -3)
+
+ tab:SetScript("OnClick", Tab_OnClick)
+ tab:SetScript("OnEnter", Tab_OnEnter)
+ tab:SetScript("OnLeave", Tab_OnLeave)
+ tab:SetScript("OnShow", Tab_OnShow)
+
+ tab._SetText = tab.SetText
+ tab.SetText = Tab_SetText
+ tab.SetSelected = Tab_SetSelected
+ tab.SetDisabled = Tab_SetDisabled
+
+ return tab
+ end,
+
+ ["SetTitle"] = function(self, text)
+ self.titletext:SetText(text or "")
+ if text and text ~= "" then
+ self.alignoffset = 25
+ else
+ self.alignoffset = 18
+ end
+ self:BuildTabs()
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ end,
+
+ ["SelectTab"] = function(self, value)
+ local status = self.status or self.localstatus
+ local found
+ for i, v in ipairs(self.tabs) do
+ if v.value == value then
+ v:SetSelected(true)
+ found = true
+ else
+ v:SetSelected(false)
+ end
+ end
+ status.selected = value
+ if found then
+ self:Fire("OnGroupSelected",value)
+ end
+ end,
+
+ ["SetTabs"] = function(self, tabs)
+ self.tablist = tabs
+ self:BuildTabs()
+ end,
+
+
+ ["BuildTabs"] = function(self)
+ local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
+ local status = self.status or self.localstatus
+ local tablist = self.tablist
+ local tabs = self.tabs
+
+ if not tablist then return end
+
+ local width = self.frame.width or self.frame:GetWidth() or 0
+
+ wipe(widths)
+ wipe(rowwidths)
+ wipe(rowends)
+
+ --Place Text into tabs and get thier initial width
+ for i, v in ipairs(tablist) do
+ local tab = tabs[i]
+ if not tab then
+ tab = self:CreateTab(i)
+ tabs[i] = tab
+ end
+
+ tab:Show()
+ tab:SetText(v.text)
+ tab:SetDisabled(v.disabled)
+ tab.value = v.value
+
+ widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
+ end
+
+ for i = (#tablist)+1, #tabs, 1 do
+ tabs[i]:Hide()
+ end
+
+ --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
+ local numtabs = #tablist
+ local numrows = 1
+ local usedwidth = 0
+
+ for i = 1, #tablist do
+ --If this is not the first tab of a row and there isn't room for it
+ if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
+ rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
+ rowends[numrows] = i - 1
+ numrows = numrows + 1
+ usedwidth = 0
+ end
+ usedwidth = usedwidth + widths[i]
+ end
+ rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
+ rowends[numrows] = #tablist
+
+ --Fix for single tabs being left on the last row, move a tab from the row above if applicable
+ if numrows > 1 then
+ --if the last row has only one tab
+ if rowends[numrows-1] == numtabs-1 then
+ --if there are more than 2 tabs in the 2nd last row
+ if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
+ --move 1 tab from the second last row to the last, if there is enough space
+ if (rowwidths[numrows] + widths[numtabs-1]) <= width then
+ rowends[numrows-1] = rowends[numrows-1] - 1
+ rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
+ rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
+ end
+ end
+ end
+ end
+
+ --anchor the rows as defined and resize tabs to fill thier row
+ local starttab = 1
+ for row, endtab in ipairs(rowends) do
+ local first = true
+ for tabno = starttab, endtab do
+ local tab = tabs[tabno]
+ tab:ClearAllPoints()
+ if first then
+ tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
+ first = false
+ else
+ tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
+ end
+ end
+
+ -- equal padding for each tab to fill the available width,
+ -- if the used space is above 75% already
+ -- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
+ -- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't
+ local padding = 0
+ if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then
+ padding = (width - rowwidths[row]) / (endtab - starttab+1)
+ end
+
+ for i = starttab, endtab do
+ PanelTemplates_TabResize(tabs[i], padding + 4, nil, nil, width, tabs[i]:GetFontString():GetStringWidth())
+ end
+ starttab = endtab + 1
+ end
+
+ self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
+ self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 60
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ self:BuildTabs(self)
+ self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - (self.borderoffset + 23)
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + (self.borderoffset + 23))
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame",nil,UIParent)
+ frame:SetHeight(100)
+ frame:SetWidth(100)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 14, 0)
+ titletext:SetPoint("TOPRIGHT", -14, 0)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+ titletext:SetText("")
+
+ local border = CreateFrame("Frame", nil, frame)
+ border:SetPoint("TOPLEFT", 1, -27)
+ border:SetPoint("BOTTOMRIGHT", -1, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -7)
+ content:SetPoint("BOTTOMRIGHT", -10, 7)
+
+ local widget = {
+ num = num,
+ frame = frame,
+ localstatus = {},
+ alignoffset = 18,
+ titletext = titletext,
+ border = border,
+ borderoffset = 27,
+ tabs = {},
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua
new file mode 100644
index 0000000..617d5dc
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua
@@ -0,0 +1,710 @@
+--[[-----------------------------------------------------------------------------
+TreeGroup Container
+Container that uses a tree control to switch between groups.
+-------------------------------------------------------------------------------]]
+local Type, Version = "TreeGroup", 40
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
+local math_min, math_max, floor = math.min, math.max, floor
+local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GameTooltip, FONT_COLOR_CODE_CLOSE
+
+-- Recycling functions
+local new, del
+do
+ local pool = setmetatable({},{__mode='k'})
+ function new()
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ return t
+ else
+ return {}
+ end
+ end
+ function del(t)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ pool[t] = true
+ end
+end
+
+local DEFAULT_TREE_WIDTH = 175
+local DEFAULT_TREE_SIZABLE = true
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function GetButtonUniqueValue(line)
+ local parent = line.parent
+ if parent and parent.value then
+ return GetButtonUniqueValue(parent).."\001"..line.value
+ else
+ return line.value
+ end
+end
+
+local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
+ local self = button.obj
+ local toggle = button.toggle
+ local frame = self.frame
+ local text = treeline.text or ""
+ local icon = treeline.icon
+ local iconCoords = treeline.iconCoords
+ local level = treeline.level
+ local value = treeline.value
+ local uniquevalue = treeline.uniquevalue
+ local disabled = treeline.disabled
+
+ button.treeline = treeline
+ button.value = value
+ button.uniquevalue = uniquevalue
+ if selected then
+ button:LockHighlight()
+ button.selected = true
+ else
+ button:UnlockHighlight()
+ button.selected = false
+ end
+ local normalTexture = button:GetNormalTexture()
+ local line = button.line
+ button.level = level
+ if ( level == 1 ) then
+ button:SetNormalFontObject("GameFontNormal")
+ button:SetHighlightFontObject("GameFontHighlight")
+ button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
+ else
+ button:SetNormalFontObject("GameFontHighlightSmall")
+ button:SetHighlightFontObject("GameFontHighlightSmall")
+ button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
+ end
+
+ if disabled then
+ button:EnableMouse(false)
+ button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE)
+ else
+ button.text:SetText(text)
+ button:EnableMouse(true)
+ end
+
+ if icon then
+ button.icon:SetTexture(icon)
+ button.icon:SetPoint("LEFT", 8 * level, (level == 1) and 0 or 1)
+ else
+ button.icon:SetTexture(nil)
+ end
+
+ if iconCoords then
+ button.icon:SetTexCoord(unpack(iconCoords))
+ else
+ button.icon:SetTexCoord(0, 1, 0, 1)
+ end
+
+ if canExpand then
+ if not isExpanded then
+ toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP")
+ toggle:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN")
+ else
+ toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
+ toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
+ end
+ toggle:Show()
+ else
+ toggle:Hide()
+ end
+end
+
+local function ShouldDisplayLevel(tree)
+ local result = false
+ for k, v in ipairs(tree) do
+ if v.children == nil and v.visible ~= false then
+ result = true
+ elseif v.children then
+ result = result or ShouldDisplayLevel(v.children)
+ end
+ if result then return result end
+ end
+ return false
+end
+
+local function addLine(self, v, tree, level, parent)
+ local line = new()
+ line.value = v.value
+ line.text = v.text
+ line.icon = v.icon
+ line.iconCoords = v.iconCoords
+ line.disabled = v.disabled
+ line.tree = tree
+ line.level = level
+ line.parent = parent
+ line.visible = v.visible
+ line.uniquevalue = GetButtonUniqueValue(line)
+ if v.children then
+ line.hasChildren = true
+ else
+ line.hasChildren = nil
+ end
+ self.lines[#self.lines+1] = line
+ return line
+end
+
+--fire an update after one frame to catch the treeframes height
+local function FirstFrameUpdate(frame)
+ local self = frame.obj
+ frame:SetScript("OnUpdate", nil)
+ self:RefreshTree()
+end
+
+local function BuildUniqueValue(...)
+ local n = select('#', ...)
+ if n == 1 then
+ return ...
+ else
+ return (...).."\001"..BuildUniqueValue(select(2,...))
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Expand_OnClick(frame)
+ local button = frame.button
+ local self = button.obj
+ local status = (self.status or self.localstatus).groups
+ status[button.uniquevalue] = not status[button.uniquevalue]
+ self:RefreshTree()
+end
+
+local function Button_OnClick(frame)
+ local self = frame.obj
+ self:Fire("OnClick", frame.uniquevalue, frame.selected)
+ if not frame.selected then
+ self:SetSelected(frame.uniquevalue)
+ frame.selected = true
+ frame:LockHighlight()
+ self:RefreshTree()
+ end
+ AceGUI:ClearFocus()
+end
+
+local function Button_OnDoubleClick(button)
+ local self = button.obj
+ local status = self.status or self.localstatus
+ local status = (self.status or self.localstatus).groups
+ status[button.uniquevalue] = not status[button.uniquevalue]
+ self:RefreshTree()
+end
+
+local function Button_OnEnter(frame)
+ local self = frame.obj
+ self:Fire("OnButtonEnter", frame.uniquevalue, frame)
+
+ if self.enabletooltips then
+ GameTooltip:SetOwner(frame, "ANCHOR_NONE")
+ GameTooltip:SetPoint("LEFT",frame,"RIGHT")
+ GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, true)
+
+ GameTooltip:Show()
+ end
+end
+
+local function Button_OnLeave(frame)
+ local self = frame.obj
+ self:Fire("OnButtonLeave", frame.uniquevalue, frame)
+
+ if self.enabletooltips then
+ GameTooltip:Hide()
+ end
+end
+
+local function OnScrollValueChanged(frame, value)
+ if frame.obj.noupdate then return end
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.scrollvalue = floor(value + 0.5)
+ self:RefreshTree()
+ AceGUI:ClearFocus()
+end
+
+local function Tree_OnSizeChanged(frame)
+ frame.obj:RefreshTree()
+end
+
+local function Tree_OnMouseWheel(frame, delta)
+ local self = frame.obj
+ if self.showscroll then
+ local scrollbar = self.scrollbar
+ local min, max = scrollbar:GetMinMaxValues()
+ local value = scrollbar:GetValue()
+ local newvalue = math_min(max,math_max(min,value - delta))
+ if value ~= newvalue then
+ scrollbar:SetValue(newvalue)
+ end
+ end
+end
+
+local function Dragger_OnLeave(frame)
+ frame:SetBackdropColor(1, 1, 1, 0)
+end
+
+local function Dragger_OnEnter(frame)
+ frame:SetBackdropColor(1, 1, 1, 0.8)
+end
+
+local function Dragger_OnMouseDown(frame)
+ local treeframe = frame:GetParent()
+ treeframe:StartSizing("RIGHT")
+end
+
+local function Dragger_OnMouseUp(frame)
+ local treeframe = frame:GetParent()
+ local self = treeframe.obj
+ local frame = treeframe:GetParent()
+ treeframe:StopMovingOrSizing()
+ --treeframe:SetScript("OnUpdate", nil)
+ treeframe:SetUserPlaced(false)
+ --Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize
+ treeframe:SetHeight(0)
+ treeframe:SetPoint("TOPLEFT", frame, "TOPLEFT",0,0)
+ treeframe:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0)
+
+ local status = self.status or self.localstatus
+ status.treewidth = treeframe:GetWidth()
+
+ treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
+ -- recalculate the content width
+ treeframe.obj:OnWidthSet(status.fullwidth)
+ -- update the layout of the content
+ treeframe.obj:DoLayout()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
+ self:EnableButtonTooltips(true)
+ self.frame:SetScript("OnUpdate", FirstFrameUpdate)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ for k, v in pairs(self.localstatus) do
+ if k == "groups" then
+ for k2 in pairs(v) do
+ v[k2] = nil
+ end
+ else
+ self.localstatus[k] = nil
+ end
+ end
+ self.localstatus.scrollvalue = 0
+ self.localstatus.treewidth = DEFAULT_TREE_WIDTH
+ self.localstatus.treesizable = DEFAULT_TREE_SIZABLE
+ end,
+
+ ["EnableButtonTooltips"] = function(self, enable)
+ self.enabletooltips = enable
+ end,
+
+ ["CreateButton"] = function(self)
+ local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
+ local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "OptionsListButtonTemplate")
+ button.obj = self
+
+ local icon = button:CreateTexture(nil, "OVERLAY")
+ icon:SetWidth(14)
+ icon:SetHeight(14)
+ button.icon = icon
+
+ button:SetScript("OnClick",Button_OnClick)
+ button:SetScript("OnDoubleClick", Button_OnDoubleClick)
+ button:SetScript("OnEnter",Button_OnEnter)
+ button:SetScript("OnLeave",Button_OnLeave)
+
+ button.toggle.button = button
+ button.toggle:SetScript("OnClick",Expand_OnClick)
+
+ button.text:SetHeight(14) -- Prevents text wrapping
+
+ return button
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ if not status.groups then
+ status.groups = {}
+ end
+ if not status.scrollvalue then
+ status.scrollvalue = 0
+ end
+ if not status.treewidth then
+ status.treewidth = DEFAULT_TREE_WIDTH
+ end
+ if status.treesizable == nil then
+ status.treesizable = DEFAULT_TREE_SIZABLE
+ end
+ self:SetTreeWidth(status.treewidth,status.treesizable)
+ self:RefreshTree()
+ end,
+
+ --sets the tree to be displayed
+ ["SetTree"] = function(self, tree, filter)
+ self.filter = filter
+ if tree then
+ assert(type(tree) == "table")
+ end
+ self.tree = tree
+ self:RefreshTree()
+ end,
+
+ ["BuildLevel"] = function(self, tree, level, parent)
+ local groups = (self.status or self.localstatus).groups
+ local hasChildren = self.hasChildren
+
+ for i, v in ipairs(tree) do
+ if v.children then
+ if not self.filter or ShouldDisplayLevel(v.children) then
+ local line = addLine(self, v, tree, level, parent)
+ if groups[line.uniquevalue] then
+ self:BuildLevel(v.children, level+1, line)
+ end
+ end
+ elseif v.visible ~= false or not self.filter then
+ addLine(self, v, tree, level, parent)
+ end
+ end
+ end,
+
+ ["RefreshTree"] = function(self,scrollToSelection)
+ local buttons = self.buttons
+ local lines = self.lines
+
+ for i, v in ipairs(buttons) do
+ v:Hide()
+ end
+ while lines[1] do
+ local t = tremove(lines)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ del(t)
+ end
+
+ if not self.tree then return end
+ --Build the list of visible entries from the tree and status tables
+ local status = self.status or self.localstatus
+ local groupstatus = status.groups
+ local tree = self.tree
+
+ local treeframe = self.treeframe
+
+ status.scrollToSelection = status.scrollToSelection or scrollToSelection -- needs to be cached in case the control hasn't been drawn yet (code bails out below)
+
+ self:BuildLevel(tree, 1)
+
+ local numlines = #lines
+
+ local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
+ if maxlines <= 0 then return end
+
+ local first, last
+
+ scrollToSelection = status.scrollToSelection
+ status.scrollToSelection = nil
+
+ if numlines <= maxlines then
+ --the whole tree fits in the frame
+ status.scrollvalue = 0
+ self:ShowScroll(false)
+ first, last = 1, numlines
+ else
+ self:ShowScroll(true)
+ --scrolling will be needed
+ self.noupdate = true
+ self.scrollbar:SetMinMaxValues(0, numlines - maxlines)
+ --check if we are scrolled down too far
+ if numlines - status.scrollvalue < maxlines then
+ status.scrollvalue = numlines - maxlines
+ end
+ self.noupdate = nil
+ first, last = status.scrollvalue+1, status.scrollvalue + maxlines
+ --show selection?
+ if scrollToSelection and status.selected then
+ local show
+ for i,line in ipairs(lines) do -- find the line number
+ if line.uniquevalue==status.selected then
+ show=i
+ end
+ end
+ if not show then
+ -- selection was deleted or something?
+ elseif show>=first and show<=last then
+ -- all good
+ else
+ -- scrolling needed!
+ if show 100 and status.treewidth > maxtreewidth then
+ self:SetTreeWidth(maxtreewidth, status.treesizable)
+ end
+ treeframe:SetMaxResize(maxtreewidth, 1600)
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 20
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetTreeWidth"] = function(self, treewidth, resizable)
+ if not resizable then
+ if type(treewidth) == 'number' then
+ resizable = false
+ elseif type(treewidth) == 'boolean' then
+ resizable = treewidth
+ treewidth = DEFAULT_TREE_WIDTH
+ else
+ resizable = false
+ treewidth = DEFAULT_TREE_WIDTH
+ end
+ end
+ self.treeframe:SetWidth(treewidth)
+ self.dragger:EnableMouse(resizable)
+
+ local status = self.status or self.localstatus
+ status.treewidth = treewidth
+ status.treesizable = resizable
+
+ -- recalculate the content width
+ if status.fullwidth then
+ self:OnWidthSet(status.fullwidth)
+ end
+ end,
+
+ ["GetTreeWidth"] = function(self)
+ local status = self.status or self.localstatus
+ return status.treewidth or DEFAULT_TREE_WIDTH
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + 20)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local DraggerBackdrop = {
+ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+ edgeFile = nil,
+ tile = true, tileSize = 16, edgeSize = 0,
+ insets = { left = 3, right = 3, top = 7, bottom = 7 }
+}
+
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame", nil, UIParent)
+
+ local treeframe = CreateFrame("Frame", nil, frame)
+ treeframe:SetPoint("TOPLEFT")
+ treeframe:SetPoint("BOTTOMLEFT")
+ treeframe:SetWidth(DEFAULT_TREE_WIDTH)
+ treeframe:EnableMouseWheel(true)
+ treeframe:SetBackdrop(PaneBackdrop)
+ treeframe:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ treeframe:SetBackdropBorderColor(0.4, 0.4, 0.4)
+ treeframe:SetResizable(true)
+ treeframe:SetMinResize(100, 1)
+ treeframe:SetMaxResize(400, 1600)
+ treeframe:SetScript("OnUpdate", FirstFrameUpdate)
+ treeframe:SetScript("OnSizeChanged", Tree_OnSizeChanged)
+ treeframe:SetScript("OnMouseWheel", Tree_OnMouseWheel)
+
+ local dragger = CreateFrame("Frame", nil, treeframe)
+ dragger:SetWidth(8)
+ dragger:SetPoint("TOP", treeframe, "TOPRIGHT")
+ dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT")
+ dragger:SetBackdrop(DraggerBackdrop)
+ dragger:SetBackdropColor(1, 1, 1, 0)
+ dragger:SetScript("OnEnter", Dragger_OnEnter)
+ dragger:SetScript("OnLeave", Dragger_OnLeave)
+ dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
+ dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
+
+ local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
+ scrollbar:SetScript("OnValueChanged", nil)
+ scrollbar:SetPoint("TOPRIGHT", -10, -26)
+ scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
+ scrollbar:SetMinMaxValues(0,0)
+ scrollbar:SetValueStep(1)
+ scrollbar:SetValue(0)
+ scrollbar:SetWidth(16)
+ scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
+
+ local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
+ scrollbg:SetAllPoints(scrollbar)
+ scrollbg:SetColorTexture(0,0,0,0.4)
+
+ local border = CreateFrame("Frame",nil,frame)
+ border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
+ border:SetPoint("BOTTOMRIGHT")
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ lines = {},
+ levels = {},
+ buttons = {},
+ hasChildren = {},
+ localstatus = { groups = {}, scrollvalue = 0 },
+ filter = false,
+ treeframe = treeframe,
+ dragger = dragger,
+ scrollbar = scrollbar,
+ border = border,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ treeframe.obj, dragger.obj, scrollbar.obj = widget, widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua b/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua
new file mode 100644
index 0000000..6825420
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua
@@ -0,0 +1,336 @@
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GameFontNormal
+
+----------------
+-- Main Frame --
+----------------
+--[[
+ Events :
+ OnClose
+
+]]
+do
+ local Type = "Window"
+ local Version = 6
+
+ local function frameOnShow(this)
+ this.obj:Fire("OnShow")
+ end
+
+ local function frameOnClose(this)
+ this.obj:Fire("OnClose")
+ end
+
+ local function closeOnClick(this)
+ PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
+ this.obj:Hide()
+ end
+
+ local function frameOnMouseDown(this)
+ AceGUI:ClearFocus()
+ end
+
+ local function titleOnMouseDown(this)
+ this:GetParent():StartMoving()
+ AceGUI:ClearFocus()
+ end
+
+ local function frameOnMouseUp(this)
+ local frame = this:GetParent()
+ frame:StopMovingOrSizing()
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.width = frame:GetWidth()
+ status.height = frame:GetHeight()
+ status.top = frame:GetTop()
+ status.left = frame:GetLeft()
+ end
+
+ local function sizerseOnMouseDown(this)
+ this:GetParent():StartSizing("BOTTOMRIGHT")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizersOnMouseDown(this)
+ this:GetParent():StartSizing("BOTTOM")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizereOnMouseDown(this)
+ this:GetParent():StartSizing("RIGHT")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizerOnMouseUp(this)
+ this:GetParent():StopMovingOrSizing()
+ end
+
+ local function SetTitle(self,title)
+ self.titletext:SetText(title)
+ end
+
+ local function SetStatusText(self,text)
+ -- self.statustext:SetText(text)
+ end
+
+ local function Hide(self)
+ self.frame:Hide()
+ end
+
+ local function Show(self)
+ self.frame:Show()
+ end
+
+ local function OnAcquire(self)
+ self.frame:SetParent(UIParent)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ self:ApplyStatus()
+ self:EnableResize(true)
+ self:Show()
+ end
+
+ local function OnRelease(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ end
+
+ -- called to set an external table to store status in
+ local function SetStatusTable(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ self:ApplyStatus()
+ end
+
+ local function ApplyStatus(self)
+ local status = self.status or self.localstatus
+ local frame = self.frame
+ self:SetWidth(status.width or 700)
+ self:SetHeight(status.height or 500)
+ if status.top and status.left then
+ frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
+ frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
+ else
+ frame:SetPoint("CENTER",UIParent,"CENTER")
+ end
+ end
+
+ local function OnWidthSet(self, width)
+ local content = self.content
+ local contentwidth = width - 34
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end
+
+
+ local function OnHeightSet(self, height)
+ local content = self.content
+ local contentheight = height - 57
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end
+
+ local function EnableResize(self, state)
+ local func = state and "Show" or "Hide"
+ self.sizer_se[func](self.sizer_se)
+ self.sizer_s[func](self.sizer_s)
+ self.sizer_e[func](self.sizer_e)
+ end
+
+ local function Constructor()
+ local frame = CreateFrame("Frame",nil,UIParent)
+ local self = {}
+ self.type = "Window"
+
+ self.Hide = Hide
+ self.Show = Show
+ self.SetTitle = SetTitle
+ self.OnRelease = OnRelease
+ self.OnAcquire = OnAcquire
+ self.SetStatusText = SetStatusText
+ self.SetStatusTable = SetStatusTable
+ self.ApplyStatus = ApplyStatus
+ self.OnWidthSet = OnWidthSet
+ self.OnHeightSet = OnHeightSet
+ self.EnableResize = EnableResize
+
+ self.localstatus = {}
+
+ self.frame = frame
+ frame.obj = self
+ frame:SetWidth(700)
+ frame:SetHeight(500)
+ frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
+ frame:EnableMouse()
+ frame:SetMovable(true)
+ frame:SetResizable(true)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetScript("OnMouseDown", frameOnMouseDown)
+
+ frame:SetScript("OnShow",frameOnShow)
+ frame:SetScript("OnHide",frameOnClose)
+ frame:SetMinResize(240,240)
+ frame:SetToplevel(true)
+
+ local titlebg = frame:CreateTexture(nil, "BACKGROUND")
+ titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
+ titlebg:SetPoint("TOPLEFT", 9, -6)
+ titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
+
+ local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
+ dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
+ dialogbg:SetPoint("TOPLEFT", 8, -24)
+ dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
+ dialogbg:SetVertexColor(0, 0, 0, .75)
+
+ local topleft = frame:CreateTexture(nil, "BORDER")
+ topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ topleft:SetWidth(64)
+ topleft:SetHeight(64)
+ topleft:SetPoint("TOPLEFT")
+ topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
+
+ local topright = frame:CreateTexture(nil, "BORDER")
+ topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ topright:SetWidth(64)
+ topright:SetHeight(64)
+ topright:SetPoint("TOPRIGHT")
+ topright:SetTexCoord(0.625, 0.75, 0, 1)
+
+ local top = frame:CreateTexture(nil, "BORDER")
+ top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ top:SetHeight(64)
+ top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
+ top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
+ top:SetTexCoord(0.25, 0.369140625, 0, 1)
+
+ local bottomleft = frame:CreateTexture(nil, "BORDER")
+ bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ bottomleft:SetWidth(64)
+ bottomleft:SetHeight(64)
+ bottomleft:SetPoint("BOTTOMLEFT")
+ bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
+
+ local bottomright = frame:CreateTexture(nil, "BORDER")
+ bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ bottomright:SetWidth(64)
+ bottomright:SetHeight(64)
+ bottomright:SetPoint("BOTTOMRIGHT")
+ bottomright:SetTexCoord(0.875, 1, 0, 1)
+
+ local bottom = frame:CreateTexture(nil, "BORDER")
+ bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ bottom:SetHeight(64)
+ bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
+ bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
+ bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
+
+ local left = frame:CreateTexture(nil, "BORDER")
+ left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ left:SetWidth(64)
+ left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
+ left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
+ left:SetTexCoord(0.001953125, 0.125, 0, 1)
+
+ local right = frame:CreateTexture(nil, "BORDER")
+ right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
+ right:SetWidth(64)
+ right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
+ right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
+ right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
+
+ local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
+ close:SetPoint("TOPRIGHT", 2, 1)
+ close:SetScript("OnClick", closeOnClick)
+ self.closebutton = close
+ close.obj = self
+
+ local titletext = frame:CreateFontString(nil, "ARTWORK")
+ titletext:SetFontObject(GameFontNormal)
+ titletext:SetPoint("TOPLEFT", 12, -8)
+ titletext:SetPoint("TOPRIGHT", -32, -8)
+ self.titletext = titletext
+
+ local title = CreateFrame("Button", nil, frame)
+ title:SetPoint("TOPLEFT", titlebg)
+ title:SetPoint("BOTTOMRIGHT", titlebg)
+ title:EnableMouse()
+ title:SetScript("OnMouseDown",titleOnMouseDown)
+ title:SetScript("OnMouseUp", frameOnMouseUp)
+ self.title = title
+
+ local sizer_se = CreateFrame("Frame",nil,frame)
+ sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
+ sizer_se:SetWidth(25)
+ sizer_se:SetHeight(25)
+ sizer_se:EnableMouse()
+ sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
+ sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_se = sizer_se
+
+ local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ self.line1 = line1
+ line1:SetWidth(14)
+ line1:SetHeight(14)
+ line1:SetPoint("BOTTOMRIGHT", -8, 8)
+ line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 14/17
+ line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ self.line2 = line2
+ line2:SetWidth(8)
+ line2:SetHeight(8)
+ line2:SetPoint("BOTTOMRIGHT", -8, 8)
+ line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 8/17
+ line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local sizer_s = CreateFrame("Frame",nil,frame)
+ sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
+ sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
+ sizer_s:SetHeight(25)
+ sizer_s:EnableMouse()
+ sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
+ sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_s = sizer_s
+
+ local sizer_e = CreateFrame("Frame",nil,frame)
+ sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
+ sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
+ sizer_e:SetWidth(25)
+ sizer_e:EnableMouse()
+ sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
+ sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_e = sizer_e
+
+ --Container Support
+ local content = CreateFrame("Frame",nil,frame)
+ self.content = content
+ content.obj = self
+ content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
+ content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
+
+ AceGUI:RegisterAsContainer(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(Type,Constructor,Version)
+end
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua
new file mode 100644
index 0000000..0a23be4
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua
@@ -0,0 +1,103 @@
+--[[-----------------------------------------------------------------------------
+Button Widget
+Graphical Button.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Button", 24
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local _G = _G
+local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Button_OnClick(frame, ...)
+ AceGUI:ClearFocus()
+ PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
+ frame.obj:Fire("OnClick", ...)
+end
+
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- restore default values
+ self:SetHeight(24)
+ self:SetWidth(200)
+ self:SetDisabled(false)
+ self:SetAutoWidth(false)
+ self:SetText()
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetText"] = function(self, text)
+ self.text:SetText(text)
+ if self.autoWidth then
+ self:SetWidth(self.text:GetStringWidth() + 30)
+ end
+ end,
+
+ ["SetAutoWidth"] = function(self, autoWidth)
+ self.autoWidth = autoWidth
+ if self.autoWidth then
+ self:SetWidth(self.text:GetStringWidth() + 30)
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ else
+ self.frame:Enable()
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnClick", Button_OnClick)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+
+ local text = frame:GetFontString()
+ text:ClearAllPoints()
+ text:SetPoint("TOPLEFT", 15, -1)
+ text:SetPoint("BOTTOMRIGHT", -15, 1)
+ text:SetJustifyV("MIDDLE")
+
+ local widget = {
+ text = text,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua
new file mode 100644
index 0000000..b96ac59
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua
@@ -0,0 +1,295 @@
+--[[-----------------------------------------------------------------------------
+Checkbox Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "CheckBox", 23
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs = select, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: SetDesaturation, GameFontHighlight
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function AlignImage(self)
+ local img = self.image:GetTexture()
+ self.text:ClearAllPoints()
+ if not img then
+ self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
+ self.text:SetPoint("RIGHT")
+ else
+ self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
+ self.text:SetPoint("RIGHT")
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function CheckBox_OnMouseDown(frame)
+ local self = frame.obj
+ if not self.disabled then
+ if self.image:GetTexture() then
+ self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
+ else
+ self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1)
+ end
+ end
+ AceGUI:ClearFocus()
+end
+
+local function CheckBox_OnMouseUp(frame)
+ local self = frame.obj
+ if not self.disabled then
+ self:ToggleChecked()
+
+ if self.checked then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ else -- for both nil and false (tristate)
+ PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
+ end
+
+ self:Fire("OnValueChanged", self.checked)
+ AlignImage(self)
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetType()
+ self:SetValue(false)
+ self:SetTriState(nil)
+ -- height is calculated from the width and required space for the description
+ self:SetWidth(200)
+ self:SetImage()
+ self:SetDisabled(nil)
+ self:SetDescription(nil)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ if self.desc then
+ self.desc:SetWidth(width - 30)
+ if self.desc:GetText() and self.desc:GetText() ~= "" then
+ self:SetHeight(28 + self.desc:GetHeight())
+ end
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ self.text:SetTextColor(0.5, 0.5, 0.5)
+ SetDesaturation(self.check, true)
+ if self.desc then
+ self.desc:SetTextColor(0.5, 0.5, 0.5)
+ end
+ else
+ self.frame:Enable()
+ self.text:SetTextColor(1, 1, 1)
+ if self.tristate and self.checked == nil then
+ SetDesaturation(self.check, true)
+ else
+ SetDesaturation(self.check, false)
+ end
+ if self.desc then
+ self.desc:SetTextColor(1, 1, 1)
+ end
+ end
+ end,
+
+ ["SetValue"] = function(self,value)
+ local check = self.check
+ self.checked = value
+ if value then
+ SetDesaturation(self.check, false)
+ self.check:Show()
+ else
+ --Nil is the unknown tristate value
+ if self.tristate and value == nil then
+ SetDesaturation(self.check, true)
+ self.check:Show()
+ else
+ SetDesaturation(self.check, false)
+ self.check:Hide()
+ end
+ end
+ self:SetDisabled(self.disabled)
+ end,
+
+ ["GetValue"] = function(self)
+ return self.checked
+ end,
+
+ ["SetTriState"] = function(self, enabled)
+ self.tristate = enabled
+ self:SetValue(self:GetValue())
+ end,
+
+ ["SetType"] = function(self, type)
+ local checkbg = self.checkbg
+ local check = self.check
+ local highlight = self.highlight
+
+ local size
+ if type == "radio" then
+ size = 16
+ checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton")
+ checkbg:SetTexCoord(0, 0.25, 0, 1)
+ check:SetTexture("Interface\\Buttons\\UI-RadioButton")
+ check:SetTexCoord(0.25, 0.5, 0, 1)
+ check:SetBlendMode("ADD")
+ highlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
+ highlight:SetTexCoord(0.5, 0.75, 0, 1)
+ else
+ size = 24
+ checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
+ checkbg:SetTexCoord(0, 1, 0, 1)
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetTexCoord(0, 1, 0, 1)
+ check:SetBlendMode("BLEND")
+ highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
+ highlight:SetTexCoord(0, 1, 0, 1)
+ end
+ checkbg:SetHeight(size)
+ checkbg:SetWidth(size)
+ end,
+
+ ["ToggleChecked"] = function(self)
+ local value = self:GetValue()
+ if self.tristate then
+ --cycle in true, nil, false order
+ if value then
+ self:SetValue(nil)
+ elseif value == nil then
+ self:SetValue(false)
+ else
+ self:SetValue(true)
+ end
+ else
+ self:SetValue(not self:GetValue())
+ end
+ end,
+
+ ["SetLabel"] = function(self, label)
+ self.text:SetText(label)
+ end,
+
+ ["SetDescription"] = function(self, desc)
+ if desc then
+ if not self.desc then
+ local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
+ desc:ClearAllPoints()
+ desc:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
+ desc:SetWidth(self.frame.width - 30)
+ desc:SetJustifyH("LEFT")
+ desc:SetJustifyV("TOP")
+ self.desc = desc
+ end
+ self.desc:Show()
+ --self.text:SetFontObject(GameFontNormal)
+ self.desc:SetText(desc)
+ self:SetHeight(28 + self.desc:GetHeight())
+ else
+ if self.desc then
+ self.desc:SetText("")
+ self.desc:Hide()
+ end
+ --self.text:SetFontObject(GameFontHighlight)
+ self:SetHeight(24)
+ end
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ AlignImage(self)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnMouseDown", CheckBox_OnMouseDown)
+ frame:SetScript("OnMouseUp", CheckBox_OnMouseUp)
+
+ local checkbg = frame:CreateTexture(nil, "ARTWORK")
+ checkbg:SetWidth(24)
+ checkbg:SetHeight(24)
+ checkbg:SetPoint("TOPLEFT")
+ checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
+
+ local check = frame:CreateTexture(nil, "OVERLAY")
+ check:SetAllPoints(checkbg)
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+
+ local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ text:SetJustifyH("LEFT")
+ text:SetHeight(18)
+ text:SetPoint("LEFT", checkbg, "RIGHT")
+ text:SetPoint("RIGHT")
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(checkbg)
+
+ local image = frame:CreateTexture(nil, "OVERLAY")
+ image:SetHeight(16)
+ image:SetWidth(16)
+ image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0)
+
+ local widget = {
+ checkbg = checkbg,
+ check = check,
+ text = text,
+ highlight = highlight,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
new file mode 100644
index 0000000..05e2b57
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
@@ -0,0 +1,188 @@
+--[[-----------------------------------------------------------------------------
+ColorPicker Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "ColorPicker", 23
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function ColorCallback(self, r, g, b, a, isAlpha)
+ if not self.HasAlpha then
+ a = 1
+ end
+ self:SetColor(r, g, b, a)
+ if ColorPickerFrame:IsVisible() then
+ --colorpicker is still open
+ self:Fire("OnValueChanged", r, g, b, a)
+ else
+ --colorpicker is closed, color callback is first, ignore it,
+ --alpha callback is the final call after it closes so confirm now
+ if isAlpha then
+ self:Fire("OnValueConfirmed", r, g, b, a)
+ end
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function ColorSwatch_OnClick(frame)
+ HideUIPanel(ColorPickerFrame)
+ local self = frame.obj
+ if not self.disabled then
+ ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
+ ColorPickerFrame:SetClampedToScreen(true)
+
+ ColorPickerFrame.func = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = 1 - OpacitySliderFrame:GetValue()
+ ColorCallback(self, r, g, b, a)
+ end
+
+ ColorPickerFrame.hasOpacity = self.HasAlpha
+ ColorPickerFrame.opacityFunc = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = 1 - OpacitySliderFrame:GetValue()
+ ColorCallback(self, r, g, b, a, true)
+ end
+
+ local r, g, b, a = self.r, self.g, self.b, self.a
+ if self.HasAlpha then
+ ColorPickerFrame.opacity = 1 - (a or 0)
+ end
+ ColorPickerFrame:SetColorRGB(r, g, b)
+
+ ColorPickerFrame.cancelFunc = function()
+ ColorCallback(self, r, g, b, a, true)
+ end
+
+ ShowUIPanel(ColorPickerFrame)
+ end
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetHeight(24)
+ self:SetWidth(200)
+ self:SetHasAlpha(false)
+ self:SetColor(0, 0, 0, 1)
+ self:SetDisabled(nil)
+ self:SetLabel(nil)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetLabel"] = function(self, text)
+ self.text:SetText(text)
+ end,
+
+ ["SetColor"] = function(self, r, g, b, a)
+ self.r = r
+ self.g = g
+ self.b = b
+ self.a = a or 1
+ self.colorSwatch:SetVertexColor(r, g, b, a)
+ end,
+
+ ["SetHasAlpha"] = function(self, HasAlpha)
+ self.HasAlpha = HasAlpha
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if self.disabled then
+ self.frame:Disable()
+ self.text:SetTextColor(0.5, 0.5, 0.5)
+ else
+ self.frame:Enable()
+ self.text:SetTextColor(1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnClick", ColorSwatch_OnClick)
+
+ local colorSwatch = frame:CreateTexture(nil, "OVERLAY")
+ colorSwatch:SetWidth(19)
+ colorSwatch:SetHeight(19)
+ colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
+ colorSwatch:SetPoint("LEFT")
+
+ local texture = frame:CreateTexture(nil, "BACKGROUND")
+ texture:SetWidth(16)
+ texture:SetHeight(16)
+ texture:SetColorTexture(1, 1, 1)
+ texture:SetPoint("CENTER", colorSwatch)
+ texture:Show()
+
+ local checkers = frame:CreateTexture(nil, "BACKGROUND")
+ checkers:SetWidth(14)
+ checkers:SetHeight(14)
+ checkers:SetTexture("Tileset\\Generic\\Checkers")
+ checkers:SetTexCoord(.25, 0, 0.5, .25)
+ checkers:SetDesaturated(true)
+ checkers:SetVertexColor(1, 1, 1, 0.75)
+ checkers:SetPoint("CENTER", colorSwatch)
+ checkers:Show()
+
+ local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
+ text:SetHeight(24)
+ text:SetJustifyH("LEFT")
+ text:SetTextColor(1, 1, 1)
+ text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
+ text:SetPoint("RIGHT")
+
+ --local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ --highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ --highlight:SetBlendMode("ADD")
+ --highlight:SetAllPoints(frame)
+
+ local widget = {
+ colorSwatch = colorSwatch,
+ text = text,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
new file mode 100644
index 0000000..5748e4f
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
@@ -0,0 +1,471 @@
+--[[ $Id: AceGUIWidget-DropDown-Items.lua 1167 2017-08-29 22:08:48Z funkydude $ ]]--
+
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local select, assert = select, assert
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame = CreateFrame
+
+local function fixlevels(parent,...)
+ local i = 1
+ local child = select(i, ...)
+ while child do
+ child:SetFrameLevel(parent:GetFrameLevel()+1)
+ fixlevels(child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+local function fixstrata(strata, parent, ...)
+ local i = 1
+ local child = select(i, ...)
+ parent:SetFrameStrata(strata)
+ while child do
+ fixstrata(strata, child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+-- ItemBase is the base "class" for all dropdown items.
+-- Each item has to use ItemBase.Create(widgetType) to
+-- create an initial 'self' value.
+-- ItemBase will add common functions and ui event handlers.
+-- Be sure to keep basic usage when you override functions.
+
+local ItemBase = {
+ -- NOTE: The ItemBase version is added to each item's version number
+ -- to ensure proper updates on ItemBase changes.
+ -- Use at least 1000er steps.
+ version = 1000,
+ counter = 0,
+}
+
+function ItemBase.Frame_OnEnter(this)
+ local self = this.obj
+
+ if self.useHighlight then
+ self.highlight:Show()
+ end
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+end
+
+function ItemBase.Frame_OnLeave(this)
+ local self = this.obj
+
+ self.highlight:Hide()
+ self:Fire("OnLeave")
+
+ if self.specialOnLeave then
+ self.specialOnLeave(self)
+ end
+end
+
+-- exported, AceGUI callback
+function ItemBase.OnAcquire(self)
+ self.frame:SetToplevel(true)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+end
+
+-- exported, AceGUI callback
+function ItemBase.OnRelease(self)
+ self:SetDisabled(false)
+ self.pullout = nil
+ self.frame:SetParent(nil)
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetPullout(self, pullout)
+ self.pullout = pullout
+
+ self.frame:SetParent(nil)
+ self.frame:SetParent(pullout.itemFrame)
+ self.parent = pullout.itemFrame
+ fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
+end
+
+-- exported
+function ItemBase.SetText(self, text)
+ self.text:SetText(text or "")
+end
+
+-- exported
+function ItemBase.GetText(self)
+ return self.text:GetText()
+end
+
+-- exported
+function ItemBase.SetPoint(self, ...)
+ self.frame:SetPoint(...)
+end
+
+-- exported
+function ItemBase.Show(self)
+ self.frame:Show()
+end
+
+-- exported
+function ItemBase.Hide(self)
+ self.frame:Hide()
+end
+
+-- exported
+function ItemBase.SetDisabled(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.useHighlight = false
+ self.text:SetTextColor(.5, .5, .5)
+ else
+ self.useHighlight = true
+ self.text:SetTextColor(1, 1, 1)
+ end
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetOnLeave(self, func)
+ self.specialOnLeave = func
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetOnEnter(self, func)
+ self.specialOnEnter = func
+end
+
+function ItemBase.Create(type)
+ -- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget
+ local count = AceGUI:GetNextWidgetNum(type)
+ local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count)
+ local self = {}
+ self.frame = frame
+ frame.obj = self
+ self.type = type
+
+ self.useHighlight = true
+
+ frame:SetHeight(17)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
+ text:SetTextColor(1,1,1)
+ text:SetJustifyH("LEFT")
+ text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
+ text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
+ self.text = text
+
+ local highlight = frame:CreateTexture(nil, "OVERLAY")
+ highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ highlight:SetBlendMode("ADD")
+ highlight:SetHeight(14)
+ highlight:ClearAllPoints()
+ highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
+ highlight:SetPoint("LEFT",frame,"LEFT",5,0)
+ highlight:Hide()
+ self.highlight = highlight
+
+ local check = frame:CreateTexture("OVERLAY")
+ check:SetWidth(16)
+ check:SetHeight(16)
+ check:SetPoint("LEFT",frame,"LEFT",3,-1)
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:Hide()
+ self.check = check
+
+ local sub = frame:CreateTexture("OVERLAY")
+ sub:SetWidth(16)
+ sub:SetHeight(16)
+ sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
+ sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
+ sub:Hide()
+ self.sub = sub
+
+ frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
+ frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
+
+ self.OnAcquire = ItemBase.OnAcquire
+ self.OnRelease = ItemBase.OnRelease
+
+ self.SetPullout = ItemBase.SetPullout
+ self.GetText = ItemBase.GetText
+ self.SetText = ItemBase.SetText
+ self.SetDisabled = ItemBase.SetDisabled
+
+ self.SetPoint = ItemBase.SetPoint
+ self.Show = ItemBase.Show
+ self.Hide = ItemBase.Hide
+
+ self.SetOnLeave = ItemBase.SetOnLeave
+ self.SetOnEnter = ItemBase.SetOnEnter
+
+ return self
+end
+
+-- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it.
+local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version)
+if IBLib then
+ IBLib.GetItemBase = function() return ItemBase end
+end
+
+--[[
+ Template for items:
+
+-- Item:
+--
+do
+ local widgetType = "Dropdown-Item-"
+ local widgetVersion = 1
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+--]]
+
+-- Item: Header
+-- A single text entry.
+-- Special: Different text color and no highlight
+do
+ local widgetType = "Dropdown-Item-Header"
+ local widgetVersion = 1
+
+ local function OnEnter(this)
+ local self = this.obj
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+ end
+
+ local function OnLeave(this)
+ local self = this.obj
+ self:Fire("OnLeave")
+
+ if self.specialOnLeave then
+ self.specialOnLeave(self)
+ end
+ end
+
+ -- exported, override
+ local function SetDisabled(self, disabled)
+ ItemBase.SetDisabled(self, disabled)
+ if not disabled then
+ self.text:SetTextColor(1, 1, 0)
+ end
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.SetDisabled = SetDisabled
+
+ self.frame:SetScript("OnEnter", OnEnter)
+ self.frame:SetScript("OnLeave", OnLeave)
+
+ self.text:SetTextColor(1, 1, 0)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Execute
+-- A simple button
+do
+ local widgetType = "Dropdown-Item-Execute"
+ local widgetVersion = 1
+
+ local function Frame_OnClick(this, button)
+ local self = this.obj
+ if self.disabled then return end
+ self:Fire("OnClick")
+ if self.pullout then
+ self.pullout:Close()
+ end
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.frame:SetScript("OnClick", Frame_OnClick)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Toggle
+-- Some sort of checkbox for dropdown menus.
+-- Does not close the pullout on click.
+do
+ local widgetType = "Dropdown-Item-Toggle"
+ local widgetVersion = 4
+
+ local function UpdateToggle(self)
+ if self.value then
+ self.check:Show()
+ else
+ self.check:Hide()
+ end
+ end
+
+ local function OnRelease(self)
+ ItemBase.OnRelease(self)
+ self:SetValue(nil)
+ end
+
+ local function Frame_OnClick(this, button)
+ local self = this.obj
+ if self.disabled then return end
+ self.value = not self.value
+ if self.value then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ else
+ PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
+ end
+ UpdateToggle(self)
+ self:Fire("OnValueChanged", self.value)
+ end
+
+ -- exported
+ local function SetValue(self, value)
+ self.value = value
+ UpdateToggle(self)
+ end
+
+ -- exported
+ local function GetValue(self)
+ return self.value
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.frame:SetScript("OnClick", Frame_OnClick)
+
+ self.SetValue = SetValue
+ self.GetValue = GetValue
+ self.OnRelease = OnRelease
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Menu
+-- Shows a submenu on mouse over
+-- Does not close the pullout on click
+do
+ local widgetType = "Dropdown-Item-Menu"
+ local widgetVersion = 2
+
+ local function OnEnter(this)
+ local self = this.obj
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+
+ self.highlight:Show()
+
+ if not self.disabled and self.submenu then
+ self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
+ end
+ end
+
+ local function OnHide(this)
+ local self = this.obj
+ if self.submenu then
+ self.submenu:Close()
+ end
+ end
+
+ -- exported
+ local function SetMenu(self, menu)
+ assert(menu.type == "Dropdown-Pullout")
+ self.submenu = menu
+ end
+
+ -- exported
+ local function CloseMenu(self)
+ self.submenu:Close()
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.sub:Show()
+
+ self.frame:SetScript("OnEnter", OnEnter)
+ self.frame:SetScript("OnHide", OnHide)
+
+ self.SetMenu = SetMenu
+ self.CloseMenu = CloseMenu
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Separator
+-- A single line to separate items
+do
+ local widgetType = "Dropdown-Item-Separator"
+ local widgetVersion = 2
+
+ -- exported, override
+ local function SetDisabled(self, disabled)
+ ItemBase.SetDisabled(self, disabled)
+ self.useHighlight = false
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.SetDisabled = SetDisabled
+
+ local line = self.frame:CreateTexture(nil, "OVERLAY")
+ line:SetHeight(1)
+ line:SetColorTexture(.5, .5, .5)
+ line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
+ line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
+
+ self.text:Hide()
+
+ self.useHighlight = false
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
new file mode 100644
index 0000000..cf0b0aa
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
@@ -0,0 +1,737 @@
+--[[ $Id: AceGUIWidget-DropDown.lua 1167 2017-08-29 22:08:48Z funkydude $ ]]--
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local min, max, floor = math.min, math.max, math.floor
+local select, pairs, ipairs, type = select, pairs, ipairs, type
+local tsort = table.sort
+
+-- WoW APIs
+local PlaySound = PlaySound
+local UIParent, CreateFrame = UIParent, CreateFrame
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: CLOSE
+
+local function fixlevels(parent,...)
+ local i = 1
+ local child = select(i, ...)
+ while child do
+ child:SetFrameLevel(parent:GetFrameLevel()+1)
+ fixlevels(child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+local function fixstrata(strata, parent, ...)
+ local i = 1
+ local child = select(i, ...)
+ parent:SetFrameStrata(strata)
+ while child do
+ fixstrata(strata, child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+do
+ local widgetType = "Dropdown-Pullout"
+ local widgetVersion = 3
+
+ --[[ Static data ]]--
+
+ local backdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
+ edgeSize = 32,
+ tileSize = 32,
+ tile = true,
+ insets = { left = 11, right = 12, top = 12, bottom = 11 },
+ }
+ local sliderBackdrop = {
+ bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
+ tile = true, tileSize = 8, edgeSize = 8,
+ insets = { left = 3, right = 3, top = 3, bottom = 3 }
+ }
+
+ local defaultWidth = 200
+ local defaultMaxHeight = 600
+
+ --[[ UI Event Handlers ]]--
+
+ -- HACK: This should be no part of the pullout, but there
+ -- is no other 'clean' way to response to any item-OnEnter
+ -- Used to close Submenus when an other item is entered
+ local function OnEnter(item)
+ local self = item.pullout
+ for k, v in ipairs(self.items) do
+ if v.CloseMenu and v ~= item then
+ v:CloseMenu()
+ end
+ end
+ end
+
+ -- See the note in Constructor() for each scroll related function
+ local function OnMouseWheel(this, value)
+ this.obj:MoveScroll(value)
+ end
+
+ local function OnScrollValueChanged(this, value)
+ this.obj:SetScroll(value)
+ end
+
+ local function OnSizeChanged(this)
+ this.obj:FixScroll()
+ end
+
+ --[[ Exported methods ]]--
+
+ -- exported
+ local function SetScroll(self, value)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+
+ local offset
+ if height > viewheight then
+ offset = 0
+ else
+ offset = floor((viewheight - height) / 1000 * value)
+ end
+ child:ClearAllPoints()
+ child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", self.slider:IsShown() and -12 or 0, offset)
+ status.offset = offset
+ status.scrollvalue = value
+ end
+
+ -- exported
+ local function MoveScroll(self, value)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+
+ if height > viewheight then
+ self.slider:Hide()
+ else
+ self.slider:Show()
+ local diff = height - viewheight
+ local delta = 1
+ if value < 0 then
+ delta = -1
+ end
+ self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
+ end
+ end
+
+ -- exported
+ local function FixScroll(self)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+ local offset = status.offset or 0
+
+ if viewheight < height then
+ self.slider:Hide()
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset)
+ self.slider:SetValue(0)
+ else
+ self.slider:Show()
+ local value = (offset / (viewheight - height) * 1000)
+ if value > 1000 then value = 1000 end
+ self.slider:SetValue(value)
+ self:SetScroll(value)
+ if value < 1000 then
+ child:ClearAllPoints()
+ child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -12, offset)
+ status.offset = offset
+ end
+ end
+ end
+
+ -- exported, AceGUI callback
+ local function OnAcquire(self)
+ self.frame:SetParent(UIParent)
+ --self.itemFrame:SetToplevel(true)
+ end
+
+ -- exported, AceGUI callback
+ local function OnRelease(self)
+ self:Clear()
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+ end
+
+ -- exported
+ local function AddItem(self, item)
+ self.items[#self.items + 1] = item
+
+ local h = #self.items * 16
+ self.itemFrame:SetHeight(h)
+ self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement
+
+ item.frame:SetPoint("LEFT", self.itemFrame, "LEFT")
+ item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT")
+
+ item:SetPullout(self)
+ item:SetOnEnter(OnEnter)
+ end
+
+ -- exported
+ local function Open(self, point, relFrame, relPoint, x, y)
+ local items = self.items
+ local frame = self.frame
+ local itemFrame = self.itemFrame
+
+ frame:SetPoint(point, relFrame, relPoint, x, y)
+
+
+ local height = 8
+ for i, item in pairs(items) do
+ if i == 1 then
+ item:SetPoint("TOP", itemFrame, "TOP", 0, -2)
+ else
+ item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1)
+ end
+
+ item:Show()
+
+ height = height + 16
+ end
+ itemFrame:SetHeight(height)
+ fixstrata("TOOLTIP", frame, frame:GetChildren())
+ frame:Show()
+ self:Fire("OnOpen")
+ end
+
+ -- exported
+ local function Close(self)
+ self.frame:Hide()
+ self:Fire("OnClose")
+ end
+
+ -- exported
+ local function Clear(self)
+ local items = self.items
+ for i, item in pairs(items) do
+ AceGUI:Release(item)
+ items[i] = nil
+ end
+ end
+
+ -- exported
+ local function IterateItems(self)
+ return ipairs(self.items)
+ end
+
+ -- exported
+ local function SetHideOnLeave(self, val)
+ self.hideOnLeave = val
+ end
+
+ -- exported
+ local function SetMaxHeight(self, height)
+ self.maxHeight = height or defaultMaxHeight
+ if self.frame:GetHeight() > height then
+ self.frame:SetHeight(height)
+ elseif (self.itemFrame:GetHeight() + 34) < height then
+ self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem
+ end
+ end
+
+ -- exported
+ local function GetRightBorderWidth(self)
+ return 6 + (self.slider:IsShown() and 12 or 0)
+ end
+
+ -- exported
+ local function GetLeftBorderWidth(self)
+ return 6
+ end
+
+ --[[ Constructor ]]--
+
+ local function Constructor()
+ local count = AceGUI:GetNextWidgetNum(widgetType)
+ local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent)
+ local self = {}
+ self.count = count
+ self.type = widgetType
+ self.frame = frame
+ frame.obj = self
+
+ self.OnAcquire = OnAcquire
+ self.OnRelease = OnRelease
+
+ self.AddItem = AddItem
+ self.Open = Open
+ self.Close = Close
+ self.Clear = Clear
+ self.IterateItems = IterateItems
+ self.SetHideOnLeave = SetHideOnLeave
+
+ self.SetScroll = SetScroll
+ self.MoveScroll = MoveScroll
+ self.FixScroll = FixScroll
+
+ self.SetMaxHeight = SetMaxHeight
+ self.GetRightBorderWidth = GetRightBorderWidth
+ self.GetLeftBorderWidth = GetLeftBorderWidth
+
+ self.items = {}
+
+ self.scrollStatus = {
+ scrollvalue = 0,
+ }
+
+ self.maxHeight = defaultMaxHeight
+
+ frame:SetBackdrop(backdrop)
+ frame:SetBackdropColor(0, 0, 0)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetClampedToScreen(true)
+ frame:SetWidth(defaultWidth)
+ frame:SetHeight(self.maxHeight)
+ --frame:SetToplevel(true)
+
+ -- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame
+ local scrollFrame = CreateFrame("ScrollFrame", nil, frame)
+ local itemFrame = CreateFrame("Frame", nil, scrollFrame)
+
+ self.scrollFrame = scrollFrame
+ self.itemFrame = itemFrame
+
+ scrollFrame.obj = self
+ itemFrame.obj = self
+
+ local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame)
+ slider:SetOrientation("VERTICAL")
+ slider:SetHitRectInsets(0, 0, -10, 0)
+ slider:SetBackdrop(sliderBackdrop)
+ slider:SetWidth(8)
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetFrameStrata("FULLSCREEN_DIALOG")
+ self.slider = slider
+ slider.obj = self
+
+ scrollFrame:SetScrollChild(itemFrame)
+ scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12)
+ scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12)
+ scrollFrame:EnableMouseWheel(true)
+ scrollFrame:SetScript("OnMouseWheel", OnMouseWheel)
+ scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
+ scrollFrame:SetToplevel(true)
+ scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
+ itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0)
+ itemFrame:SetHeight(400)
+ itemFrame:SetToplevel(true)
+ itemFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0)
+ slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0)
+ slider:SetScript("OnValueChanged", OnScrollValueChanged)
+ slider:SetMinMaxValues(0, 1000)
+ slider:SetValueStep(1)
+ slider:SetValue(0)
+
+ scrollFrame:Show()
+ itemFrame:Show()
+ slider:Hide()
+
+ self:FixScroll()
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
+end
+
+do
+ local widgetType = "Dropdown"
+ local widgetVersion = 31
+
+ --[[ Static data ]]--
+
+ --[[ UI event handler ]]--
+
+ local function Control_OnEnter(this)
+ this.obj.button:LockHighlight()
+ this.obj:Fire("OnEnter")
+ end
+
+ local function Control_OnLeave(this)
+ this.obj.button:UnlockHighlight()
+ this.obj:Fire("OnLeave")
+ end
+
+ local function Dropdown_OnHide(this)
+ local self = this.obj
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+
+ local function Dropdown_TogglePullout(this)
+ local self = this.obj
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ if self.open then
+ self.open = nil
+ self.pullout:Close()
+ AceGUI:ClearFocus()
+ else
+ self.open = true
+ self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth())
+ self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0)
+ AceGUI:SetFocus(self)
+ end
+ end
+
+ local function OnPulloutOpen(this)
+ local self = this.userdata.obj
+ local value = self.value
+
+ if not self.multiselect then
+ for i, item in this:IterateItems() do
+ item:SetValue(item.userdata.value == value)
+ end
+ end
+
+ self.open = true
+ self:Fire("OnOpened")
+ end
+
+ local function OnPulloutClose(this)
+ local self = this.userdata.obj
+ self.open = nil
+ self:Fire("OnClosed")
+ end
+
+ local function ShowMultiText(self)
+ local text
+ for i, widget in self.pullout:IterateItems() do
+ if widget.type == "Dropdown-Item-Toggle" then
+ if widget:GetValue() then
+ if text then
+ text = text..", "..widget:GetText()
+ else
+ text = widget:GetText()
+ end
+ end
+ end
+ end
+ self:SetText(text)
+ end
+
+ local function OnItemValueChanged(this, event, checked)
+ local self = this.userdata.obj
+
+ if self.multiselect then
+ self:Fire("OnValueChanged", this.userdata.value, checked)
+ ShowMultiText(self)
+ else
+ if checked then
+ self:SetValue(this.userdata.value)
+ self:Fire("OnValueChanged", this.userdata.value)
+ else
+ this:SetValue(true)
+ end
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+ end
+
+ --[[ Exported methods ]]--
+
+ -- exported, AceGUI callback
+ local function OnAcquire(self)
+ local pullout = AceGUI:Create("Dropdown-Pullout")
+ self.pullout = pullout
+ pullout.userdata.obj = self
+ pullout:SetCallback("OnClose", OnPulloutClose)
+ pullout:SetCallback("OnOpen", OnPulloutOpen)
+ self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
+ fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
+
+ self:SetHeight(44)
+ self:SetWidth(200)
+ self:SetLabel()
+ self:SetPulloutWidth(nil)
+ end
+
+ -- exported, AceGUI callback
+ local function OnRelease(self)
+ if self.open then
+ self.pullout:Close()
+ end
+ AceGUI:Release(self.pullout)
+ self.pullout = nil
+
+ self:SetText("")
+ self:SetDisabled(false)
+ self:SetMultiselect(false)
+
+ self.value = nil
+ self.list = nil
+ self.open = nil
+ self.hasClose = nil
+
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+ end
+
+ -- exported
+ local function SetDisabled(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.text:SetTextColor(0.5,0.5,0.5)
+ self.button:Disable()
+ self.button_cover:Disable()
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.button:Enable()
+ self.button_cover:Enable()
+ self.label:SetTextColor(1,.82,0)
+ self.text:SetTextColor(1,1,1)
+ end
+ end
+
+ -- exported
+ local function ClearFocus(self)
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+
+ -- exported
+ local function SetText(self, text)
+ self.text:SetText(text or "")
+ end
+
+ -- exported
+ local function SetLabel(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ self.label:Show()
+ self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-14)
+ self:SetHeight(40)
+ self.alignoffset = 26
+ else
+ self.label:SetText("")
+ self.label:Hide()
+ self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0)
+ self:SetHeight(26)
+ self.alignoffset = 12
+ end
+ end
+
+ -- exported
+ local function SetValue(self, value)
+ if self.list then
+ self:SetText(self.list[value] or "")
+ end
+ self.value = value
+ end
+
+ -- exported
+ local function GetValue(self)
+ return self.value
+ end
+
+ -- exported
+ local function SetItemValue(self, item, value)
+ if not self.multiselect then return end
+ for i, widget in self.pullout:IterateItems() do
+ if widget.userdata.value == item then
+ if widget.SetValue then
+ widget:SetValue(value)
+ end
+ end
+ end
+ ShowMultiText(self)
+ end
+
+ -- exported
+ local function SetItemDisabled(self, item, disabled)
+ for i, widget in self.pullout:IterateItems() do
+ if widget.userdata.value == item then
+ widget:SetDisabled(disabled)
+ end
+ end
+ end
+
+ local function AddListItem(self, value, text, itemType)
+ if not itemType then itemType = "Dropdown-Item-Toggle" end
+ local exists = AceGUI:GetWidgetVersion(itemType)
+ if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
+
+ local item = AceGUI:Create(itemType)
+ item:SetText(text)
+ item.userdata.obj = self
+ item.userdata.value = value
+ item:SetCallback("OnValueChanged", OnItemValueChanged)
+ self.pullout:AddItem(item)
+ end
+
+ local function AddCloseButton(self)
+ if not self.hasClose then
+ local close = AceGUI:Create("Dropdown-Item-Execute")
+ close:SetText(CLOSE)
+ self.pullout:AddItem(close)
+ self.hasClose = true
+ end
+ end
+
+ -- exported
+ local sortlist = {}
+ local function SetList(self, list, order, itemType)
+ self.list = list
+ self.pullout:Clear()
+ self.hasClose = nil
+ if not list then return end
+
+ if type(order) ~= "table" then
+ for v in pairs(list) do
+ sortlist[#sortlist + 1] = v
+ end
+ tsort(sortlist)
+
+ for i, key in ipairs(sortlist) do
+ AddListItem(self, key, list[key], itemType)
+ sortlist[i] = nil
+ end
+ else
+ for i, key in ipairs(order) do
+ AddListItem(self, key, list[key], itemType)
+ end
+ end
+ if self.multiselect then
+ ShowMultiText(self)
+ AddCloseButton(self)
+ end
+ end
+
+ -- exported
+ local function AddItem(self, value, text, itemType)
+ if self.list then
+ self.list[value] = text
+ AddListItem(self, value, text, itemType)
+ end
+ end
+
+ -- exported
+ local function SetMultiselect(self, multi)
+ self.multiselect = multi
+ if multi then
+ ShowMultiText(self)
+ AddCloseButton(self)
+ end
+ end
+
+ -- exported
+ local function GetMultiselect(self)
+ return self.multiselect
+ end
+
+ local function SetPulloutWidth(self, width)
+ self.pulloutWidth = width
+ end
+
+ --[[ Constructor ]]--
+
+ local function Constructor()
+ local count = AceGUI:GetNextWidgetNum(widgetType)
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate")
+
+ local self = {}
+ self.type = widgetType
+ self.frame = frame
+ self.dropdown = dropdown
+ self.count = count
+ frame.obj = self
+ dropdown.obj = self
+
+ self.OnRelease = OnRelease
+ self.OnAcquire = OnAcquire
+
+ self.ClearFocus = ClearFocus
+
+ self.SetText = SetText
+ self.SetValue = SetValue
+ self.GetValue = GetValue
+ self.SetList = SetList
+ self.SetLabel = SetLabel
+ self.SetDisabled = SetDisabled
+ self.AddItem = AddItem
+ self.SetMultiselect = SetMultiselect
+ self.GetMultiselect = GetMultiselect
+ self.SetItemValue = SetItemValue
+ self.SetItemDisabled = SetItemDisabled
+ self.SetPulloutWidth = SetPulloutWidth
+
+ self.alignoffset = 26
+
+ frame:SetScript("OnHide",Dropdown_OnHide)
+
+ dropdown:ClearAllPoints()
+ dropdown:SetPoint("TOPLEFT",frame,"TOPLEFT",-15,0)
+ dropdown:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",17,0)
+ dropdown:SetScript("OnHide", nil)
+
+ local left = _G[dropdown:GetName() .. "Left"]
+ local middle = _G[dropdown:GetName() .. "Middle"]
+ local right = _G[dropdown:GetName() .. "Right"]
+
+ middle:ClearAllPoints()
+ right:ClearAllPoints()
+
+ middle:SetPoint("LEFT", left, "RIGHT", 0, 0)
+ middle:SetPoint("RIGHT", right, "LEFT", 0, 0)
+ right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17)
+
+ local button = _G[dropdown:GetName() .. "Button"]
+ self.button = button
+ button.obj = self
+ button:SetScript("OnEnter",Control_OnEnter)
+ button:SetScript("OnLeave",Control_OnLeave)
+ button:SetScript("OnClick",Dropdown_TogglePullout)
+
+ local button_cover = CreateFrame("BUTTON",nil,self.frame)
+ self.button_cover = button_cover
+ button_cover.obj = self
+ button_cover:SetPoint("TOPLEFT",self.frame,"BOTTOMLEFT",0,25)
+ button_cover:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT")
+ button_cover:SetScript("OnEnter",Control_OnEnter)
+ button_cover:SetScript("OnLeave",Control_OnLeave)
+ button_cover:SetScript("OnClick",Dropdown_TogglePullout)
+
+ local text = _G[dropdown:GetName() .. "Text"]
+ self.text = text
+ text.obj = self
+ text:ClearAllPoints()
+ text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2)
+ text:SetPoint("LEFT", left, "LEFT", 25, 2)
+
+ local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
+ label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
+ label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
+ label:SetJustifyH("LEFT")
+ label:SetHeight(18)
+ label:Hide()
+ self.label = label
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
+end
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
new file mode 100644
index 0000000..b0b00f9
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
@@ -0,0 +1,265 @@
+--[[-----------------------------------------------------------------------------
+EditBox Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "EditBox", 27
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local tostring, pairs = tostring, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+if not AceGUIEditBoxInsertLink then
+ -- upgradeable hook
+ hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
+end
+
+function _G.AceGUIEditBoxInsertLink(text)
+ for i = 1, AceGUI:GetWidgetCount(Type) do
+ local editbox = _G["AceGUI-3.0EditBox"..i]
+ if editbox and editbox:IsVisible() and editbox:HasFocus() then
+ editbox:Insert(text)
+ return true
+ end
+ end
+end
+
+local function ShowButton(self)
+ if not self.disablebutton then
+ self.button:Show()
+ self.editbox:SetTextInsets(0, 20, 3, 3)
+ end
+end
+
+local function HideButton(self)
+ self.button:Hide()
+ self.editbox:SetTextInsets(0, 0, 3, 3)
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Frame_OnShowFocus(frame)
+ frame.obj.editbox:SetFocus()
+ frame:SetScript("OnShow", nil)
+end
+
+local function EditBox_OnEscapePressed(frame)
+ AceGUI:ClearFocus()
+end
+
+local function EditBox_OnEnterPressed(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ local cancel = self:Fire("OnEnterPressed", value)
+ if not cancel then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ HideButton(self)
+ end
+end
+
+local function EditBox_OnReceiveDrag(frame)
+ local self = frame.obj
+ local type, id, info = GetCursorInfo()
+ if type == "item" then
+ self:SetText(info)
+ self:Fire("OnEnterPressed", info)
+ ClearCursor()
+ elseif type == "spell" then
+ local name = GetSpellInfo(id, info)
+ self:SetText(name)
+ self:Fire("OnEnterPressed", name)
+ ClearCursor()
+ elseif type == "macro" then
+ local name = GetMacroInfo(id)
+ self:SetText(name)
+ self:Fire("OnEnterPressed", name)
+ ClearCursor()
+ end
+ HideButton(self)
+ AceGUI:ClearFocus()
+end
+
+local function EditBox_OnTextChanged(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ if tostring(value) ~= tostring(self.lasttext) then
+ self:Fire("OnTextChanged", value)
+ self.lasttext = value
+ ShowButton(self)
+ end
+end
+
+local function EditBox_OnFocusGained(frame)
+ AceGUI:SetFocus(frame.obj)
+end
+
+local function Button_OnClick(frame)
+ local editbox = frame.obj.editbox
+ editbox:ClearFocus()
+ EditBox_OnEnterPressed(editbox)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- height is controlled by SetLabel
+ self:SetWidth(200)
+ self:SetDisabled(false)
+ self:SetLabel()
+ self:SetText()
+ self:DisableButton(false)
+ self:SetMaxLetters(0)
+ end,
+
+ ["OnRelease"] = function(self)
+ self:ClearFocus()
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.editbox:EnableMouse(false)
+ self.editbox:ClearFocus()
+ self.editbox:SetTextColor(0.5,0.5,0.5)
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.editbox:EnableMouse(true)
+ self.editbox:SetTextColor(1,1,1)
+ self.label:SetTextColor(1,.82,0)
+ end
+ end,
+
+ ["SetText"] = function(self, text)
+ self.lasttext = text or ""
+ self.editbox:SetText(text or "")
+ self.editbox:SetCursorPosition(0)
+ HideButton(self)
+ end,
+
+ ["GetText"] = function(self, text)
+ return self.editbox:GetText()
+ end,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ self.label:Show()
+ self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
+ self:SetHeight(44)
+ self.alignoffset = 30
+ else
+ self.label:SetText("")
+ self.label:Hide()
+ self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
+ self:SetHeight(26)
+ self.alignoffset = 12
+ end
+ end,
+
+ ["DisableButton"] = function(self, disabled)
+ self.disablebutton = disabled
+ if disabled then
+ HideButton(self)
+ end
+ end,
+
+ ["SetMaxLetters"] = function (self, num)
+ self.editbox:SetMaxLetters(num or 0)
+ end,
+
+ ["ClearFocus"] = function(self)
+ self.editbox:ClearFocus()
+ self.frame:SetScript("OnShow", nil)
+ end,
+
+ ["SetFocus"] = function(self)
+ self.editbox:SetFocus()
+ if not self.frame:IsShown() then
+ self.frame:SetScript("OnShow", Frame_OnShowFocus)
+ end
+ end,
+
+ ["HighlightText"] = function(self, from, to)
+ self.editbox:HighlightText(from, to)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate")
+ editbox:SetAutoFocus(false)
+ editbox:SetFontObject(ChatFontNormal)
+ editbox:SetScript("OnEnter", Control_OnEnter)
+ editbox:SetScript("OnLeave", Control_OnLeave)
+ editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
+ editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
+ editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
+ editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
+ editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
+ editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
+ editbox:SetTextInsets(0, 0, 3, 3)
+ editbox:SetMaxLetters(256)
+ editbox:SetPoint("BOTTOMLEFT", 6, 0)
+ editbox:SetPoint("BOTTOMRIGHT")
+ editbox:SetHeight(19)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
+ label:SetPoint("TOPLEFT", 0, -2)
+ label:SetPoint("TOPRIGHT", 0, -2)
+ label:SetJustifyH("LEFT")
+ label:SetHeight(18)
+
+ local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
+ button:SetWidth(40)
+ button:SetHeight(20)
+ button:SetPoint("RIGHT", -2, 0)
+ button:SetText(OKAY)
+ button:SetScript("OnClick", Button_OnClick)
+ button:Hide()
+
+ local widget = {
+ alignoffset = 30,
+ editbox = editbox,
+ label = label,
+ button = button,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ editbox.obj, button.obj = widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
new file mode 100644
index 0000000..1aaf3f5
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
@@ -0,0 +1,78 @@
+--[[-----------------------------------------------------------------------------
+Heading Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "Heading", 20
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetText()
+ self:SetFullWidth()
+ self:SetHeight(18)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetText"] = function(self, text)
+ self.label:SetText(text or "")
+ if text and text ~= "" then
+ self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
+ self.right:Show()
+ else
+ self.left:SetPoint("RIGHT", -3, 0)
+ self.right:Hide()
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
+ label:SetPoint("TOP")
+ label:SetPoint("BOTTOM")
+ label:SetJustifyH("CENTER")
+
+ local left = frame:CreateTexture(nil, "BACKGROUND")
+ left:SetHeight(8)
+ left:SetPoint("LEFT", 3, 0)
+ left:SetPoint("RIGHT", label, "LEFT", -5, 0)
+ left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ left:SetTexCoord(0.81, 0.94, 0.5, 1)
+
+ local right = frame:CreateTexture(nil, "BACKGROUND")
+ right:SetHeight(8)
+ right:SetPoint("RIGHT", -3, 0)
+ right:SetPoint("LEFT", label, "RIGHT", 5, 0)
+ right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ right:SetTexCoord(0.81, 0.94, 0.5, 1)
+
+ local widget = {
+ label = label,
+ left = left,
+ right = right,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua
new file mode 100644
index 0000000..561da73
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua
@@ -0,0 +1,140 @@
+--[[-----------------------------------------------------------------------------
+Icon Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "Icon", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs, print = select, pairs, print
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Button_OnClick(frame, button)
+ frame.obj:Fire("OnClick", button)
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetHeight(110)
+ self:SetWidth(110)
+ self:SetLabel()
+ self:SetImage(nil)
+ self:SetImageSize(64, 64)
+ self:SetDisabled(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:Show()
+ self.label:SetText(text)
+ self:SetHeight(self.image:GetHeight() + 25)
+ else
+ self.label:Hide()
+ self:SetHeight(self.image:GetHeight() + 10)
+ end
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ end,
+
+ ["SetImageSize"] = function(self, width, height)
+ self.image:SetWidth(width)
+ self.image:SetHeight(height)
+ --self.frame:SetWidth(width + 30)
+ if self.label:IsShown() then
+ self:SetHeight(height + 25)
+ else
+ self:SetHeight(height + 10)
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
+ else
+ self.frame:Enable()
+ self.label:SetTextColor(1, 1, 1)
+ self.image:SetVertexColor(1, 1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnClick", Button_OnClick)
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
+ label:SetPoint("BOTTOMLEFT")
+ label:SetPoint("BOTTOMRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetJustifyV("TOP")
+ label:SetHeight(18)
+
+ local image = frame:CreateTexture(nil, "BACKGROUND")
+ image:SetWidth(64)
+ image:SetHeight(64)
+ image:SetPoint("TOP", 0, -5)
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetAllPoints(image)
+ highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
+ highlight:SetTexCoord(0, 1, 0.23, 0.77)
+ highlight:SetBlendMode("ADD")
+
+ local widget = {
+ label = label,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua
new file mode 100644
index 0000000..036efee
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua
@@ -0,0 +1,101 @@
+--[[-----------------------------------------------------------------------------
+InteractiveLabel Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "InteractiveLabel", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs = select, pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GameFontHighlightSmall
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Label_OnClick(frame, button)
+ frame.obj:Fire("OnClick", button)
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:LabelOnAcquire()
+ self:SetHighlight()
+ self:SetHighlightTexCoord()
+ self:SetDisabled(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetHighlight"] = function(self, ...)
+ self.highlight:SetTexture(...)
+ end,
+
+ ["SetHighlightTexCoord"] = function(self, ...)
+ local c = select("#", ...)
+ if c == 4 or c == 8 then
+ self.highlight:SetTexCoord(...)
+ else
+ self.highlight:SetTexCoord(0, 1, 0, 1)
+ end
+ end,
+
+ ["SetDisabled"] = function(self,disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:EnableMouse(false)
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ else
+ self.frame:EnableMouse(true)
+ self.label:SetTextColor(1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ -- create a Label type that we will hijack
+ local label = AceGUI:Create("Label")
+
+ local frame = label.frame
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnMouseDown", Label_OnClick)
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetTexture(nil)
+ highlight:SetAllPoints()
+ highlight:SetBlendMode("ADD")
+
+ label.highlight = highlight
+ label.type = Type
+ label.LabelOnAcquire = label.OnAcquire
+ for method, func in pairs(methods) do
+ label[method] = func
+ end
+
+ return label
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
+
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua
new file mode 100644
index 0000000..ec4cead
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua
@@ -0,0 +1,249 @@
+--[[-----------------------------------------------------------------------------
+Keybinding Widget
+Set Keybindings in the Config UI.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Keybinding", 25
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: NOT_BOUND
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Keybinding_OnClick(frame, button)
+ if button == "LeftButton" or button == "RightButton" then
+ local self = frame.obj
+ if self.waitingForKey then
+ frame:EnableKeyboard(false)
+ frame:EnableMouseWheel(false)
+ self.msgframe:Hide()
+ frame:UnlockHighlight()
+ self.waitingForKey = nil
+ else
+ frame:EnableKeyboard(true)
+ frame:EnableMouseWheel(true)
+ self.msgframe:Show()
+ frame:LockHighlight()
+ self.waitingForKey = true
+ end
+ end
+ AceGUI:ClearFocus()
+end
+
+local ignoreKeys = {
+ ["BUTTON1"] = true, ["BUTTON2"] = true,
+ ["UNKNOWN"] = true,
+ ["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
+ ["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
+}
+local function Keybinding_OnKeyDown(frame, key)
+ local self = frame.obj
+ if self.waitingForKey then
+ local keyPressed = key
+ if keyPressed == "ESCAPE" then
+ keyPressed = ""
+ else
+ if ignoreKeys[keyPressed] then return end
+ if IsShiftKeyDown() then
+ keyPressed = "SHIFT-"..keyPressed
+ end
+ if IsControlKeyDown() then
+ keyPressed = "CTRL-"..keyPressed
+ end
+ if IsAltKeyDown() then
+ keyPressed = "ALT-"..keyPressed
+ end
+ end
+
+ frame:EnableKeyboard(false)
+ frame:EnableMouseWheel(false)
+ self.msgframe:Hide()
+ frame:UnlockHighlight()
+ self.waitingForKey = nil
+
+ if not self.disabled then
+ self:SetKey(keyPressed)
+ self:Fire("OnKeyChanged", keyPressed)
+ end
+ end
+end
+
+local function Keybinding_OnMouseDown(frame, button)
+ if button == "LeftButton" or button == "RightButton" then
+ return
+ elseif button == "MiddleButton" then
+ button = "BUTTON3"
+ elseif button == "Button4" then
+ button = "BUTTON4"
+ elseif button == "Button5" then
+ button = "BUTTON5"
+ end
+ Keybinding_OnKeyDown(frame, button)
+end
+
+local function Keybinding_OnMouseWheel(frame, direction)
+ local button
+ if direction >= 0 then
+ button = "MOUSEWHEELUP"
+ else
+ button = "MOUSEWHEELDOWN"
+ end
+ Keybinding_OnKeyDown(frame, button)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(200)
+ self:SetLabel("")
+ self:SetKey("")
+ self.waitingForKey = nil
+ self.msgframe:Hide()
+ self:SetDisabled(false)
+ self.button:EnableKeyboard(false)
+ self.button:EnableMouseWheel(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.button:Disable()
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.button:Enable()
+ self.label:SetTextColor(1,1,1)
+ end
+ end,
+
+ ["SetKey"] = function(self, key)
+ if (key or "") == "" then
+ self.button:SetText(NOT_BOUND)
+ self.button:SetNormalFontObject("GameFontNormal")
+ else
+ self.button:SetText(key)
+ self.button:SetNormalFontObject("GameFontHighlight")
+ end
+ end,
+
+ ["GetKey"] = function(self)
+ local key = self.button:GetText()
+ if key == NOT_BOUND then
+ key = nil
+ end
+ return key
+ end,
+
+ ["SetLabel"] = function(self, label)
+ self.label:SetText(label or "")
+ if (label or "") == "" then
+ self.alignoffset = nil
+ self:SetHeight(24)
+ else
+ self.alignoffset = 30
+ self:SetHeight(44)
+ end
+ end,
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+
+local ControlBackdrop = {
+ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 3, bottom = 3 }
+}
+
+local function keybindingMsgFixWidth(frame)
+ frame:SetWidth(frame.msg:GetWidth() + 10)
+ frame:SetScript("OnUpdate", nil)
+end
+
+local function Constructor()
+ local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
+
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
+
+ button:EnableMouse(true)
+ button:EnableMouseWheel(false)
+ button:RegisterForClicks("AnyDown")
+ button:SetScript("OnEnter", Control_OnEnter)
+ button:SetScript("OnLeave", Control_OnLeave)
+ button:SetScript("OnClick", Keybinding_OnClick)
+ button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
+ button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
+ button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
+ button:SetPoint("BOTTOMLEFT")
+ button:SetPoint("BOTTOMRIGHT")
+ button:SetHeight(24)
+ button:EnableKeyboard(false)
+
+ local text = button:GetFontString()
+ text:SetPoint("LEFT", 7, 0)
+ text:SetPoint("RIGHT", -7, 0)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ label:SetPoint("TOPLEFT")
+ label:SetPoint("TOPRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetHeight(18)
+
+ local msgframe = CreateFrame("Frame", nil, UIParent)
+ msgframe:SetHeight(30)
+ msgframe:SetBackdrop(ControlBackdrop)
+ msgframe:SetBackdropColor(0,0,0)
+ msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
+ msgframe:SetFrameLevel(1000)
+ msgframe:SetToplevel(true)
+
+ local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.")
+ msgframe.msg = msg
+ msg:SetPoint("TOPLEFT", 5, -5)
+ msgframe:SetScript("OnUpdate", keybindingMsgFixWidth)
+ msgframe:SetPoint("BOTTOM", button, "TOP")
+ msgframe:Hide()
+
+ local widget = {
+ button = button,
+ label = label,
+ msgframe = msgframe,
+ frame = frame,
+ alignoffset = 30,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ button.obj = widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua
new file mode 100644
index 0000000..75817a0
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua
@@ -0,0 +1,173 @@
+--[[-----------------------------------------------------------------------------
+Label Widget
+Displays text and optionally an icon.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Label", 24
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local max, select, pairs = math.max, select, pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GameFontHighlightSmall
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+local function UpdateImageAnchor(self)
+ if self.resizing then return end
+ local frame = self.frame
+ local width = frame.width or frame:GetWidth() or 0
+ local image = self.image
+ local label = self.label
+ local height
+
+ label:ClearAllPoints()
+ image:ClearAllPoints()
+
+ if self.imageshown then
+ local imagewidth = image:GetWidth()
+ if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
+ -- image goes on top centered when less than 200 width for the text, or if there is no text
+ image:SetPoint("TOP")
+ label:SetPoint("TOP", image, "BOTTOM")
+ label:SetPoint("LEFT")
+ label:SetWidth(width)
+ height = image:GetHeight() + label:GetHeight()
+ else
+ -- image on the left
+ image:SetPoint("TOPLEFT")
+ if image:GetHeight() > label:GetHeight() then
+ label:SetPoint("LEFT", image, "RIGHT", 4, 0)
+ else
+ label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
+ end
+ label:SetWidth(width - imagewidth - 4)
+ height = max(image:GetHeight(), label:GetHeight())
+ end
+ else
+ -- no image shown
+ label:SetPoint("TOPLEFT")
+ label:SetWidth(width)
+ height = label:GetHeight()
+ end
+
+ self.resizing = true
+ frame:SetHeight(height)
+ frame.height = height
+ self.resizing = nil
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- set the flag to stop constant size updates
+ self.resizing = true
+ -- height is set dynamically by the text and image size
+ self:SetWidth(200)
+ self:SetText()
+ self:SetImage(nil)
+ self:SetImageSize(16, 16)
+ self:SetColor()
+ self:SetFontObject()
+ self:SetJustifyH("LEFT")
+ self:SetJustifyV("TOP")
+
+ -- reset the flag
+ self.resizing = nil
+ -- run the update explicitly
+ UpdateImageAnchor(self)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetText"] = function(self, text)
+ self.label:SetText(text)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetColor"] = function(self, r, g, b)
+ if not (r and g and b) then
+ r, g, b = 1, 1, 1
+ end
+ self.label:SetVertexColor(r, g, b)
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ self.imageshown = true
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ self.imageshown = nil
+ end
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetFont"] = function(self, font, height, flags)
+ self.label:SetFont(font, height, flags)
+ end,
+
+ ["SetFontObject"] = function(self, font)
+ self:SetFont((font or GameFontHighlightSmall):GetFont())
+ end,
+
+ ["SetImageSize"] = function(self, width, height)
+ self.image:SetWidth(width)
+ self.image:SetHeight(height)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetJustifyH"] = function(self, justifyH)
+ self.label:SetJustifyH(justifyH)
+ end,
+
+ ["SetJustifyV"] = function(self, justifyV)
+ self.label:SetJustifyV(justifyV)
+ end,
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
+ local image = frame:CreateTexture(nil, "BACKGROUND")
+
+ -- create widget
+ local widget = {
+ label = label,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
new file mode 100644
index 0000000..9af4b87
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
@@ -0,0 +1,366 @@
+local Type, Version = "MultiLineEditBox", 28
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: ACCEPT, ChatFontNormal
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+if not AceGUIMultiLineEditBoxInsertLink then
+ -- upgradeable hook
+ hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
+end
+
+function _G.AceGUIMultiLineEditBoxInsertLink(text)
+ for i = 1, AceGUI:GetWidgetCount(Type) do
+ local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
+ if editbox and editbox:IsVisible() and editbox:HasFocus() then
+ editbox:Insert(text)
+ return true
+ end
+ end
+end
+
+
+local function Layout(self)
+ self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
+
+ if self.labelHeight == 0 then
+ self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
+ else
+ self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
+ end
+
+ if self.disablebutton then
+ self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21)
+ self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4)
+ else
+ self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18)
+ self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT")
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function OnClick(self) -- Button
+ self = self.obj
+ self.editBox:ClearFocus()
+ if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
+ self.button:Disable()
+ end
+end
+
+local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
+ self, y = self.obj.scrollFrame, -y
+ local offset = self:GetVerticalScroll()
+ if y < offset then
+ self:SetVerticalScroll(y)
+ else
+ y = y + cursorHeight - self:GetHeight()
+ if y > offset then
+ self:SetVerticalScroll(y)
+ end
+ end
+end
+
+local function OnEditFocusLost(self) -- EditBox
+ self:HighlightText(0, 0)
+ self.obj:Fire("OnEditFocusLost")
+end
+
+local function OnEnter(self) -- EditBox / ScrollFrame
+ self = self.obj
+ if not self.entered then
+ self.entered = true
+ self:Fire("OnEnter")
+ end
+end
+
+local function OnLeave(self) -- EditBox / ScrollFrame
+ self = self.obj
+ if self.entered then
+ self.entered = nil
+ self:Fire("OnLeave")
+ end
+end
+
+local function OnMouseUp(self) -- ScrollFrame
+ self = self.obj.editBox
+ self:SetFocus()
+ self:SetCursorPosition(self:GetNumLetters())
+end
+
+local function OnReceiveDrag(self) -- EditBox / ScrollFrame
+ local type, id, info = GetCursorInfo()
+ if type == "spell" then
+ info = GetSpellInfo(id, info)
+ elseif type ~= "item" then
+ return
+ end
+ ClearCursor()
+ self = self.obj
+ local editBox = self.editBox
+ if not editBox:HasFocus() then
+ editBox:SetFocus()
+ editBox:SetCursorPosition(editBox:GetNumLetters())
+ end
+ editBox:Insert(info)
+ self.button:Enable()
+end
+
+local function OnSizeChanged(self, width, height) -- ScrollFrame
+ self.obj.editBox:SetWidth(width)
+end
+
+local function OnTextChanged(self, userInput) -- EditBox
+ if userInput then
+ self = self.obj
+ self:Fire("OnTextChanged", self.editBox:GetText())
+ self.button:Enable()
+ end
+end
+
+local function OnTextSet(self) -- EditBox
+ self:HighlightText(0, 0)
+ self:SetCursorPosition(self:GetNumLetters())
+ self:SetCursorPosition(0)
+ self.obj.button:Disable()
+end
+
+local function OnVerticalScroll(self, offset) -- ScrollFrame
+ local editBox = self.obj.editBox
+ editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
+end
+
+local function OnShowFocus(frame)
+ frame.obj.editBox:SetFocus()
+ frame:SetScript("OnShow", nil)
+end
+
+local function OnEditFocusGained(frame)
+ AceGUI:SetFocus(frame.obj)
+ frame.obj:Fire("OnEditFocusGained")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.editBox:SetText("")
+ self:SetDisabled(false)
+ self:SetWidth(200)
+ self:DisableButton(false)
+ self:SetNumLines()
+ self.entered = nil
+ self:SetMaxLetters(0)
+ end,
+
+ ["OnRelease"] = function(self)
+ self:ClearFocus()
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ local editBox = self.editBox
+ if disabled then
+ editBox:ClearFocus()
+ editBox:EnableMouse(false)
+ editBox:SetTextColor(0.5, 0.5, 0.5)
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ self.scrollFrame:EnableMouse(false)
+ self.button:Disable()
+ else
+ editBox:EnableMouse(true)
+ editBox:SetTextColor(1, 1, 1)
+ self.label:SetTextColor(1, 0.82, 0)
+ self.scrollFrame:EnableMouse(true)
+ end
+ end,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ if self.labelHeight ~= 10 then
+ self.labelHeight = 10
+ self.label:Show()
+ end
+ elseif self.labelHeight ~= 0 then
+ self.labelHeight = 0
+ self.label:Hide()
+ end
+ Layout(self)
+ end,
+
+ ["SetNumLines"] = function(self, value)
+ if not value or value < 4 then
+ value = 4
+ end
+ self.numlines = value
+ Layout(self)
+ end,
+
+ ["SetText"] = function(self, text)
+ self.editBox:SetText(text)
+ end,
+
+ ["GetText"] = function(self)
+ return self.editBox:GetText()
+ end,
+
+ ["SetMaxLetters"] = function (self, num)
+ self.editBox:SetMaxLetters(num or 0)
+ end,
+
+ ["DisableButton"] = function(self, disabled)
+ self.disablebutton = disabled
+ if disabled then
+ self.button:Hide()
+ else
+ self.button:Show()
+ end
+ Layout(self)
+ end,
+
+ ["ClearFocus"] = function(self)
+ self.editBox:ClearFocus()
+ self.frame:SetScript("OnShow", nil)
+ end,
+
+ ["SetFocus"] = function(self)
+ self.editBox:SetFocus()
+ if not self.frame:IsShown() then
+ self.frame:SetScript("OnShow", OnShowFocus)
+ end
+ end,
+
+ ["HighlightText"] = function(self, from, to)
+ self.editBox:HighlightText(from, to)
+ end,
+
+ ["GetCursorPosition"] = function(self)
+ return self.editBox:GetCursorPosition()
+ end,
+
+ ["SetCursorPosition"] = function(self, ...)
+ return self.editBox:SetCursorPosition(...)
+ end,
+
+
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local backdrop = {
+ bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
+ edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
+ insets = { left = 4, right = 3, top = 4, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local widgetNum = AceGUI:GetNextWidgetNum(Type)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
+ label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4)
+ label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4)
+ label:SetJustifyH("LEFT")
+ label:SetText(ACCEPT)
+ label:SetHeight(10)
+
+ local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate")
+ button:SetPoint("BOTTOMLEFT", 0, 4)
+ button:SetHeight(22)
+ button:SetWidth(label:GetStringWidth() + 24)
+ button:SetText(ACCEPT)
+ button:SetScript("OnClick", OnClick)
+ button:Disable()
+
+ local text = button:GetFontString()
+ text:ClearAllPoints()
+ text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5)
+ text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1)
+ text:SetJustifyV("MIDDLE")
+
+ local scrollBG = CreateFrame("Frame", nil, frame)
+ scrollBG:SetBackdrop(backdrop)
+ scrollBG:SetBackdropColor(0, 0, 0)
+ scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
+
+ local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
+ scrollBar:ClearAllPoints()
+ scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19)
+ scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18)
+ scrollBar:SetPoint("RIGHT", frame, "RIGHT")
+
+ scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19)
+ scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT")
+
+ scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6)
+ scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4)
+ scrollFrame:SetScript("OnEnter", OnEnter)
+ scrollFrame:SetScript("OnLeave", OnLeave)
+ scrollFrame:SetScript("OnMouseUp", OnMouseUp)
+ scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
+ scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
+ scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
+
+ local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
+ editBox:SetAllPoints()
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetMultiLine(true)
+ editBox:EnableMouse(true)
+ editBox:SetAutoFocus(false)
+ editBox:SetCountInvisibleLetters(false)
+ editBox:SetScript("OnCursorChanged", OnCursorChanged)
+ editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
+ editBox:SetScript("OnEnter", OnEnter)
+ editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
+ editBox:SetScript("OnLeave", OnLeave)
+ editBox:SetScript("OnMouseDown", OnReceiveDrag)
+ editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
+ editBox:SetScript("OnTextChanged", OnTextChanged)
+ editBox:SetScript("OnTextSet", OnTextSet)
+ editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
+
+
+ scrollFrame:SetScrollChild(editBox)
+
+ local widget = {
+ button = button,
+ editBox = editBox,
+ frame = frame,
+ label = label,
+ labelHeight = 10,
+ numlines = 4,
+ scrollBar = scrollBar,
+ scrollBG = scrollBG,
+ scrollFrame = scrollFrame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua b/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua
new file mode 100644
index 0000000..20d0887
--- /dev/null
+++ b/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua
@@ -0,0 +1,285 @@
+--[[-----------------------------------------------------------------------------
+Slider Widget
+Graphical Slider, like, for Range values.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Slider", 22
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local min, max, floor = math.min, math.max, math.floor
+local tonumber, pairs = tonumber, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GameFontHighlightSmall
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function UpdateText(self)
+ local value = self.value or 0
+ if self.ispercent then
+ self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
+ else
+ self.editbox:SetText(floor(value * 100 + 0.5) / 100)
+ end
+end
+
+local function UpdateLabels(self)
+ local min, max = (self.min or 0), (self.max or 100)
+ if self.ispercent then
+ self.lowtext:SetFormattedText("%s%%", (min * 100))
+ self.hightext:SetFormattedText("%s%%", (max * 100))
+ else
+ self.lowtext:SetText(min)
+ self.hightext:SetText(max)
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Frame_OnMouseDown(frame)
+ frame.obj.slider:EnableMouseWheel(true)
+ AceGUI:ClearFocus()
+end
+
+local function Slider_OnValueChanged(frame)
+ local self = frame.obj
+ if not frame.setup then
+ local newvalue = frame:GetValue()
+ if self.step and self.step > 0 then
+ local min_value = self.min or 0
+ newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
+ end
+ if newvalue ~= self.value and not self.disabled then
+ self.value = newvalue
+ self:Fire("OnValueChanged", newvalue)
+ end
+ if self.value then
+ UpdateText(self)
+ end
+ end
+end
+
+local function Slider_OnMouseUp(frame)
+ local self = frame.obj
+ self:Fire("OnMouseUp", self.value)
+end
+
+local function Slider_OnMouseWheel(frame, v)
+ local self = frame.obj
+ if not self.disabled then
+ local value = self.value
+ if v > 0 then
+ value = min(value + (self.step or 1), self.max)
+ else
+ value = max(value - (self.step or 1), self.min)
+ end
+ self.slider:SetValue(value)
+ end
+end
+
+local function EditBox_OnEscapePressed(frame)
+ frame:ClearFocus()
+end
+
+local function EditBox_OnEnterPressed(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ if self.ispercent then
+ value = value:gsub('%%', '')
+ value = tonumber(value) / 100
+ else
+ value = tonumber(value)
+ end
+
+ if value then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ self.slider:SetValue(value)
+ self:Fire("OnMouseUp", value)
+ end
+end
+
+local function EditBox_OnEnter(frame)
+ frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
+end
+
+local function EditBox_OnLeave(frame)
+ frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(200)
+ self:SetHeight(44)
+ self:SetDisabled(false)
+ self:SetIsPercent(nil)
+ self:SetSliderValues(0,100,1)
+ self:SetValue(0)
+ self.slider:EnableMouseWheel(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.slider:EnableMouse(false)
+ self.label:SetTextColor(.5, .5, .5)
+ self.hightext:SetTextColor(.5, .5, .5)
+ self.lowtext:SetTextColor(.5, .5, .5)
+ --self.valuetext:SetTextColor(.5, .5, .5)
+ self.editbox:SetTextColor(.5, .5, .5)
+ self.editbox:EnableMouse(false)
+ self.editbox:ClearFocus()
+ else
+ self.slider:EnableMouse(true)
+ self.label:SetTextColor(1, .82, 0)
+ self.hightext:SetTextColor(1, 1, 1)
+ self.lowtext:SetTextColor(1, 1, 1)
+ --self.valuetext:SetTextColor(1, 1, 1)
+ self.editbox:SetTextColor(1, 1, 1)
+ self.editbox:EnableMouse(true)
+ end
+ end,
+
+ ["SetValue"] = function(self, value)
+ self.slider.setup = true
+ self.slider:SetValue(value)
+ self.value = value
+ UpdateText(self)
+ self.slider.setup = nil
+ end,
+
+ ["GetValue"] = function(self)
+ return self.value
+ end,
+
+ ["SetLabel"] = function(self, text)
+ self.label:SetText(text)
+ end,
+
+ ["SetSliderValues"] = function(self, min, max, step)
+ local frame = self.slider
+ frame.setup = true
+ self.min = min
+ self.max = max
+ self.step = step
+ frame:SetMinMaxValues(min or 0,max or 100)
+ UpdateLabels(self)
+ frame:SetValueStep(step or 1)
+ if self.value then
+ frame:SetValue(self.value)
+ end
+ frame.setup = nil
+ end,
+
+ ["SetIsPercent"] = function(self, value)
+ self.ispercent = value
+ UpdateLabels(self)
+ UpdateText(self)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local SliderBackdrop = {
+ bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
+ tile = true, tileSize = 8, edgeSize = 8,
+ insets = { left = 3, right = 3, top = 6, bottom = 6 }
+}
+
+local ManualBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ tile = true, edgeSize = 1, tileSize = 5,
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnMouseDown", Frame_OnMouseDown)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ label:SetPoint("TOPLEFT")
+ label:SetPoint("TOPRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetHeight(15)
+
+ local slider = CreateFrame("Slider", nil, frame)
+ slider:SetOrientation("HORIZONTAL")
+ slider:SetHeight(15)
+ slider:SetHitRectInsets(0, 0, -10, 0)
+ slider:SetBackdrop(SliderBackdrop)
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
+ slider:SetPoint("TOP", label, "BOTTOM")
+ slider:SetPoint("LEFT", 3, 0)
+ slider:SetPoint("RIGHT", -3, 0)
+ slider:SetValue(0)
+ slider:SetScript("OnValueChanged",Slider_OnValueChanged)
+ slider:SetScript("OnEnter", Control_OnEnter)
+ slider:SetScript("OnLeave", Control_OnLeave)
+ slider:SetScript("OnMouseUp", Slider_OnMouseUp)
+ slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
+
+ local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+ lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
+
+ local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+ hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
+
+ local editbox = CreateFrame("EditBox", nil, frame)
+ editbox:SetAutoFocus(false)
+ editbox:SetFontObject(GameFontHighlightSmall)
+ editbox:SetPoint("TOP", slider, "BOTTOM")
+ editbox:SetHeight(14)
+ editbox:SetWidth(70)
+ editbox:SetJustifyH("CENTER")
+ editbox:EnableMouse(true)
+ editbox:SetBackdrop(ManualBackdrop)
+ editbox:SetBackdropColor(0, 0, 0, 0.5)
+ editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80)
+ editbox:SetScript("OnEnter", EditBox_OnEnter)
+ editbox:SetScript("OnLeave", EditBox_OnLeave)
+ editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
+ editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
+
+ local widget = {
+ label = label,
+ slider = slider,
+ lowtext = lowtext,
+ hightext = hightext,
+ editbox = editbox,
+ alignoffset = 25,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ slider.obj, editbox.obj = widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type,Constructor,Version)
diff --git a/libs/AceLocale-3.0/AceLocale-3.0.lua b/libs/AceLocale-3.0/AceLocale-3.0.lua
new file mode 100644
index 0000000..e133781
--- /dev/null
+++ b/libs/AceLocale-3.0/AceLocale-3.0.lua
@@ -0,0 +1,137 @@
+--- **AceLocale-3.0** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings.
+-- @class file
+-- @name AceLocale-3.0
+-- @release $Id: AceLocale-3.0.lua 1035 2011-07-09 03:20:13Z kaelten $
+local MAJOR,MINOR = "AceLocale-3.0", 6
+
+local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceLocale then return end -- no upgrade needed
+
+-- Lua APIs
+local assert, tostring, error = assert, tostring, error
+local getmetatable, setmetatable, rawset, rawget = getmetatable, setmetatable, rawset, rawget
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: GAME_LOCALE, geterrorhandler
+
+local gameLocale = GetLocale()
+if gameLocale == "enGB" then
+ gameLocale = "enUS"
+end
+
+AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref
+AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName"
+
+-- This metatable is used on all tables returned from GetLocale
+local readmeta = {
+ __index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key
+ rawset(self, key, key) -- only need to see the warning once, really
+ geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'")
+ return key
+ end
+}
+
+-- This metatable is used on all tables returned from GetLocale if the silent flag is true, it does not issue a warning on unknown keys
+local readmetasilent = {
+ __index = function(self, key) -- requesting totally unknown entries: return key
+ rawset(self, key, key) -- only need to invoke this function once
+ return key
+ end
+}
+
+-- Remember the locale table being registered right now (it gets set by :NewLocale())
+-- NOTE: Do never try to register 2 locale tables at once and mix their definition.
+local registering
+
+-- local assert false function
+local assertfalse = function() assert(false) end
+
+-- This metatable proxy is used when registering nondefault locales
+local writeproxy = setmetatable({}, {
+ __newindex = function(self, key, value)
+ rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string
+ end,
+ __index = assertfalse
+})
+
+-- This metatable proxy is used when registering the default locale.
+-- It refuses to overwrite existing values
+-- Reason 1: Allows loading locales in any order
+-- Reason 2: If 2 modules have the same string, but only the first one to be
+-- loaded has a translation for the current locale, the translation
+-- doesn't get overwritten.
+--
+local writedefaultproxy = setmetatable({}, {
+ __newindex = function(self, key, value)
+ if not rawget(registering, key) then
+ rawset(registering, key, value == true and key or value)
+ end
+ end,
+ __index = assertfalse
+})
+
+--- Register a new locale (or extend an existing one) for the specified application.
+-- :NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players
+-- game locale.
+-- @paramsig application, locale[, isDefault[, silent]]
+-- @param application Unique name of addon / module
+-- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc.
+-- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS)
+-- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used).
+-- @usage
+-- -- enUS.lua
+-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true)
+-- L["string1"] = true
+--
+-- -- deDE.lua
+-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "deDE")
+-- if not L then return end
+-- L["string1"] = "Zeichenkette1"
+-- @return Locale Table to add localizations to, or nil if the current locale is not required.
+function AceLocale:NewLocale(application, locale, isDefault, silent)
+
+ -- GAME_LOCALE allows translators to test translations of addons without having that wow client installed
+ local gameLocale = GAME_LOCALE or gameLocale
+
+ local app = AceLocale.apps[application]
+
+ if silent and app and getmetatable(app) ~= readmetasilent then
+ geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered")
+ end
+
+ if not app then
+ if silent=="raw" then
+ app = {}
+ else
+ app = setmetatable({}, silent and readmetasilent or readmeta)
+ end
+ AceLocale.apps[application] = app
+ AceLocale.appnames[app] = application
+ end
+
+ if locale ~= gameLocale and not isDefault then
+ return -- nop, we don't need these translations
+ end
+
+ registering = app -- remember globally for writeproxy and writedefaultproxy
+
+ if isDefault then
+ return writedefaultproxy
+ end
+
+ return writeproxy
+end
+
+--- Returns localizations for the current locale (or default locale if translations are missing).
+-- Errors if nothing is registered (spank developer, not just a missing translation)
+-- @param application Unique name of addon / module
+-- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional)
+-- @return The locale table for the current language.
+function AceLocale:GetLocale(application, silent)
+ if not silent and not AceLocale.apps[application] then
+ error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2)
+ end
+ return AceLocale.apps[application]
+end
diff --git a/libs/AceLocale-3.0/AceLocale-3.0.xml b/libs/AceLocale-3.0/AceLocale-3.0.xml
new file mode 100644
index 0000000..bf023f0
--- /dev/null
+++ b/libs/AceLocale-3.0/AceLocale-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceSerializer-3.0/.svn/entries b/libs/AceSerializer-3.0/.svn/entries
new file mode 100644
index 0000000..48082f7
--- /dev/null
+++ b/libs/AceSerializer-3.0/.svn/entries
@@ -0,0 +1 @@
+12
diff --git a/libs/AceSerializer-3.0/.svn/format b/libs/AceSerializer-3.0/.svn/format
new file mode 100644
index 0000000..48082f7
--- /dev/null
+++ b/libs/AceSerializer-3.0/.svn/format
@@ -0,0 +1 @@
+12
diff --git a/libs/AceSerializer-3.0/.svn/pristine/60/606e6fbdb72ca67d2659397af03c60c0203076d4.svn-base b/libs/AceSerializer-3.0/.svn/pristine/60/606e6fbdb72ca67d2659397af03c60c0203076d4.svn-base
new file mode 100644
index 0000000..94924af
--- /dev/null
+++ b/libs/AceSerializer-3.0/.svn/pristine/60/606e6fbdb72ca67d2659397af03c60c0203076d4.svn-base
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/libs/AceSerializer-3.0/.svn/pristine/71/712f1f3a1256edfbea9eb1bd4d69f80609ae75dd.svn-base b/libs/AceSerializer-3.0/.svn/pristine/71/712f1f3a1256edfbea9eb1bd4d69f80609ae75dd.svn-base
new file mode 100644
index 0000000..064ece5
--- /dev/null
+++ b/libs/AceSerializer-3.0/.svn/pristine/71/712f1f3a1256edfbea9eb1bd4d69f80609ae75dd.svn-base
@@ -0,0 +1,283 @@
+--- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format,
+-- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially
+-- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple
+-- references to the same table will be send individually.
+--
+-- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceSerializer itself.\\
+-- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceSerializer.
+-- @class file
+-- @name AceSerializer-3.0
+-- @release $Id$
+local MAJOR,MINOR = "AceSerializer-3.0", 4
+local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceSerializer then return end
+
+-- Lua APIs
+local strbyte, strchar, gsub, gmatch, format = string.byte, string.char, string.gsub, string.gmatch, string.format
+local assert, error, pcall = assert, error, pcall
+local type, tostring, tonumber = type, tostring, tonumber
+local pairs, select, frexp = pairs, select, math.frexp
+local tconcat = table.concat
+
+-- quick copies of string representations of wonky numbers
+local inf = math.huge
+
+local serNaN -- can't do this in 4.3, see ace3 ticket 268
+local serInf = tostring(inf)
+local serNegInf = tostring(-inf)
+
+
+-- Serialization functions
+
+local function SerializeStringHelper(ch) -- Used by SerializeValue for strings
+ -- We use \126 ("~") as an escape character for all nonprints plus a few more
+ local n = strbyte(ch)
+ if n==30 then -- v3 / ticket 115: catch a nonprint that ends up being "~^" when encoded... DOH
+ return "\126\122"
+ elseif n<=32 then -- nonprint + space
+ return "\126"..strchar(n+64)
+ elseif n==94 then -- value separator
+ return "\126\125"
+ elseif n==126 then -- our own escape character
+ return "\126\124"
+ elseif n==127 then -- nonprint (DEL)
+ return "\126\123"
+ else
+ assert(false) -- can't be reached if caller uses a sane regex
+ end
+end
+
+local function SerializeValue(v, res, nres)
+ -- We use "^" as a value separator, followed by one byte for type indicator
+ local t=type(v)
+
+ if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc)
+ res[nres+1] = "^S"
+ res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper)
+ nres=nres+2
+
+ elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components)
+ local str = tostring(v)
+ if tonumber(str)==v --[[not in 4.3 or str==serNaN]] or str==serInf or str==serNegInf then
+ -- translates just fine, transmit as-is
+ res[nres+1] = "^N"
+ res[nres+2] = str
+ nres=nres+2
+ else
+ local m,e = frexp(v)
+ res[nres+1] = "^F"
+ res[nres+2] = format("%.0f",m*2^53) -- force mantissa to become integer (it's originally 0.5--0.9999)
+ res[nres+3] = "^f"
+ res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation
+ nres=nres+4
+ end
+
+ elseif t=="table" then -- ^T...^t = table (list of key,value pairs)
+ nres=nres+1
+ res[nres] = "^T"
+ for k,v in pairs(v) do
+ nres = SerializeValue(k, res, nres)
+ nres = SerializeValue(v, res, nres)
+ end
+ nres=nres+1
+ res[nres] = "^t"
+
+ elseif t=="boolean" then -- ^B = true, ^b = false
+ nres=nres+1
+ if v then
+ res[nres] = "^B" -- true
+ else
+ res[nres] = "^b" -- false
+ end
+
+ elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P)
+ nres=nres+1
+ res[nres] = "^Z"
+
+ else
+ error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive
+ end
+
+ return nres
+end
+
+
+
+local serializeTbl = { "^1" } -- "^1" = Hi, I'm data serialized by AceSerializer protocol rev 1
+
+--- Serialize the data passed into the function.
+-- Takes a list of values (strings, numbers, booleans, nils, tables)
+-- and returns it in serialized form (a string).\\
+-- May throw errors on invalid data types.
+-- @param ... List of values to serialize
+-- @return The data in its serialized form (string)
+function AceSerializer:Serialize(...)
+ local nres = 1
+
+ for i=1,select("#", ...) do
+ local v = select(i, ...)
+ nres = SerializeValue(v, serializeTbl, nres)
+ end
+
+ serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data
+
+ return tconcat(serializeTbl, "", 1, nres+1)
+end
+
+-- Deserialization functions
+local function DeserializeStringHelper(escape)
+ if escape<"~\122" then
+ return strchar(strbyte(escape,2,2)-64)
+ elseif escape=="~\122" then -- v3 / ticket 115: special case encode since 30+64=94 ("^") - OOPS.
+ return "\030"
+ elseif escape=="~\123" then
+ return "\127"
+ elseif escape=="~\124" then
+ return "\126"
+ elseif escape=="~\125" then
+ return "\94"
+ end
+ error("DeserializeStringHelper got called for '"..escape.."'?!?") -- can't be reached unless regex is screwed up
+end
+
+local function DeserializeNumberHelper(number)
+ --[[ not in 4.3 if number == serNaN then
+ return 0/0
+ else]]if number == serNegInf then
+ return -inf
+ elseif number == serInf then
+ return inf
+ else
+ return tonumber(number)
+ end
+end
+
+-- DeserializeValue: worker function for :Deserialize()
+-- It works in two modes:
+-- Main (top-level) mode: Deserialize a list of values and return them all
+-- Recursive (table) mode: Deserialize only a single value (_may_ of course be another table with lots of subvalues in it)
+--
+-- The function _always_ works recursively due to having to build a list of values to return
+--
+-- Callers are expected to pcall(DeserializeValue) to trap errors
+
+local function DeserializeValue(iter,single,ctl,data)
+
+ if not single then
+ ctl,data = iter()
+ end
+
+ if not ctl then
+ error("Supplied data misses AceSerializer terminator ('^^')")
+ end
+
+ if ctl=="^^" then
+ -- ignore extraneous data
+ return
+ end
+
+ local res
+
+ if ctl=="^S" then
+ res = gsub(data, "~.", DeserializeStringHelper)
+ elseif ctl=="^N" then
+ res = DeserializeNumberHelper(data)
+ if not res then
+ error("Invalid serialized number: '"..tostring(data).."'")
+ end
+ elseif ctl=="^F" then -- ^F^f
+ local ctl2,e = iter()
+ if ctl2~="^f" then
+ error("Invalid serialized floating-point number, expected '^f', not '"..tostring(ctl2).."'")
+ end
+ local m=tonumber(data)
+ e=tonumber(e)
+ if not (m and e) then
+ error("Invalid serialized floating-point number, expected mantissa and exponent, got '"..tostring(m).."' and '"..tostring(e).."'")
+ end
+ res = m*(2^e)
+ elseif ctl=="^B" then -- yeah yeah ignore data portion
+ res = true
+ elseif ctl=="^b" then -- yeah yeah ignore data portion
+ res = false
+ elseif ctl=="^Z" then -- yeah yeah ignore data portion
+ res = nil
+ elseif ctl=="^T" then
+ -- ignore ^T's data, future extensibility?
+ res = {}
+ local k,v
+ while true do
+ ctl,data = iter()
+ if ctl=="^t" then break end -- ignore ^t's data
+ k = DeserializeValue(iter,true,ctl,data)
+ if k==nil then
+ error("Invalid AceSerializer table format (no table end marker)")
+ end
+ ctl,data = iter()
+ v = DeserializeValue(iter,true,ctl,data)
+ if v==nil then
+ error("Invalid AceSerializer table format (no table end marker)")
+ end
+ res[k]=v
+ end
+ else
+ error("Invalid AceSerializer control code '"..ctl.."'")
+ end
+
+ if not single then
+ return res,DeserializeValue(iter)
+ else
+ return res
+ end
+end
+
+--- Deserializes the data into its original values.
+-- Accepts serialized data, ignoring all control characters and whitespace.
+-- @param str The serialized data (from :Serialize)
+-- @return true followed by a list of values, OR false followed by an error message
+function AceSerializer:Deserialize(str)
+ str = gsub(str, "[%c ]", "") -- ignore all control characters; nice for embedding in email and stuff
+
+ local iter = gmatch(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^
+ local ctl,data = iter()
+ if not ctl or ctl~="^1" then
+ -- we purposefully ignore the data portion of the start code, it can be used as an extension mechanism
+ return false, "Supplied data is not AceSerializer data (rev 1)"
+ end
+
+ return pcall(DeserializeValue, iter)
+end
+
+
+----------------------------------------
+-- Base library stuff
+----------------------------------------
+
+AceSerializer.internals = { -- for test scripts
+ SerializeValue = SerializeValue,
+ SerializeStringHelper = SerializeStringHelper,
+}
+
+local mixins = {
+ "Serialize",
+ "Deserialize",
+}
+
+AceSerializer.embeds = AceSerializer.embeds or {}
+
+function AceSerializer:Embed(target)
+ for k, v in pairs(mixins) do
+ target[v] = self[v]
+ end
+ self.embeds[target] = true
+ return target
+end
+
+-- Update embeds
+for target, v in pairs(AceSerializer.embeds) do
+ AceSerializer:Embed(target)
+end
\ No newline at end of file
diff --git a/libs/AceSerializer-3.0/.svn/wc.db b/libs/AceSerializer-3.0/.svn/wc.db
new file mode 100644
index 0000000..e38c4c4
Binary files /dev/null and b/libs/AceSerializer-3.0/.svn/wc.db differ
diff --git a/libs/AceSerializer-3.0/AceSerializer-3.0.lua b/libs/AceSerializer-3.0/AceSerializer-3.0.lua
new file mode 100644
index 0000000..0b19e08
--- /dev/null
+++ b/libs/AceSerializer-3.0/AceSerializer-3.0.lua
@@ -0,0 +1,287 @@
+--- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format,
+-- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially
+-- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple
+-- references to the same table will be send individually.
+--
+-- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceSerializer itself.\\
+-- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceSerializer.
+-- @class file
+-- @name AceSerializer-3.0
+-- @release $Id: AceSerializer-3.0.lua 1135 2015-09-19 20:39:16Z nevcairiel $
+local MAJOR,MINOR = "AceSerializer-3.0", 5
+local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceSerializer then return end
+
+-- Lua APIs
+local strbyte, strchar, gsub, gmatch, format = string.byte, string.char, string.gsub, string.gmatch, string.format
+local assert, error, pcall = assert, error, pcall
+local type, tostring, tonumber = type, tostring, tonumber
+local pairs, select, frexp = pairs, select, math.frexp
+local tconcat = table.concat
+
+-- quick copies of string representations of wonky numbers
+local inf = math.huge
+
+local serNaN -- can't do this in 4.3, see ace3 ticket 268
+local serInf, serInfMac = "1.#INF", "inf"
+local serNegInf, serNegInfMac = "-1.#INF", "-inf"
+
+
+-- Serialization functions
+
+local function SerializeStringHelper(ch) -- Used by SerializeValue for strings
+ -- We use \126 ("~") as an escape character for all nonprints plus a few more
+ local n = strbyte(ch)
+ if n==30 then -- v3 / ticket 115: catch a nonprint that ends up being "~^" when encoded... DOH
+ return "\126\122"
+ elseif n<=32 then -- nonprint + space
+ return "\126"..strchar(n+64)
+ elseif n==94 then -- value separator
+ return "\126\125"
+ elseif n==126 then -- our own escape character
+ return "\126\124"
+ elseif n==127 then -- nonprint (DEL)
+ return "\126\123"
+ else
+ assert(false) -- can't be reached if caller uses a sane regex
+ end
+end
+
+local function SerializeValue(v, res, nres)
+ -- We use "^" as a value separator, followed by one byte for type indicator
+ local t=type(v)
+
+ if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc)
+ res[nres+1] = "^S"
+ res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper)
+ nres=nres+2
+
+ elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components)
+ local str = tostring(v)
+ if tonumber(str)==v --[[not in 4.3 or str==serNaN]] then
+ -- translates just fine, transmit as-is
+ res[nres+1] = "^N"
+ res[nres+2] = str
+ nres=nres+2
+ elseif v == inf or v == -inf then
+ res[nres+1] = "^N"
+ res[nres+2] = v == inf and serInf or serNegInf
+ nres=nres+2
+ else
+ local m,e = frexp(v)
+ res[nres+1] = "^F"
+ res[nres+2] = format("%.0f",m*2^53) -- force mantissa to become integer (it's originally 0.5--0.9999)
+ res[nres+3] = "^f"
+ res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation
+ nres=nres+4
+ end
+
+ elseif t=="table" then -- ^T...^t = table (list of key,value pairs)
+ nres=nres+1
+ res[nres] = "^T"
+ for k,v in pairs(v) do
+ nres = SerializeValue(k, res, nres)
+ nres = SerializeValue(v, res, nres)
+ end
+ nres=nres+1
+ res[nres] = "^t"
+
+ elseif t=="boolean" then -- ^B = true, ^b = false
+ nres=nres+1
+ if v then
+ res[nres] = "^B" -- true
+ else
+ res[nres] = "^b" -- false
+ end
+
+ elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P)
+ nres=nres+1
+ res[nres] = "^Z"
+
+ else
+ error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive
+ end
+
+ return nres
+end
+
+
+
+local serializeTbl = { "^1" } -- "^1" = Hi, I'm data serialized by AceSerializer protocol rev 1
+
+--- Serialize the data passed into the function.
+-- Takes a list of values (strings, numbers, booleans, nils, tables)
+-- and returns it in serialized form (a string).\\
+-- May throw errors on invalid data types.
+-- @param ... List of values to serialize
+-- @return The data in its serialized form (string)
+function AceSerializer:Serialize(...)
+ local nres = 1
+
+ for i=1,select("#", ...) do
+ local v = select(i, ...)
+ nres = SerializeValue(v, serializeTbl, nres)
+ end
+
+ serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data
+
+ return tconcat(serializeTbl, "", 1, nres+1)
+end
+
+-- Deserialization functions
+local function DeserializeStringHelper(escape)
+ if escape<"~\122" then
+ return strchar(strbyte(escape,2,2)-64)
+ elseif escape=="~\122" then -- v3 / ticket 115: special case encode since 30+64=94 ("^") - OOPS.
+ return "\030"
+ elseif escape=="~\123" then
+ return "\127"
+ elseif escape=="~\124" then
+ return "\126"
+ elseif escape=="~\125" then
+ return "\94"
+ end
+ error("DeserializeStringHelper got called for '"..escape.."'?!?") -- can't be reached unless regex is screwed up
+end
+
+local function DeserializeNumberHelper(number)
+ --[[ not in 4.3 if number == serNaN then
+ return 0/0
+ else]]if number == serNegInf or number == serNegInfMac then
+ return -inf
+ elseif number == serInf or number == serInfMac then
+ return inf
+ else
+ return tonumber(number)
+ end
+end
+
+-- DeserializeValue: worker function for :Deserialize()
+-- It works in two modes:
+-- Main (top-level) mode: Deserialize a list of values and return them all
+-- Recursive (table) mode: Deserialize only a single value (_may_ of course be another table with lots of subvalues in it)
+--
+-- The function _always_ works recursively due to having to build a list of values to return
+--
+-- Callers are expected to pcall(DeserializeValue) to trap errors
+
+local function DeserializeValue(iter,single,ctl,data)
+
+ if not single then
+ ctl,data = iter()
+ end
+
+ if not ctl then
+ error("Supplied data misses AceSerializer terminator ('^^')")
+ end
+
+ if ctl=="^^" then
+ -- ignore extraneous data
+ return
+ end
+
+ local res
+
+ if ctl=="^S" then
+ res = gsub(data, "~.", DeserializeStringHelper)
+ elseif ctl=="^N" then
+ res = DeserializeNumberHelper(data)
+ if not res then
+ error("Invalid serialized number: '"..tostring(data).."'")
+ end
+ elseif ctl=="^F" then -- ^F^f
+ local ctl2,e = iter()
+ if ctl2~="^f" then
+ error("Invalid serialized floating-point number, expected '^f', not '"..tostring(ctl2).."'")
+ end
+ local m=tonumber(data)
+ e=tonumber(e)
+ if not (m and e) then
+ error("Invalid serialized floating-point number, expected mantissa and exponent, got '"..tostring(m).."' and '"..tostring(e).."'")
+ end
+ res = m*(2^e)
+ elseif ctl=="^B" then -- yeah yeah ignore data portion
+ res = true
+ elseif ctl=="^b" then -- yeah yeah ignore data portion
+ res = false
+ elseif ctl=="^Z" then -- yeah yeah ignore data portion
+ res = nil
+ elseif ctl=="^T" then
+ -- ignore ^T's data, future extensibility?
+ res = {}
+ local k,v
+ while true do
+ ctl,data = iter()
+ if ctl=="^t" then break end -- ignore ^t's data
+ k = DeserializeValue(iter,true,ctl,data)
+ if k==nil then
+ error("Invalid AceSerializer table format (no table end marker)")
+ end
+ ctl,data = iter()
+ v = DeserializeValue(iter,true,ctl,data)
+ if v==nil then
+ error("Invalid AceSerializer table format (no table end marker)")
+ end
+ res[k]=v
+ end
+ else
+ error("Invalid AceSerializer control code '"..ctl.."'")
+ end
+
+ if not single then
+ return res,DeserializeValue(iter)
+ else
+ return res
+ end
+end
+
+--- Deserializes the data into its original values.
+-- Accepts serialized data, ignoring all control characters and whitespace.
+-- @param str The serialized data (from :Serialize)
+-- @return true followed by a list of values, OR false followed by an error message
+function AceSerializer:Deserialize(str)
+ str = gsub(str, "[%c ]", "") -- ignore all control characters; nice for embedding in email and stuff
+
+ local iter = gmatch(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^
+ local ctl,data = iter()
+ if not ctl or ctl~="^1" then
+ -- we purposefully ignore the data portion of the start code, it can be used as an extension mechanism
+ return false, "Supplied data is not AceSerializer data (rev 1)"
+ end
+
+ return pcall(DeserializeValue, iter)
+end
+
+
+----------------------------------------
+-- Base library stuff
+----------------------------------------
+
+AceSerializer.internals = { -- for test scripts
+ SerializeValue = SerializeValue,
+ SerializeStringHelper = SerializeStringHelper,
+}
+
+local mixins = {
+ "Serialize",
+ "Deserialize",
+}
+
+AceSerializer.embeds = AceSerializer.embeds or {}
+
+function AceSerializer:Embed(target)
+ for k, v in pairs(mixins) do
+ target[v] = self[v]
+ end
+ self.embeds[target] = true
+ return target
+end
+
+-- Update embeds
+for target, v in pairs(AceSerializer.embeds) do
+ AceSerializer:Embed(target)
+end
diff --git a/libs/AceSerializer-3.0/AceSerializer-3.0.xml b/libs/AceSerializer-3.0/AceSerializer-3.0.xml
new file mode 100644
index 0000000..677d08e
--- /dev/null
+++ b/libs/AceSerializer-3.0/AceSerializer-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/AceTimer-3.0/AceTimer-3.0.lua b/libs/AceTimer-3.0/AceTimer-3.0.lua
new file mode 100644
index 0000000..336864b
--- /dev/null
+++ b/libs/AceTimer-3.0/AceTimer-3.0.lua
@@ -0,0 +1,278 @@
+--- **AceTimer-3.0** provides a central facility for registering timers.
+-- AceTimer supports one-shot timers and repeating timers. All timers are stored in an efficient
+-- data structure that allows easy dispatching and fast rescheduling. Timers can be registered
+-- or canceled at any time, even from within a running timer, without conflict or large overhead.\\
+-- AceTimer is currently limited to firing timers at a frequency of 0.01s as this is what the WoW timer API
+-- restricts us to.
+--
+-- All `:Schedule` functions will return a handle to the current timer, which you will need to store if you
+-- need to cancel the timer you just registered.
+--
+-- **AceTimer-3.0** can be embeded into your addon, either explicitly by calling AceTimer:Embed(MyAddon) or by
+-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
+-- and can be accessed directly, without having to explicitly call AceTimer itself.\\
+-- It is recommended to embed AceTimer, otherwise you'll have to specify a custom `self` on all calls you
+-- make into AceTimer.
+-- @class file
+-- @name AceTimer-3.0
+-- @release $Id: AceTimer-3.0.lua 1170 2018-03-29 17:38:58Z funkydude $
+
+local MAJOR, MINOR = "AceTimer-3.0", 17 -- Bump minor on changes
+local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceTimer then return end -- No upgrade needed
+AceTimer.activeTimers = AceTimer.activeTimers or {} -- Active timer list
+local activeTimers = AceTimer.activeTimers -- Upvalue our private data
+
+-- Lua APIs
+local type, unpack, next, error, select = type, unpack, next, error, select
+-- WoW APIs
+local GetTime, C_TimerAfter = GetTime, C_Timer.After
+
+local function new(self, loop, func, delay, ...)
+ if delay < 0.01 then
+ delay = 0.01 -- Restrict to the lowest time that the C_Timer API allows us
+ end
+
+ local timer = {
+ object = self,
+ func = func,
+ looping = loop,
+ argsCount = select("#", ...),
+ delay = delay,
+ ends = GetTime() + delay,
+ ...
+ }
+
+ activeTimers[timer] = timer
+
+ -- Create new timer closure to wrap the "timer" object
+ timer.callback = function()
+ if not timer.cancelled then
+ if type(timer.func) == "string" then
+ -- We manually set the unpack count to prevent issues with an arg set that contains nil and ends with nil
+ -- e.g. local t = {1, 2, nil, 3, nil} print(#t) will result in 2, instead of 5. This fixes said issue.
+ timer.object[timer.func](timer.object, unpack(timer, 1, timer.argsCount))
+ else
+ timer.func(unpack(timer, 1, timer.argsCount))
+ end
+
+ if timer.looping and not timer.cancelled then
+ -- Compensate delay to get a perfect average delay, even if individual times don't match up perfectly
+ -- due to fps differences
+ local time = GetTime()
+ local delay = timer.delay - (time - timer.ends)
+ -- Ensure the delay doesn't go below the threshold
+ if delay < 0.01 then delay = 0.01 end
+ C_TimerAfter(delay, timer.callback)
+ timer.ends = time + delay
+ else
+ activeTimers[timer.handle or timer] = nil
+ end
+ end
+ end
+
+ C_TimerAfter(delay, timer.callback)
+ return timer
+end
+
+--- Schedule a new one-shot timer.
+-- The timer will fire once in `delay` seconds, unless canceled before.
+-- @param callback Callback function for the timer pulse (funcref or method name).
+-- @param delay Delay for the timer, in seconds.
+-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
+-- @usage
+-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
+--
+-- function MyAddOn:OnEnable()
+-- self:ScheduleTimer("TimerFeedback", 5)
+-- end
+--
+-- function MyAddOn:TimerFeedback()
+-- print("5 seconds passed")
+-- end
+function AceTimer:ScheduleTimer(func, delay, ...)
+ if not func or not delay then
+ error(MAJOR..": ScheduleTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
+ end
+ if type(func) == "string" then
+ if type(self) ~= "table" then
+ error(MAJOR..": ScheduleTimer(callback, delay, args...): 'self' - must be a table.", 2)
+ elseif not self[func] then
+ error(MAJOR..": ScheduleTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
+ end
+ end
+ return new(self, nil, func, delay, ...)
+end
+
+--- Schedule a repeating timer.
+-- The timer will fire every `delay` seconds, until canceled.
+-- @param callback Callback function for the timer pulse (funcref or method name).
+-- @param delay Delay for the timer, in seconds.
+-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
+-- @usage
+-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
+--
+-- function MyAddOn:OnEnable()
+-- self.timerCount = 0
+-- self.testTimer = self:ScheduleRepeatingTimer("TimerFeedback", 5)
+-- end
+--
+-- function MyAddOn:TimerFeedback()
+-- self.timerCount = self.timerCount + 1
+-- print(("%d seconds passed"):format(5 * self.timerCount))
+-- -- run 30 seconds in total
+-- if self.timerCount == 6 then
+-- self:CancelTimer(self.testTimer)
+-- end
+-- end
+function AceTimer:ScheduleRepeatingTimer(func, delay, ...)
+ if not func or not delay then
+ error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
+ end
+ if type(func) == "string" then
+ if type(self) ~= "table" then
+ error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'self' - must be a table.", 2)
+ elseif not self[func] then
+ error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
+ end
+ end
+ return new(self, true, func, delay, ...)
+end
+
+--- Cancels a timer with the given id, registered by the same addon object as used for `:ScheduleTimer`
+-- Both one-shot and repeating timers can be canceled with this function, as long as the `id` is valid
+-- and the timer has not fired yet or was canceled before.
+-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
+function AceTimer:CancelTimer(id)
+ local timer = activeTimers[id]
+
+ if not timer then
+ return false
+ else
+ timer.cancelled = true
+ activeTimers[id] = nil
+ return true
+ end
+end
+
+--- Cancels all timers registered to the current addon object ('self')
+function AceTimer:CancelAllTimers()
+ for k,v in next, activeTimers do
+ if v.object == self then
+ AceTimer.CancelTimer(self, k)
+ end
+ end
+end
+
+--- Returns the time left for a timer with the given id, registered by the current addon object ('self').
+-- This function will return 0 when the id is invalid.
+-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
+-- @return The time left on the timer.
+function AceTimer:TimeLeft(id)
+ local timer = activeTimers[id]
+ if not timer then
+ return 0
+ else
+ return timer.ends - GetTime()
+ end
+end
+
+
+-- ---------------------------------------------------------------------
+-- Upgrading
+
+-- Upgrade from old hash-bucket based timers to C_Timer.After timers.
+if oldminor and oldminor < 10 then
+ -- disable old timer logic
+ AceTimer.frame:SetScript("OnUpdate", nil)
+ AceTimer.frame:SetScript("OnEvent", nil)
+ AceTimer.frame:UnregisterAllEvents()
+ -- convert timers
+ for object,timers in next, AceTimer.selfs do
+ for handle,timer in next, timers do
+ if type(timer) == "table" and timer.callback then
+ local newTimer
+ if timer.delay then
+ newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.callback, timer.delay, timer.arg)
+ else
+ newTimer = AceTimer.ScheduleTimer(timer.object, timer.callback, timer.when - GetTime(), timer.arg)
+ end
+ -- Use the old handle for old timers
+ activeTimers[newTimer] = nil
+ activeTimers[handle] = newTimer
+ newTimer.handle = handle
+ end
+ end
+ end
+ AceTimer.selfs = nil
+ AceTimer.hash = nil
+ AceTimer.debug = nil
+elseif oldminor and oldminor < 17 then
+ -- Upgrade from old animation based timers to C_Timer.After timers.
+ AceTimer.inactiveTimers = nil
+ AceTimer.frame = nil
+ local oldTimers = AceTimer.activeTimers
+ -- Clear old timer table and update upvalue
+ AceTimer.activeTimers = {}
+ activeTimers = AceTimer.activeTimers
+ for handle, timer in next, oldTimers do
+ local newTimer
+ -- Stop the old timer animation
+ local duration, elapsed = timer:GetDuration(), timer:GetElapsed()
+ timer:GetParent():Stop()
+ if timer.looping then
+ newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.func, duration, unpack(timer.args, 1, timer.argsCount))
+ else
+ newTimer = AceTimer.ScheduleTimer(timer.object, timer.func, duration - elapsed, unpack(timer.args, 1, timer.argsCount))
+ end
+ -- Use the old handle for old timers
+ activeTimers[newTimer] = nil
+ activeTimers[handle] = newTimer
+ newTimer.handle = handle
+ end
+
+ -- Migrate transitional handles
+ if oldminor < 13 and AceTimer.hashCompatTable then
+ for handle, id in next, AceTimer.hashCompatTable do
+ local t = activeTimers[id]
+ if t then
+ activeTimers[id] = nil
+ activeTimers[handle] = t
+ t.handle = handle
+ end
+ end
+ AceTimer.hashCompatTable = nil
+ end
+end
+
+-- ---------------------------------------------------------------------
+-- Embed handling
+
+AceTimer.embeds = AceTimer.embeds or {}
+
+local mixins = {
+ "ScheduleTimer", "ScheduleRepeatingTimer",
+ "CancelTimer", "CancelAllTimers",
+ "TimeLeft"
+}
+
+function AceTimer:Embed(target)
+ AceTimer.embeds[target] = true
+ for _,v in next, mixins do
+ target[v] = AceTimer[v]
+ end
+ return target
+end
+
+-- AceTimer:OnEmbedDisable(target)
+-- target (object) - target object that AceTimer is embedded in.
+--
+-- cancel all timers registered for the object
+function AceTimer:OnEmbedDisable(target)
+ target:CancelAllTimers()
+end
+
+for addon in next, AceTimer.embeds do
+ AceTimer:Embed(addon)
+end
diff --git a/libs/AceTimer-3.0/AceTimer-3.0.xml b/libs/AceTimer-3.0/AceTimer-3.0.xml
new file mode 100644
index 0000000..d5aee81
--- /dev/null
+++ b/libs/AceTimer-3.0/AceTimer-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua b/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
new file mode 100644
index 0000000..675d7b0
--- /dev/null
+++ b/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
@@ -0,0 +1,238 @@
+--[[ $Id: CallbackHandler-1.0.lua 1131 2015-06-04 07:29:24Z nevcairiel $ ]]
+local MAJOR, MINOR = "CallbackHandler-1.0", 6
+local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not CallbackHandler then return end -- No upgrade needed
+
+local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
+
+-- Lua APIs
+local tconcat = table.concat
+local assert, error, loadstring = assert, error, loadstring
+local setmetatable, rawset, rawget = setmetatable, rawset, rawget
+local next, select, pairs, type, tostring = next, select, pairs, type, tostring
+
+-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
+-- List them here for Mikk's FindGlobals script
+-- GLOBALS: geterrorhandler
+
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function CreateDispatcher(argCount)
+ local code = [[
+ local next, xpcall, eh = ...
+
+ local method, ARGS
+ local function call() method(ARGS) end
+
+ local function dispatch(handlers, ...)
+ local index
+ index, method = next(handlers)
+ if not method then return end
+ local OLD_ARGS = ARGS
+ ARGS = ...
+ repeat
+ xpcall(call, eh)
+ index, method = next(handlers, index)
+ until not method
+ ARGS = OLD_ARGS
+ end
+
+ return dispatch
+ ]]
+
+ local ARGS, OLD_ARGS = {}, {}
+ for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
+ code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
+ return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
+end
+
+local Dispatchers = setmetatable({}, {__index=function(self, argCount)
+ local dispatcher = CreateDispatcher(argCount)
+ rawset(self, argCount, dispatcher)
+ return dispatcher
+end})
+
+--------------------------------------------------------------------------
+-- CallbackHandler:New
+--
+-- target - target object to embed public APIs in
+-- RegisterName - name of the callback registration API, default "RegisterCallback"
+-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
+-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
+
+function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
+
+ RegisterName = RegisterName or "RegisterCallback"
+ UnregisterName = UnregisterName or "UnregisterCallback"
+ if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
+ UnregisterAllName = "UnregisterAllCallbacks"
+ end
+
+ -- we declare all objects and exported APIs inside this closure to quickly gain access
+ -- to e.g. function names, the "target" parameter, etc
+
+
+ -- Create the registry object
+ local events = setmetatable({}, meta)
+ local registry = { recurse=0, events=events }
+
+ -- registry:Fire() - fires the given event/message into the registry
+ function registry:Fire(eventname, ...)
+ if not rawget(events, eventname) or not next(events[eventname]) then return end
+ local oldrecurse = registry.recurse
+ registry.recurse = oldrecurse + 1
+
+ Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
+
+ registry.recurse = oldrecurse
+
+ if registry.insertQueue and oldrecurse==0 then
+ -- Something in one of our callbacks wanted to register more callbacks; they got queued
+ for eventname,callbacks in pairs(registry.insertQueue) do
+ local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
+ for self,func in pairs(callbacks) do
+ events[eventname][self] = func
+ -- fire OnUsed callback?
+ if first and registry.OnUsed then
+ registry.OnUsed(registry, target, eventname)
+ first = nil
+ end
+ end
+ end
+ registry.insertQueue = nil
+ end
+ end
+
+ -- Registration of a callback, handles:
+ -- self["method"], leads to self["method"](self, ...)
+ -- self with function ref, leads to functionref(...)
+ -- "addonId" (instead of self) with function ref, leads to functionref(...)
+ -- all with an optional arg, which, if present, gets passed as first argument (after self if present)
+ target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
+ if type(eventname) ~= "string" then
+ error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
+ end
+
+ method = method or eventname
+
+ local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
+
+ if type(method) ~= "string" and type(method) ~= "function" then
+ error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
+ end
+
+ local regfunc
+
+ if type(method) == "string" then
+ -- self["method"] calling style
+ if type(self) ~= "table" then
+ error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
+ elseif self==target then
+ error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
+ elseif type(self[method]) ~= "function" then
+ error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
+ end
+
+ if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
+ local arg=select(1,...)
+ regfunc = function(...) self[method](self,arg,...) end
+ else
+ regfunc = function(...) self[method](self,...) end
+ end
+ else
+ -- function ref with self=object or self="addonId" or self=thread
+ if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
+ error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
+ end
+
+ if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
+ local arg=select(1,...)
+ regfunc = function(...) method(arg,...) end
+ else
+ regfunc = method
+ end
+ end
+
+
+ if events[eventname][self] or registry.recurse<1 then
+ -- if registry.recurse<1 then
+ -- we're overwriting an existing entry, or not currently recursing. just set it.
+ events[eventname][self] = regfunc
+ -- fire OnUsed callback?
+ if registry.OnUsed and first then
+ registry.OnUsed(registry, target, eventname)
+ end
+ else
+ -- we're currently processing a callback in this registry, so delay the registration of this new entry!
+ -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
+ registry.insertQueue = registry.insertQueue or setmetatable({},meta)
+ registry.insertQueue[eventname][self] = regfunc
+ end
+ end
+
+ -- Unregister a callback
+ target[UnregisterName] = function(self, eventname)
+ if not self or self==target then
+ error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
+ end
+ if type(eventname) ~= "string" then
+ error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
+ end
+ if rawget(events, eventname) and events[eventname][self] then
+ events[eventname][self] = nil
+ -- Fire OnUnused callback?
+ if registry.OnUnused and not next(events[eventname]) then
+ registry.OnUnused(registry, target, eventname)
+ end
+ end
+ if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
+ registry.insertQueue[eventname][self] = nil
+ end
+ end
+
+ -- OPTIONAL: Unregister all callbacks for given selfs/addonIds
+ if UnregisterAllName then
+ target[UnregisterAllName] = function(...)
+ if select("#",...)<1 then
+ error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
+ end
+ if select("#",...)==1 and ...==target then
+ error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
+ end
+
+
+ for i=1,select("#",...) do
+ local self = select(i,...)
+ if registry.insertQueue then
+ for eventname, callbacks in pairs(registry.insertQueue) do
+ if callbacks[self] then
+ callbacks[self] = nil
+ end
+ end
+ end
+ for eventname, callbacks in pairs(events) do
+ if callbacks[self] then
+ callbacks[self] = nil
+ -- Fire OnUnused callback?
+ if registry.OnUnused and not next(callbacks) then
+ registry.OnUnused(registry, target, eventname)
+ end
+ end
+ end
+ end
+ end
+ end
+
+ return registry
+end
+
+
+-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
+-- try to upgrade old implicit embeds since the system is selfcontained and
+-- relies on closures to work.
+
diff --git a/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml b/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
new file mode 100644
index 0000000..c107f88
--- /dev/null
+++ b/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/DF/addon.lua b/libs/DF/addon.lua
new file mode 100644
index 0000000..c7f92ef
--- /dev/null
+++ b/libs/DF/addon.lua
@@ -0,0 +1,62 @@
+
+local DF = _G ["DetailsFramework"]
+local _
+
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+function DF:CreateAddOn (name, global_saved, global_table, options_table, broker)
+
+ local addon = LibStub ("AceAddon-3.0"):NewAddon (name, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "DetailsFramework-1.0", "AceComm-3.0")
+ _G [name] = addon
+ addon.__name = name
+
+ function addon:OnInitialize()
+
+ if (global_saved) then
+ if (broker and broker.Minimap and not global_table.Minimap) then
+ DF:Msg (name, "broker.Minimap is true but no global.Minimap declared.")
+ end
+ self.db = LibStub ("AceDB-3.0"):New (global_saved, global_table or {}, true)
+ end
+
+ if (options_table) then
+ LibStub ("AceConfig-3.0"):RegisterOptionsTable (name, options_table)
+ addon.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions (name, name)
+
+ LibStub ("AceConfig-3.0"):RegisterOptionsTable (name .. "-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
+ addon.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions (name .. "-Profiles", "Profiles", name)
+ end
+
+ if (broker) then
+ local broker_click_function = broker.OnClick
+ if (not broker_click_function and options_table) then
+ broker_click_function = function()
+ InterfaceOptionsFrame_OpenToCategory (name)
+ InterfaceOptionsFrame_OpenToCategory (name)
+ end
+ end
+
+ local databroker = LibStub ("LibDataBroker-1.1"):NewDataObject (name, {
+ type = broker.type or "launcher",
+ icon = broker.icon or [[Interface\PvPRankBadges\PvPRank15]],
+ text = broker.text or "",
+ OnTooltipShow = broker.OnTooltipShow,
+ OnClick = broker_click_function
+ })
+
+ if (databroker and broker.Minimap and global_table.Minimap) then
+ LibStub ("LibDBIcon-1.0"):Register (name, databroker, addon.db.profile.Minimap)
+ end
+ end
+
+ if (addon.OnInit) then
+ xpcall (addon.OnInit, geterrorhandler(), addon)
+ end
+
+ end
+
+ return addon
+
+end
diff --git a/libs/DF/auras.lua b/libs/DF/auras.lua
new file mode 100644
index 0000000..345ede7
--- /dev/null
+++ b/libs/DF/auras.lua
@@ -0,0 +1,1069 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local tinsert = tinsert
+local GetSpellInfo = GetSpellInfo
+local lower = string.lower
+local GetSpellBookItemInfo = GetSpellBookItemInfo
+
+local CONST_MAX_SPELLS = 300000
+
+function DF:GetAuraByName (unit, spellName, isDebuff)
+ isDebuff = isDebuff and "HARMFUL|PLAYER"
+
+ for i = 1, 40 do
+ local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll = UnitAura (unit, i, isDebuff)
+ if (not name) then
+ return
+ end
+
+ if (name == spellName) then
+ return name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll
+ end
+ end
+end
+
+local default_text_for_aura_frame = {
+ AUTOMATIC = "Automatic",
+ MANUAL = "Manual",
+ METHOD = "Aura Tracking Method:",
+ BUFFS_IGNORED = "Buffs Ignored",
+ DEBUFFS_IGNORED = "Debuffs Ignored",
+ BUFFS_TRACKED = "Buffs Tracked",
+ DEBUFFS_TRACKED = "Debuffs Tracked",
+
+ AUTOMATIC_DESC = "Auras are being tracked automatically, the addon controls what to show.\nYou may add auras to the blacklist or add extra auras to track.",
+ MANUAL_DESC = "Auras are being tracked manually, the addon only check for auras you entered below.",
+
+ MANUAL_ADD_BLACKLIST_BUFF = "Add Buff to Blacklist",
+ MANUAL_ADD_BLACKLIST_DEBUFF = "Add Debuff to Blacklist",
+ MANUAL_ADD_TRACKLIST_BUFF = "Add Buff to Tracklist",
+ MANUAL_ADD_TRACKLIST_DEBUFF = "Add Debuff to Tracklist",
+}
+
+function DF:LoadAllSpells (hashMap, indexTable, allSpellsSameName)
+
+ --pre checking which tables to fill to avoid checking if the table exists during the gigantic loop for performance
+
+ if (not DF.LoadingAuraAlertFrame) then
+ DF.LoadingAuraAlertFrame = CreateFrame ("frame", "DetailsFrameworkLoadingAurasAlert", UIParent)
+ DF.LoadingAuraAlertFrame:SetSize (340, 75)
+ DF.LoadingAuraAlertFrame:SetPoint ("center")
+ DF.LoadingAuraAlertFrame:SetFrameStrata ("TOOLTIP")
+ DF:ApplyStandardBackdrop (DF.LoadingAuraAlertFrame)
+ DF.LoadingAuraAlertFrame:SetBackdropBorderColor (1, 0.8, 0.1)
+
+ DF.LoadingAuraAlertFrame.IsLoadingLabel1 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "We are currently loading spell names and spell IDs")
+ DF.LoadingAuraAlertFrame.IsLoadingLabel2 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "This may take only a few seconds")
+ DF.LoadingAuraAlertFrame.IsLoadingImage1 = DF:CreateImage (DF.LoadingAuraAlertFrame, [[Interface\DialogFrame\UI-Dialog-Icon-AlertOther]], 32, 32)
+ DF.LoadingAuraAlertFrame.IsLoadingLabel1.align = "center"
+ DF.LoadingAuraAlertFrame.IsLoadingLabel2.align = "center"
+
+ DF.LoadingAuraAlertFrame.IsLoadingLabel1:SetPoint ("center", 16, 10)
+ DF.LoadingAuraAlertFrame.IsLoadingLabel2:SetPoint ("center", 16, -5)
+ DF.LoadingAuraAlertFrame.IsLoadingImage1:SetPoint ("left", 10, 0)
+ end
+
+ DF.LoadingAuraAlertFrame:Show()
+
+ C_Timer.After (0.1, function()
+ if (hashMap and not indexTable) then
+ for i = 1, CONST_MAX_SPELLS do
+ local spellName = GetSpellInfo (i)
+ if (spellName) then
+ hashMap [lower (spellName)] = i
+ end
+ end
+
+ elseif (not hashMap and indexTable) then
+ for i = 1, CONST_MAX_SPELLS do
+ local spellName = GetSpellInfo (i)
+ if (spellName) then
+ indexTable [#indexTable+1] = lower (spellName)
+ end
+ end
+
+ elseif (hashMap and indexTable) then
+ --DF_CALC_PERFORMANCE()
+ if (allSpellsSameName) then
+ for i = 1, CONST_MAX_SPELLS do
+ local spellName = GetSpellInfo (i)
+ if (spellName) then
+ spellName = lower (spellName)
+ indexTable [#indexTable + 1] = spellName
+ hashMap [spellName] = i
+
+ --same name table
+ local sameNameTable = allSpellsSameName [spellName]
+ if (not sameNameTable) then
+ sameNameTable = {}
+ allSpellsSameName [spellName] = sameNameTable
+ end
+ sameNameTable [#sameNameTable + 1] = i
+ end
+ end
+ else
+ for i = 1, CONST_MAX_SPELLS do
+ local spellName = GetSpellInfo (i)
+ if (spellName) then
+ spellName = lower (spellName)
+ indexTable [#indexTable + 1] = spellName
+ hashMap [spellName] = i
+ end
+ end
+ end
+ end
+
+ DF.LoadingAuraAlertFrame:Hide()
+ end)
+
+end
+
+local cleanfunction = function() end
+
+do
+ local metaPrototype = {
+ WidgetType = "aura_tracker",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["aura_tracker"]] = _G [DF.GlobalWidgetControlNames ["aura_tracker"]] or metaPrototype
+end
+
+local AuraTrackerMetaFunctions = _G [DF.GlobalWidgetControlNames ["aura_tracker"]]
+
+--create panels
+local on_profile_changed = function (self, newdb)
+
+ self.db = newdb
+
+ --automatic
+ self.buff_ignored:DoSetData (newdb.aura_tracker.buff_banned)
+ self.debuff_ignored:DoSetData (newdb.aura_tracker.debuff_banned)
+ self.buff_tracked:DoSetData (newdb.aura_tracker.buff_tracked)
+ self.debuff_tracked:DoSetData (newdb.aura_tracker.debuff_tracked)
+
+ self.buff_ignored:DoRefresh()
+ self.debuff_ignored:DoRefresh()
+ self.buff_tracked:DoRefresh()
+ self.debuff_tracked:DoRefresh()
+
+ --manual
+ self.buffs_added:SetData (newdb.aura_tracker.buff)
+ self.debuffs_added:SetData (newdb.aura_tracker.debuff)
+ self.buffs_added:Refresh()
+ self.debuffs_added:Refresh()
+
+ --method
+ if (newdb.aura_tracker.track_method == 0x1) then
+ self.f_auto:Show()
+ self.f_manual:Hide()
+
+ self.AutomaticTrackingCheckbox:SetValue (true)
+ self.ManualTrackingCheckbox:SetValue (false)
+ self.desc_label.text = self.LocTexts.AUTOMATIC_DESC
+
+ elseif (newdb.aura_tracker.track_method == 0x2) then
+ self.f_auto:Hide()
+ self.f_manual:Show()
+
+ self.AutomaticTrackingCheckbox:SetValue (false)
+ self.ManualTrackingCheckbox:SetValue (true)
+ self.desc_label.text = self.LocTexts.MANUAL_DESC
+ end
+end
+
+local aura_panel_defaultoptions = {
+ height = 400,
+ row_height = 18,
+ width = 230,
+ button_text_template = "OPTIONS_FONT_TEMPLATE"
+}
+
+function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, texts)
+
+ local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+ local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
+ local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
+ local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
+
+ local f = CreateFrame ("frame", name, parent)
+ f.db = db
+ f.OnProfileChanged = on_profile_changed
+ f.LocTexts = texts
+ options = options or {}
+ self.table.deploy (options, aura_panel_defaultoptions)
+
+ local f_auto = CreateFrame ("frame", "$parent_Automatic", f)
+ local f_manual = CreateFrame ("frame", "$parent_Manual", f)
+ f_auto:SetPoint ("topleft", f, "topleft", 0, -24)
+ f_manual:SetPoint ("topleft", f, "topleft", 0, -24)
+ f_auto:SetSize (600, 600)
+ f_manual:SetSize (600, 600)
+ f.f_auto = f_auto
+ f.f_manual = f_manual
+
+ --check if the texts table is valid and also deploy default values into the table in case some value is nil
+ texts = (type (texts == "table") and texts) or default_text_for_aura_frame
+ DF.table.deploy (texts, default_text_for_aura_frame)
+
+ -------------
+
+ local on_switch_tracking_method = function (self)
+ local method = self.Method
+
+ f.db.aura_tracker.track_method = method
+ if (change_callback) then
+ DF:QuickDispatch (change_callback)
+ end
+
+ if (method == 0x1) then
+ f_auto:Show()
+ f_manual:Hide()
+ f.AutomaticTrackingCheckbox:SetValue (true)
+ f.ManualTrackingCheckbox:SetValue (false)
+ f.desc_label.text = texts.AUTOMATIC_DESC
+
+ elseif (method == 0x2) then
+ f_auto:Hide()
+ f_manual:Show()
+ f.AutomaticTrackingCheckbox:SetValue (false)
+ f.ManualTrackingCheckbox:SetValue (true)
+ f.desc_label.text = texts.MANUAL_DESC
+ end
+ end
+
+ local background_method_selection = CreateFrame ("frame", nil, f)
+ background_method_selection:SetHeight (82)
+ background_method_selection:SetPoint ("topleft", f, "topleft", 0, 0)
+ background_method_selection:SetPoint ("topright", f, "topright", 0, 0)
+ DF:ApplyStandardBackdrop (background_method_selection)
+
+ local tracking_method_label = self:CreateLabel (background_method_selection, texts.METHOD, 12, "orange")
+ tracking_method_label:SetPoint ("topleft", background_method_selection, "topleft", 6, -4)
+
+ f.desc_label = self:CreateLabel (background_method_selection, "", 10, "silver")
+ f.desc_label:SetPoint ("left", background_method_selection, "left", 130, 0)
+ f.desc_label:SetJustifyV ("top")
+
+ local automatic_tracking_checkbox = DF:CreateSwitch (background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
+ automatic_tracking_checkbox.Method = 0x1
+ automatic_tracking_checkbox:SetAsCheckBox()
+ automatic_tracking_checkbox:SetSize (24, 24)
+ f.AutomaticTrackingCheckbox = automatic_tracking_checkbox
+
+ local automatic_tracking_label = DF:CreateLabel (background_method_selection, "Automatic")
+ automatic_tracking_label:SetPoint ("left", automatic_tracking_checkbox, "right", 2, 0)
+
+ local manual_tracking_checkbox = DF:CreateSwitch (background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
+ manual_tracking_checkbox.Method = 0x2
+ manual_tracking_checkbox:SetAsCheckBox()
+ manual_tracking_checkbox:SetSize (24, 24)
+ f.ManualTrackingCheckbox = manual_tracking_checkbox
+
+ local manual_tracking_label = DF:CreateLabel (background_method_selection, "Manual")
+ manual_tracking_label:SetPoint ("left", manual_tracking_checkbox, "right", 2, 0)
+
+ automatic_tracking_checkbox:SetPoint ("topleft", tracking_method_label, "bottomleft", 0, -6)
+ manual_tracking_checkbox:SetPoint ("topleft", automatic_tracking_checkbox, "bottomleft", 0, -6)
+
+
+-------- anchors points
+
+ local y = -110
+
+-------- automatic
+
+ --manual add the buff and ebuff names
+ local AllSpellsMap = {}
+ local AllSpellNames = {}
+
+ --store a table with spell name as key and in the value an index table with spell IDs
+ local AllSpellsSameName = {}
+
+ local load_all_spells = function (self, capsule)
+ if (not next (AllSpellsMap)) then
+ DF:LoadAllSpells (AllSpellsMap, AllSpellNames, AllSpellsSameName)
+
+ f_auto.AddBuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames
+ f_auto.AddDebuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames
+ f_auto.AddBuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames
+ f_auto.AddDebuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames
+
+ f_manual.NewBuffTextBox.SpellAutoCompleteList = AllSpellNames
+ f_manual.NewDebuffTextBox.SpellAutoCompleteList = AllSpellNames
+
+ --
+
+ f_auto.AddBuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+ f_auto.AddDebuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+ f_auto.AddBuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+ f_auto.AddDebuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+
+ f_manual.NewBuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+ f_manual.NewDebuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
+
+ --
+
+ f_auto.AddBuffBlacklistTextBox.ShouldOptimizeAutoComplete = true
+ f_auto.AddDebuffBlacklistTextBox.ShouldOptimizeAutoComplete = true
+ f_auto.AddBuffTracklistTextBox.ShouldOptimizeAutoComplete = true
+ f_auto.AddDebuffTracklistTextBox.ShouldOptimizeAutoComplete = true
+
+ f_manual.NewBuffTextBox.ShouldOptimizeAutoComplete = true
+ f_manual.NewDebuffTextBox.ShouldOptimizeAutoComplete = true
+ end
+ end
+
+ --this set the width of the background box, text entry and button
+ local textEntryWidth = 120
+
+ --create the background
+ local background_add_blacklist = CreateFrame ("frame", nil, f_auto)
+ background_add_blacklist:SetSize (textEntryWidth + 10, 135)
+ DF:ApplyStandardBackdrop (background_add_blacklist)
+ background_add_blacklist.__background:SetVertexColor (0.47, 0.27, 0.27)
+
+ local background_add_tracklist = CreateFrame ("frame", nil, f_auto)
+ background_add_tracklist:SetSize (textEntryWidth + 10, 135)
+ DF:ApplyStandardBackdrop (background_add_tracklist)
+ background_add_tracklist.__background:SetVertexColor (0.27, 0.27, 0.47)
+
+ --black list
+ --create labels
+ local buff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ local debuff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+
+ local buff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, textEntryWidth, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template)
+ buff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ buff_name_blacklist_entry:SetJustifyH ("left")
+ buff_name_blacklist_entry.tooltip = "Enter the buff name using lower case letters."
+ f_auto.AddBuffBlacklistTextBox = buff_name_blacklist_entry
+
+ local debuff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, textEntryWidth, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template)
+ debuff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ debuff_name_blacklist_entry:SetJustifyH ("left")
+ debuff_name_blacklist_entry.tooltip = "Enter the debuff name using lower case letters."
+ f_auto.AddDebuffBlacklistTextBox = debuff_name_blacklist_entry
+
+ local same_name_spells_add = function (spellID, t)
+ local spellName = GetSpellInfo (spellID)
+ if (spellName) then
+ if (not next (AllSpellsMap)) then
+ load_all_spells()
+ end
+
+ spellName = lower (spellName)
+ local spellWithSameName = AllSpellsSameName [spellName]
+ if (spellWithSameName) then
+ if (t) then
+ t [spellName] = DF.table.copy ({}, spellWithSameName)
+ else
+ db.aura_cache_by_name [spellName] = DF.table.copy ({}, spellWithSameName)
+ end
+ end
+ end
+ end
+ DF.AddSpellWithSameName = same_name_spells_add
+
+ local get_spellID_from_string = function (text)
+ --check if the user entered a spell ID
+ local isSpellID = tonumber (text)
+ if (isSpellID and isSpellID > 1 and isSpellID < 10000000) then
+ local isValidSpellID = GetSpellInfo (isSpellID)
+ if (isValidSpellID) then
+ return isSpellID
+ else
+ return
+ end
+ end
+
+ --get the spell ID from the spell name
+ text = lower (text)
+ local spellID = AllSpellsMap [text]
+ if (not spellID) then
+ return
+ end
+
+ return spellID
+ end
+
+ local add_blacklist_buff_button = self:CreateButton (background_add_blacklist, function()
+ local text = buff_name_blacklist_entry.text
+ buff_name_blacklist_entry:SetText ("")
+ buff_name_blacklist_entry:ClearFocus()
+
+ if (text ~= "") then
+ --get the spellId
+ local spellId = get_spellID_from_string (text)
+ if (not spellId) then
+ DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!")
+ return
+ end
+
+ --add the spellId to the blacklist
+ f.db.aura_tracker.buff_banned [spellId] = true
+
+ --refresh the buff blacklist frame
+ f.buff_ignored:DoRefresh()
+
+ DF:QuickDispatch (change_callback)
+
+ --add to spells with the same name cache
+ same_name_spells_add (spellId)
+ end
+
+ end, textEntryWidth, 20, "Add to Blacklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template))
+
+ local add_blacklist_debuff_button = self:CreateButton (background_add_blacklist, function()
+ local text = debuff_name_blacklist_entry.text
+ debuff_name_blacklist_entry:SetText ("")
+ debuff_name_blacklist_entry:ClearFocus()
+
+ if (text ~= "") then
+ --get the spellId
+ local spellId = get_spellID_from_string (text)
+ if (not spellId) then
+ DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!")
+ return
+ end
+
+ --add the spellId to the blacklist
+ f.db.aura_tracker.debuff_banned [spellId] = true
+
+ --refresh the buff blacklist frame
+ f.debuff_ignored:DoRefresh()
+
+ DF:QuickDispatch (change_callback)
+
+ --add to spells with the same name cache
+ same_name_spells_add (spellId)
+ end
+ end, textEntryWidth, 20, "Add to Blacklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template))
+
+
+ --track list
+ local buff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ local debuff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+
+ local buff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, textEntryWidth, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template)
+ buff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ buff_name_tracklist_entry:SetJustifyH ("left")
+ buff_name_tracklist_entry.tooltip = "Enter the buff name using lower case letters."
+ f_auto.AddBuffTracklistTextBox = buff_name_tracklist_entry
+
+ local debuff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, textEntryWidth, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template)
+ debuff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ debuff_name_tracklist_entry:SetJustifyH ("left")
+ debuff_name_tracklist_entry.tooltip = "Enter the debuff name using lower case letters."
+ f_auto.AddDebuffTracklistTextBox = debuff_name_tracklist_entry
+
+ local add_tracklist_debuff_button = self:CreateButton (background_add_tracklist, function()
+ local text = debuff_name_tracklist_entry.text
+ debuff_name_tracklist_entry:SetText ("")
+ debuff_name_tracklist_entry:ClearFocus()
+
+ if (text ~= "") then
+ --get the spellId
+ local spellId = get_spellID_from_string (text)
+ if (not spellId) then
+ DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!")
+ return
+ end
+
+ --add the spellId to the blacklist
+ f.db.aura_tracker.debuff_tracked [spellId] = true
+
+ --refresh the buff blacklist frame
+ f.debuff_tracked:DoRefresh()
+
+ DF:QuickDispatch (change_callback)
+
+ --add to spells with the same name cache
+ same_name_spells_add (spellId)
+ end
+ end, textEntryWidth, 20, "Add to Tracklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template))
+
+ local add_tracklist_buff_button = self:CreateButton (background_add_tracklist, function()
+ local text = buff_name_tracklist_entry.text
+ buff_name_tracklist_entry:SetText ("")
+ buff_name_tracklist_entry:ClearFocus()
+
+ if (text ~= "") then
+ --get the spellId
+ local spellId = get_spellID_from_string (text)
+ if (not spellId) then
+ DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!")
+ return
+ end
+
+ --add the spellId to the blacklist
+ f.db.aura_tracker.buff_tracked [spellId] = true
+
+ --refresh the buff tracklist frame
+ f.buff_tracked:DoRefresh()
+
+ --callback the addon
+ DF:QuickDispatch (change_callback)
+
+ --add to spells with the same name cache
+ same_name_spells_add (spellId)
+ end
+
+ end, textEntryWidth, 20, "Add to Tracklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template))
+
+ --anchors:
+ background_add_blacklist:SetPoint ("topleft", f_auto, "topleft", 0, y)
+ background_add_tracklist:SetPoint ("topleft", background_add_blacklist, "bottomleft", 0, -10)
+
+ --debuff blacklist
+ debuff_name_blacklist_entry:SetPoint ("topleft", background_add_blacklist, "topleft", 5, -20)
+ debuff_blacklist_label:SetPoint ("bottomleft", debuff_name_blacklist_entry, "topleft", 0, 2)
+ add_blacklist_debuff_button:SetPoint ("topleft", debuff_name_blacklist_entry, "bottomleft", 0, -2)
+
+ --buff blacklist
+ buff_blacklist_label:SetPoint ("topleft", add_blacklist_debuff_button.widget, "bottomleft", 0, -10)
+ buff_name_blacklist_entry:SetPoint ("topleft", buff_blacklist_label, "bottomleft", 0, -2)
+ add_blacklist_buff_button:SetPoint ("topleft", buff_name_blacklist_entry, "bottomleft", 0, -2)
+
+
+ --debuff tracklist
+ debuff_name_tracklist_entry:SetPoint ("topleft", background_add_tracklist, "topleft", 5, -20)
+ debuff_tracklist_label:SetPoint ("bottomleft", debuff_name_tracklist_entry, "topleft", 0, 2)
+ add_tracklist_debuff_button:SetPoint ("topleft", debuff_name_tracklist_entry, "bottomleft", 0, -2)
+
+ --buff tracklist
+ buff_tracklist_label:SetPoint ("topleft", add_tracklist_debuff_button.widget, "bottomleft", 0, -10)
+ buff_name_tracklist_entry:SetPoint ("topleft", buff_tracklist_label, "bottomleft", 0, -2)
+ add_tracklist_buff_button:SetPoint ("topleft", buff_name_tracklist_entry, "bottomleft", 0, -2)
+
+ local ALL_BUFFS = {}
+ local ALL_DEBUFFS = {}
+
+ --options passed to the create aura panel
+ local width, height, row_height = options.width, options.height, options.row_height
+
+ local autoTrackList_LineOnEnter = function (self, capsule, value)
+
+ value = value or self.SpellID
+
+ local spellName = GetSpellInfo (value)
+ if (spellName) then
+
+ local spellsWithSameName = db.aura_cache_by_name [lower (spellName)]
+ if (not spellsWithSameName) then
+ same_name_spells_add (value)
+ spellsWithSameName = db.aura_cache_by_name [lower (spellName)]
+ end
+
+ if (spellsWithSameName) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:SetOwner (self, "left", "right", 2, 0)
+ GameCooltip2:SetOption ("TextSize", 10)
+
+ for i, spellID in ipairs (spellsWithSameName) do
+ local spellName, _, spellIcon = GetSpellInfo (spellID)
+ if (spellName) then
+ GameCooltip2:AddLine (spellName .. " (" .. spellID .. ")")
+ GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9)
+ end
+ end
+
+ GameCooltip2:Show()
+ end
+
+ end
+ end
+
+ local autoTrackList_LineOnLeave = function()
+ GameCooltip2:Hide()
+ end
+
+ local scrollWidth = 208
+ local scrollHeight = 343
+ local lineAmount = 18
+ local lineHeight = 18
+ local backdropColor = {.8, .8, .8, 0.2}
+ local backdropColor_OnEnter = {.8, .8, .8, 0.4}
+
+ local createAuraScrollBox = function (parent, name, member, title, db, removeFunc)
+
+ local updateFunc = function (self, data, offset, totalLines)
+ for i = 1, totalLines do
+ local index = i + offset
+ local auraTable = data [index]
+ if (auraTable) then
+ local line = self:GetLine (i)
+ local spellID, spellName, spellIcon = unpack (auraTable)
+
+ line.SpellID = spellID
+ line.SpellName = spellName
+ line.SpellIcon = spellIcon
+
+ line.name:SetText (spellName)
+ line.icon:SetTexture (spellIcon)
+ line.icon:SetTexCoord (.1, .9, .1, .9)
+ end
+ end
+ end
+
+ local lineOnEnter = function (self)
+ self:SetBackdropColor (unpack (backdropColor_OnEnter))
+
+ --GameTooltip:SetOwner (self, "ANCHOR_CURSOR")
+ --GameTooltip:SetSpellByID (self.SpellID)
+ --GameTooltip:AddLine (" ")
+ --GameTooltip:Show()
+ end
+
+ local lineOnLeave = function (self)
+ self:SetBackdropColor (unpack (backdropColor))
+ --GameTooltip:Hide()
+ end
+
+ local onRemoveClick = function (self)
+ local spellID = self:GetParent().SpellID
+ db [spellID] = nil
+ parent [member]:DoRefresh()
+ end
+
+ local createLineFunc = function (self, index)
+ local line = CreateFrame ("button", "$parentLine" .. index, self)
+ line:SetPoint ("topleft", self, "topleft", 1, - ((index - 1) * (lineHeight + 1)) - 1)
+ line:SetSize (scrollWidth - 2, lineHeight)
+ line:SetScript ("OnEnter", autoTrackList_LineOnEnter)
+ line:HookScript ("OnEnter", lineOnEnter)
+ line:SetScript ("OnLeave", autoTrackList_LineOnLeave)
+ line:HookScript ("OnLeave", lineOnLeave)
+
+ line:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ line:SetBackdropColor (unpack (backdropColor))
+
+ local icon = line:CreateTexture ("$parentIcon", "overlay")
+ icon:SetSize (lineHeight - 2, lineHeight - 2)
+
+ local name = line:CreateFontString ("$parentName", "overlay", "GameFontNormal")
+ DF:SetFontSize (name, 10)
+
+ local remove_button = CreateFrame ("button", "$parentRemoveButton", line, "UIPanelCloseButton")
+ remove_button:SetSize (16, 16)
+ remove_button:SetScript ("OnClick", onRemoveClick)
+ remove_button:SetPoint ("topright", line, "topright")
+ remove_button:GetNormalTexture():SetDesaturated (true)
+
+ icon:SetPoint ("left", line, "left", 2, 0)
+ name:SetPoint ("left", icon, "right", 3, 0)
+
+ line.icon = icon
+ line.name = name
+ line.removebutton = remove_button
+
+ return line
+ end
+
+ local scroll = DF:CreateScrollBox (parent, name, updateFunc, db, scrollWidth, scrollHeight, lineAmount, lineHeight)
+ DF:ReskinSlider (scroll)
+ parent [member] = scroll
+ scroll.OriginalData = db
+
+ function scroll:DoRefresh()
+ local t = {}
+ for spellID, _ in pairs (scroll.OriginalData) do
+ local spellName, _, spellIcon = GetSpellInfo (spellID)
+ if (spellName) then
+ local lowerSpellName = spellName:lower()
+ tinsert (t, {spellID, spellName, spellIcon, lowerSpellName})
+ end
+ end
+
+ table.sort (t, function (t1, t2) return t1[4] < t2[4] end)
+
+ self:SetData (t)
+ self:Refresh()
+ end
+
+ function scroll:DoSetData (newDB)
+ self:SetData (newDB)
+ scroll.OriginalData = newDB
+ self:DoRefresh()
+ end
+
+ local title = DF:CreateLabel (parent, title)
+ title.textcolor = "silver"
+ title:SetPoint ("bottomleft", scroll, "topleft", 0, 2)
+
+ for i = 1, lineAmount do
+ scroll:CreateLine (createLineFunc)
+ end
+
+ scroll:DoRefresh()
+ return scroll
+ end
+
+ local buff_tracked = createAuraScrollBox (f_auto, "$parentBuffTracked", "BuffTrackerScroll", f.LocTexts.BUFFS_TRACKED, f.db.aura_tracker.buff_tracked, function()end)
+ local debuff_tracked = createAuraScrollBox (f_auto, "$parentDebuffTracked", "DebuffTrackerScroll", f.LocTexts.DEBUFFS_TRACKED, f.db.aura_tracker.debuff_tracked, function()end)
+
+ local buff_ignored = createAuraScrollBox (f_auto, "$parentBuffIgnored", "BuffIgnoredScroll", f.LocTexts.BUFFS_IGNORED, f.db.aura_tracker.buff_banned, function()end)
+ local debuff_ignored = createAuraScrollBox (f_auto, "$parentDebuffIgnored", "DebuffIgnoredScroll", f.LocTexts.DEBUFFS_IGNORED, f.db.aura_tracker.debuff_banned, function()end)
+
+ local xLocation = 140
+ scrollWidth = scrollWidth + 20
+
+ debuff_ignored:SetPoint ("topleft", f_auto, "topleft", 0 + xLocation, y)
+ buff_ignored:SetPoint ("topleft", f_auto, "topleft", 8 + scrollWidth + xLocation, y)
+ debuff_tracked:SetPoint ("topleft", f_auto, "topleft", 16 + (scrollWidth * 2) + xLocation, y)
+ buff_tracked:SetPoint ("topleft", f_auto, "topleft", 24 + (scrollWidth * 3) + xLocation, y)
+
+ f.buff_ignored = buff_ignored
+ f.debuff_ignored = debuff_ignored
+ f.buff_tracked = buff_tracked
+ f.debuff_tracked = debuff_tracked
+
+ f_auto:SetScript ("OnShow", function()
+ for i = 1, BUFF_MAX_DISPLAY do
+ local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HELPFUL")
+ if (name) then
+ ALL_BUFFS [spellId] = true
+ end
+ local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HARMFUL")
+ if (name) then
+ ALL_DEBUFFS [spellId] = true
+ end
+ end
+
+ buff_tracked:DoRefresh()
+ debuff_tracked:DoRefresh()
+ buff_ignored:DoRefresh()
+ debuff_ignored:DoRefresh()
+
+ end)
+ f_auto:SetScript ("OnHide", function()
+ --
+ end)
+
+ --show the frame selecton on the f.db
+
+ if (f.db.aura_tracker.track_method == 0x1) then
+ on_switch_tracking_method (automatic_tracking_checkbox)
+ elseif (f.db.aura_tracker.track_method == 0x2) then
+ on_switch_tracking_method (manual_tracking_checkbox)
+ end
+
+-------manual
+
+ --> build the two aura scrolls for buff and debuff
+
+ local scroll_width = width
+ local scroll_height = height
+ local scroll_lines = 15
+ local scroll_line_height = 20
+
+ local backdrop_color = {.8, .8, .8, 0.2}
+ local backdrop_color_on_enter = {.8, .8, .8, 0.4}
+
+ local line_onenter = function (self)
+ self:SetBackdropColor (unpack (backdrop_color_on_enter))
+ local spellid = select (7, GetSpellInfo (self.value))
+ if (spellid) then
+ GameTooltip:SetOwner (self, "ANCHOR_CURSOR")
+ GameTooltip:SetSpellByID (spellid)
+ GameTooltip:AddLine (" ")
+ GameTooltip:Show()
+ end
+ end
+
+ local line_onleave = function (self)
+ self:SetBackdropColor (unpack (backdrop_color))
+ GameTooltip:Hide()
+ end
+
+ local onclick_remove_button = function (self)
+ local spell = self:GetParent().value
+ local data = self:GetParent():GetParent():GetData()
+
+ for i = 1, #data do
+ if (data[i] == spell) then
+ tremove (data, i)
+ break
+ end
+ end
+
+ self:GetParent():GetParent():Refresh()
+ end
+
+ local scroll_createline = function (self, index)
+ local line = CreateFrame ("button", "$parentLine" .. index, self)
+ line:SetPoint ("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1)) - 1)
+ line:SetSize (scroll_width - 2, scroll_line_height)
+ line:SetScript ("OnEnter", line_onenter)
+ line:SetScript ("OnLeave", line_onleave)
+
+ line:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ line:SetBackdropColor (unpack (backdrop_color))
+
+ local icon = line:CreateTexture ("$parentIcon", "overlay")
+ icon:SetSize (scroll_line_height - 2, scroll_line_height - 2)
+
+ local name = line:CreateFontString ("$parentName", "overlay", "GameFontNormal")
+
+ local remove_button = CreateFrame ("button", "$parentRemoveButton", line, "UIPanelCloseButton")
+ remove_button:SetSize (16, 16)
+ remove_button:SetScript ("OnClick", onclick_remove_button)
+ remove_button:SetPoint ("topright", line, "topright")
+ remove_button:GetNormalTexture():SetDesaturated (true)
+
+ icon:SetPoint ("left", line, "left", 2, 0)
+ name:SetPoint ("left", icon, "right", 2, 0)
+
+ line.icon = icon
+ line.name = name
+ line.removebutton = remove_button
+
+ return line
+ end
+
+ local scroll_refresh = function (self, data, offset, total_lines)
+ for i = 1, total_lines do
+ local index = i + offset
+ local aura = data [index]
+ if (aura) then
+ local line = self:GetLine (i)
+ local name, _, icon = GetSpellInfo (aura)
+ line.value = aura
+ if (name) then
+ line.name:SetText (name)
+ line.icon:SetTexture (icon)
+ line.icon:SetTexCoord (.1, .9, .1, .9)
+ else
+ line.name:SetText (aura)
+ line.icon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]])
+ end
+ end
+ end
+ end
+
+ local buffs_added = self:CreateScrollBox (f_manual, "$parentBuffsAdded", scroll_refresh, f.db.aura_tracker.buff, scroll_width, scroll_height, scroll_lines, scroll_line_height)
+ buffs_added:SetPoint ("topleft", f_manual, "topleft", 0, y)
+ DF:ReskinSlider (buffs_added)
+
+ for i = 1, scroll_lines do
+ buffs_added:CreateLine (scroll_createline)
+ end
+
+ local debuffs_added = self:CreateScrollBox (f_manual, "$parentDebuffsAdded", scroll_refresh, f.db.aura_tracker.debuff, scroll_width, scroll_height, scroll_lines, scroll_line_height)
+ debuffs_added:SetPoint ("topleft", f_manual, "topleft", width+30, y)
+ DF:ReskinSlider (debuffs_added)
+
+ for i = 1, scroll_lines do
+ debuffs_added:CreateLine (scroll_createline)
+ end
+
+ f.buffs_added = buffs_added
+ f.debuffs_added = debuffs_added
+
+ local buffs_added_name = DF:CreateLabel (buffs_added, "Buffs", 12, "silver")
+ buffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ buffs_added_name:SetPoint ("bottomleft", buffs_added, "topleft", 0, 2)
+ buffs_added.Title = buffs_added_name
+
+ local debuffs_added_name = DF:CreateLabel (debuffs_added, "Debuffs", 12, "silver")
+ debuffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ debuffs_added_name:SetPoint ("bottomleft", debuffs_added, "topleft", 0, 2)
+ debuffs_added.Title = debuffs_added_name
+
+ --> build the text entry to type the spellname
+ local new_buff_string = self:CreateLabel (f_manual, "Add Buff")
+ local new_debuff_string = self:CreateLabel (f_manual, "Add Debuff")
+ local new_buff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template)
+ local new_debuff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template)
+
+ new_buff_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ new_debuff_entry:SetHook ("OnEditFocusGained", load_all_spells)
+ new_buff_entry.tooltip = "Enter the buff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name."
+ new_debuff_entry.tooltip = "Enter the debuff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name."
+
+ new_buff_entry:SetJustifyH ("left")
+ new_debuff_entry:SetJustifyH ("left")
+
+ local add_buff_button = self:CreateButton (f_manual, function()
+
+ local text = new_buff_entry.text
+ new_buff_entry:SetText ("")
+ new_buff_entry:ClearFocus()
+
+ if (text ~= "") then
+ --> check for more than one spellname
+ if (text:find (";")) then
+ for _, spellName in ipairs ({strsplit (";", text)}) do
+ spellName = self:trim (spellName)
+ local spellID = get_spellID_from_string (spellName)
+
+ if (spellID) then
+ tinsert (f.db.aura_tracker.buff, spellID)
+ else
+ print ("spellId not found for spell:", spellName)
+ end
+ end
+ else
+ --get the spellId
+ local spellID = get_spellID_from_string (text)
+ if (not spellID) then
+ print ("spellIs for spell ", text, "not found")
+ return
+ end
+
+ tinsert (f.db.aura_tracker.buff, spellID)
+ end
+
+ buffs_added:Refresh()
+ end
+
+ end, 100, 20, "Add Buff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+
+ local add_debuff_button = self:CreateButton (f_manual, function()
+ local text = new_debuff_entry.text
+ new_debuff_entry:SetText ("")
+ new_debuff_entry:ClearFocus()
+ if (text ~= "") then
+ --> check for more than one spellname
+ if (text:find (";")) then
+ for _, spellName in ipairs ({strsplit (";", text)}) do
+ spellName = self:trim (spellName)
+ local spellID = get_spellID_from_string (spellName)
+
+ if (spellID) then
+ tinsert (f.db.aura_tracker.debuff, spellID)
+ else
+ print ("spellId not found for spell:", spellName)
+ end
+ end
+ else
+ --get the spellId
+ local spellID = get_spellID_from_string (text)
+ if (not spellID) then
+ print ("spellIs for spell ", text, "not found")
+ return
+ end
+
+ tinsert (f.db.aura_tracker.debuff, spellID)
+ end
+
+ debuffs_added:Refresh()
+ end
+ end, 100, 20, "Add Debuff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+
+ local multiple_spells_label = DF:CreateLabel (buffs_added, "You can add multiple auras at once by separating them with ';'.\nExample: Fireball; Frostbolt; Flamestrike", 10, "gray")
+ multiple_spells_label:SetSize (350, 24)
+ multiple_spells_label:SetJustifyV ("top")
+
+ local export_box = self:CreateTextEntry (f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template)
+
+ local export_buff_button = self:CreateButton (f_manual, function()
+ local str = ""
+ for _, spellId in ipairs (f.db.aura_tracker.buff) do
+ local spellName = GetSpellInfo (spellId)
+ if (spellName) then
+ str = str .. spellName .. "; "
+ end
+ end
+ export_box.text = str
+ export_box:SetFocus (true)
+ export_box:HighlightText()
+
+ end, 120, 20, "Export Buffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+
+ local export_debuff_button = self:CreateButton (f_manual, function()
+ local str = ""
+ for _, spellId in ipairs (f.db.aura_tracker.debuff) do
+ local spellName = GetSpellInfo (spellId)
+ if (spellName) then
+ str = str .. spellName .. "; "
+ end
+ end
+
+ export_box.text = str
+ export_box:SetFocus (true)
+ export_box:HighlightText()
+
+ end, 120, 20, "Export Debuffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+
+ new_buff_entry:SetPoint ("topleft", f_manual, "topleft", 480, y)
+ new_buff_string:SetPoint ("bottomleft", new_buff_entry, "topleft", 0, 2)
+ add_buff_button:SetPoint ("left", new_buff_entry, "right", 2, 0)
+ add_buff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it."
+
+ new_debuff_string:SetPoint ("topleft", new_buff_entry, "bottomleft", 0, -6)
+ new_debuff_entry:SetPoint ("topleft", new_debuff_string, "bottomleft", 0, -2)
+ add_debuff_button:SetPoint ("left", new_debuff_entry, "right", 2, 0)
+ add_debuff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it."
+
+ multiple_spells_label:SetPoint ("topleft", new_debuff_entry, "bottomleft", 0, -6)
+
+ export_buff_button:SetPoint ("topleft", multiple_spells_label, "bottomleft", 0, -12)
+ export_debuff_button:SetPoint ("left",export_buff_button, "right", 2, 0)
+ export_box:SetPoint ("topleft", export_buff_button, "bottomleft", 0, -6)
+
+ buffs_added:Refresh()
+ debuffs_added:Refresh()
+
+
+----------------------- ---------------------------------------------- ---------------------------------------------- -----------------------
+
+ f:SetScript ("OnShow", function()
+ buffs_added:Refresh()
+ debuffs_added:Refresh()
+ end)
+
+ return f
+end
+
+
+function DF:GetAllPlayerSpells (include_lower_case)
+ local playerSpells = {}
+ local tab, tabTex, offset, numSpells = GetSpellTabInfo (2)
+ for i = 1, numSpells do
+ local index = offset + i
+ local spellType, spellId = GetSpellBookItemInfo (index, "player")
+ if (spellType == "SPELL") then
+ local spellName = GetSpellInfo (spellId)
+ tinsert (playerSpells, spellName)
+ if (include_lower_case) then
+ tinsert (playerSpells, lower (spellName))
+ end
+ end
+ end
+ return playerSpells
+end
+
+function DF:SetAutoCompleteWithSpells (textentry)
+ textentry:SetHook ("OnEditFocusGained", function()
+ local playerSpells = DF:GetAllPlayerSpells (true)
+ textentry.WordList = playerSpells
+ end)
+ textentry:SetAsAutoComplete ("WordList")
+end
+
+--check for aura
+
+
+-- add aura
+
+
+--handle savedvariables
+
+
+--remove a aura
+
+
+
+
+
+--handle UNIT_AURA event
+
+
diff --git a/libs/DF/background.tga b/libs/DF/background.tga
new file mode 100644
index 0000000..8978d43
Binary files /dev/null and b/libs/DF/background.tga differ
diff --git a/libs/DF/border_1.tga b/libs/DF/border_1.tga
new file mode 100644
index 0000000..0f84fce
Binary files /dev/null and b/libs/DF/border_1.tga differ
diff --git a/libs/DF/border_2.tga b/libs/DF/border_2.tga
new file mode 100644
index 0000000..22b2c53
Binary files /dev/null and b/libs/DF/border_2.tga differ
diff --git a/libs/DF/border_3.tga b/libs/DF/border_3.tga
new file mode 100644
index 0000000..79e236b
Binary files /dev/null and b/libs/DF/border_3.tga differ
diff --git a/libs/DF/button.lua b/libs/DF/button.lua
new file mode 100644
index 0000000..2356f78
--- /dev/null
+++ b/libs/DF/button.lua
@@ -0,0 +1,1217 @@
+
+local DF = _G ["DetailsFramework"]
+
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APIButtonFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "button",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["button"]] = _G [DF.GlobalWidgetControlNames ["button"]] or metaPrototype
+end
+
+local ButtonMetaFunctions = _G [DF.GlobalWidgetControlNames ["button"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ ButtonMetaFunctions.__call = function (self)
+ local frameWidget = self.widget
+ DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.button:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.button:GetHeight()
+ end
+ --> text
+ local gmember_text = function (_object)
+ return _object.button.text:GetText()
+ end
+ --> function
+ local gmember_function = function (_object)
+ return _rawget (_object, "func")
+ end
+ --> text color
+ local gmember_textcolor = function (_object)
+ return _object.button.text:GetTextColor()
+ end
+ --> text font
+ local gmember_textfont = function (_object)
+ local fontface = _object.button.text:GetFont()
+ return fontface
+ end
+ --> text size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.button.text:GetFont()
+ return fontsize
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return {_object.button:GetNormalTexture(), _object.button:GetHighlightTexture(), _object.button:GetPushedTexture(), _object.button:GetDisabledTexture()}
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "is_locked")
+ end
+
+ ButtonMetaFunctions.GetMembers = ButtonMetaFunctions.GetMembers or {}
+ ButtonMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ ButtonMetaFunctions.GetMembers ["shown"] = gmember_shown
+ ButtonMetaFunctions.GetMembers ["width"] = gmember_width
+ ButtonMetaFunctions.GetMembers ["height"] = gmember_height
+ ButtonMetaFunctions.GetMembers ["text"] = gmember_text
+ ButtonMetaFunctions.GetMembers ["clickfunction"] = gmember_function
+ ButtonMetaFunctions.GetMembers ["texture"] = gmember_texture
+ ButtonMetaFunctions.GetMembers ["locked"] = gmember_locked
+ ButtonMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor
+ ButtonMetaFunctions.GetMembers ["fontface"] = gmember_textfont
+ ButtonMetaFunctions.GetMembers ["fontsize"] = gmember_textsize
+ ButtonMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias
+ ButtonMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias
+ ButtonMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias
+
+ ButtonMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = ButtonMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return ButtonMetaFunctions [_member_requested]
+ end
+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.button:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.button:SetHeight (_value)
+ end
+ --> text
+ local smember_text = function (_object, _value)
+ return _object.button.text:SetText (_value)
+ end
+ --> function
+ local smember_function = function (_object, _value)
+ return _rawset (_object, "func", _value)
+ end
+ --> param1
+ local smember_param1 = function (_object, _value)
+ return _rawset (_object, "param1", _value)
+ end
+ --> param2
+ local smember_param2 = function (_object, _value)
+ return _rawset (_object, "param2", _value)
+ end
+ --> text color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object.button.text:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> text font
+ local smember_textfont = function (_object, _value)
+ return DF:SetFontFace (_object.button.text, _value)
+ end
+ --> text size
+ local smember_textsize = function (_object, _value)
+ return DF:SetFontSize (_object.button.text, _value)
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (_type (_value) == "table") then
+ local _value1, _value2, _value3, _value4 = unpack (_value)
+ if (_value1) then
+ _object.button:SetNormalTexture (_value1)
+ end
+ if (_value2) then
+ _object.button:SetHighlightTexture (_value2, "ADD")
+ end
+ if (_value3) then
+ _object.button:SetPushedTexture (_value3)
+ end
+ if (_value4) then
+ _object.button:SetDisabledTexture (_value4)
+ end
+ else
+ _object.button:SetNormalTexture (_value)
+ _object.button:SetHighlightTexture (_value, "ADD")
+ _object.button:SetPushedTexture (_value)
+ _object.button:SetDisabledTexture (_value)
+ end
+ return
+ end
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ _object.button:SetMovable (false)
+ return _rawset (_object, "is_locked", true)
+ else
+ _object.button:SetMovable (true)
+ _rawset (_object, "is_locked", false)
+ return
+ end
+ end
+ --> text align
+ local smember_textalign = function (_object, _value)
+ if (_value == "left" or _value == "<") then
+ _object.button.text:SetPoint ("left", _object.button, "left", 2, 0)
+ _object.capsule_textalign = "left"
+ elseif (_value == "center" or _value == "|") then
+ _object.button.text:SetPoint ("center", _object.button, "center", 0, 0)
+ _object.capsule_textalign = "center"
+ elseif (_value == "right" or _value == ">") then
+ _object.button.text:SetPoint ("right", _object.button, "right", -2, 0)
+ _object.capsule_textalign = "right"
+ end
+ end
+
+ ButtonMetaFunctions.SetMembers = ButtonMetaFunctions.SetMembers or {}
+ ButtonMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
+ ButtonMetaFunctions.SetMembers ["show"] = smember_show
+ ButtonMetaFunctions.SetMembers ["hide"] = smember_hide
+ ButtonMetaFunctions.SetMembers ["width"] = smember_width
+ ButtonMetaFunctions.SetMembers ["height"] = smember_height
+ ButtonMetaFunctions.SetMembers ["text"] = smember_text
+ ButtonMetaFunctions.SetMembers ["clickfunction"] = smember_function
+ ButtonMetaFunctions.SetMembers ["param1"] = smember_param1
+ ButtonMetaFunctions.SetMembers ["param2"] = smember_param2
+ ButtonMetaFunctions.SetMembers ["textcolor"] = smember_textcolor
+ ButtonMetaFunctions.SetMembers ["textfont"] = smember_textfont
+ ButtonMetaFunctions.SetMembers ["textsize"] = smember_textsize
+ ButtonMetaFunctions.SetMembers ["texture"] = smember_texture
+ ButtonMetaFunctions.SetMembers ["locked"] = smember_locked
+ ButtonMetaFunctions.SetMembers ["textalign"] = smember_textalign
+
+ ButtonMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = ButtonMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function ButtonMetaFunctions:IsShown()
+ return self.button:IsShown()
+ end
+ function ButtonMetaFunctions:Show()
+ return self.button:Show()
+ end
+ function ButtonMetaFunctions:Hide()
+ return self.button:Hide()
+ end
+
+-- setpoint
+ function ButtonMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ error ("SetPoint: Invalid parameter.")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function ButtonMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.button:SetWidth (w)
+ end
+ if (h) then
+ return self.button:SetHeight (h)
+ end
+ end
+
+-- tooltip
+ function ButtonMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function ButtonMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- functions
+ function ButtonMetaFunctions:SetClickFunction (func, param1, param2, clicktype)
+ if (not clicktype or string.find (string.lower (clicktype), "left")) then
+ if (func) then
+ _rawset (self, "func", func)
+ else
+ _rawset (self, "func", cleanfunction)
+ end
+
+ if (param1 ~= nil) then
+ _rawset (self, "param1", param1)
+ end
+ if (param2 ~= nil) then
+ _rawset (self, "param2", param2)
+ end
+
+ elseif (clicktype or string.find (string.lower (clicktype), "right")) then
+ if (func) then
+ _rawset (self, "funcright", func)
+ else
+ _rawset (self, "funcright", cleanfunction)
+ end
+ end
+ end
+
+-- text
+ function ButtonMetaFunctions:SetText (text)
+ if (text) then
+ self.button.text:SetText (text)
+ else
+ self.button.text:SetText (nil)
+ end
+ end
+
+-- textcolor
+ function ButtonMetaFunctions:SetTextColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.button.text:SetTextColor (color, arg2, arg3, arg4 or 1)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ return self.button.text:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+-- textsize
+ function ButtonMetaFunctions:SetTextSize (size)
+ return DF:SetFontSize (self.button.text, _value)
+ end
+
+-- textfont
+ function ButtonMetaFunctions:SetTextFont (font)
+ return DF:SetFontFace (_object.button.text, _value)
+ end
+
+-- textures
+ function ButtonMetaFunctions:SetTexture (normal, highlight, pressed, disabled)
+ if (normal) then
+ self.button:SetNormalTexture (normal)
+ elseif (_type (normal) ~= "boolean") then
+ self.button:SetNormalTexture (nil)
+ end
+
+ if (_type (highlight) == "boolean") then
+ if (highlight and normal and _type (normal) ~= "boolean") then
+ self.button:SetHighlightTexture (normal, "ADD")
+ end
+ elseif (highlight == nil) then
+ self.button:SetHighlightTexture (nil)
+ else
+ self.button:SetHighlightTexture (highlight, "ADD")
+ end
+
+ if (_type (pressed) == "boolean") then
+ if (pressed and normal and _type (normal) ~= "boolean") then
+ self.button:SetPushedTexture (normal)
+ end
+ elseif (pressed == nil) then
+ self.button:SetPushedTexture (nil)
+ else
+ self.button:SetPushedTexture (pressed, "ADD")
+ end
+
+ if (_type (disabled) == "boolean") then
+ if (disabled and normal and _type (normal) ~= "boolean") then
+ self.button:SetDisabledTexture (normal)
+ end
+ elseif (disabled == nil) then
+ self.button:SetDisabledTexture (nil)
+ else
+ self.button:SetDisabledTexture (disabled, "ADD")
+ end
+
+ end
+
+-- frame levels
+ function ButtonMetaFunctions:GetFrameLevel()
+ return self.button:GetFrameLevel()
+ end
+ function ButtonMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.button:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.button:SetFrameLevel (framelevel)
+ end
+ end
+
+-- icon
+ function ButtonMetaFunctions:GetIconTexture()
+ if (self.icon) then
+ return self.icon:GetTexture()
+ end
+ end
+
+ function ButtonMetaFunctions:SetIcon (texture, width, height, layout, texcoord, overlay, textdistance, leftpadding, textheight, short_method)
+ if (not self.icon) then
+ self.icon = self:CreateTexture (nil, "artwork")
+ self.icon:SetSize (self.height*0.8, self.height*0.8)
+ self.icon:SetPoint ("left", self.widget, "left", 4 + (leftpadding or 0), 0)
+ self.icon.leftpadding = leftpadding or 0
+ self.widget.text:ClearAllPoints()
+ self.widget.text:SetPoint ("left", self.icon, "right", textdistance or 2, 0 + (textheight or 0))
+ end
+
+ self.icon:SetTexture (texture)
+ self.icon:SetSize (width or self.height*0.8, height or self.height*0.8)
+ self.icon:SetDrawLayer (layout or "artwork")
+ if (texcoord) then
+ self.icon:SetTexCoord (unpack (texcoord))
+ else
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ end
+ if (overlay) then
+ if (type (overlay) == "string") then
+ local r, g, b, a = DF:ParseColors (overlay)
+ self.icon:SetVertexColor (r, g, b, a)
+ else
+ self.icon:SetVertexColor (unpack (overlay))
+ end
+ else
+ self.icon:SetVertexColor (1, 1, 1, 1)
+ end
+
+ local w = self.button:GetWidth()
+ local iconw = self.icon:GetWidth()
+ local text_width = self.button.text:GetStringWidth()
+ if (text_width > w-15-iconw) then
+
+ if (short_method == false) then
+
+ elseif (not short_method) then
+ local new_width = text_width+15+iconw
+ self.button:SetWidth (new_width)
+
+ elseif (short_method == 1) then
+ local loop = true
+ local textsize = 11
+ while (loop) do
+ if (text_width+15+iconw < w or textsize < 8) then
+ loop = false
+ break
+ else
+ DF:SetFontSize (self.button.text, textsize)
+ text_width = self.button.text:GetStringWidth()
+ textsize = textsize - 1
+ end
+ end
+
+ end
+ end
+
+ end
+
+-- frame stratas
+ function ButtonMetaFunctions:SetFrameStrata()
+ return self.button:GetFrameStrata()
+ end
+ function ButtonMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.button:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.button:SetFrameStrata (strata)
+ end
+ end
+
+-- enabled
+ function ButtonMetaFunctions:IsEnabled()
+ return self.button:IsEnabled()
+ end
+ function ButtonMetaFunctions:Enable()
+ return self.button:Enable()
+ end
+ function ButtonMetaFunctions:Disable()
+ return self.button:Disable()
+ end
+
+-- exec
+ function ButtonMetaFunctions:Exec()
+ local frameWidget = self.widget
+ DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":Exec()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
+ end
+ function ButtonMetaFunctions:Click()
+ local frameWidget = self.widget
+ DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":Click()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
+ end
+ function ButtonMetaFunctions:RightClick()
+ local frameWidget = self.widget
+ DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2)
+ end
+
+--> custom textures
+ function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split, side_textures, side_textures2)
+
+ self.button:SetNormalTexture (nil)
+ self.button:SetPushedTexture (nil)
+ self.button:SetDisabledTexture (nil)
+ self.button:SetHighlightTexture (nil)
+
+ local button = self.button
+
+ if (use_split) then
+
+ --> 4 corners
+ button.textureTopLeft = button:CreateTexture (nil, "artwork"); button.textureTopLeft:SetSize (8, 8); button.textureTopLeft:SetPoint ("topleft", button)
+ button.textureTopRight = button:CreateTexture (nil, "artwork"); button.textureTopRight:SetSize (8, 8); button.textureTopRight:SetPoint ("topright", button)
+ button.textureBottomLeft = button:CreateTexture (nil, "artwork"); button.textureBottomLeft:SetSize (8, 8); button.textureBottomLeft:SetPoint ("bottomleft", button)
+ button.textureBottomRight = button:CreateTexture (nil, "artwork"); button.textureBottomRight:SetSize (8, 8); button.textureBottomRight:SetPoint ("bottomright", button)
+
+ button.textureLeft = button:CreateTexture (nil, "artwork"); button.textureLeft:SetWidth (4); button.textureLeft:SetPoint ("topleft", button.textureTopLeft, "bottomleft"); button.textureLeft:SetPoint ("bottomleft", button.textureBottomLeft, "topleft")
+ button.textureRight = button:CreateTexture (nil, "artwork"); button.textureRight:SetWidth (4); button.textureRight:SetPoint ("topright", button.textureTopRight, "bottomright"); button.textureRight:SetPoint ("bottomright", button.textureBottomRight, "topright")
+ button.textureTop = button:CreateTexture (nil, "artwork"); button.textureTop:SetHeight (4); button.textureTop:SetPoint ("topleft", button.textureTopLeft, "topright"); button.textureTop:SetPoint ("topright", button.textureTopRight, "topleft");
+ button.textureBottom = button:CreateTexture (nil, "artwork"); button.textureBottom:SetHeight (4); button.textureBottom:SetPoint ("bottomleft", button.textureBottomLeft, "bottomright"); button.textureBottom:SetPoint ("bottomright", button.textureBottomRight, "bottomleft");
+
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+
+ button.textureTopLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureTopRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottomLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottomRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureTop:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottom:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+
+ else
+ texture = texture or "Interface\\AddOns\\Details\\images\\default_button"
+ self.button.texture = self.button:CreateTexture (nil, "artwork")
+
+ if (not rect) then
+ self.button.texture:SetAllPoints (self.button)
+ else
+ self.button.texture:SetPoint ("topleft", self.button, "topleft", rect.x1, rect.y1)
+ self.button.texture:SetPoint ("bottomright", self.button, "bottomright", rect.x2, rect.y2)
+ end
+
+ if (coords) then
+ self.button.texture.coords = coords
+ self.button.texture:SetTexCoord (_unpack (coords.Normal))
+ else
+ self.button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+
+ self.button.texture:SetTexture (texture)
+ end
+
+ if (side_textures) then
+ local left = self.button:CreateTexture (nil, "overlay")
+ left:SetTexture ([[Interface\TALENTFRAME\talent-main]])
+ left:SetTexCoord (0.13671875, 0.25, 0.486328125, 0.576171875)
+ left:SetPoint ("left", self.button, 0, 0)
+ left:SetWidth (10)
+ left:SetHeight (self.button:GetHeight()+2)
+ self.button.left_border = left
+
+ local right = self.button:CreateTexture (nil, "overlay")
+ right:SetTexture ([[Interface\TALENTFRAME\talent-main]])
+ right:SetTexCoord (0.01953125, 0.13671875, 0.486328125, 0.576171875)
+ right:SetPoint ("right", self.button, 0, 0)
+ right:SetWidth (10)
+ right:SetHeight (self.button:GetHeight()+2)
+ self.button.right_border = right
+
+ elseif (side_textures2) then
+
+ local left = self.button:CreateTexture (nil, "overlay")
+ left:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ left:SetTexCoord (94/512, 123/512, 42/512, 87/512)
+ left:SetPoint ("left", self.button, 0, 0)
+ left:SetWidth (10)
+ left:SetHeight (self.button:GetHeight()+2)
+ self.button.left_border = left
+
+ local right = self.button:CreateTexture (nil, "overlay")
+ right:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ right:SetTexCoord (65/512, 94/512, 42/512, 87/512)
+ right:SetPoint ("right", self.button, 0, 0)
+ right:SetWidth (10)
+ right:SetHeight (self.button:GetHeight()+2)
+ self.button.right_border = right
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (button)
+
+ local capsule = button.MyObject
+
+ if (button.textureTopLeft) then
+ button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128)
+ button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128)
+ end
+
+ local kill = capsule:RunHooksForWidget ("OnEnter", button, capsule)
+ if (kill) then
+ return
+ end
+
+ button.MyObject.is_mouse_over = true
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight))
+ else
+ button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375)
+ end
+ end
+
+ if (button.MyObject.onenter_backdrop_border_color) then
+ button:SetBackdropBorderColor (unpack (button.MyObject.onenter_backdrop_border_color))
+ end
+
+ if (button.MyObject.onenter_backdrop) then
+ button:SetBackdropColor (unpack (button.MyObject.onenter_backdrop))
+ end
+
+ if (button.MyObject.have_tooltip) then
+ GameCooltip2:Preset (2)
+ if (type (button.MyObject.have_tooltip) == "function") then
+ GameCooltip2:AddLine (button.MyObject.have_tooltip() or "")
+ else
+ GameCooltip2:AddLine (button.MyObject.have_tooltip)
+ end
+ GameCooltip2:ShowCooltip (button, "tooltip")
+ end
+ end
+
+ local OnLeave = function (button)
+
+ local capsule = button.MyObject
+
+ if (button.textureLeft and not button.MyObject.is_mouse_down) then
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+ end
+
+ local kill = capsule:RunHooksForWidget ("OnLeave", button, capsule)
+ if (kill) then
+ return
+ end
+
+ button.MyObject.is_mouse_over = false
+
+ if (button.texture and not button.MyObject.is_mouse_down) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Normal))
+ else
+ button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+ end
+
+ if (button.MyObject.onleave_backdrop_border_color) then
+ button:SetBackdropBorderColor (unpack (button.MyObject.onleave_backdrop_border_color))
+ end
+
+ if (button.MyObject.onleave_backdrop) then
+ button:SetBackdropColor (unpack (button.MyObject.onleave_backdrop))
+ end
+
+ if (button.MyObject.have_tooltip) then
+ if (GameCooltip2:GetText (1) == button.MyObject.have_tooltip or type (button.MyObject.have_tooltip) == "function") then
+ GameCooltip2:Hide()
+ end
+ end
+ end
+
+ local OnHide = function (button)
+ local capsule = button.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", button, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnShow = function (button)
+ local capsule = button.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", button, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnMouseDown = function (button, buttontype)
+ local capsule = button.MyObject
+
+ if (not button:IsEnabled()) then
+ return
+ end
+
+ if (button.textureTopLeft) then
+ button.textureLeft:SetTexCoord (0, 4/128, 72/128, 88/128)
+ button.textureRight:SetTexCoord (124/128, 1, 72/128, 88/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 65/128, 68/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 92/128, 96/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 65/128, 71/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 65/128, 71/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 88/128, 96/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 88/128, 96/128)
+ end
+
+ local kill = capsule:RunHooksForWidget ("OnMouseDown", button, capsule)
+ if (kill) then
+ return
+ end
+
+ button.MyObject.is_mouse_down = true
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Pushed))
+ else
+ button.texture:SetTexCoord (0, 1, 0.5078125, 0.75)
+ end
+ end
+
+ if (button.MyObject.capsule_textalign) then
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1)
+ elseif (button.MyObject.capsule_textalign == "left") then
+ button.text:SetPoint ("left", button, "left", 3, -1)
+ elseif (button.MyObject.capsule_textalign == "center") then
+ button.text:SetPoint ("center", button, "center", 1, -1)
+ elseif (button.MyObject.capsule_textalign == "right") then
+ button.text:SetPoint ("right", button, "right", -1, -1)
+ end
+ else
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 7 + (button.MyObject.icon.leftpadding or 0), -2)
+ else
+ button.text:SetPoint ("center", button,"center", 1, -1)
+ end
+ end
+
+ button.mouse_down = GetTime()
+ local x, y = GetCursorPosition()
+ button.x = _math_floor (x)
+ button.y = _math_floor (y)
+
+ if (not button.MyObject.container.isLocked and button.MyObject.container:IsMovable()) then
+ if (not button.isLocked and button:IsMovable()) then
+ button.MyObject.container.isMoving = true
+ button.MyObject.container:StartMoving()
+ end
+ end
+
+ if (button.MyObject.options.OnGrab) then
+ if (_type (button.MyObject.options.OnGrab) == "string" and button.MyObject.options.OnGrab == "PassClick") then
+ if (buttontype == "LeftButton") then
+ DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ else
+ DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ end
+ end
+ end
+ end
+
+ local OnMouseUp = function (button, buttontype)
+ if (not button:IsEnabled()) then
+ return
+ end
+
+ if (button.textureLeft) then
+ if (button.MyObject.is_mouse_over) then
+ button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128)
+ button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128)
+ else
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+ end
+ end
+
+ local capsule = button.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseUp", button, capsule)
+ if (kill) then
+ return
+ end
+
+ button.MyObject.is_mouse_down = false
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ if (button.MyObject.is_mouse_over) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight))
+ else
+ button.texture:SetTexCoord (_unpack (coords.Normal))
+ end
+ else
+ if (button.MyObject.is_mouse_over) then
+ button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375)
+ else
+ button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+ end
+ end
+
+ if (button.MyObject.capsule_textalign) then
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
+ elseif (button.MyObject.capsule_textalign == "left") then
+ button.text:SetPoint ("left", button, "left", 2, 0)
+ elseif (button.MyObject.capsule_textalign == "center") then
+ button.text:SetPoint ("center", button, "center", 0, 0)
+ elseif (button.MyObject.capsule_textalign == "right") then
+ button.text:SetPoint ("right", button, "right", -2, 0)
+ end
+ else
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
+ else
+ button.text:SetPoint ("center", button,"center", 0, 0)
+ end
+ end
+
+ if (button.MyObject.container.isMoving) then
+ button.MyObject.container:StopMovingOrSizing()
+ button.MyObject.container.isMoving = false
+ end
+
+ local x, y = GetCursorPosition()
+ x = _math_floor (x)
+ y = _math_floor (y)
+
+ button.mouse_down = button.mouse_down or 0 --avoid issues when the button was pressed while disabled and release when enabled
+
+ if (
+ (x == button.x and y == button.y) or
+ (button.mouse_down+0.5 > GetTime() and button:IsMouseOver())
+ ) then
+ if (buttontype == "LeftButton") then
+ DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ else
+ DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ end
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+
+function ButtonMetaFunctions:SetTemplate (template)
+
+ if (type (template) == "string") then
+ template = DF:GetTemplate ("button", template)
+ end
+
+ if (not template) then
+ DF:Error ("template not found")
+ return
+ end
+
+ if (template.width) then
+ self:SetWidth (template.width)
+ end
+ if (template.height) then
+ self:SetHeight (template.height)
+ end
+
+ if (template.backdrop) then
+ self:SetBackdrop (template.backdrop)
+ end
+ if (template.backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropcolor)
+ self:SetBackdropColor (r, g, b, a)
+ self.onleave_backdrop = {r, g, b, a}
+ end
+ if (template.backdropbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
+ self:SetBackdropBorderColor (r, g, b, a)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onentercolor) then
+ local r, g, b, a = DF:ParseColors (template.onentercolor)
+ self.onenter_backdrop = {r, g, b, a}
+ end
+
+ if (template.onleavecolor) then
+ local r, g, b, a = DF:ParseColors (template.onleavecolor)
+ self.onleave_backdrop = {r, g, b, a}
+ end
+
+ if (template.onenterbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onenterbordercolor)
+ self.onenter_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onleavebordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onleavebordercolor)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.icon) then
+ local i = template.icon
+ self:SetIcon (i.texture, i.width, i.height, i.layout, i.texcoord, i.color, i.textdistance, i.leftpadding)
+ end
+
+ if (template.textsize) then
+ self.textsize = template.textsize
+ end
+
+ if (template.textfont) then
+ self.textfont = template.textfont
+ end
+
+ if (template.textcolor) then
+ self.textcolor = template.textcolor
+ end
+
+ if (template.textalign) then
+ self.textalign = template.textalign
+ end
+end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+local build_button = function (self)
+ self:SetSize (100, 20)
+
+ self.text = self:CreateFontString ("$parent_Text", "ARTWORK", "GameFontNormal")
+ self.text:SetJustifyH ("CENTER")
+ DF:SetFontSize (self.text, 10)
+ self.text:SetPoint ("CENTER", self, "CENTER", 0, 0)
+
+ self.texture_disabled = self:CreateTexture ("$parent_TextureDisabled", "OVERLAY")
+ self.texture_disabled:SetAllPoints()
+ self.texture_disabled:Hide()
+ self.texture_disabled:SetTexture ("Interface\\Tooltips\\UI-Tooltip-Background")
+
+ self:SetScript ("OnDisable", function (self)
+ self.texture_disabled:Show()
+ self.texture_disabled:SetVertexColor (0, 0, 0)
+ self.texture_disabled:SetAlpha (.5)
+ end)
+
+ self:SetScript ("OnEnable", function (self)
+ self.texture_disabled:Hide()
+ end)
+end
+
+function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method, button_template, text_template)
+ return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method, button_template, text_template)
+end
+
+function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method, button_template, text_template)
+
+ if (not name) then
+ name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter
+ DF.ButtonCounter = DF.ButtonCounter + 1
+
+ elseif (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local ButtonObject = {type = "button", dframework = true}
+
+ if (member) then
+ parent [member] = ButtonObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ ButtonObject.is_locked = true
+ ButtonObject.container = container
+ ButtonObject.options = {OnGrab = false}
+
+ ButtonObject.button = CreateFrame ("button", name, parent)
+ DF:Mixin (ButtonObject.button, DF.WidgetFunctions)
+
+ build_button (ButtonObject.button)
+
+ ButtonObject.widget = ButtonObject.button
+
+ --ButtonObject.button:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}})
+ ButtonObject.button:SetBackdropColor (0, 0, 0, 0.4)
+ ButtonObject.button:SetBackdropBorderColor (1, 1, 1, 1)
+
+ if (not APIButtonFunctions) then
+ APIButtonFunctions = true
+ local idx = getmetatable (ButtonObject.button).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not ButtonMetaFunctions [funcName]) then
+ ButtonMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.button:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+
+ ButtonObject.button:SetWidth (w or 100)
+ ButtonObject.button:SetHeight (h or 20)
+ ButtonObject.button.MyObject = ButtonObject
+
+ ButtonObject.text_overlay = _G [name .. "_Text"]
+ ButtonObject.disabled_overlay = _G [name .. "_TextureDisabled"]
+
+ ButtonObject.button:SetNormalTexture (texture)
+ ButtonObject.button:SetPushedTexture (texture)
+ ButtonObject.button:SetDisabledTexture (texture)
+ ButtonObject.button:SetHighlightTexture (texture, "ADD")
+
+ ButtonObject.button.text:SetText (text)
+ ButtonObject.button.text:SetPoint ("center", ButtonObject.button, "center")
+
+ local text_width = ButtonObject.button.text:GetStringWidth()
+ if (text_width > w-15 and ButtonObject.button.text:GetText() ~= "") then
+ if (short_method == false) then --> if is false, do not use auto resize
+ --do nothing
+ elseif (not short_method) then --> if the value is omitted, use the default resize
+ local new_width = text_width+15
+ ButtonObject.button:SetWidth (new_width)
+
+ elseif (short_method == 1) then
+ local loop = true
+ local textsize = 11
+ while (loop) do
+ if (text_width+15 < w or textsize < 8) then
+ loop = false
+ break
+ else
+ DF:SetFontSize (ButtonObject.button.text, textsize)
+ text_width = ButtonObject.button.text:GetStringWidth()
+ textsize = textsize - 1
+ end
+ end
+
+ elseif (short_method == 2) then
+
+ end
+ end
+
+ ButtonObject.func = func or cleanfunction
+ ButtonObject.funcright = cleanfunction
+ ButtonObject.param1 = param1
+ ButtonObject.param2 = param2
+
+ ButtonObject.short_method = short_method
+
+ if (text_template) then
+ if (text_template.size) then
+ DF:SetFontSize (ButtonObject.button.text, text_template.size)
+ end
+ if (text_template.color) then
+ local r, g, b, a = DF:ParseColors (text_template.color)
+ ButtonObject.button.text:SetTextColor (r, g, b, a)
+ end
+ if (text_template.font) then
+ local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+ local font = SharedMedia:Fetch ("font", text_template.font)
+ DF:SetFontFace (ButtonObject.button.text, font)
+ end
+ end
+
+ --> hooks
+ ButtonObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnMouseDown = {},
+ OnMouseUp = {},
+ }
+
+ ButtonObject.button:SetScript ("OnEnter", OnEnter)
+ ButtonObject.button:SetScript ("OnLeave", OnLeave)
+ ButtonObject.button:SetScript ("OnHide", OnHide)
+ ButtonObject.button:SetScript ("OnShow", OnShow)
+ ButtonObject.button:SetScript ("OnMouseDown", OnMouseDown)
+ ButtonObject.button:SetScript ("OnMouseUp", OnMouseUp)
+
+ _setmetatable (ButtonObject, ButtonMetaFunctions)
+
+ if (button_template) then
+ ButtonObject:SetTemplate (button_template)
+ end
+
+ return ButtonObject
+
+end
+
+local pickcolor_callback = function (self, r, g, b, a, button)
+ a = abs (a-1)
+ button.MyObject.color_texture:SetVertexColor (r, g, b, a)
+
+ --> safecall
+ DF:CoreDispatch ((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, r, g, b, a)
+ button.MyObject:RunHooksForWidget ("OnColorChanged", button.MyObject, r, g, b, a)
+end
+
+local pickcolor = function (self, alpha, param2)
+ local r, g, b, a = self.MyObject.color_texture:GetVertexColor()
+ a = abs (a-1)
+ DF:ColorPick (self, r, g, b, a, pickcolor_callback)
+end
+
+local color_button_height = 16
+local color_button_width = 16
+
+local set_colorpick_color = function (button, r, g, b, a)
+ a = a or 1
+ button.color_texture:SetVertexColor (r, g, b, a)
+end
+
+local colorpick_cancel = function (self)
+ ColorPickerFrame:Hide()
+end
+
+function DF:CreateColorPickButton (parent, name, member, callback, alpha, button_template)
+ return DF:NewColorPickButton (parent, name, member, callback, alpha, button_template)
+end
+
+function DF:NewColorPickButton (parent, name, member, callback, alpha, button_template)
+
+ --button
+ local button = DF:NewButton (parent, _, name, member, color_button_width, color_button_height, pickcolor, alpha, "param2", nil, nil, nil, button_template)
+ button.color_callback = callback
+ button.Cancel = colorpick_cancel
+ button.SetColor = set_colorpick_color
+
+ button.HookList.OnColorChanged = {}
+
+ if (not button_template) then
+ button:InstallCustomTexture()
+ button:SetBackdrop ({edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 6,
+ bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], insets = {left = 0, right = 0, top = 0, bottom = 0}})
+ end
+
+ --textura do fundo
+ local background = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, nil, "$parentBck")
+ --background:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ background:SetPoint ("topleft", button.widget, "topleft", 1, -2)
+ background:SetPoint ("bottomright", button.widget, "bottomright", -1, 1)
+ background:SetTexCoord (0.337890625, 0.390625, 0.625, 0.658203125)
+ background:SetDrawLayer ("background", 1)
+
+ --textura da cor
+ local img = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, "color_texture", "$parentTex")
+ img:SetColorTexture (1, 1, 1)
+ img:SetPoint ("topleft", button.widget, "topleft", 1, -2)
+ img:SetPoint ("bottomright", button.widget, "bottomright", -1, 1)
+ img:SetDrawLayer ("background", 2)
+
+ return button
+
+end
diff --git a/libs/DF/button.xml b/libs/DF/button.xml
new file mode 100644
index 0000000..aa885f3
--- /dev/null
+++ b/libs/DF/button.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/libs/DF/colors.lua b/libs/DF/colors.lua
new file mode 100644
index 0000000..ec28bdc
--- /dev/null
+++ b/libs/DF/colors.lua
@@ -0,0 +1,174 @@
+do
+
+ local DF = _G ["DetailsFramework"]
+
+ if (not DF or not DetailsFrameworkCanLoad) then
+ return
+ end
+
+ DF.alias_text_colors = DF.alias_text_colors or {}
+
+ local defaultColors = {
+ ["HUNTER"] = {0.67, 0.83, 0.45},
+ ["WARLOCK"] = {0.58, 0.51, 0.79},
+ ["PRIEST"] = {1.0, 1.0, 1.0},
+ ["PALADIN"] = {0.96, 0.55, 0.73},
+ ["MAGE"] = {0.41, 0.8, 0.94},
+ ["ROGUE"] = {1.0, 0.96, 0.41},
+ ["DRUID"] = {1.0, 0.49, 0.04},
+ ["SHAMAN"] = {0.0, 0.44, 0.87},
+ ["WARRIOR"] = {0.78, 0.61, 0.43},
+ ["DEATHKNIGHT"] = {0.77, 0.12, 0.23},
+ ["MONK"] = {0.0, 1.00, 0.59},
+ ["DEMONHUNTER"] = {0.64, 0.19, 0.79},
+
+ ["aliceblue"] = {0.941176, 0.972549, 1, 1},
+ ["antiquewhite"] = {0.980392, 0.921569, 0.843137, 1},
+ ["aqua"] = {0, 1, 1, 1},
+ ["aquamarine"] = {0.498039, 1, 0.831373, 1},
+ ["azure"] = {0.941176, 1, 1, 1},
+ ["beige"] = {0.960784, 0.960784, 0.862745, 1},
+ ["bisque"] = {1, 0.894118, 0.768627, 1},
+ ["black"] = {0, 0, 0, 1},
+ ["blanchedalmond"] = {1, 0.921569, 0.803922, 1},
+ ["blue"] = {0, 0, 1, 1},
+ ["blueviolet"] = {0.541176, 0.168627, 0.886275, 1},
+ ["brown"] = {0.647059, 0.164706, 0.164706, 1},
+ ["burlywood"] = {0.870588, 0.721569, 0.529412, 1},
+ ["cadetblue"] = {0.372549, 0.619608, 0.627451, 1},
+ ["chartreuse"] = {0.498039, 1, 0, 1},
+ ["chocolate"] = {0.823529, 0.411765, 0.117647, 1},
+ ["coral"] = {1, 0.498039, 0.313725, 1},
+ ["cornflowerblue"] = {0.392157, 0.584314, 0.929412, 1},
+ ["cornsilk"] = {1, 0.972549, 0.862745, 1},
+ ["crimson"] = {0.862745, 0.0784314, 0.235294, 1},
+ ["cyan"] = {0, 1, 1, 1},
+ ["darkblue"] = {0, 0, 0.545098, 1},
+ ["darkcyan"] = {0, 0.545098, 0.545098, 1},
+ ["darkgoldenrod"] = {0.721569, 0.52549, 0.0431373, 1},
+ ["darkgray"] = {0.662745, 0.662745, 0.662745, 1},
+ ["darkgreen"] = {0, 0.392157, 0, 1},
+ ["darkkhaki"] = {0.741176, 0.717647, 0.419608, 1},
+ ["darkmagenta"] = {0.545098, 0, 0.545098, 1},
+ ["darkolivegreen"] = {0.333333, 0.419608, 0.184314, 1},
+ ["darkorange"] = {1, 0.54902, 0, 1},
+ ["darkorchid"] = {0.6, 0.196078, 0.8, 1},
+ ["darkred"] = {0.545098, 0, 0, 1},
+ ["darksalmon"] = {0.913725, 0.588235, 0.478431, 1},
+ ["darkseagreen"] = {0.560784, 0.737255, 0.560784, 1},
+ ["darkslateblue"] = {0.282353, 0.239216, 0.545098, 1},
+ ["darkslategray"] = {0.184314, 0.309804, 0.309804, 1},
+ ["darkturquoise"] = {0, 0.807843, 0.819608, 1},
+ ["darkviolet"] = {0.580392, 0, 0.827451, 1},
+ ["deeppink"] = {1, 0.0784314, 0.576471, 1},
+ ["deepskyblue"] = {0, 0.74902, 1, 1},
+ ["dimgray"] = {0.411765, 0.411765, 0.411765, 1},
+ ["dimgrey"] = {0.411765, 0.411765, 0.411765, 1},
+ ["dodgerblue"] = {0.117647, 0.564706, 1, 1},
+ ["firebrick"] = {0.698039, 0.133333, 0.133333, 1},
+ ["floralwhite"] = {1, 0.980392, 0.941176, 1},
+ ["forestgreen"] = {0.133333, 0.545098, 0.133333, 1},
+ ["fuchsia"] = {1, 0, 1, 1},
+ ["gainsboro"] = {0.862745, 0.862745, 0.862745, 1},
+ ["ghostwhite"] = {0.972549, 0.972549, 1, 1},
+ ["gold"] = {1, 0.843137, 0, 1},
+ ["goldenrod"] = {0.854902, 0.647059, 0.12549, 1},
+ ["gray"] = {0.501961, 0.501961, 0.501961, 1},
+ ["green"] = {0, 0.501961, 0, 1},
+ ["greenyellow"] = {0.678431, 1, 0.184314, 1},
+ ["honeydew"] = {0.941176, 1, 0.941176, 1},
+ ["hotpink"] = {1, 0.411765, 0.705882, 1},
+ ["indianred"] = {0.803922, 0.360784, 0.360784, 1},
+ ["indigo"] = {0.294118, 0, 0.509804, 1},
+ ["ivory"] = {1, 1, 0.941176, 1},
+ ["khaki"] = {0.941176, 0.901961, 0.54902, 1},
+ ["lavender"] = {0.901961, 0.901961, 0.980392, 1},
+ ["lavenderblush"] = {1, 0.941176, 0.960784, 1},
+ ["lawngreen"] = {0.486275, 0.988235, 0, 1},
+ ["lemonchiffon"] = {1, 0.980392, 0.803922, 1},
+ ["lightblue"] = {0.678431, 0.847059, 0.901961, 1},
+ ["lightcoral"] = {0.941176, 0.501961, 0.501961, 1},
+ ["lightcyan"] = {0.878431, 1, 1, 1},
+ ["lightgoldenrodyellow"] = {0.980392, 0.980392, 0.823529, 1},
+ ["lightgray"] = {0.827451, 0.827451, 0.827451, 1},
+ ["lightgreen"] = {0.564706, 0.933333, 0.564706, 1},
+ ["lightpink"] = {1, 0.713725, 0.756863, 1},
+ ["lightsalmon"] = {1, 0.627451, 0.478431, 1},
+ ["lightseagreen"] = {0.12549, 0.698039, 0.666667, 1},
+ ["lightskyblue"] = {0.529412, 0.807843, 0.980392, 1},
+ ["lightslategray"] = {0.466667, 0.533333, 0.6, 1},
+ ["lightsteelblue"] = {0.690196, 0.768627, 0.870588, 1},
+ ["lightyellow"] = {1, 1, 0.878431, 1},
+ ["lime"] = {0, 1, 0, 1},
+ ["limegreen"] = {0.196078, 0.803922, 0.196078, 1},
+ ["linen"] = {0.980392, 0.941176, 0.901961, 1},
+ ["magenta"] = {1, 0, 1, 1},
+ ["maroon"] = {0.501961, 0, 0, 1},
+ ["mediumaquamarine"] = {0.4, 0.803922, 0.666667, 1},
+ ["mediumblue"] = {0, 0, 0.803922, 1},
+ ["mediumorchid"] = {0.729412, 0.333333, 0.827451, 1},
+ ["mediumpurple"] = {0.576471, 0.439216, 0.858824, 1},
+ ["mediumseagreen"] = {0.235294, 0.701961, 0.443137, 1},
+ ["mediumslateblue"] = {0.482353, 0.407843, 0.933333, 1},
+ ["mediumspringgreen"] = {0, 0.980392, 0.603922, 1},
+ ["mediumturquoise"] = {0.282353, 0.819608, 0.8, 1},
+ ["mediumvioletred"] = {0.780392, 0.0823529, 0.521569, 1},
+ ["midnightblue"] = {0.0980392, 0.0980392, 0.439216, 1},
+ ["mintcream"] = {0.960784, 1, 0.980392, 1},
+ ["mistyrose"] = {1, 0.894118, 0.882353, 1},
+ ["moccasin"] = {1, 0.894118, 0.709804, 1},
+ ["navajowhite"] = {1, 0.870588, 0.678431, 1},
+ ["navy"] = {0, 0, 0.501961, 1},
+ ["none"] ={0, 0, 0, 0},
+ ["oldlace"] = {0.992157, 0.960784, 0.901961, 1},
+ ["olive"] = {0.501961, 0.501961, 0, 1},
+ ["olivedrab"] = {0.419608, 0.556863, 0.137255, 1},
+ ["orange"] = {1, 0.647059, 0, 1},
+ ["orangered"] = {1, 0.270588, 0, 1},
+ ["orchid"] = {0.854902, 0.439216, 0.839216, 1},
+ ["palegoldenrod"] = {0.933333, 0.909804, 0.666667, 1},
+ ["palegreen"] = {0.596078, 0.984314, 0.596078, 1},
+ ["paleturquoise"] = {0.686275, 0.933333, 0.933333, 1},
+ ["palevioletred"] = {0.858824, 0.439216, 0.576471, 1},
+ ["papayawhip"] = {1, 0.937255, 0.835294, 1},
+ ["peachpuff"] = {1, 0.854902, 0.72549, 1},
+ ["peru"] = {0.803922, 0.521569, 0.247059, 1},
+ ["pink"] = {1, 0.752941, 0.796078, 1},
+ ["plum"] = {0.866667, 0.627451, 0.866667, 1},
+ ["powderblue"] = {0.690196, 0.878431, 0.901961, 1},
+ ["purple"] = {0.501961, 0, 0.501961, 1},
+ ["red"] = {1, 0, 0, 1},
+ ["rosybrown"] = {0.737255, 0.560784, 0.560784, 1},
+ ["royalblue"] = {0.254902, 0.411765, 0.882353, 1},
+ ["saddlebrown"] = {0.545098, 0.270588, 0.0745098, 1},
+ ["salmon"] = {0.980392, 0.501961, 0.447059, 1},
+ ["sandybrown"] = {0.956863, 0.643137, 0.376471, 1},
+ ["seagreen"] = {0.180392, 0.545098, 0.341176, 1},
+ ["seashell"] = {1, 0.960784, 0.933333, 1},
+ ["sienna"] = {0.627451, 0.321569, 0.176471, 1},
+ ["silver"] = {0.752941, 0.752941, 0.752941, 1},
+ ["skyblue"] = {0.529412, 0.807843, 0.921569, 1},
+ ["slateblue"] = {0.415686, 0.352941, 0.803922, 1},
+ ["slategray"] = {0.439216, 0.501961, 0.564706, 1},
+ ["snow"] = {1, 0.980392, 0.980392, 1},
+ ["springgreen"] = {0, 1, 0.498039, 1},
+ ["steelblue"] = {0.27451, 0.509804, 0.705882, 1},
+ ["tan"] = {0.823529, 0.705882, 0.54902, 1},
+ ["teal"] = {0, 0.501961, 0.501961, 1},
+ ["thistle"] = {0.847059, 0.74902, 0.847059, 1},
+ ["tomato"] = {1, 0.388235, 0.278431, 1},
+ ["transparent"] ={0, 0, 0, 0},
+ ["turquoise"] = {0.25098, 0.878431, 0.815686, 1},
+ ["violet"] = {0.933333, 0.509804, 0.933333, 1},
+ ["wheat"] = {0.960784, 0.870588, 0.701961, 1},
+ ["white"] = {1, 1, 1, 1},
+ ["whitesmoke"] = {0.960784, 0.960784, 0.960784, 1},
+ ["yellow"] = {1, 1, 0, 1},
+ ["yellowgreen"] = {0.603922, 0.803922, 0.196078, 1}
+ }
+
+ for colorName, colorTable in pairs (defaultColors) do
+ DF.alias_text_colors [colorName] = colorTable
+ end
+
+end
diff --git a/libs/DF/cooltip.lua b/libs/DF/cooltip.lua
new file mode 100644
index 0000000..25aa890
--- /dev/null
+++ b/libs/DF/cooltip.lua
@@ -0,0 +1,3413 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+local _
+--lua locals
+local _math_floor= math.floor
+local _type = type
+local _math_abs = math.abs
+local _tinsert = tinsert
+local _unpack = unpack
+local _ipairs = ipairs
+local _table_wipe = table.wipe
+local _table_insert = table.insert
+local _math_max = math.max
+--api locals
+local _GetScreenWidth = GetScreenWidth
+local _GetScreenHeight = GetScreenHeight
+local _UIParent = UIParent
+local _CreateFrame = CreateFrame
+
+local version = 2
+
+function DF:CreateCoolTip()
+
+----------------------------------------------------------------------
+ --> Cooltip Startup
+----------------------------------------------------------------------
+
+ --> if a cooltip is already created with a higher version
+ if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then
+ return
+ end
+
+ --> initialize
+ local CoolTip = {
+ version = version
+ }
+ _G.GameCooltip2 = CoolTip
+
+ --> containers
+ CoolTip.LeftTextTable = {}
+ CoolTip.LeftTextTableSub = {}
+ CoolTip.RightTextTable = {}
+ CoolTip.RightTextTableSub = {}
+ CoolTip.LeftIconTable = {}
+ CoolTip.LeftIconTableSub = {}
+ CoolTip.RightIconTable = {}
+ CoolTip.RightIconTableSub = {}
+ CoolTip.Banner = {false, false, false}
+ CoolTip.TopIconTableSub = {}
+ CoolTip.StatusBarTable = {}
+ CoolTip.StatusBarTableSub = {}
+ CoolTip.WallpaperTable = {}
+ CoolTip.WallpaperTableSub = {}
+
+ CoolTip.PopupFrameTable = {}
+
+ CoolTip.FunctionsTableMain = {} --> menus
+ CoolTip.FunctionsTableSub = {} --> menus
+ CoolTip.ParametersTableMain = {} --> menus
+ CoolTip.ParametersTableSub = {} --> menus
+
+ CoolTip.FixedValue = nil --> menus
+ CoolTip.SelectedIndexMain = nil --> menus
+ CoolTip.SelectedIndexSec = {} --> menus
+
+ --options table
+ CoolTip.OptionsList = {
+ ["RightTextMargin"] = true,
+ ["IconSize"] = true,
+ ["HeightAnchorMod"] = true,
+ ["WidthAnchorMod"] = true,
+ ["MinWidth"] = true,
+ ["FixedWidth"] = true,
+ ["FixedHeight"] = true,
+ ["FixedWidthSub"] = true,
+ ["FixedHeightSub"] = true,
+ ["AlignAsBlizzTooltip"] = true,
+ ["AlignAsBlizzTooltipFrameHeightOffset"] = true,
+ ["IgnoreSubMenu"] = true,
+ ["IgnoreButtonAutoHeight"] = true,
+ ["TextHeightMod"] = true,
+ ["ButtonHeightMod"] = true,
+ ["ButtonHeightModSub"] = true,
+ ["YSpacingMod"] = true,
+ ["YSpacingModSub"] = true,
+ ["ButtonsYMod"] = true,
+ ["ButtonsYModSub"] = true,
+ ["IconHeightMod"] = true,
+ ["StatusBarHeightMod"] = true,
+ ["StatusBarTexture"] = true,
+ ["TextSize"] = true,
+ ["TextFont"] = true,
+ ["TextColor"] = true,
+ ["TextColorRight"] = true,
+ ["TextShadow"] = true,
+ ["LeftTextWidth"] = true,
+ ["RightTextWidth"] = true,
+ ["LeftTextHeight"] = true,
+ ["RightTextHeight"] = true,
+ ["NoFade"] = true,
+ ["MyAnchor"] = true,
+ ["Anchor"] = true,
+ ["RelativeAnchor"] = true,
+ ["NoLastSelectedBar"] = true,
+ ["SubMenuIsTooltip"] = true,
+ ["LeftBorderSize"] = true,
+ ["RightBorderSize"] = true,
+ ["HeighMod"] = true,
+ ["HeighModSub"] = true,
+ ["IconBlendMode"] = true,
+ ["IconBlendModeHover"] = true,
+ ["SubFollowButton"] = true,
+ ["IgnoreArrows"] = true,
+ ["SelectedTopAnchorMod"] = true,
+ ["SelectedBottomAnchorMod"] = true,
+ ["SelectedLeftAnchorMod"] = true,
+ ["SelectedRightAnchorMod"] = true,
+ }
+
+ CoolTip.AliasList = {
+ ["VerticalOffset"] = "ButtonsYMod",
+ ["VerticalPadding"] = "YSpacingMod",
+ ["LineHeightSizeOffset"] = "ButtonHeightMod",
+ ["FrameHeightSizeOffset"] = "HeighMod",
+
+ }
+
+ CoolTip.OptionsTable = {}
+
+ --cprops
+ CoolTip.Indexes = 0 --> amount of lines current on shown
+ CoolTip.IndexesSub = {} --> amount of lines current on shown
+ CoolTip.HaveSubMenu = false --> amount of lines current on shown
+ CoolTip.SubIndexes = 0 --> amount of lines current on shown on sub menu
+ CoolTip.Type = 1 --> 1 tooltip 2 tooltip with bars 3 menu 4 menu + submenus
+ CoolTip.Host = nil --> frame to anchor
+ CoolTip.LastSize = 0 --> last size
+
+ CoolTip.LastIndex = 0
+
+ CoolTip.internal_x_mod = 0
+ CoolTip.internal_y_mod = 0
+ CoolTip.overlap_checked = false
+
+ --defaults
+ CoolTip.default_height = 20
+ CoolTip.default_text_size = 10.5
+ CoolTip.default_text_font = "GameFontHighlight"
+
+ CoolTip.selected_anchor = {}
+ CoolTip.selected_anchor.left = 2
+ CoolTip.selected_anchor.right = 0
+ CoolTip.selected_anchor.top = 0
+ CoolTip.selected_anchor.bottom = 0
+
+ CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT")
+
+ --> create frames
+
+ local build_main_frame = function (self)
+
+ self:SetSize (500, 500)
+ self:SetPoint ("CENTER", UIParent, "CENTER")
+ self:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
+ self:SetBackdropColor (0.09019, 0.09019, 0.18823, 1)
+ self:SetBackdropBorderColor (0, 0, 0, 1)
+
+ if (not self.framebackgroundCenter) then
+ self.framebackgroundCenter = self:CreateTexture ("$parent_FrameBackgroundCenter", "BACKGROUND")
+ self.framebackgroundCenter:SetDrawLayer ("BACKGROUND", 2)
+ self.framebackgroundCenter:SetColorTexture (0, 0, 0, .5)
+ self.framebackgroundCenter:SetPoint ("TOPLEFT", self, "TOPLEFT", 35, -3)
+ self.framebackgroundCenter:SetPoint ("TOPRIGHT", self, "TOPRIGHT", -35, -3)
+ self.framebackgroundCenter:SetPoint ("BOTTOMLEFT", self, "BOTTOMLEFT", 35, 3)
+ self.framebackgroundCenter:SetPoint ("BOTTOMRIGHT", self, "BOTTOMRIGHT", -35, 3)
+ end
+
+ if (not self.framebackgroundLeft) then
+ self.framebackgroundLeft = self:CreateTexture ("$parent_FrameBackgroundLeft", "BACKGROUND")
+ self.framebackgroundLeft:SetDrawLayer ("BACKGROUND", 3)
+ self.framebackgroundLeft:SetColorTexture (0, 0, 0, .5)
+ self.framebackgroundLeft:SetPoint ("TOPLEFT", self, "TOPLEFT", 3, -3)
+ self.framebackgroundLeft:SetPoint ("BOTTOMLEFT", self, "BOTTOMLEFT", 3, 3)
+ self.framebackgroundLeft:SetWidth (32)
+ end
+
+ if (not self.framebackgroundRight) then
+ self.framebackgroundRight = self:CreateTexture ("$parent_FrameBackgroundRight", "BACKGROUND")
+ self.framebackgroundRight:SetDrawLayer ("BACKGROUND", 3)
+ self.framebackgroundRight:SetColorTexture (0, 0, 0, .5)
+ self.framebackgroundRight:SetPoint ("TOPRIGHT", self, "TOPRIGHT", -3, -3)
+ self.framebackgroundRight:SetPoint ("BOTTOMRIGHT", self, "BOTTOMRIGHT", -3, 3)
+ self.framebackgroundRight:SetWidth (32)
+ end
+
+ if (not self.frameWallpaper) then
+ self.frameWallpaper = self:CreateTexture ("$parent_FrameWallPaper", "BACKGROUND")
+ self.frameWallpaper:SetDrawLayer ("BACKGROUND", 4)
+ self.frameWallpaper:SetPoint ("TOPLEFT", self, "TOPLEFT", 0, 0)
+ self.frameWallpaper:SetPoint ("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, 0)
+ end
+
+ if (not self.selectedTop) then
+ self.selectedTop = self:CreateTexture ("$parent_SelectedTop", "ARTWORK")
+ self.selectedTop:SetColorTexture (.5, .5, .5, .75)
+ self.selectedTop:SetHeight (3)
+ end
+
+ if (not self.selectedBottom) then
+ self.selectedBottom = self:CreateTexture ("$parent_SelectedBottom", "ARTWORK")
+ self.selectedBottom:SetColorTexture (.5, .5, .5, .75)
+ self.selectedBottom:SetHeight (3)
+ end
+
+ if (not self.selectedMiddle) then
+ self.selectedMiddle = self:CreateTexture ("$parent_Selected", "ARTWORK")
+ self.selectedMiddle:SetColorTexture (.5, .5, .5, .75)
+ self.selectedMiddle:SetPoint ("TOPLEFT", self.selectedTop, "BOTTOMLEFT")
+ self.selectedMiddle:SetPoint ("BOTTOMRIGHT", self.selectedBottom, "TOPRIGHT")
+ end
+
+ if (not self.upperImage2) then
+ self.upperImage2 = self:CreateTexture ("$parent_UpperImage2", "ARTWORK")
+ self.upperImage2:Hide()
+ self.upperImage2:SetPoint ("CENTER", self, "CENTER", 0, -3)
+ self.upperImage2:SetPoint ("BOTTOM", self, "TOP", 0, -3)
+ end
+
+ if (not self.upperImage) then
+ self.upperImage = self:CreateTexture ("$parent_UpperImage", "OVERLAY")
+ self.upperImage:Hide()
+ self.upperImage:SetPoint ("CENTER", self, "CENTER", 0, -3)
+ self.upperImage:SetPoint ("BOTTOM", self, "TOP", 0, -3)
+ end
+
+ if (not self.upperImageText) then
+ self.upperImageText = self:CreateFontString ("$parent_UpperImageText", "OVERLAY", "GameTooltipHeaderText")
+ self.upperImageText:SetJustifyH ("LEFT")
+ self.upperImageText:SetPoint ("LEFT", self.upperImage, "RIGHT", 5, 0)
+ DF:SetFontSize (self.upperImageText, 13)
+ end
+
+ if (not self.upperImageText2) then
+ self.upperImageText2 = self:CreateFontString ("$parent_UpperImageText2", "OVERLAY", "GameTooltipHeaderText")
+ self.upperImageText2:SetJustifyH ("LEFT")
+ self.upperImageText2:SetPoint ("BOTTOMRIGHT", self, "LEFT", 0, 3)
+ DF:SetFontSize (self.upperImageText2, 13)
+ end
+
+ if (not self.titleIcon) then
+ self.titleIcon = self:CreateTexture ("$parent_TitleIcon", "OVERLAY")
+ self.titleIcon:SetTexture ("Interface\\Challenges\\challenges-main")
+ self.titleIcon:SetTexCoord (0.1521484375, 0.563671875, 0.160859375, 0.234375)
+ self.titleIcon:SetPoint ("CENTER", self, "CENTER")
+ self.titleIcon:SetPoint ("BOTTOM", self, "TOP", 0, -22)
+ self.titleIcon:Hide()
+ end
+
+ if (not self.titleText) then
+ self.titleText = self:CreateFontString ("$parent_TitleText", "OVERLAY", "GameFontHighlightSmall")
+ self.titleText:SetJustifyH ("LEFT")
+ DF:SetFontSize (self.titleText, 10)
+ self.titleText:SetPoint ("CENTER", self.titleIcon, "CENTER", 0, 6)
+ end
+ end
+
+ --> main frame
+ local frame1
+ if (not GameCooltipFrame1) then
+ frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent)
+
+ tinsert (UISpecialFrames, "GameCooltipFrame1")
+ DF:CreateFlashAnimation (frame1)
+
+ --removing the border makes the cooltip much more clear
+ if (DF.CreateBorder) then
+ DF:CreateBorder (frame1, .3, .1, .03)
+ frame1:SetBorderAlpha (0, 0, 0)
+ end
+ else
+ frame1 = GameCooltipFrame1
+ end
+
+ --> build widgets for frame
+ build_main_frame (frame1)
+
+ GameCooltipFrame1_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
+ GameCooltipFrame1_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
+ GameCooltipFrame1_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
+
+ --> secondary frame
+ local frame2
+ if (not GameCooltipFrame2) then
+ frame2 = CreateFrame ("Frame", "GameCooltipFrame2", UIParent)
+
+ tinsert (UISpecialFrames, "GameCooltipFrame2")
+ DF:CreateFlashAnimation (frame2)
+ frame2:SetClampedToScreen (true)
+
+ --removing the border makes the cooltip much more clear
+ if (DF.CreateBorder) then
+ DF:CreateBorder (frame2, .3, .1, .03)
+ frame2:SetBorderAlpha (0, 0, 0)
+ end
+ else
+ frame2 = GameCooltipFrame2
+ end
+
+ --> build widgets for frame
+ build_main_frame (frame2)
+
+ frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0)
+
+ GameCooltipFrame2_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
+ GameCooltipFrame2_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
+ GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
+
+ CoolTip.frame1 = frame1
+ CoolTip.frame2 = frame2
+ DF:FadeFrame (frame1, 0)
+ DF:FadeFrame (frame2, 0)
+
+ --> line container
+ frame1.Lines = {}
+ frame2.Lines = {}
+
+----------------------------------------------------------------------
+ --> Title Function
+----------------------------------------------------------------------
+
+ function CoolTip:SetTitle (_f, text)
+ if (_f == 1) then
+ CoolTip.title1 = true
+ CoolTip.title_text = text
+ end
+ end
+
+ function CoolTip:SetTitleAnchor (_f, _anchor, ...)
+ _anchor = string.lower (_anchor)
+ if (_f == 1) then
+ self.frame1.titleIcon:ClearAllPoints()
+ self.frame1.titleText:ClearAllPoints()
+
+ if (_anchor == "left") then
+ self.frame1.titleIcon:SetPoint ("left", frame1, "left", ...)
+ self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
+
+ elseif (_anchor == "center") then
+ self.frame1.titleIcon:SetPoint ("center", frame1, "center")
+ self.frame1.titleIcon:SetPoint ("bottom", frame1, "top")
+ self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
+ self.frame1.titleText:SetText ("TESTE")
+
+ self.frame1.titleText:Show()
+ self.frame1.titleIcon:Show()
+
+ elseif (_anchor == "right") then
+ self.frame1.titleIcon:SetPoint ("right", frame1, "right", ...)
+ self.frame1.titleText:SetPoint ("right", frame1.titleIcon, "left")
+
+ end
+ elseif (_f == 2) then
+ self.frame2.titleIcon:ClearAllPoints()
+ self.frame2.titleText:ClearAllPoints()
+ if (_anchor == "left") then
+ self.frame2.titleIcon:SetPoint ("left", frame2, "left", ...)
+ self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
+ elseif (_anchor == "center") then
+ self.frame2.titleIcon:SetPoint ("center", frame2, "center", ...)
+ self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
+ elseif (_anchor == "right") then
+ self.frame2.titleIcon:SetPoint ("right", frame2, "right", ...)
+ self.frame2.titleText:SetPoint ("right", frame2.titleIcon, "left")
+ end
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Button Hide and Show Functions
+----------------------------------------------------------------------
+
+ local elapsedTime = 0
+
+ CoolTip.mouseOver = false
+ CoolTip.buttonClicked = false
+
+ frame1:SetScript ("OnEnter", function (self)
+ --> is cooltip a menu?
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+ self:SetScript ("OnUpdate", nil)
+ DF:FadeFrame (self, 0)
+
+ if (CoolTip.sub_menus) then
+ DF:FadeFrame (frame2, 0)
+ end
+ end
+ end)
+
+ frame2:SetScript ("OnEnter", function (self)
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ return CoolTip:Close()
+ end
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+ self:SetScript ("OnUpdate", nil)
+ DF:FadeFrame (self, 0)
+ DF:FadeFrame (frame1, 0)
+ end
+ end)
+
+ local OnLeaveUpdateFrame1 = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
+ DF:FadeFrame (self, 1)
+ DF:FadeFrame (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:FadeFrame (self, 1)
+ DF:FadeFrame (frame2, 1)
+ end
+ self:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ frame1:SetScript ("OnLeave", function (self)
+
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
+ end
+ end)
+
+ local OnLeaveUpdateFrame2 = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
+ DF:FadeFrame (self, 1)
+ DF:FadeFrame (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:FadeFrame (self, 1)
+ DF:FadeFrame (frame2, 1)
+ end
+ self:SetScript ("OnUpdate", nil)
+ frame1:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ frame2:SetScript ("OnLeave", function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
+
+ end
+ end)
+
+ frame1:SetScript ("OnHide", function (self)
+ CoolTip.active = false
+ CoolTip.buttonClicked = false
+ CoolTip.mouseOver = false
+
+ --> reset parent and strata
+ frame1:SetParent (UIParent)
+ frame2:SetParent (UIParent)
+ frame1:SetFrameStrata ("TOOLTIP")
+ frame2:SetFrameStrata ("TOOLTIP")
+ end)
+
+----------------------------------------------------------------------
+ --> Button Creation Functions
+----------------------------------------------------------------------
+
+ local build_button = function (self)
+
+ self:SetSize (1, 20)
+
+ --> status bar
+ self.statusbar = CreateFrame ("StatusBar", "$Parent_StatusBar", self)
+ self.statusbar:SetPoint ("LEFT", self, "LEFT", 10, 0)
+ self.statusbar:SetPoint ("RIGHT", self, "RIGHT", -10, 0)
+ self.statusbar:SetPoint ("TOP", self, "TOP", 0, 0)
+ self.statusbar:SetPoint ("BOTTOM", self, "BOTTOM", 0, 0)
+ self.statusbar:SetHeight (20)
+
+ local statusbar = self.statusbar
+
+ statusbar.texture = statusbar:CreateTexture ("$parent_Texture", "BACKGROUND")
+ statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
+ statusbar.texture:SetSize (300, 14)
+ statusbar:SetStatusBarTexture (statusbar.texture)
+ statusbar:SetMinMaxValues (0, 100)
+
+ statusbar.spark = statusbar:CreateTexture ("$parent_Spark", "BACKGROUND")
+ statusbar.spark:Hide()
+ statusbar.spark:SetTexture ("Interface\\CastingBar\\UI-CastingBar-Spark")
+ statusbar.spark:SetBlendMode ("ADD")
+ statusbar.spark:SetSize (12, 24)
+ statusbar.spark:SetPoint ("LEFT", statusbar, "RIGHT", -20, -1)
+
+ statusbar.background = statusbar:CreateTexture ("$parent_Background", "ARTWORK")
+ statusbar.background:Hide()
+ statusbar.background:SetTexture ("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
+ statusbar.background:SetPoint ("LEFT", statusbar, "LEFT", -6, 0)
+ statusbar.background:SetPoint ("RIGHT", statusbar, "RIGHT", 6, 0)
+ statusbar.background:SetPoint ("TOP", statusbar, "TOP", 0, 0)
+ statusbar.background:SetPoint ("BOTTOM", statusbar, "BOTTOM", 0, 0)
+
+ self.background = statusbar.background
+
+ statusbar.leftIcon = statusbar:CreateTexture ("$parent_LeftIcon", "OVERLAY")
+ statusbar.leftIcon:SetSize (16, 16)
+ statusbar.leftIcon:SetPoint ("LEFT", statusbar, "LEFT", 0, 0)
+
+ statusbar.rightIcon = statusbar:CreateTexture ("$parent_RightIcon", "OVERLAY")
+ statusbar.rightIcon:SetSize (16, 16)
+ statusbar.rightIcon:SetPoint ("RIGHT", statusbar, "RIGHT", 0, 0)
+
+ statusbar.spark2 = statusbar:CreateTexture ("$parent_Spark2", "OVERLAY")
+ statusbar.spark2:SetSize (32, 32)
+ statusbar.spark2:SetPoint ("LEFT", statusbar, "RIGHT", -17, -1)
+ statusbar.spark2:SetBlendMode ("ADD")
+ statusbar.spark2:SetTexture ("Interface\\CastingBar\\UI-CastingBar-Spark")
+ statusbar.spark2:Hide()
+
+ statusbar.subMenuArrow = statusbar:CreateTexture ("$parent_SubMenuArrow", "OVERLAY")
+ statusbar.subMenuArrow:SetSize (12, 12)
+ statusbar.subMenuArrow:SetPoint ("RIGHT", statusbar, "RIGHT", 3, 0)
+ statusbar.subMenuArrow:SetBlendMode ("ADD")
+ statusbar.subMenuArrow:SetTexture ("Interface\\CHATFRAME\\ChatFrameExpandArrow")
+ statusbar.subMenuArrow:Hide()
+
+ statusbar.leftText = statusbar:CreateFontString ("$parent_LeftText", "OVERLAY", "GameTooltipHeaderText")
+ statusbar.leftText:SetJustifyH ("LEFT")
+ statusbar.leftText:SetPoint ("LEFT", statusbar.leftIcon, "RIGHT", 3, 0)
+ DF:SetFontSize (statusbar.leftText, 10)
+
+ statusbar.rightText = statusbar:CreateFontString ("$parent_TextRight", "OVERLAY", "GameTooltipHeaderText")
+ statusbar.rightText:SetJustifyH ("RIGHT")
+ statusbar.rightText:SetPoint ("RIGHT", statusbar.rightIcon, "LEFT", -3, 0)
+ DF:SetFontSize (statusbar.leftText, 10)
+
+ --> background status bar
+ self.statusbar2 = CreateFrame ("StatusBar", "$Parent_StatusBarBackground", self)
+ self.statusbar2:SetPoint ("LEFT", self.statusbar, "LEFT")
+ self.statusbar2:SetPoint ("RIGHT", self.statusbar, "RIGHT")
+ self.statusbar2:SetPoint ("TOP", self.statusbar, "TOP")
+ self.statusbar2:SetPoint ("BOTTOM", self.statusbar, "BOTTOM")
+
+ local statusbar2 = self.statusbar2
+
+ statusbar2.texture = statusbar2:CreateTexture ("$parent_Texture", "BACKGROUND")
+ statusbar2.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
+ statusbar2.texture:SetSize (300, 14)
+ statusbar2:SetStatusBarTexture (statusbar2.texture)
+ statusbar2:SetMinMaxValues (0, 100)
+
+ --> on load
+ self:RegisterForClicks ("LeftButtonDown")
+ self.leftIcon = self.statusbar.leftIcon
+ self.rightIcon = self.statusbar.rightIcon
+ self.texture = self.statusbar.texture
+ self.spark = self.statusbar.spark
+ self.spark2 = self.statusbar.spark2
+ self.leftText = self.statusbar.leftText
+ self.rightText = self.statusbar.rightText
+ self.statusbar:SetFrameLevel (self:GetFrameLevel()+2)
+ self.statusbar2:SetFrameLevel (self.statusbar:GetFrameLevel()-1)
+ self.statusbar2:SetValue (0)
+
+ --> scripts
+ self:SetScript ("OnMouseDown", GameCooltipButtonMouseDown)
+ self:SetScript ("OnMouseUp", GameCooltipButtonMouseUp)
+
+ end
+
+ function GameCooltipButtonMouseDown (button)
+ local mod = CoolTip.OptionsTable.TextHeightMod or 0
+ button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
+ button.leftText:SetPoint ("left", button.leftIcon, "right", 4, -1+mod)
+ end
+
+ function GameCooltipButtonMouseUp (button)
+ local mod = CoolTip.OptionsTable.TextHeightMod or 0
+ button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
+ button.leftText:SetPoint ("left", button.leftIcon, "right", 3, 0+mod)
+ end
+
+ function CoolTip:CreateButton (index, frame, name)
+ local new_button = CreateFrame ("Button", name, frame)
+ build_button (new_button)
+
+ frame.Lines [index] = new_button
+ return new_button
+ end
+
+ local OnEnterUpdateButton = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.001) then
+ --> search key: ~onenterupdatemain
+ CoolTip:ShowSub (self.index)
+ CoolTip.last_button = self.index
+ self:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local OnLeaveUpdateButton = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked) then
+ DF:FadeFrame (frame1, 1)
+ DF:FadeFrame (frame2, 1)
+
+ elseif (not CoolTip.active) then
+ DF:FadeFrame (frame1, 1)
+ DF:FadeFrame (frame2, 1)
+ end
+ frame1:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local OnEnterMainButton = function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+
+ frame1:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+
+ self.background:Show()
+
+ if (CoolTip.OptionsTable.IconBlendModeHover) then
+ self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
+ else
+ self.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ if (CoolTip.PopupFrameTable [self.index]) then
+ local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index])
+ if (on_enter) then
+ xpcall (on_enter, geterrorhandler(), frame1, param1, param2)
+ end
+
+ elseif (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ CoolTip:ShowSub (self.index)
+ self.index = self.ID
+ else
+ if (CoolTip.last_button) then
+ CoolTip:ShowSub (CoolTip.last_button)
+ else
+ CoolTip:ShowSub (self.index)
+ end
+ elapsedTime = 0
+ self.index = self.ID
+ self:SetScript ("OnUpdate", OnEnterUpdateButton)
+ end
+
+ else
+ --hide second frame
+ DF:FadeFrame (frame2, 1)
+ CoolTip.last_button = nil
+ end
+ else
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+ end
+ end
+
+ local OnLeaveMainButton = function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ self:SetScript ("OnUpdate", nil)
+
+ self.background:Hide()
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ self.leftIcon:SetBlendMode ("BLEND")
+ self.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ if (CoolTip.PopupFrameTable [self.index]) then
+ local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index])
+ if (on_leave) then
+ xpcall (on_leave, geterrorhandler(), frame1, param1, param2)
+ end
+ end
+
+ elapsedTime = 0
+ frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
+ else
+ CoolTip.active = false
+ elapsedTime = 0
+ frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
+ CoolTip.mouseOver = false
+ end
+ end
+
+ function CoolTip:NewMainButton (i)
+ local newButton = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i)
+
+ --> serach key: ~onenter
+ newButton.ID = i
+ newButton:SetScript ("OnEnter", OnEnterMainButton)
+ newButton:SetScript ("OnLeave", OnLeaveMainButton)
+
+ return newButton
+ end
+
+ --> buttons for the secondary frame
+
+ local OnLeaveUpdateButtonSec = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked) then
+ DF:FadeFrame (frame1, 1)
+ DF:FadeFrame (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:FadeFrame (frame1, 1)
+ DF:FadeFrame (frame2, 1)
+ end
+ frame2:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local OnEnterSecondaryButton = function (self)
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ return CoolTip:Close()
+ end
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+
+ self.background:Show()
+
+ if (CoolTip.OptionsTable.IconBlendModeHover) then
+ self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
+ else
+ self.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ frame1:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+
+ DF:FadeFrame (frame1, 0)
+ DF:FadeFrame (frame2, 0)
+ else
+ CoolTip.mouseOver = true
+ CoolTip.had_interaction = true
+ end
+ end
+
+ local OnLeaveSecondaryButton = function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+
+ self.background:Hide()
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ self.leftIcon:SetBlendMode ("BLEND")
+ self.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ elapsedTime = 0
+ frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
+ end
+ end
+
+ function CoolTip:NewSecondaryButton (i)
+ local newButton = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i)
+
+ newButton.ID = i
+ newButton:SetScript ("OnEnter", OnEnterSecondaryButton)
+ newButton:SetScript ("OnLeave", OnLeaveSecondaryButton)
+
+ return newButton
+ end
+
+----------------------------------------------------------------------
+ --> Button Click Functions
+----------------------------------------------------------------------
+
+ CoolTip.selected_anchor.left = 4
+ CoolTip.selected_anchor.right = -4
+ CoolTip.selected_anchor.top = 0
+ CoolTip.selected_anchor.bottom = 0
+
+ function CoolTip:HideSelectedTexture (frame)
+ frame.selectedTop:Hide()
+ frame.selectedBottom:Hide()
+ frame.selectedMiddle:Hide()
+ end
+
+ function CoolTip:ShowSelectedTexture (frame)
+ frame.selectedTop:Show()
+ frame.selectedBottom:Show()
+ frame.selectedMiddle:Show()
+ end
+
+ function CoolTip:SetSelectedAnchor (frame, button)
+
+ local left = CoolTip.selected_anchor.left + (CoolTip.OptionsTable.SelectedLeftAnchorMod or 0)
+ local right = CoolTip.selected_anchor.right + (CoolTip.OptionsTable.SelectedRightAnchorMod or 0)
+
+ local top = CoolTip.selected_anchor.top + (CoolTip.OptionsTable.SelectedTopAnchorMod or 0)
+ local bottom = CoolTip.selected_anchor.bottom + (CoolTip.OptionsTable.SelectedBottomAnchorMod or 0)
+
+ frame.selectedTop:ClearAllPoints()
+ frame.selectedBottom:ClearAllPoints()
+
+ frame.selectedTop:SetPoint ("topleft", button, "topleft", left+1, top) --
+ frame.selectedTop:SetPoint ("topright", button, "topright", right-1, top) --
+
+ frame.selectedBottom:SetPoint ("bottomleft", button, "bottomleft", left+1, bottom) --
+ frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right-1, bottom) --
+
+ CoolTip:ShowSelectedTexture (frame)
+ end
+
+ local OnClickFunctionMainButton = function (self, button)
+ if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
+ CoolTip:ShowSub (self.index)
+ CoolTip.last_button = self.index
+ end
+
+ CoolTip.buttonClicked = true
+ CoolTip:SetSelectedAnchor (frame1, self)
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame1)
+ end
+ CoolTip.SelectedIndexMain = self.index
+
+ if (CoolTip.FunctionsTableMain [self.index]) then
+ local parameterTable = CoolTip.ParametersTableMain [self.index]
+ local func = CoolTip.FunctionsTableMain [self.index]
+ --> passing nil as the first parameter was a design mistake
+ --CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
+ local okay, errortext = pcall (func, CoolTip.Host, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
+ if (not okay) then
+ print ("Cooltip OnClick Error:", errortext)
+ end
+ end
+ end
+
+ local OnClickFunctionSecondaryButton = function (self, button)
+ CoolTip.buttonClicked = true
+
+ CoolTip:SetSelectedAnchor (frame2, self)
+
+ if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then
+ local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index]
+ local func = CoolTip.FunctionsTableSub [self.mainIndex] [self.index]
+ --CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
+ local okay, errortext = pcall (func, CoolTip.Host, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
+ if (not okay) then
+ print ("Cooltip OnClick Error:", errortext)
+ end
+ end
+
+ local botao_p = frame1.Lines [self.mainIndex]
+ CoolTip:SetSelectedAnchor (frame1, botao_p)
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame1)
+ end
+
+ CoolTip.SelectedIndexMain = self.mainIndex
+ CoolTip.SelectedIndexSec [self.mainIndex] = self.index
+ end
+
+
+ --> format functions
+
+ function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub)
+ --> reset width
+ menuButton.leftText:SetWidth (0)
+ menuButton.leftText:SetHeight (0)
+ menuButton.rightText:SetWidth (0)
+ menuButton.rightText:SetHeight (0)
+
+ menuButton.rightText:SetPoint ("right", menuButton.rightIcon, "left", CoolTip.OptionsTable.RightTextMargin or -3, 0)
+
+ --> set text
+ if (leftTextTable) then
+
+ menuButton.leftText:SetText (leftTextTable [1])
+
+ local r, g, b, a = leftTextTable [2], leftTextTable [3], leftTextTable [4], leftTextTable [5]
+
+ if (r == 0 and g == 0 and b == 0 and a == 0) then
+ if (CoolTip.OptionsTable.TextColor) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
+ menuButton.leftText:SetTextColor (r, g, b, a)
+ else
+ menuButton.leftText:SetTextColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.leftText:SetTextColor (r, g, b, a)
+ end
+
+ if (CoolTip.OptionsTable.TextSize and not leftTextTable [6]) then
+ DF:SetFontSize (menuButton.leftText, CoolTip.OptionsTable.TextSize)
+ end
+
+ if (CoolTip.OptionsTable.LeftTextWidth) then
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.LeftTextWidth)
+ else
+ menuButton.leftText:SetWidth (0)
+ end
+
+ if (CoolTip.OptionsTable.LeftTextHeight) then
+ menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight)
+ else
+ menuButton.leftText:SetHeight (0)
+ end
+
+ if (CoolTip.OptionsTable.TextFont and not leftTextTable [7]) then --font
+
+ if (_G [CoolTip.OptionsTable.TextFont]) then
+ menuButton.leftText:SetFontObject (GameFontRed or CoolTip.OptionsTable.TextFont)
+ else
+ local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
+ local _, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (font, size, flags)
+ end
+
+ elseif (leftTextTable [7]) then
+ if (_G [leftTextTable [7]]) then
+ menuButton.leftText:SetFontObject (leftTextTable [7])
+ local face, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (face, size, flags)
+ else
+ local font = SharedMedia:Fetch ("font", leftTextTable [7])
+ local face, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (face, size, flags)
+ end
+ else
+ menuButton.leftText:SetFont (CoolTip._default_font, leftTextTable [6] or CoolTip.OptionsTable.TextSize or 10, leftTextTable [8] or CoolTip.OptionsTable.TextShadow)
+ end
+
+ local height_mod = CoolTip.OptionsTable.TextHeightMod or 0
+ menuButton.leftText:SetPoint ("center", menuButton.leftIcon, "center", 0, 0+height_mod)
+ menuButton.leftText:SetPoint ("left", menuButton.leftIcon, "right", 3, 0+height_mod)
+
+ else
+ menuButton.leftText:SetText ("")
+ end
+
+ if (rightTextTable) then
+ menuButton.rightText:SetText (rightTextTable [1])
+
+ local r, g, b, a = rightTextTable [2], rightTextTable [3], rightTextTable [4], rightTextTable [5]
+
+ if (r == 0 and g == 0 and b == 0 and a == 0) then
+
+ if (CoolTip.OptionsTable.TextColorRight) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColorRight)
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ elseif (CoolTip.OptionsTable.TextColor) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ else
+ menuButton.rightText:SetTextColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ end
+
+ if (CoolTip.OptionsTable.TextSize and not rightTextTable [6]) then
+ DF:SetFontSize (menuButton.rightText, CoolTip.OptionsTable.TextSize)
+ end
+
+ if (CoolTip.OptionsTable.RightTextWidth) then
+ menuButton.rightText:SetWidth (CoolTip.OptionsTable.RightTextWidth)
+ else
+ menuButton.rightText:SetWidth (0)
+ end
+
+ if (CoolTip.OptionsTable.TextFont and not rightTextTable [7]) then
+ if (_G [CoolTip.OptionsTable.TextFont]) then
+ menuButton.rightText:SetFontObject (CoolTip.OptionsTable.TextFont)
+ else
+ local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
+ local _, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (font, size, flags)
+ end
+
+ elseif (rightTextTable [7]) then
+ if (_G [rightTextTable [7]]) then
+ menuButton.rightText:SetFontObject (rightTextTable [7])
+ local face, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (face, size, flags)
+ else
+ local font = SharedMedia:Fetch ("font", rightTextTable [7])
+ local face, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (face, size, flags)
+ end
+
+ else
+ menuButton.rightText:SetFont (CoolTip._default_font, rightTextTable [6] or CoolTip.OptionsTable.TextSize or 10, rightTextTable [8] or CoolTip.OptionsTable.TextShadow)
+ end
+
+
+ else
+ menuButton.rightText:SetText ("")
+ end
+
+ --> left icon
+ if (leftIconTable and leftIconTable [1]) then
+ menuButton.leftIcon:SetTexture (leftIconTable [1])
+ menuButton.leftIcon:SetWidth (leftIconTable [2])
+ menuButton.leftIcon:SetHeight (leftIconTable [3])
+ menuButton.leftIcon:SetTexCoord (leftIconTable [4], leftIconTable [5], leftIconTable [6], leftIconTable [7])
+
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (leftIconTable [8])
+ menuButton.leftIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ menuButton.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ menuButton.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ menuButton.leftIcon:SetDesaturated (leftIconTable [9])
+ else
+ menuButton.leftIcon:SetTexture (nil)
+ menuButton.leftIcon:SetWidth (1)
+ menuButton.leftIcon:SetHeight (1)
+ end
+
+ --> right icon
+ if (rightIconTable and rightIconTable [1]) then
+ menuButton.rightIcon:SetTexture (rightIconTable [1])
+ menuButton.rightIcon:SetWidth (rightIconTable [2])
+ menuButton.rightIcon:SetHeight (rightIconTable [3])
+ menuButton.rightIcon:SetTexCoord (rightIconTable [4], rightIconTable [5], rightIconTable [6], rightIconTable [7])
+
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (rightIconTable [8])
+ menuButton.rightIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ menuButton.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ menuButton.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ menuButton.rightIcon:SetDesaturated (rightIconTable [9])
+ else
+ menuButton.rightIcon:SetTexture (nil)
+ menuButton.rightIcon:SetWidth (1)
+ menuButton.rightIcon:SetHeight (1)
+ end
+
+ --> overwrite icon size
+ if (CoolTip.OptionsTable.IconSize) then
+ menuButton.leftIcon:SetWidth (CoolTip.OptionsTable.IconSize)
+ menuButton.leftIcon:SetHeight (CoolTip.OptionsTable.IconSize)
+ menuButton.rightIcon:SetWidth (CoolTip.OptionsTable.IconSize)
+ menuButton.rightIcon:SetHeight (CoolTip.OptionsTable.IconSize)
+ end
+
+ menuButton.leftText:SetHeight (0)
+ menuButton.rightText:SetHeight (0)
+
+ if (CoolTip.Type == 2) then
+ CoolTip:LeftTextSpace (menuButton)
+ end
+ if (CoolTip.OptionsTable.LeftTextHeight) then
+ menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight)
+ end
+ if (CoolTip.OptionsTable.RightTextHeight) then
+ menuButton.rightText:SetHeight (CoolTip.OptionsTable.RightTextHeight)
+ end
+
+ --> string length
+ if (not isSub) then --> main frame
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() + 10
+ if (stringWidth > frame.w) then
+ frame.w = stringWidth
+ end
+ end
+ else
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidth - menuButton.leftIcon:GetWidth() - menuButton.rightText:GetStringWidth() - menuButton.rightIcon:GetWidth() - 22)
+ end
+ else
+ if (not CoolTip.OptionsTable.FixedWidthSub) then
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame.w) then
+ frame.w = stringWidth
+ end
+ end
+ else
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidthSub - menuButton.leftIcon:GetWidth() - 12)
+ end
+ end
+
+ local height = _math_max ( menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight() )
+ if (height > frame.hHeight) then
+ frame.hHeight = height
+ end
+
+ end
+
+ function CoolTip:RefreshSpark (menuButton)
+ menuButton.spark:ClearAllPoints()
+ menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth() / 100)) - 5, 0)
+ menuButton.spark2:ClearAllPoints()
+ menuButton.spark2:SetPoint ("left", menuButton.statusbar, "left", menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth()/100) - 16, 0)
+ end
+
+ function CoolTip:StatusBar (menuButton, StatusBar)
+
+ if (StatusBar) then
+
+ menuButton.statusbar:SetValue (StatusBar [1])
+ menuButton.statusbar:SetStatusBarColor (StatusBar [2], StatusBar [3], StatusBar [4], StatusBar [5])
+ menuButton.statusbar:SetHeight (20 + (CoolTip.OptionsTable.StatusBarHeightMod or 0))
+
+ menuButton.spark2:Hide()
+ if (StatusBar [6]) then
+ menuButton.spark:Show()
+ --menuButton.spark:ClearAllPoints()
+ --menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (StatusBar [1] * (menuButton.statusbar:GetWidth() / 100)) - 3, 0)
+ else
+ menuButton.spark:Hide()
+ end
+
+ if (StatusBar [7]) then
+ menuButton.statusbar2:SetValue (StatusBar[7].value)
+ menuButton.statusbar2.texture:SetTexture (StatusBar[7].texture or [[Interface\RaidFrame\Raid-Bar-Hp-Fill]])
+ if (StatusBar[7].specialSpark) then
+ menuButton.spark2:Show()
+ end
+ if (StatusBar[7].color) then
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (StatusBar[7].color)
+ menuButton.statusbar2:SetStatusBarColor (ColorR, ColorG, ColorB, ColorA)
+ else
+ menuButton.statusbar2:SetStatusBarColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.statusbar2:SetValue (0)
+ menuButton.spark2:Hide()
+ end
+
+ if (StatusBar [8]) then
+ local texture = SharedMedia:Fetch ("statusbar", StatusBar [8], true)
+ if (texture) then
+ menuButton.statusbar.texture:SetTexture (texture)
+ else
+ menuButton.statusbar.texture:SetTexture (StatusBar [8])
+ end
+ elseif (CoolTip.OptionsTable.StatusBarTexture) then
+ local texture = SharedMedia:Fetch ("statusbar", CoolTip.OptionsTable.StatusBarTexture, true)
+ if (texture) then
+ menuButton.statusbar.texture:SetTexture (texture)
+ else
+ menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture)
+ end
+ else
+ menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
+ end
+
+ --[[
+ if (CoolTip.OptionsTable.StatusBarTexture) then
+ menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture)
+ else
+ menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
+ end
+ --]]
+ else
+ menuButton.statusbar:SetValue (0)
+ menuButton.statusbar2:SetValue (0)
+ menuButton.spark:Hide()
+ menuButton.spark2:Hide()
+ end
+
+ if (CoolTip.OptionsTable.LeftBorderSize) then
+ menuButton.statusbar:SetPoint ("left", menuButton, "left", 10 + CoolTip.OptionsTable.LeftBorderSize, 0)
+ else
+ menuButton.statusbar:SetPoint ("left", menuButton, "left", 10, 0)
+ end
+
+ if (CoolTip.OptionsTable.RightBorderSize) then
+ menuButton.statusbar:SetPoint ("right", menuButton, "right", CoolTip.OptionsTable.RightBorderSize + (- 10), 0)
+ else
+ menuButton.statusbar:SetPoint ("right", menuButton, "right", -10, 0)
+ end
+ end
+
+ function CoolTip:SetupMainButton (menuButton, index)
+ menuButton.index = index
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (index, frame1, menuButton, CoolTip.LeftTextTable [index], CoolTip.RightTextTable [index], CoolTip.LeftIconTable [index], CoolTip.RightIconTable [index])
+ --> setup statusbar
+ CoolTip:StatusBar (menuButton, CoolTip.StatusBarTable [index])
+
+ --> click
+ menuButton:RegisterForClicks ("LeftButtonDown")
+
+ --> string length
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame1.w) then
+ frame1.w = stringWidth
+ end
+ end
+
+ --> register click function
+ menuButton:SetScript ("OnClick", OnClickFunctionMainButton)
+ menuButton:Show()
+ end
+
+ function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex)
+
+ menuButton.index = index
+ menuButton.mainIndex = mainMenuIndex
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (index, frame2, menuButton, CoolTip.LeftTextTableSub [mainMenuIndex] and CoolTip.LeftTextTableSub [mainMenuIndex] [index],
+ CoolTip.RightTextTableSub [mainMenuIndex] and CoolTip.RightTextTableSub [mainMenuIndex] [index],
+ CoolTip.LeftIconTableSub [mainMenuIndex] and CoolTip.LeftIconTableSub [mainMenuIndex] [index],
+ CoolTip.RightIconTableSub [mainMenuIndex] and CoolTip.RightIconTableSub [mainMenuIndex] [index], true)
+ --> setup statusbar
+ CoolTip:StatusBar (menuButton, CoolTip.StatusBarTableSub [mainMenuIndex] and CoolTip.StatusBarTableSub [mainMenuIndex] [index])
+
+ --> click
+ menuButton:RegisterForClicks ("LeftButtonDown")
+
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3)
+ menuButton:SetPoint ("left", frame2, "left", -4, 0)
+ menuButton:SetPoint ("right", frame2, "right", 4, 0)
+
+ DF:FadeFrame (menuButton, 0)
+
+ --> string length
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame2.w) then
+ frame2.w = stringWidth
+ end
+
+ menuButton:SetScript ("OnClick", OnClickFunctionSecondaryButton)
+ menuButton:Show()
+
+ return true
+ end
+
+ -- -- --------------------------------------------------------------------------------------------------------------
+
+ function CoolTip:SetupWallpaper (wallpaperTable, wallpaper)
+ local texture = wallpaperTable [1]
+ if (DF:IsHtmlColor (texture) or type (texture) == "table") then
+ local r, g, b, a = DF:ParseColors (texture)
+ wallpaper:SetTexture (r, g, b, a)
+ else
+ wallpaper:SetTexture (texture)
+ end
+
+ wallpaper:SetTexCoord (wallpaperTable[2], wallpaperTable[3], wallpaperTable[4], wallpaperTable[5])
+
+ local color = wallpaperTable[6]
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ wallpaper:SetVertexColor (r, g, b, a)
+ else
+ wallpaper:SetVertexColor (1, 1, 1, 1)
+ end
+
+ if (wallpaperTable[7]) then
+ wallpaper:SetDesaturated (true)
+ else
+ wallpaper:SetDesaturated (false)
+ end
+
+ wallpaper:Show()
+ end
+
+ -- -- --------------------------------------------------------------------------------------------------------------
+
+ function CoolTip:ShowSub (index)
+
+ if (CoolTip.OptionsTable.IgnoreSubMenu) then
+ DF:FadeFrame (frame2, 1)
+ return
+ end
+
+ frame2:SetHeight (6)
+
+ local amtIndexes = CoolTip.IndexesSub [index]
+ if (not amtIndexes) then
+ --print ("Sub menu called but sub menu indexes is nil")
+ return
+ end
+
+ if (CoolTip.OptionsTable.FixedWidthSub) then
+ frame2:SetWidth (CoolTip.OptionsTable.FixedWidthSub)
+ end
+
+ frame2.h = CoolTip.IndexesSub [index] * 20
+ frame2.hHeight = 0
+ frame2.w = 0
+
+ --> pegar a fontsize da label principal
+ local mainButton = frame1.Lines [index]
+ local fontSize = DF:GetFontSize (mainButton.leftText)
+
+ local GotChecked = false
+
+ local IsTooltip = CoolTip.OptionsTable.SubMenuIsTooltip
+ if (IsTooltip) then
+ frame2:EnableMouse (false)
+ else
+ frame2:EnableMouse (true)
+ end
+
+ for i = 1, CoolTip.IndexesSub [index] do
+
+ local button = frame2.Lines [i]
+
+ if (not button) then
+ button = CoolTip:NewSecondaryButton (i)
+ end
+
+ local checked = CoolTip:SetupSecondaryButton (button, i, index)
+ if (checked) then
+ GotChecked = true
+ end
+
+ if (IsTooltip) then
+ button:EnableMouse (false)
+ else
+ button:EnableMouse (true)
+ end
+ end
+
+ local selected = CoolTip.SelectedIndexSec [index]
+ if (selected) then
+
+ CoolTip:SetSelectedAnchor (frame2, frame2.Lines [selected])
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame2)
+ end
+ else
+ CoolTip:HideSelectedTexture (frame2)
+ end
+
+ for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do
+ DF:FadeFrame (frame2.Lines[i], 1)
+ end
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = CoolTip.OptionsTable.YSpacingModSub
+ end
+
+ --> normalize height of all rows
+ for i = 1, CoolTip.IndexesSub [index] do
+
+ local menuButton = frame2.Lines [i]
+
+ -- CoolTipFrame2.Lines [2].divbar
+
+ if (menuButton.leftText:GetText() == "$div") then
+
+ --> height
+ menuButton:SetHeight (4)
+
+ --> points
+ menuButton:ClearAllPoints()
+
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("left", frame2, "left", -4, 0)
+ menuButton:SetPoint ("right", frame2, "right", 4, 0)
+
+ menuButton.rightText:SetText ("")
+
+ local div_size_up = tonumber (CoolTip.RightTextTableSub [index] [i] [2])
+ if (not div_size_up) then
+ div_size_up = 0
+ end
+ local div_size_down = tonumber (CoolTip.RightTextTableSub [index] [i] [3])
+ if (not div_size_down) then
+ div_size_down = 0
+ end
+
+ menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing + (2 + (div_size_up or 0)))
+
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
+ end
+
+ spacing = spacing + 17 + (div_size_down or 0)
+
+ menuButton.leftText:SetText ("")
+ menuButton.isDiv = true
+
+ if (not menuButton.divbar) then
+ CoolTip:CreateDivBar (menuButton)
+ else
+ menuButton.divbar:Show()
+ end
+
+ menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
+ menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
+
+ else
+ --> height
+ menuButton:SetHeight (frame2.hHeight + (CoolTip.OptionsTable.ButtonHeightModSub or 0))
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing)
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
+ end
+ menuButton:SetPoint ("left", frame2, "left", -4, 0)
+ menuButton:SetPoint ("right", frame2, "right", 4, 0)
+
+ if (menuButton.divbar) then
+ menuButton.divbar:Hide()
+ menuButton.isDiv = false
+ end
+ end
+
+ end
+
+ local mod = CoolTip.OptionsTable.HeighModSub or 0
+ frame2:SetHeight ( (frame2.hHeight * CoolTip.IndexesSub [index]) + 12 + (-spacing) + mod)
+
+ if (CoolTip.TopIconTableSub [index]) then
+ local upperImageTable = CoolTip.TopIconTableSub [index]
+ frame2.upperImage:SetTexture (upperImageTable [1])
+ frame2.upperImage:SetWidth (upperImageTable [2])
+ frame2.upperImage:SetHeight (upperImageTable [3])
+ frame2.upperImage:SetTexCoord (upperImageTable[4], upperImageTable[5], upperImageTable[6], upperImageTable[7])
+ frame2.upperImage:Show()
+ else
+ frame2.upperImage:Hide()
+ end
+
+ if (CoolTip.WallpaperTableSub [index]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTableSub [index], frame2.frameWallpaper)
+ else
+ frame2.frameWallpaper:Hide()
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidthSub) then
+ frame2:SetWidth (frame2.w + 44)
+ end
+
+ DF:FadeFrame (frame2, 0)
+
+ CoolTip:CheckOverlap()
+
+ if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then
+
+ local button = frame1.Lines [index]
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("left", button, "right", 4, 0)
+
+ elseif (CoolTip.OptionsTable.SubFollowButton and CoolTip.frame2_leftside) then
+
+ local button = frame1.Lines [index]
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("right", button, "left", -4, 0)
+
+ elseif (CoolTip.frame2_leftside) then
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft", -4, 0)
+ else
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0)
+ end
+
+ end
+
+ function CoolTip:HideSub()
+ DF:FadeFrame (frame2, 1)
+ end
+
+
+ function CoolTip:LeftTextSpace (row)
+ row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth())
+ row.leftText:SetHeight (10)
+ end
+
+ --> ~inicio ~start ~tooltip
+ function CoolTip:monta_tooltip()
+
+ --> hide sub frame
+ DF:FadeFrame (frame2, 1)
+ --> hide select bar
+ CoolTip:HideSelectedTexture (frame1)
+
+ frame1:EnableMouse (false)
+
+ --> elevator
+ local yDown = 5
+ --> width
+ if (CoolTip.OptionsTable.FixedWidth) then
+ frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
+ end
+
+ frame1.w = CoolTip.OptionsTable.FixedWidth or 0
+ frame1.hHeight = 0
+ frame2.hHeight = 0
+
+ CoolTip.active = true
+
+ for i = 1, CoolTip.Indexes do
+
+ local button = frame1.Lines [i]
+ if (not button) then
+ button = CoolTip:NewMainButton (i)
+ end
+
+ button.index = i
+
+ --> basic stuff
+ button:Show()
+ button.background:Hide()
+ button:SetHeight (CoolTip.OptionsTable.ButtonHeightMod or CoolTip.default_height)
+ button:RegisterForClicks()
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (i, frame1, button, CoolTip.LeftTextTable [i], CoolTip.RightTextTable [i], CoolTip.LeftIconTable [i], CoolTip.RightIconTable [i])
+ --> setup statusbar
+ CoolTip:StatusBar (button, CoolTip.StatusBarTable [i])
+ end
+
+ --> hide unused lines
+ for i = CoolTip.Indexes+1, #frame1.Lines do
+ frame1.Lines[i]:Hide()
+ end
+ CoolTip.NumLines = CoolTip.Indexes
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = CoolTip.OptionsTable.YSpacingMod
+ end
+
+ --> normalize height of all rows
+ local temp = -6 + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame1, "center")
+ menuButton:SetPoint ("left", frame1, "left", -4, 0)
+ menuButton:SetPoint ("right", frame1, "right", 4, 0)
+
+ if (menuButton.divbar) then
+ menuButton.divbar:Hide()
+ menuButton.isDiv = false
+ end
+
+ --> height
+ if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
+ local height = _math_max (8, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
+ menuButton:SetHeight (height)
+ menuButton:SetPoint ("top", frame1, "top", 0, temp)
+ temp = temp + ( height * -1)
+
+ elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+
+ local height = _math_max (menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
+ menuButton:SetHeight (height)
+ menuButton:SetPoint ("top", frame1, "top", 0, temp)
+
+ temp = temp + ( height * -1) + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
+
+ else
+ menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
+ end
+
+ --> points
+
+ if (CoolTip.OptionsTable.YSpacingMod and not CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+
+ menuButton:EnableMouse (false)
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.Type == 2) then --> with bars
+ if (CoolTip.OptionsTable.MinWidth) then
+ local w = frame1.w + 34
+ PixelUtil.SetWidth (frame1, math.max (w, CoolTip.OptionsTable.MinWidth))
+ else
+ PixelUtil.SetWidth (frame1, frame1.w + 34)
+ end
+ else
+ --> width stability check
+ local width = frame1.w + 24
+ if (width > CoolTip.LastSize-5 and width < CoolTip.LastSize+5) then
+ width = CoolTip.LastSize
+ else
+ CoolTip.LastSize = width
+ end
+
+ if (CoolTip.OptionsTable.MinWidth) then
+ PixelUtil.SetWidth (frame1, math.max (width, CoolTip.OptionsTable.MinWidth))
+ else
+ PixelUtil.SetWidth (frame1, width)
+ end
+ end
+ end
+
+ if (CoolTip.OptionsTable.FixedHeight) then
+ PixelUtil.SetHeight (frame1, CoolTip.OptionsTable.FixedHeight)
+ else
+ if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
+ PixelUtil.SetHeight (frame1, ((temp-10) * -1) + (CoolTip.OptionsTable.AlignAsBlizzTooltipFrameHeightOffset or 0))
+
+ elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+ PixelUtil.SetHeight (frame1, (temp+spacing) * -1)
+
+ else
+ PixelUtil.SetHeight (frame1, _math_max ( (frame1.hHeight * CoolTip.Indexes) + 8 + ((CoolTip.OptionsTable.ButtonsYMod or 0)*-1), 22 ))
+ end
+ end
+
+ if (CoolTip.WallpaperTable [1]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
+ else
+ frame1.frameWallpaper:Hide()
+ end
+
+ --> unhide frame
+ DF:FadeFrame (frame1, 0)
+ CoolTip:SetMyPoint (host)
+
+ --> fix sparks
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ if (menuButton.spark:IsShown() or menuButton.spark2:IsShown()) then
+ CoolTip:RefreshSpark (menuButton)
+ end
+ end
+ end
+
+ function CoolTip:CreateDivBar (button)
+ button.divbar = button:CreateTexture (nil, "overlay")
+
+ button.divbar:SetTexture ([[Interface\QUESTFRAME\AutoQuest-Parts]])
+ button.divbar:SetTexCoord (238/512, 445/512, 0/64, 4/64)
+
+ button.divbar:SetHeight (3)
+ button.divbar:SetAlpha (0.1)
+
+ button.divbar:SetDesaturated (true)
+ end
+
+ --> ~inicio ~start ~menu
+ function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize)
+
+ if (CoolTip.Indexes == 0) then
+ CoolTip:Reset()
+ CoolTip:SetType ("tooltip")
+ CoolTip:AddLine ("There is no options.")
+ CoolTip:ShowCooltip()
+ return
+ end
+
+ if (CoolTip.OptionsTable.FixedWidth) then
+ frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
+ end
+
+ frame1.w = CoolTip.OptionsTable.FixedWidth or 0
+ frame1.hHeight = 0
+ frame2.hHeight = 0
+
+ frame1:EnableMouse (true)
+
+ if (CoolTip.HaveSubMenu) then --> zera o segundo frame
+ frame2.w = 0
+ frame2:SetHeight (6)
+ if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then
+ DF:FadeFrame (frame2, 0)
+ else
+ DF:FadeFrame (frame2, 1)
+ end
+ else
+ DF:FadeFrame (frame2, 1)
+ end
+
+ CoolTip.active = true
+
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ if (not menuButton) then
+ menuButton = CoolTip:NewMainButton (i)
+ end
+
+ CoolTip:SetupMainButton (menuButton, i)
+
+ menuButton.background:Hide()
+ end
+
+ --> selected texture
+ if (CoolTip.SelectedIndexMain) then
+ CoolTip:SetSelectedAnchor (frame1, frame1.Lines [CoolTip.SelectedIndexMain])
+
+ if (CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:HideSelectedTexture (frame1)
+ else
+ CoolTip:ShowSelectedTexture (frame1)
+ end
+ else
+ CoolTip:HideSelectedTexture (frame1)
+ end
+
+ if (CoolTip.Indexes < #frame1.Lines) then
+ for i = CoolTip.Indexes+1, #frame1.Lines do
+ frame1.Lines[i]:Hide()
+ end
+ end
+
+ CoolTip.NumLines = CoolTip.Indexes
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = CoolTip.OptionsTable.YSpacingMod
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.OptionsTable.MinWidth) then
+ local w = frame1.w + 24
+ frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth))
+ else
+ frame1:SetWidth (frame1.w + 24)
+ end
+ end
+
+ --> normalize height of all rows
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ menuButton:EnableMouse (true)
+
+ if (menuButton.leftText:GetText() == "$div") then
+
+ --> height
+ menuButton:SetHeight (4)
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("left", frame1, "left", -4, 0)
+ menuButton:SetPoint ("right", frame1, "right", 4, 0)
+ menuButton:SetPoint ("center", frame1, "center")
+
+ local div_size_up = tonumber (CoolTip.LeftTextTable [i] [2])
+ if (not div_size_up) then
+ div_size_up = 0
+ end
+ local div_size_down = tonumber (CoolTip.LeftTextTable [i] [3])
+ if (not div_size_down) then
+ div_size_down = 0
+ end
+
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing - 4 + div_size_up)
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+
+ spacing = spacing + 4 + div_size_down
+
+ menuButton.leftText:SetText ("")
+ menuButton.isDiv = true
+
+ if (not menuButton.divbar) then
+ CoolTip:CreateDivBar (menuButton)
+ else
+ menuButton.divbar:Show()
+ end
+
+ menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
+ menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
+
+ else
+
+ --> height
+ menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame1, "center")
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+ menuButton:SetPoint ("left", frame1, "left", -4, 0)
+ menuButton:SetPoint ("right", frame1, "right", 4, 0)
+
+ if (menuButton.divbar) then
+ menuButton.divbar:Hide()
+ menuButton.isDiv = false
+ end
+ end
+
+ end
+
+ if (CoolTip.OptionsTable.FixedHeight) then
+ frame1:SetHeight (CoolTip.OptionsTable.FixedHeight)
+ else
+ local mod = CoolTip.OptionsTable.HeighMod or 0
+ frame1:SetHeight (_math_max ( (frame1.hHeight * CoolTip.Indexes) + 12 + (-spacing) + mod, 22 ))
+ end
+
+ --> sub menu arrows
+ if (CoolTip.HaveSubMenu and not CoolTip.OptionsTable.IgnoreArrows and not CoolTip.OptionsTable.SubMenuIsTooltip) then
+ for i = 1, CoolTip.Indexes do
+ if (CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
+ frame1.Lines [i].statusbar.subMenuArrow:Show()
+ else
+ frame1.Lines [i].statusbar.subMenuArrow:Hide()
+ end
+ end
+
+ frame1:SetWidth (frame1:GetWidth() + 16)
+ end
+
+ frame1:ClearAllPoints()
+ CoolTip:SetMyPoint (host)
+
+ if (CoolTip.title1) then
+ CoolTip.frame1.titleText:Show()
+ CoolTip.frame1.titleIcon:Show()
+ CoolTip.frame1.titleText:SetText (CoolTip.title_text)
+ CoolTip.frame1.titleIcon:SetWidth (frame1:GetWidth())
+ CoolTip.frame1.titleIcon:SetHeight (40)
+ end
+
+ if (CoolTip.WallpaperTable [1]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
+ else
+ frame1.frameWallpaper:Hide()
+ end
+
+ DF:FadeFrame (frame1, 0)
+
+ for i = 1, CoolTip.Indexes do
+ if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then
+ if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
+ CoolTip:ShowSub (i)
+ end
+ end
+ end
+
+ return true
+ end
+
+ function CoolTip:SetMyPoint (host, x_mod, y_mod)
+
+ local moveX = x_mod or 0
+ local moveY = y_mod or 0
+
+ --> clear all points
+ frame1:ClearAllPoints()
+
+ local anchor = CoolTip.OptionsTable.Anchor or CoolTip.Host
+
+ --frame1:SetPoint (CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY)
+ PixelUtil.SetPoint (frame1, CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY)
+
+ if (not x_mod) then
+ --> check if cooltip is out of screen bounds
+ local center_x = frame1:GetCenter()
+
+ if (center_x) then
+ local screen_x_res = GetScreenWidth()
+ local half_x = frame1:GetWidth() / 2
+
+ if (center_x+half_x > screen_x_res) then
+ --> out of right side
+ local move_to_left = (center_x + half_x) - screen_x_res
+ CoolTip.internal_x_mod = -move_to_left
+ return CoolTip:SetMyPoint (host, -move_to_left, 0)
+
+ elseif (center_x-half_x < 0) then
+ --> out of left side
+ local move_to_right = center_x - half_x
+ CoolTip.internal_x_mod = move_to_right*-1
+ return CoolTip:SetMyPoint (host, move_to_right*-1, 0)
+ end
+ end
+ end
+
+ if (not y_mod) then
+ --> check if cooltip is out of screen bounds
+ local _, center_y = frame1:GetCenter()
+ local screen_y_res = GetScreenHeight()
+ local half_y = frame1:GetHeight() / 2
+
+ if (center_y) then
+ if (center_y+half_y > screen_y_res) then
+ --> out of top side
+ local move_to_down = (center_y + half_y) - screen_y_res
+ CoolTip.internal_y_mod = -move_to_down
+ return CoolTip:SetMyPoint (host, 0, -move_to_down)
+
+ elseif (center_y-half_y < 0) then
+ --> out of bottom side
+ local move_to_up = center_y - half_y
+ CoolTip.internal_y_mod = move_to_up*-1
+ return CoolTip:SetMyPoint (host, 0, move_to_up*-1)
+
+ end
+ end
+ end
+
+ if (frame2:IsShown() and not CoolTip.overlap_checked) then
+
+ local frame_2_center_x = frame2:GetCenter()
+ if (frame_2_center_x) then
+ local frame_2_half_x = frame2:GetWidth() / 2
+
+ local frame_1_center_x = frame1:GetCenter()
+ if (frame_1_center_x) then
+
+ local frame_1_half_x = frame1:GetWidth() / 2
+
+ local f1_end_point = frame_1_center_x + frame_1_half_x - 3
+ local f2_start_point = frame_2_center_x - frame_2_half_x
+
+ if (f2_start_point < f1_end_point) then
+ local diff = f2_start_point - f1_end_point
+ CoolTip.overlap_checked = true
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft", 4, 0)
+ CoolTip.frame2_leftside = true
+ --> diff
+ return CoolTip:SetMyPoint (host, CoolTip.internal_x_mod , CoolTip.internal_y_mod)
+ end
+
+ end
+ end
+
+ end
+
+ end
+
+ function CoolTip:CheckOverlap()
+ if (frame2:IsShown()) then
+
+ local frame_2_center_x = frame2:GetCenter()
+ if (frame_2_center_x) then
+ local frame_2_half_x = frame2:GetWidth() / 2
+
+ local frame_1_center_x = frame1:GetCenter()
+ if (frame_1_center_x) then
+
+ local frame_1_half_x = frame1:GetWidth() / 2
+
+ local f1_end_point = frame_1_center_x + frame_1_half_x - 3
+ local f2_start_point = frame_2_center_x - frame_2_half_x
+
+ if (f2_start_point < f1_end_point) then
+ local diff = f2_start_point - f1_end_point
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft", 4, 0)
+ CoolTip.frame2_leftside = true
+ end
+
+ end
+ end
+
+ end
+ end
+
+ function CoolTip:GetText (buttonIndex)
+ local button1 = frame1.Lines [buttonIndex]
+ if (not button1) then
+ return "", ""
+ else
+ return button1.leftText:GetText() or "", button1.rightText:GetText() or ""
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Get the number of lines current shown on cooltip
+
+ function CoolTip:GetNumLines()
+ return CoolTip.NumLines or 0
+ end
+
+----------------------------------------------------------------------
+ --> Remove all options actived
+ --> Set a option on current cooltip
+
+ function CoolTip:ClearAllOptions()
+ for option, _ in pairs (CoolTip.OptionsTable) do
+ CoolTip.OptionsTable [option] = nil
+ end
+
+ CoolTip:SetOption ("MyAnchor", "bottom")
+ CoolTip:SetOption ("RelativeAnchor", "top")
+ CoolTip:SetOption ("WidthAnchorMod", 0)
+ CoolTip:SetOption ("HeightAnchorMod", 0)
+ end
+
+ function CoolTip:SetOption (optionName, value)
+
+ --> check for name alias
+ optionName = CoolTip.AliasList [optionName] or optionName
+
+ --> check if this options exists
+ if (not CoolTip.OptionsList [optionName]) then
+ return --> error
+ end
+
+ --> set options
+ CoolTip.OptionsTable [optionName] = value
+ end
+
+----------------------------------------------------------------------
+ --> set the anchor of cooltip
+ --> parameters: frame [, cooltip anchor point, frame anchor point [, x mod, y mod]]
+ --> frame [, x mod, y mod]
+
+ --> alias
+ function CoolTip:GetOwner()
+ return CoolTip.Host
+ end
+
+ function CoolTip:SetOwner (frame, myPoint, hisPoint, x, y)
+ return CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
+ end
+
+ function CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
+ --> check data integrity
+ if (type (frame) ~= "table" or not frame.GetObjectType) then
+ print ("host needs to be a frame")
+ return --> error
+ end
+
+ CoolTip.Host = frame
+
+ CoolTip.frame1:SetFrameLevel (frame:GetFrameLevel()+1)
+
+ --> defaults
+ myPoint = myPoint or CoolTip.OptionsTable.MyAnchor or "bottom"
+ hisPoint = hisPoint or CoolTip.OptionsTable.hisPoint or "top"
+
+ x = x or CoolTip.OptionsTable.WidthAnchorMod or 0
+ y = y or CoolTip.OptionsTable.HeightAnchorMod or 0
+
+ --> check options
+ if (type (myPoint) == "string") then
+ CoolTip:SetOption ("MyAnchor", myPoint)
+ CoolTip:SetOption ("WidthAnchorMod", x)
+ elseif (type (myPoint) == "number") then
+ CoolTip:SetOption ("HeightAnchorMod", myPoint)
+ end
+
+ if (type (hisPoint) == "string") then
+ CoolTip:SetOption ("RelativeAnchor", hisPoint)
+ CoolTip:SetOption ("HeightAnchorMod", y)
+ elseif (type (hisPoint) == "number") then
+ CoolTip:SetOption ("WidthAnchorMod", hisPoint)
+ end
+ end
+
+----------------------------------------------------------------------
+ --> set cooltip type
+ --> parameters: type (1 = tooltip | 2 = tooltip with bars | 3 = menu)
+
+ function CoolTip:IsMenu()
+ return CoolTip.frame1:IsShown() and CoolTip.Type == 3
+ end
+
+ function CoolTip:IsTooltip()
+ return CoolTip.frame1:IsShown() and (CoolTip.Type == 1 or CoolTip.Type == 2)
+ end
+
+ function CoolTip:GetType()
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ return "tooltip"
+ elseif (CoolTip.Type == 3) then
+ return "menu"
+ else
+ return "none"
+ end
+ end
+
+ function CoolTip:SetType (newType)
+ if (type (newType) == "string") then
+ if (newType == "tooltip") then
+ CoolTip.Type = 1
+ elseif (newType == "tooltipbar") then
+ CoolTip.Type = 2
+ elseif (newType == "menu") then
+ CoolTip.Type = 3
+ else
+ --> error
+ end
+ elseif (type (newType) == "number") then
+ if (newType == 1) then
+ CoolTip.Type = 1
+ elseif (newType == 2) then
+ CoolTip.Type = 2
+ elseif (newType == 3) then
+ CoolTip.Type = 3
+ else
+ --> error
+ end
+ else
+ --> error
+ end
+ end
+
+ --> Set a fixed value for menu
+ function CoolTip:SetFixedParameter (value, injected)
+ if (injected ~= nil) then
+ local frame = value
+ if (frame.dframework) then
+ frame = frame.widget
+ end
+ if (frame.CoolTip) then
+ frame.CoolTip.FixedValue = injected
+ else
+ --debug
+ end
+ end
+ CoolTip.FixedValue = value
+ end
+
+ function CoolTip:SetColor (menuType, ...)
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (...)
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+ frame1.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame1.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame1.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+ frame2.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame2.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame2.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ else
+ return --> error
+ end
+ end
+
+ --> Set last selected option
+ function CoolTip:SetLastSelected (menuType, index, index2)
+
+ if (CoolTip.Type == 3) then
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+ CoolTip.SelectedIndexMain = index
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+ CoolTip.SelectedIndexSec [index] = index2
+ else
+ return --> error
+ end
+ else
+ return --> error
+ end
+ end
+
+ --> serack key: ~select
+ function CoolTip:Select (menuType, option, mainIndex)
+ if (menuType == 1) then --main menu
+ local botao = frame1.Lines [option]
+ CoolTip.buttonClicked = true
+ CoolTip:SetSelectedAnchor (frame1, botao)
+
+ --UIFrameFlash (frame1.selected, 0.05, 0.05, 0.2, true, 0, 0)
+
+ elseif (menuType == 2) then --sub menu
+ CoolTip:ShowSub (mainIndex)
+ local botao = frame2.Lines [option]
+ CoolTip.buttonClicked = true
+
+ CoolTip:SetSelectedAnchor (frame2, botao)
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Reset cooltip
+
+ local default_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true,
+ edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+ local default_backdrop_color = {0.09019, 0.09019, 0.18823, 1}
+ local default_backdropborder_color = {1, 1, 1, 1}
+
+ --borda preta sem usar unpack
+
+ --> wipe all data ~reset
+ function CoolTip:Reset()
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0)
+
+ frame1:SetParent (UIParent)
+ frame2:SetParent (UIParent)
+ frame1:SetFrameStrata ("TOOLTIP")
+ frame2:SetFrameStrata ("TOOLTIP")
+
+ CoolTip:HideSelectedTexture (frame1)
+ CoolTip:HideSelectedTexture (frame2)
+
+ CoolTip.FixedValue = nil
+ CoolTip.HaveSubMenu = false
+
+ CoolTip.SelectedIndexMain = nil
+ _table_wipe (CoolTip.SelectedIndexSec)
+
+ CoolTip.Indexes = 0
+ CoolTip.SubIndexes = 0
+ _table_wipe (CoolTip.IndexesSub)
+
+ CoolTip.internal_x_mod = 0
+ CoolTip.internal_y_mod = 0
+ CoolTip.current_anchor = nil
+ CoolTip.overlap_checked = false
+
+ CoolTip.frame2_leftside = nil
+
+ frame1:SetBackdrop (default_backdrop)
+ frame1:SetBackdropColor (unpack (default_backdrop_color))
+ frame1:SetBackdropBorderColor (unpack (default_backdropborder_color))
+
+ frame2:SetBackdrop (default_backdrop)
+ frame2:SetBackdropColor (unpack (default_backdrop_color))
+ frame2:SetBackdropBorderColor (unpack (default_backdropborder_color))
+
+ --[
+ _table_wipe (CoolTip.PopupFrameTable)
+
+ _table_wipe (CoolTip.LeftTextTable)
+ _table_wipe (CoolTip.LeftTextTableSub)
+ _table_wipe (CoolTip.RightTextTable)
+ _table_wipe (CoolTip.RightTextTableSub)
+
+ _table_wipe (CoolTip.LeftIconTable)
+ _table_wipe (CoolTip.LeftIconTableSub)
+ _table_wipe (CoolTip.RightIconTable)
+ _table_wipe (CoolTip.RightIconTableSub)
+
+ _table_wipe (CoolTip.StatusBarTable)
+ _table_wipe (CoolTip.StatusBarTableSub)
+
+ _table_wipe (CoolTip.FunctionsTableMain)
+ _table_wipe (CoolTip.FunctionsTableSub)
+
+ _table_wipe (CoolTip.ParametersTableMain)
+ _table_wipe (CoolTip.ParametersTableSub)
+
+ _table_wipe (CoolTip.WallpaperTable)
+ _table_wipe (CoolTip.WallpaperTableSub)
+ --]]
+
+ _table_wipe (CoolTip.TopIconTableSub)
+ CoolTip.Banner [1] = false
+ CoolTip.Banner [2] = false
+ CoolTip.Banner [3] = false
+
+ frame1.upperImage:Hide()
+ frame1.upperImage2:Hide()
+ frame1.upperImageText:Hide()
+ frame1.upperImageText2:Hide()
+
+ frame1.frameWallpaper:Hide()
+ frame2.frameWallpaper:Hide()
+
+ frame2.upperImage:Hide()
+
+ CoolTip.title1 = nil
+ CoolTip.title_text = nil
+
+ CoolTip.frame1.titleText:Hide()
+ CoolTip.frame1.titleIcon:Hide()
+
+ CoolTip:ClearAllOptions()
+ CoolTip:SetColor (1, "transparent")
+ CoolTip:SetColor (2, "transparent")
+
+ local f1Lines = frame1.Lines
+ for i = 1, #f1Lines do
+ f1Lines [i].statusbar.subMenuArrow:Hide()
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Menu functions
+
+ local _default_color = {1, 1, 1}
+ local _default_point = {"center", "center", 0, -3}
+
+ function CoolTip:AddMenu (menuType, func, param1, param2, param3, leftText, leftIcon, indexUp)
+
+ if (leftText and indexUp and ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1))) then
+ CoolTip.Indexes = CoolTip.Indexes + 1
+
+ if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
+ CoolTip.IndexesSub [CoolTip.Indexes] = 0
+ end
+
+ CoolTip.SubIndexes = 0
+ end
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ print ("Indexes are 0")
+ return --> return error
+ end
+
+ --> check data integrity
+ if (type (func) ~= "function") then
+ print ("No function")
+ return --> erroe
+ end
+
+ --> add
+
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+
+ local parameterTable
+ if (CoolTip.isSpecial) then
+ parameterTable = {}
+ _table_insert (CoolTip.FunctionsTableMain, CoolTip.Indexes, func)
+ _table_insert (CoolTip.ParametersTableMain, CoolTip.Indexes, parameterTable)
+ else
+
+ CoolTip.FunctionsTableMain [CoolTip.Indexes] = func
+
+ parameterTable = CoolTip.ParametersTableMain [CoolTip.Indexes]
+ if (not parameterTable) then
+ parameterTable = {}
+ CoolTip.ParametersTableMain [CoolTip.Indexes] = parameterTable
+ end
+ end
+
+ parameterTable [1] = param1
+ parameterTable [2] = param2
+ parameterTable [3] = param3
+
+ if (leftIcon) then
+ local iconTable = CoolTip.LeftIconTable [CoolTip.Indexes]
+
+ if (not iconTable or CoolTip.isSpecial) then
+ iconTable = {}
+ CoolTip.LeftIconTable [CoolTip.Indexes] = iconTable
+ end
+
+ iconTable [1] = leftIcon
+ iconTable [2] = 16 --> default 16
+ iconTable [3] = 16 --> default 16
+ iconTable [4] = 0 --> default 0
+ iconTable [5] = 1 --> default 1
+ iconTable [6] = 0 --> default 0
+ iconTable [7] = 1 --> default 1
+ iconTable [8] = _default_color
+ end
+
+ if (leftText) then
+ local lineTable_left = CoolTip.LeftTextTable [CoolTip.Indexes]
+
+ if (not lineTable_left or CoolTip.isSpecial) then
+ lineTable_left = {}
+ CoolTip.LeftTextTable [CoolTip.Indexes] = lineTable_left
+ end
+
+ lineTable_left [1] = leftText --> line text
+ lineTable_left [2] = 0
+ lineTable_left [3] = 0
+ lineTable_left [4] = 0
+ lineTable_left [5] = 0
+ lineTable_left [6] = false
+ lineTable_left [7] = false
+ lineTable_left [8] = false
+
+ end
+
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+
+ if (CoolTip.SubIndexes == 0) then
+ if (not indexUp or not leftText) then
+ print ("GameCooltip Error: Attempt to add a submenu with a parent")
+ return --> error
+ end
+ end
+
+ if (indexUp and leftText) then
+ CoolTip.SubIndexes = CoolTip.SubIndexes + 1
+ CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
+
+ elseif (indexUp and not leftText) then
+ print ("GameCooltip Error: Attempt to add a submenu with a parent")
+ return --> error [leftText can't be nil if indexUp are true]
+ end
+
+ --> menu container
+ local subMenuContainerParameters = CoolTip.ParametersTableSub [CoolTip.Indexes]
+ if (not subMenuContainerParameters) then
+ subMenuContainerParameters = {}
+ CoolTip.ParametersTableSub [CoolTip.Indexes] = subMenuContainerParameters
+ end
+
+ local subMenuContainerFunctions = CoolTip.FunctionsTableSub [CoolTip.Indexes]
+ if (not subMenuContainerFunctions or CoolTip.isSpecial) then
+ subMenuContainerFunctions = {}
+ CoolTip.FunctionsTableSub [CoolTip.Indexes] = subMenuContainerFunctions
+ end
+
+ --> menu table
+ local subMenuTablesParameters = subMenuContainerParameters [CoolTip.SubIndexes]
+ if (not subMenuTablesParameters or CoolTip.isSpecial) then
+ subMenuTablesParameters = {}
+ subMenuContainerParameters [CoolTip.SubIndexes] = subMenuTablesParameters
+ end
+
+ --> add
+ subMenuContainerFunctions [CoolTip.SubIndexes] = func
+
+ subMenuTablesParameters [1] = param1
+ subMenuTablesParameters [2] = param2
+ subMenuTablesParameters [3] = param3
+
+ --> text and icon
+ if (leftIcon) then
+
+ local subMenuContainerIcons = CoolTip.LeftIconTableSub [CoolTip.Indexes]
+ if (not subMenuContainerIcons) then
+ subMenuContainerIcons = {}
+ CoolTip.LeftIconTableSub [CoolTip.Indexes] = subMenuContainerIcons
+ end
+ local subMenuTablesIcons = subMenuContainerIcons [CoolTip.SubIndexes]
+ if (not subMenuTablesIcons or CoolTip.isSpecial) then
+ subMenuTablesIcons = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = subMenuTablesIcons
+ end
+
+ subMenuTablesIcons [1] = leftIcon
+ subMenuTablesIcons [2] = 16 --> default 16
+ subMenuTablesIcons [3] = 16 --> default 16
+ subMenuTablesIcons [4] = 0 --> default 0
+ subMenuTablesIcons [5] = 1 --> default 1
+ subMenuTablesIcons [6] = 0 --> default 0
+ subMenuTablesIcons [7] = 1 --> default 1
+ subMenuTablesIcons [8] = _default_color
+ end
+
+ if (leftText) then
+
+ local subMenuContainerTexts = CoolTip.LeftTextTableSub [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ CoolTip.LeftTextTableSub [CoolTip.Indexes] = subMenuContainerTexts
+ end
+ local subMenuTablesTexts = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not subMenuTablesTexts or CoolTip.isSpecial) then
+ subMenuTablesTexts = {}
+ subMenuContainerTexts [CoolTip.SubIndexes] = subMenuTablesTexts
+ end
+
+ subMenuTablesTexts [1] = leftText --> line text
+ subMenuTablesTexts [2] = 0
+ subMenuTablesTexts [3] = 0
+ subMenuTablesTexts [4] = 0
+ subMenuTablesTexts [5] = 0
+ subMenuTablesTexts [6] = false
+ subMenuTablesTexts [7] = false
+ subMenuTablesTexts [8] = false
+
+ end
+
+ CoolTip.HaveSubMenu = true
+
+ else
+ return --> error
+ end
+ end
+
+----------------------------------------------------------------------
+ --> adds a statusbar to the last line added.
+ --> only works with cooltip type 2 (tooltip with bars)
+ --> parameters: value [, color red, color green, color blue, color alpha [, glow]]
+ --> can also use a table or html color name in color red and send glow in color green
+
+ function CoolTip:AddStatusBar (statusbarValue, frame, ColorR, ColorG, ColorB, ColorA, statusbarGlow, backgroundBar, barTexture)
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ --> check data integrity
+ if (type (statusbarValue) ~= "number") then
+ return --> error
+ end
+
+ if (type (ColorR) == "table" or type (ColorR) == "string") then
+ statusbarGlow, backgroundBar, ColorR, ColorG, ColorB, ColorA = ColorG, ColorB, DF:ParseColors (ColorR)
+ elseif (type (ColorR) == "boolean") then
+ backgroundBar = ColorG
+ statusbarGlow = ColorR
+ ColorR, ColorG, ColorB, ColorA = 1, 1, 1, 1
+ else
+ --> error
+ end
+
+ --> add
+ local frameTable
+ local statusbarTable
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+ frameTable = CoolTip.StatusBarTable
+
+ if (CoolTip.isSpecial) then
+ statusbarTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
+ else
+ statusbarTable = frameTable [CoolTip.Indexes]
+ if (not statusbarTable) then
+ statusbarTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
+ --frameTable [CoolTip.Indexes] = statusbarTable
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ frameTable = CoolTip.StatusBarTableSub
+
+ local subMenuContainerStatusBar = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerStatusBar) then
+ subMenuContainerStatusBar = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerStatusBar
+ end
+
+ if (CoolTip.isSpecial) then
+ statusbarTable = {}
+ _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
+ else
+ statusbarTable = subMenuContainerStatusBar [CoolTip.SubIndexes]
+ if (not statusbarTable) then
+ statusbarTable = {}
+ _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
+ end
+ end
+ else
+ print ("unknow frame")
+ return --> error
+ end
+
+ statusbarTable [1] = statusbarValue
+ statusbarTable [2] = ColorR
+ statusbarTable [3] = ColorG
+ statusbarTable [4] = ColorB
+ statusbarTable [5] = ColorA
+ statusbarTable [6] = statusbarGlow
+ statusbarTable [7] = backgroundBar
+ statusbarTable [8] = barTexture
+
+ end
+
+ frame1.frameWallpaper:Hide()
+ frame2.frameWallpaper:Hide()
+
+ function CoolTip:SetWallpaper (index, texture, texcoord, color, desaturate)
+
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ local frameTable
+ local wallpaperTable
+
+ if ( (type (index) == "number" and index == 1) or (type (index) == "string" and index == "main") ) then
+ wallpaperTable = CoolTip.WallpaperTable
+
+ elseif ( (type (index) == "number" and index == 2) or (type (index) == "string" and index == "sub") ) then
+ frameTable = CoolTip.WallpaperTableSub
+
+ local subMenuContainerWallpapers = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerWallpapers) then
+ subMenuContainerWallpapers = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerWallpapers
+ end
+
+ wallpaperTable = subMenuContainerWallpapers
+ end
+
+ wallpaperTable [1] = texture
+ if (texcoord) then
+ wallpaperTable [2] = texcoord [1]
+ wallpaperTable [3] = texcoord [2]
+ wallpaperTable [4] = texcoord [3]
+ wallpaperTable [5] = texcoord [4]
+ else
+ wallpaperTable [2] = 0
+ wallpaperTable [3] = 1
+ wallpaperTable [4] = 0
+ wallpaperTable [5] = 1
+ end
+ wallpaperTable [6] = color
+ wallpaperTable [7] = desaturate
+ end
+
+ function CoolTip:SetBannerText (index, text, anchor, color, fontsize, fontface, fontflag)
+ local fontstring
+
+ if (index == 1) then
+ fontstring = frame1.upperImageText
+ elseif (index == 2) then
+ fontstring = frame1.upperImageText2
+ end
+
+ fontstring:SetText (text or "")
+
+ if (anchor and index == 1) then
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ fontstring:SetPoint (myAnchor, frame1.upperImage, hisAnchor or myAnchor, x or 0, y or 0)
+ elseif (anchor and index == 2) then
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ fontstring:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ fontstring:SetTextColor (r, g, b, a)
+ end
+
+ local face, size, flags = fontstring:GetFont()
+ face = fontface or [[Fonts\FRIZQT__.TTF]]
+ size = fontsize or 13
+ flags = fontflag or nil
+ fontstring:SetFont (face, size, flags)
+ fontstring:Show()
+ end
+
+ function CoolTip:SetBackdrop (index, backdrop, backdropcolor, bordercolor)
+
+ local f
+ if (index == 1) then
+ f = frame1
+ elseif (index == 2) then
+ f = frame2
+ end
+
+ if (backdrop) then
+ f:SetBackdrop (backdrop)
+ end
+ if (backdropcolor) then
+ local r, g, b, a = DF:ParseColors (backdropcolor)
+ f:SetBackdropColor (r, g, b, a)
+ end
+ if (bordercolor) then
+ local r, g, b, a = DF:ParseColors (bordercolor)
+ f:SetBackdropBorderColor (r, g, b, a)
+ end
+
+ --[=[
+ f:SetBackdrop (nil)
+
+ f.framebackgroundCenter:SetTexture (nil)
+ f.framebackgroundLeft:SetTexture (nil)
+ f.framebackgroundRight:SetTexture (nil)
+ f.frameWallpaper:SetTexture (nil)
+ --]=]
+ end
+
+ function CoolTip:SetBannerImage (index, texturepath, width, height, anchor, texcoord, overlay)
+
+ local texture
+
+ if (index == 1) then
+ texture = frame1.upperImage
+ elseif (index == 2) then
+ texture = frame1.upperImage2
+ end
+
+ if (texturepath) then
+ texture:SetTexture (texturepath)
+ end
+
+ if (width) then
+ texture:SetWidth (width)
+ end
+ if (height) then
+ texture:SetHeight (height)
+ end
+
+ if (anchor) then
+ if (type (anchor[1]) == "table") then
+ for _, t in _ipairs (anchor) do
+ local myAnchor, hisAnchor, x, y = unpack (t)
+ texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+ else
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+ end
+
+ if (texcoord) then
+ local L, R, T, B = unpack (texcoord)
+ texture:SetTexCoord (L, R, T, B)
+ end
+
+ if (overlay) then
+ texture:SetVertexColor (unpack (overlay))
+ end
+
+ CoolTip.Banner [index] = true
+ texture:Show()
+
+ end
+
+----------------------------------------------------------------------
+ --> adds a icon to the last line added.
+ --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
+ --> parameters: icon [, width [, height [, TexCoords L R T B ]]]
+ --> texture support string path or texture object
+
+ function CoolTip:AddTexture (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+ return CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+ end
+ function CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ --> check data integrity
+ if ( (type (iconTexture) ~= "string" and type (iconTexture) ~= "number") and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then
+ return --> return error
+ end
+
+ side = side or 1
+
+ local frameTable
+ local iconTable
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+
+ if (not side or (type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
+ frameTable = CoolTip.LeftIconTable
+
+ elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
+ frameTable = CoolTip.RightIconTable
+
+ end
+
+ if (CoolTip.isSpecial) then
+ iconTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, iconTable)
+ else
+ iconTable = frameTable [CoolTip.Indexes]
+ if (not iconTable) then
+ iconTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, iconTable)
+ --frameTable [CoolTip.Indexes] = iconTable
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ if ((type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
+ frameTable = CoolTip.LeftIconTableSub
+ elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
+ frameTable = CoolTip.RightIconTableSub
+ elseif ((type (side) == "string" and side == "top") or (type (side) == "number" and side == 3)) then
+ CoolTip.TopIconTableSub [CoolTip.Indexes] = CoolTip.TopIconTableSub [CoolTip.Indexes] or {}
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [1] = iconTexture
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [2] = iconWidth or 16
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [3] = iconHeight or 16
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [4] = L or 0
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [5] = R or 1
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [6] = T or 0
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [7] = B or 1
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [8] = overlayColor or _default_color
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [9] = desaturated
+ return
+ end
+
+ local subMenuContainerIcons = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerIcons) then
+ subMenuContainerIcons = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerIcons
+ end
+
+ if (CoolTip.isSpecial) then
+ iconTable = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
+ else
+ iconTable = subMenuContainerIcons [CoolTip.SubIndexes]
+ if (not iconTable) then
+ iconTable = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
+ end
+ end
+
+ else
+ return --> error
+ end
+
+ iconTable [1] = iconTexture
+ iconTable [2] = iconWidth or 16 --> default 16
+ iconTable [3] = iconHeight or 16 --> default 16
+ iconTable [4] = L or 0 --> default 0
+ iconTable [5] = R or 1 --> default 1
+ iconTable [6] = T or 0 --> default 0
+ iconTable [7] = B or 1 --> default 1
+ iconTable [8] = overlayColor or _default_color --> default 1, 1, 1
+ iconTable [9] = desaturated
+
+ return true
+ end
+
+----------------------------------------------------------------------
+ --> popup frame
+ function CoolTip:AddPopUpFrame (func_on_show, func_on_hide, param1, param2)
+
+ -- act like a sub menu
+ if (CoolTip.Indexes > 0) then
+ CoolTip.PopupFrameTable [CoolTip.Indexes] = {func_on_show or false, func_on_hide or false, param1, param2}
+ end
+
+ end
+
+----------------------------------------------------------------------
+ --> adds a line.
+ --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
+ --> parameters: left text, right text [, L color R, L color G, L color B, L color A [, R color R, R color G, R color B, R color A [, wrap]]]
+
+ --> alias
+ function CoolTip:AddDoubleLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+ return CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+ end
+
+ --> adds a line for tooltips
+ function CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+
+ --> check data integrity
+ local t = type (leftText)
+ if (t ~= "string") then
+ if (t == "number") then
+ leftText = tostring (leftText)
+ else
+ leftText = ""
+ end
+ end
+
+ local t = type (rightText)
+ if (t ~= "string") then
+ if (t == "number") then
+ rightText = tostring (rightText)
+ else
+ rightText = ""
+ end
+ end
+
+ if (type (ColorR1) ~= "number") then
+ ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2
+
+ if (type (ColorR1) == "boolean" or not ColorR1) then
+ ColorR1, ColorG1, ColorB1, ColorA1 = 0, 0, 0, 0
+ else
+ ColorR1, ColorG1, ColorB1, ColorA1 = DF:ParseColors (ColorR1)
+ end
+ end
+
+ if (type (ColorR2) ~= "number") then
+ fontSize, fontFace, fontFlag = ColorG2, ColorB2, ColorA2
+
+ if (type (ColorR2) == "boolean" or not ColorR2) then
+ ColorR2, ColorG2, ColorB2, ColorA2 = 0, 0, 0, 0
+ else
+ ColorR2, ColorG2, ColorB2, ColorA2 = DF:ParseColors (ColorR2)
+ end
+ end
+
+ local frameTableLeft
+ local frameTableRight
+ local lineTable_left
+ local lineTable_right
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+
+ CoolTip.Indexes = CoolTip.Indexes + 1
+
+ if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
+ CoolTip.IndexesSub [CoolTip.Indexes] = 0
+ end
+
+ CoolTip.SubIndexes = 0
+
+ frameTableLeft = CoolTip.LeftTextTable
+ frameTableRight = CoolTip.RightTextTable
+
+ if (CoolTip.isSpecial) then
+ lineTable_left = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
+ lineTable_right = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
+ else
+ lineTable_left = frameTableLeft [CoolTip.Indexes]
+ lineTable_right = frameTableRight [CoolTip.Indexes]
+
+ if (not lineTable_left) then
+ lineTable_left = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
+ end
+ if (not lineTable_right) then
+ lineTable_right = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ CoolTip.SubIndexes = CoolTip.SubIndexes + 1
+ CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
+ CoolTip.HaveSubMenu = true
+
+ frameTableLeft = CoolTip.LeftTextTableSub
+ frameTableRight = CoolTip.RightTextTableSub
+
+ local subMenuContainerTexts = frameTableLeft [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, subMenuContainerTexts)
+ end
+
+ if (CoolTip.isSpecial) then
+ lineTable_left = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
+ else
+ lineTable_left = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not lineTable_left) then
+ lineTable_left = {}
+ --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_left
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
+ end
+ end
+
+ local subMenuContainerTexts = frameTableRight [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, subMenuContainerTexts)
+ --frameTableRight [CoolTip.Indexes] = subMenuContainerTexts
+ end
+
+ if (CoolTip.isSpecial) then
+ lineTable_right = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
+ else
+ lineTable_right = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not lineTable_right) then
+ lineTable_right = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
+ --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_right
+ end
+ end
+ else
+ return --> error
+ end
+
+ lineTable_left [1] = leftText --> line text
+ lineTable_left [2] = ColorR1
+ lineTable_left [3] = ColorG1
+ lineTable_left [4] = ColorB1
+ lineTable_left [5] = ColorA1
+ lineTable_left [6] = fontSize
+ lineTable_left [7] = fontFace
+ lineTable_left [8] = fontFlag
+
+ lineTable_right [1] = rightText --> line text
+ lineTable_right [2] = ColorR2
+ lineTable_right [3] = ColorG2
+ lineTable_right [4] = ColorB2
+ lineTable_right [5] = ColorA2
+ lineTable_right [6] = fontSize
+ lineTable_right [7] = fontFace
+ lineTable_right [8] = fontFlag
+ end
+
+ function CoolTip:AddSpecial (widgetType, index, subIndex, ...)
+
+ local currentIndex = CoolTip.Indexes
+ local currentSubIndex = CoolTip.SubIndexes
+ CoolTip.isSpecial = true
+
+ widgetType = string.lower (widgetType)
+
+ if (widgetType == "line") then
+
+ if (subIndex) then
+ CoolTip.Indexes = index
+ CoolTip.SubIndexes = subIndex-1
+ else
+ CoolTip.Indexes = index-1
+ end
+
+ CoolTip:AddLine (...)
+
+ if (subIndex) then
+ CoolTip.Indexes = currentIndex
+ CoolTip.SubIndexes = currentSubIndex+1
+ else
+ CoolTip.Indexes = currentIndex+1
+ end
+
+ elseif (widgetType == "icon") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddIcon (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ elseif (widgetType == "statusbar") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddStatusBar (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ elseif (widgetType == "menu") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddMenu (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ end
+
+ CoolTip.isSpecial = false
+
+ end
+
+ --> search key: ~fromline
+ function CoolTip:AddFromTable (_table)
+ for index, menu in _ipairs (_table) do
+ if (menu.func) then
+ CoolTip:AddMenu (menu.type or 1, menu.func, menu.param1, menu.param2, menu.param3, nil, menu.icon)
+ elseif (menu.statusbar) then
+ CoolTip:AddStatusBar (menu.value, menu.type or 1, menu.color, true)
+ elseif (menu.icon) then
+ CoolTip:AddIcon (menu.icon, menu.type or 1, menu.side or 1, menu.width, menu.height, menu.l, menu.r, menu.t, menu.b, menu.color)
+ elseif (menu.textleft or menu.textright or menu.text) then
+ CoolTip:AddLine (menu.text, "", menu.type, menu.color, menu.color)
+ end
+ end
+ end
+
+----------------------------------------------------------------------
+ --> show cooltip
+
+ --> serach key: ~start
+ function CoolTip:Show (frame, menuType, color)
+ CoolTip.had_interaction = false
+ return CoolTip:ShowCooltip (frame, menuType, color)
+ end
+
+ function CoolTip:ShowCooltip (frame, menuType, color)
+
+ frame1:SetFrameStrata ("TOOLTIP")
+ frame2:SetFrameStrata ("TOOLTIP")
+ frame1:SetParent (UIParent)
+ frame2:SetParent (UIParent)
+
+ CoolTip.had_interaction = false
+
+ if (frame) then
+ --> details framework
+ if (frame.dframework) then
+ frame = frame.widget
+ end
+ CoolTip:SetHost (frame)
+ end
+ if (menuType) then
+ CoolTip:SetType (menuType)
+ end
+ if (color) then
+ CoolTip:SetColor (1, color)
+ CoolTip:SetColor (2, color)
+ end
+
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ return CoolTip:monta_tooltip()
+
+ elseif (CoolTip.Type == 3) then
+ return CoolTip:monta_cooltip()
+
+ end
+ end
+
+ local emptyOptions = {}
+
+ function CoolTip:Hide()
+ return CoolTip:Close()
+ end
+
+ function CoolTip:Close()
+ CoolTip.active = false
+ CoolTip.Host = nil
+ DF:FadeFrame (frame1, 1)
+ DF:FadeFrame (frame2, 1)
+ end
+
+
+
+ --> old function call
+ function CoolTip:ShowMe (host, arg2)
+ --> ignore if mouse is up me
+ if (CoolTip.mouseOver) then
+ return
+ end
+
+ if (not host or not arg2) then --> hideme
+ CoolTip:Close()
+ end
+ end
+
+ --> search key: ~inject
+ function CoolTip:ExecFunc (host, fromClick)
+
+ if (host.dframework) then
+ if (not host.widget.CoolTip) then
+ host.widget.CoolTip = host.CoolTip
+ end
+ host = host.widget
+ end
+
+ CoolTip:Reset()
+ CoolTip:SetType (host.CoolTip.Type)
+ CoolTip:SetFixedParameter (host.CoolTip.FixedValue)
+ CoolTip:SetColor ("main", host.CoolTip.MainColor or "transparent")
+ CoolTip:SetColor ("sec", host.CoolTip.SubColor or "transparent")
+
+ local okay, errortext = pcall (host.CoolTip.BuildFunc, host, host.CoolTip and host.CoolTip.FixedValue) --resetting anchors
+ if (not okay) then
+ print ("Cooltip Injected Fucntion Error:", errortext)
+ end
+
+ CoolTip:SetOwner (host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y)
+
+ local options = host.CoolTip.Options
+ if (type (options) == "function") then
+ options = options()
+ end
+ if (options) then
+ for optionName, optionValue in pairs (options) do
+ CoolTip:SetOption (optionName, optionValue)
+ end
+ end
+
+ if (CoolTip.Indexes == 0) then
+ if (host.CoolTip.Default) then
+ CoolTip:SetType ("tooltip")
+ CoolTip:AddLine (host.CoolTip.Default, nil, 1, "white")
+ end
+ end
+
+ CoolTip:ShowCooltip()
+
+ if (fromClick) then
+ --UIFrameFlash (frame1, )
+ frame1:Flash (0.05, 0.05, 0.2, true, 0, 0)
+ end
+ end
+
+ local wait = 0.2
+
+ local InjectOnUpdateEnter = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > wait) then
+ self:SetScript ("OnUpdate", nil)
+ CoolTip:ExecFunc (self)
+ end
+ end
+
+ local InjectOnUpdateLeave = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.2) then
+ if (not CoolTip.mouseOver and not CoolTip.buttonOver and self == CoolTip.Host) then
+ CoolTip:ShowMe (false)
+ end
+ self:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local InjectOnLeave = function (self)
+ CoolTip.buttonOver = false
+
+ if (CoolTip.active) then
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", InjectOnUpdateLeave)
+ else
+ self:SetScript ("OnUpdate", nil)
+ end
+
+ if (self.CoolTip.OnLeaveFunc) then
+ self.CoolTip.OnLeaveFunc (self)
+ end
+
+ if (self.OldOnLeaveScript) then
+ self:OldOnLeaveScript()
+ end
+ end
+
+ local InjectOnEnter = function (self)
+ CoolTip.buttonOver = true
+ if (CoolTip.active) then
+ CoolTip:ExecFunc (self)
+ else
+ elapsedTime = 0
+ wait = self.CoolTip.ShowSpeed or 0.2
+ self:SetScript ("OnUpdate", InjectOnUpdateEnter)
+ end
+
+ if (self.CoolTip.OnEnterFunc) then
+ self.CoolTip.OnEnterFunc (self)
+ end
+
+ if (self.OldOnEnterScript) then
+ self:OldOnEnterScript()
+ end
+ end
+
+ function CoolTip:CoolTipInject (host, openOnClick)
+ if (host.dframework) then
+ if (not host.widget.CoolTip) then
+ host.widget.CoolTip = host.CoolTip
+ end
+ host = host.widget
+ end
+
+ local coolTable = host.CoolTip
+ if (not coolTable) then
+ print ("Host nao tem uma CoolTable.")
+ return false
+ end
+
+ host.OldOnEnterScript = host:GetScript ("OnEnter")
+ host.OldOnLeaveScript = host:GetScript ("OnLeave")
+
+ host:SetScript ("OnEnter", InjectOnEnter)
+ host:SetScript ("OnLeave", InjectOnLeave)
+
+ if (openOnClick) then
+ if (host:GetObjectType() == "Button") then
+ host:SetScript ("OnClick", function() CoolTip:ExecFunc (host, true) end)
+ end
+ end
+
+ return ture
+ end
+
+ --> all done
+ CoolTip:ClearAllOptions()
+
+-- local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true,
+-- edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}}
+
+ local preset2_backdrop = {bgFile = DF.folder .. "background", edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true,
+ edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+ local default_backdrop_color = {0.09019, 0.09019, 0.18823, 0.8}
+ local default_backdropborder_color = {1, 1, 1, 1}
+
+ local gray_table = {0.37, 0.37, 0.37, 0.95}
+ local white_table = {1, 1, 1, 1}
+ local black_table = {0.2, 0.2, 0.2, 1}
+
+ function CoolTip:Preset (number)
+ self:Reset()
+
+ if (number == 1) then
+ self:SetOption ("TextFont", "Friz Quadrata TT")
+ self:SetOption ("TextColor", "orange")
+ self:SetOption ("TextSize", 12)
+ self:SetOption ("ButtonsYMod", -4)
+ self:SetOption ("YSpacingMod", -4)
+ self:SetOption ("IgnoreButtonAutoHeight", true)
+ self:SetColor (1, 0.5, 0.5, 0.5, 0.5)
+
+ elseif (number == 2) then
+ self:SetOption ("TextFont", "Friz Quadrata TT")
+ self:SetOption ("TextColor", "orange")
+ self:SetOption ("TextSize", 12)
+ self:SetOption ("FixedWidth", 220)
+ self:SetOption ("ButtonsYMod", -4)
+ self:SetOption ("YSpacingMod", -4)
+ self:SetOption ("IgnoreButtonAutoHeight", true)
+
+ self:SetColor (1, 0.5, 0.5, 0.5, 0)
+
+ self:SetBackdrop (1, preset2_backdrop, gray_table, black_table)
+ self:SetBackdrop (2, preset2_backdrop, gray_table, black_table)
+ end
+ end
+
+ function CoolTip:QuickTooltip (host, ...)
+
+ CoolTip:Preset (2)
+ CoolTip:SetHost (host)
+
+ for i = 1, select ("#", ...) do
+ local line = select (i, ...)
+ CoolTip:AddLine (line)
+ end
+
+ CoolTip:ShowCooltip()
+ end
+
+ function CoolTip:InjectQuickTooltip (host, ...)
+ host.CooltipQuickTooltip = {...}
+ host:HookScript ("OnEnter", function()
+ CoolTip:QuickTooltip (host, unpack (host.CooltipQuickTooltip))
+ end)
+ host:HookScript ("OnLeave", function()
+ CoolTip:Hide()
+ end)
+ end
+
+
+
+ return CoolTip
+
+end
+
+DF:CreateCoolTip()
diff --git a/libs/DF/cooltip.xml b/libs/DF/cooltip.xml
new file mode 100644
index 0000000..88d04c2
--- /dev/null
+++ b/libs/DF/cooltip.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/libs/DF/cooltip_background.tga b/libs/DF/cooltip_background.tga
new file mode 100644
index 0000000..8c46e0d
Binary files /dev/null and b/libs/DF/cooltip_background.tga differ
diff --git a/libs/DF/dropdown.lua b/libs/DF/dropdown.lua
new file mode 100644
index 0000000..c19eb2b
--- /dev/null
+++ b/libs/DF/dropdown.lua
@@ -0,0 +1,1172 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+local _string_len = string.len --> lua local
+
+local cleanfunction = function() end
+local APIDropDownFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "dropdown",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["dropdown"]] = _G [DF.GlobalWidgetControlNames ["dropdown"]] or metaPrototype
+end
+
+local DropDownMetaFunctions = _G [DF.GlobalWidgetControlNames ["dropdown"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ DropDownMetaFunctions.__call = function (_table, value)
+ --> unknow
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> selected value
+ local gmember_value = function (_object)
+ return _object:GetValue()
+ end
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.button:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.button:GetHeight()
+ end
+ --> current text
+ local gmember_text = function (_object)
+ return _object.label:GetText()
+ end
+ --> menu creation function
+ local gmember_function = function (_object)
+ return _object:GetFunction()
+ end
+ --> menu width
+ local gmember_menuwidth = function (_object)
+ return _rawget (self, "realsizeW")
+ end
+ --> menu height
+ local gmember_menuheight = function (_object)
+ return _rawget (self, "realsizeH")
+ end
+
+ DropDownMetaFunctions.GetMembers = DropDownMetaFunctions.GetMembers or {}
+ DropDownMetaFunctions.GetMembers ["value"] = gmember_value
+ DropDownMetaFunctions.GetMembers ["text"] = gmember_text
+ DropDownMetaFunctions.GetMembers ["shown"] = gmember_shown
+ DropDownMetaFunctions.GetMembers ["width"] = gmember_width
+ DropDownMetaFunctions.GetMembers ["menuwidth"] = gmember_menuwidth
+ DropDownMetaFunctions.GetMembers ["height"] = gmember_height
+ DropDownMetaFunctions.GetMembers ["menuheight"] = gmember_menuheight
+ DropDownMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ DropDownMetaFunctions.GetMembers ["func"] = gmember_function
+
+ DropDownMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = DropDownMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return DropDownMetaFunctions [_member_requested]
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.dropdown:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.dropdown:SetHeight (_value)
+ end
+ --> menu creation function
+ local smember_function = function (_object, _value)
+ return _object:SetFunction (_value)
+ end
+ --> menu width
+ local smember_menuwidth = function (_object, _value)
+ _object:SetMenuSize (_value, nil)
+ end
+ --> menu height
+ local smember_menuheight = function (_object, _value)
+ _object:SetMenuSize (nil, _value)
+ end
+
+ DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {}
+ DropDownMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
+ DropDownMetaFunctions.SetMembers ["show"] = smember_show
+ DropDownMetaFunctions.SetMembers ["hide"] = smember_hide
+ DropDownMetaFunctions.SetMembers ["width"] = smember_width
+ DropDownMetaFunctions.SetMembers ["menuwidth"] = smember_menuwidth
+ DropDownMetaFunctions.SetMembers ["height"] = smember_height
+ DropDownMetaFunctions.SetMembers ["menuheight"] = smember_menuheight
+ DropDownMetaFunctions.SetMembers ["func"] = smember_function
+
+ DropDownMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = DropDownMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+ function DropDownMetaFunctions:IsShown()
+ return self.dropdown:IsShown()
+ end
+ function DropDownMetaFunctions:Show()
+ return self.dropdown:Show()
+ end
+ function DropDownMetaFunctions:Hide()
+ return self.dropdown:Hide()
+ end
+
+--> menu width and height
+ function DropDownMetaFunctions:SetMenuSize (w, h)
+ if (w) then
+ return _rawset (self, "realsizeW", w)
+ end
+ if (h) then
+ return _rawset (self, "realsizeH", h)
+ end
+ end
+ function DropDownMetaFunctions:GetMenuSize()
+ return _rawget (self, "realsizeW"), _rawget (self, "realsizeH")
+ end
+
+--> function
+ function DropDownMetaFunctions:SetFunction (func)
+ return _rawset (self, "func", func)
+ end
+ function DropDownMetaFunctions:GetFunction()
+ return _rawget (self, "func")
+ end
+
+--> value
+ function DropDownMetaFunctions:GetValue()
+ return _rawget (self, "myvalue")
+ end
+ function DropDownMetaFunctions:SetValue (value)
+ return _rawset (self, "myvalue", value)
+ end
+
+--> setpoint
+ function DropDownMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+--> sizes
+ function DropDownMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.dropdown:SetWidth (w)
+ end
+ if (h) then
+ return self.dropdown:SetHeight (h)
+ end
+ end
+
+--> tooltip
+ function DropDownMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function DropDownMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+--> frame levels
+ function DropDownMetaFunctions:GetFrameLevel()
+ return self.dropdown:GetFrameLevel()
+ end
+ function DropDownMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.dropdown:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.dropdown:SetFrameLevel (framelevel)
+ end
+ end
+
+--> frame stratas
+ function DropDownMetaFunctions:GetFrameStrata()
+ return self.dropdown:GetFrameStrata()
+ end
+ function DropDownMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.dropdown:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.dropdown:SetFrameStrata (strata)
+ end
+ end
+
+--> enabled
+ function DropDownMetaFunctions:IsEnabled()
+ return self.dropdown:IsEnabled()
+ end
+
+ function DropDownMetaFunctions:Enable()
+
+ self:SetAlpha (1)
+ _rawset (self, "lockdown", false)
+
+ if (self.OnEnable) then
+ self.OnEnable (self)
+ end
+ --return self.dropdown:Enable()
+ end
+
+ function DropDownMetaFunctions:Disable()
+
+ self:SetAlpha (.4)
+ _rawset (self, "lockdown", true)
+
+ if (self.OnDisable) then
+ self.OnDisable (self)
+ end
+ --return self.dropdown:Disable()
+ end
+
+--> fixed value
+ function DropDownMetaFunctions:SetFixedParameter (value)
+ _rawset (self, "FixedValue", value)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+local last_opened = false
+
+local function isOptionVisible (thisOption)
+ if (_type (thisOption.shown) == "boolean" or _type (thisOption.shown) == "function") then
+ if (not thisOption.shown) then
+ return false
+ elseif (not thisOption.shown()) then
+ return false
+ end
+ end
+ return true
+end
+
+function DropDownMetaFunctions:Refresh()
+ --> do a safe call
+ local menu = DF:Dispatch (self.func, self)
+
+ if (#menu == 0) then
+ self:NoOption (true)
+ self.no_options = true
+ return false
+
+ elseif (self.no_options) then
+ self.no_options = false
+ self:NoOption (false)
+ self:NoOptionSelected()
+ return true
+ end
+
+ return true
+end
+
+function DropDownMetaFunctions:NoOptionSelected()
+ if (self.no_options) then
+ return
+ end
+ self.label:SetText (self.empty_text or "no option selected")
+ self.label:SetPoint ("left", self.icon, "right", 2, 0)
+ self.label:SetTextColor (1, 1, 1, 0.4)
+ if (self.empty_icon) then
+ self.icon:SetTexture (self.empty_icon)
+ else
+ self.icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
+ self.icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
+ end
+ self.icon:SetVertexColor (1, 1, 1, 0.4)
+
+ self.last_select = nil
+end
+
+function DropDownMetaFunctions:NoOption (state)
+ if (state) then
+ self:Disable()
+ self:SetAlpha (0.5)
+ self.no_options = true
+ self.label:SetText ("no options")
+ self.label:SetPoint ("left", self.icon, "right", 2, 0)
+ self.label:SetTextColor (1, 1, 1, 0.4)
+ self.icon:SetTexture ([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]])
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ self.icon:SetVertexColor (1, 1, 1, 0.4)
+ else
+ self.no_options = false
+ self:Enable()
+ self:SetAlpha (1)
+ end
+end
+
+function DropDownMetaFunctions:Select (optionName, byOptionNumber)
+
+ if (type (optionName) == "boolean" and not optionName) then
+ self:NoOptionSelected()
+ return false
+ end
+
+ local menu = DF:Dispatch (self.func, self)
+
+ if (#menu == 0) then
+ self:NoOption (true)
+ return true
+ else
+ self:NoOption (false)
+ end
+
+ if (byOptionNumber and type (optionName) == "number") then
+ if (not menu [optionName]) then --> invalid index
+ self:NoOptionSelected()
+ return false
+ end
+ self:Selected (menu [optionName])
+ return true
+ end
+
+ for _, thisMenu in ipairs (menu) do
+ if ( ( thisMenu.label == optionName or thisMenu.value == optionName ) and isOptionVisible (thisMenu)) then
+ self:Selected (thisMenu)
+ return true
+ end
+ end
+
+ return false
+end
+
+function DropDownMetaFunctions:SetEmptyTextAndIcon (text, icon)
+ if (text) then
+ self.empty_text = text
+ end
+ if (icon) then
+ self.empty_icon = icon
+ end
+
+ self:Selected (self.last_select)
+end
+
+function DropDownMetaFunctions:Selected (_table)
+
+ if (not _table) then
+
+ --> there is any options?
+ if (not self:Refresh()) then
+ self.last_select = nil
+ return
+ end
+
+ --> exists options but none selected
+ self:NoOptionSelected()
+ return
+ end
+
+ self.last_select = _table
+ self:NoOption (false)
+
+ self.label:SetText (_table.label)
+ self.icon:SetTexture (_table.icon)
+
+ if (_table.icon) then
+ self.label:SetPoint ("left", self.icon, "right", 2, 0)
+ if (_table.texcoord) then
+ self.icon:SetTexCoord (unpack (_table.texcoord))
+ else
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ end
+
+ if (_table.iconcolor) then
+ if (type (_table.iconcolor) == "string") then
+ self.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
+ else
+ self.icon:SetVertexColor (unpack (_table.iconcolor))
+ end
+ else
+ self.icon:SetVertexColor (1, 1, 1, 1)
+ end
+
+ self.icon:SetSize (self:GetHeight()-2, self:GetHeight()-2)
+ else
+ self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0)
+ end
+
+ self.statusbar:SetTexture (_table.statusbar)
+
+ if (_table.color) then
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
+ self.label:SetTextColor (_value1, _value2, _value3, _value4)
+ else
+ self.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ if (_table.font) then
+ self.label:SetFont (_table.font, 10)
+ else
+ self.label:SetFont ("GameFontHighlightSmall", 10)
+ end
+
+ self:SetValue (_table.value)
+
+end
+
+function DetailsFrameworkDropDownOptionClick (button)
+
+ --> update name and icon on main frame
+ button.object:Selected (button.table)
+
+ --> close menu frame
+ button.object:Close()
+
+ --> exec function if any
+ if (button.table.onclick) then
+
+ local success, errorText = pcall (button.table.onclick, button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
+ if (not success) then
+ error ("Details! Framework: dropdown " .. button:GetParent():GetParent():GetParent().MyObject:GetName() .. " error: " .. errorText)
+ end
+
+ button:GetParent():GetParent():GetParent().MyObject:RunHooksForWidget ("OnOptionSelected", button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
+ end
+
+ --> set the value of selected option in main object
+ button.object.myvalue = button.table.value
+ button.object.myvaluelabel = button.table.label
+end
+
+function DropDownMetaFunctions:Open()
+ self.dropdown.dropdownframe:Show()
+ self.dropdown.dropdownborder:Show()
+ self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
+ self.opened = true
+ if (last_opened) then
+ last_opened:Close()
+ end
+ last_opened = self
+end
+
+function DropDownMetaFunctions:Close()
+ --> when menu is being close, just hide the border and the script will call back this again
+ if (self.dropdown.dropdownborder:IsShown()) then
+ self.dropdown.dropdownborder:Hide()
+ return
+ end
+ self.dropdown.dropdownframe:Hide()
+ self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
+
+ local selectedTexture = _G [self:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
+ selectedTexture:Hide()
+
+ self.opened = false
+ last_opened = false
+end
+
+--> close by escape key
+function DetailsFrameworkDropDownOptionsFrameOnHide (frame)
+ frame:GetParent().MyObject:Close()
+end
+
+function DetailsFrameworkDropDownOptionOnEnter (frame)
+ if (frame.table.desc) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine (frame.table.desc)
+ if (frame.table.descfont) then
+ GameCooltip2:SetOption ("TextFont", frame.table.descfont)
+ end
+
+ if (frame.table.tooltipwidth) then
+ GameCooltip2:SetOption ("FixedWidth", frame.table.tooltipwidth)
+ end
+
+ GameCooltip2:SetHost (frame, "topleft", "topright", 10, 0)
+
+ GameCooltip2:ShowCooltip (nil, "tooltip")
+ frame.tooltip = true
+ end
+ frame:GetParent().mouseover:SetPoint ("left", frame)
+ frame:GetParent().mouseover:Show()
+end
+
+function DetailsFrameworkDropDownOptionOnLeave (frame)
+ if (frame.table.desc) then
+ GameCooltip2:ShowMe (false)
+ end
+ frame:GetParent().mouseover:Hide()
+end
+
+function DetailsFrameworkDropDownOnMouseDown (button)
+
+ local object = button.MyObject
+
+ if (not object.opened and not _rawget (object, "lockdown")) then --> click to open
+
+ local menu = object:func()
+ object.builtMenu = menu
+
+ local frame_witdh = object.realsizeW
+
+ if (menu [1]) then
+ --> build menu
+
+ local scrollFrame = _G [button:GetName() .. "_ScrollFrame"]
+ local scrollChild = _G [button:GetName() .. "_ScrollFrame_ScrollChild"]
+ local scrollBorder = _G [button:GetName() .. "_Border"]
+ local selectedTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
+ local mouseOverTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_MouseOverTexture"]
+
+ local i = 1
+ local showing = 0
+ local currentText = button.text:GetText() or ""
+ local currentIndex
+
+ if (object.OnMouseDownHook) then
+ local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture)
+ if (interrupt) then
+ return
+ end
+ end
+
+ for tindex, _table in ipairs (menu) do
+
+ local show = isOptionVisible (_table)
+
+ if (show) then
+ local _this_row = object.menus [i]
+ showing = showing + 1
+
+ if (not _this_row) then
+
+ local name = button:GetName() .. "Row" .. i
+ local parent = scrollChild
+
+ _this_row = DF:CreateDropdownButton (parent, name)
+ local anchor_i = i-1
+ _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
+ _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
+ _this_row.object = object
+ object.menus [i] = _this_row
+ end
+
+ _this_row:SetFrameStrata (_this_row:GetParent():GetFrameStrata())
+ _this_row:SetFrameLevel (_this_row:GetParent():GetFrameLevel()+10)
+
+ _this_row.icon:SetTexture (_table.icon)
+ if (_table.icon) then
+
+ _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
+
+ if (_table.texcoord) then
+ _this_row.icon:SetTexCoord (unpack (_table.texcoord))
+ else
+ _this_row.icon:SetTexCoord (0, 1, 0, 1)
+ end
+
+ if (_table.iconcolor) then
+ if (type (_table.iconcolor) == "string") then
+ _this_row.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
+ else
+ _this_row.icon:SetVertexColor (unpack (_table.iconcolor))
+ end
+ else
+ _this_row.icon:SetVertexColor (1, 1, 1, 1)
+ end
+ else
+ _this_row.label:SetPoint ("left", _this_row.statusbar, "left", 2, 0)
+ end
+
+ if (_table.iconsize) then
+ _this_row.icon:SetSize (_table.iconsize[1], _table.iconsize[2])
+ else
+ _this_row.icon:SetSize (20, 20)
+ end
+
+ if (_table.font) then
+ _this_row.label:SetFont (_table.font, 10.5)
+ else
+ _this_row.label:SetFont ("GameFontHighlightSmall", 10.5)
+ end
+
+ _this_row.statusbar:SetTexture (_table.statusbar)
+ _this_row.label:SetText (_table.label)
+
+ if (currentText and currentText == _table.label) then
+ if (_table.icon) then
+ selectedTexture:SetPoint ("left", _this_row.icon, "left", -3, 0)
+ else
+ selectedTexture:SetPoint ("left", _this_row.statusbar, "left", 0, 0)
+ end
+
+ selectedTexture:Show()
+ selectedTexture:SetVertexColor (1, 1, 1, .3)
+ selectedTexture:SetTexCoord (0, 29/32, 5/32, 27/32)
+
+ currentIndex = tindex
+ currentText = nil
+ end
+
+ if (_table.color) then
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
+ _this_row.label:SetTextColor (_value1, _value2, _value3, _value4)
+ else
+ _this_row.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ _this_row.table = _table
+
+ local labelwitdh = _this_row.label:GetStringWidth()
+ if (labelwitdh+40 > frame_witdh) then
+ frame_witdh = labelwitdh+40
+ end
+ _this_row:Show()
+
+ i = i + 1
+ end
+
+ end
+
+ if (currentText) then
+ selectedTexture:Hide()
+ else
+ selectedTexture:SetWidth (frame_witdh-20)
+ end
+
+ for i = showing+1, #object.menus do
+ object.menus [i]:Hide()
+ end
+
+ local size = object.realsizeH
+
+ if (showing*20 > size) then
+ --show scrollbar and setup scroll
+ object:ShowScroll()
+ scrollFrame:EnableMouseWheel (true)
+ object.scroll:Altura (size-35)
+ object.scroll:SetMinMaxValues (0, (showing*20) - size + 20)
+ --width
+ scrollBorder:SetWidth (frame_witdh+20)
+ scrollFrame:SetWidth (frame_witdh+20)
+ scrollChild:SetWidth (frame_witdh+20)
+ --height
+ scrollBorder:SetHeight (size+2)
+ scrollFrame:SetHeight (size+2)
+ scrollChild:SetHeight ((showing*20)+20)
+ --mouse over texture
+ mouseOverTexture:SetWidth (frame_witdh-7)
+ --selected
+ selectedTexture:SetWidth (frame_witdh - 9)
+
+ for index, row in ipairs (object.menus) do
+ row:SetPoint ("topright", scrollChild, "topright", -22, ((-index-1)*20)-5)
+ end
+
+ else
+ --hide scrollbar and disable wheel
+ object:HideScroll()
+ scrollFrame:EnableMouseWheel (false)
+ --width
+ scrollBorder:SetWidth (frame_witdh)
+ scrollFrame:SetWidth (frame_witdh)
+ scrollChild:SetWidth (frame_witdh)
+ --height
+ scrollBorder:SetHeight ((showing*20) + 10)
+ scrollFrame:SetHeight ((showing*20) + 10)
+ --mouse over texture
+ mouseOverTexture:SetWidth (frame_witdh-10)
+ --selected
+ selectedTexture:SetWidth (frame_witdh - 9)
+
+ for index, row in ipairs (object.menus) do
+ row:SetPoint ("topright", scrollChild, "topright", -5, ((-index-1)*20)-5)
+ end
+ end
+
+ if (object.myvaluelabel and currentIndex and scrollFrame.slider:IsShown()) then
+ object.scroll:SetValue (max ((currentIndex*20) - 80, 0))
+ else
+ object.scroll:SetValue (0)
+ end
+
+ object:Open()
+
+ else
+ --> clear menu
+
+ end
+
+ else --> click to close
+
+ object:Close()
+ end
+
+end
+
+function DetailsFrameworkDropDownOnEnter (self)
+
+ local capsule = self.MyObject
+ local kill = capsule:RunHooksForWidget ("OnEnter", self, capsule)
+ if (kill) then
+ return
+ end
+
+ if (self.MyObject.onenter_backdrop) then
+ self:SetBackdropColor (unpack (self.MyObject.onenter_backdrop))
+ else
+ self:SetBackdropColor (.2, .2, .2, .2)
+ end
+
+ if (self.MyObject.onenter_backdrop_border_color) then
+ self:SetBackdropBorderColor (unpack (self.MyObject.onenter_backdrop_border_color))
+ end
+
+ self.arrowTexture2:Show()
+
+ if (self.MyObject.have_tooltip) then
+ GameCooltip2:Preset (2)
+
+ if (type (self.MyObject.have_tooltip) == "function") then
+ GameCooltip2:AddLine (self.MyObject.have_tooltip() or "")
+ else
+ GameCooltip2:AddLine (self.MyObject.have_tooltip)
+ end
+
+ GameCooltip2:SetOwner (self)
+ GameCooltip2:ShowCooltip()
+ end
+
+end
+
+function DetailsFrameworkDropDownOnLeave (self)
+ local capsule = self.MyObject
+ local kill = capsule:RunHooksForWidget ("OnLeave", self, capsule)
+ if (kill) then
+ return
+ end
+
+ if (self.MyObject.onleave_backdrop) then
+ self:SetBackdropColor (unpack (self.MyObject.onleave_backdrop))
+ else
+ self:SetBackdropColor (1, 1, 1, .5)
+ end
+
+ if (self.MyObject.onleave_backdrop_border_color) then
+ self:SetBackdropBorderColor (unpack (self.MyObject.onleave_backdrop_border_color))
+ end
+
+ self.arrowTexture2:Hide()
+
+ if (self.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+end
+
+function DetailsFrameworkDropDownOnSizeChanged (self, w, h)
+ self.MyObject.label:SetSize (self:GetWidth()-40, 10)
+end
+
+function DetailsFrameworkDropDownOnShow (self)
+ local capsule = self.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", self, capsule)
+ if (kill) then
+ return
+ end
+end
+
+function DetailsFrameworkDropDownOnHide (self)
+ local capsule = self.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", self, capsule)
+ if (kill) then
+ return
+ end
+
+ self.MyObject:Close()
+end
+
+function DF:BuildDropDownFontList (on_click, icon, icon_texcoord, icon_size)
+ local t = {}
+ local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+ for name, fontPath in pairs (SharedMedia:HashTable ("font")) do
+ t[#t+1] = {value = name, label = name, onclick = on_click, icon = icon, iconsize = icon_size, texcoord = icon_texcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
+ end
+ table.sort (t, function (t1, t2) return t1.label < t2.label end)
+ return t
+end
+
+------------------------------------------------------------------------------------------------------------
+function DropDownMetaFunctions:SetTemplate (template)
+
+ if (template.width) then
+ self:SetWidth (template.width)
+ end
+ if (template.height) then
+ self:SetHeight (template.height)
+ end
+
+ if (template.backdrop) then
+ self:SetBackdrop (template.backdrop)
+ end
+ if (template.backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropcolor)
+ self:SetBackdropColor (r, g, b, a)
+ self.onleave_backdrop = {r, g, b, a}
+ end
+ if (template.backdropbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
+ self:SetBackdropBorderColor (r, g, b, a)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onentercolor) then
+ local r, g, b, a = DF:ParseColors (template.onentercolor)
+ self.onenter_backdrop = {r, g, b, a}
+ end
+
+ if (template.onleavecolor) then
+ local r, g, b, a = DF:ParseColors (template.onleavecolor)
+ self.onleave_backdrop = {r, g, b, a}
+ end
+
+ if (template.onenterbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onenterbordercolor)
+ self.onenter_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onleavebordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onleavebordercolor)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateDropDown (parent, func, default, w, h, member, name, template)
+ return DF:NewDropDown (parent, parent, name, member, w, h, func, default, template)
+end
+
+function DF:NewDropDown (parent, container, name, member, w, h, func, default, template)
+
+ if (not name) then
+ name = "DetailsFrameworkDropDownNumber" .. DF.DropDownCounter
+ DF.DropDownCounter = DF.DropDownCounter + 1
+
+ elseif (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local DropDownObject = {type = "dropdown", dframework = true}
+
+ if (member) then
+ parent [member] = DropDownObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ if (default == nil) then
+ default = 1
+ end
+
+ --> default members:
+ --> misc
+ DropDownObject.container = container
+
+ DropDownObject.dropdown = DF:CreateNewDropdownFrame (parent, name)
+
+ DropDownObject.widget = DropDownObject.dropdown
+
+ DropDownObject.__it = {nil, nil}
+
+ if (not APIDropDownFunctions) then
+ APIDropDownFunctions = true
+ local idx = getmetatable (DropDownObject.dropdown).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not DropDownMetaFunctions [funcName]) then
+ DropDownMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.dropdown:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ DropDownObject.dropdown.MyObject = DropDownObject
+
+ DropDownObject.dropdown:SetWidth (w)
+ DropDownObject.dropdown:SetHeight (h)
+
+ DropDownObject.func = func
+ DropDownObject.realsizeW = 150
+ DropDownObject.realsizeH = 150
+ DropDownObject.FixedValue = nil
+ DropDownObject.opened = false
+ DropDownObject.menus = {}
+ DropDownObject.myvalue = nil
+
+ DropDownObject.label = _G [name .. "_Text"]
+
+ DropDownObject.icon = _G [name .. "_IconTexture"]
+ DropDownObject.statusbar = _G [name .. "_StatusBarTexture"]
+ DropDownObject.select = _G [name .. "_SelectedTexture"]
+
+ local scroll = _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame"]
+
+ DropDownObject.scroll = DF:NewScrollBar (scroll, _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame".."_ScrollChild"], -18, -18)
+ DF:ReskinSlider (scroll)
+
+ function DropDownObject:HideScroll()
+ scroll.baixo:Hide()
+ scroll.cima:Hide()
+ scroll.slider:Hide()
+ end
+ function DropDownObject:ShowScroll()
+ scroll.baixo:Show()
+ scroll.cima:Show()
+ scroll.slider:Show()
+ end
+
+ DropDownObject:HideScroll()
+ DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10)
+
+ DropDownObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnOptionSelected = {},
+ }
+
+ DropDownObject.dropdown:SetScript ("OnShow", DetailsFrameworkDropDownOnShow)
+ DropDownObject.dropdown:SetScript ("OnHide", DetailsFrameworkDropDownOnHide)
+ DropDownObject.dropdown:SetScript ("OnEnter", DetailsFrameworkDropDownOnEnter)
+ DropDownObject.dropdown:SetScript ("OnLeave", DetailsFrameworkDropDownOnLeave)
+
+ --> setup class
+ _setmetatable (DropDownObject, DropDownMetaFunctions)
+
+ --> initialize first menu selected
+ if (type (default) == "string") then
+ DropDownObject:Select (default)
+
+ elseif (type (default) == "number") then
+ if (not DropDownObject:Select (default)) then
+ DropDownObject:Select (default, true)
+ end
+ end
+
+ if (template) then
+ DropDownObject:SetTemplate (template)
+ end
+
+ return DropDownObject
+
+end
+
+local default_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
+edgeSize = 1, tile = true, tileSize = 16, insets = {left = 1, right = 1, top = 0, bottom = 1}}
+local border_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+local child_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 256, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+
+function DF:CreateNewDropdownFrame (parent, name)
+ local f = CreateFrame ("button", name, parent)
+ f:SetBackdrop (default_backdrop)
+ f:SetSize (150, 20)
+
+ local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "BACKGROUND")
+ statusbar:SetPoint ("topleft", f, "topleft", 3, -3)
+ statusbar:SetPoint ("bottomright", f, "bottomright", -3, 3)
+ f.statusbar = statusbar
+
+ local icon = f:CreateTexture ("$parent_IconTexture", "ARTWORK")
+ icon:SetPoint ("left", f, "left", 2, 0)
+ icon:SetSize (20, 20)
+ icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
+ icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
+ icon:SetVertexColor (1, 1, 1, 0.4)
+ f.icon = icon
+
+ local text = f:CreateFontString ("$parent_Text", "ARTWORK", "GameFontHighlightSmall")
+ text:SetPoint ("left", icon, "right", 5, 0)
+ text:SetJustifyH ("left")
+ text:SetText ("no option selected")
+ text:SetTextColor (1, 1, 1, 0.4)
+ DF:SetFontSize (text, 10)
+ f.text = text
+
+ local arrow = f:CreateTexture ("$parent_ArrowTexture2", "OVERLAY")
+ arrow:SetPoint ("right", f, "right", 5, -1)
+ arrow:SetBlendMode ("ADD")
+ arrow:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Highlight]])
+ arrow:Hide()
+ arrow:SetSize (32, 28)
+ f.arrowTexture2 = arrow
+
+ local buttonTexture = f:CreateTexture ("$parent_ArrowTexture", "OVERLAY")
+ buttonTexture:SetPoint ("right", f, "right", 5, -1)
+ buttonTexture:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Up]])
+ buttonTexture:SetSize (32, 28)
+ f.arrowTexture = buttonTexture
+
+ --scripts
+ f:SetScript ("OnSizeChanged", DetailsFrameworkDropDownOnSizeChanged)
+ f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOnMouseDown)
+
+ --on load
+ f:SetBackdropColor (1, 1, 1, .5)
+ f.arrowTexture:SetDrawLayer ("OVERLAY", 1)
+ f.arrowTexture2:SetDrawLayer ("OVERLAY", 2)
+
+ --dropdown
+ local border = CreateFrame ("frame", "$Parent_Border", f)
+ border:Hide()
+ border:SetFrameStrata ("FULLSCREEN")
+ border:SetSize (150, 150)
+ border:SetPoint ("topleft", f, "bottomleft")
+ border:SetBackdrop (border_backdrop)
+ border:SetScript ("OnHide", DetailsFrameworkDropDownOptionsFrameOnHide)
+ border:SetBackdropColor (0, 0, 0, 0.92)
+ border:SetBackdropBorderColor (0, 0, 0, 1)
+ f.dropdownborder = border
+
+ local scroll = CreateFrame ("ScrollFrame", "$Parent_ScrollFrame", f)
+ scroll:Hide()
+ scroll:SetFrameStrata ("FULLSCREEN")
+ scroll:SetSize (150, 150)
+ scroll:SetPoint ("topleft", f, "bottomleft", 0, 0)
+ f.dropdownframe = scroll
+
+ local child = CreateFrame ("frame", "$Parent_ScrollChild", scroll)
+ child:SetSize (150, 150)
+ child:SetPoint ("topleft", scroll, "topleft", 0, 0)
+ child:SetBackdrop (child_backdrop)
+ child:SetBackdropColor (0, 0, 0, 1)
+
+ DF:ApplyStandardBackdrop (child)
+
+ local selected = child:CreateTexture ("$parent_SelectedTexture", "BACKGROUND")
+ selected:SetSize (150, 16)
+ selected:Hide()
+ selected:SetPoint ("left", child, "left", 2, 0)
+ selected:SetTexture ([[Interface\RAIDFRAME\Raid-Bar-Hp-Fill]])
+ child.selected = selected
+
+ local mouseover = child:CreateTexture ("$parent_MouseOverTexture", "ARTWORK")
+ mouseover:SetBlendMode ("ADD")
+ mouseover:Hide()
+ mouseover:SetTexture ([[Interface\Buttons\UI-Listbox-Highlight]])
+ mouseover:SetSize (150, 15)
+ mouseover:SetPoint ("left", child, "left", 2, 0)
+ child.mouseover = mouseover
+
+ scroll:SetScrollChild (child)
+ tinsert (UISpecialFrames, f.dropdownborder:GetName())
+ tinsert (UISpecialFrames, f.dropdownframe:GetName())
+
+ return f
+end
+
+function DF:CreateDropdownButton (parent, name)
+
+ local f = CreateFrame ("button", name, parent)
+ f:SetSize (150, 20)
+
+ local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "ARTWORK")
+ statusbar:SetPoint ("left", f, "left", 1, 0)
+ statusbar:SetPoint ("right", f, "right", -10, 0)
+ statusbar:SetSize (150, 20)
+ f.statusbar = statusbar
+
+ local icon = f:CreateTexture ("$parent_IconTexture", "OVERLAY")
+ icon:SetPoint ("left", f, "left", 2, 0)
+ icon:SetSize (20, 20)
+ icon:SetTexture ([[Interface\ICONS\Spell_ChargePositive]])
+ f.icon = icon
+
+ local text = f:CreateFontString ("$parent_Text", "OVERLAY", "GameFontHighlightSmall")
+ text:SetPoint ("left", icon, "right", 5, 0)
+ text:SetJustifyH ("left")
+ DF:SetFontSize (text, 10)
+ f.label = text
+
+ f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOptionClick)
+ f:SetScript ("OnEnter", DetailsFrameworkDropDownOptionOnEnter)
+ f:SetScript ("OnLeave", DetailsFrameworkDropDownOptionOnLeave)
+
+ return f
+end
diff --git a/libs/DF/dropdown.xml b/libs/DF/dropdown.xml
new file mode 100644
index 0000000..63b4a88
--- /dev/null
+++ b/libs/DF/dropdown.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/libs/DF/feedback_sites.tga b/libs/DF/feedback_sites.tga
new file mode 100644
index 0000000..cad38ed
Binary files /dev/null and b/libs/DF/feedback_sites.tga differ
diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua
new file mode 100644
index 0000000..a10b21f
--- /dev/null
+++ b/libs/DF/fw.lua
@@ -0,0 +1,2830 @@
+
+local dversion = 139
+local major, minor = "DetailsFramework-1.0", dversion
+local DF, oldminor = LibStub:NewLibrary (major, minor)
+
+if (not DF) then
+ DetailsFrameworkCanLoad = false
+ return
+end
+
+DetailsFrameworkCanLoad = true
+local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+
+local _
+local _type = type
+local _unpack = unpack
+local upper = string.upper
+local string_match = string.match
+
+SMALL_NUMBER = 0.000001
+ALPHA_BLEND_AMOUNT = 0.8400251
+
+DF.AuthorInfo = {
+ Name = "Tercioo",
+ Discord = "https://discord.gg/AGSzAZX",
+}
+
+--> will always give a very random name for our widgets
+local init_counter = math.random (1, 1000000)
+
+DF.LabelNameCounter = DF.LabelNameCounter or init_counter
+DF.PictureNameCounter = DF.PictureNameCounter or init_counter
+DF.BarNameCounter = DF.BarNameCounter or init_counter
+DF.DropDownCounter = DF.DropDownCounter or init_counter
+DF.PanelCounter = DF.PanelCounter or init_counter
+DF.SimplePanelCounter = DF.SimplePanelCounter or init_counter
+DF.ButtonCounter = DF.ButtonCounter or init_counter
+DF.SliderCounter = DF.SliderCounter or init_counter
+DF.SwitchCounter = DF.SwitchCounter or init_counter
+DF.SplitBarCounter = DF.SplitBarCounter or init_counter
+
+DF.FRAMELEVEL_OVERLAY = 750
+DF.FRAMELEVEL_BACKGROUND = 150
+
+DF.FrameWorkVersion = tostring (dversion)
+function DF:PrintVersion()
+ print ("Details! Framework Version:", DF.FrameWorkVersion)
+end
+
+LibStub:GetLibrary("AceTimer-3.0"):Embed (DF)
+
+--> get the working folder
+do
+ local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
+ if (path) then
+ DF.folder = "Interface\\AddOns\\" .. path
+ else
+ --> if not found, try to use the last valid one
+ DF.folder = DF.folder or ""
+ end
+end
+
+DF.debug = false
+
+_G ["DetailsFramework"] = DF
+
+DF.embeds = DF.embeds or {}
+local embed_functions = {
+ "RemoveRealName",
+ "table",
+ "BuildDropDownFontList",
+ "SetFontSize",
+ "SetFontFace",
+ "SetFontColor",
+ "GetFontSize",
+ "GetFontFace",
+ "SetFontOutline",
+ "trim",
+ "Msg",
+ "CreateFlashAnimation",
+ "Fade",
+ "NewColor",
+ "IsHtmlColor",
+ "ParseColors",
+ "BuildMenu",
+ "ShowTutorialAlertFrame",
+ "GetNpcIdFromGuid",
+ "ShowFeedbackPanel",
+ "SetAsOptionsPanel",
+ "GetPlayerRole",
+ "GetCharacterTalents",
+ "GetCharacterPvPTalents",
+
+ "CreateDropDown",
+ "CreateButton",
+ "CreateColorPickButton",
+ "CreateLabel",
+ "CreateBar",
+ "CreatePanel",
+ "CreateFillPanel",
+ "ColorPick",
+ "IconPick",
+ "CreateSimplePanel",
+ "CreateChartPanel",
+ "CreateImage",
+ "CreateScrollBar",
+ "CreateSwitch",
+ "CreateSlider",
+ "CreateSplitBar",
+ "CreateTextEntry",
+ "Create1PxPanel",
+ "CreateFeedbackButton",
+ "CreateOptionsFrame",
+ "NewSpecialLuaEditorEntry",
+ "ShowPromptPanel",
+ "ShowTextPromptPanel",
+ "www_icons",
+ "GetTemplate",
+ "InstallTemplate",
+ "GetFrameworkFolder",
+ "ShowPanicWarning",
+ "SetFrameworkDebugState",
+ "FindHighestParent",
+ "OpenInterfaceProfile",
+ "CreateInCombatTexture",
+ "CreateAnimationHub",
+ "CreateAnimation",
+ "CreateScrollBox",
+ "CreateBorder",
+ "FormatNumber",
+ "IntegerToTimer",
+ "QuickDispatch",
+ "Dispatch",
+ "CommaValue",
+ "RemoveRealmName",
+ "Trim",
+ "CreateGlowOverlay",
+ "CreateAnts",
+ "CreateFrameShake",
+}
+
+DF.WidgetFunctions = {
+ GetCapsule = function (self)
+ return self.MyObject
+ end,
+}
+
+DF.table = {}
+
+function DF:GetFrameworkFolder()
+ return DF.folder
+end
+
+function DF:SetFrameworkDebugState (state)
+ DF.debug = state
+end
+
+function DF:FadeFrame (frame, t)
+ if (t == 0) then
+ frame.hidden = false
+ frame.faded = false
+ frame.fading_out = false
+ frame.fading_in = false
+ frame:Show()
+ frame:SetAlpha (1)
+
+ elseif (t == 1) then
+ frame.hidden = true
+ frame.faded = true
+ frame.fading_out = false
+ frame.fading_in = false
+ frame:SetAlpha (0)
+ frame:Hide()
+ end
+end
+
+function DF.table.find (t, value)
+ for i = 1, #t do
+ if (t[i] == value) then
+ return i
+ end
+ end
+end
+
+function DF.table.addunique (t, index, value)
+ if (not value) then
+ value = index
+ index = #t + 1
+ end
+
+ for i = 1, #t do
+ if (t[i] == value) then
+ return false
+ end
+ end
+
+ tinsert (t, index, value)
+ return true
+end
+
+function DF.table.reverse (t)
+ local new = {}
+ local index = 1
+ for i = #t, 1, -1 do
+ new [index] = t[i]
+ index = index + 1
+ end
+ return new
+end
+
+--> copy from table2 to table1 overwriting values
+function DF.table.copy (t1, t2)
+ for key, value in pairs (t2) do
+ if (key ~= "__index") then
+ if (type (value) == "table") then
+ t1 [key] = t1 [key] or {}
+ DF.table.copy (t1 [key], t2 [key])
+ else
+ t1 [key] = value
+ end
+ end
+ end
+ return t1
+end
+
+--> copy values that does exist on table2 but not on table1
+function DF.table.deploy (t1, t2)
+ for key, value in pairs (t2) do
+ if (type (value) == "table") then
+ t1 [key] = t1 [key] or {}
+ DF.table.deploy (t1 [key], t2 [key])
+ elseif (t1 [key] == nil) then
+ t1 [key] = value
+ end
+ end
+ return t1
+end
+
+function DF.table.dump (t, s, deep)
+ s = s or ""
+ deep = deep or 0
+ local space = ""
+ for i = 1, deep do
+ space = space .. " "
+ end
+
+ for key, value in pairs (t) do
+ local tpe = _type (value)
+
+ if (type (key) == "function") then
+ key = "#function#"
+ elseif (type (key) == "table") then
+ key = "#table#"
+ end
+
+ if (type (key) ~= "string" and type (key) ~= "number") then
+ key = "unknown?"
+ end
+
+ if (tpe == "table") then
+ if (type (key) == "number") then
+ s = s .. space .. "[" .. key .. "] = |cFFa9ffa9 {|r\n"
+ else
+ s = s .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9 {|r\n"
+ end
+ s = s .. DF.table.dump (value, nil, deep+1)
+ s = s .. space .. "|cFFa9ffa9},|r\n"
+
+ elseif (tpe == "string") then
+ s = s .. space .. "[\"" .. key .. "\"] = \"|cFFfff1c1" .. value .. "|r\",\n"
+
+ elseif (tpe == "number") then
+ s = s .. space .. "[\"" .. key .. "\"] = |cFFffc1f4" .. value .. "|r,\n"
+
+ elseif (tpe == "function") then
+ s = s .. space .. "[\"" .. key .. "\"] = function()end,\n"
+
+ elseif (tpe == "boolean") then
+ s = s .. space .. "[\"" .. key .. "\"] = |cFF99d0ff" .. (value and "true" or "false") .. "|r,\n"
+ end
+ end
+
+ return s
+end
+
+DF.www_icons = {
+ texture = "feedback_sites",
+ wowi = {0, 0.7890625, 0, 37/128},
+ curse = {0, 0.7890625, 38/123, 79/128},
+ mmoc = {0, 0.7890625, 80/123, 123/128},
+}
+
+local symbol_1K, symbol_10K, symbol_1B
+if (GetLocale() == "koKR") then
+ symbol_1K, symbol_10K, symbol_1B = "천", "만", "억"
+elseif (GetLocale() == "zhCN") then
+ symbol_1K, symbol_10K, symbol_1B = "千", "万", "亿"
+elseif (GetLocale() == "zhTW") then
+ symbol_1K, symbol_10K, symbol_1B = "千", "萬", "億"
+end
+
+function DF:GetAsianNumberSymbols()
+ if (GetLocale() == "koKR") then
+ return "천", "만", "억"
+ elseif (GetLocale() == "zhCN") then
+ return "千", "万", "亿"
+ elseif (GetLocale() == "zhTW") then
+ return "千", "萬", "億"
+ else
+ --> return korean as default (if the language is western)
+ return "천", "만", "억"
+ end
+end
+
+if (symbol_1K) then
+ function DF.FormatNumber (numero)
+ if (numero > 99999999) then
+ return format ("%.2f", numero/100000000) .. symbol_1B
+ elseif (numero > 999999) then
+ return format ("%.2f", numero/10000) .. symbol_10K
+ elseif (numero > 99999) then
+ return floor (numero/10000) .. symbol_10K
+ elseif (numero > 9999) then
+ return format ("%.1f", (numero/10000)) .. symbol_10K
+ elseif (numero > 999) then
+ return format ("%.1f", (numero/1000)) .. symbol_1K
+ end
+ return format ("%.1f", numero)
+ end
+else
+ function DF.FormatNumber (numero)
+ if (numero > 999999999) then
+ return format ("%.2f", numero/1000000000) .. "B"
+ elseif (numero > 999999) then
+ return format ("%.2f", numero/1000000) .. "M"
+ elseif (numero > 99999) then
+ return floor (numero/1000) .. "K"
+ elseif (numero > 999) then
+ return format ("%.1f", (numero/1000)) .. "K"
+ end
+ return floor (numero)
+ end
+end
+
+function DF:CommaValue (value)
+ if (not value) then
+ return "0"
+ end
+
+ value = floor (value)
+
+ if (value == 0) then
+ return "0"
+ end
+
+ --source http://richard.warburton.it
+ local left, num, right = string_match (value, '^([^%d]*%d)(%d*)(.-)$')
+ return left .. (num:reverse():gsub ('(%d%d%d)','%1,'):reverse()) .. right
+end
+
+function DF:IntegerToTimer (value)
+ return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
+end
+
+function DF:Embed (target)
+ for k, v in pairs (embed_functions) do
+ target[v] = self[v]
+ end
+ self.embeds [target] = true
+ return target
+end
+
+function DF:RemoveRealmName (name)
+ return name:gsub (("%-.*"), "")
+end
+
+function DF:RemoveRealName (name)
+ return name:gsub (("%-.*"), "")
+end
+
+function DF:SetFontSize (fontString, ...)
+ local fonte, _, flags = fontString:GetFont()
+ fontString:SetFont (fonte, max (...), flags)
+end
+function DF:SetFontFace (fontString, fontface)
+ local font = SharedMedia:Fetch ("font", fontface, true)
+ if (font) then
+ fontface = font
+ end
+
+ local _, size, flags = fontString:GetFont()
+ fontString:SetFont (fontface, size, flags)
+end
+function DF:SetFontColor (fontString, r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ fontString:SetTextColor (r, g, b, a)
+end
+
+function DF:SetFontShadow (fontString, r, g, b, a, x, y)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ fontString:SetShadowColor (r, g, b, a)
+
+ local offSetX, offSetY = fontString:GetShadowOffset()
+ x = x or offSetX
+ y = y or offSetY
+
+ fontString:SetShadowOffset (x, y)
+end
+
+function DF:AddClassColorToText (text, class)
+ if (type (class) ~= "string") then
+ return DF:RemoveRealName (text)
+
+ elseif (class == "UNKNOW" or class == "PET") then
+ return DF:RemoveRealName (text)
+ end
+
+ local color = RAID_CLASS_COLORS [class]
+ if (color) then
+ text = "|c" .. color.colorStr .. DF:RemoveRealName (text) .. "|r"
+ else
+ return DF:RemoveRealName (text)
+ end
+
+ return text
+end
+
+function DF:GetFontSize (fontString)
+ local _, size = fontString:GetFont()
+ return size
+end
+function DF:GetFontFace (fontString)
+ local fontface = fontString:GetFont()
+ return fontface
+end
+
+local ValidOutlines = {
+ ["NONE"] = true,
+ ["MONOCHROME"] = true,
+ ["OUTLINE"] = true,
+ ["THICKOUTLINE"] = true,
+}
+function DF:SetFontOutline (fontString, outline)
+ local fonte, size = fontString:GetFont()
+ if (outline) then
+ if (ValidOutlines [outline]) then
+ outline = outline
+ elseif (_type (outline) == "boolean" and outline) then
+ outline = "OUTLINE"
+ elseif (outline == 1) then
+ outline = "OUTLINE"
+ elseif (outline == 2) then
+ outline = "THICKOUTLINE"
+ end
+ end
+
+ fontString:SetFont (fonte, size, outline)
+end
+
+function DF:Trim (s) --hello name conventions!
+ return DF:trim (s)
+end
+
+function DF:trim (s)
+ local from = s:match"^%s*()"
+ return from > #s and "" or s:match(".*%S", from)
+end
+
+function DF:TruncateText (fontString, maxWidth)
+ local text = fontString:GetText()
+
+ while (fontString:GetStringWidth() > maxWidth) do
+ text = strsub (text, 1, #text - 1)
+ fontString:SetText (text)
+ if (string.len (text) <= 1) then
+ break
+ end
+ end
+end
+
+function DF:Msg (msg)
+ print ("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg)
+end
+
+function DF:GetNpcIdFromGuid (guid)
+ local NpcId = select ( 6, strsplit ( "-", guid ) )
+ if (NpcId) then
+ return tonumber ( NpcId )
+ end
+ return 0
+end
+
+function DF.SortOrder1 (t1, t2)
+ return t1[1] > t2[1]
+end
+function DF.SortOrder2 (t1, t2)
+ return t1[2] > t2[2]
+end
+function DF.SortOrder3 (t1, t2)
+ return t1[3] > t2[3]
+end
+function DF.SortOrder1R (t1, t2)
+ return t1[1] < t2[1]
+end
+function DF.SortOrder2R (t1, t2)
+ return t1[2] < t2[2]
+end
+function DF.SortOrder3R (t1, t2)
+ return t1[3] < t2[3]
+end
+
+local onFinish = function (self)
+ if (self.showWhenDone) then
+ self.frame:SetAlpha (1)
+ else
+ self.frame:SetAlpha (0)
+ self.frame:Hide()
+ end
+
+ if (self.onFinishFunc) then
+ self:onFinishFunc (self.frame)
+ end
+end
+
+local stop = function (self)
+ local FlashAnimation = self.FlashAnimation
+ FlashAnimation:Stop()
+end
+
+local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
+
+ local FlashAnimation = self.FlashAnimation
+
+ local fadeIn = FlashAnimation.fadeIn
+ local fadeOut = FlashAnimation.fadeOut
+
+ fadeIn:Stop()
+ fadeOut:Stop()
+
+ fadeIn:SetDuration (fadeInTime or 1)
+ fadeIn:SetEndDelay (flashInHoldTime or 0)
+
+ fadeOut:SetDuration (fadeOutTime or 1)
+ fadeOut:SetEndDelay (flashOutHoldTime or 0)
+
+ FlashAnimation.duration = flashDuration
+ FlashAnimation.loopTime = FlashAnimation:GetDuration()
+ FlashAnimation.finishAt = GetTime() + flashDuration
+ FlashAnimation.showWhenDone = showWhenDone
+
+ FlashAnimation:SetLooping (loopType or "REPEAT")
+
+ self:Show()
+ self:SetAlpha (0)
+ FlashAnimation:Play()
+end
+
+function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
+ local FlashAnimation = frame:CreateAnimationGroup()
+
+ FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
+ FlashAnimation.fadeOut:SetOrder (1)
+ FlashAnimation.fadeOut:SetFromAlpha (0)
+ FlashAnimation.fadeOut:SetToAlpha (1)
+
+ FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
+ FlashAnimation.fadeIn:SetOrder (2)
+ FlashAnimation.fadeIn:SetFromAlpha (1)
+ FlashAnimation.fadeIn:SetToAlpha (0)
+
+ frame.FlashAnimation = FlashAnimation
+ FlashAnimation.frame = frame
+ FlashAnimation.onFinishFunc = onFinishFunc
+
+ FlashAnimation:SetScript ("OnLoop", onLoopFunc)
+ FlashAnimation:SetScript ("OnFinished", onFinish)
+
+ frame.Flash = flash
+ frame.Stop = stop
+end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> points
+
+ function DF:CheckPoints (v1, v2, v3, v4, v5, object)
+
+ if (not v1 and not v2) then
+ return "topleft", object.widget:GetParent(), "topleft", 0, 0
+ end
+
+ if (_type (v1) == "string") then
+ local frameGlobal = _G [v1]
+ if (frameGlobal and type (frameGlobal) == "table" and frameGlobal.GetObjectType) then
+ return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
+ end
+
+ elseif (_type (v2) == "string") then
+ local frameGlobal = _G [v2]
+ if (frameGlobal and type (frameGlobal) == "table" and frameGlobal.GetObjectType) then
+ return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
+ end
+ end
+
+ if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
+ if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
+ v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
+ end
+
+ elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
+ v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
+
+ elseif (_type (v1) == "number") then --> :setpoint (x, y)
+ v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
+
+ elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
+ v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
+
+ end
+
+ if (not v2) then
+ v2 = object.widget:GetParent()
+ elseif (v2.dframework) then
+ v2 = v2.widget
+ end
+
+ return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
+ end
+
+ local anchoring_functions = {
+ function (frame, anchorTo, offSetX, offSetY) --> 1 TOP LEFT
+ frame:ClearAllPoints()
+ frame:SetPoint ("bottomleft", anchorTo, "topleft", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 2 LEFT
+ frame:ClearAllPoints()
+ frame:SetPoint ("right", anchorTo, "left", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 3 BOTTOM LEFT
+ frame:ClearAllPoints()
+ frame:SetPoint ("topleft", anchorTo, "bottomleft", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 4 BOTTOM
+ frame:ClearAllPoints()
+ frame:SetPoint ("top", anchorTo, "bottom", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 5 BOTTOM RIGHT
+ frame:ClearAllPoints()
+ frame:SetPoint ("topright", anchorTo, "bottomright", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 6 RIGHT
+ frame:ClearAllPoints()
+ frame:SetPoint ("left", anchorTo, "right", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 7 TOP RIGHT
+ frame:ClearAllPoints()
+ frame:SetPoint ("bottomright", anchorTo, "topright", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 8 TOP
+ frame:ClearAllPoints()
+ frame:SetPoint ("bottom", anchorTo, "top", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 9 CENTER
+ frame:ClearAllPoints()
+ frame:SetPoint ("center", anchorTo, "center", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 10
+ frame:ClearAllPoints()
+ frame:SetPoint ("left", anchorTo, "left", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 11
+ frame:ClearAllPoints()
+ frame:SetPoint ("right", anchorTo, "right", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 12
+ frame:ClearAllPoints()
+ frame:SetPoint ("top", anchorTo, "top", offSetX, offSetY)
+ end,
+
+ function (frame, anchorTo, offSetX, offSetY) --> 13
+ frame:ClearAllPoints()
+ frame:SetPoint ("bottom", anchorTo, "bottom", offSetX, offSetY)
+ end
+ }
+
+ function DF:SetAnchor (widget, config, anchorTo)
+ anchorTo = anchorTo or widget:GetParent()
+ anchoring_functions [config.side] (widget, anchorTo, config.x, config.y)
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> colors
+
+ function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
+ assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
+ assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
+
+ if (_type (_colortable) == "table") then
+ if (_colortable[1] and _colortable[2] and _colortable[3]) then
+ _colortable[4] = _colortable[4] or 1
+ DF.alias_text_colors [_colorname] = _colortable
+ else
+ error ("invalid color table.")
+ end
+ elseif (_colortable and _green and _blue) then
+ _alpha = _alpha or 1
+ DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
+ else
+ error ("invalid parameter.")
+ end
+
+ return true
+ end
+
+ local colorTableMixin = {
+ GetColor = function (self)
+ return self.r, self.g, self.b, self.a
+ end,
+
+ SetColor = function (self, r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self.r = r or self.r
+ self.g = g or self.g
+ self.b = b or self.b
+ self.a = a or self.a
+ end,
+
+ IsColorTable = true,
+ }
+
+ function DF:CreateColorTable (r, g, b, a)
+ local t = {
+ r = r or 1,
+ g = g or 1,
+ b = b or 1,
+ a = a or 1,
+ }
+ DF:Mixin (t, colorTableMixin)
+ return t
+ end
+
+ function DF:IsHtmlColor (color)
+ return DF.alias_text_colors [color]
+ end
+
+ local tn = tonumber
+ function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
+ if (_type (_arg1) == "table") then
+ if (_arg1.IsColorTable) then
+ return _arg1:GetColor()
+
+ elseif (not _arg1[1] and _arg1.r) then
+ _arg1, _arg2, _arg3, _arg4 = _arg1.r, _arg1.g, _arg1.b, _arg1.a
+
+ else
+ _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
+ end
+
+ elseif (_type (_arg1) == "string") then
+
+ if (string.find (_arg1, "#")) then
+ _arg1 = _arg1:gsub ("#","")
+ if (string.len (_arg1) == 8) then --alpha
+ _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, tn ("0x" .. _arg1:sub (7, 8))/255, tn ("0x" .. _arg1:sub (1, 2))/255
+ else
+ _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (1, 2))/255, tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, 1
+ end
+
+ else
+ local color = DF.alias_text_colors [_arg1]
+ if (color) then
+ _arg1, _arg2, _arg3, _arg4 = _unpack (color)
+ else
+ _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
+ end
+ end
+ end
+
+ if (not _arg1) then
+ _arg1 = 1
+ end
+ if (not _arg2) then
+ _arg2 = 1
+ end
+ if (not _arg3) then
+ _arg3 = 1
+ end
+ if (not _arg4) then
+ _arg4 = 1
+ end
+
+ return _arg1, _arg2, _arg3, _arg4
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> menus
+
+ local disable_on_combat = {}
+
+ function DF:BuildMenu (parent, menu, x_offset, y_offset, height, use_two_points, text_template, dropdown_template, switch_template, switch_is_box, slider_template, button_template, value_change_hook)
+
+ if (not parent.widget_list) then
+ DF:SetAsOptionsPanel (parent)
+ end
+
+ local cur_x = x_offset
+ local cur_y = y_offset
+ local max_x = 0
+ local line_widgets_created = 0 --how many widgets has been created on this line loop pass
+
+ height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
+ height = height*-1
+
+ for index, widget_table in ipairs (menu) do
+
+ local widget_created
+
+ if (widget_table.type == "blank" or widget_table.type == "space") then
+ -- do nothing
+
+ elseif (widget_table.type == "label" or widget_table.type == "text") then
+ local label = DF:CreateLabel (parent, widget_table.get() or widget_table.text, widget_table.text_template or text_template or widget_table.size, widget_table.color, widget_table.font, nil, "$parentWidget" .. index, "overlay")
+ label._get = widget_table.get
+ label.widget_type = "label"
+ label:SetPoint (cur_x, cur_y)
+ tinsert (parent.widget_list, label)
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "select" or widget_table.type == "dropdown") then
+ local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template)
+ dropdown.tooltip = widget_table.desc
+ dropdown._get = widget_table.get
+ dropdown.widget_type = "select"
+ local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+ dropdown:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ --> global callback
+ if (value_change_hook) then
+ dropdown:SetHook ("OnOptionSelected", value_change_hook)
+ end
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ dropdown:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local size = label.widget:GetStringWidth() + 140 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, dropdown)
+ widget_created = dropdown
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
+ local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template)
+ switch.tooltip = widget_table.desc
+ switch._get = widget_table.get
+ switch.widget_type = "toggle"
+ switch.OnSwitch = widget_table.set
+
+ if (switch_is_box) then
+ switch:SetAsCheckBox()
+ end
+
+ if (value_change_hook) then
+ switch:SetHook ("OnSwitch", value_change_hook)
+ end
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ switch:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+ switch:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 60 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, switch)
+ widget_created = switch
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "range" or widget_table.type == "slider") then
+ local is_decimanls = widget_table.usedecimals
+ local slider = DF:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls, nil, nil, slider_template)
+ slider.tooltip = widget_table.desc
+ slider._get = widget_table.get
+ slider.widget_type = "range"
+ slider:SetHook ("OnValueChange", widget_table.set)
+
+ if (widget_table.thumbscale) then
+ slider:SetThumbSize (slider.thumb:GetWidth()*widget_table.thumbscale, nil)
+ else
+ slider:SetThumbSize (slider.thumb:GetWidth()*1.3, nil)
+ end
+
+ if (value_change_hook) then
+ slider:SetHook ("OnValueChange", value_change_hook)
+ end
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ slider:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+ slider:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 140 + 6
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, slider)
+ widget_created = slider
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "color" or widget_table.type == "color") then
+ local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template)
+ colorpick.tooltip = widget_table.desc
+ colorpick._get = widget_table.get
+ colorpick.widget_type = "color"
+
+ local default_value, g, b, a = widget_table.get()
+ if (type (default_value) == "table") then
+ colorpick:SetColor (unpack (default_value))
+ else
+ colorpick:SetColor (default_value, g, b, a)
+ end
+
+ if (value_change_hook) then
+ colorpick:SetHook ("OnColorChanged", value_change_hook)
+ end
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ colorpick:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+ colorpick:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 60 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, colorpick)
+ widget_created = colorpick
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "execute" or widget_table.type == "button") then
+
+ local button = DF:NewButton (parent, nil, "$parentWidget" .. index, nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name, nil, button_template, text_template)
+ if (not button_template) then
+ button:InstallCustomTexture()
+ end
+
+ button:SetPoint (cur_x, cur_y)
+ button.tooltip = widget_table.desc
+ button.widget_type = "execute"
+
+ --> execute doesn't trigger global callback
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ button:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local size = button:GetWidth() + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, button)
+ widget_created = button
+ line_widgets_created = line_widgets_created + 1
+
+ elseif (widget_table.type == "textentry") then
+ local textentry = DF:CreateTextEntry (parent, widget_table.func, 120, 18, nil, "$parentWidget" .. index, nil, button_template)
+ textentry.tooltip = widget_table.desc
+ textentry.text = widget_table.get()
+ textentry._get = widget_table.get
+ textentry.widget_type = "textentry"
+ textentry:SetHook ("OnEnterPressed", widget_table.set)
+ textentry:SetHook ("OnEditFocusLost", widget_table.set)
+
+ local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+ textentry:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ --> text entry doesn't trigger global callback
+
+ --> hook list
+ if (widget_table.hooks) then
+ for hookName, hookFunc in pairs (widget_table.hooks) do
+ textentry:SetHook (hookName, hookFunc)
+ end
+ end
+
+ local size = label.widget:GetStringWidth() + 60 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ tinsert (parent.widget_list, textentry)
+ widget_created = textentry
+ line_widgets_created = line_widgets_created + 1
+
+ end
+
+ if (widget_table.nocombat) then
+ tinsert (disable_on_combat, widget_created)
+ end
+
+ if (widget_table.spacement) then
+ cur_y = cur_y - 30
+ else
+ cur_y = cur_y - 20
+ end
+
+ if (widget_table.type == "breakline" or cur_y < height) then
+ cur_y = y_offset
+ cur_x = cur_x + max_x + 30
+ line_widgets_created = 0
+ max_x = 0
+ end
+
+ end
+
+ DF.RefreshUnsafeOptionsWidgets()
+
+ end
+
+ local lock_notsafe_widgets = function()
+ for _, widget in ipairs (disable_on_combat) do
+ widget:Disable()
+ end
+ end
+ local unlock_notsafe_widgets = function()
+ for _, widget in ipairs (disable_on_combat) do
+ widget:Enable()
+ end
+ end
+ function DF.RefreshUnsafeOptionsWidgets()
+ if (DF.PlayerHasCombatFlag) then
+ lock_notsafe_widgets()
+ else
+ unlock_notsafe_widgets()
+ end
+ end
+ DF.PlayerHasCombatFlag = false
+ local ProtectCombatFrame = CreateFrame ("frame")
+ ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_ENABLED")
+ ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_DISABLED")
+ ProtectCombatFrame:RegisterEvent ("PLAYER_ENTERING_WORLD")
+ ProtectCombatFrame:SetScript ("OnEvent", function (self, event)
+ if (event == "PLAYER_ENTERING_WORLD") then
+ if (InCombatLockdown()) then
+ DF.PlayerHasCombatFlag = true
+ else
+ DF.PlayerHasCombatFlag = false
+ end
+ DF.RefreshUnsafeOptionsWidgets()
+
+ elseif (event == "PLAYER_REGEN_ENABLED") then
+ DF.PlayerHasCombatFlag = false
+ DF.RefreshUnsafeOptionsWidgets()
+
+ elseif (event == "PLAYER_REGEN_DISABLED") then
+ DF.PlayerHasCombatFlag = true
+ DF.RefreshUnsafeOptionsWidgets()
+
+ end
+ end)
+
+ function DF:CreateInCombatTexture (frame)
+ if (DF.debug and not frame) then
+ error ("Details! Framework: CreateInCombatTexture invalid frame on parameter 1.")
+ end
+
+ local in_combat_background = DF:CreateImage (frame)
+ in_combat_background:SetColorTexture (.6, 0, 0, .1)
+ in_combat_background:Hide()
+
+ local in_combat_label = Plater:CreateLabel (frame, "you are in combat", 24, "silver")
+ in_combat_label:SetPoint ("right", in_combat_background, "right", -10, 0)
+ in_combat_label:Hide()
+
+ frame:RegisterEvent ("PLAYER_REGEN_DISABLED")
+ frame:RegisterEvent ("PLAYER_REGEN_ENABLED")
+ frame:SetScript ("OnEvent", function (self, event)
+ if (event == "PLAYER_REGEN_DISABLED") then
+ in_combat_background:Show()
+ in_combat_label:Show()
+ elseif (event == "PLAYER_REGEN_ENABLED") then
+ in_combat_background:Hide()
+ in_combat_label:Hide()
+ end
+ end)
+
+ return in_combat_background
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> tutorials
+
+ function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
+
+ local TutorialAlertFrame = _G.DetailsFrameworkAlertFrame
+
+ if (not TutorialAlertFrame) then
+
+ TutorialAlertFrame = CreateFrame ("frame", "DetailsFrameworkAlertFrame", UIParent, "MicroButtonAlertTemplate")
+ TutorialAlertFrame.isFirst = true
+ TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
+ TutorialAlertFrame:SetFrameStrata ("TOOLTIP")
+ TutorialAlertFrame:Hide()
+
+ TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
+ if (self.clickfunc and type (self.clickfunc) == "function") then
+ self.clickfunc()
+ end
+ self:Hide()
+ end)
+ TutorialAlertFrame:Hide()
+ end
+
+ --
+ TutorialAlertFrame.label = type (maintext) == "string" and maintext or type (desctext) == "string" and desctext or ""
+ MicroButtonAlert_SetText (TutorialAlertFrame, alert.label)
+ --
+
+ TutorialAlertFrame.clickfunc = clickfunc
+ TutorialAlertFrame:Show()
+ end
+
+ local refresh_options = function (self)
+ for _, widget in ipairs (self.widget_list) do
+ if (widget._get) then
+ if (widget.widget_type == "label") then
+ if (widget._get()) then
+ widget:SetText (widget._get())
+ end
+ elseif (widget.widget_type == "select") then
+ widget:Select (widget._get())
+ elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
+ widget:SetValue (widget._get())
+ elseif (widget.widget_type == "textentry") then
+ widget:SetText (widget._get())
+ elseif (widget.widget_type == "color") then
+ local default_value, g, b, a = widget._get()
+ if (type (default_value) == "table") then
+ widget:SetColor (unpack (default_value))
+ else
+ widget:SetColor (default_value, g, b, a)
+ end
+ end
+ end
+ end
+ end
+
+ function DF:SetAsOptionsPanel (frame)
+ frame.RefreshOptions = refresh_options
+ frame.widget_list = {}
+ end
+
+ function DF:CreateOptionsFrame (name, title, template)
+
+ template = template or 1
+
+ if (template == 2) then
+ local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
+ tinsert (UISpecialFrames, name)
+ options_frame:SetSize (500, 200)
+ options_frame.RefreshOptions = refresh_options
+ options_frame.widget_list = {}
+
+ options_frame:SetScript ("OnMouseDown", function(self, button)
+ if (button == "RightButton") then
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ return options_frame:Hide()
+ elseif (button == "LeftButton" and not self.moving) then
+ self.moving = true
+ self:StartMoving()
+ end
+ end)
+ options_frame:SetScript ("OnMouseUp", function(self)
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ end)
+
+ options_frame:SetMovable (true)
+ options_frame:EnableMouse (true)
+ options_frame:SetFrameStrata ("DIALOG")
+ options_frame:SetToplevel (true)
+
+ options_frame:Hide()
+
+ options_frame:SetPoint ("center", UIParent, "center")
+ options_frame.TitleText:SetText (title)
+ options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
+
+ return options_frame
+
+ elseif (template == 1) then
+
+ local options_frame = CreateFrame ("frame", name, UIParent)
+ tinsert (UISpecialFrames, name)
+ options_frame:SetSize (500, 200)
+ options_frame.RefreshOptions = refresh_options
+ options_frame.widget_list = {}
+
+ options_frame:SetScript ("OnMouseDown", function(self, button)
+ if (button == "RightButton") then
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ return options_frame:Hide()
+ elseif (button == "LeftButton" and not self.moving) then
+ self.moving = true
+ self:StartMoving()
+ end
+ end)
+ options_frame:SetScript ("OnMouseUp", function(self)
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ end)
+
+ options_frame:SetMovable (true)
+ options_frame:EnableMouse (true)
+ options_frame:SetFrameStrata ("DIALOG")
+ options_frame:SetToplevel (true)
+
+ options_frame:Hide()
+
+ options_frame:SetPoint ("center", UIParent, "center")
+
+ options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
+ edgeFile = DF.folder .. "border_2", edgeSize = 32,
+ insets = {left = 1, right = 1, top = 1, bottom = 1}})
+ options_frame:SetBackdropColor (0, 0, 0, .7)
+
+ local texturetitle = options_frame:CreateTexture (nil, "artwork")
+ texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
+ texturetitle:SetTexCoord (0, 1, 0, 1)
+ texturetitle:SetVertexColor (1, 1, 1, 1)
+ texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
+ texturetitle:SetWidth (36)
+ texturetitle:SetHeight (36)
+
+ local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
+ title:SetPoint ("left", texturetitle, "right", 2, -1)
+ DF:SetFontOutline (title, true)
+
+ local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
+ c:SetWidth (32)
+ c:SetHeight (32)
+ c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
+ c:SetFrameLevel (options_frame:GetFrameLevel()+1)
+
+ return options_frame
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> templates
+
+--fonts
+
+DF.font_templates = DF.font_templates or {}
+
+--> detect which language is the client and select the font accordingly
+local clientLanguage = GetLocale()
+if (clientLanguage == "enGB") then
+ clientLanguage = "enUS"
+end
+
+DF.ClientLanguage = clientLanguage
+
+--> returns which region the language the client is running, return "western", "russia" or "asia"
+function DF:GetClientRegion()
+ if (clientLanguage == "zhCN" or clientLanguage == "koKR" or clientLanguage == "zhTW") then
+ return "asia"
+ elseif (clientLanguage == "ruRU") then
+ return "russia"
+ else
+ return "western"
+ end
+end
+
+--> return the best font to use for the client language
+function DF:GetBestFontForLanguage (language, western, cyrillic, china, korean, taiwan)
+ if (not language) then
+ language = DF.ClientLanguage
+ end
+
+ if (language == "enUS" or language == "deDE" or language == "esES" or language == "esMX" or language == "frFR" or language == "itIT" or language == "ptBR") then
+ return western or "Accidental Presidency"
+
+ elseif (language == "ruRU") then
+ return cyrillic or "Arial Narrow"
+
+ elseif (language == "zhCN") then
+ return china or "AR CrystalzcuheiGBK Demibold"
+
+ elseif (language == "koKR") then
+ return korean or "2002"
+
+ elseif (language == "zhTW") then
+ return taiwan or "AR CrystalzcuheiGBK Demibold"
+
+ end
+end
+
+--DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
+--DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
+DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = DF:GetBestFontForLanguage()}
+DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = DF:GetBestFontForLanguage()}
+
+-- dropdowns
+
+DF.dropdown_templates = DF.dropdown_templates or {}
+DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdropcolor = {1, 1, 1, .5},
+ backdropbordercolor = {0, 0, 0, 1},
+ onentercolor = {1, 1, 1, .5},
+ onenterbordercolor = {1, 1, 1, 1},
+}
+
+-- switches
+
+DF.switch_templates = DF.switch_templates or {}
+DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdropcolor = {1, 1, 1, .5},
+ backdropbordercolor = {0, 0, 0, 1},
+ width = 18,
+ height = 18,
+ enabled_backdropcolor = {1, 1, 1, .5},
+ disabled_backdropcolor = {1, 1, 1, .2},
+ onenterbordercolor = {1, 1, 1, 1},
+}
+DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdropcolor = {1, 1, 1, .5},
+ backdropbordercolor = {0, 0, 0, 1},
+ width = 18,
+ height = 18,
+ enabled_backdropcolor = {1, 1, 1, .5},
+ disabled_backdropcolor = {1, 1, 1, .5},
+ onenterbordercolor = {1, 1, 1, 1},
+}
+
+-- buttons
+
+DF.button_templates = DF.button_templates or {}
+DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdropcolor = {1, 1, 1, .5},
+ backdropbordercolor = {0, 0, 0, 1},
+}
+
+-- sliders
+
+DF.slider_templates = DF.slider_templates or {}
+DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdropcolor = {1, 1, 1, .5},
+ backdropbordercolor = {0, 0, 0, 1},
+ onentercolor = {1, 1, 1, .5},
+ onenterbordercolor = {1, 1, 1, 1},
+ thumbtexture = [[Interface\Tooltips\UI-Tooltip-Background]],
+ thumbwidth = 16,
+ thumbheight = 14,
+ thumbcolor = {0, 0, 0, 0.5},
+}
+
+function DF:InstallTemplate (widget_type, template_name, template, parent_name)
+
+ local newTemplate = {}
+
+ --if has a parent, just copy the parent to the new template
+ if (parent_name and type (parent_name) == "string") then
+ local parentTemplate = DF:GetTemplate (widget_type, parent_name)
+ if (parentTemplate) then
+ DF.table.copy (newTemplate, parentTemplate)
+ end
+ end
+
+ --copy the template passed into the new template
+ DF.table.copy (newTemplate, template)
+
+ widget_type = string.lower (widget_type)
+
+ local template_table
+ if (widget_type == "font") then
+ template_table = DF.font_templates
+
+ local font = template.font
+ if (font) then
+ --> fonts passed into the template has default to western
+ --> the framework will get the game client language and change the font if needed
+ font = DF:GetBestFontForLanguage (nil, font)
+ end
+
+ elseif (widget_type == "dropdown") then
+ template_table = DF.dropdown_templates
+ elseif (widget_type == "button") then
+ template_table = DF.button_templates
+ elseif (widget_type == "switch") then
+ template_table = DF.switch_templates
+ elseif (widget_type == "slider") then
+ template_table = DF.slider_templates
+ end
+
+ template_table [template_name] = newTemplate
+
+ return newTemplate
+end
+
+function DF:GetTemplate (widget_type, template_name)
+ widget_type = string.lower (widget_type)
+
+ local template_table
+ if (widget_type == "font") then
+ template_table = DF.font_templates
+ elseif (widget_type == "dropdown") then
+ template_table = DF.dropdown_templates
+ elseif (widget_type == "button") then
+ template_table = DF.button_templates
+ elseif (widget_type == "switch") then
+ template_table = DF.switch_templates
+ elseif (widget_type == "slider") then
+ template_table = DF.slider_templates
+ end
+ return template_table [template_name]
+end
+
+function DF.GetParentName (frame)
+ local parentName = frame:GetName()
+ if (not parentName) then
+ error ("Details! FrameWork: called $parent but parent was no name.", 2)
+ end
+ return parentName
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> widget scripts and hooks
+
+function DF:RunHooksForWidget (event, ...)
+ local hooks = self.HookList [event]
+
+ if (not hooks) then
+ print (self.widget:GetName(), "no hooks for", event)
+ return
+ end
+
+ for i, func in ipairs (hooks) do
+ local success, canInterrupt = pcall (func, ...)
+ if (not success) then
+ error ("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
+ elseif (canInterrupt) then
+ return true
+ end
+ end
+end
+
+function DF:SetHook (hookType, func)
+ if (self.HookList [hookType]) then
+ if (type (func) == "function") then
+ local isRemoval = false
+ for i = #self.HookList [hookType], 1, -1 do
+ if (self.HookList [hookType] [i] == func) then
+ tremove (self.HookList [hookType], i)
+ isRemoval = true
+ break
+ end
+ end
+ if (not isRemoval) then
+ tinsert (self.HookList [hookType], func)
+ end
+ else
+ if (DF.debug) then
+ error ("Details! Framework: invalid function for widget " .. self.WidgetType .. ".")
+ end
+ end
+ else
+ if (DF.debug) then
+ error ("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.")
+ end
+ end
+end
+
+function DF:Error (errortext)
+ print ("|cFFFF2222Details! Framework Error|r:", errortext, self.GetName and self:GetName(), self.WidgetType, debugstack (2, 3, 0))
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> members
+
+DF.GlobalWidgetControlNames = {
+ textentry = "DF_TextEntryMetaFunctions",
+ button = "DF_ButtonMetaFunctions",
+ panel = "DF_PanelMetaFunctions",
+ dropdown = "DF_DropdownMetaFunctions",
+ label = "DF_LabelMetaFunctions",
+ normal_bar = "DF_NormalBarMetaFunctions",
+ image = "DF_ImageMetaFunctions",
+ slider = "DF_SliderMetaFunctions",
+ split_bar = "DF_SplitBarMetaFunctions",
+ aura_tracker = "DF_AuraTracker",
+}
+
+function DF:AddMemberForWidget (widgetName, memberType, memberName, func)
+ if (DF.GlobalWidgetControlNames [widgetName]) then
+ if (type (memberName) == "string" and (memberType == "SET" or memberType == "GET")) then
+ if (func) then
+ local widgetControlObject = _G [DF.GlobalWidgetControlNames [widgetName]]
+
+ if (memberType == "SET") then
+ widgetControlObject ["SetMembers"] [memberName] = func
+ elseif (memberType == "GET") then
+ widgetControlObject ["GetMembers"] [memberName] = func
+ end
+ else
+ if (DF.debug) then
+ error ("Details! Framework: AddMemberForWidget invalid function.")
+ end
+ end
+ else
+ if (DF.debug) then
+ error ("Details! Framework: AddMemberForWidget unknown memberName or memberType.")
+ end
+ end
+ else
+ if (DF.debug) then
+ error ("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".")
+ end
+ end
+end
+
+-----------------------------
+
+function DF:OpenInterfaceProfile()
+ InterfaceOptionsFrame_OpenToCategory (self.__name)
+ InterfaceOptionsFrame_OpenToCategory (self.__name)
+ for i = 1, 100 do
+ local button = _G ["InterfaceOptionsFrameAddOnsButton" .. i]
+ if (button) then
+ local text = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Text"]
+ if (text) then
+ text = text:GetText()
+ if (text == self.__name) then
+ local toggle = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Toggle"]
+ if (toggle) then
+ if (toggle:GetNormalTexture():GetTexture():find ("PlusButton")) then
+ --is minimized, need expand
+ toggle:Click()
+ _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
+ elseif (toggle:GetNormalTexture():GetTexture():find ("MinusButton")) then
+ --isn't minimized
+ _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
+ end
+ end
+ break
+ end
+ end
+ else
+ self:Msg ("Couldn't not find the profile panel.")
+ break
+ end
+ end
+end
+
+-----------------------------
+--safe copy from blizz api
+function DF:Mixin (object, ...)
+ for i = 1, select("#", ...) do
+ local mixin = select(i, ...);
+ for k, v in pairs(mixin) do
+ object[k] = v;
+ end
+ end
+
+ return object;
+end
+
+-----------------------------
+--> animations
+
+function DF:CreateAnimationHub (parent, onPlay, onFinished)
+ local newAnimation = parent:CreateAnimationGroup()
+ newAnimation:SetScript ("OnPlay", onPlay)
+ newAnimation:SetScript ("OnFinished", onFinished)
+ newAnimation:SetScript ("OnStop", onFinished)
+ newAnimation.NextAnimation = 1
+ return newAnimation
+end
+
+function DF:CreateAnimation (animation, type, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+ local anim = animation:CreateAnimation (type)
+
+ anim:SetOrder (order or animation.NextAnimation)
+ anim:SetDuration (duration)
+
+ type = string.upper (type)
+
+ if (type == "ALPHA") then
+ anim:SetFromAlpha (arg1)
+ anim:SetToAlpha (arg2)
+
+ elseif (type == "SCALE") then
+ anim:SetFromScale (arg1, arg2)
+ anim:SetToScale (arg3, arg4)
+ anim:SetOrigin (arg5 or "center", arg6 or 0, arg7 or 0) --point, x, y
+
+ elseif (type == "ROTATION") then
+ anim:SetDegrees (arg1) --degree
+ anim:SetOrigin (arg2 or "center", arg3 or 0, arg4 or 0) --point, x, y
+
+ elseif (type == "TRANSLATION") then
+ anim:SetOffset (arg1, arg2)
+
+ end
+
+ animation.NextAnimation = animation.NextAnimation + 1
+ return anim
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> frame shakes
+
+--> frame shakes rely on OnUpdate scripts, we are using a built-in OnUpdate so is guarantee it'll run
+local FrameshakeUpdateFrame = DetailsFrameworkFrameshakeControl or CreateFrame ("frame", "DetailsFrameworkFrameshakeControl", UIParent)
+--> store the frame which has frame shakes registered
+FrameshakeUpdateFrame.RegisteredFrames = FrameshakeUpdateFrame.RegisteredFrames or {}
+
+FrameshakeUpdateFrame.RegisterFrame = function (newFrame)
+ --> add the frame into the registered frames to update
+ DF.table.addunique (FrameshakeUpdateFrame.RegisteredFrames, newFrame)
+end
+
+--forward declared
+local frameshake_do_update
+
+FrameshakeUpdateFrame:SetScript ("OnUpdate", function (self, deltaTime)
+ for i = 1, #FrameshakeUpdateFrame.RegisteredFrames do
+ local parent = FrameshakeUpdateFrame.RegisteredFrames [i]
+ --> check if there's a shake running
+ if (parent.__frameshakes.enabled > 0) then
+ --update all shakes for this frame
+ for i = 1, #parent.__frameshakes do
+ local shakeObject = parent.__frameshakes [i]
+ if (shakeObject.IsPlaying) then
+ frameshake_do_update (parent, shakeObject, deltaTime)
+ end
+ end
+ end
+ end
+end)
+
+
+local frameshake_shake_finished = function (parent, shakeObject)
+ if (shakeObject.IsPlaying) then
+ shakeObject.IsPlaying = false
+ shakeObject.TimeLeft = 0
+ shakeObject.IsFadingOut = false
+ shakeObject.IsFadingIn = false
+
+ --> update the amount of shake running on this frame
+ parent.__frameshakes.enabled = parent.__frameshakes.enabled - 1
+
+ --> restore the default anchors, in case where deltaTime was too small that didn't triggered an update
+ for i = 1, #shakeObject.Anchors do
+ local anchor = shakeObject.Anchors [i]
+
+ --> automatic anchoring and reanching needs to the reviwed in the future
+ if (#anchor == 1) then
+ local anchorTo = unpack (anchor)
+ parent:ClearAllPoints()
+ parent:SetPoint (anchorTo)
+
+ elseif (#anchor == 2) then
+ local anchorTo, point1 = unpack (anchor)
+ parent:ClearAllPoints()
+ parent:SetPoint (anchorTo, point1)
+
+ elseif (#anchor == 3) then
+ local anchorTo, point1, point2 = unpack (anchor)
+ parent:SetPoint (anchorTo, point1, point2)
+
+ elseif (#anchor == 5) then
+ local anchorName1, anchorTo, anchorName2, point1, point2 = unpack (anchor)
+ parent:SetPoint (anchorName1, anchorTo, anchorName2, point1, point2)
+ end
+ end
+ end
+end
+
+--already declared above the update function
+frameshake_do_update = function (parent, shakeObject, deltaTime)
+
+ --> check delta time
+ deltaTime = deltaTime or 0
+
+ --> update time left
+ shakeObject.TimeLeft = max (shakeObject.TimeLeft - deltaTime, 0)
+
+ if (shakeObject.TimeLeft > 0) then
+ --> update fade in and out
+ if (shakeObject.IsFadingIn) then
+ shakeObject.IsFadingInTime = shakeObject.IsFadingInTime + deltaTime
+ end
+ if (shakeObject.IsFadingOut) then
+ shakeObject.IsFadingOutTime = shakeObject.IsFadingOutTime + deltaTime
+ end
+
+ --> check if can disable fade in
+ if (shakeObject.IsFadingIn and shakeObject.IsFadingInTime > shakeObject.FadeInTime) then
+ shakeObject.IsFadingIn = false
+ end
+
+ --> check if can enable fade out
+ if (not shakeObject.IsFadingOut and shakeObject.TimeLeft < shakeObject.FadeOutTime) then
+ shakeObject.IsFadingOut = true
+ shakeObject.IsFadingOutTime = shakeObject.FadeOutTime - shakeObject.TimeLeft
+ end
+
+ --> update position
+ local scaleShake = min (shakeObject.IsFadingIn and (shakeObject.IsFadingInTime / shakeObject.FadeInTime) or 1, shakeObject.IsFadingOut and (1 - shakeObject.IsFadingOutTime / shakeObject.FadeOutTime) or 1)
+
+ if (scaleShake > 0) then
+
+ --> delate the time by the frequency on both X and Y offsets
+ shakeObject.XSineOffset = shakeObject.XSineOffset + (deltaTime * shakeObject.Frequency)
+ shakeObject.YSineOffset = shakeObject.YSineOffset + (deltaTime * shakeObject.Frequency)
+
+ --> calc the new position
+ local newX, newY
+ if (shakeObject.AbsoluteSineX) then
+ --absoluting only the sine wave, passing a negative scale will reverse the absolute direction
+ newX = shakeObject.Amplitude * abs (math.sin (shakeObject.XSineOffset)) * scaleShake * shakeObject.ScaleX
+ else
+ newX = shakeObject.Amplitude * math.sin (shakeObject.XSineOffset) * scaleShake * shakeObject.ScaleX
+ end
+
+ if (shakeObject.AbsoluteSineY) then
+ newY = shakeObject.Amplitude * abs (math.sin (shakeObject.YSineOffset)) * scaleShake * shakeObject.ScaleY
+ else
+ newY = shakeObject.Amplitude * math.sin (shakeObject.YSineOffset) * scaleShake * shakeObject.ScaleY
+ end
+
+ --> apply the offset to the frame anchors
+ for i = 1, #shakeObject.Anchors do
+ local anchor = shakeObject.Anchors [i]
+
+ if (#anchor == 1 or #anchor == 3) then
+ local anchorTo, point1, point2 = unpack (anchor)
+ point1 = point1 or 0
+ point2 = point2 or 0
+ parent:SetPoint (anchorTo, point1 + newX, point2 + newY)
+
+ elseif (#anchor == 5) then
+ local anchorName1, anchorTo, anchorName2, point1, point2 = unpack (anchor)
+ --parent:ClearAllPoints()
+
+ parent:SetPoint (anchorName1, anchorTo, anchorName2, point1 + newX, point2 + newY)
+ end
+ end
+
+ end
+ else
+ frameshake_shake_finished (parent, shakeObject)
+ end
+end
+
+local frameshake_stop = function (parent, shakeObject)
+ frameshake_shake_finished (parent, shakeObject)
+end
+
+--> scale direction scales the X and Y coordinates, scale strength scales the amplitude and frequency
+local frameshake_play = function (parent, shakeObject, scaleDirection, scaleAmplitude, scaleFrequency, scaleDuration)
+
+ --> check if is already playing
+ if (shakeObject.TimeLeft > 0) then
+ --> reset the time left
+ shakeObject.TimeLeft = shakeObject.Duration
+
+ if (shakeObject.IsFadingOut) then
+ if (shakeObject.FadeInTime > 0) then
+ shakeObject.IsFadingIn = true
+ --> scale the current fade out into fade in, so it starts the fade in at the point where it was fading out
+ shakeObject.IsFadingInTime = shakeObject.FadeInTime * (1 - shakeObject.IsFadingOutTime / shakeObject.FadeOutTime)
+ else
+ shakeObject.IsFadingIn = false
+ shakeObject.IsFadingInTime = 0
+ end
+
+ --> disable fade out and enable fade in
+ shakeObject.IsFadingOut = false
+ shakeObject.IsFadingOutTime = 0
+ end
+ else
+ --> create a new random offset
+ shakeObject.XSineOffset = math.pi * 2 * math.random()
+ shakeObject.YSineOffset = math.pi * 2 * math.random()
+
+ --> store the initial position if case it needs a reset
+ shakeObject.StartedXSineOffset = shakeObject.XSineOffset
+ shakeObject.StartedYSineOffset = shakeObject.YSineOffset
+
+ --> check if there's a fade in time
+ if (shakeObject.FadeInTime > 0) then
+ shakeObject.IsFadingIn = true
+ else
+ shakeObject.IsFadingIn = false
+ end
+
+ shakeObject.IsFadingInTime = 0
+ shakeObject.IsFadingOut = false
+ shakeObject.IsFadingOutTime = 0
+
+ --> apply custom scale
+ shakeObject.ScaleX = (scaleDirection or 1) * shakeObject.OriginalScaleX
+ shakeObject.ScaleY = (scaleDirection or 1) * shakeObject.OriginalScaleY
+ shakeObject.Frequency = (scaleFrequency or 1) * shakeObject.OriginalFrequency
+ shakeObject.Amplitude = (scaleAmplitude or 1) * shakeObject.OriginalAmplitude
+ shakeObject.Duration = (scaleDuration or 1) * shakeObject.OriginalDuration
+
+ --> update the time left
+ shakeObject.TimeLeft = shakeObject.Duration
+
+ --> check if is dynamic points
+ if (shakeObject.IsDynamicAnchor) then
+ wipe (shakeObject.Anchors)
+ for i = 1, parent:GetNumPoints() do
+ local p1, p2, p3, p4, p5 = parent:GetPoint (i)
+ shakeObject.Anchors [#shakeObject.Anchors+1] = {p1, p2, p3, p4, p5}
+ end
+ end
+
+ --> update the amount of shake running on this frame
+ parent.__frameshakes.enabled = parent.__frameshakes.enabled + 1
+
+ if (not parent:GetScript ("OnUpdate")) then
+ parent:SetScript ("OnUpdate", function()end)
+ end
+ end
+
+ shakeObject.IsPlaying = true
+
+ frameshake_do_update (parent, shakeObject)
+end
+
+local frameshake_set_config = function (parent, shakeObject, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)
+ shakeObject.Amplitude = amplitude or shakeObject.Amplitude
+ shakeObject.Frequency = frequency or shakeObject.Frequency
+ shakeObject.Duration = duration or shakeObject.Duration
+ shakeObject.FadeInTime = fadeInTime or shakeObject.FadeInTime
+ shakeObject.FadeOutTime = fadeOutTime or shakeObject.FadeOutTime
+ shakeObject.ScaleX = scaleX or shakeObject.ScaleX
+ shakeObject.ScaleY = scaleY or shakeObject.ScaleY
+
+ if (absoluteSineX ~= nil) then
+ shakeObject.AbsoluteSineX = absoluteSineX
+ end
+ if (absoluteSineY ~= nil) then
+ shakeObject.AbsoluteSineY = absoluteSineY
+ end
+
+ shakeObject.OriginalScaleX = shakeObject.ScaleX
+ shakeObject.OriginalScaleY = shakeObject.ScaleY
+ shakeObject.OriginalFrequency = shakeObject.Frequency
+ shakeObject.OriginalAmplitude = shakeObject.Amplitude
+ shakeObject.OriginalDuration = shakeObject.Duration
+end
+
+function DF:CreateFrameShake (parent, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)
+
+ --> create the shake table
+ local frameShake = {
+ Amplitude = amplitude or 2,
+ Frequency = frequency or 5,
+ Duration = duration or 0.3,
+ FadeInTime = fadeInTime or 0.01,
+ FadeOutTime = fadeOutTime or 0.01,
+ ScaleX = scaleX or 0.2,
+ ScaleY = scaleY or 1,
+ AbsoluteSineX = absoluteSineX,
+ AbsoluteSineY = absoluteSineY,
+ --
+ IsPlaying = false,
+ TimeLeft = 0,
+ }
+
+ frameShake.OriginalScaleX = frameShake.ScaleX
+ frameShake.OriginalScaleY = frameShake.ScaleY
+ frameShake.OriginalFrequency = frameShake.Frequency
+ frameShake.OriginalAmplitude = frameShake.Amplitude
+ frameShake.OriginalDuration = frameShake.Duration
+
+ if (type (anchorPoints) ~= "table") then
+ frameShake.IsDynamicAnchor = true
+ frameShake.Anchors = {}
+ else
+ frameShake.Anchors = anchorPoints
+ end
+
+ --> inject frame shake table into the frame
+ if (not parent.__frameshakes) then
+ parent.__frameshakes = {
+ enabled = 0,
+ }
+ parent.PlayFrameShake = frameshake_play
+ parent.StopFrameShake = frameshake_stop
+ parent.UpdateFrameShake = frameshake_do_update
+ parent.SetFrameShakeSettings = frameshake_set_config
+
+ --> register the frame within the frame shake updater
+ FrameshakeUpdateFrame.RegisterFrame (parent)
+ end
+
+ tinsert (parent.__frameshakes, frameShake)
+
+ return frameShake
+end
+
+
+-----------------------------
+--> glow overlay
+
+local glow_overlay_play = function (self)
+ if (not self:IsShown()) then
+ self:Show()
+ end
+ if (self.animOut:IsPlaying()) then
+ self.animOut:Stop()
+ end
+ if (not self.animIn:IsPlaying()) then
+ self.animIn:Play()
+ end
+end
+
+local glow_overlay_stop = function (self)
+ if (self.animOut:IsPlaying()) then
+ self.animOut:Stop()
+ end
+ if (self.animIn:IsPlaying()) then
+ self.animIn:Stop()
+ end
+ if (self:IsShown()) then
+ self:Hide()
+ end
+end
+
+local glow_overlay_setcolor = function (self, antsColor, glowColor)
+ if (antsColor) then
+ local r, g, b, a = DF:ParseColors (antsColor)
+ self.ants:SetVertexColor (r, g, b, a)
+ self.AntsColor.r = r
+ self.AntsColor.g = g
+ self.AntsColor.b = b
+ self.AntsColor.a = a
+ end
+
+ if (glowColor) then
+ local r, g, b, a = DF:ParseColors (glowColor)
+ self.outerGlow:SetVertexColor (r, g, b, a)
+ self.GlowColor.r = r
+ self.GlowColor.g = g
+ self.GlowColor.b = b
+ self.GlowColor.a = a
+ end
+end
+
+local glow_overlay_onshow = function (self)
+ glow_overlay_play (self)
+end
+
+local glow_overlay_onhide = function (self)
+ glow_overlay_stop (self)
+end
+
+--this is most copied from the wow client code, few changes applied to customize it
+function DF:CreateGlowOverlay (parent, antsColor, glowColor)
+ local glowFrame = CreateFrame ("frame", parent:GetName() and "$parentGlow2" or "OverlayActionGlow" .. math.random (1, 10000000), parent, "ActionBarButtonSpellActivationAlert")
+ glowFrame:HookScript ("OnShow", glow_overlay_onshow)
+ glowFrame:HookScript ("OnHide", glow_overlay_onhide)
+
+ glowFrame.Play = glow_overlay_play
+ glowFrame.Stop = glow_overlay_stop
+ glowFrame.SetColor = glow_overlay_setcolor
+
+ glowFrame:Hide()
+
+ parent.overlay = glowFrame
+ local frameWidth, frameHeight = parent:GetSize()
+
+ local scale = 1.4
+
+ --Make the height/width available before the next frame:
+ parent.overlay:SetSize(frameWidth * scale, frameHeight * scale)
+ parent.overlay:SetPoint("TOPLEFT", parent, "TOPLEFT", -frameWidth * 0.32, frameHeight * 0.36)
+ parent.overlay:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", frameWidth * 0.32, -frameHeight * 0.36)
+
+ local r, g, b, a = DF:ParseColors (antsColor or defaultColor)
+ glowFrame.ants:SetVertexColor (r, g, b, a)
+ glowFrame.AntsColor = {r, g, b, a}
+
+ local r, g, b, a = DF:ParseColors (glowColor or defaultColor)
+ glowFrame.outerGlow:SetVertexColor (r, g, b, a)
+ glowFrame.GlowColor = {r, g, b, a}
+
+ glowFrame.outerGlow:SetScale (1.2)
+ return glowFrame
+end
+
+--> custom glow with ants animation
+local ants_set_texture_offset = function (self, leftOffset, rightOffset, topOffset, bottomOffset)
+ leftOffset = leftOffset or 0
+ rightOffset = rightOffset or 0
+ topOffset = topOffset or 0
+ bottomOffset = bottomOffset or 0
+
+ self:ClearAllPoints()
+ self:SetPoint ("topleft", leftOffset, topOffset)
+ self:SetPoint ("bottomright", rightOffset, bottomOffset)
+end
+
+function DF:CreateAnts (parent, antTable, leftOffset, rightOffset, topOffset, bottomOffset, antTexture)
+ leftOffset = leftOffset or 0
+ rightOffset = rightOffset or 0
+ topOffset = topOffset or 0
+ bottomOffset = bottomOffset or 0
+
+ local f = CreateFrame ("frame", nil, parent)
+ f:SetPoint ("topleft", leftOffset, topOffset)
+ f:SetPoint ("bottomright", rightOffset, bottomOffset)
+
+ f.SetOffset = ants_set_texture_offset
+
+ local t = f:CreateTexture (nil, "overlay")
+ t:SetAllPoints()
+ t:SetTexture (antTable.Texture)
+ t:SetBlendMode (antTable.BlendMode or "ADD")
+ t:SetVertexColor (DF:ParseColors (antTable.Color or "white"))
+ f.Texture = t
+
+ f.AntTable = antTable
+
+ f:SetScript ("OnUpdate", function (self, deltaTime)
+ AnimateTexCoords (t, self.AntTable.TextureWidth, self.AntTable.TextureHeight, self.AntTable.TexturePartsWidth, self.AntTable.TexturePartsHeight, self.AntTable.AmountParts, deltaTime, self.AntTable.Throttle or 0.025)
+ end)
+
+ return f
+end
+
+--[=[ --test ants
+do
+ local f = DF:CreateAnts (UIParent)
+end
+--]=]
+
+-----------------------------
+--> borders
+
+local default_border_color1 = .5
+local default_border_color2 = .3
+local default_border_color3 = .1
+
+local SetBorderAlpha = function (self, alpha1, alpha2, alpha3)
+ self.Borders.Alpha1 = alpha1 or self.Borders.Alpha1
+ self.Borders.Alpha2 = alpha2 or self.Borders.Alpha2
+ self.Borders.Alpha3 = alpha3 or self.Borders.Alpha3
+
+ for _, texture in ipairs (self.Borders.Layer1) do
+ texture:SetAlpha (self.Borders.Alpha1)
+ end
+ for _, texture in ipairs (self.Borders.Layer2) do
+ texture:SetAlpha (self.Borders.Alpha2)
+ end
+ for _, texture in ipairs (self.Borders.Layer3) do
+ texture:SetAlpha (self.Borders.Alpha3)
+ end
+end
+
+local SetBorderColor = function (self, r, g, b)
+ for _, texture in ipairs (self.Borders.Layer1) do
+ texture:SetColorTexture (r, g, b)
+ end
+ for _, texture in ipairs (self.Borders.Layer2) do
+ texture:SetColorTexture (r, g, b)
+ end
+ for _, texture in ipairs (self.Borders.Layer3) do
+ texture:SetColorTexture (r, g, b)
+ end
+end
+
+local SetLayerVisibility = function (self, layer1Shown, layer2Shown, layer3Shown)
+
+ for _, texture in ipairs (self.Borders.Layer1) do
+ texture:SetShown (layer1Shown)
+ end
+
+ for _, texture in ipairs (self.Borders.Layer2) do
+ texture:SetShown (layer2Shown)
+ end
+
+ for _, texture in ipairs (self.Borders.Layer3) do
+ texture:SetShown (layer3Shown)
+ end
+
+end
+
+function DF:CreateBorder (parent, alpha1, alpha2, alpha3)
+
+ parent.Borders = {
+ Layer1 = {},
+ Layer2 = {},
+ Layer3 = {},
+ Alpha1 = alpha1 or default_border_color1,
+ Alpha2 = alpha2 or default_border_color2,
+ Alpha3 = alpha3 or default_border_color3,
+ }
+
+ parent.SetBorderAlpha = SetBorderAlpha
+ parent.SetBorderColor = SetBorderColor
+ parent.SetLayerVisibility = SetLayerVisibility
+
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "topleft", parent, "topleft", -1, 1)
+ PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", -1, -1)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -2, 2)
+ PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -2, -2)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -3, 3)
+ PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -3, -3)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "topleft", parent, "topleft", 0, 1)
+ PixelUtil.SetPoint (border1, "topright", parent, "topright", 1, 1)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -1, 2)
+ PixelUtil.SetPoint (border2, "topright", parent, "topright", 2, 2)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -2, 3)
+ PixelUtil.SetPoint (border3, "topright", parent, "topright", 3, 3)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "topright", parent, "topright", 1, 0)
+ PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 1, -1)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topright", parent, "topright", 2, 1)
+ PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 2, -2)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topright", parent, "topright", 3, 2)
+ PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 3, -3)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", 0, -1)
+ PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 0, -1)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -1, -2)
+ PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 1, -2)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -2, -3)
+ PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 2, -3)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+end
+
+function DF:CreateBorderSolid (parent, size)
+
+end
+
+function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread)
+
+ parent.Borders = {
+ Layer1 = {},
+ Layer2 = {},
+ Layer3 = {},
+ Alpha1 = alpha1 or default_border_color1,
+ Alpha2 = alpha2 or default_border_color2,
+ Alpha3 = alpha3 or default_border_color3,
+ }
+
+ parent.SetBorderAlpha = SetBorderAlpha
+ parent.SetBorderColor = SetBorderColor
+ parent.SetLayerVisibility = SetLayerVisibility
+
+ size = size or 1
+ local minPixels = 1
+ local spread = 0
+
+ --left
+ local border1 = parent:CreateTexture (nil, "background")
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ PixelUtil.SetPoint (border1, "topleft", parent, "topleft", -1 + spread, 1 + (-spread), 0, 0)
+ PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", -1 + spread, -1 + spread, 0, 0)
+ PixelUtil.SetWidth (border1, size, minPixels)
+
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -2 + spread, 2 + (-spread))
+ PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -2 + spread, -2 + spread)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ PixelUtil.SetWidth (border2, size, minPixels)
+
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -3 + spread, 3 + (-spread))
+ PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -3 + spread, -3 + spread)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+ PixelUtil.SetWidth (border3, size, minPixels)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ --top
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "topleft", parent, "topleft", 0 + spread, 1 + (-spread))
+ PixelUtil.SetPoint (border1, "topright", parent, "topright", 1 + (-spread), 1 + (-spread))
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ PixelUtil.SetHeight (border1, size, minPixels)
+
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -1 + spread, 2 + (-spread))
+ PixelUtil.SetPoint (border2, "topright", parent, "topright", 2 + (-spread), 2 + (-spread))
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ PixelUtil.SetHeight (border2, size, minPixels)
+
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -2 + spread, 3 + (-spread))
+ PixelUtil.SetPoint (border3, "topright", parent, "topright", 3 + (-spread), 3 + (-spread))
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+ PixelUtil.SetHeight (border3, size, minPixels)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ --right
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "topright", parent, "topright", 1 + (-spread), 0 + (-spread))
+ PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 1 + (-spread), -1 + spread)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ PixelUtil.SetWidth (border1, size, minPixels)
+
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "topright", parent, "topright", 2 + (-spread), 1 + (-spread))
+ PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 2 + (-spread), -2 + spread)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ PixelUtil.SetWidth (border2, size, minPixels)
+
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "topright", parent, "topright", 3 + (-spread), 2 + (-spread))
+ PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 3 + (-spread), -3 + spread)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+ PixelUtil.SetWidth (border3, size, minPixels)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+ local border1 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", 0 + spread, -1 + spread)
+ PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 0 + (-spread), -1 + spread)
+ border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
+ PixelUtil.SetHeight (border1, size, minPixels)
+
+ local border2 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -1 + spread, -2 + spread)
+ PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 1 + (-spread), -2 + spread)
+ border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
+ PixelUtil.SetHeight (border2, size, minPixels)
+
+ local border3 = parent:CreateTexture (nil, "background")
+ PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -2 + spread, -3 + spread)
+ PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 2 + (-spread), -3 + spread)
+ border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
+ PixelUtil.SetHeight (border3, size, minPixels)
+
+ tinsert (parent.Borders.Layer1, border1)
+ tinsert (parent.Borders.Layer2, border2)
+ tinsert (parent.Borders.Layer3, border3)
+
+end
+
+function DF:ReskinSlider (slider, heightOffset)
+ if (slider.slider) then
+ slider.cima:SetNormalTexture ([[Interface\Buttons\Arrow-Up-Up]])
+ slider.cima:SetPushedTexture ([[Interface\Buttons\Arrow-Up-Down]])
+ slider.cima:SetDisabledTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
+ slider.cima:GetNormalTexture():ClearAllPoints()
+ slider.cima:GetPushedTexture():ClearAllPoints()
+ slider.cima:GetDisabledTexture():ClearAllPoints()
+ slider.cima:GetNormalTexture():SetPoint ("center", slider.cima, "center", 1, 1)
+ slider.cima:GetPushedTexture():SetPoint ("center", slider.cima, "center", 1, 1)
+ slider.cima:GetDisabledTexture():SetPoint ("center", slider.cima, "center", 1, 1)
+ slider.cima:SetSize (16, 16)
+ slider.cima:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
+ slider.cima:SetBackdropColor (0, 0, 0, 0.3)
+ slider.cima:SetBackdropBorderColor (0, 0, 0, 1)
+
+ slider.baixo:SetNormalTexture ([[Interface\Buttons\Arrow-Down-Up]])
+ slider.baixo:SetPushedTexture ([[Interface\Buttons\Arrow-Down-Down]])
+ slider.baixo:SetDisabledTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
+ slider.baixo:GetNormalTexture():ClearAllPoints()
+ slider.baixo:GetPushedTexture():ClearAllPoints()
+ slider.baixo:GetDisabledTexture():ClearAllPoints()
+ slider.baixo:GetNormalTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
+ slider.baixo:GetPushedTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
+ slider.baixo:GetDisabledTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
+ slider.baixo:SetSize (16, 16)
+ slider.baixo:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
+ slider.baixo:SetBackdropColor (0, 0, 0, 0.35)
+ slider.baixo:SetBackdropBorderColor (0, 0, 0, 1)
+
+ slider.slider:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
+ slider.slider:SetBackdropColor (0, 0, 0, 0.35)
+ slider.slider:SetBackdropBorderColor (0, 0, 0, 1)
+
+ --slider.slider:Altura (164)
+ slider.slider:cimaPoint (0, 13)
+ slider.slider:baixoPoint (0, -13)
+ slider.slider.thumb:SetTexture ([[Interface\AddOns\Details\images\icons2]])
+ slider.slider.thumb:SetTexCoord (482/512, 492/512, 104/512, 120/512)
+ slider.slider.thumb:SetSize (12, 12)
+ slider.slider.thumb:SetVertexColor (0.6, 0.6, 0.6, 0.95)
+
+ else
+ --up button
+ do
+ local normalTexture = slider.ScrollBar.ScrollUpButton.Normal
+ normalTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Up]])
+ normalTexture:SetTexCoord (0, 1, .2, 1)
+
+ normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
+ normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
+
+ local pushedTexture = slider.ScrollBar.ScrollUpButton.Pushed
+ pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Down]])
+ pushedTexture:SetTexCoord (0, 1, .2, 1)
+
+ pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
+ pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
+
+ local disabledTexture = slider.ScrollBar.ScrollUpButton.Disabled
+ disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
+ disabledTexture:SetTexCoord (0, 1, .2, 1)
+ disabledTexture:SetAlpha (.5)
+
+ disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
+ disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
+
+ slider.ScrollBar.ScrollUpButton:SetSize (16, 16)
+ slider.ScrollBar.ScrollUpButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
+ slider.ScrollBar.ScrollUpButton:SetBackdropColor (0, 0, 0, 0.3)
+ slider.ScrollBar.ScrollUpButton:SetBackdropBorderColor (0, 0, 0, 1)
+
+ --it was having problems with the texture anchor when calling ClearAllPoints() and setting new points different from the original
+ --now it is using the same points from the original with small offsets tp align correctly
+ end
+
+ --down button
+ do
+ local normalTexture = slider.ScrollBar.ScrollDownButton.Normal
+ normalTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Up]])
+ normalTexture:SetTexCoord (0, 1, 0, .8)
+
+ normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
+ normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
+
+ local pushedTexture = slider.ScrollBar.ScrollDownButton.Pushed
+ pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Down]])
+ pushedTexture:SetTexCoord (0, 1, 0, .8)
+
+ pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
+ pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
+
+ local disabledTexture = slider.ScrollBar.ScrollDownButton.Disabled
+ disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
+ disabledTexture:SetTexCoord (0, 1, 0, .8)
+ disabledTexture:SetAlpha (.5)
+
+ disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
+ disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
+
+ slider.ScrollBar.ScrollDownButton:SetSize (16, 16)
+ slider.ScrollBar.ScrollDownButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
+ slider.ScrollBar.ScrollDownButton:SetBackdropColor (0, 0, 0, 0.3)
+ slider.ScrollBar.ScrollDownButton:SetBackdropBorderColor (0, 0, 0, 1)
+
+ --
+ --slider.ScrollBar.ScrollDownButton:SetPoint ("top", slider.ScrollBar, "bottom", 0, 0)
+ end
+
+ --
+
+ slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 6, -16)
+ slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 6, 16 + (heightOffset and heightOffset*-1 or 0))
+
+ slider.ScrollBar.ThumbTexture:SetColorTexture (.5, .5, .5, .3)
+ slider.ScrollBar.ThumbTexture:SetSize (12, 8)
+
+ --
+
+ slider.ScrollBar:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
+ slider.ScrollBar:SetBackdropColor (0, 0, 0, 0.35)
+ slider.ScrollBar:SetBackdropBorderColor (0, 0, 0, 1)
+ end
+end
+
+function DF:GetCurrentSpec()
+ local specIndex = GetSpecialization()
+ if (specIndex) then
+ local specID = GetSpecializationInfo (specIndex)
+ if (specID and specID ~= 0) then
+ return specID
+ end
+ end
+end
+
+local specs_per_class = {
+ ["DEMONHUNTER"] = {577, 581},
+ ["DEATHKNIGHT"] = {250, 251, 252},
+ ["WARRIOR"] = {71, 72, 73},
+ ["MAGE"] = {62, 63, 64},
+ ["ROGUE"] = {259, 260, 261},
+ ["DRUID"] = {102, 103, 104, 105},
+ ["HUNTER"] = {253, 254, 255},
+ ["SHAMAN"] = {262, 263, 254},
+ ["PRIEST"] = {256, 257, 258},
+ ["WARLOCK"] = {265, 266, 267},
+ ["PALADIN"] = {65, 66, 70},
+ ["MONK"] = {268, 269, 270},
+}
+
+function DF:GetClassSpecIDs (class)
+ return specs_per_class [class]
+end
+
+local dispatch_error = function (context, errortext)
+ DF:Msg ( (context or "") .. " |cFFFF9900error|r: " .. (errortext or ""))
+end
+
+--> safe call an external func with payload and without telling who is calling
+function DF:QuickDispatch (func, ...)
+ if (type (func) ~= "function") then
+ return
+ end
+
+ local okay, errortext = pcall (func, ...)
+
+ if (not okay) then
+ --> trigger an error msg
+ dispatch_error (_, errortext)
+ return
+ end
+
+ return true
+end
+
+function DF:Dispatch (func, ...)
+ if (type (func) ~= "function") then
+ return dispatch_error (_, "Dispatch required a function.")
+ end
+
+ local okay, result1, result2, result3, result4 = xpcall (func, geterrorhandler(), ...)
+
+ if (not okay) then
+ return nil
+ end
+
+ return result1, result2, result3, result4
+end
+
+--[=[
+ DF:CoreDispatch (func, context, ...)
+ safe call a function making a error window with what caused, the context and traceback of the error
+ this func is only used inside the framework for sensitive calls where the func must run without errors
+ @func = the function which will be called
+ @context = what made the function be called
+ ... parameters to pass in the function call
+--]=]
+function DF:CoreDispatch (context, func, ...)
+ if (type (func) ~= "function") then
+ local stack = debugstack(2)
+ local errortext = "D!Framework " .. context .. " error: invalid function to call\n====================\n" .. stack .. "\n====================\n"
+ error (errortext)
+ end
+
+ local okay, result1, result2, result3, result4 = pcall (func, ...)
+
+ if (not okay) then
+ local stack = debugstack (2)
+ local errortext = "D!Framework (" .. context .. ") error: " .. result1 .. "\n====================\n" .. stack .. "\n====================\n"
+ error (errortext)
+ end
+
+ return result1, result2, result3, result4
+end
+
+
+--/run local a, b =32,3; local f=function(c,d) return c+d, 2, 3;end; print (xpcall(f,geterrorhandler(),a,b))
+function DF_CALC_PERFORMANCE()
+ local F = CreateFrame ("frame")
+ local T = GetTime()
+ local J = false
+ F:SetScript ("OnUpdate", function (self, deltaTime)
+ if (not J) then
+ J = true
+ return
+ end
+ print ("Elapsed Time:", deltaTime)
+ F:SetScript ("OnUpdate", nil)
+ end)
+end
+
+DF.ClassFileNameToIndex = {
+ ["DEATHKNIGHT"] = 6,
+ ["WARRIOR"] = 1,
+ ["ROGUE"] = 4,
+ ["MAGE"] = 8,
+ ["PRIEST"] = 5,
+ ["HUNTER"] = 3,
+ ["WARLOCK"] = 9,
+ ["DEMONHUNTER"] = 12,
+ ["SHAMAN"] = 7,
+ ["DRUID"] = 11,
+ ["MONK"] = 10,
+ ["PALADIN"] = 2,
+}
+DF.ClassCache = {}
+
+function DF:GetClassList()
+
+ if (next (DF.ClassCache)) then
+ return DF.ClassCache
+ end
+
+ for className, classIndex in pairs (DF.ClassFileNameToIndex) do
+ local classTable = C_CreatureInfo.GetClassInfo (classIndex)
+ local t = {
+ ID = classIndex,
+ Name = classTable.className,
+ Texture = [[Interface\GLUES\CHARACTERCREATE\UI-CharacterCreate-Classes]],
+ TexCoord = CLASS_ICON_TCOORDS [className],
+ FileString = className,
+ }
+ tinsert (DF.ClassCache, t)
+ end
+
+ return DF.ClassCache
+
+end
+
+--hardcoded race list
+DF.RaceList = {
+ [1] = "Human",
+ [2] = "Orc",
+ [3] = "Dwarf",
+ [4] = "NightElf",
+ [5] = "Scourge",
+ [6] = "Tauren",
+ [7] = "Gnome",
+ [8] = "Troll",
+ [9] = "Goblin",
+ [10] = "BloodElf",
+ [11] = "Draenei",
+ [22] = "Worgen",
+ [24] = "Pandaren",
+}
+
+DF.AlliedRaceList = {
+ [27] = "Nightborne",
+ [29] = "HighmountainTauren",
+ [31] = "VoidElf",
+ [33] = "LightforgedDraenei",
+ [35] = "ZandalariTroll",
+ [36] = "KulTiran",
+ [38] = "DarkIronDwarf",
+ [40] = "Vulpera",
+ [41] = "MagharOrc",
+}
+
+--> store and return a list of character races, always return the non-localized value
+DF.RaceCache = {}
+function DF:GetCharacterRaceList (fullList)
+ if (next (DF.RaceCache)) then
+ return DF.RaceCache
+ end
+
+ for i = 1, 100 do
+ local raceInfo = C_CreatureInfo.GetRaceInfo (i)
+ if (raceInfo and DF.RaceList [raceInfo.raceID]) then
+ tinsert (DF.RaceCache, {Name = raceInfo.raceName, FileString = raceInfo.clientFileString})
+ end
+
+ local alliedRaceInfo = C_AlliedRaces.GetRaceInfoByID (i)
+ if (alliedRaceInfo and DF.AlliedRaceList [alliedRaceInfo.raceID]) then
+ tinsert (DF.RaceCache, {Name = alliedRaceInfo.name, FileString = alliedRaceInfo.raceFileString})
+ end
+ end
+
+ return DF.RaceCache
+end
+
+--get a list of talents for the current spec the player is using
+--if onlySelected return an index table with only the talents the character has selected
+--if onlySelectedHash return a hash table with [spelID] = true
+function DF:GetCharacterTalents (onlySelected, onlySelectedHash)
+ local talentList = {}
+
+ for i = 1, 7 do
+ for o = 1, 3 do
+ local talentID, name, texture, selected, available = GetTalentInfo (i, o, 1)
+ if (onlySelectedHash) then
+ if (selected) then
+ talentList [talentID] = true
+ break
+ end
+ elseif (onlySelected) then
+ if (selected) then
+ tinsert (talentList, {Name = name, ID = talentID, Texture = texture, IsSelected = selected})
+ break
+ end
+ else
+ tinsert (talentList, {Name = name, ID = talentID, Texture = texture, IsSelected = selected})
+ end
+ end
+ end
+
+ return talentList
+end
+
+function DF:GetCharacterPvPTalents (onlySelected, onlySelectedHash)
+ if (onlySelected or onlySelectedHash) then
+ local talentsSelected = C_SpecializationInfo.GetAllSelectedPvpTalentIDs()
+ local talentList = {}
+ for _, talentID in ipairs (talentsSelected) do
+ local _, talentName, texture = GetPvpTalentInfoByID (talentID)
+ if (onlySelectedHash) then
+ talentList [talentID] = true
+ else
+ tinsert (talentList, {Name = talentName, ID = talentID, Texture = texture, IsSelected = true})
+ end
+ end
+ return talentList
+
+ else
+ local alreadyAdded = {}
+ local talentList = {}
+ for i = 1, 4 do --4 slots - get talents available in each one
+ local slotInfo = C_SpecializationInfo.GetPvpTalentSlotInfo (i)
+ if (slotInfo) then
+ for _, talentID in ipairs (slotInfo.availableTalentIDs) do
+ if (not alreadyAdded [talentID]) then
+ local _, talentName, texture, selected = GetPvpTalentInfoByID (talentID)
+ tinsert (talentList, {Name = talentName, ID = talentID, Texture = texture, IsSelected = selected})
+ alreadyAdded [talentID] = true
+ end
+ end
+ end
+ end
+ return talentList
+ end
+end
+
+DF.GroupTypes = {
+ {Name = "Arena", ID = "arena"},
+ {Name = "Battleground", ID = "pvp"},
+ {Name = "Raid", ID = "raid"},
+ {Name = "Dungeon", ID = "party"},
+ {Name = "Scenario", ID = "scenario"},
+ {Name = "Open World", ID = "none"},
+}
+function DF:GetGroupTypes()
+ return DF.GroupTypes
+end
+
+DF.RoleTypes = {
+ {Name = _G.DAMAGER, ID = "DAMAGER", Texture = _G.INLINE_DAMAGER_ICON},
+ {Name = _G.HEALER, ID = "HEALER", Texture = _G.INLINE_HEALER_ICON},
+ {Name = _G.TANK, ID = "TANK", Texture = _G.INLINE_TANK_ICON},
+}
+function DF:GetRoleTypes()
+ return DF.RoleTypes
+end
+
+DF.CLEncounterID = {
+ {ID = 2144, Name = "Taloc"},
+ {ID = 2141, Name = "MOTHER"},
+ {ID = 2128, Name = "Fetid Devourer"},
+ {ID = 2136, Name = "Zek'voz"},
+ {ID = 2134, Name = "Vectis"},
+ {ID = 2145, Name = "Zul"},
+ {ID = 2135, Name = "Mythrax the Unraveler"},
+ {ID = 2122, Name = "G'huun"},
+}
+
+function DF:GetPlayerRole()
+ local assignedRole = UnitGroupRolesAssigned ("player")
+ if (assignedRole == "NONE") then
+ local spec = GetSpecialization()
+ return spec and GetSpecializationRole (spec) or "NONE"
+ end
+ return assignedRole
+end
+
+function DF:GetCLEncounterIDs()
+ return DF.CLEncounterID
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> delta seconds reader
+
+if (not DetailsFrameworkDeltaTimeFrame) then
+ CreateFrame ("frame", "DetailsFrameworkDeltaTimeFrame", UIParent)
+end
+
+local deltaTimeFrame = DetailsFrameworkDeltaTimeFrame
+deltaTimeFrame:SetScript ("OnUpdate", function (self, deltaTime)
+ self.deltaTime = deltaTime
+end)
+
+function GetWorldDeltaSeconds()
+ return deltaTimeFrame.deltaTime
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> debug
+
+DF.DebugMixin = {
+
+ debug = true,
+
+ CheckPoint = function (self, checkPointName, ...)
+ print (self:GetName(), checkPointName, ...)
+ end,
+
+ CheckVisibilityState = function (self, widget)
+
+ self = widget or self
+
+ local width, height = self:GetSize()
+ width = floor (width)
+ height = floor (height)
+
+ local numPoints = self:GetNumPoints()
+
+ print ("shown:", self:IsShown(), "visible:", self:IsVisible(), "alpha:", self:GetAlpha(), "size:", width, height, "points:", numPoints)
+ end,
+
+ CheckStack = function (self)
+ local stack = debugstack()
+ Details:Dump (stack)
+ end,
+
+}
+
+--doo elsee
+--was doing double loops due to not enought height
diff --git a/libs/DF/help.lua b/libs/DF/help.lua
new file mode 100644
index 0000000..0825fba
--- /dev/null
+++ b/libs/DF/help.lua
@@ -0,0 +1,123 @@
+
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+
+local APIHelpFunctions = false
+local HelpMetaFunctions = {}
+
+ local get_members_function_index = {}
+
+ HelpMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return HelpMetaFunctions [_member_requested]
+ end
+
+ local set_members_function_index = {}
+
+ HelpMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+function HelpMetaFunctions:AddHelp (width, height, x, y, buttonX, buttonY, text, anchor)
+ self.helpTable [#self.helpTable + 1] = {
+ HighLightBox = {x = x, y = y, width = width, height = height},
+ ButtonPos = { x = buttonX, y = buttonY},
+ ToolTipDir = anchor or "RIGHT",
+ ToolTipText = text
+ }
+end
+
+function HelpMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+end
+
+function HelpMetaFunctions:ShowHelp()
+ if (not HelpPlate_IsShowing (self.helpTable)) then
+ HelpPlate_Show (self.helpTable, self.frame, self.button, true)
+ else
+ HelpPlate_Hide (true)
+ end
+end
+
+local nameCounter = 1
+function DF:NewHelp (parent, width, height, x, y, buttonWidth, buttonHeight, name)
+
+ local help = {}
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+
+ local helpButton = CreateFrame ("button", name or "DetailsFrameworkHelpButton"..nameCounter, parent, "MainHelpPlateButton")
+ nameCounter = nameCounter + 1
+
+ if (not APIHelpFunctions) then
+ APIHelpFunctions = true
+ local idx = getmetatable (helpButton).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not HelpMetaFunctions [funcName]) then
+ HelpMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ if (buttonWidth and buttonHeight) then
+ helpButton:SetWidth (buttonWidth)
+ helpButton:SetHeight (buttonHeight)
+ helpButton.I:SetWidth (buttonWidth*0.8)
+ helpButton.I:SetHeight (buttonHeight*0.8)
+ helpButton.Ring:SetWidth (buttonWidth)
+ helpButton.Ring:SetHeight (buttonHeight)
+ helpButton.Ring:SetPoint ("center", buttonWidth*.2, -buttonWidth*.2)
+ end
+
+ help.helpTable = {
+ FramePos = {x = x, y = y},
+ FrameSize = {width = width, height = height}
+ }
+
+ help.frame = parent
+ help.button = helpButton
+ help.widget = helpButton
+ help.I = helpButton.I
+ help.Ring = helpButton.Ring
+
+ helpButton:SetScript ("OnClick", function()
+ help:ShowHelp()
+ end)
+
+ setmetatable (help, HelpMetaFunctions)
+
+ return help
+
+end
diff --git a/libs/DF/icons.tga b/libs/DF/icons.tga
new file mode 100644
index 0000000..4b34cb5
Binary files /dev/null and b/libs/DF/icons.tga differ
diff --git a/libs/DF/label.lua b/libs/DF/label.lua
new file mode 100644
index 0000000..4e69ee2
--- /dev/null
+++ b/libs/DF/label.lua
@@ -0,0 +1,334 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APILabelFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "label",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["label"]] = _G [DF.GlobalWidgetControlNames ["label"]] or metaPrototype
+end
+
+local LabelMetaFunctions = _G [DF.GlobalWidgetControlNames ["label"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ LabelMetaFunctions.__call = function (_table, value)
+ return self.label:SetText (value)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.label:GetStringWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.label:GetStringHeight()
+ end
+ --> text
+ local gmember_text = function (_object)
+ return _object.label:GetText()
+ end
+ --> text color
+ local gmember_textcolor = function (_object)
+ return _object.label:GetTextColor()
+ end
+ --> text font
+ local gmember_textfont = function (_object)
+ local fontface = _object.label:GetFont()
+ return fontface
+ end
+ --> text size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.label:GetFont()
+ return fontsize
+ end
+
+ LabelMetaFunctions.GetMembers = LabelMetaFunctions.GetMembers or {}
+ LabelMetaFunctions.GetMembers ["shown"] = gmember_shown
+ LabelMetaFunctions.GetMembers ["width"] = gmember_width
+ LabelMetaFunctions.GetMembers ["height"] = gmember_height
+ LabelMetaFunctions.GetMembers ["text"] = gmember_text
+ LabelMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor
+ LabelMetaFunctions.GetMembers ["fontface"] = gmember_textfont
+ LabelMetaFunctions.GetMembers ["fontsize"] = gmember_textsize
+ LabelMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias
+ LabelMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias
+ LabelMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias
+
+ LabelMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = LabelMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return LabelMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> text
+ local smember_text = function (_object, _value)
+ return _object.label:SetText (_value)
+ end
+ --> text color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object.label:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> text font
+ local smember_textfont = function (_object, _value)
+ return DF:SetFontFace (_object.label, _value)
+ end
+ --> text size
+ local smember_textsize = function (_object, _value)
+ return DF:SetFontSize (_object.label, _value)
+ end
+ --> text align
+ local smember_textalign = function (_object, _value)
+ if (_value == "<") then
+ _value = "left"
+ elseif (_value == ">") then
+ _value = "right"
+ elseif (_value == "|") then
+ _value = "center"
+ end
+ return _object.label:SetJustifyH (_value)
+ end
+ --> text valign
+ local smember_textvalign = function (_object, _value)
+ if (_value == "^") then
+ _value = "top"
+ elseif (_value == "_") then
+ _value = "bottom"
+ elseif (_value == "|") then
+ _value = "middle"
+ end
+ return _object.label:SetJustifyV (_value)
+ end
+ --> field size width
+ local smember_width = function (_object, _value)
+ return _object.label:SetWidth (_value)
+ end
+ --> field size height
+ local smember_height = function (_object, _value)
+ return _object.label:SetHeight (_value)
+ end
+ --> outline (shadow)
+ local smember_outline = function (_object, _value)
+ DF:SetFontOutline (_object.label, _value)
+ end
+
+ LabelMetaFunctions.SetMembers = LabelMetaFunctions.SetMembers or {}
+ LabelMetaFunctions.SetMembers["show"] = smember_show
+ LabelMetaFunctions.SetMembers["hide"] = smember_hide
+ LabelMetaFunctions.SetMembers["align"] = smember_textalign
+ LabelMetaFunctions.SetMembers["valign"] = smember_textvalign
+ LabelMetaFunctions.SetMembers["text"] = smember_text
+ LabelMetaFunctions.SetMembers["width"] = smember_width
+ LabelMetaFunctions.SetMembers["height"] = smember_height
+ LabelMetaFunctions.SetMembers["fontcolor"] = smember_textcolor
+ LabelMetaFunctions.SetMembers["color"] = smember_textcolor--alias
+ LabelMetaFunctions.SetMembers["fontface"] = smember_textfont
+ LabelMetaFunctions.SetMembers["fontsize"] = smember_textsize
+ LabelMetaFunctions.SetMembers["textcolor"] = smember_textcolor--alias
+ LabelMetaFunctions.SetMembers["textfont"] = smember_textfont--alias
+ LabelMetaFunctions.SetMembers["textsize"] = smember_textsize--alias
+ LabelMetaFunctions.SetMembers["shadow"] = smember_outline
+ LabelMetaFunctions.SetMembers["outline"] = smember_outline--alias
+
+ LabelMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = LabelMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function LabelMetaFunctions:IsShown()
+ return self.label:IsShown()
+ end
+ function LabelMetaFunctions:Show()
+ return self.label:Show()
+ end
+ function LabelMetaFunctions:Hide()
+ return self.label:Hide()
+ end
+
+--text text
+ function LabelMetaFunctions:SetTextTruncated (text, maxWidth)
+ self.widget:SetText (text)
+ DF:TruncateText (self.widget, maxWidth)
+ end
+
+-- textcolor
+ function LabelMetaFunctions:SetTextColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.label:SetTextColor (color, arg2, arg3, arg4 or 1)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ return self.label:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+-- setpoint
+ function LabelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+------------------------------------------------------------------------------------------------------------
+
+ function LabelMetaFunctions:SetTemplate (template)
+ if (template.size) then
+ DF:SetFontSize (self.label, template.size)
+ end
+ if (template.color) then
+ local r, g, b, a = DF:ParseColors (template.color)
+ self:SetTextColor (r, g, b, a)
+ end
+ if (template.font) then
+ local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+ local font = SharedMedia:Fetch ("font", template.font)
+ DF:SetFontFace (self.label, font)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+function DF:CreateLabel (parent, text, size, color, font, member, name, layer)
+ return DF:NewLabel (parent, nil, name, member, text, font, size, color, layer)
+end
+
+function DF:NewLabel (parent, container, name, member, text, font, size, color, layer)
+
+ if (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (not name) then
+ name = "DetailsFrameworkLabelNumber" .. DF.LabelNameCounter
+ DF.LabelNameCounter = DF.LabelNameCounter + 1
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local LabelObject = {type = "label", dframework = true}
+
+ if (member) then
+ parent [member] = LabelObject
+ --container [member] = LabelObject.label
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ font = font or "GameFontHighlightSmall"
+
+ LabelObject.label = parent:CreateFontString (name, layer or "OVERLAY", font)
+ LabelObject.widget = LabelObject.label
+
+ LabelObject.label.MyObject = LabelObject
+
+ if (not APILabelFunctions) then
+ APILabelFunctions = true
+ local idx = getmetatable (LabelObject.label).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not LabelMetaFunctions [funcName]) then
+ LabelMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.label:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ LabelObject.label:SetText (text)
+
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ LabelObject.label:SetTextColor (r, g, b, a)
+ end
+
+ if (size and type (size) == "number") then
+ DF:SetFontSize (LabelObject.label, size)
+ end
+
+ LabelObject.HookList = {
+ }
+
+ LabelObject.label:SetJustifyH ("LEFT")
+
+ setmetatable (LabelObject, LabelMetaFunctions)
+
+ if (size and type (size) == "table") then
+ LabelObject:SetTemplate (size)
+ end
+
+ return LabelObject
+end
diff --git a/libs/DF/load.xml b/libs/DF/load.xml
new file mode 100644
index 0000000..7e8e3b2
--- /dev/null
+++ b/libs/DF/load.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/DF/mail.tga b/libs/DF/mail.tga
new file mode 100644
index 0000000..817eb66
Binary files /dev/null and b/libs/DF/mail.tga differ
diff --git a/libs/DF/math.lua b/libs/DF/math.lua
new file mode 100644
index 0000000..fa9f64c
--- /dev/null
+++ b/libs/DF/math.lua
@@ -0,0 +1,114 @@
+
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local UnitExists = UnitExists
+local atan2 = math.atan2
+local pi = math.pi
+local abs = math.abs
+
+SMALL_FLOAT = 0.000001
+
+--find distance between two players
+function DF:GetDistance_Unit (unit1, unit2)
+ if (UnitExists (unit1) and UnitExists (unit2)) then
+ local u1X, u1Y = UnitPosition (unit1)
+ local u2X, u2Y = UnitPosition (unit2)
+
+ local dX = u2X - u1X
+ local dY = u2Y - u1Y
+
+ return ((dX*dX) + (dY*dY)) ^ .5
+ end
+ return 0
+end
+
+--find distance between two points
+function DF:GetDistance_Point (x1, y1, x2, y2)
+ local dx = x2 - x1
+ local dy = y2 - y1
+ return ((dx * dx) + (dy * dy)) ^ .5
+end
+
+--find a rotation for an object from a point to another point
+function DF:FindLookAtRotation (x1, y1, x2, y2)
+ return atan2 (y2 - y1, x2 - x1) + pi
+end
+
+--find the value scale between two given values. e.g: value of 500 in a range 0-100 result in 10 in a scale for 0-10
+function DF:MapRangeClamped (inputX, inputY, outputX, outputY, value)
+ return DF:GetRangeValue (outputX, outputY, Clamp (DF:GetRangePercent (inputX, inputY, value), 0, 1))
+end
+
+--find the value scale between two given values. e.g: value of 75 in a range 0-100 result in 7.5 in a scale for 0-10
+function DF:MapRangeUnclamped (inputX, inputY, outputX, outputY, value)
+ return DF:GetRangeValue (outputX, outputY, DF:GetRangePercent (inputX, inputY, value))
+end
+
+--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
+function DF:GetRangePercent (minValue, maxValue, value)
+ return (value - minValue) / (maxValue - minValue)
+end
+
+--find the value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
+function DF:GetRangeValue (minValue, maxValue, percent)
+ return Lerp (minValue, maxValue, percent)
+end
+
+--dot product of two 2D Vectors
+function DF:GetDotProduct (value1, value2)
+ return (value1.x * value2.x) + (value1.y * value2.y)
+end
+
+--normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
+function DF:LerpNorm (minValue, maxValue, value)
+ return (minValue + value * (maxValue - minValue))
+end
+
+--change the color by the deltaTime
+function DF:LerpLinearColor (deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
+ deltaTime = deltaTime * interpSpeed
+ local r = r1 + (r2 - r1) * deltaTime
+ local g = g1 + (g2 - g1) * deltaTime
+ local b = b1 + (b2 - b1) * deltaTime
+ return r, g, b
+end
+
+--check if a number is near another number by a tolerance
+function DF:IsNearlyEqual (value1, value2, tolerance)
+ tolerance = tolerance or SMALL_FLOAT
+ return abs (value1 - value2) <= tolerance
+end
+
+--check if a number is near zero
+function DF:IsNearlyZero (value, tolerance)
+ tolerance = tolerance or SMALL_FLOAT
+ return abs (value) <= tolerance
+end
+
+--check if a number is within a two other numbers, if isInclusive is true, it'll include the max value
+function DF:IsWithin (minValue, maxValue, value, isInclusive)
+ if (isInclusive) then
+ return ((value >= minValue) and (value <= maxValue))
+ else
+ return ((value >= minValue) and (value < maxValue))
+ end
+end
+
+--dont allow a number ot be lower or bigger than a certain range
+function DF:Clamp (minValue, maxValue, value)
+ return value < minValue and minValue or value < maxValue and value or maxValue
+end
+
+--from http://lua-users.org/wiki/SimpleRound cut fractions on a float
+function DF:Round (num, numDecimalPlaces)
+ local mult = 10^(numDecimalPlaces or 0)
+ return math.floor(num * mult + 0.5) / mult
+end
+
+function DF:ScaleBack ()
+
+end
diff --git a/libs/DF/normal_bar.lua b/libs/DF/normal_bar.lua
new file mode 100644
index 0000000..83426b0
--- /dev/null
+++ b/libs/DF/normal_bar.lua
@@ -0,0 +1,847 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua locals
+local _rawget = rawget --> lua locals
+local _setmetatable = setmetatable --> lua locals
+local _unpack = unpack --> lua locals
+local _type = type --> lua locals
+local _math_floor = math.floor --> lua locals
+
+local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+
+local cleanfunction = function() end
+local APIBarFunctions
+
+do
+ local metaPrototype = {
+ WidgetType = "normal_bar",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["normal_bar"]] = _G [DF.GlobalWidgetControlNames ["normal_bar"]] or metaPrototype
+end
+
+local BarMetaFunctions = _G [DF.GlobalWidgetControlNames ["normal_bar"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ BarMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ return _table.statusbar:GetValue()
+ else
+ return _table.statusbar:SetValue (value)
+ end
+ end
+
+ BarMetaFunctions.__add = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v + v2
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v + v1
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+ BarMetaFunctions.__sub = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v - v2
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v - v1
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local function gmember_tooltip (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object.statusbar:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.statusbar:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.statusbar:GetHeight()
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object.statusbar:GetValue()
+ end
+ --> right text
+ local gmember_rtext = function (_object)
+ return _object.textright:GetText()
+ end
+ --> left text
+ local gmember_ltext = function (_object)
+ return _object.textleft:GetText()
+ end
+ --> left color
+ local gmember_color = function (_object)
+ local r, g, b, a = _object._texture:GetVertexColor()
+ return r, g, b, a
+ end
+ --> icon
+ local gmember_icon = function (_object)
+ return _object._icon:GetTexture()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object._texture:GetTexture()
+ end
+ --> font size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.textleft:GetFont()
+ return fontsize
+ end
+ --> font face
+ local gmember_textfont = function (_object)
+ local fontface = _object.textleft:GetFont()
+ return fontface
+ end
+ --> font color
+ local gmember_textcolor = function (_object)
+ return _object.textleft:GetTextColor()
+ end
+ --> alpha
+ local gmember_alpha= function (_object)
+ return _object:GetAlpha()
+ end
+
+ BarMetaFunctions.GetMembers = BarMetaFunctions.GetMembers or {}
+ BarMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ BarMetaFunctions.GetMembers ["shown"] = gmember_shown
+ BarMetaFunctions.GetMembers ["width"] = gmember_width
+ BarMetaFunctions.GetMembers ["height"] = gmember_height
+ BarMetaFunctions.GetMembers ["value"] = gmember_value
+ BarMetaFunctions.GetMembers ["lefttext"] = gmember_ltext
+ BarMetaFunctions.GetMembers ["righttext"] = gmember_rtext
+ BarMetaFunctions.GetMembers ["color"] = gmember_color
+ BarMetaFunctions.GetMembers ["icon"] = gmember_icon
+ BarMetaFunctions.GetMembers ["texture"] = gmember_texture
+ BarMetaFunctions.GetMembers ["fontsize"] = gmember_textsize
+ BarMetaFunctions.GetMembers ["fontface"] = gmember_textfont
+ BarMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor
+ BarMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias
+ BarMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias
+ BarMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias
+ BarMetaFunctions.GetMembers ["alpha"] = gmember_alpha
+
+ BarMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = BarMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return BarMetaFunctions [_member_requested]
+ end
+
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_shown = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (_value) then
+ return _object:Hide()
+ else
+ return _object:Show()
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.statusbar:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.statusbar:SetHeight (_value)
+ end
+ --> statusbar value
+ local smember_value = function (_object, _value)
+ _object.statusbar:SetValue (_value)
+ return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 16, 0)
+ end
+ --> right text
+ local smember_rtext = function (_object, _value)
+ return _object.textright:SetText (_value)
+ end
+ --> left text
+ local smember_ltext = function (_object, _value)
+ return _object.textleft:SetText (_value)
+ end
+ --> color
+ local smember_color = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+
+ _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
+ _object._texture.original_colors = {_value1, _value2, _value3, _value4}
+ _object.timer_texture:SetVertexColor (_value1, _value2, _value3, _value4)
+
+ _object.timer_textureR:SetVertexColor (_value1, _value2, _value3, _value4)
+
+ return _object._texture:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> background color
+ local smember_backgroundcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> icon
+ local smember_icon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object._icon:SetTexture (_value1)
+ if (_value2) then
+ _object._icon:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object._icon:SetTexture (_value)
+ end
+ return
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object._texture:SetTexture (_value1)
+ _object.timer_texture:SetTexture (_value1)
+ _object.timer_textureR:SetTexture (_value1)
+ if (_value2) then
+ _object._texture:SetTexCoord (_unpack (_value2))
+ _object.timer_texture:SetTexCoord (_unpack (_value2))
+ _object.timer_textureR:SetTexCoord (_unpack (_value2))
+ end
+ else
+ if (_value:find ("\\")) then
+ _object._texture:SetTexture (_value)
+ else
+ local file = SharedMedia:Fetch ("statusbar", _value)
+ if (file) then
+ _object._texture:SetTexture (file)
+ _object.timer_texture:SetTexture (file)
+ _object.timer_textureR:SetTexture (file)
+ else
+ _object._texture:SetTexture (_value)
+ _object.timer_texture:SetTexture (_value)
+ _object.timer_textureR:SetTexture (_value)
+ end
+ end
+ end
+ return
+ end
+ --> background texture
+ local smember_backgroundtexture = function (_object, _value)
+ if (_value:find ("\\")) then
+ _object.background:SetTexture (_value)
+ else
+ local file = SharedMedia:Fetch ("statusbar", _value)
+ if (file) then
+ _object.background:SetTexture (file)
+ else
+ _object.background:SetTexture (_value)
+ end
+ end
+ return
+ end
+ --> font face
+ local smember_textfont = function (_object, _value)
+ DF:SetFontFace (_object.textleft, _value)
+ return DF:SetFontFace (_object.textright, _value)
+ end
+ --> font size
+ local smember_textsize = function (_object, _value)
+ DF:SetFontSize (_object.textleft, _value)
+ return DF:SetFontSize (_object.textright, _value)
+ end
+ --> font color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
+ return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> outline (shadow)
+ local smember_outline = function (_object, _value)
+ DF:SetFontOutline (_object.textleft, _value)
+ return DF:SetFontOutline (_object.textright, _value)
+ end
+ --> alpha
+ local smember_alpha= function (_object, _value)
+ return _object:SetAlpha (_value)
+ end
+
+ BarMetaFunctions.SetMembers = BarMetaFunctions.SetMembers or {}
+ BarMetaFunctions.SetMembers["tooltip"] = smember_tooltip
+ BarMetaFunctions.SetMembers["shown"] = smember_shown
+ BarMetaFunctions.SetMembers["width"] = smember_width
+ BarMetaFunctions.SetMembers["height"] = smember_height
+ BarMetaFunctions.SetMembers["value"] = smember_value
+ BarMetaFunctions.SetMembers["righttext"] = smember_rtext
+ BarMetaFunctions.SetMembers["lefttext"] = smember_ltext
+ BarMetaFunctions.SetMembers["color"] = smember_color
+ BarMetaFunctions.SetMembers["backgroundcolor"] = smember_backgroundcolor
+ BarMetaFunctions.SetMembers["icon"] = smember_icon
+ BarMetaFunctions.SetMembers["texture"] = smember_texture
+ BarMetaFunctions.SetMembers["backgroundtexture"] = smember_backgroundtexture
+ BarMetaFunctions.SetMembers["fontsize"] = smember_textsize
+ BarMetaFunctions.SetMembers["fontface"] = smember_textfont
+ BarMetaFunctions.SetMembers["fontcolor"] = smember_textcolor
+ BarMetaFunctions.SetMembers["textsize"] = smember_textsize --alias
+ BarMetaFunctions.SetMembers["textfont"] = smember_textfont --alias
+ BarMetaFunctions.SetMembers["textcolor"] = smember_textcolor --alias
+ BarMetaFunctions.SetMembers["shadow"] = smember_outline
+ BarMetaFunctions.SetMembers["outline"] = smember_outline --alias
+ BarMetaFunctions.SetMembers["alpha"] = smember_alpha
+
+ BarMetaFunctions.__newindex = function (_table, _key, _value)
+
+ local func = BarMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function BarMetaFunctions:Show()
+ self.statusbar:Show()
+ end
+ function BarMetaFunctions:Hide()
+ self.statusbar:Hide()
+ end
+
+
+--> return color
+ function BarMetaFunctions:GetVertexColor()
+ return self._texture:GetVertexColor()
+ end
+
+--> set value (status bar)
+
+ function BarMetaFunctions:SetValue (value)
+ if (not value) then
+ value = 0
+ end
+ self.statusbar:SetValue (value)
+ self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 16, 0)
+ end
+
+--> set point
+ function BarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+--> set sizes
+ function BarMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.statusbar:SetWidth (w)
+ end
+ if (h) then
+ self.statusbar:SetHeight (h)
+ end
+ end
+
+--> set texture
+ function BarMetaFunctions:SetTexture (texture)
+ self._texture:SetTexture (texture)
+ end
+
+--> set texts
+ function BarMetaFunctions:SetLeftText (text)
+ self.textleft:SetText (text)
+ end
+ function BarMetaFunctions:SetRightText (text)
+ self.textright:SetText (text)
+ end
+
+--> set color
+ function BarMetaFunctions:SetColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+
+ self._texture:SetVertexColor (r, g, b, a)
+ self.statusbar:SetStatusBarColor (r, g, b, a)
+ self._texture.original_colors = {r, g, b, a}
+ end
+
+--> set icons
+ function BarMetaFunctions:SetIcon (texture, ...)
+ self._icon:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = _unpack (...)
+ self._icon:SetTexCoord (L, R, U, D)
+ end
+ end
+
+--> show div
+ function BarMetaFunctions:ShowDiv (bool)
+ if (bool) then
+ self.div:Show()
+ else
+ self.div:Hide()
+ end
+ end
+
+-- tooltip
+ function BarMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function BarMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function BarMetaFunctions:GetFrameLevel()
+ return self.statusbar:GetFrameLevel()
+ end
+ function BarMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.statusbar:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.statusbar:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function BarMetaFunctions:SetFrameStrata()
+ return self.statusbar:GetFrameStrata()
+ end
+ function BarMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.statusbar:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.statusbar:SetFrameStrata (strata)
+ end
+ end
+
+--> container
+ function BarMetaFunctions:SetContainer (container)
+ self.container = container
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ frame.MyObject.background:Show()
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (frame, "tooltip")
+ end
+
+ end
+
+ local OnLeave = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ frame.MyObject.background:Hide()
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+ end
+
+ local OnHide = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnShow = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+ end
+
+ local OnMouseUp = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> timer
+
+ function BarMetaFunctions:OnTimerEnd()
+ local capsule = self
+ local kill = capsule:RunHooksForWidget ("OnTimerEnd", self.widget, capsule)
+ if (kill) then
+ return
+ end
+
+ self.timer_texture:Hide()
+ self.timer_textureR:Hide()
+ self.div_timer:Hide()
+ self:Hide()
+ self.timer = false
+ end
+
+ function BarMetaFunctions:CancelTimerBar (no_timer_end)
+ if (not self.HasTimer) then
+ return
+ end
+ if (self.TimerScheduled) then
+ DF:CancelTimer (self.TimerScheduled)
+ self.TimerScheduled = nil
+ else
+ if (self.statusbar:GetScript ("OnUpdate")) then
+ self.statusbar:SetScript ("OnUpdate", nil)
+ end
+ end
+ self.righttext = ""
+ if (not no_timer_end) then
+ self:OnTimerEnd()
+ end
+ end
+
+ local OnUpdate = function (self, elapsed)
+ --> percent of elapsed
+ local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo
+ if (self.inverse) then
+ self.t:SetWidth (self.total_size * pct)
+ else
+ self.t:SetWidth (self.total_size * abs (pct-1))
+ end
+
+ --> right text
+ self.remaining = self.remaining - elapsed
+ if (self.MyObject.RightTextIsTimer) then
+ self.righttext:SetText (DF:IntegerToTimer (self.remaining))
+ else
+ self.righttext:SetText (_math_floor (self.remaining))
+ end
+
+ if (pct >= 1) then
+ self.righttext:SetText ("")
+ self:SetScript ("OnUpdate", nil)
+ self.MyObject.HasTimer = nil
+ self.MyObject:OnTimerEnd()
+ end
+ end
+
+ function BarMetaFunctions:SetTimer (tempo, end_at)
+
+ if (end_at) then
+ self.statusbar.tempo = end_at - tempo
+ self.statusbar.remaining = end_at - GetTime()
+ self.statusbar.end_timer = end_at
+ else
+ self.statusbar.tempo = tempo
+ self.statusbar.remaining = tempo
+ self.statusbar.end_timer = GetTime() + tempo
+ end
+
+ self.statusbar.total_size = self.statusbar:GetWidth()
+ self.statusbar.inverse = self.BarIsInverse
+
+ self (0)
+
+ self.div_timer:Show()
+ self.background:Show()
+ self:Show()
+
+ if (self.LeftToRight) then
+ self.timer_texture:Hide()
+ self.timer_textureR:Show()
+ self.statusbar.t = self.timer_textureR
+ self.timer_textureR:ClearAllPoints()
+ self.timer_textureR:SetPoint ("right", self.statusbar, "right")
+ self.div_timer:SetPoint ("left", self.timer_textureR, "left", -14, -1)
+ else
+ self.timer_texture:Show()
+ self.timer_textureR:Hide()
+ self.statusbar.t = self.timer_texture
+ self.timer_texture:ClearAllPoints()
+ self.timer_texture:SetPoint ("left", self.statusbar, "left")
+ self.div_timer:SetPoint ("left", self.timer_texture, "right", -16, -1)
+ end
+
+ if (self.BarIsInverse) then
+ self.statusbar.t:SetWidth (1)
+ else
+ self.statusbar.t:SetWidth (self.statusbar.total_size)
+ end
+
+ self.timer = true
+
+ self.HasTimer = true
+ self.TimerScheduled = DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self)
+ end
+
+ function DF:StartTimeBarAnimation (timebar)
+ timebar.TimerScheduled = nil
+ timebar.statusbar:SetScript ("OnUpdate", OnUpdate)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DetailsFrameworkNormalBar_OnCreate (self)
+ self.texture.original_colors = {1, 1, 1, 1}
+ self.background.original_colors = {.3, .3, .3, .3}
+ self.timertexture.original_colors = {.3, .3, .3, .3}
+ return true
+end
+
+local build_statusbar = function (self)
+
+ self:SetSize (300, 14)
+
+ self.background = self:CreateTexture ("$parent_background", "BACKGROUND")
+ self.background:Hide()
+ self.background:SetAllPoints()
+ self.background:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+ self.background:SetVertexColor (.3, .3, .3, .3)
+
+ self.timertexture = self:CreateTexture ("$parent_timerTexture", "ARTWORK")
+ self.timertexture:Hide()
+ self.timertexture:SetSize (300, 14)
+ self.timertexture:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+ self.timertexture:SetPoint ("LEFT", self, "LEFT")
+
+ self.timertextureR = self:CreateTexture ("$parent_timerTextureR", "ARTWORK")
+ self.timertextureR:Hide()
+ self.timertextureR:SetSize (300, 14)
+ self.timertextureR:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+ self.timertextureR:SetPoint ("TOPRIGHT", self, 0, 0)
+ self.timertextureR:SetPoint ("BOTTOMRIGHT", self, 0, 0)
+
+ self.texture = self:CreateTexture ("$parent_statusbarTexture", "ARTWORK")
+ self.texture:SetSize (300, 14)
+ self.texture:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+
+ self:SetStatusBarTexture (self.texture)
+
+ self.icontexture = self:CreateTexture ("$parent_icon", "OVERLAY")
+ self.icontexture:SetSize (14, 14)
+ self.icontexture:SetPoint ("LEFT", self, "LEFT")
+
+ self.sparkmouseover = self:CreateTexture ("$parent_sparkMouseover", "OVERLAY")
+ self.sparkmouseover:SetSize (32, 32)
+ self.sparkmouseover:SetTexture ([[Interface\CastingBar\UI-CastingBar-Spark]])
+ self.sparkmouseover:SetBlendMode ("ADD")
+ self.sparkmouseover:SetPoint ("LEFT", self, "RIGHT", -16, -1)
+ self.sparkmouseover:Hide()
+
+ self.sparktimer = self:CreateTexture ("$parent_sparkTimer", "OVERLAY")
+ self.sparktimer:SetSize (32, 32)
+ self.sparktimer:SetPoint ("LEFT", self.timertexture, "RIGHT", -16, -1)
+ self.sparktimer:SetTexture ([[Interface\CastingBar\UI-CastingBar-Spark]])
+ self.sparktimer:SetBlendMode ("ADD")
+ self.sparktimer:Hide()
+
+ self.lefttext = self:CreateFontString ("$parent_TextLeft", "OVERLAY", "GameFontHighlight")
+ self.lefttext:SetJustifyH ("LEFT")
+ self.lefttext:SetPoint ("LEFT", self.icontexture, "RIGHT", 3, 0)
+ DF:SetFontSize (self.lefttext, 10)
+
+ self.righttext = self:CreateFontString ("$parent_TextRight", "OVERLAY", "GameFontHighlight")
+ self.righttext:SetJustifyH ("LEFT")
+ DF:SetFontSize (self.righttext, 10)
+ self.righttext:SetPoint ("RIGHT", self, "RIGHT", -3, 0)
+
+ DetailsFrameworkNormalBar_OnCreate (self)
+end
+
+function DF:CreateBar (parent, texture, w, h, value, member, name)
+ return DF:NewBar (parent, parent, name, member, w, h, value, texture)
+end
+
+function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
+
+ if (not name) then
+ name = "DetailsFrameworkBarNumber" .. DF.BarNameCounter
+ DF.BarNameCounter = DF.BarNameCounter + 1
+
+ elseif (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ elseif (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local BarObject = {type = "bar", dframework = true}
+
+ if (member) then
+ parent [member] = BarObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ value = value or 0
+ w = w or 150
+ h = h or 14
+
+ --> default members:
+ --> misc
+ BarObject.locked = false
+
+ BarObject.container = container
+
+ --> create widgets
+ BarObject.statusbar = CreateFrame ("statusbar", name, parent)
+ DF:Mixin (BarObject.statusbar, DF.WidgetFunctions)
+
+ build_statusbar (BarObject.statusbar)
+
+ BarObject.widget = BarObject.statusbar
+
+ if (not APIBarFunctions) then
+ APIBarFunctions = true
+ local idx = getmetatable (BarObject.statusbar).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not BarMetaFunctions [funcName]) then
+ BarMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.statusbar:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ BarObject.statusbar:SetHeight (h)
+ BarObject.statusbar:SetWidth (w)
+ BarObject.statusbar:SetFrameLevel (parent:GetFrameLevel()+1)
+ BarObject.statusbar:SetMinMaxValues (0, 100)
+ BarObject.statusbar:SetValue (value or 50)
+ BarObject.statusbar.MyObject = BarObject
+
+ BarObject.timer_texture = _G [name .. "_timerTexture"]
+ BarObject.timer_texture:SetWidth (w)
+ BarObject.timer_texture:SetHeight (h)
+
+ BarObject.timer_textureR = _G [name .. "_timerTextureR"]
+ BarObject.timer_textureR:Hide()
+
+ BarObject._texture = _G [name .. "_statusbarTexture"]
+ BarObject.background = _G [name .. "_background"]
+ BarObject._icon = _G [name .. "_icon"]
+ BarObject.textleft = _G [name .. "_TextLeft"]
+ BarObject.textright = _G [name .. "_TextRight"]
+ BarObject.div = _G [name .. "_sparkMouseover"]
+ BarObject.div_timer = _G [name .. "_sparkTimer"]
+
+ --> hooks
+ BarObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnMouseDown = {},
+ OnMouseUp = {},
+ OnTimerEnd = {},
+ }
+
+ BarObject.statusbar:SetScript ("OnEnter", OnEnter)
+ BarObject.statusbar:SetScript ("OnLeave", OnLeave)
+ BarObject.statusbar:SetScript ("OnHide", OnHide)
+ BarObject.statusbar:SetScript ("OnShow", OnShow)
+ BarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
+ BarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
+
+ --> set class
+ _setmetatable (BarObject, BarMetaFunctions)
+
+ --> set texture
+ if (texture_name) then
+ smember_texture (BarObject, texture_name)
+ end
+
+ return BarObject
+end --endd
diff --git a/libs/DF/normal_bar.xml b/libs/DF/normal_bar.xml
new file mode 100644
index 0000000..48a54d5
--- /dev/null
+++ b/libs/DF/normal_bar.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/libs/DF/panel.lua b/libs/DF/panel.lua
new file mode 100644
index 0000000..9cdfe57
--- /dev/null
+++ b/libs/DF/panel.lua
@@ -0,0 +1,9376 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+--> lua locals
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APIFrameFunctions
+
+do
+ local metaPrototype = {
+ WidgetType = "panel",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["panel"]] = _G [DF.GlobalWidgetControlNames ["panel"]] or metaPrototype
+end
+
+local PanelMetaFunctions = _G [DF.GlobalWidgetControlNames ["panel"]]
+
+--> mixin for options functions
+DF.OptionsFunctions = {
+ SetOption = function (self, optionName, optionValue)
+ if (self.options) then
+ self.options [optionName] = optionValue
+ else
+ self.options = {}
+ self.options [optionName] = optionValue
+ end
+
+ if (self.OnOptionChanged) then
+ DF:Dispatch (self.OnOptionChanged, self, optionName, optionValue)
+ end
+ end,
+
+ GetOption = function (self, optionName)
+ return self.options and self.options [optionName]
+ end,
+
+ GetAllOptions = function (self)
+ if (self.options) then
+ local optionsTable = {}
+ for key, _ in pairs (self.options) do
+ optionsTable [#optionsTable + 1] = key
+ end
+ return optionsTable
+ else
+ return {}
+ end
+ end,
+
+ BuildOptionsTable = function (self, defaultOptions, userOptions)
+ self.options = self.options or {}
+ DF.table.deploy (self.options, userOptions or {})
+ DF.table.deploy (self.options, defaultOptions or {})
+ end
+}
+
+--> default options for the frame layout
+local default_framelayout_options = {
+ amount_per_line = 4,
+ start_x = 2,
+ start_y = -2,
+ is_vertical = false,
+ grow_right = true, --on vertical (if not grow next line left)
+ grow_down = true, --on horizontal (if not grow next line up)
+ anchor_to_child = false, --if true set the point to the previous frame instead of coordinate
+ anchor_point = "topleft",
+ anchor_relative = "topleft",
+ offset_x = 100,
+ offset_y = 20,
+ width = 0, --if bigger than 0, it will set the value
+ height = 0,
+ break_if_hidden = true, --stop if encounters a hidden frame
+}
+
+--> mixin for frame layout
+DF.LayoutFrame = {
+ AnchorTo = function (self, anchor, point, x, y)
+ if (point == "top") then
+ self:ClearAllPoints()
+ self:SetPoint ("bottom", anchor, "top", x or 0, y or 0)
+
+ elseif (point == "bottom") then
+ self:ClearAllPoints()
+ self:SetPoint ("top", anchor, "bottom", x or 0, y or 0)
+
+ elseif (point == "left") then
+ self:ClearAllPoints()
+ self:SetPoint ("right", anchor, "left", x or 0, y or 0)
+
+ elseif (point == "right") then
+ self:ClearAllPoints()
+ self:SetPoint ("left", anchor, "right", x or 0, y or 0)
+ end
+ end,
+
+ ArrangeFrames = function (self, frameList, options)
+
+ if (not frameList) then
+ frameList = {self:GetChildren()}
+ end
+
+ options = options or {}
+ DF.table.deploy (options, default_framelayout_options)
+
+ local breakLine = options.amount_per_line + 1
+ local currentX, currentY = options.start_x, options.start_y
+ local offsetX, offsetY = options.offset_x, options.offset_y
+ local anchorPoint = options.anchor_point
+ local anchorAt = options.anchor_relative
+ local latestFrame = self
+ local firstRowFrame = frameList [1]
+
+ if (options.is_vertical) then
+ for i = 1, #frameList do
+ local thisFrame = frameList [i]
+ if (options.break_if_hidden and not thisFrame:IsShown()) then
+ break
+ end
+ thisFrame:ClearAllPoints()
+
+ if (options.anchor_to_child) then
+ if (i == breakLine) then
+ if (options.grow_right) then
+ thisFrame:SetPoint ("topleft", firstRowFrame, "topright", offsetX, 0)
+ else
+ thisFrame:SetPoint ("topright", firstRowFrame, "topleft", -offsetX, 0)
+ end
+ firstRowFrame = thisFrame
+ latestFrame = thisFrame
+ breakLine = breakLine + options.amount_per_line
+ else
+ thisFrame:SetPoint (anchorPoint, latestFrame, i == 1 and "topleft" or anchorAt, offsetX, i == 1 and 0 or offsetY)
+ latestFrame = thisFrame
+ end
+ else
+ if (i == breakLine) then
+ if (options.grow_right) then
+ currentX = currentX + offsetX
+ else
+ currentX = currentX - offsetX
+ end
+ currentY = options.start_y
+
+ firstRowFrame = thisFrame
+ breakLine = breakLine + options.amount_per_line
+ end
+
+ thisFrame:SetPoint (anchorPoint, self, anchorAt, currentX, currentY)
+ currentY = currentY - offsetY
+ end
+ end
+
+ else
+ for i = 1, #frameList do
+ local thisFrame = frameList [i]
+ if (options.break_if_hidden and not thisFrame:IsShown()) then
+ break
+ end
+ thisFrame:ClearAllPoints()
+
+ if (options.anchor_to_child) then
+ if (i == breakLine) then
+ if (options.grow_down) then
+ thisFrame:SetPoint ("topleft", firstRowFrame, "bottomleft", 0, -offsetY)
+ else
+ thisFrame:SetPoint ("bottomleft", firstRowFrame, "topleft", 0, offsetY)
+ end
+ firstRowFrame = thisFrame
+ latestFrame = thisFrame
+ breakLine = breakLine + options.amount_per_line
+ else
+ thisFrame:SetPoint (anchorPoint, latestFrame, i == 1 and "topleft" or anchorAt, i == 1 and 0 or offsetX, offsetY)
+ latestFrame = thisFrame
+ end
+ else
+ if (i == breakLine) then
+ if (options.grow_down) then
+ currentY = currentY - offsetY
+ else
+ currentY = currentY + offsetY
+ end
+ currentX = options.start_x
+
+ firstRowFrame = thisFrame
+ breakLine = breakLine + options.amount_per_line
+ end
+
+ thisFrame:SetPoint (anchorPoint, self, anchorAt, currentX, currentY)
+ currentX = currentX + offsetX
+ end
+ end
+ end
+ end
+
+}
+
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ PanelMetaFunctions.__call = function (_table, value)
+ --> nothing to do
+ return true
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> backdrop color
+ local gmember_color = function (_object)
+ return _object.frame:GetBackdropColor()
+ end
+ --> backdrop table
+ local gmember_backdrop = function (_object)
+ return _object.frame:GetBackdrop()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.frame:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.frame:GetHeight()
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "is_locked")
+ end
+
+ PanelMetaFunctions.GetMembers = PanelMetaFunctions.GetMembers or {}
+ PanelMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ PanelMetaFunctions.GetMembers ["shown"] = gmember_shown
+ PanelMetaFunctions.GetMembers ["color"] = gmember_color
+ PanelMetaFunctions.GetMembers ["backdrop"] = gmember_backdrop
+ PanelMetaFunctions.GetMembers ["width"] = gmember_width
+ PanelMetaFunctions.GetMembers ["height"] = gmember_height
+ PanelMetaFunctions.GetMembers ["locked"] = gmember_locked
+
+ PanelMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = PanelMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return PanelMetaFunctions [_member_requested]
+ end
+
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> backdrop color
+ local smember_color = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.frame:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.frame:SetHeight (_value)
+ end
+
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ _object.frame:SetMovable (false)
+ return _rawset (_object, "is_locked", true)
+ else
+ _object.frame:SetMovable (true)
+ _rawset (_object, "is_locked", false)
+ return
+ end
+ end
+
+ --> backdrop
+ local smember_backdrop = function (_object, _value)
+ return _object.frame:SetBackdrop (_value)
+ end
+
+ --> close with right button
+ local smember_right_close = function (_object, _value)
+ return _rawset (_object, "rightButtonClose", _value)
+ end
+
+ PanelMetaFunctions.SetMembers = PanelMetaFunctions.SetMembers or {}
+ PanelMetaFunctions.SetMembers["tooltip"] = smember_tooltip
+ PanelMetaFunctions.SetMembers["show"] = smember_show
+ PanelMetaFunctions.SetMembers["hide"] = smember_hide
+ PanelMetaFunctions.SetMembers["color"] = smember_color
+ PanelMetaFunctions.SetMembers["backdrop"] = smember_backdrop
+ PanelMetaFunctions.SetMembers["width"] = smember_width
+ PanelMetaFunctions.SetMembers["height"] = smember_height
+ PanelMetaFunctions.SetMembers["locked"] = smember_locked
+ PanelMetaFunctions.SetMembers["close_with_right"] = smember_right_close
+
+ PanelMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = PanelMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> right click to close
+ function PanelMetaFunctions:CreateRightClickLabel (textType, w, h, close_text)
+ local text
+ w = w or 20
+ h = h or 20
+
+ if (close_text) then
+ text = close_text
+ else
+ if (textType) then
+ textType = string.lower (textType)
+ if (textType == "short") then
+ text = "close window"
+ elseif (textType == "medium") then
+ text = "close window"
+ elseif (textType == "large") then
+ text = "close window"
+ end
+ else
+ text = "close window"
+ end
+ end
+
+ return DF:NewLabel (self, _, "$parentRightMouseToClose", nil, "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:"..w..":"..h..":0:1:512:512:8:70:328:409|t " .. text)
+ end
+
+--> show & hide
+ function PanelMetaFunctions:Show()
+ self.frame:Show()
+
+ end
+ function PanelMetaFunctions:Hide()
+ self.frame:Hide()
+
+ end
+
+-- setpoint
+ function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function PanelMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.frame:SetWidth (w)
+ end
+ if (h) then
+ self.frame:SetHeight (h)
+ end
+ end
+
+-- clear
+ function PanelMetaFunctions:HideWidgets()
+ for widgetName, widgetSelf in pairs (self) do
+ if (type (widgetSelf) == "table" and widgetSelf.dframework) then
+ widgetSelf:Hide()
+ end
+ end
+ end
+
+-- backdrop
+ function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
+
+ if (_type (background) == "boolean" and not background) then
+ return self.frame:SetBackdrop (nil)
+
+ elseif (_type (background) == "table") then
+ self.frame:SetBackdrop (background)
+
+ else
+ local currentBackdrop = self.frame:GetBackdrop() or {edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", tile=true, tileSize=16, edgeSize=16, insets={left=1, right=0, top=0, bottom=0}}
+ currentBackdrop.bgFile = background or currentBackdrop.bgFile
+ currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
+ currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
+ currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
+ currentBackdrop.tile = tile or currentBackdrop.tile
+ currentBackdrop.insets.left = left or currentBackdrop.insets.left
+ currentBackdrop.insets.right = left or currentBackdrop.insets.right
+ currentBackdrop.insets.top = left or currentBackdrop.insets.top
+ currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
+ self.frame:SetBackdrop (currentBackdrop)
+ end
+ end
+
+-- backdropcolor
+ function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
+ else
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
+ end
+ end
+
+-- border color
+ function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
+ end
+
+-- tooltip
+ function PanelMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function PanelMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function PanelMetaFunctions:GetFrameLevel()
+ return self.widget:GetFrameLevel()
+ end
+ function PanelMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.widget:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.widget:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function PanelMetaFunctions:SetFrameStrata()
+ return self.widget:GetFrameStrata()
+ end
+ function PanelMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.widget:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.widget:SetFrameStrata (strata)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:SetType ("tooltip")
+ GameCooltip2:SetColor ("main", "transparent")
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:SetOwner (frame)
+ GameCooltip2:ShowCooltip()
+ end
+ end
+
+ local OnLeave = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ end
+
+ local OnHide = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnShow = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.container == UIParent) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.isMoving = true
+ frame:StartMoving()
+ end
+
+ elseif (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+
+
+ end
+
+ local OnMouseUp = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (button == "RightButton" and frame.MyObject.rightButtonClose) then
+ frame.MyObject:Hide()
+ end
+
+ if (frame.MyObject.container == UIParent) then
+ if (frame.isMoving) then
+ frame:StopMovingOrSizing()
+ frame.isMoving = false
+ end
+ else
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+function DF:CreatePanel (parent, w, h, backdrop, backdropcolor, bordercolor, member, name)
+ return DF:NewPanel (parent, parent, name, member, w, h, backdrop, backdropcolor, bordercolor)
+end
+
+function DF:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
+
+ if (not name) then
+ name = "DetailsFrameworkPanelNumber" .. DF.PanelCounter
+ DF.PanelCounter = DF.PanelCounter + 1
+
+ elseif (not parent) then
+ parent = UIParent
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local PanelObject = {type = "panel", dframework = true}
+
+ if (member) then
+ parent [member] = PanelObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> misc
+ PanelObject.is_locked = true
+ PanelObject.container = container
+ PanelObject.rightButtonClose = false
+
+ PanelObject.frame = CreateFrame ("frame", name, parent)
+ PanelObject.frame:SetSize (100, 100)
+ PanelObject.frame.Gradient = {
+ ["OnEnter"] = {0.3, 0.3, 0.3, 0.5},
+ ["OnLeave"] = {0.9, 0.7, 0.7, 1}
+ }
+ PanelObject.frame:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\DialogFrame\UI-DialogBox-Border", edgeSize = 10, tileSize = 64, tile = true})
+
+ PanelObject.widget = PanelObject.frame
+
+ if (not APIFrameFunctions) then
+ APIFrameFunctions = {}
+ local idx = getmetatable (PanelObject.frame).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not PanelMetaFunctions [funcName]) then
+ PanelMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.frame:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ PanelObject.frame:SetWidth (w or 100)
+ PanelObject.frame:SetHeight (h or 100)
+
+ PanelObject.frame.MyObject = PanelObject
+
+ PanelObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnMouseDown = {},
+ OnMouseUp = {},
+ }
+
+ --> hooks
+ PanelObject.frame:SetScript ("OnEnter", OnEnter)
+ PanelObject.frame:SetScript ("OnLeave", OnLeave)
+ PanelObject.frame:SetScript ("OnHide", OnHide)
+ PanelObject.frame:SetScript ("OnShow", OnShow)
+ PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
+ PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
+
+ _setmetatable (PanelObject, PanelMetaFunctions)
+
+ if (backdrop) then
+ PanelObject:SetBackdrop (backdrop)
+ elseif (_type (backdrop) == "boolean") then
+ PanelObject.frame:SetBackdrop (nil)
+ end
+
+ if (backdropcolor) then
+ PanelObject:SetBackdropColor (backdropcolor)
+ end
+
+ if (bordercolor) then
+ PanelObject:SetBackdropBorderColor (bordercolor)
+ end
+
+ return PanelObject
+end
+
+------------fill panel
+
+local button_on_enter = function (self)
+ self.MyObject._icon:SetBlendMode ("ADD")
+ if (self.MyObject.onenter_func) then
+ pcall (self.MyObject.onenter_func, self.MyObject)
+ end
+end
+local button_on_leave = function (self)
+ self.MyObject._icon:SetBlendMode ("BLEND")
+ if (self.MyObject.onleave_func) then
+ pcall (self.MyObject.onleave_func, self.MyObject)
+ end
+end
+
+local add_row = function (self, t, need_update)
+ local index = #self.rows+1
+
+ local thisrow = DF:NewPanel (self, self, "$parentHeader_" .. self._name .. index, nil, 1, 20)
+ thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]}
+ thisrow.color = "silver"
+ thisrow.type = t.type
+ thisrow.func = t.func
+ thisrow.name = t.name
+ thisrow.notext = t.notext
+ thisrow.icon = t.icon
+ thisrow.iconalign = t.iconalign
+
+ thisrow.hidden = t.hidden or false
+
+ thisrow.onenter = t.onenter
+ thisrow.onleave = t.onleave
+
+ local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text")
+ text:SetPoint ("left", thisrow, "left", 2, 0)
+ text:SetText (t.name)
+
+ tinsert (self._raw_rows, t)
+ tinsert (self.rows, thisrow)
+
+ if (need_update) then
+ self:AlignRows()
+ end
+end
+
+local align_rows = function (self)
+
+ local rows_shown = 0
+ for index, row in ipairs (self.rows) do
+ if (not row.hidden) then
+ rows_shown = rows_shown + 1
+ end
+ end
+
+ local cur_width = 0
+ local row_width = self._width / rows_shown
+
+ local sindex = 1
+
+ wipe (self._anchors)
+
+ for index, row in ipairs (self.rows) do
+ if (not row.hidden) then
+ if (self._autowidth) then
+ if (self._raw_rows [index].width) then
+ row.width = self._raw_rows [index].width
+ else
+ row.width = row_width
+ end
+ row:SetPoint ("topleft", self, "topleft", cur_width, 0)
+ tinsert (self._anchors, cur_width)
+ cur_width = cur_width + row_width + 1
+ else
+ row:SetPoint ("topleft", self, "topleft", cur_width, 0)
+ row.width = self._raw_rows [index].width
+ tinsert (self._anchors, cur_width)
+ cur_width = cur_width + self._raw_rows [index].width + 1
+ end
+
+ row:Show()
+
+ local type = row.type
+
+ if (type == "text") then
+ for i = 1, #self.scrollframe.lines do
+ local line = self.scrollframe.lines [i]
+ local text = tremove (line.text_available)
+ if (not text) then
+ self:CreateRowText (line)
+ text = tremove (line.text_available)
+ end
+ tinsert (line.text_inuse, text)
+ text:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
+ text:SetWidth (row.width)
+
+ DF:SetFontSize (text, row.textsize or 10)
+ text:SetJustifyH (row.textalign or "left")
+ end
+ elseif (type == "entry") then
+ for i = 1, #self.scrollframe.lines do
+ local line = self.scrollframe.lines [i]
+ local entry = tremove (line.entry_available)
+ if (not entry) then
+ self:CreateRowEntry (line)
+ entry = tremove (line.entry_available)
+ end
+ tinsert (line.entry_inuse, entry)
+ entry:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
+ if (sindex == rows_shown) then
+ entry:SetWidth (row.width - 25)
+ else
+ entry:SetWidth (row.width)
+ end
+ entry.func = row.func
+
+ entry.onenter_func = nil
+ entry.onleave_func = nil
+
+ if (row.onenter) then
+ entry.onenter_func = row.onenter
+ end
+ if (row.onleave) then
+ entry.onleave_func = row.onleave
+ end
+ end
+ elseif (type == "button") then
+ for i = 1, #self.scrollframe.lines do
+ local line = self.scrollframe.lines [i]
+ local button = tremove (line.button_available)
+ if (not button) then
+ self:CreateRowButton (line)
+ button = tremove (line.button_available)
+ end
+ tinsert (line.button_inuse, button)
+ button:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
+ if (sindex == rows_shown) then
+ button:SetWidth (row.width - 25)
+ else
+ button:SetWidth (row.width)
+ end
+
+ if (row.icon) then
+ button._icon.texture = row.icon
+ button._icon:ClearAllPoints()
+ if (row.iconalign) then
+ if (row.iconalign == "center") then
+ button._icon:SetPoint ("center", button, "center")
+ elseif (row.iconalign == "right") then
+ button._icon:SetPoint ("right", button, "right")
+ end
+ else
+ button._icon:SetPoint ("left", button, "left")
+ end
+ end
+
+ if (row.name and not row.notext) then
+ button._text:SetPoint ("left", button._icon, "right", 2, 0)
+ button._text.text = row.name
+ end
+
+ button.onenter_func = nil
+ button.onleave_func = nil
+
+ if (row.onenter) then
+ button.onenter_func = row.onenter
+ end
+ if (row.onleave) then
+ button.onleave_func = row.onleave
+ end
+
+ end
+ elseif (type == "icon") then
+ for i = 1, #self.scrollframe.lines do
+ local line = self.scrollframe.lines [i]
+ local icon = tremove (line.icon_available)
+ if (not icon) then
+ self:CreateRowIcon (line)
+ icon = tremove (line.icon_available)
+ end
+ tinsert (line.icon_inuse, icon)
+ icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
+ icon.func = row.func
+ end
+
+ elseif (type == "texture") then
+ for i = 1, #self.scrollframe.lines do
+ local line = self.scrollframe.lines [i]
+ local texture = tremove (line.texture_available)
+ if (not texture) then
+ self:CreateRowTexture (line)
+ texture = tremove (line.texture_available)
+ end
+ tinsert (line.texture_inuse, texture)
+ texture:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
+ end
+
+ end
+
+ sindex = sindex + 1
+ else
+ row:Hide()
+ end
+ end
+
+ if (#self.rows > 0) then
+ if (self._autowidth) then
+ self.rows [#self.rows]:SetWidth (row_width - rows_shown + 1)
+ else
+ self.rows [#self.rows]:SetWidth (self._raw_rows [rows_shown].width - rows_shown + 1)
+ end
+ end
+
+ self.showing_amt = rows_shown
+end
+
+local update_rows = function (self, updated_rows)
+
+ for i = 1, #updated_rows do
+ local t = updated_rows [i]
+ local raw = self._raw_rows [i]
+
+ if (not raw) then
+ self:AddRow (t)
+ else
+ raw.name = t.name
+ raw.hidden = t.hidden or false
+ raw.textsize = t.textsize
+ raw.textalign = t.textalign
+
+ local widget = self.rows [i]
+ widget.name = t.name
+ widget.textsize = t.textsize
+ widget.textalign = t.textalign
+ widget.hidden = t.hidden or false
+
+ --
+ widget.onenter = t.onenter
+ widget.onleave = t.onleave
+ --
+
+ widget.text:SetText (t.name)
+ DF:SetFontSize (widget.text, raw.textsize or 10)
+ widget.text:SetJustifyH (raw.textalign or "left")
+
+ end
+ end
+
+ for i = #updated_rows+1, #self._raw_rows do
+ local raw = self._raw_rows [i]
+ local widget = self.rows [i]
+ raw.hidden = true
+ widget.hidden = true
+ end
+
+ for index, row in ipairs (self.scrollframe.lines) do
+ for i = #row.text_inuse, 1, -1 do
+ tinsert (row.text_available, tremove (row.text_inuse, i))
+ end
+ for i = 1, #row.text_available do
+ row.text_available[i]:Hide()
+ end
+
+ for i = #row.entry_inuse, 1, -1 do
+ tinsert (row.entry_available, tremove (row.entry_inuse, i))
+ end
+ for i = 1, #row.entry_available do
+ row.entry_available[i]:Hide()
+ end
+
+ for i = #row.button_inuse, 1, -1 do
+ tinsert (row.button_available, tremove (row.button_inuse, i))
+ end
+ for i = 1, #row.button_available do
+ row.button_available[i]:Hide()
+ end
+
+ for i = #row.icon_inuse, 1, -1 do
+ tinsert (row.icon_available, tremove (row.icon_inuse, i))
+ end
+ for i = 1, #row.icon_available do
+ row.icon_available[i]:Hide()
+ end
+
+ for i = #row.texture_inuse, 1, -1 do
+ tinsert (row.texture_available, tremove (row.texture_inuse, i))
+ end
+ for i = 1, #row.texture_available do
+ row.texture_available[i]:Hide()
+ end
+ end
+
+ self.current_header = updated_rows
+
+ self:AlignRows()
+
+end
+
+local create_panel_text = function (self, row)
+ row.text_total = row.text_total + 1
+ local text = DF:NewLabel (row, nil, self._name .. "$parentLabel" .. row.text_total, "text" .. row.text_total)
+ tinsert (row.text_available, text)
+end
+
+local create_panel_entry = function (self, row)
+ row.entry_total = row.entry_total + 1
+ local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. row.entry_total, "entry", 120, 20)
+ editbox.align = "left"
+
+ editbox:SetHook ("OnEnterPressed", function()
+ editbox.widget.focuslost = true
+ editbox:ClearFocus()
+ editbox.func (editbox.index, editbox.text)
+ return true
+ end)
+
+ editbox:SetHook ("OnEnter", function()
+ if (editbox.onenter_func) then
+ pcall (editbox.onenter_func, editbox)
+ end
+ end)
+ editbox:SetHook ("OnLeave", function()
+ if (editbox.onleave_func) then
+ pcall (editbox.onleave_func, editbox)
+ end
+ end)
+
+ editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
+ editbox:SetBackdropColor (1, 1, 1, 0.1)
+ editbox:SetBackdropBorderColor (1, 1, 1, 0.1)
+ editbox.editbox.current_bordercolor = {1, 1, 1, 0.1}
+
+ editbox:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+
+ tinsert (row.entry_available, editbox)
+end
+
+local create_panel_button = function (self, row)
+ row.button_total = row.button_total + 1
+ local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
+
+ --> create icon and the text
+ local icon = DF:NewImage (button, nil, 20, 20)
+ local text = DF:NewLabel (button)
+
+ button._icon = icon
+ button._text = text
+
+ button:SetHook ("OnEnter", button_on_enter)
+ button:SetHook ("OnLeave", button_on_leave)
+
+ tinsert (row.button_available, button)
+end
+
+local icon_onclick = function (texture, iconbutton)
+ iconbutton._icon.texture = texture
+ iconbutton.func (iconbutton.index, texture)
+end
+
+local create_panel_icon = function (self, row)
+ row.icon_total = row.icon_total + 1
+ local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. row.icon_total, "iconbutton", 22, 20)
+ iconbutton:InstallCustomTexture()
+
+ iconbutton:SetHook ("OnEnter", button_on_enter)
+ iconbutton:SetHook ("OnLeave", button_on_leave)
+
+ iconbutton:SetHook ("OnMouseUp", function()
+ DF:IconPick (icon_onclick, true, iconbutton)
+ return true
+ end)
+
+ local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. row.icon_total)
+ iconbutton._icon = icon
+
+ icon:SetPoint ("center", iconbutton, "center", 0, 0)
+
+ tinsert (row.icon_available, iconbutton)
+end
+
+local create_panel_texture = function (self, row)
+ row.texture_total = row.texture_total + 1
+ local texture = DF:NewImage (row, nil, 20, 20, "artwork", nil, "_icon" .. row.texture_total, "$parentIcon" .. row.texture_total)
+ tinsert (row.texture_available, texture)
+end
+
+local set_fill_function = function (self, func)
+ self._fillfunc = func
+end
+local set_total_function = function (self, func)
+ self._totalfunc = func
+end
+local drop_header_function = function (self)
+ wipe (self.rows)
+end
+
+local fillpanel_update_size = function (self, elapsed)
+ local panel = self.MyObject
+
+ panel._width = panel:GetWidth()
+ panel._height = panel:GetHeight()
+
+ panel:UpdateRowAmount()
+ if (panel.current_header) then
+ update_rows (panel, panel.current_header)
+ end
+ panel:Refresh()
+
+ self:SetScript ("OnUpdate", nil)
+end
+
+ -- ~fillpanel
+ --alias
+function DF:CreateFillPanel (parent, rows, w, h, total_lines, fill_row, autowidth, options, member, name)
+ return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
+end
+
+function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
+
+ local panel = DF:NewPanel (parent, parent, name, member, w, h)
+ panel.backdrop = nil
+
+ options = options or {rowheight = 20}
+ panel.rows = {}
+
+ panel.AddRow = add_row
+ panel.AlignRows = align_rows
+ panel.UpdateRows = update_rows
+ panel.CreateRowText = create_panel_text
+ panel.CreateRowEntry = create_panel_entry
+ panel.CreateRowButton = create_panel_button
+ panel.CreateRowIcon = create_panel_icon
+ panel.CreateRowTexture = create_panel_texture
+ panel.SetFillFunction = set_fill_function
+ panel.SetTotalFunction = set_total_function
+ panel.DropHeader = drop_header_function
+
+ panel._name = name
+ panel._width = w
+ panel._height = h
+ panel._raw_rows = {}
+ panel._anchors = {}
+ panel._fillfunc = fill_row
+ panel._totalfunc = total_lines
+ panel._autowidth = autowidth
+
+ panel:SetScript ("OnSizeChanged", function()
+ panel:SetScript ("OnUpdate", fillpanel_update_size)
+ end)
+
+ for index, t in ipairs (rows) do
+ panel.AddRow (panel, t)
+ end
+
+ local refresh_fillbox = function (self)
+
+ local offset = FauxScrollFrame_GetOffset (self)
+ local filled_lines = panel._totalfunc (panel)
+
+ for index = 1, #self.lines do
+
+ local row = self.lines [index]
+ if (index <= filled_lines) then
+
+ local real_index = index + offset
+ local results = panel._fillfunc (real_index, panel)
+
+ if (results and results [1]) then
+ row:Show()
+
+ local text, entry, button, icon, texture = 1, 1, 1, 1, 1
+
+ for index, t in ipairs (panel.rows) do
+ if (not t.hidden) then
+ if (t.type == "text") then
+ local fontstring = row.text_inuse [text]
+ text = text + 1
+ fontstring:SetText (results [index])
+ fontstring.index = real_index
+ fontstring:Show()
+
+ elseif (t.type == "entry") then
+ local entrywidget = row.entry_inuse [entry]
+ entry = entry + 1
+ entrywidget.index = real_index
+
+ if (type (results [index]) == "table") then
+ entrywidget:SetText (results [index].text)
+ entrywidget.id = results [index].id
+ entrywidget.data1 = results [index].data1
+ entrywidget.data2 = results [index].data2
+ else
+ entrywidget:SetText (results [index])
+ end
+
+ entrywidget:SetCursorPosition(0)
+
+ entrywidget:Show()
+
+ elseif (t.type == "button") then
+ local buttonwidget = row.button_inuse [button]
+ button = button + 1
+ buttonwidget.index = real_index
+
+ if (type (results [index]) == "table") then
+ if (results [index].text) then
+ buttonwidget:SetText (results [index].text)
+ end
+
+ if (results [index].icon) then
+ buttonwidget._icon:SetTexture (results [index].icon)
+ end
+
+ if (results [index].func) then
+ local func = function()
+ t.func (real_index, results [index].value)
+ panel:Refresh()
+ end
+ buttonwidget:SetClickFunction (func)
+ else
+ local func = function()
+ t.func (real_index, index)
+ panel:Refresh()
+ end
+ buttonwidget:SetClickFunction (func)
+ end
+
+ buttonwidget.id = results [index].id
+ buttonwidget.data1 = results [index].data1
+ buttonwidget.data2 = results [index].data2
+
+ else
+ local func = function()
+ t.func (real_index, index)
+ panel:Refresh()
+ end
+ buttonwidget:SetClickFunction (func)
+ buttonwidget:SetText (results [index])
+ end
+
+ buttonwidget:Show()
+
+ elseif (t.type == "icon") then
+ local iconwidget = row.icon_inuse [icon]
+ icon = icon + 1
+
+ iconwidget.line = index
+ iconwidget.index = real_index
+
+ --print (index, results [index])
+ if (type (results [index]) == "string") then
+ local result = results [index]:gsub (".-%\\", "")
+ iconwidget._icon.texture = results [index]
+ else
+ iconwidget._icon:SetTexture (results [index])
+ end
+
+ iconwidget:Show()
+
+ elseif (t.type == "texture") then
+ local texturewidget = row.texture_inuse [texture]
+ texture = texture + 1
+
+ texturewidget.line = index
+ texturewidget.index = real_index
+
+ if (type (results [index]) == "string") then
+ local result = results [index]:gsub (".-%\\", "")
+ texturewidget.texture = results [index]
+ else
+ texturewidget:SetTexture (results [index])
+ end
+
+ texturewidget:Show()
+ end
+ end
+ end
+
+ else
+ row:Hide()
+ end
+ else
+ row:Hide()
+ end
+ end
+ end
+
+ function panel:Refresh()
+ if (type (panel._totalfunc) == "boolean") then
+ --> not yet initialized
+ return
+ end
+ local filled_lines = panel._totalfunc (panel)
+ local scroll_total_lines = #panel.scrollframe.lines
+ local line_height = options.rowheight
+ refresh_fillbox (panel.scrollframe)
+ FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
+ panel.scrollframe:Show()
+ end
+
+ local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
+ scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end)
+ scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21)
+ scrollframe:SetPoint ("topright", panel.widget, "topright", -23, -21)
+ scrollframe:SetPoint ("bottomleft", panel.widget, "bottomleft")
+ scrollframe:SetPoint ("bottomright", panel.widget, "bottomright", -23, 0)
+ scrollframe:SetSize (w, h)
+ panel.scrollframe = scrollframe
+ scrollframe.lines = {}
+
+ DF:ReskinSlider (scrollframe)
+
+ --create lines
+ function panel:UpdateRowAmount()
+ local size = options.rowheight
+ local amount = math.floor (((panel._height-21) / size))
+
+ for i = #scrollframe.lines+1, amount do
+ local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget)
+ row:SetSize (1, size)
+ row.color = {1, 1, 1, .2}
+
+ row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
+
+ if (i%2 == 0) then
+ row:SetBackdropColor (.5, .5, .5, 0.2)
+ else
+ row:SetBackdropColor (1, 1, 1, 0.00)
+ end
+
+ row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
+ row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
+ tinsert (scrollframe.lines, row)
+
+ row.text_available = {}
+ row.text_inuse = {}
+ row.text_total = 0
+
+ row.entry_available = {}
+ row.entry_inuse = {}
+ row.entry_total = 0
+
+ row.button_available = {}
+ row.button_inuse = {}
+ row.button_total = 0
+
+ row.icon_available = {}
+ row.icon_inuse = {}
+ row.icon_total = 0
+
+ row.texture_available = {}
+ row.texture_inuse = {}
+ row.texture_total = 0
+ end
+ end
+ panel:UpdateRowAmount()
+
+ panel.AlignRows (panel)
+
+ return panel
+end
+
+
+------------color pick
+local color_pick_func = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = OpacitySliderFrame:GetValue()
+ ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
+end
+local color_pick_func_cancel = function()
+ ColorPickerFrame:SetColorRGB (unpack (ColorPickerFrame.previousValues))
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = OpacitySliderFrame:GetValue()
+ ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
+end
+
+function DF:ColorPick (frame, r, g, b, alpha, callback)
+
+ ColorPickerFrame:ClearAllPoints()
+ ColorPickerFrame:SetPoint ("bottomleft", frame, "topright", 0, 0)
+
+ ColorPickerFrame.dcallback = callback
+ ColorPickerFrame.dframe = frame
+
+ ColorPickerFrame.func = color_pick_func
+ ColorPickerFrame.opacityFunc = color_pick_func
+ ColorPickerFrame.cancelFunc = color_pick_func_cancel
+
+ ColorPickerFrame.opacity = alpha
+ ColorPickerFrame.hasOpacity = alpha and true
+
+ ColorPickerFrame.previousValues = {r, g, b}
+ ColorPickerFrame:SetParent (UIParent)
+ ColorPickerFrame:SetFrameStrata ("tooltip")
+ ColorPickerFrame:SetColorRGB (r, g, b)
+ ColorPickerFrame:Show()
+
+end
+
+------------icon pick
+function DF:IconPick (callback, close_when_select, param1, param2)
+
+ if (not DF.IconPickFrame) then
+
+ local string_lower = string.lower
+
+ DF.IconPickFrame = CreateFrame ("frame", "DetailsFrameworkIconPickFrame", UIParent)
+ tinsert (UISpecialFrames, "DetailsFrameworkIconPickFrame")
+ DF.IconPickFrame:SetFrameStrata ("TOOLTIP")
+
+ DF.IconPickFrame:SetPoint ("center", UIParent, "center")
+ DF.IconPickFrame:SetWidth (350)
+ DF.IconPickFrame:SetHeight (277)
+ DF.IconPickFrame:EnableMouse (true)
+ DF.IconPickFrame:SetMovable (true)
+
+ DF:CreateTitleBar (DF.IconPickFrame, "Icon Picker")
+
+ DF.IconPickFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+
+ DF.IconPickFrame:SetBackdropBorderColor (0, 0, 0)
+ DF.IconPickFrame:SetBackdropColor (24/255, 24/255, 24/255, .8)
+ DF.IconPickFrame:SetFrameLevel (5000)
+
+ DF.IconPickFrame:SetScript ("OnMouseDown", function (self)
+ if (not self.isMoving) then
+ DF.IconPickFrame:StartMoving()
+ self.isMoving = true
+ end
+ end)
+
+ DF.IconPickFrame:SetScript ("OnMouseUp", function (self)
+ if (self.isMoving) then
+ DF.IconPickFrame:StopMovingOrSizing()
+ self.isMoving = nil
+ end
+ end)
+
+ DF.IconPickFrame.emptyFunction = function() end
+ DF.IconPickFrame.callback = DF.IconPickFrame.emptyFunction
+
+ DF.IconPickFrame.preview = CreateFrame ("frame", nil, UIParent)
+ DF.IconPickFrame.preview:SetFrameStrata ("tooltip")
+ DF.IconPickFrame.preview:SetFrameLevel (6001)
+ DF.IconPickFrame.preview:SetSize (76, 76)
+
+ local preview_image_bg = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
+ preview_image_bg:SetDrawLayer ("background", 0)
+ preview_image_bg:SetAllPoints (DF.IconPickFrame.preview)
+ preview_image_bg:SetColorTexture (0, 0, 0)
+
+ local preview_image = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
+ preview_image:SetAllPoints (DF.IconPickFrame.preview)
+
+ DF.IconPickFrame.preview.icon = preview_image
+ DF.IconPickFrame.preview:Hide()
+
+ --serach
+ DF.IconPickFrame.searchLabel = DF:NewLabel (DF.IconPickFrame, nil, "$parentSearchBoxLabel", nil, "search:", font, size, color)
+ DF.IconPickFrame.searchLabel:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12, -36)
+ DF.IconPickFrame.searchLabel:SetTemplate (DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+
+ DF.IconPickFrame.search = DF:NewTextEntry (DF.IconPickFrame, nil, "$parentSearchBox", nil, 140, 20)
+ DF.IconPickFrame.search:SetPoint ("left", DF.IconPickFrame.searchLabel, "right", 2, 0)
+ DF.IconPickFrame.search:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+
+ DF.IconPickFrame.search:SetHook ("OnTextChanged", function()
+ DF.IconPickFrame.searching = DF.IconPickFrame.search:GetText()
+ if (DF.IconPickFrame.searching == "") then
+ DF.IconPickFrameScroll:Show()
+ DF.IconPickFrame.searching = nil
+ DF.IconPickFrame.updateFunc()
+ else
+ DF.IconPickFrameScroll:Hide()
+ FauxScrollFrame_SetOffset (DF.IconPickFrame, 1)
+ DF.IconPickFrame.last_filter_index = 1
+ DF.IconPickFrame.updateFunc()
+ end
+ end)
+
+ --manually enter the icon path
+ DF.IconPickFrame.customIcon = DF:CreateLabel (DF.IconPickFrame, "Icon Path:", DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ DF.IconPickFrame.customIcon:SetPoint ("bottomleft", DF.IconPickFrame, "bottomleft", 12, 16)
+
+ DF.IconPickFrame.customIconEntry = DF:CreateTextEntry (DF.IconPickFrame, function()end, 200, 20, "CustomIconEntry", _, _, DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ DF.IconPickFrame.customIconEntry:SetPoint ("left", DF.IconPickFrame.customIcon, "right", 2, 0)
+
+ DF.IconPickFrame.customIconEntry:SetHook ("OnTextChanged", function()
+ DF.IconPickFrame.preview:SetPoint ("bottom", DF.IconPickFrame.customIconEntry.widget, "top", 0, 2)
+ DF.IconPickFrame.preview.icon:SetTexture (DF.IconPickFrame.customIconEntry:GetText())
+ DF.IconPickFrame.preview:Show()
+ end)
+
+ DF.IconPickFrame.customIconEntry:SetHook ("OnEnter", function()
+ DF.IconPickFrame.preview:SetPoint ("bottom", DF.IconPickFrame.customIconEntry.widget, "top", 0, 2)
+ DF.IconPickFrame.preview.icon:SetTexture (DF.IconPickFrame.customIconEntry:GetText())
+ DF.IconPickFrame.preview:Show()
+ end)
+
+ --> close button
+ local close_button = CreateFrame ("button", nil, DF.IconPickFrame, "UIPanelCloseButton")
+ close_button:SetWidth (32)
+ close_button:SetHeight (32)
+ close_button:SetPoint ("TOPRIGHT", DF.IconPickFrame, "TOPRIGHT", -8, -7)
+ close_button:SetFrameLevel (close_button:GetFrameLevel()+2)
+ close_button:SetAlpha (0) --just hide, it is used below
+
+ --> accept custom icon button
+ local accept_custom_icon = function()
+ local path = DF.IconPickFrame.customIconEntry:GetText()
+
+ DF:QuickDispatch (DF.IconPickFrame.callback, path, DF.IconPickFrame.param1, DF.IconPickFrame.param2)
+
+ if (DF.IconPickFrame.click_close) then
+ close_button:Click()
+ end
+ end
+
+ DF.IconPickFrame.customIconAccept = DF:CreateButton (DF.IconPickFrame, accept_custom_icon, 82, 20, "Accept", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ DF.IconPickFrame.customIconAccept:SetPoint ("left", DF.IconPickFrame.customIconEntry, "right", 2, 0)
+
+ --fill with icons
+
+ local MACRO_ICON_FILENAMES = {}
+ local SPELLNAMES_CACHE = {}
+
+ DF.IconPickFrame:SetScript ("OnShow", function()
+
+ MACRO_ICON_FILENAMES [1] = "INV_MISC_QUESTIONMARK"
+ local index = 2
+
+ for i = 1, GetNumSpellTabs() do
+ local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo (i)
+ offset = offset + 1
+ local tabEnd = offset + numSpells
+
+ for j = offset, tabEnd - 1 do
+ --to get spell info by slot, you have to pass in a pet argument
+ local spellType, ID = GetSpellBookItemInfo (j, "player")
+ if (spellType ~= "FUTURESPELL") then
+ MACRO_ICON_FILENAMES [index] = GetSpellBookItemTexture (j, "player") or 0
+ index = index + 1
+
+ elseif (spellType == "FLYOUT") then
+ local _, _, numSlots, isKnown = GetFlyoutInfo (ID)
+ if (isKnown and numSlots > 0) then
+ for k = 1, numSlots do
+ local spellID, overrideSpellID, isKnown = GetFlyoutSlotInfo (ID, k)
+ if (isKnown) then
+ MACRO_ICON_FILENAMES [index] = GetSpellTexture (spellID) or 0
+ index = index + 1
+ end
+ end
+ end
+
+ end
+ end
+ end
+
+ GetLooseMacroItemIcons (MACRO_ICON_FILENAMES)
+ GetLooseMacroIcons (MACRO_ICON_FILENAMES)
+ GetMacroIcons (MACRO_ICON_FILENAMES)
+ GetMacroItemIcons (MACRO_ICON_FILENAMES)
+
+ --reset the custom icon text entry
+ DF.IconPickFrame.customIconEntry:SetText ("")
+ --reset the search text entry
+ DF.IconPickFrame.search:SetText ("")
+ end)
+
+ DF.IconPickFrame:SetScript ("OnHide", function()
+ wipe (MACRO_ICON_FILENAMES)
+ DF.IconPickFrame.preview:Hide()
+ collectgarbage()
+ end)
+
+ DF.IconPickFrame.buttons = {}
+
+ local OnClickFunction = function (self)
+
+ DF:QuickDispatch (DF.IconPickFrame.callback, self.icon:GetTexture(), DF.IconPickFrame.param1, DF.IconPickFrame.param2)
+
+ if (DF.IconPickFrame.click_close) then
+ close_button:Click()
+ end
+ end
+
+ local onenter = function (self)
+ DF.IconPickFrame.preview:SetPoint ("bottom", self, "top", 0, 2)
+ DF.IconPickFrame.preview.icon:SetTexture (self.icon:GetTexture())
+ DF.IconPickFrame.preview:Show()
+ self.icon:SetBlendMode ("ADD")
+ end
+ local onleave = function (self)
+ DF.IconPickFrame.preview:Hide()
+ self.icon:SetBlendMode ("BLEND")
+ end
+
+ local backdrop = {bgFile = DF.folder .. "background", tile = true, tileSize = 16,
+ insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10}
+
+ for i = 0, 9 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..(i+1), DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..(i+1).."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i+1
+
+ newcheck:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12 + (i*30), -60)
+ newcheck:SetID (i+1)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 11, 20 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 21, 30 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 31, 40 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 41, 50 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 51, 60 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2) image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+
+ local scroll = CreateFrame ("ScrollFrame", "DetailsFrameworkIconPickFrameScroll", DF.IconPickFrame, "ListScrollFrameTemplate")
+ DF:ReskinSlider (scroll)
+
+ local ChecksFrame_Update = function (self)
+
+ local numMacroIcons = #MACRO_ICON_FILENAMES
+ local macroPopupIcon, macroPopupButton
+ local macroPopupOffset = FauxScrollFrame_GetOffset (scroll)
+ local index
+
+ local texture
+ local filter
+ if (DF.IconPickFrame.searching) then
+ filter = string_lower (DF.IconPickFrame.searching)
+ end
+
+ local pool
+ local shown = 0
+
+ if (filter and filter ~= "") then
+ if (#SPELLNAMES_CACHE == 0) then
+ --build name cache
+ local GetSpellInfo = GetSpellInfo
+ for i = 1, #MACRO_ICON_FILENAMES do
+ local spellName = GetSpellInfo (MACRO_ICON_FILENAMES [i])
+ SPELLNAMES_CACHE [i] = spellName or "NULL"
+ end
+ end
+
+ --do the filter
+ pool = {}
+ for i = 1, #SPELLNAMES_CACHE do
+ if (SPELLNAMES_CACHE [i]:find (filter)) then
+ pool [#pool+1] = MACRO_ICON_FILENAMES [i]
+ shown = shown + 1
+ end
+ end
+ else
+ shown = nil
+ end
+
+ if (not pool) then
+ pool = MACRO_ICON_FILENAMES
+ end
+
+ for i = 1, 60 do
+ macroPopupIcon = _G ["DetailsFrameworkIconPickFrameButton"..i.."Icon"]
+ macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..i]
+ index = (macroPopupOffset * 10) + i
+ texture = pool [index]
+ if ( index <= numMacroIcons and texture ) then
+
+ if (type (texture) == "number") then
+ macroPopupIcon:SetTexture (texture)
+ else
+ macroPopupIcon:SetTexture ("INTERFACE\\ICONS\\" .. texture)
+ end
+
+ macroPopupIcon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
+ macroPopupButton.IconID = index
+ macroPopupButton:Show()
+ else
+ macroPopupButton:Hide()
+ end
+ end
+
+ pool = nil
+
+ -- Scrollbar stuff
+ FauxScrollFrame_Update (scroll, ceil ((shown or numMacroIcons) / 10) , 5, 20 )
+ end
+
+ DF.IconPickFrame.updateFunc = ChecksFrame_Update
+
+ scroll:SetPoint ("topleft", DF.IconPickFrame, "topleft", -18, -58)
+ scroll:SetWidth (330)
+ scroll:SetHeight (178)
+ scroll:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scroll, offset, 20, ChecksFrame_Update) end)
+ scroll.update = ChecksFrame_Update
+ DF.IconPickFrameScroll = scroll
+ DF.IconPickFrame:Hide()
+
+ end
+
+ DF.IconPickFrame.param1, DF.IconPickFrame.param2 = param1, param2
+
+ DF.IconPickFrame:Show()
+ DF.IconPickFrameScroll.update (DF.IconPickFrameScroll)
+ DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
+ DF.IconPickFrame.click_close = close_when_select
+
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+function DF:ShowPanicWarning (text)
+ if (not DF.PanicWarningWindow) then
+ DF.PanicWarningWindow = CreateFrame ("frame", "DetailsFrameworkPanicWarningWindow", UIParent)
+ DF.PanicWarningWindow:SetHeight (80)
+ DF.PanicWarningWindow:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ DF.PanicWarningWindow:SetBackdropColor (1, 0, 0, 0.2)
+ DF.PanicWarningWindow:SetPoint ("topleft", UIParent, "topleft", 0, -250)
+ DF.PanicWarningWindow:SetPoint ("topright", UIParent, "topright", 0, -250)
+
+ DF.PanicWarningWindow.text = DF.PanicWarningWindow:CreateFontString (nil, "overlay", "GameFontNormal")
+ DF.PanicWarningWindow.text:SetPoint ("center", DF.PanicWarningWindow, "center")
+ DF.PanicWarningWindow.text:SetTextColor (1, 0.6, 0)
+ end
+
+ DF.PanicWarningWindow.text:SetText (text)
+ DF.PanicWarningWindow:Show()
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+local simple_panel_mouse_down = function (self, button)
+ if (button == "RightButton") then
+ if (self.IsMoving) then
+ self.IsMoving = false
+ self:StopMovingOrSizing()
+ if (self.db and self.db.position) then
+ DF:SavePositionOnScreen (self)
+ end
+ end
+ if (not self.DontRightClickClose) then
+ self:Hide()
+ end
+ return
+ end
+ if (not self.IsMoving and not self.IsLocked) then
+ self.IsMoving = true
+ self:StartMoving()
+ end
+end
+local simple_panel_mouse_up = function (self, button)
+ if (self.IsMoving) then
+ self.IsMoving = false
+ self:StopMovingOrSizing()
+ if (self.db and self.db.position) then
+ DF:SavePositionOnScreen (self)
+ end
+ end
+end
+local simple_panel_settitle = function (self, title)
+ self.Title:SetText (title)
+end
+
+local simple_panel_close_click = function (self)
+ self:GetParent():GetParent():Hide()
+end
+
+local SimplePanel_frame_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}
+local SimplePanel_frame_backdrop_color = {0, 0, 0, 0.9}
+local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
+
+--with_label was making the frame stay in place while its parent moves
+--the slider was anchoring to with_label and here here were anchoring the slider again
+function DF:CreateScaleBar (frame, config)
+ local scaleBar, text = DF:CreateSlider (frame, 120, 14, 0.6, 1.6, 0.1, config.scale, true, "ScaleBar", nil, "Scale:", DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE"), DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ --scaleBar:SetPoint ("right", frame.Close, "left", -26, 0)
+ text:SetPoint ("topleft", frame, "topleft", 12, -7)
+ scaleBar:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
+ scaleBar.OnValueChanged = function (_, _, value)
+ config.scale = value
+ if (not scaleBar.IsValueChanging) then
+ frame:SetScale (config.scale)
+ end
+ end
+ scaleBar:SetHook ("OnMouseUp", function()
+ frame:SetScale (config.scale)
+ end)
+
+ scaleBar:SetAlpha (0.2)
+
+ return scaleBar
+end
+
+local no_options = {}
+function DF:CreateSimplePanel (parent, w, h, title, name, panel_options, db)
+
+ if (db and name and not db [name]) then
+ db [name] = {scale = 1}
+ end
+
+ if (not name) then
+ name = "DetailsFrameworkSimplePanel" .. DF.SimplePanelCounter
+ DF.SimplePanelCounter = DF.SimplePanelCounter + 1
+ end
+ if (not parent) then
+ parent = UIParent
+ end
+
+ panel_options = panel_options or no_options
+
+ local f = CreateFrame ("frame", name, UIParent)
+ f:SetSize (w or 400, h or 250)
+ f:SetPoint ("center", UIParent, "center", 0, 0)
+ f:SetFrameStrata ("FULLSCREEN")
+ f:EnableMouse()
+ f:SetMovable (true)
+ f:SetBackdrop (SimplePanel_frame_backdrop)
+ f:SetBackdropColor (unpack (SimplePanel_frame_backdrop_color))
+ f:SetBackdropBorderColor (unpack (SimplePanel_frame_backdrop_border_color))
+
+ f.DontRightClickClose = panel_options.DontRightClickClose
+
+ if (not panel_options.NoTUISpecialFrame) then
+ tinsert (UISpecialFrames, name)
+ end
+
+ local title_bar = CreateFrame ("frame", name .. "TitleBar", f)
+ title_bar:SetPoint ("topleft", f, "topleft", 2, -3)
+ title_bar:SetPoint ("topright", f, "topright", -2, -3)
+ title_bar:SetHeight (20)
+ title_bar:SetBackdrop (SimplePanel_frame_backdrop)
+ title_bar:SetBackdropColor (.2, .2, .2, 1)
+ title_bar:SetBackdropBorderColor (0, 0, 0, 1)
+ f.TitleBar = title_bar
+
+ local close = CreateFrame ("button", name and name .. "CloseButton", title_bar)
+ close:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
+ close:SetSize (16, 16)
+ close:SetNormalTexture (DF.folder .. "icons")
+ close:SetHighlightTexture (DF.folder .. "icons")
+ close:SetPushedTexture (DF.folder .. "icons")
+ close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:SetAlpha (0.7)
+ close:SetScript ("OnClick", simple_panel_close_click)
+ f.Close = close
+
+ local title_string = title_bar:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
+ title_string:SetTextColor (.8, .8, .8, 1)
+ title_string:SetText (title or "")
+ f.Title = title_string
+
+ if (panel_options.UseScaleBar and db [name]) then
+ DF:CreateScaleBar (f, db [name])
+ f:SetScale (db [name].scale)
+ end
+
+ f.Title:SetPoint ("center", title_bar, "center")
+ f.Close:SetPoint ("right", title_bar, "right", -2, 0)
+
+ f:SetScript ("OnMouseDown", simple_panel_mouse_down)
+ f:SetScript ("OnMouseUp", simple_panel_mouse_up)
+
+ f.SetTitle = simple_panel_settitle
+
+ return f
+end
+
+local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
+edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
+
+local Panel1PxOnClickClose = function (self)
+ self:GetParent():Hide()
+end
+local Panel1PxOnToggleLock = function (self)
+ if (self.IsLocked) then
+ self.IsLocked = false
+ self:SetMovable (true)
+ self:EnableMouse (true)
+ self.Lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ self.Lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ self.Lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ if (self.OnUnlock) then
+ self:OnUnlock()
+ end
+ if (self.db) then
+ self.db.IsLocked = self.IsLocked
+ end
+ else
+ self.IsLocked = true
+ self:SetMovable (false)
+ self:EnableMouse (false)
+ self.Lock:GetNormalTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ self.Lock:GetHighlightTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ self.Lock:GetPushedTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ if (self.OnLock) then
+ self:OnLock()
+ end
+ if (self.db) then
+ self.db.IsLocked = self.IsLocked
+ end
+ end
+end
+local Panel1PxOnClickLock = function (self)
+ local f = self:GetParent()
+ Panel1PxOnToggleLock (f)
+end
+local Panel1PxSetTitle = function (self, text)
+ self.Title:SetText (text or "")
+end
+
+local Panel1PxSetLocked= function (self, lock_state)
+ if (type (lock_state) ~= "boolean") then
+ return
+ end
+ if (lock_state) then
+ -- lock it
+ self.IsLocked = false
+ Panel1PxOnClickLock (self.Lock)
+ else
+ -- unlockit
+ self.IsLocked = true
+ Panel1PxOnClickLock (self.Lock)
+ end
+end
+
+local Panel1PxReadConfig = function (self)
+ local db = self.db
+ if (db) then
+ db.IsLocked = db.IsLocked or false
+ self.IsLocked = db.IsLocked
+ db.position = db.position or {x = 0, y = 0}
+ db.position.x = db.position.x or 0
+ db.position.y = db.position.y or 0
+ DF:RestoreFramePosition (self)
+ end
+end
+
+function DF:SavePositionOnScreen (frame)
+ if (frame.db and frame.db.position) then
+ local x, y = DF:GetPositionOnScreen (frame)
+ --print ("saving...", x, y, frame:GetName())
+ if (x and y) then
+ frame.db.position.x, frame.db.position.y = x, y
+ end
+ end
+end
+
+function DF:GetPositionOnScreen (frame)
+ local xOfs, yOfs = frame:GetCenter()
+ if (not xOfs) then
+ return
+ end
+ local scale = frame:GetEffectiveScale()
+ local UIscale = UIParent:GetScale()
+ xOfs = xOfs*scale - GetScreenWidth()*UIscale/2
+ yOfs = yOfs*scale - GetScreenHeight()*UIscale/2
+ return xOfs/UIscale, yOfs/UIscale
+end
+
+function DF:RestoreFramePosition (frame)
+ if (frame.db and frame.db.position) then
+ local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
+ frame:ClearAllPoints()
+ frame.db.position.x = frame.db.position.x or 0
+ frame.db.position.y = frame.db.position.y or 0
+ frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
+ end
+end
+
+local Panel1PxSavePosition= function (self)
+ DF:SavePositionOnScreen (self)
+end
+
+local Panel1PxHasPosition = function (self)
+ local db = self.db
+ if (db) then
+ if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then
+ return true
+ end
+ end
+end
+
+function DF:Create1PxPanel (parent, w, h, title, name, config, title_anchor, no_special_frame)
+ local f = CreateFrame ("frame", name, parent or UIParent)
+ f:SetSize (w or 100, h or 75)
+ f:SetPoint ("center", UIParent, "center")
+
+ if (name and not no_special_frame) then
+ tinsert (UISpecialFrames, name)
+ end
+
+ f:SetScript ("OnMouseDown", simple_panel_mouse_down)
+ f:SetScript ("OnMouseUp", simple_panel_mouse_up)
+
+ f:SetBackdrop (Panel1PxBackdrop)
+ f:SetBackdropColor (0, 0, 0, 0.5)
+
+ f.IsLocked = (config and config.IsLocked ~= nil and config.IsLocked) or false
+ f:SetMovable (true)
+ f:EnableMouse (true)
+ f:SetUserPlaced (true)
+
+ f.db = config
+ --print (config.position.x, config.position.x)
+ Panel1PxReadConfig (f)
+
+ local close = CreateFrame ("button", name and name .. "CloseButton", f)
+ close:SetSize (16, 16)
+ close:SetNormalTexture (DF.folder .. "icons")
+ close:SetHighlightTexture (DF.folder .. "icons")
+ close:SetPushedTexture (DF.folder .. "icons")
+ close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:SetAlpha (0.7)
+
+ local lock = CreateFrame ("button", name and name .. "LockButton", f)
+ lock:SetSize (16, 16)
+ lock:SetNormalTexture (DF.folder .. "icons")
+ lock:SetHighlightTexture (DF.folder .. "icons")
+ lock:SetPushedTexture (DF.folder .. "icons")
+ lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:SetAlpha (0.7)
+
+ close:SetPoint ("topright", f, "topright", -3, -3)
+ lock:SetPoint ("right", close, "left", 3, 0)
+
+ close:SetScript ("OnClick", Panel1PxOnClickClose)
+ lock:SetScript ("OnClick", Panel1PxOnClickLock)
+
+ local title_string = f:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
+ title_string:SetPoint ("topleft", f, "topleft", 5, -5)
+ title_string:SetText (title or "")
+
+ if (title_anchor) then
+ if (title_anchor == "top") then
+ title_string:ClearAllPoints()
+ title_string:SetPoint ("bottomleft", f, "topleft", 0, 0)
+ close:ClearAllPoints()
+ close:SetPoint ("bottomright", f, "topright", 0, 0)
+ end
+ f.title_anchor = title_anchor
+ end
+
+ f.SetTitle = Panel1PxSetTitle
+ f.Title = title_string
+ f.Lock = lock
+ f.Close = close
+ f.HasPosition = Panel1PxHasPosition
+ f.SavePosition = Panel1PxSavePosition
+
+ f.IsLocked = not f.IsLocked
+ f.SetLocked = Panel1PxSetLocked
+ Panel1PxOnToggleLock (f)
+
+ return f
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~prompt
+function DF:ShowPromptPanel (message, func_true, func_false)
+
+ if (not DF.prompt_panel) then
+ local f = CreateFrame ("frame", "DetailsFrameworkPromptSimple", UIParent)
+ f:SetSize (400, 80)
+ f:SetFrameStrata ("DIALOG")
+ f:SetPoint ("center", UIParent, "center", 0, 300)
+ f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ f:SetBackdropColor (0, 0, 0, 0.8)
+ f:SetBackdropBorderColor (0, 0, 0, 1)
+ tinsert (UISpecialFrames, "DetailsFrameworkPromptSimple")
+
+ DF:CreateTitleBar (f, "Prompt!")
+ DF:ApplyStandardBackdrop (f)
+
+ local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ prompt:SetPoint ("top", f, "top", 0, -28)
+ prompt:SetJustifyH ("center")
+ f.prompt = prompt
+
+ local button_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+
+ local button_true = DF:CreateButton (f, nil, 60, 20, "Yes", nil, nil, nil, nil, nil, nil, options_dropdown_template)
+ button_true:SetPoint ("bottomright", f, "bottomright", -5, 5)
+ f.button_true = button_true
+
+ local button_false = DF:CreateButton (f, nil, 60, 20, "No", nil, nil, nil, nil, nil, nil, options_dropdown_template)
+ button_false:SetPoint ("bottomleft", f, "bottomleft", 5, 5)
+ f.button_false = button_false
+
+ button_true:SetClickFunction (function()
+ local my_func = button_true.true_function
+ if (my_func) then
+ local okey, errormessage = pcall (my_func, true)
+ if (not okey) then
+ print ("error:", errormessage)
+ end
+ f:Hide()
+ end
+ end)
+
+ button_false:SetClickFunction (function()
+ local my_func = button_false.false_function
+ if (my_func) then
+ local okey, errormessage = pcall (my_func, true)
+ if (not okey) then
+ print ("error:", errormessage)
+ end
+ f:Hide()
+ end
+ end)
+
+ f:Hide()
+ DF.promtp_panel = f
+ end
+
+ assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.")
+
+ DF.promtp_panel.prompt:SetText (message)
+ DF.promtp_panel.button_true.true_function = func_true
+ DF.promtp_panel.button_false.false_function = func_false
+
+ DF.promtp_panel:Show()
+end
+
+
+function DF:ShowTextPromptPanel (message, callback)
+
+ if (not DF.text_prompt_panel) then
+
+ local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
+ f:SetSize (400, 120)
+ f:SetFrameStrata ("FULLSCREEN")
+ f:SetPoint ("center", UIParent, "center", 0, 100)
+ f:EnableMouse (true)
+ f:SetMovable (true)
+ f:RegisterForDrag ("LeftButton")
+ f:SetScript ("OnDragStart", function() f:StartMoving() end)
+ f:SetScript ("OnDragStop", function() f:StopMovingOrSizing() end)
+ f:SetScript ("OnMouseDown", function (self, button) if (button == "RightButton") then f.EntryBox:ClearFocus() f:Hide() end end)
+ tinsert (UISpecialFrames, "DetailsFrameworkPrompt")
+
+ DF:CreateTitleBar (f, "Prompt!")
+ DF:ApplyStandardBackdrop (f)
+
+ local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ prompt:SetPoint ("top", f, "top", 0, -25)
+ prompt:SetJustifyH ("center")
+ prompt:SetSize (360, 36)
+ f.prompt = prompt
+
+ local button_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+
+ local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, options_dropdown_template)
+ textbox:SetPoint ("topleft", f, "topleft", 10, -60)
+ f.EntryBox = textbox
+
+ local button_true = DF:CreateButton (f, nil, 60, 20, "Okey", nil, nil, nil, nil, nil, nil, options_dropdown_template)
+ button_true:SetPoint ("bottomright", f, "bottomright", -10, 5)
+ f.button_true = button_true
+
+ local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus() f:Hide() end, 60, 20, "Cancel", nil, nil, nil, nil, nil, nil, options_dropdown_template)
+ button_false:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
+ f.button_false = button_false
+
+ local executeCallback = function()
+ local my_func = button_true.true_function
+ if (my_func) then
+ local okey, errormessage = pcall (my_func, textbox:GetText())
+ textbox:ClearFocus()
+ if (not okey) then
+ print ("error:", errormessage)
+ end
+ f:Hide()
+ end
+ end
+
+ button_true:SetClickFunction (function()
+ executeCallback()
+ end)
+
+ textbox:SetHook ("OnEnterPressed", function()
+ executeCallback()
+ end)
+
+ f:Hide()
+ DF.text_prompt_panel = f
+ end
+
+ DF.text_prompt_panel:Show()
+
+ DetailsFrameworkPrompt.EntryBox:SetText ("")
+ DF.text_prompt_panel.prompt:SetText (message)
+ DF.text_prompt_panel.button_true.true_function = callback
+ DF.text_prompt_panel.textbox:SetFocus (true)
+
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> options button -- ~options
+function DF:CreateOptionsButton (parent, callback, name)
+
+ local b = CreateFrame ("button", name, parent)
+ b:SetSize (14, 14)
+ b:SetNormalTexture (DF.folder .. "icons")
+ b:SetHighlightTexture (DF.folder .. "icons")
+ b:SetPushedTexture (DF.folder .. "icons")
+ b:GetNormalTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:GetHighlightTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:GetPushedTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:SetAlpha (0.7)
+
+ b:SetScript ("OnClick", callback)
+ b:SetScript ("OnEnter", function (self)
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine ("Options")
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end)
+ b:SetScript ("OnLeave", function (self)
+ GameCooltip2:Hide()
+ end)
+
+ return b
+
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> feedback panel -- ~feedback
+
+function DF:CreateFeedbackButton (parent, callback, name)
+ local b = CreateFrame ("button", name, parent)
+ b:SetSize (12, 13)
+ b:SetNormalTexture (DF.folder .. "mail")
+ b:SetPushedTexture (DF.folder .. "mail")
+ b:SetHighlightTexture (DF.folder .. "mail")
+
+ b:SetScript ("OnClick", callback)
+ b:SetScript ("OnEnter", function (self)
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine ("Send Feedback")
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end)
+ b:SetScript ("OnLeave", function (self)
+ GameCooltip2:Hide()
+ end)
+
+ return b
+end
+
+local backdrop_fb_line = {bgFile = DF.folder .. "background", edgeFile = DF.folder .. "border_3",
+tile = true, tileSize = 64, edgeSize = 8, insets = {left = 2, right = 2, top = 2, bottom = 2}}
+
+local on_enter_feedback = function (self)
+ self:SetBackdropColor (1, 1, 0, 0.5)
+end
+local on_leave_feedback = function (self)
+ self:SetBackdropColor (0, 0, 0, 0.3)
+end
+
+local on_click_feedback = function (self)
+
+ local feedback_link_textbox = DF.feedback_link_textbox
+
+ if (not feedback_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.feedback_link_textbox = editbox
+ feedback_link_textbox = editbox
+ end
+
+ feedback_link_textbox.link = self.link
+ feedback_link_textbox.text = self.link
+ feedback_link_textbox:Show()
+
+ feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
+
+ feedback_link_textbox:HighlightText()
+
+ feedback_link_textbox:SetFocus()
+ feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local feedback_get_fb_line = function (self)
+
+ local line = self.feedback_lines [self.next_feedback]
+ if (not line) then
+ line = CreateFrame ("frame", "AddonFeedbackPanelFB" .. self.next_feedback, self)
+ line:SetBackdrop (backdrop_fb_line)
+ line:SetBackdropColor (0, 0, 0, 0.3)
+ line:SetSize (390, 42)
+ line:SetPoint ("topleft", self.feedback_anchor, "bottomleft", 0, -5 + ((self.next_feedback-1) * 46 * -1))
+ line:SetScript ("OnEnter", on_enter_feedback)
+ line:SetScript ("OnLeave", on_leave_feedback)
+ line:SetScript ("OnMouseUp", on_click_feedback)
+
+ line.icon = line:CreateTexture (nil, "overlay")
+ line.icon:SetSize (90, 36)
+
+ line.desc = line:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+
+ line.icon:SetPoint ("left", line, "left", 5, 0)
+ line.desc:SetPoint ("left", line.icon, "right", 5, 0)
+
+ local arrow = line:CreateTexture (nil, "overlay")
+ arrow:SetTexture ([[Interface\Buttons\JumpUpArrow]])
+ arrow:SetRotation (-1.55)
+ arrow:SetPoint ("right", line, "right", -5, 0)
+
+ self.feedback_lines [self.next_feedback] = line
+ end
+
+ self.next_feedback = self.next_feedback + 1
+
+ return line
+end
+
+local on_click_feedback = function (self)
+
+ local feedback_link_textbox = DF.feedback_link_textbox
+
+ if (not feedback_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.feedback_link_textbox = editbox
+ feedback_link_textbox = editbox
+ end
+
+ feedback_link_textbox.link = self.link
+ feedback_link_textbox.text = self.link
+ feedback_link_textbox:Show()
+
+ feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
+
+ feedback_link_textbox:HighlightText()
+
+ feedback_link_textbox:SetFocus()
+ feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local on_enter_addon = function (self)
+ if (self.tooltip) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine ("|cFFFFFF00" .. self.name .. "|r")
+ GameCooltip2:AddLine ("")
+ GameCooltip2:AddLine (self.tooltip)
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end
+ self.icon:SetBlendMode ("ADD")
+end
+local on_leave_addon = function (self)
+ if (self.tooltip) then
+ GameCooltip2:Hide()
+ end
+ self.icon:SetBlendMode ("BLEND")
+end
+local on_click_addon = function (self)
+ local addon_link_textbox = DF.addon_link_textbox
+
+ if (not addon_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 128, 64)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.addon_link_textbox = editbox
+ addon_link_textbox = editbox
+ end
+
+ addon_link_textbox.link = self.link
+ addon_link_textbox.text = self.link
+ addon_link_textbox:Show()
+
+ addon_link_textbox:SetPoint ("topleft", self.icon, "topleft", 0, 0)
+
+ addon_link_textbox:HighlightText()
+
+ addon_link_textbox:SetFocus()
+ addon_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local feedback_get_addons_line = function (self)
+ local line = self.addons_lines [self.next_addons]
+ if (not line) then
+
+ line = CreateFrame ("frame", "AddonFeedbackPanelSA" .. self.next_addons, self)
+ line:SetSize (128, 64)
+
+ if (self.next_addons == 1) then
+ line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5)
+ elseif (self.next_addons_line_break == self.next_addons) then
+ line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5 + floor (self.next_addons_line_break/3) * 66 * -1)
+ self.next_addons_line_break = self.next_addons_line_break + 3
+ else
+ local previous = self.addons_lines [self.next_addons - 1]
+ line:SetPoint ("topleft", previous, "topright", 2, 0)
+ end
+
+ line:SetScript ("OnEnter", on_enter_addon)
+ line:SetScript ("OnLeave", on_leave_addon)
+ line:SetScript ("OnMouseUp", on_click_addon)
+
+ line.icon = line:CreateTexture (nil, "overlay")
+ line.icon:SetSize (128, 64)
+
+ line.icon:SetPoint ("topleft", line, "topleft", 0, 0)
+
+ self.addons_lines [self.next_addons] = line
+ end
+
+ self.next_addons = self.next_addons + 1
+
+ return line
+end
+
+local default_coords = {0, 1, 0, 1}
+local feedback_add_fb = function (self, table)
+ local line = self:GetFeedbackLine()
+ line.icon:SetTexture (table.icon)
+ line.icon:SetTexCoord (unpack (table.coords or default_coords))
+ line.desc:SetText (table.desc)
+ line.link = table.link
+ line:Show()
+end
+
+local feedback_add_addon = function (self, table)
+ local block = self:GetAddonsLine()
+ block.icon:SetTexture (table.icon)
+ block.icon:SetTexCoord (unpack (table.coords or default_coords))
+ block.link = table.link
+ block.tooltip = table.desc
+ block.name = table.name
+ block:Show()
+end
+
+local feedback_hide_all = function (self)
+ self.next_feedback = 1
+ self.next_addons = 1
+
+ for index, line in ipairs (self.feedback_lines) do
+ line:Hide()
+ end
+
+ for index, line in ipairs (self.addons_lines) do
+ line:Hide()
+ end
+end
+
+-- feedback_methods = { { icon = icon path, desc = description, link = url}}
+function DF:ShowFeedbackPanel (addon_name, version, feedback_methods, more_addons)
+
+ local f = _G.AddonFeedbackPanel
+
+ if (not f) then
+ f = DF:Create1PxPanel (UIParent, 400, 100, addon_name .. " Feedback", "AddonFeedbackPanel", nil)
+ f:SetFrameStrata ("FULLSCREEN")
+ f:SetPoint ("center", UIParent, "center")
+ f:SetBackdropColor (0, 0, 0, 0.8)
+ f.feedback_lines = {}
+ f.addons_lines = {}
+ f.next_feedback = 1
+ f.next_addons = 1
+ f.next_addons_line_break = 4
+
+ local feedback_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ feedback_anchor:SetText ("Feedback:")
+ feedback_anchor:SetPoint ("topleft", f, "topleft", 5, -30)
+ f.feedback_anchor = feedback_anchor
+ local excla_text = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ excla_text:SetText ("click and copy the link")
+ excla_text:SetPoint ("topright", f, "topright", -5, -30)
+ excla_text:SetTextColor (1, 0.8, 0.2, 0.6)
+
+ local addons_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ addons_anchor:SetText ("AddOns From the Same Author:")
+ f.addons_anchor = addons_anchor
+ local excla_text2 = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ excla_text2:SetText ("click and copy the link")
+ excla_text2:SetTextColor (1, 0.8, 0.2, 0.6)
+ f.excla_text2 = excla_text2
+
+ f.GetFeedbackLine = feedback_get_fb_line
+ f.GetAddonsLine = feedback_get_addons_line
+ f.AddFeedbackMethod = feedback_add_fb
+ f.AddOtherAddon = feedback_add_addon
+ f.HideAll = feedback_hide_all
+
+ DF:SetFontSize (f.Title, 14)
+
+ end
+
+ f:HideAll()
+ f:SetTitle (addon_name)
+
+ for index, feedback in ipairs (feedback_methods) do
+ f:AddFeedbackMethod (feedback)
+ end
+
+ f.addons_anchor:SetPoint ("topleft", f, "topleft", 5, f.next_feedback * 50 * -1)
+ f.excla_text2:SetPoint ("topright", f, "topright", -5, f.next_feedback * 50 * -1)
+
+ for index, addon in ipairs (more_addons) do
+ f:AddOtherAddon (addon)
+ end
+
+ f:SetHeight (80 + ((f.next_feedback-1) * 50) + (ceil ((f.next_addons-1)/3) * 66))
+
+ f:Show()
+
+ return true
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> chart panel -- ~chart
+
+local chart_panel_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
+edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}}
+
+local chart_panel_align_timelabels = function (self, elapsed_time)
+
+ self.TimeScale = elapsed_time
+
+ local linha = self.TimeLabels [17]
+ local minutos, segundos = math.floor (elapsed_time / 60), math.floor (elapsed_time % 60)
+ if (segundos < 10) then
+ segundos = "0" .. segundos
+ end
+
+ if (minutos > 0) then
+ if (minutos < 10) then
+ minutos = "0" .. minutos
+ end
+ linha:SetText (minutos .. ":" .. segundos)
+ else
+ linha:SetText ("00:" .. segundos)
+ end
+
+ local time_div = elapsed_time / 16 --786 -- 49.125
+
+ for i = 2, 16 do
+
+ local linha = self.TimeLabels [i]
+
+ local this_time = time_div * (i-1)
+ local minutos, segundos = math.floor (this_time / 60), math.floor (this_time % 60)
+
+ if (segundos < 10) then
+ segundos = "0" .. segundos
+ end
+
+ if (minutos > 0) then
+ if (minutos < 10) then
+ minutos = "0" .. minutos
+ end
+ linha:SetText (minutos .. ":" .. segundos)
+ else
+ linha:SetText ("00:" .. segundos)
+ end
+
+ end
+
+end
+
+local chart_panel_set_scale = function (self, amt, func, text)
+ if (type (amt) ~= "number") then
+ return
+ end
+
+ --each line amount, then multiply the line index by this number
+ local piece = amt / 8
+
+ for i = 1, 8 do
+ if (func) then
+ self ["dpsamt" .. math.abs (i-9)]:SetText (func (piece*i))
+ else
+ if (piece*i > 1) then
+ self ["dpsamt" .. math.abs (i-9)]:SetText (DF.FormatNumber (piece*i))
+ else
+ self ["dpsamt" .. math.abs (i-9)]:SetText (format ("%.3f", piece*i))
+ end
+ end
+ end
+end
+
+local chart_panel_can_move = function (self, can)
+ self.can_move = can
+end
+
+local chart_panel_overlay_reset = function (self)
+ self.OverlaysAmount = 1
+ for index, pack in ipairs (self.Overlays) do
+ for index2, texture in ipairs (pack) do
+ texture:Hide()
+ end
+ end
+end
+
+local chart_panel_reset = function (self)
+
+ self.Graphic:ResetData()
+ self.Graphic.max_value = 0
+
+ self.TimeScale = nil
+ self.BoxLabelsAmount = 1
+ table.wipe (self.GData)
+ table.wipe (self.OData)
+
+ for index, box in ipairs (self.BoxLabels) do
+ box.check:Hide()
+ box.button:Hide()
+ box.box:Hide()
+ box.text:Hide()
+ box.border:Hide()
+ box.showing = false
+ end
+
+ chart_panel_overlay_reset (self)
+end
+
+local chart_panel_enable_line = function (f, thisbox)
+
+ local index = thisbox.index
+ local type = thisbox.type
+
+ if (thisbox.enabled) then
+ --disable
+ thisbox.check:Hide()
+ thisbox.enabled = false
+ else
+ --enable
+ thisbox.check:Show()
+ thisbox.enabled = true
+ end
+
+ if (type == "graphic") then
+
+ f.Graphic:ResetData()
+ f.Graphic.max_value = 0
+
+ local max = 0
+ local max_time = 0
+
+ for index, box in ipairs (f.BoxLabels) do
+ if (box.type == type and box.showing and box.enabled) then
+ local data = f.GData [index]
+
+ f.Graphic:AddDataSeries (data[1], data[2], nil, data[3])
+
+ if (data[4] > max) then
+ max = data[4]
+ end
+ if (data [5] > max_time) then
+ max_time = data [5]
+ end
+ end
+ end
+
+ f:SetScale (max)
+ f:SetTime (max_time)
+
+ elseif (type == "overlay") then
+
+ chart_panel_overlay_reset (f)
+
+ for index, box in ipairs (f.BoxLabels) do
+ if (box.type == type and box.showing and box.enabled) then
+
+ f:AddOverlay (box.index)
+
+ end
+ end
+
+ end
+end
+
+local create_box = function (self, next_box)
+
+ local thisbox = {}
+ self.BoxLabels [next_box] = thisbox
+
+ local box = DF:NewImage (self.Graphic, nil, 16, 16, "border")
+ local text = DF:NewLabel (self.Graphic)
+
+ local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork")
+ border:SetPoint ("center", box, "center", -3, -4)
+ border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]])
+
+ local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay")
+ checktexture:SetPoint ("center", box, "center", 0, -1)
+ checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
+
+ thisbox.box = box
+ thisbox.text = text
+ thisbox.border = border
+ thisbox.check = checktexture
+ thisbox.enabled = true
+
+ local button = CreateFrame ("button", nil, self.Graphic)
+ button:SetSize (20, 20)
+ button:SetScript ("OnClick", function()
+ chart_panel_enable_line (self, thisbox)
+ end)
+ button:SetPoint ("topleft", box.widget or box, "topleft", 0, 0)
+ button:SetPoint ("bottomright", box.widget or box, "bottomright", 0, 0)
+
+ button:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ button:SetBackdropColor (0, 0, 0, 0.0)
+ button:SetBackdropBorderColor (0, 0, 0, 1)
+
+ thisbox.button = button
+
+ thisbox.box:SetPoint ("right", text, "left", -4, 0)
+
+ if (next_box == 1) then
+ thisbox.text:SetPoint ("topright", self, "topright", -35, -16)
+ else
+ thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -17, 0)
+ end
+
+ return thisbox
+
+end
+
+local realign_labels = function (self)
+
+ if (not self.ShowHeader) then
+ for _, box in ipairs (self.BoxLabels) do
+ box.check:Hide()
+ box.button:Hide()
+ box.border:Hide()
+ box.box:Hide()
+ box.text:Hide()
+ end
+ return
+ end
+
+ local width = self:GetWidth() - 108
+
+ local first_box = self.BoxLabels [1]
+ first_box.text:SetPoint ("topright", self, "topright", -35, -16)
+
+ local line_width = first_box.text:GetStringWidth() + 26
+
+ for i = 2, #self.BoxLabels do
+
+ local box = self.BoxLabels [i]
+
+ if (box.box:IsShown()) then
+
+ line_width = line_width + box.text:GetStringWidth() + 26
+
+ if (line_width > width) then
+ line_width = box.text:GetStringWidth() + 26
+ box.text:SetPoint ("topright", self, "topright", -35, -40)
+ else
+ box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -27, 0)
+ end
+ else
+ break
+ end
+ end
+
+ if (self.HeaderOnlyIndicator) then
+ for _, box in ipairs (self.BoxLabels) do
+ box.check:Hide()
+ box.button:Hide()
+ end
+ return
+ end
+
+end
+
+local chart_panel_add_label = function (self, color, name, type, number)
+
+ local next_box = self.BoxLabelsAmount
+ local thisbox = self.BoxLabels [next_box]
+
+ if (not thisbox) then
+ thisbox = create_box (self, next_box)
+ end
+
+ self.BoxLabelsAmount = self.BoxLabelsAmount + 1
+
+ thisbox.type = type
+ thisbox.index = number
+
+ thisbox.box:SetColorTexture (unpack (color))
+ thisbox.text:SetText (name)
+
+ thisbox.check:Show()
+ thisbox.button:Show()
+ thisbox.border:Hide()
+ thisbox.box:Show()
+ thisbox.text:Show()
+
+ thisbox.showing = true
+ thisbox.enabled = true
+
+ realign_labels (self)
+
+end
+
+local line_default_color = {1, 1, 1}
+local draw_overlay = function (self, this_overlay, overlayData, color)
+
+ local pixel = self.Graphic:GetWidth() / self.TimeScale
+ local index = 1
+ local r, g, b, a = unpack (color or line_default_color)
+
+ for i = 1, #overlayData, 2 do
+ local aura_start = overlayData [i]
+ local aura_end = overlayData [i+1]
+
+ local this_block = this_overlay [index]
+ if (not this_block) then
+ this_block = self.Graphic:CreateTexture (nil, "border")
+ tinsert (this_overlay, this_block)
+ end
+ this_block:SetHeight (self.Graphic:GetHeight())
+
+ this_block:SetPoint ("left", self.Graphic, "left", pixel * aura_start, 0)
+ if (aura_end) then
+ this_block:SetWidth ((aura_end-aura_start)*pixel)
+ else
+ --malformed table
+ this_block:SetWidth (pixel*5)
+ end
+
+ this_block:SetColorTexture (r, g, b, a or 0.25)
+ this_block:Show()
+
+ index = index + 1
+ end
+
+end
+
+local chart_panel_add_overlay = function (self, overlayData, color, name, icon)
+
+ if (not self.TimeScale) then
+ error ("Use SetTime (time) before adding an overlay.")
+ end
+
+ if (type (overlayData) == "number") then
+ local overlay_index = overlayData
+ draw_overlay (self, self.Overlays [self.OverlaysAmount], self.OData [overlay_index][1], self.OData [overlay_index][2])
+ else
+ local this_overlay = self.Overlays [self.OverlaysAmount]
+ if (not this_overlay) then
+ this_overlay = {}
+ tinsert (self.Overlays, this_overlay)
+ end
+
+ draw_overlay (self, this_overlay, overlayData, color)
+
+ tinsert (self.OData, {overlayData, color or line_default_color})
+ if (name and self.HeaderShowOverlays) then
+ self:AddLabel (color or line_default_color, name, "overlay", #self.OData)
+ end
+ end
+
+ self.OverlaysAmount = self.OverlaysAmount + 1
+end
+
+-- Define the tricube weight function
+function calc_cubeweight (i, j, d)
+ local w = ( 1 - math.abs ((j-i)/d)^3)^3
+ if w < 0 then
+ w = 0
+ end
+ return w
+end
+
+local calc_lowess_smoothing = function (self, data, bandwidth)
+ local length = #data
+ local newData = {}
+
+ for i = 1, length do
+ local A = 0
+ local B = 0
+ local C = 0
+ local D = 0
+ local E = 0
+
+ -- Calculate span of values to be included in the regression
+ local jmin = floor (i-bandwidth/2)
+ local jmax = ceil (i+bandwidth/2)
+ if jmin < 1 then
+ jmin = 1
+ end
+ if jmax > length then
+ jmax = length
+ end
+
+ -- For all the values in the span, compute the weight and then the linear fit
+
+ for j = jmin, jmax do
+ w = calc_cubeweight (i, j, bandwidth/2)
+ x = j
+ y = data [j]
+
+ A = A + w*x
+ B = B + w*y
+ C = C + w*x^2
+ D = D + w*x*y
+ E = E + w
+ end
+
+ -- Calculate a (slope) and b (offset) for the linear fit
+ local a = (A*B-D*E)/(A^2 - C*E)
+ local b = (A*D-B*C)/(A^2 - C*E)
+
+ -- Calculate the smoothed value by the formula y=a*x+b (x <- i)
+ newData [i] = a*i+b
+
+ end
+
+ return newData
+end
+
+local calc_stddev = function (self, data)
+ local total = 0
+ for i = 1, #data do
+ total = total + data[i]
+ end
+ local mean = total / #data
+
+ local totalDistance = 0
+ for i = 1, #data do
+ totalDistance = totalDistance + ((data[i] - mean) ^ 2)
+ end
+
+ local deviation = math.sqrt (totalDistance / #data)
+ return deviation
+end
+
+
+
+local SMA_table = {}
+local SMA_max = 0
+local reset_SMA = function()
+ table.wipe (SMA_table)
+ SMA_max = 0
+end
+
+local calc_SMA
+calc_SMA = function (a, b, ...)
+ if (b) then
+ return calc_SMA (a + b, ...)
+ else
+ return a
+ end
+end
+
+local do_SMA = function (value, max_value)
+
+ if (#SMA_table == 10) then
+ tremove (SMA_table, 1)
+ end
+
+ SMA_table [#SMA_table + 1] = value
+
+ local new_value = calc_SMA (unpack (SMA_table)) / #SMA_table
+
+ if (new_value > SMA_max) then
+ SMA_max = new_value
+ return new_value, SMA_max
+ else
+ return new_value
+ end
+
+end
+
+local chart_panel_onresize = function (self)
+ local width, height = self:GetSize()
+ local spacement = width - 78 - 60
+ spacement = spacement / 16
+
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), self.TimeLabelsHeight)
+ label.line:SetHeight (height - 45)
+ end
+
+ local spacement = (self.Graphic:GetHeight()) / 8
+ for i = 1, 8 do
+ self ["dpsamt"..i]:SetPoint ("TOPLEFT", self, "TOPLEFT", 27, -25 + (-(spacement* (i-1))) )
+ self ["dpsamt"..i].line:SetWidth (width-20)
+ end
+
+ self.Graphic:SetSize (width - 135, height - 67)
+ self.Graphic:SetPoint ("topleft", self, "topleft", 108, -35)
+end
+
+local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
+
+ local f = self
+ self = self.Graphic
+
+ local _data = {}
+ local max_value = graphicData.max_value
+ local amount = #graphicData
+
+ local scaleW = 1/self:GetWidth()
+
+ local content = graphicData
+ tinsert (content, 1, 0)
+ tinsert (content, 1, 0)
+ tinsert (content, #content+1, 0)
+ tinsert (content, #content+1, 0)
+
+ local _i = 3
+
+ local graphMaxDps = math.max (self.max_value, max_value)
+
+ if (not smoothLevel) then
+ while (_i <= #content-2) do
+ local v = (content[_i-2]+content[_i-1]+content[_i]+content[_i+1]+content[_i+2])/5 --> normalize
+ _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == "SHORT") then
+ while (_i <= #content-2) do
+ local value = (content[_i] + content[_i+1]) / 2
+ _data [#_data+1] = {scaleW*(_i-2), value}
+ _data [#_data+1] = {scaleW*(_i-2), value}
+ _i = _i + 2
+ end
+
+ elseif (smoothLevel == "SMA") then
+ reset_SMA()
+ while (_i <= #content-2) do
+ local value, is_new_max_value = do_SMA (content[_i], max_value)
+ if (is_new_max_value) then
+ max_value = is_new_max_value
+ end
+ _data [#_data+1] = {scaleW*(_i-2), value} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == -1) then
+ while (_i <= #content-2) do
+ local current = content[_i]
+
+ local minus_2 = content[_i-2] * 0.6
+ local minus_1 = content[_i-1] * 0.8
+ local plus_1 = content[_i+1] * 0.8
+ local plus_2 = content[_i+2] * 0.6
+
+ local v = (current + minus_2 + minus_1 + plus_1 + plus_2)/5 --> normalize
+ _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == 1) then
+ _i = 2
+ while (_i <= #content-1) do
+ local v = (content[_i-1]+content[_i]+content[_i+1])/3 --> normalize
+ _data [#_data+1] = {scaleW*(_i-1), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == 2) then
+ _i = 1
+ while (_i <= #content) do
+ local v = content[_i] --> do not normalize
+ _data [#_data+1] = {scaleW*(_i), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ end
+
+ tremove (content, 1)
+ tremove (content, 1)
+ tremove (content, #graphicData)
+ tremove (content, #graphicData)
+
+ if (max_value > self.max_value) then
+ --> normalize previous data
+ if (self.max_value > 0) then
+ local normalizePercent = self.max_value / max_value
+ for dataIndex, Data in ipairs (self.Data) do
+ local Points = Data.Points
+ for i = 1, #Points do
+ Points[i][2] = Points[i][2]*normalizePercent
+ end
+ end
+ end
+
+ self.max_value = max_value
+ f:SetScale (max_value)
+
+ end
+
+ tinsert (f.GData, {_data, color or line_default_color, lineTexture, max_value, elapsed_time})
+ if (name) then
+ f:AddLabel (color or line_default_color, name, "graphic", #f.GData)
+ end
+
+ if (firstIndex) then
+ if (lineTexture) then
+ if (not lineTexture:find ("\\") and not lineTexture:find ("//")) then
+ local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua")
+ if path then
+ lineTexture = "Interface\\AddOns\\" .. path .. lineTexture
+ else
+ lineTexture = nil
+ end
+ end
+ end
+
+ table.insert (self.Data, 1, {Points = _data, Color = color or line_default_color, lineTexture = lineTexture, ElapsedTime = elapsed_time})
+ self.NeedsUpdate = true
+ else
+ self:AddDataSeries (_data, color or line_default_color, nil, lineTexture)
+ self.Data [#self.Data].ElapsedTime = elapsed_time
+ end
+
+ local max_time = 0
+ for _, data in ipairs (self.Data) do
+ if (data.ElapsedTime > max_time) then
+ max_time = data.ElapsedTime
+ end
+ end
+
+ f:SetTime (max_time)
+
+ chart_panel_onresize (f)
+end
+
+
+
+
+local chart_panel_vlines_on = function (self)
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label.line:Show()
+ end
+end
+
+local chart_panel_vlines_off = function (self)
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label.line:Hide()
+ end
+end
+
+local chart_panel_set_title = function (self, title)
+ self.chart_title.text = title
+end
+
+local chart_panel_mousedown = function (self, button)
+ if (button == "LeftButton" and self.can_move) then
+ if (not self.isMoving) then
+ self:StartMoving()
+ self.isMoving = true
+ end
+ elseif (button == "RightButton" and not self.no_right_click_close) then
+ if (not self.isMoving) then
+ self:Hide()
+ end
+ end
+end
+local chart_panel_mouseup = function (self, button)
+ if (button == "LeftButton" and self.isMoving) then
+ self:StopMovingOrSizing()
+ self.isMoving = nil
+ end
+end
+
+local chart_panel_hide_close_button = function (self)
+ self.CloseButton:Hide()
+end
+
+local chart_panel_right_click_close = function (self, value)
+ if (type (value) == "boolean") then
+ if (value) then
+ self.no_right_click_close = nil
+ else
+ self.no_right_click_close = true
+ end
+ end
+end
+
+function DF:CreateChartPanel (parent, w, h, name)
+
+ if (not name) then
+ name = "DFPanel" .. DF.PanelCounter
+ DF.PanelCounter = DF.PanelCounter + 1
+ end
+
+ parent = parent or UIParent
+ w = w or 800
+ h = h or 500
+
+ local f = CreateFrame ("frame", name, parent)
+ f:SetSize (w or 500, h or 400)
+ f:EnableMouse (true)
+ f:SetMovable (true)
+
+ f:SetScript ("OnMouseDown", chart_panel_mousedown)
+ f:SetScript ("OnMouseUp", chart_panel_mouseup)
+
+ f:SetBackdrop (chart_panel_backdrop)
+ f:SetBackdropColor (.3, .3, .3, .3)
+
+ local c = CreateFrame ("Button", nil, f, "UIPanelCloseButton")
+ c:SetWidth (32)
+ c:SetHeight (32)
+ c:SetPoint ("TOPRIGHT", f, "TOPRIGHT", -3, -7)
+ c:SetFrameLevel (f:GetFrameLevel()+1)
+ c:SetAlpha (0.9)
+ f.CloseButton = c
+
+ local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0})
+ title:SetPoint ("topleft", f, "topleft", 110, -13)
+
+ f.Overlays = {}
+ f.OverlaysAmount = 1
+
+ f.BoxLabels = {}
+ f.BoxLabelsAmount = 1
+
+ f.ShowHeader = true
+ f.HeaderOnlyIndicator = false
+ f.HeaderShowOverlays = true
+
+ --graphic
+ local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67)
+ g:SetXAxis (-1,1)
+ g:SetYAxis (-1,1)
+ g:SetGridSpacing (false, false)
+ g:SetGridColor ({0.5,0.5,0.5,0.3})
+ g:SetAxisDrawing (false,false)
+ g:SetAxisColor({1.0,1.0,1.0,1.0})
+ g:SetAutoScale (true)
+ g:SetLineTexture ("smallline")
+ g:SetBorderSize ("right", 0.001)
+ g:SetBorderSize ("left", 0.000)
+ g:SetBorderSize ("top", 0.002)
+ g:SetBorderSize ("bottom", 0.001)
+ g.VerticalLines = {}
+ g.max_value = 0
+
+ g:SetLineTexture ("line")
+
+ f.Graphic = g
+ f.GData = {}
+ f.OData = {}
+ f.ChartFrames = {}
+
+ --div lines
+ for i = 1, 8, 1 do
+ local line = g:CreateTexture (nil, "overlay")
+ line:SetColorTexture (1, 1, 1, .05)
+ line:SetWidth (670)
+ line:SetHeight (1.1)
+
+ local s = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ f ["dpsamt"..i] = s
+ s:SetText ("100k")
+ s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i)))
+
+ line:SetPoint ("topleft", s, "bottom", -27, 0)
+ line:SetPoint ("topright", g, "right", 0, 0)
+ s.line = line
+ end
+
+ --create time labels and the bottom texture to use as a background to these labels
+ f.TimeLabels = {}
+ f.TimeLabelsHeight = 16
+
+ for i = 1, 17 do
+ local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ time:SetText ("00:00")
+ time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), f.TimeLabelsHeight)
+ f.TimeLabels [i] = time
+
+ local line = f:CreateTexture (nil, "border")
+ line:SetSize (1, h-45)
+ line:SetColorTexture (1, 1, 1, .1)
+ line:SetPoint ("bottomleft", time, "topright", 0, -10)
+ line:Hide()
+ time.line = line
+ end
+
+ local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture")
+ bottom_texture:SetColorTexture (.1, .1, .1, .7)
+ bottom_texture:SetPoint ("topright", g, "bottomright", 0, 0)
+ bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 12)
+
+
+
+ f.SetTime = chart_panel_align_timelabels
+ f.EnableVerticalLines = chart_panel_vlines_on
+ f.DisableVerticalLines = chart_panel_vlines_off
+ f.SetTitle = chart_panel_set_title
+ f.SetScale = chart_panel_set_scale
+ f.Reset = chart_panel_reset
+ f.AddLine = chart_panel_add_data
+ f.CanMove = chart_panel_can_move
+ f.AddLabel = chart_panel_add_label
+ f.AddOverlay = chart_panel_add_overlay
+ f.HideCloseButton = chart_panel_hide_close_button
+ f.RightClickClose = chart_panel_right_click_close
+ f.CalcStdDev = calc_stddev
+ f.CalcLowessSmoothing = calc_lowess_smoothing
+
+ f:SetScript ("OnSizeChanged", chart_panel_onresize)
+ chart_panel_onresize (f)
+
+ return f
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~gframe
+local gframe_on_enter_line = function (self)
+ self:SetBackdropColor (0, 0, 0, 0)
+
+ local parent = self:GetParent()
+ local ball = self.ball
+ ball:SetBlendMode ("ADD")
+
+ local on_enter = parent._onenter_line
+ if (on_enter) then
+ return on_enter (self, parent)
+ end
+end
+
+local gframe_on_leave_line = function (self)
+ self:SetBackdropColor (0, 0, 0, .6)
+
+ local parent = self:GetParent()
+ local ball = self.ball
+ ball:SetBlendMode ("BLEND")
+
+ local on_leave = parent._onleave_line
+ if (on_leave) then
+ return on_leave (self, parent)
+ end
+end
+
+local gframe_create_line = function (self)
+ local index = #self._lines+1
+
+ local f = CreateFrame ("frame", nil, self)
+ self._lines [index] = f
+ f.id = index
+ f:SetScript ("OnEnter", gframe_on_enter_line)
+ f:SetScript ("OnLeave", gframe_on_leave_line)
+
+ f:SetWidth (self._linewidth)
+
+ if (index == 1) then
+ f:SetPoint ("topleft", self, "topleft")
+ f:SetPoint ("bottomleft", self, "bottomleft")
+ else
+ local previous_line = self._lines [index-1]
+ f:SetPoint ("topleft", previous_line, "topright")
+ f:SetPoint ("bottomleft", previous_line, "bottomright")
+ end
+
+ local t = f:CreateTexture (nil, "background")
+ t:SetWidth (1)
+ t:SetPoint ("topright", f, "topright")
+ t:SetPoint ("bottomright", f, "bottomright")
+ t:SetColorTexture (1, 1, 1, .1)
+ f.grid = t
+
+ local b = f:CreateTexture (nil, "overlay")
+ b:SetTexture ([[Interface\COMMON\Indicator-Yellow]])
+ b:SetSize (16, 16)
+ f.ball = b
+ local anchor = CreateFrame ("frame", nil, f)
+ anchor:SetAllPoints (b)
+ b.tooltip_anchor = anchor
+
+ local spellicon = f:CreateTexture (nil, "artwork")
+ spellicon:SetPoint ("bottom", b, "bottom", 0, 10)
+ spellicon:SetSize (16, 16)
+ f.spellicon = spellicon
+
+ local text = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ local textBackground = f:CreateTexture (nil, "artwork")
+ textBackground:SetSize (30, 16)
+ textBackground:SetColorTexture (0, 0, 0, 0.5)
+ textBackground:SetPoint ("bottom", f.ball, "top", 0, -6)
+ text:SetPoint ("center", textBackground, "center")
+ DF:SetFontSize (text, 10)
+ f.text = text
+ f.textBackground = textBackground
+
+ local timeline = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ timeline:SetPoint ("bottomright", f, "bottomright", -2, 0)
+ DF:SetFontSize (timeline, 8)
+ f.timeline = timeline
+
+ return f
+end
+
+local gframe_getline = function (self, index)
+ local line = self._lines [index]
+ if (not line) then
+ line = gframe_create_line (self)
+ end
+ return line
+end
+
+local gframe_reset = function (self)
+ for i, line in ipairs (self._lines) do
+ line:Hide()
+ end
+ if (self.GraphLib_Lines_Used) then
+ for i = #self.GraphLib_Lines_Used, 1, -1 do
+ local line = tremove (self.GraphLib_Lines_Used)
+ tinsert (self.GraphLib_Lines, line)
+ line:Hide()
+ end
+ end
+end
+
+local gframe_update = function (self, lines)
+
+ local g = LibStub:GetLibrary ("LibGraph-2.0")
+ local h = self:GetHeight()/100
+ local amtlines = #lines
+ local linewidth = self._linewidth
+
+ local max_value = 0
+ for i = 1, amtlines do
+ if (lines [i].value > max_value) then
+ max_value = lines [i].value
+ end
+ end
+
+ self.MaxValue = max_value
+
+ local o = 1
+ local lastvalue = self:GetHeight()/2
+ max_value = math.max (max_value, 0.0000001)
+
+ for i = 1, min (amtlines, self._maxlines) do
+
+ local data = lines [i]
+
+ local pvalue = data.value / max_value * 100
+ if (pvalue > 98) then
+ pvalue = 98
+ end
+ pvalue = pvalue * h
+
+ g:DrawLine (self, (o-1)*linewidth, lastvalue, o*linewidth, pvalue, linewidth, {1, 1, 1, 1}, "overlay")
+ lastvalue = pvalue
+
+ local line = self:GetLine (i)
+ line:Show()
+ line.ball:Show()
+
+ line.ball:SetPoint ("bottomleft", self, "bottomleft", (o*linewidth)-8, pvalue-8)
+ line.spellicon:SetTexture (nil)
+ line.timeline:SetText (data.text)
+ line.timeline:Show()
+
+ if (data.utext) then
+ line.text:Show()
+ line.textBackground:Show()
+ line.text:SetText (data.utext)
+ else
+ line.text:Hide()
+ line.textBackground:Hide()
+ end
+
+ line.data = data
+
+ o = o + 1
+ end
+
+end
+
+function DF:CreateGFrame (parent, w, h, linewidth, onenter, onleave, member, name)
+ local f = CreateFrame ("frame", name, parent)
+ f:SetSize (w or 450, h or 150)
+ --f.CustomLine = [[Interface\AddOns\Details\Libs\LibGraph-2.0\line]]
+
+ if (member) then
+ parent [member] = f
+ end
+
+ f.CreateLine = gframe_create_line
+ f.GetLine = gframe_getline
+ f.Reset = gframe_reset
+ f.UpdateLines = gframe_update
+
+ f.MaxValue = 0
+
+ f._lines = {}
+
+ f._onenter_line = onenter
+ f._onleave_line = onleave
+
+ f._linewidth = linewidth or 50
+ f._maxlines = floor (f:GetWidth() / f._linewidth)
+
+ return f
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~buttoncontainer
+
+function DF:CreateButtonContainer (parent, name)
+ local f = CreateFrame ("frame", name, parent)
+-- f.
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> options tabs and buttons -dot
+
+function DF:FindHighestParent (self)
+ local f
+ if (self:GetParent() == UIParent) then
+ f = self
+ end
+ if (not f) then
+ f = self
+ for i = 1, 6 do
+ local parent = f:GetParent()
+ if (parent == UIParent) then
+ break
+ else
+ f = parent
+ end
+ end
+ end
+
+ return f
+end
+
+DF.TabContainerFunctions = {}
+
+local button_tab_template = DF.table.copy ({}, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+button_tab_template.backdropbordercolor = nil
+
+DF.TabContainerFunctions.CreateUnderlineGlow = function (button)
+ local selectedGlow = button:CreateTexture (nil, "background", -4)
+ selectedGlow:SetPoint ("topleft", button.widget, "bottomleft", -7, 0)
+ selectedGlow:SetPoint ("topright", button.widget, "bottomright", 7, 0)
+ selectedGlow:SetTexture ([[Interface\BUTTONS\UI-Panel-Button-Glow]])
+ selectedGlow:SetTexCoord (0, 95/128, 30/64, 38/64)
+ selectedGlow:SetBlendMode ("ADD")
+ selectedGlow:SetHeight (8)
+ selectedGlow:SetAlpha (.75)
+ selectedGlow:Hide()
+ button.selectedUnderlineGlow = selectedGlow
+end
+
+DF.TabContainerFunctions.OnMouseDown = function (self, button)
+ --> search for UIParent
+ local f = DF:FindHighestParent (self)
+ local container = self:GetParent()
+
+ if (button == "LeftButton") then
+ if (not f.IsMoving and f:IsMovable()) then
+ f:StartMoving()
+ f.IsMoving = true
+ end
+ elseif (button == "RightButton") then
+ if (not f.IsMoving and container.IsContainer) then
+ if (self.IsFrontPage) then
+ if (container.CanCloseWithRightClick) then
+ if (f.CloseFunction) then
+ f:CloseFunction()
+ else
+ f:Hide()
+ end
+ end
+ else
+ --goes back to front page
+ DF.TabContainerFunctions.SelectIndex (self, _, 1)
+ end
+ end
+ end
+end
+
+DF.TabContainerFunctions.OnMouseUp = function (self, button)
+ local f = DF:FindHighestParent (self)
+ if (f.IsMoving) then
+ f:StopMovingOrSizing()
+ f.IsMoving = false
+ end
+end
+
+DF.TabContainerFunctions.SelectIndex = function (self, fixedParam, menuIndex)
+ local mainFrame = self.AllFrames and self or self.mainFrame or self:GetParent()
+
+ for i = 1, #mainFrame.AllFrames do
+ mainFrame.AllFrames[i]:Hide()
+ if (mainFrame.ButtonNotSelectedBorderColor) then
+ mainFrame.AllButtons[i]:SetBackdropBorderColor (unpack (mainFrame.ButtonNotSelectedBorderColor))
+ end
+ if (mainFrame.AllButtons[i].selectedUnderlineGlow) then
+ mainFrame.AllButtons[i].selectedUnderlineGlow:Hide()
+ end
+ end
+
+ mainFrame.AllFrames[menuIndex]:Show()
+ if (mainFrame.ButtonSelectedBorderColor) then
+ mainFrame.AllButtons[menuIndex]:SetBackdropBorderColor (unpack (mainFrame.ButtonSelectedBorderColor))
+ end
+ if (mainFrame.AllButtons[menuIndex].selectedUnderlineGlow) then
+ mainFrame.AllButtons[menuIndex].selectedUnderlineGlow:Show()
+ end
+ mainFrame.CurrentIndex = menuIndex
+end
+
+DF.TabContainerFunctions.SetIndex = function (self, index)
+ self.CurrentIndex = index
+end
+
+local tab_container_on_show = function (self)
+ local index = self.CurrentIndex
+ self.SelectIndex (self.AllButtons[index], nil, index)
+end
+
+function DF:CreateTabContainer (parent, title, frame_name, frame_list, options_table)
+
+ local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+ local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
+ local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
+ local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
+
+ options_table = options_table or {}
+ local frame_width = parent:GetWidth()
+ local frame_height = parent:GetHeight()
+ local y_offset = options_table.y_offset or 0
+ local button_width = options_table.button_width or 160
+ local button_height = options_table.button_height or 20
+ local button_anchor_x = options_table.button_x or 230
+ local button_anchor_y = options_table.button_y or -32
+ local button_text_size = options_table.button_text_size or 10
+
+ local mainFrame = CreateFrame ("frame", frame_name, parent.widget or parent)
+ mainFrame:SetAllPoints()
+ DF:Mixin (mainFrame, DF.TabContainerFunctions)
+
+ local mainTitle = DF:CreateLabel (mainFrame, title, 24, "white")
+ mainTitle:SetPoint ("topleft", mainFrame, "topleft", 10, -30 + y_offset)
+
+ mainFrame:SetFrameLevel (200)
+
+ mainFrame.AllFrames = {}
+ mainFrame.AllButtons = {}
+ mainFrame.CurrentIndex = 1
+ mainFrame.IsContainer = true
+ mainFrame.ButtonSelectedBorderColor = options_table.button_selected_border_color or {1, 1, 0, 1}
+ mainFrame.ButtonNotSelectedBorderColor = options_table.button_border_color or {0, 0, 0, 0}
+
+ if (options_table.right_click_interact ~= nil) then
+ mainFrame.CanCloseWithRightClick = options_table.right_click_interact
+ else
+ mainFrame.CanCloseWithRightClick = true
+ end
+
+ for i, frame in ipairs (frame_list) do
+ local f = CreateFrame ("frame", "$parent" .. frame.name, mainFrame)
+ f:SetAllPoints()
+ f:SetFrameLevel (210)
+ f:Hide()
+
+ local title = DF:CreateLabel (f, frame.title, 16, "silver")
+ title:SetPoint ("topleft", mainTitle, "bottomleft", 0, 0)
+
+ local tabButton = DF:CreateButton (mainFrame, DF.TabContainerFunctions.SelectIndex, button_width, button_height, frame.title, i, nil, nil, nil, nil, false, button_tab_template)
+ PixelUtil.SetSize (tabButton, button_width, button_height)
+ tabButton:SetFrameLevel (220)
+ tabButton.textsize = button_text_size
+ tabButton.mainFrame = mainFrame
+ DF.TabContainerFunctions.CreateUnderlineGlow (tabButton)
+
+ local right_click_to_back
+ if (i == 1 or options_table.rightbutton_always_close) then
+ right_click_to_back = DF:CreateLabel (f, "right click to close", 10, "gray")
+ right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, options_table.right_click_y or 0)
+ if (options_table.close_text_alpha) then
+ right_click_to_back:SetAlpha (options_table.close_text_alpha)
+ end
+ f.IsFrontPage = true
+ else
+ right_click_to_back = DF:CreateLabel (f, "right click to go back to main menu", 10, "gray")
+ right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, options_table.right_click_y or 0)
+ if (options_table.close_text_alpha) then
+ right_click_to_back:SetAlpha (options_table.close_text_alpha)
+ end
+ end
+
+ if (options_table.hide_click_label) then
+ right_click_to_back:Hide()
+ end
+
+ f:SetScript ("OnMouseDown", DF.TabContainerFunctions.OnMouseDown)
+ f:SetScript ("OnMouseUp", DF.TabContainerFunctions.OnMouseUp)
+
+ tinsert (mainFrame.AllFrames, f)
+ tinsert (mainFrame.AllButtons, tabButton)
+ end
+
+ --order buttons
+ local x = button_anchor_x
+ local y = button_anchor_y
+ local space_for_buttons = frame_width - (#frame_list*3) - button_anchor_x
+ local amount_buttons_per_row = floor (space_for_buttons / button_width)
+ local last_button = mainFrame.AllButtons[1]
+
+ mainFrame.AllButtons[1]:SetPoint ("topleft", mainTitle, "topleft", x, y)
+ x = x + button_width + 2
+
+ for i = 2, #mainFrame.AllButtons do
+ local button = mainFrame.AllButtons [i]
+ PixelUtil.SetPoint (button, "topleft", mainTitle, "topleft", x, y)
+ x = x + button_width + 2
+
+ if (i % amount_buttons_per_row == 0) then
+ x = button_anchor_x
+ y = y - button_height - 1
+ end
+ end
+
+ --> when show the frame, reset to the current internal index
+ mainFrame:SetScript ("OnShow", tab_container_on_show)
+ --> select the first frame
+ mainFrame.SelectIndex (mainFrame.AllButtons[1], nil, 1)
+
+ return mainFrame
+end
+
+
+
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~listbox
+
+local simple_list_box_ResetWidgets = function (self)
+ for _, widget in ipairs (self.widgets) do
+ widget:Hide()
+ end
+ self.nextWidget = 1
+end
+
+local simple_list_box_onenter = function (self, capsule)
+ self:GetParent().options.onenter (self, capsule, capsule.value)
+end
+
+local simple_list_box_onleave = function (self, capsule)
+ self:GetParent().options.onleave (self, capsule, capsule.value)
+ GameTooltip:Hide()
+end
+
+local simple_list_box_GetOrCreateWidget = function (self)
+ local index = self.nextWidget
+ local widget = self.widgets [index]
+ if (not widget) then
+ widget = DF:CreateButton (self, function()end, self.options.width, self.options.row_height, "", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
+ widget:SetHook ("OnEnter", simple_list_box_onenter)
+ widget:SetHook ("OnLeave", simple_list_box_onleave)
+ widget.textcolor = self.options.textcolor
+ widget.textsize = self.options.text_size
+ widget.onleave_backdrop = self.options.backdrop_color
+
+ widget.XButton = DF:CreateButton (widget, function()end, 16, 16)
+ widget.XButton:SetPoint ("topright", widget.widget, "topright")
+ widget.XButton:SetIcon ([[Interface\BUTTONS\UI-Panel-MinimizeButton-Up]], 16, 16, "overlay", nil, nil, 0, -4, 0, false)
+ widget.XButton.icon:SetDesaturated (true)
+
+ if (not self.options.show_x_button) then
+ widget.XButton:Hide()
+ end
+
+ tinsert (self.widgets, widget)
+ end
+ self.nextWidget = self.nextWidget + 1
+ return widget
+end
+
+local simple_list_box_RefreshWidgets = function (self)
+ self:ResetWidgets()
+ local amt = 0
+ for value, _ in pairs (self.list_table) do
+ local widget = self:GetOrCreateWidget()
+ widget:SetPoint ("topleft", self, "topleft", 1, -self.options.row_height * (self.nextWidget-2) - 4)
+ widget:SetPoint ("topright", self, "topright", -1, -self.options.row_height * (self.nextWidget-2) - 4)
+
+ widget:SetClickFunction (self.func, value)
+
+ if (self.options.show_x_button) then
+ widget.XButton:SetClickFunction (self.options.x_button_func, value)
+ widget.XButton.value = value
+ widget.XButton:Show()
+ else
+ widget.XButton:Hide()
+ end
+
+ widget.value = value
+
+ if (self.options.icon) then
+ if (type (self.options.icon) == "string" or type (self.options.icon) == "number") then
+ local coords = type (self.options.iconcoords) == "table" and self.options.iconcoords or {0, 1, 0, 1}
+ widget:SetIcon (self.options.icon, self.options.row_height - 2, self.options.row_height - 2, "overlay", coords)
+
+ elseif (type (self.options.icon) == "function") then
+ local icon = self.options.icon (value)
+ if (icon) then
+ local coords = type (self.options.iconcoords) == "table" and self.options.iconcoords or {0, 1, 0, 1}
+ widget:SetIcon (icon, self.options.row_height - 2, self.options.row_height - 2, "overlay", coords)
+ end
+ end
+ else
+ widget:SetIcon ("", self.options.row_height, self.options.row_height)
+ end
+
+ if (self.options.text) then
+ if (type (self.options.text) == "function") then
+ local text = self.options.text (value)
+ if (text) then
+ widget:SetText (text)
+ else
+ widget:SetText ("")
+ end
+ else
+ widget:SetText (self.options.text or "")
+ end
+ else
+ widget:SetText ("")
+ end
+
+ widget.value = value
+
+ local r, g, b, a = DF:ParseColors (self.options.backdrop_color)
+ widget:SetBackdropColor (r, g, b, a)
+
+ widget:Show()
+ amt = amt + 1
+ end
+ if (amt == 0) then
+ self.EmptyLabel:Show()
+ else
+ self.EmptyLabel:Hide()
+ end
+end
+
+local backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}
+local default_options = {
+ height = 400,
+ row_height = 16,
+ width = 230,
+ icon = false,
+ text = "",
+ text_size = 10,
+ textcolor = "wheat",
+
+ backdrop_color = {1, 1, 1, .5},
+ panel_border_color = {0, 0, 0, 0.5},
+
+ onenter = function (self, capsule)
+ if (capsule) then
+ capsule.textcolor = "white"
+ end
+ end,
+ onleave = function (self, capsule)
+ if (capsule) then
+ capsule.textcolor = self:GetParent().options.textcolor
+ end
+ GameTooltip:Hide()
+ end,
+}
+
+local simple_list_box_SetData = function (self, t)
+ self.list_table = t
+end
+
+function DF:CreateSimpleListBox (parent, name, title, empty_text, list_table, onclick, options)
+ local f = CreateFrame ("frame", name, parent)
+
+ f.ResetWidgets = simple_list_box_ResetWidgets
+ f.GetOrCreateWidget = simple_list_box_GetOrCreateWidget
+ f.Refresh = simple_list_box_RefreshWidgets
+ f.SetData = simple_list_box_SetData
+ f.nextWidget = 1
+ f.list_table = list_table
+ f.func = function (self, button, value)
+ --onclick (value)
+ DF:QuickDispatch (onclick, value)
+ f:Refresh()
+ end
+ f.widgets = {}
+
+ DF:ApplyStandardBackdrop (f)
+
+ f.options = options or {}
+ self.table.deploy (f.options, default_options)
+
+ if (f.options.x_button_func) then
+ local original_X_function = f.options.x_button_func
+ f.options.x_button_func = function (self, button, value)
+ DF:QuickDispatch (original_X_function, value)
+ f:Refresh()
+ end
+ end
+
+ f:SetBackdropBorderColor (unpack (f.options.panel_border_color))
+
+ f:SetSize (f.options.width + 2, f.options.height)
+
+ local name = DF:CreateLabel (f, title, 12, "silver")
+ name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ name:SetPoint ("bottomleft", f, "topleft", 0, 2)
+ f.Title = name
+
+ local emptyLabel = DF:CreateLabel (f, empty_text, 12, "gray")
+ emptyLabel:SetAlpha (.6)
+ emptyLabel:SetSize (f.options.width-10, f.options.height)
+ emptyLabel:SetPoint ("center", 0, 0)
+ emptyLabel:Hide()
+ emptyLabel.align = "center"
+ f.EmptyLabel = emptyLabel
+
+ return f
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~scrollbox
+
+DF.SortFunctions = {}
+
+local SortMember = ""
+local SortByMember = function (t1, t2)
+ return t1[SortMember] > t2[SortMember]
+end
+local SortByMemberReverse = function (t1, t2)
+ return t1[SortMember] < t2[SortMember]
+end
+
+DF.SortFunctions.Sort = function (self, t, by, is_reverse)
+ SortMember = by
+ if (not is_reverse) then
+ table.sort (t, SortByMember)
+ else
+ table.sort (t, SortByMemberReverse)
+ end
+end
+
+
+DF.ScrollBoxFunctions = {}
+
+DF.ScrollBoxFunctions.Refresh = function (self)
+ for _, frame in ipairs (self.Frames) do
+ frame:Hide()
+ frame._InUse = nil
+ end
+
+ local offset = 0
+ if (self.IsFauxScroll) then
+ FauxScrollFrame_Update (self, #self.data, self.LineAmount, self.LineHeight+1)
+ offset = FauxScrollFrame_GetOffset (self)
+ end
+
+ DF:CoreDispatch ((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
+
+ for _, frame in ipairs (self.Frames) do
+ if (not frame._InUse) then
+ frame:Hide()
+ else
+ frame:Show()
+ end
+ end
+
+ self:Show()
+
+ if (self.HideScrollBar) then
+ local frameName = self:GetName()
+ if (frameName) then
+ local scrollBar = _G [frameName .. "ScrollBar"]
+ if (scrollBar) then
+ scrollBar:Hide()
+ end
+ else
+
+ end
+
+ end
+
+ return self.Frames
+end
+
+DF.ScrollBoxFunctions.OnVerticalScroll = function (self, offset)
+ FauxScrollFrame_OnVerticalScroll (self, offset, self.LineHeight, self.Refresh)
+ return true
+end
+
+DF.ScrollBoxFunctions.CreateLine = function (self, func)
+ if (not func) then
+ func = self.CreateLineFunc
+ end
+ local okay, newLine = pcall (func, self, #self.Frames+1)
+ if (okay) then
+ tinsert (self.Frames, newLine)
+ newLine.Index = #self.Frames
+ return newLine
+ else
+ error ("Details! FrameWork: CreateLine(): " .. newLine)
+ end
+end
+
+DF.ScrollBoxFunctions.GetLine = function (self, line_index)
+ local line = self.Frames [line_index]
+ if (line) then
+ line._InUse = true
+ end
+ return line
+end
+
+DF.ScrollBoxFunctions.SetData = function (self, data)
+ self.data = data
+end
+DF.ScrollBoxFunctions.GetData = function (self)
+ return self.data
+end
+
+DF.ScrollBoxFunctions.GetFrames = function (self)
+ return self.Frames
+end
+
+DF.ScrollBoxFunctions.GetNumFramesCreated = function (self)
+ return #self.Frames
+end
+
+DF.ScrollBoxFunctions.GetNumFramesShown = function (self)
+ return self.LineAmount
+end
+
+DF.ScrollBoxFunctions.SetNumFramesShown = function (self, new_amount)
+ --> hide frames which won't be used
+ if (new_amount < #self.Frames) then
+ for i = new_amount+1, #self.Frames do
+ self.Frames [i]:Hide()
+ end
+ end
+
+ --> set the new amount
+ self.LineAmount = new_amount
+end
+
+DF.ScrollBoxFunctions.SetFramesHeight = function (self, new_height)
+ self.LineHeight = new_height
+ self:OnSizeChanged()
+ self:Refresh()
+end
+
+DF.ScrollBoxFunctions.OnSizeChanged = function (self)
+ if (self.ReajustNumFrames) then
+ --> how many lines the scroll can show
+ local amountOfFramesToShow = floor (self:GetHeight() / self.LineHeight)
+
+ --> how many lines the scroll already have
+ local totalFramesCreated = self:GetNumFramesCreated()
+
+ --> how many lines are current shown
+ local totalFramesShown = self:GetNumFramesShown()
+
+ --> the amount of frames increased
+ if (amountOfFramesToShow > totalFramesShown) then
+ for i = totalFramesShown+1, amountOfFramesToShow do
+ --> check if need to create a new line
+ if (i > totalFramesCreated) then
+ self:CreateLine (self.CreateLineFunc)
+ end
+ end
+
+ --> the amount of frames decreased
+ elseif (amountOfFramesToShow < totalFramesShown) then
+ --> hide all frames above the new amount to show
+ for i = totalFramesCreated, amountOfFramesToShow, -1 do
+ if (self.Frames [i]) then
+ self.Frames [i]:Hide()
+ end
+ end
+ end
+
+ --> set the new amount of frames
+ self:SetNumFramesShown (amountOfFramesToShow)
+
+ --> refresh lines
+ self:Refresh()
+ end
+end
+
+function DF:CreateScrollBox (parent, name, refresh_func, data, width, height, line_amount, line_height, create_line_func, auto_amount, no_scroll)
+ local scroll = CreateFrame ("scrollframe", name, parent, "FauxScrollFrameTemplate")
+
+ DF:ApplyStandardBackdrop (scroll)
+
+ scroll:SetSize (width, height)
+ scroll.LineAmount = line_amount
+ scroll.LineHeight = line_height
+ scroll.IsFauxScroll = true
+ scroll.HideScrollBar = no_scroll
+ scroll.Frames = {}
+ scroll.ReajustNumFrames = auto_amount
+ scroll.CreateLineFunc = create_line_func
+
+ DF:Mixin (scroll, DF.SortFunctions)
+ DF:Mixin (scroll, DF.ScrollBoxFunctions)
+
+ scroll.refresh_func = refresh_func
+ scroll.data = data
+
+ scroll:SetScript ("OnVerticalScroll", scroll.OnVerticalScroll)
+ scroll:SetScript ("OnSizeChanged", DF.ScrollBoxFunctions.OnSizeChanged)
+
+ return scroll
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~resizers
+
+function DF:CreateResizeGrips (parent)
+ if (parent) then
+ local parentName = parent:GetName()
+
+ local leftResizer = CreateFrame ("button", parentName and parentName .. "LeftResizer" or nil, parent)
+ local rightResizer = CreateFrame ("button", parentName and parentName .. "RightResizer" or nil, parent)
+
+ leftResizer:SetPoint ("bottomleft", parent, "bottomleft")
+ rightResizer:SetPoint ("bottomright", parent, "bottomright")
+ leftResizer:SetSize (16, 16)
+ rightResizer:SetSize (16, 16)
+
+ rightResizer:SetNormalTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
+ rightResizer:SetHighlightTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
+ rightResizer:SetPushedTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
+ leftResizer:SetNormalTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
+ leftResizer:SetHighlightTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
+ leftResizer:SetPushedTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
+
+ leftResizer:GetNormalTexture():SetTexCoord (1, 0, 0, 1)
+ leftResizer:GetHighlightTexture():SetTexCoord (1, 0, 0, 1)
+ leftResizer:GetPushedTexture():SetTexCoord (1, 0, 0, 1)
+
+ return leftResizer, rightResizer
+ end
+end
+
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~keybind
+
+
+--------------------------------
+--> keybind frame ~key
+
+
+local ignoredKeys = {
+ ["LSHIFT"] = true,
+ ["RSHIFT"] = true,
+ ["LCTRL"] = true,
+ ["RCTRL"] = true,
+ ["LALT"] = true,
+ ["RALT"] = true,
+ ["UNKNOWN"] = true,
+}
+
+local mouseKeys = {
+ ["LeftButton"] = "type1",
+ ["RightButton"] = "type2",
+ ["MiddleButton"] = "type3",
+ ["Button4"] = "type4",
+ ["Button5"] = "type5",
+ ["Button6"] = "type6",
+ ["Button7"] = "type7",
+ ["Button8"] = "type8",
+ ["Button9"] = "type9",
+ ["Button10"] = "type10",
+ ["Button11"] = "type11",
+ ["Button12"] = "type12",
+ ["Button13"] = "type13",
+ ["Button14"] = "type14",
+ ["Button15"] = "type15",
+ ["Button16"] = "type16",
+}
+
+local keysToMouse = {
+ ["type1"] = "LeftButton",
+ ["type2"] = "RightButton",
+ ["type3"] = "MiddleButton",
+ ["type4"] = "Button4",
+ ["type5"] = "Button5",
+ ["type6"] = "Button6",
+ ["type7"] = "Button7",
+ ["type8"] = "Button8",
+ ["type9"] = "Button9",
+ ["type10"] = "Button10",
+ ["type11"] = "Button11",
+ ["type12"] = "Button12",
+ ["type13"] = "Button13",
+ ["type14"] = "Button14",
+ ["type15"] = "Button15",
+ ["type16"] = "Button16",
+}
+
+local keybind_set_data = function (self, new_data_table)
+ self.Data = new_data_table
+ self.keybindScroll:UpdateScroll()
+end
+
+function DF:CreateKeybindBox (parent, name, data, callback, width, height, line_amount, line_height)
+
+ local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+ local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
+ local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
+ local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
+
+ local SCROLL_ROLL_AMOUNT = line_amount
+
+ --keybind set frame
+ local new_keybind_frame = CreateFrame ("frame", name, parent)
+ new_keybind_frame:SetSize (width, height)
+
+ -- keybind scrollframe
+ local keybindScroll = CreateFrame ("scrollframe", "$parentScrollFrame", new_keybind_frame, "FauxScrollFrameTemplate")
+ keybindScroll:SetSize (1019, 348)
+ keybindScroll.Frames = {}
+ new_keybind_frame.keybindScroll = keybindScroll
+
+ --waiting the player to press a key
+ new_keybind_frame.IsListening = false
+
+ --check for valid data table
+ if (type (data) ~= "table") then
+ print ("error: data must be a table. DF > CreateKeybindBox()")
+ return
+ end
+
+ if (not next (data)) then
+ --> build data table for the character class
+ local _, unitClass = UnitClass ("player")
+ if (unitClass) then
+ local specIds = DF:GetClassSpecIDs (unitClass)
+ if (specIds) then
+ for _, specId in ipairs (specIds) do
+ data [specId] = {}
+ end
+ end
+ end
+ end
+
+ new_keybind_frame.Data = data
+ new_keybind_frame.SetData = keybind_set_data
+
+ new_keybind_frame.EditingSpec = DF:GetCurrentSpec()
+ new_keybind_frame.CurrentKeybindEditingSet = new_keybind_frame.Data [new_keybind_frame.EditingSpec]
+
+ local allSpecButtons = {}
+ local switch_spec = function (self, button, specID)
+ new_keybind_frame.EditingSpec = specID
+ new_keybind_frame.CurrentKeybindEditingSet = new_keybind_frame.Data [specID]
+
+ for _, button in ipairs (allSpecButtons) do
+ button.selectedTexture:Hide()
+ end
+ self.MyObject.selectedTexture:Show()
+
+ --feedback ao jogador uma vez que as keybinds podem ter o mesmo valor
+ C_Timer.After (.04, function() new_keybind_frame:Hide() end)
+ C_Timer.After (.06, function() new_keybind_frame:Show() end)
+
+ --atualiza a scroll
+ keybindScroll:UpdateScroll()
+ end
+
+ --choose which spec to use
+ local spec1 = DF:CreateButton (new_keybind_frame, switch_spec, 160, 20, "Spec1 Placeholder Text", 1, _, _, "SpecButton1", _, 0, options_button_template, options_text_template)
+ local spec2 = DF:CreateButton (new_keybind_frame, switch_spec, 160, 20, "Spec2 Placeholder Text", 1, _, _, "SpecButton2", _, 0, options_button_template, options_text_template)
+ local spec3 = DF:CreateButton (new_keybind_frame, switch_spec, 160, 20, "Spec3 Placeholder Text", 1, _, _, "SpecButton3", _, 0, options_button_template, options_text_template)
+ local spec4 = DF:CreateButton (new_keybind_frame, switch_spec, 160, 20, "Spec4 Placeholder Text", 1, _, _, "SpecButton4", _, 0, options_button_template, options_text_template)
+
+ --format the button label and icon with the spec information
+ local className, class = UnitClass ("player")
+ local i = 1
+ local specIds = DF:GetClassSpecIDs (class)
+
+ for index, specId in ipairs (specIds) do
+ local button = new_keybind_frame ["SpecButton" .. index]
+ local spec_id, spec_name, spec_description, spec_icon, spec_background, spec_role, spec_class = GetSpecializationInfoByID (specId)
+ button.text = spec_name
+ button:SetClickFunction (switch_spec, specId)
+ button:SetIcon (spec_icon)
+ button.specID = specId
+
+ local selectedTexture = button:CreateTexture (nil, "background")
+ selectedTexture:SetAllPoints()
+ selectedTexture:SetColorTexture (1, 1, 1, 0.5)
+ if (specId ~= new_keybind_frame.EditingSpec) then
+ selectedTexture:Hide()
+ end
+ button.selectedTexture = selectedTexture
+
+ tinsert (allSpecButtons, button)
+ i = i + 1
+ end
+
+ local specsTitle = DF:CreateLabel (new_keybind_frame, "Config keys for spec:", 12, "silver")
+ specsTitle:SetPoint ("topleft", new_keybind_frame, "topleft", 10, mainStartY)
+
+ keybindScroll:SetPoint ("topleft", specsTitle.widget, "bottomleft", 0, -120)
+
+ spec1:SetPoint ("topleft", specsTitle, "bottomleft", 0, -10)
+ spec2:SetPoint ("topleft", specsTitle, "bottomleft", 0, -30)
+ spec3:SetPoint ("topleft", specsTitle, "bottomleft", 0, -50)
+ if (class == "DRUID") then
+ spec4:SetPoint ("topleft", specsTitle, "bottomleft", 0, -70)
+ end
+
+ local enter_the_key = CreateFrame ("frame", nil, new_keybind_frame)
+ enter_the_key:SetFrameStrata ("tooltip")
+ enter_the_key:SetSize (200, 60)
+ enter_the_key:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
+ enter_the_key:SetBackdropColor (0, 0, 0, 1)
+ enter_the_key:SetBackdropBorderColor (1, 1, 1, 1)
+ enter_the_key.text = DF:CreateLabel (enter_the_key, "- Press a keyboard key to bind.\n- Click to bind a mouse button.\n- Press escape to cancel.", 11, "orange")
+ enter_the_key.text:SetPoint ("center", enter_the_key, "center")
+ enter_the_key:Hide()
+
+ local registerKeybind = function (self, key)
+ if (ignoredKeys [key]) then
+ return
+ end
+ if (key == "ESCAPE") then
+ enter_the_key:Hide()
+ new_keybind_frame.IsListening = false
+ new_keybind_frame:SetScript ("OnKeyDown", nil)
+ return
+ end
+
+ local bind = (IsShiftKeyDown() and "SHIFT-" or "") .. (IsControlKeyDown() and "CTRL-" or "") .. (IsAltKeyDown() and "ALT-" or "")
+ bind = bind .. key
+
+ --adiciona para a tabela de keybinds
+ local keybind = new_keybind_frame.CurrentKeybindEditingSet [self.keybindIndex]
+ keybind.key = bind
+
+ new_keybind_frame.IsListening = false
+ new_keybind_frame:SetScript ("OnKeyDown", nil)
+
+ enter_the_key:Hide()
+ new_keybind_frame.keybindScroll:UpdateScroll()
+
+ DF:QuickDispatch (callback)
+ end
+
+ local set_keybind_key = function (self, button, keybindIndex)
+ if (new_keybind_frame.IsListening) then
+ key = mouseKeys [button] or button
+ return registerKeybind (new_keybind_frame, key)
+ end
+ new_keybind_frame.IsListening = true
+ new_keybind_frame.keybindIndex = keybindIndex
+ new_keybind_frame:SetScript ("OnKeyDown", registerKeybind)
+
+ enter_the_key:Show()
+ enter_the_key:SetPoint ("bottom", self, "top")
+ end
+
+ local new_key_bind = function (self, button, specID)
+ tinsert (new_keybind_frame.CurrentKeybindEditingSet, {key = "-none-", action = "_target", actiontext = ""})
+ FauxScrollFrame_SetOffset (new_keybind_frame.keybindScroll, max (#new_keybind_frame.CurrentKeybindEditingSet-SCROLL_ROLL_AMOUNT, 0))
+ new_keybind_frame.keybindScroll:UpdateScroll()
+ end
+
+ local set_action_text = function (keybindIndex, _, text)
+ local keybind = new_keybind_frame.CurrentKeybindEditingSet [keybindIndex]
+ keybind.actiontext = text
+ DF:QuickDispatch (callback)
+ end
+
+ local set_action_on_espace_press = function (textentry, capsule)
+ capsule = capsule or textentry.MyObject
+ local keybind = new_keybind_frame.CurrentKeybindEditingSet [capsule.CurIndex]
+ textentry:SetText (keybind.actiontext)
+ DF:QuickDispatch (callback)
+ end
+
+ local lock_textentry = {
+ ["_target"] = true,
+ ["_taunt"] = true,
+ ["_interrupt"] = true,
+ ["_dispel"] = true,
+ ["_spell"] = false,
+ ["_macro"] = false,
+ }
+
+ local change_key_action = function (self, keybindIndex, value)
+ local keybind = new_keybind_frame.CurrentKeybindEditingSet [keybindIndex]
+ keybind.action = value
+ new_keybind_frame.keybindScroll:UpdateScroll()
+ DF:QuickDispatch (callback)
+ end
+ local fill_action_dropdown = function()
+
+ local locClass, class = UnitClass ("player")
+
+ local taunt = ""
+ local interrupt = ""
+ local dispel = ""
+
+ if (type (dispel) == "table") then
+ local dispelString = "\n"
+ for specID, spellid in pairs (dispel) do
+ local specid, specName = GetSpecializationInfoByID (specID)
+ local spellName = GetSpellInfo (spellid)
+ dispelString = dispelString .. "|cFFE5E5E5" .. specName .. "|r: |cFFFFFFFF" .. spellName .. "\n"
+ end
+ dispel = dispelString
+ else
+ dispel = ""
+ end
+
+ return {
+ --{value = "_target", label = "Target", onclick = change_key_action, desc = "Target the unit"},
+ --{value = "_taunt", label = "Taunt", onclick = change_key_action, desc = "Cast the taunt spell for your class\n\n|cFFFFFFFFSpell: " .. taunt},
+ --{value = "_interrupt", label = "Interrupt", onclick = change_key_action, desc = "Cast the interrupt spell for your class\n\n|cFFFFFFFFSpell: " .. interrupt},
+ --{value = "_dispel", label = "Dispel", onclick = change_key_action, desc = "Cast the interrupt spell for your class\n\n|cFFFFFFFFSpell: " .. dispel},
+ {value = "_spell", label = "Cast Spell", onclick = change_key_action, desc = "Type the spell name in the text box"},
+ {value = "_macro", label = "Run Macro", onclick = change_key_action, desc = "Type your macro in the text box"},
+ }
+ end
+
+ local copy_keybind = function (self, button, keybindIndex)
+ local keybind = new_keybind_frame.CurrentKeybindEditingSet [keybindIndex]
+ for specID, t in pairs (new_keybind_frame.Data) do
+ if (specID ~= new_keybind_frame.EditingSpec) then
+ local key = CopyTable (keybind)
+ local specid, specName = GetSpecializationInfoByID (specID)
+ tinsert (new_keybind_frame.Data [specID], key)
+ DF:Msg ("Keybind copied to " .. specName)
+ end
+ end
+ DF:QuickDispatch (callback)
+ end
+
+ local delete_keybind = function (self, button, keybindIndex)
+ tremove (new_keybind_frame.CurrentKeybindEditingSet, keybindIndex)
+ new_keybind_frame.keybindScroll:UpdateScroll()
+ DF:QuickDispatch (callback)
+ end
+
+ local newTitle = DF:CreateLabel (new_keybind_frame, "Create a new Keybind:", 12, "silver")
+ newTitle:SetPoint ("topleft", new_keybind_frame, "topleft", 200, mainStartY)
+ local createNewKeybind = DF:CreateButton (new_keybind_frame, new_key_bind, 160, 20, "New Key Bind", 1, _, _, "NewKeybindButton", _, 0, options_button_template, options_text_template)
+ createNewKeybind:SetPoint ("topleft", newTitle, "bottomleft", 0, -10)
+ --createNewKeybind:SetIcon ([[Interface\Buttons\UI-GuildButton-PublicNote-Up]])
+
+ local update_keybind_list = function (self)
+
+ local keybinds = new_keybind_frame.CurrentKeybindEditingSet
+ FauxScrollFrame_Update (self, #keybinds, SCROLL_ROLL_AMOUNT, 21)
+ local offset = FauxScrollFrame_GetOffset (self)
+
+ for i = 1, SCROLL_ROLL_AMOUNT do
+ local index = i + offset
+ local f = self.Frames [i]
+ local data = keybinds [index]
+
+ if (data) then
+ --index
+ f.Index.text = index
+ --keybind
+ local keyBindText = keysToMouse [data.key] or data.key
+
+ keyBindText = keyBindText:gsub ("type1", "LeftButton")
+ keyBindText = keyBindText:gsub ("type2", "RightButton")
+ keyBindText = keyBindText:gsub ("type3", "MiddleButton")
+
+ f.KeyBind.text = keyBindText
+ f.KeyBind:SetClickFunction (set_keybind_key, index, nil, "left")
+ f.KeyBind:SetClickFunction (set_keybind_key, index, nil, "right")
+ --action
+ f.ActionDrop:SetFixedParameter (index)
+ f.ActionDrop:Select (data.action)
+ --action text
+ f.ActionText.text = data.actiontext
+ f.ActionText:SetEnterFunction (set_action_text, index)
+ f.ActionText.CurIndex = index
+
+ if (lock_textentry [data.action]) then
+ f.ActionText:Disable()
+ else
+ f.ActionText:Enable()
+ end
+
+ --copy
+ f.Copy:SetClickFunction (copy_keybind, index)
+ --delete
+ f.Delete:SetClickFunction (delete_keybind, index)
+
+ f:Show()
+ else
+ f:Hide()
+ end
+ end
+
+ self:Show()
+ end
+
+
+
+ keybindScroll:SetScript ("OnVerticalScroll", function (self, offset)
+ FauxScrollFrame_OnVerticalScroll (self, offset, 21, update_keybind_list)
+ end)
+ keybindScroll.UpdateScroll = update_keybind_list
+
+ local backdropColor = {.3, .3, .3, .3}
+ local backdropColorOnEnter = {.6, .6, .6, .6}
+ local on_enter = function (self)
+ self:SetBackdropColor (unpack (backdropColorOnEnter))
+ end
+ local on_leave = function (self)
+ self:SetBackdropColor (unpack (backdropColor))
+ end
+
+ local font = "GameFontHighlightSmall"
+
+ for i = 1, SCROLL_ROLL_AMOUNT do
+ local f = CreateFrame ("frame", "$KeyBindFrame" .. i, keybindScroll)
+ f:SetSize (1009, 20)
+ f:SetPoint ("topleft", keybindScroll, "topleft", 0, -(i-1)*29)
+ f:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ f:SetBackdropColor (unpack (backdropColor))
+ f:SetScript ("OnEnter", on_enter)
+ f:SetScript ("OnLeave", on_leave)
+ tinsert (keybindScroll.Frames, f)
+
+ f.Index = DF:CreateLabel (f, "1")
+ f.KeyBind = DF:CreateButton (f, set_key_bind, 100, 20, "", _, _, _, "SetNewKeybindButton", _, 0, options_button_template, options_text_template)
+ f.ActionDrop = DF:CreateDropDown (f, fill_action_dropdown, 0, 120, 20, "ActionDropdown", _, options_dropdown_template)
+ f.ActionText = DF:CreateTextEntry (f, function()end, 660, 20, "TextBox", _, _, options_dropdown_template)
+ f.Copy = DF:CreateButton (f, copy_keybind, 20, 20, "", _, _, _, "CopyKeybindButton", _, 0, options_button_template, options_text_template)
+ f.Delete = DF:CreateButton (f, delete_keybind, 16, 20, "", _, _, _, "DeleteKeybindButton", _, 2, options_button_template, options_text_template)
+
+ f.Index:SetPoint ("left", f, "left", 10, 0)
+ f.KeyBind:SetPoint ("left", f, "left", 43, 0)
+ f.ActionDrop:SetPoint ("left", f, "left", 150, 0)
+ f.ActionText:SetPoint ("left", f, "left", 276, 0)
+ f.Copy:SetPoint ("left", f, "left", 950, 0)
+ f.Delete:SetPoint ("left", f, "left", 990, 0)
+
+ f.Copy:SetIcon ([[Interface\Buttons\UI-GuildButton-PublicNote-Up]], nil, nil, nil, nil, nil, nil, 4)
+ f.Delete:SetIcon ([[Interface\Buttons\UI-StopButton]], nil, nil, nil, nil, nil, nil, 4)
+
+ f.Copy.tooltip = "copy this keybind to other specs"
+ f.Delete.tooltip = "erase this keybind"
+
+ --editbox
+ f.ActionText:SetJustifyH ("left")
+ f.ActionText:SetHook ("OnEscapePressed", set_action_on_espace_press)
+ f.ActionText:SetHook ("OnEditFocusGained", function()
+ local playerSpells = {}
+ local tab, tabTex, offset, numSpells = GetSpellTabInfo (2)
+ for i = 1, numSpells do
+ local index = offset + i
+ local spellType, spellId = GetSpellBookItemInfo (index, "player")
+ if (spellType == "SPELL") then
+ local spellName = GetSpellInfo (spellId)
+ tinsert (playerSpells, spellName)
+ end
+ end
+ f.ActionText.WordList = playerSpells
+ end)
+
+ f.ActionText:SetAsAutoComplete ("WordList")
+ end
+
+ local header = CreateFrame ("frame", "$parentOptionsPanelFrameHeader", keybindScroll)
+ header:SetPoint ("bottomleft", keybindScroll, "topleft", 0, 2)
+ header:SetPoint ("bottomright", keybindScroll, "topright", 0, 2)
+ header:SetHeight (16)
+
+ header.Index = DF:CreateLabel (header, "Index", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ header.Key = DF:CreateLabel (header, "Key", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ header.Action = DF:CreateLabel (header, "Action", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ header.Macro = DF:CreateLabel (header, "Spell Name / Macro", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ header.Copy = DF:CreateLabel (header, "Copy", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+ header.Delete = DF:CreateLabel (header, "Delete", DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
+
+ header.Index:SetPoint ("left", header, "left", 10, 0)
+ header.Key:SetPoint ("left", header, "left", 43, 0)
+ header.Action:SetPoint ("left", header, "left", 150, 0)
+ header.Macro:SetPoint ("left", header, "left", 276, 0)
+ header.Copy:SetPoint ("left", header, "left", 950, 0)
+ header.Delete:SetPoint ("left", header, "left", 990, 0)
+
+ new_keybind_frame:SetScript ("OnShow", function()
+
+ --new_keybind_frame.EditingSpec = EnemyGrid.CurrentSpec
+ --new_keybind_frame.CurrentKeybindEditingSet = EnemyGrid.CurrentKeybindSet
+
+ for _, button in ipairs (allSpecButtons) do
+ if (new_keybind_frame.EditingSpec ~= button.specID) then
+ button.selectedTexture:Hide()
+ else
+ button.selectedTexture:Show()
+ end
+ end
+
+ keybindScroll:UpdateScroll()
+ end)
+
+ new_keybind_frame:SetScript ("OnHide", function()
+ if (new_keybind_frame.IsListening) then
+ new_keybind_frame.IsListening = false
+ new_keybind_frame:SetScript ("OnKeyDown", nil)
+ end
+ end)
+
+ return new_keybind_frame
+end
+
+function DF:BuildKeybindFunctions (data, prefix)
+
+ --~keybind
+ local classLoc, class = UnitClass ("player")
+ local bindingList = data
+
+ local bindString = "self:ClearBindings()"
+ local bindKeyBindTypeFunc = [[local unitFrame = ...]]
+ local bindMacroTextFunc = [[local unitFrame = ...]]
+ local isMouseBinding
+
+ for i = 1, #bindingList do
+ local bind = bindingList [i]
+ local bindType
+
+ --which button to press
+ if (bind.key:find ("type")) then
+ local keyNumber = tonumber (bind.key:match ("%d"))
+ bindType = keyNumber
+ isMouseBinding = true
+ else
+ bindType = prefix .. "" .. i
+ bindString = bindString .. "self:SetBindingClick (0, '" .. bind.key .. "', self:GetName(), '" .. bindType .. "')"
+ bindType = "-" .. prefix .. "" .. i
+ isMouseBinding = nil
+ end
+
+ --keybind type
+ local shift, alt, ctrl = bind.key:match ("SHIFT"), bind.key:match ("ALT"), bind.key:match ("CTRL")
+ local CommandKeys = alt and alt .. "-" or ""
+ CommandKeys = ctrl and CommandKeys .. ctrl .. "-" or CommandKeys
+ CommandKeys = shift and CommandKeys .. shift .. "-" or CommandKeys
+
+ local keyBindType
+ if (isMouseBinding) then
+ keyBindType = [[unitFrame:SetAttribute ("@COMMANDtype@BINDTYPE", "macro")]]
+ else
+ keyBindType = [[unitFrame:SetAttribute ("type@BINDTYPE", "macro")]]
+ end
+
+ keyBindType = keyBindType:gsub ("@BINDTYPE", bindType)
+ keyBindType = keyBindType:gsub ("@COMMAND", CommandKeys)
+ bindKeyBindTypeFunc = bindKeyBindTypeFunc .. keyBindType
+
+ --spell or macro
+ if (bind.action == "_spell") then
+ local macroTextLine
+ if (isMouseBinding) then
+ macroTextLine = [[unitFrame:SetAttribute ("@COMMANDmacrotext@BINDTYPE", "/cast [@mouseover] @SPELL")]]
+ else
+ macroTextLine = [[unitFrame:SetAttribute ("macrotext@BINDTYPE", "/cast [@mouseover] @SPELL")]]
+ end
+ macroTextLine = macroTextLine:gsub ("@BINDTYPE", bindType)
+ macroTextLine = macroTextLine:gsub ("@SPELL", bind.actiontext)
+ macroTextLine = macroTextLine:gsub ("@COMMAND", CommandKeys)
+ bindMacroTextFunc = bindMacroTextFunc .. macroTextLine
+
+ elseif (bind.action == "_macro") then
+ local macroTextLine
+ if (isMouseBinding) then
+ macroTextLine = [[unitFrame:SetAttribute ("@COMMANDmacrotext@BINDTYPE", "@MACRO")]]
+ else
+ macroTextLine = [[unitFrame:SetAttribute ("macrotext@BINDTYPE", "@MACRO")]]
+ end
+ macroTextLine = macroTextLine:gsub ("@BINDTYPE", bindType)
+ macroTextLine = macroTextLine:gsub ("@MACRO", bind.actiontext)
+ macroTextLine = macroTextLine:gsub ("@COMMAND", CommandKeys)
+ bindMacroTextFunc = bindMacroTextFunc .. macroTextLine
+
+ end
+ end
+
+ --~key
+ local bindTypeFuncLoaded = loadstring (bindKeyBindTypeFunc)
+ local bindMacroFuncLoaded = loadstring (bindMacroTextFunc)
+
+ if (not bindMacroFuncLoaded or not bindTypeFuncLoaded) then
+ return
+ end
+
+ return bindString, bindTypeFuncLoaded, bindMacroFuncLoaded
+end
+
+
+function DF:SetKeybindsOnProtectedFrame (frame, bind_string, bind_type_func, bind_macro_func)
+
+ bind_type_func (frame)
+ bind_macro_func (frame)
+ frame:SetAttribute ("_onenter", bind_string)
+
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~standard backdrop
+
+function DF:ApplyStandardBackdrop (f, darkTheme, alphaScale)
+ alphaScale = alphaScale or 1.0
+
+ if (darkTheme) then
+ f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Cooldown\cooldown2]], tileSize = 32, tile = true})
+ f:SetBackdropBorderColor (0, 0, 0, 1)
+ f:SetBackdropColor (.54, .54, .54, .54 * alphaScale)
+ else
+ f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ f:SetBackdropBorderColor (0, 0, 0, 1)
+ f:SetBackdropColor (0, 0, 0, 0.2 * alphaScale)
+ end
+
+ if (not f.__background) then
+ f.__background = f:CreateTexture (nil, "background")
+ end
+
+ f.__background:SetColorTexture (0.2317647, 0.2317647, 0.2317647)
+ f.__background:SetVertexColor (0.27, 0.27, 0.27)
+ f.__background:SetAlpha (0.8 * alphaScale)
+ f.__background:SetVertTile (true)
+ f.__background:SetHorizTile (true)
+ f.__background:SetAllPoints()
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~title bar
+
+DF.TitleFunctions = {
+
+ SetTitle = function (self, titleText, titleColor, font, size)
+ self.TitleLabel:SetText (titleText or self.TitleLabel:GetText())
+
+ if (titleColor) then
+ local r, g, b, a = DF:ParseColors (titleColor)
+ self.TitleLabel:SetTextColor (r, g, b, a)
+ end
+
+ if (font) then
+ DF:SetFontFace (self.TitleLabel, font)
+ end
+
+ if (size) then
+ DF:SetFontSize (self.TitleLabel, size)
+ end
+ end
+
+
+}
+
+function DF:CreateTitleBar (f, titleText)
+
+ local titleBar = CreateFrame ("frame", f:GetName() and f:GetName() .. "TitleBar" or nil, f)
+ titleBar:SetPoint ("topleft", f, "topleft", 2, -3)
+ titleBar:SetPoint ("topright", f, "topright", -2, -3)
+ titleBar:SetHeight (20)
+ titleBar:SetBackdrop (SimplePanel_frame_backdrop) --it's an upload from this file
+ titleBar:SetBackdropColor (.2, .2, .2, 1)
+ titleBar:SetBackdropBorderColor (0, 0, 0, 1)
+
+ local closeButton = CreateFrame ("button", titleBar:GetName() and titleBar:GetName() .. "CloseButton" or nil, titleBar)
+ closeButton:SetSize (16, 16)
+ closeButton:SetNormalTexture (DF.folder .. "icons")
+ closeButton:SetHighlightTexture (DF.folder .. "icons")
+ closeButton:SetPushedTexture (DF.folder .. "icons")
+ closeButton:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
+ closeButton:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
+ closeButton:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
+ closeButton:SetAlpha (0.7)
+ closeButton:SetScript ("OnClick", simple_panel_close_click) --upvalue from this file
+
+ local titleLabel = titleBar:CreateFontString (titleBar:GetName() and titleBar:GetName() .. "TitleText" or nil, "overlay", "GameFontNormal")
+ titleLabel:SetTextColor (.8, .8, .8, 1)
+ titleLabel:SetText (titleText or "")
+
+ --anchors
+ closeButton:SetPoint ("right", titleBar, "right", -2, 0)
+ titleLabel:SetPoint ("center", titleBar, "center")
+
+ --members
+ f.TitleBar = titleBar
+ f.CloseButton = closeButton
+ f.TitleLabel = titleLabel
+
+ DF:Mixin (f, DF.TitleFunctions)
+
+ return titleBar
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- ~icon row
+
+DF.IconRowFunctions = {
+
+ GetIcon = function (self)
+ local iconFrame = self.IconPool [self.NextIcon]
+
+ if (not iconFrame) then
+ local newIconFrame = CreateFrame ("frame", "$parentIcon" .. self.NextIcon, self)
+
+ newIconFrame.Texture = newIconFrame:CreateTexture (nil, "artwork")
+ PixelUtil.SetPoint (newIconFrame.Texture, "topleft", newIconFrame, "topleft", 1, -1)
+ PixelUtil.SetPoint (newIconFrame.Texture, "bottomright", newIconFrame, "bottomright", -1, 1)
+
+ newIconFrame.Border = newIconFrame:CreateTexture (nil, "background")
+ newIconFrame.Border:SetAllPoints()
+ newIconFrame.Border:SetColorTexture (0, 0, 0)
+
+ newIconFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
+ newIconFrame:SetBackdropBorderColor (0, 0, 0, 0)
+ newIconFrame:EnableMouse (false)
+
+ local cooldownFrame = CreateFrame ("cooldown", "$parentIconCooldown" .. self.NextIcon, newIconFrame, "CooldownFrameTemplate")
+ cooldownFrame:SetAllPoints()
+ cooldownFrame:EnableMouse (false)
+ cooldownFrame:SetFrameLevel (newIconFrame:GetFrameLevel()+1)
+
+ newIconFrame.CountdownText = cooldownFrame:CreateFontString (nil, "overlay", "GameFontNormal")
+ newIconFrame.CountdownText:SetPoint ("center")
+ newIconFrame.CountdownText:Hide()
+
+ newIconFrame.Desc = newIconFrame:CreateFontString (nil, "overlay", "GameFontNormal")
+ newIconFrame.Desc:SetPoint ("bottom", newIconFrame, "top", 0, 2)
+ newIconFrame.Desc:Hide()
+
+ newIconFrame.Cooldown = cooldownFrame
+
+ self.IconPool [self.NextIcon] = newIconFrame
+ iconFrame = newIconFrame
+ end
+
+ iconFrame:ClearAllPoints()
+
+ local anchor = self.options.anchor
+ local anchorTo = self.NextIcon == 1 and self or self.IconPool [self.NextIcon - 1]
+ local xPadding = self.NextIcon == 1 and self.options.left_padding or self.options.icon_padding
+ local growDirection = self.options.grow_direction
+
+ if (growDirection == 1) then --grow to right
+ if (self.NextIcon == 1) then
+ PixelUtil.SetPoint (iconFrame, "left", anchorTo, "left", xPadding, 0)
+ else
+ PixelUtil.SetPoint (iconFrame, "left", anchorTo, "right", xPadding, 0)
+ end
+
+ elseif (growDirection == 2) then --grow to left
+ if (self.NextIcon == 1) then
+ PixelUtil.SetPoint (iconFrame, "right", anchorTo, "right", xPadding, 0)
+ else
+ PixelUtil.SetPoint (iconFrame, "right", anchorTo, "left", xPadding, 0)
+ end
+
+ end
+
+ DF:SetFontColor (iconFrame.CountdownText, self.options.text_color)
+
+ self.NextIcon = self.NextIcon + 1
+ return iconFrame
+ end,
+
+ SetIcon = function (self, spellId, borderColor, startTime, duration, forceTexture, descText)
+
+ local spellName, _, spellIcon
+
+ if (not forceTexture) then
+ spellName, _, spellIcon = GetSpellInfo (spellId)
+ else
+ spellIcon = forceTexture
+ end
+
+ if (spellIcon) then
+ local iconFrame = self:GetIcon()
+ iconFrame.Texture:SetTexture (spellIcon)
+ iconFrame.Texture:SetTexCoord (unpack (self.options.texcoord))
+
+ if (borderColor) then
+ iconFrame:SetBackdropBorderColor (Plater:ParseColors (borderColor))
+ else
+ iconFrame:SetBackdropBorderColor (0, 0, 0 ,0)
+ end
+
+ if (startTime) then
+ CooldownFrame_Set (iconFrame.Cooldown, startTime, duration, true, true)
+
+ if (self.options.show_text) then
+ iconFrame.CountdownText:Show()
+
+ local formattedTime = floor (startTime + duration - GetTime())
+
+ if (formattedTime >= 3600) then
+ formattedTime = floor (formattedTime / 3600) .. "h"
+
+ elseif (formattedTime >= 60) then
+ formattedTime = floor (formattedTime / 60) .. "m"
+
+ else
+ formattedTime = floor (formattedTime)
+ end
+
+ iconFrame.CountdownText:SetText (formattedTime)
+ iconFrame.Cooldown:SetHideCountdownNumbers (true)
+ else
+ iconFrame.CountdownText:Hide()
+ iconFrame.Cooldown:SetHideCountdownNumbers (false)
+ end
+ else
+ iconFrame.CountdownText:Hide()
+ end
+
+ if (descText and self.options.desc_text) then
+ iconFrame.Desc:Show()
+ iconFrame.Desc:SetText (descText.text)
+ iconFrame.Desc:SetTextColor (DF:ParseColors (descText.text_color or self.options.desc_text_color))
+ DF:SetFontSize (iconFrame.Desc, descText.text_size or self.options.desc_text_size)
+ else
+ iconFrame.Desc:Hide()
+ end
+
+ PixelUtil.SetSize (iconFrame, self.options.icon_width, self.options.icon_height)
+ iconFrame:Show()
+
+ --> update the size of the frame
+ self:SetWidth ((self.options.left_padding * 2) + (self.options.icon_padding * (self.NextIcon-2)) + (self.options.icon_width * (self.NextIcon - 1)))
+ self:SetHeight (self.options.icon_height + (self.options.top_padding * 2))
+
+ --> show the frame
+ self:Show()
+
+ return iconFrame
+ end
+ end,
+
+ ClearIcons = function (self)
+ for i = 1, self.NextIcon -1 do
+ self.IconPool [i]:Hide()
+ end
+ self.NextIcon = 1
+ self:Hide()
+ end,
+
+ GetIconGrowDirection = function (self)
+ local side = self.options.anchor.side
+
+ if (side == 1) then
+ return 1
+ elseif (side == 2) then
+ return 2
+ elseif (side == 3) then
+ return 1
+ elseif (side == 4) then
+ return 1
+ elseif (side == 5) then
+ return 2
+ elseif (side == 6) then
+ return 1
+ elseif (side == 7) then
+ return 2
+ elseif (side == 8) then
+ return 1
+ elseif (side == 9) then
+ return 1
+ elseif (side == 10) then
+ return 1
+ elseif (side == 11) then
+ return 2
+ elseif (side == 12) then
+ return 1
+ elseif (side == 13) then
+ return 1
+ end
+ end,
+
+ OnOptionChanged = function (self, optionName)
+ self:SetBackdropColor (unpack (self.options.backdrop_color))
+ self:SetBackdropBorderColor (unpack (self.options.backdrop_border_color))
+ end,
+}
+
+local default_icon_row_options = {
+ icon_width = 20,
+ icon_height = 20,
+ texcoord = {.1, .9, .1, .9},
+ show_text = true,
+ text_color = {1, 1, 1, 1},
+ desc_text = true,
+ desc_text_color = {1, 1, 1, 1},
+ desc_text_size = 7,
+ left_padding = 1, --distance between right and left
+ top_padding = 1, --distance between top and bottom
+ icon_padding = 1, --distance between each icon
+ backdrop = {},
+ backdrop_color = {0, 0, 0, 0.5},
+ backdrop_border_color = {0, 0, 0, 1},
+ anchor = {side = 6, x = 2, y = 0},
+ grow_direction = 1, --1 = to right 2 = to left
+}
+
+function DF:CreateIconRow (parent, name, options)
+ local f = CreateFrame ("frame", name, parent)
+ f.IconPool = {}
+ f.NextIcon = 1
+
+ DF:Mixin (f, DF.IconRowFunctions)
+ DF:Mixin (f, DF.OptionsFunctions)
+
+ f:BuildOptionsTable (default_icon_row_options, options)
+
+ f:SetSize (f.options.icon_width, f.options.icon_height + (f.options.top_padding * 2))
+
+ f:SetBackdrop (f.options.backdrop)
+ f:SetBackdropColor (unpack (f.options.backdrop_color))
+ f:SetBackdropBorderColor (unpack (f.options.backdrop_border_color))
+
+ return f
+end
+
+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> ~header
+
+DF.HeaderFunctions = {
+ AddFrameToHeaderAlignment = function (self, frame)
+ self.FramesToAlign = self.FramesToAlign or {}
+ tinsert (self.FramesToAlign, frame)
+ end,
+
+ AlignWithHeader = function (self, headerFrame, anchor)
+ local headerFrames = headerFrame.HeadersCreated
+ anchor = anchor or "topleft"
+
+ for i = 1, #self.FramesToAlign do
+ local frame = self.FramesToAlign [i]
+ frame:ClearAllPoints()
+
+ local headerFrame = headerFrames [i]
+ frame:SetPoint (anchor, self, anchor, headerFrame.XPosition, 0)
+ end
+ end,
+}
+
+DF.HeaderCoreFunctions = {
+ SetHeaderTable = function (self, newTable)
+ self.HeadersCreated = self.HeadersCreated or {}
+ self.HeaderTable = newTable
+ self.NextHeader = 1
+ self.HeaderWidth = 0
+ self.HeaderHeight = 0
+ self:Refresh()
+ end,
+
+ Refresh = function (self)
+
+ --> refresh background frame
+ self:SetBackdrop (self.options.backdrop)
+ self:SetBackdropColor (unpack (self.options.backdrop_color))
+ self:SetBackdropBorderColor (unpack (self.options.backdrop_border_color))
+
+ --> reset all header frames
+ for i = 1, #self.HeadersCreated do
+ self.HeadersCreated [i].InUse = false
+ self.HeadersCreated [i]:Hide()
+ end
+
+ local previousHeaderFrame
+ local growDirection = string.lower (self.options.grow_direction)
+
+ --> update header frames
+ local headerSize = #self.HeaderTable
+ for i = 1, headerSize do
+ local headerFrame = self:GetNextHeader()
+ self:UpdateHeaderFrame (headerFrame, i)
+
+ --> grow direction
+ if (not previousHeaderFrame) then
+ headerFrame:SetPoint ("topleft", self, "topleft", 0, 0)
+ else
+ if (growDirection == "right") then
+ headerFrame:SetPoint ("topleft", previousHeaderFrame, "topright", self.options.padding, 0)
+ elseif (growDirection == "left") then
+ headerFrame:SetPoint ("topright", previousHeaderFrame, "topleft", -self.options.padding, 0)
+ elseif (growDirection == "bottom") then
+ headerFrame:SetPoint ("topleft", previousHeaderFrame, "bottomleft", 0, -self.options.padding)
+ elseif (growDirection == "top") then
+ headerFrame:SetPoint ("bottomleft", previousHeaderFrame, "topleft", 0, self.options.padding)
+ end
+ end
+
+ previousHeaderFrame = headerFrame
+ end
+
+ self:SetSize (self.HeaderWidth, self.HeaderHeight)
+
+ end,
+
+ UpdateHeaderFrame = function (self, headerFrame, headerIndex)
+ local headerData = self.HeaderTable [headerIndex]
+
+ if (headerData.icon) then
+ headerFrame.Icon:SetTexture (headerData.icon)
+
+ if (headerData.texcoord) then
+ headerFrame.Icon:SetTexCoord (unpack (headerData.texcoord))
+ else
+ headerFrame.Icon:SetTexCoord (0, 1, 0, 1)
+ end
+
+ headerFrame.Icon:SetPoint ("left", headerFrame, "left", self.options.padding, 0)
+ headerFrame.Icon:Show()
+ end
+
+ if (headerData.text) then
+ headerFrame.Text:SetText (headerData.text)
+
+ --> text options
+ DF:SetFontColor (headerFrame.Text, self.options.text_color)
+ DF:SetFontSize (headerFrame.Text, self.options.text_size)
+ DF:SetFontOutline (headerFrame.Text, self.options.text_shadow)
+
+ --> point
+ if (not headerData.icon) then
+ headerFrame.Text:SetPoint ("left", headerFrame, "left", self.options.padding, 0)
+ else
+ headerFrame.Text:SetPoint ("left", headerFrame.Icon, "right", self.options.padding, 0)
+ end
+
+ headerFrame.Text:Show()
+ end
+
+ --> size
+ if (headerData.width) then
+ headerFrame:SetWidth (headerData.width)
+ end
+ if (headerData.height) then
+ headerFrame:SetHeight (headerData.height)
+ end
+
+ headerFrame.XPosition = self.HeaderWidth-- + self.options.padding
+ headerFrame.YPosition = self.HeaderHeight-- + self.options.padding
+
+ --> add the header piece size to the total header size
+ local growDirection = string.lower (self.options.grow_direction)
+
+ if (growDirection == "right" or growDirection == "left") then
+ self.HeaderWidth = self.HeaderWidth + headerFrame:GetWidth() + self.options.padding
+ self.HeaderHeight = math.max (self.HeaderHeight, headerFrame:GetHeight())
+
+ elseif (growDirection == "top" or growDirection == "bottom") then
+ self.HeaderWidth = math.max (self.HeaderWidth, headerFrame:GetWidth())
+ self.HeaderHeight = self.HeaderHeight + headerFrame:GetHeight() + self.options.padding
+ end
+
+ headerFrame:Show()
+ headerFrame.InUse = true
+ end,
+
+ RefreshHeader = function (self, headerFrame)
+ headerFrame:SetSize (self.options.header_width, self.options.header_height)
+ headerFrame:SetBackdrop (self.options.header_backdrop)
+ headerFrame:SetBackdropColor (unpack (self.options.header_backdrop_color))
+ headerFrame:SetBackdropBorderColor (unpack (self.options.header_backdrop_border_color))
+
+ headerFrame:ClearAllPoints()
+
+ headerFrame.Icon:SetTexture ("")
+ headerFrame.Icon:Hide()
+ headerFrame.Text:SetText ("")
+ headerFrame.Text:Hide()
+ end,
+
+ GetNextHeader = function (self)
+ local nextHeader = self.NextHeader
+ local headerFrame = self.HeadersCreated [nextHeader]
+
+ if (not headerFrame) then
+ local newHeader = CreateFrame ("frame", "$parentHeaderIndex" .. nextHeader, self)
+
+ DF:CreateImage (newHeader, "", self.options.header_height, self.options.header_height, "ARTWORK", nil, "Icon", "$parentIcon")
+ DF:CreateLabel (newHeader, "", self.options.text_size, self.options.text_color, "GameFontNormal", "Text", "$parentText", "ARTWORK")
+
+ tinsert (self.HeadersCreated, newHeader)
+ headerFrame = newHeader
+ end
+
+ self:RefreshHeader (headerFrame)
+ self.NextHeader = self.NextHeader + 1
+ return headerFrame
+ end,
+
+ NextHeader = 1,
+ HeaderWidth = 0,
+ HeaderHeight = 0,
+}
+
+local default_header_options = {
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {0, 0, 0, 0.2},
+ backdrop_border_color = {0.1, 0.1, 0.1, .2},
+
+ text_color = {1, 1, 1, 1},
+ text_size = 10,
+ text_shadow = false,
+ grow_direction = "RIGHT",
+ padding = 2,
+
+ --each piece of the header
+ header_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ header_backdrop_color = {0, 0, 0, 0.5},
+ header_backdrop_border_color = {0, 0, 0, 0},
+ header_width = 120,
+ header_height = 20,
+
+}
+
+function DF:CreateHeader (parent, headerTable, options)
+ local f = CreateFrame ("frame", "$parentHeaderLine", parent)
+
+ DF:Mixin (f, DF.OptionsFunctions)
+ DF:Mixin (f, DF.HeaderCoreFunctions)
+
+ f:BuildOptionsTable (default_header_options, options)
+
+ f:SetBackdrop (f.options.backdrop)
+ f:SetBackdropColor (unpack (f.options.backdrop_color))
+ f:SetBackdropBorderColor (unpack (f.options.backdrop_border_color))
+
+ f:SetHeaderTable (headerTable)
+
+ return f
+end
+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> radio group
+
+local default_radiogroup_options = {
+ width = 1,
+ height = 1,
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {0, 0, 0, 0.2},
+ backdrop_border_color = {0.1, 0.1, 0.1, .2},
+ is_radio = false,
+}
+
+DF.RadioGroupCoreFunctions = {
+ RadioOnClick = function (self, fixedParam, value)
+ --turn off all checkboxes
+ local frameList = {self:GetParent():GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
+ checkbox:SetValue (false)
+ end
+
+ --turn on the clicked checkbox
+ self:SetValue (true)
+
+ --callback
+ DF:QuickDispatch (self._set, fixedParam)
+ end,
+
+ Disable = function (self)
+ local frameList = {self:GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
+ checkbox:Disable()
+ end
+ end,
+
+ Enable = function (self)
+ local frameList = {self:GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
+ checkbox:Enable()
+ end
+ end,
+
+ DeselectAll = function (self)
+ local frameList = {self:GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
+ checkbox:SetValue (false)
+ end
+ end,
+
+ FadeIn = function (self)
+ local frameList = {self:GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox:SetAlpha (1)
+ end
+ end,
+
+ FadeOut = function (self)
+ local frameList = {self:GetChildren()}
+ for _, checkbox in ipairs (frameList) do
+ checkbox:SetAlpha (.7)
+ end
+ end,
+
+ SetFadeState = function (self, state)
+ if (state) then
+ self:FadeIn()
+ else
+ self:FadeOut()
+ end
+ end,
+
+ CreateCheckbox = function (self)
+ local checkbox = DF:CreateSwitch (self, function()end, false, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
+ checkbox:SetAsCheckBox()
+ checkbox.Icon = DF:CreateImage (checkbox, "", 16, 16)
+ checkbox.Label = DF:CreateLabel (checkbox, "")
+
+ return checkbox
+ end,
+
+ RefreshCheckbox = function (self, checkbox, optionTable)
+ checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
+
+ local setFunc = self.options.is_radio and self.RadioOnClick or optionTable.set
+ checkbox:SetSwitchFunction (setFunc)
+ checkbox._set = setFunc
+ checkbox:SetFixedParameter (optionTable.param)
+
+ local isChecked = DF:Dispatch (optionTable.get)
+ checkbox:SetValue (isChecked)
+
+ checkbox.Label:SetText (optionTable.name)
+
+ if (optionTable.texture) then
+ checkbox.Icon:SetTexture (optionTable.texture)
+ checkbox.Icon:SetPoint ("left", checkbox, "right", 2, 0)
+ checkbox.Label:SetPoint ("left", checkbox.Icon, "right", 2, 0)
+
+ if (optionTable.texcoord) then
+ checkbox.Icon:SetTexCoord (unpack (optionTable.texcoord))
+ else
+ checkbox.Icon:SetTexCoord (0, 1, 0, 1)
+ end
+ else
+ checkbox.Icon:SetTexture ("")
+ checkbox.Label:SetPoint ("left", checkbox, "right", 2, 0)
+ end
+ end,
+
+ Refresh = function (self)
+ local radioOptions = self.RadioOptionsTable
+ local radioCheckboxes = {self:GetChildren()}
+
+ for _, checkbox in ipairs (radioCheckboxes) do
+ checkbox:Hide()
+ end
+
+ for radioIndex, optionsTable in ipairs (radioOptions) do
+ local checkbox = radioCheckboxes [radioIndex]
+ if (not checkbox) then
+ checkbox = self:CreateCheckbox()
+ end
+ checkbox.OptionID = radioIndex
+ checkbox:Show()
+ self:RefreshCheckbox (checkbox, optionsTable)
+ end
+
+ --sending false to automatically use the radio group children
+ self:ArrangeFrames (false, self.AnchorOptions)
+ end,
+
+ SetOptions = function (self, radioOptions)
+ self.RadioOptionsTable = radioOptions
+ self:Refresh()
+ end,
+}
+
+--[=[
+ radionOptions: an index table with options for the radio group {name = "", set = func (self, param, value), param = value, get = func, texture = "", texcoord = {}}
+ set function receives as self the checkbox, use :GetParent() to get the radion group frame
+ if get function return nil or false the checkbox isn't checked
+ name: the name of the frame
+ options: override options for default_radiogroup_options table
+ anchorOptions: override options for default_framelayout_options table
+--]=]
+function DF:CreateRadionGroup (parent, radioOptions, name, options, anchorOptions)
+ local f = CreateFrame ("frame", name, parent)
+
+ DF:Mixin (f, DF.OptionsFunctions)
+ DF:Mixin (f, DF.RadioGroupCoreFunctions)
+ DF:Mixin (f, DF.LayoutFrame)
+
+ f:BuildOptionsTable (default_radiogroup_options, options)
+
+ f:SetSize (f.options.width, f.options.height)
+ f:SetBackdrop (f.options.backdrop)
+ f:SetBackdropColor (unpack (f.options.backdrop_color))
+ f:SetBackdropBorderColor (unpack (f.options.backdrop_border_color))
+
+ f.AnchorOptions = anchorOptions or {}
+
+ if (f.options.title) then
+ local titleLabel = DF:CreateLabel (f, f.options.title, DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ titleLabel:SetPoint ("bottomleft", f, "topleft", 0, 2)
+ f.Title = titleLabel
+ end
+
+ f:SetOptions (radioOptions)
+
+ return f
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> load conditions panel
+
+--this is the table prototype to hold load conditions settings
+local default_load_conditions = {
+ class = {},
+ spec = {},
+ race = {},
+ talent = {},
+ pvptalent = {},
+ group = {},
+ role = {},
+ affix = {},
+ encounter_ids = {},
+ map_ids = {},
+}
+
+local default_load_conditions_frame_options = {
+ title = "Details! Framework: Load Conditions",
+ name = "Object",
+}
+
+function DF:CreateLoadFilterParser (callback)
+ local f = CreateFrame ("frame")
+ f:RegisterEvent ("PLAYER_ENTERING_WORLD")
+ f:RegisterEvent ("PLAYER_SPECIALIZATION_CHANGED")
+ f:RegisterEvent ("PLAYER_TALENT_UPDATE")
+ f:RegisterEvent ("PLAYER_ROLES_ASSIGNED")
+ f:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
+ f:RegisterEvent ("CHALLENGE_MODE_START")
+ f:RegisterEvent ("ENCOUNTER_START")
+ f:RegisterEvent ("PLAYER_REGEN_ENABLED")
+
+ f:SetScript ("OnEvent", function (self, event, ...)
+ if (event == "ENCOUNTER_START") then
+ local encounterID = ...
+ f.EncounterIDCached = encounterID
+
+ elseif (event == "PLAYER_REGEN_ENABLED") then
+ f.EncounterIDCached = nil
+
+ elseif (event == "PLAYER_SPECIALIZATION_CHANGED") then
+ if (DetailsFrameworkLoadConditionsPanel and DetailsFrameworkLoadConditionsPanel:IsShown()) then
+ DetailsFrameworkLoadConditionsPanel:Refresh()
+ end
+
+ local unit = ...
+ if (not unit or not UnitIsUnit ("player", unit)) then
+ return
+ end
+
+ elseif (event == "PLAYER_ROLES_ASSIGNED") then
+ local assignedRole = UnitGroupRolesAssigned ("player")
+ if (assignedRole == "NONE") then
+ local spec = GetSpecialization()
+ if (spec) then
+ assignedRole = GetSpecializationRole (spec)
+ end
+ end
+
+ if (DF.CurrentPlayerRole == assignedRole) then
+ return
+ end
+
+ DF.CurrentPlayerRole = assignedRole
+ end
+
+ --print ("Plater Script Update:", event, ...)
+
+ DF:QuickDispatch (callback, f.EncounterIDCached)
+ end)
+end
+
+function DF:PassLoadFilters (loadTable, encounterID)
+ --class
+ local passLoadClass
+ if (loadTable.class.Enabled) then
+ local _, classFileName = UnitClass ("player")
+ if (not loadTable.class [classFileName]) then
+ return false
+ else
+ passLoadClass = true
+ end
+ end
+
+ --spec
+ if (loadTable.spec.Enabled) then
+ local canCheckTalents = true
+
+ if (passLoadClass) then
+ --if is allowed to load on this class, check if the talents isn't from another class
+ local _, classFileName = UnitClass ("player")
+ local specsForThisClass = DF:GetClassSpecIDs (classFileName)
+
+ canCheckTalents = false
+
+ for _, specID in ipairs (specsForThisClass) do
+ if (loadTable.spec [specID]) then
+ --theres a talent for this class
+ canCheckTalents = true
+ break
+ end
+ end
+ end
+
+ if (canCheckTalents) then
+ local specIndex = GetSpecialization()
+ if (specIndex) then
+ local specID = GetSpecializationInfo (specIndex)
+ if (not loadTable.spec [specID]) then
+ return false
+ end
+ else
+ return false
+ end
+ end
+ end
+
+ --race
+ if (loadTable.race.Enabled) then
+ local raceName, raceFileName, raceID = UnitRace ("player")
+ if (not loadTable.race [raceFileName]) then
+ return false
+ end
+ end
+
+ --talents
+ if (loadTable.talent.Enabled) then
+ local talentsInUse = DF:GetCharacterTalents (false, true)
+ local hasTalent
+ for talentID, _ in pairs (talentsInUse) do
+ if (loadTable.talent [talentID]) then
+ hasTalent = true
+ break
+ end
+ end
+ if (not hasTalent) then
+ return false
+ end
+ end
+
+ --pvptalent
+ if (loadTable.pvptalent.Enabled) then
+ local talentsInUse = DF:GetCharacterPvPTalents (false, true)
+ local hasTalent
+ for talentID, _ in pairs (talentsInUse) do
+ if (loadTable.pvptalent [talentID]) then
+ hasTalent = true
+ break
+ end
+ end
+ if (not hasTalent) then
+ return false
+ end
+ end
+
+ --group
+ if (loadTable.group.Enabled) then
+ local _, zoneType = GetInstanceInfo()
+ if (not loadTable.group [zoneType]) then
+ return
+ end
+ end
+
+ --role
+ if (loadTable.role.Enabled) then
+ local assignedRole = UnitGroupRolesAssigned ("player")
+ if (assignedRole == "NONE") then
+ local spec = GetSpecialization()
+ if (spec) then
+ assignedRole = GetSpecializationRole (spec)
+ end
+ end
+ if (not loadTable.role [assignedRole]) then
+ return false
+ end
+ end
+
+ --affix
+ if (loadTable.affix.Enabled) then
+ local isInMythicDungeon = C_ChallengeMode.IsChallengeModeActive()
+ if (not isInMythicDungeon) then
+ return false
+ end
+
+ local level, affixes, wasEnergized = C_ChallengeMode.GetActiveKeystoneInfo()
+ local hasAffix = false
+ for _, affixID in ipairs (affixes) do
+ if (loadTable.affix [affixID]) then
+ hasAffix = true
+ break
+ end
+ end
+
+ if (not hasAffix) then
+ return false
+ end
+ end
+
+ --encounter id
+ if (loadTable.encounter_ids.Enabled) then
+ if (not encounterID) then
+ return
+ end
+ local hasEncounter
+ for _, ID in ipairs (loadTable.encounter_ids) do
+ if (ID == encounterID) then
+ hasEncounter = true
+ break
+ end
+ if (not hasEncounter) then
+ return false
+ end
+ end
+ end
+
+ --map id
+ if (loadTable.map_ids.Enabled) then
+ local _, _, _, _, _, _, _, zoneMapID = GetInstanceInfo()
+ local uiMapID = C_Map.GetBestMapForUnit ("player")
+
+ local hasMapID
+ for _, ID in ipairs (loadTable.map_ids) do
+ if (ID == zoneMapID or ID == uiMapID) then
+ hasMapID = true
+ break
+ end
+ if (not hasMapID) then
+ return false
+ end
+ end
+ end
+
+ return true
+end
+
+--this func will deploy the default values from the prototype into the config table
+function DF:UpdateLoadConditionsTable (configTable)
+ configTable = configTable or {}
+ DF.table.deploy (configTable, default_load_conditions)
+ return configTable
+end
+
+--/run Plater.OpenOptionsPanel()PlaterOptionsPanelContainer:SelectIndex (Plater, 14)
+
+function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
+
+ frameOptions = frameOptions or {}
+ DF.table.deploy (frameOptions, default_load_conditions_frame_options)
+
+ DF:UpdateLoadConditionsTable (optionsTable)
+
+ if (not DetailsFrameworkLoadConditionsPanel) then
+
+ local f = DF:CreateSimplePanel (UIParent, 970, 505, "Load Conditions", "DetailsFrameworkLoadConditionsPanel")
+ f:SetBackdropColor (0, 0, 0, 1)
+ f.AllRadioGroups = {}
+ f.AllTextEntries = {}
+ f.OptionsTable = optionsTable
+
+ DF:ApplyStandardBackdrop (f, false, 1.1)
+
+ local xStartAt = 10
+ local x2StartAt = 500
+ local anchorPositions = {
+ class = {xStartAt, -70},
+ spec = {xStartAt, -170},
+ race = {xStartAt, -210},
+ role = {xStartAt, -310},
+ talent = {xStartAt, -350},
+ pvptalent = {x2StartAt, -70},
+ group = {x2StartAt, -210},
+ affix = {x2StartAt, -270},
+ encounter_ids = {x2StartAt, -360},
+ map_ids = {x2StartAt, -400},
+ }
+
+ local editingLabel = DF:CreateLabel (f, "Load Conditions For:")
+ local editingWhatLabel = DF:CreateLabel (f, "")
+ editingLabel:SetPoint ("topleft", f, "topleft", 10, -35)
+ editingWhatLabel:SetPoint ("left", editingLabel, "right", 2, 0)
+
+ --this label store the name of what is being edited
+ f.EditingLabel = editingWhatLabel
+
+ --when the user click on an option, run the callback
+ f.RunCallback = function()
+ DF:Dispatch (f.CallbackFunc)
+ end
+
+ --when the user click on an option or when the panel is opened
+ --check if there's an option enabled and fadein all options, fadeout otherwise
+ f.OnRadioStateChanged = function (radioGroup, subConfigTable)
+ subConfigTable.Enabled = nil
+ subConfigTable.Enabled = next (subConfigTable) and true or nil
+ radioGroup:SetFadeState (subConfigTable.Enabled)
+ end
+
+ --create the radio group for character class
+ f.OnRadioCheckboxClick = function (self, key, value)
+ --hierarchy: DBKey ["class"] key ["HUNTER"] value TRUE
+ local DBKey = self:GetParent().DBKey
+ f.OptionsTable [DBKey] [key] = value and true or nil
+ f.OnRadioStateChanged (self:GetParent(), f.OptionsTable [DBKey])
+ f.RunCallback()
+ end
+
+ --create the radio group for classes
+ local classes = {}
+ for _, classTable in pairs (DF:GetClassList()) do
+ tinsert (classes, {
+ name = classTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = classTable.FileString,
+ get = function() return f.OptionsTable.class [classTable.FileString] end,
+ texture = classTable.Texture,
+ texcoord = classTable.TexCoord,
+ })
+ end
+
+ local classGroup = DF:CreateRadionGroup (f, classes, name, {width = 200, height = 200, title = "Character Class"}, {offset_x = 130, amount_per_line = 3})
+ classGroup:SetPoint ("topleft", f, "topleft", anchorPositions.class [1], anchorPositions.class [2])
+ classGroup.DBKey = "class"
+ tinsert (f.AllRadioGroups, classGroup)
+
+ --create the radio group for character spec
+ local specs = {}
+ for _, specID in ipairs (DF:GetClassSpecIDs (select (2, UnitClass ("player")))) do
+ local specID, specName, specDescription, specIcon, specBackground, specRole, specClass = GetSpecializationInfoByID (specID)
+ tinsert (specs, {
+ name = specName,
+ set = f.OnRadioCheckboxClick,
+ param = specID,
+ get = function() return f.OptionsTable.spec [specID] end,
+ texture = specIcon,
+ })
+ end
+ local specGroup = DF:CreateRadionGroup (f, specs, name, {width = 200, height = 200, title = "Character Spec"}, {offset_x = 130, amount_per_line = 4})
+ specGroup:SetPoint ("topleft", f, "topleft", anchorPositions.spec [1], anchorPositions.spec [2])
+ specGroup.DBKey = "spec"
+ tinsert (f.AllRadioGroups, specGroup)
+
+ --create radio group for character races
+ local raceList = {}
+ for _, raceTable in ipairs (DF:GetCharacterRaceList()) do
+ tinsert (raceList, {
+ name = raceTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = raceTable.FileString,
+ get = function() return f.OptionsTable.race [raceTable.FileString] end,
+ })
+ end
+ local raceGroup = DF:CreateRadionGroup (f, raceList, name, {width = 200, height = 200, title = "Character Race"})
+ raceGroup:SetPoint ("topleft", f, "topleft", anchorPositions.race [1], anchorPositions.race [2])
+ raceGroup.DBKey = "race"
+ tinsert (f.AllRadioGroups, raceGroup)
+
+ --create radio group for talents
+ local talentList = {}
+ for _, talentTable in ipairs (DF:GetCharacterTalents()) do
+ tinsert (talentList, {
+ name = talentTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = talentTable.ID,
+ get = function() return f.OptionsTable.talent [talentTable.ID] end,
+ texture = talentTable.Texture,
+ })
+ end
+ local talentGroup = DF:CreateRadionGroup (f, talentList, name, {width = 200, height = 200, title = "Characer Talents"}, {offset_x = 150, amount_per_line = 3})
+ talentGroup:SetPoint ("topleft", f, "topleft", anchorPositions.talent [1], anchorPositions.talent [2])
+ talentGroup.DBKey = "talent"
+ tinsert (f.AllRadioGroups, talentGroup)
+ f.TalentGroup = talentGroup
+
+ do
+ --create a frame to show talents selected in other specs or characters
+ local otherTalents = CreateFrame ("frame", nil, f)
+ otherTalents:SetSize (26, 26)
+ otherTalents:SetPoint ("left", talentGroup.Title.widget, "right", 10, -2)
+ otherTalents.Texture = DF:CreateImage (otherTalents, [[Interface\BUTTONS\AdventureGuideMicrobuttonAlert]], 24, 24)
+ otherTalents.Texture:SetAllPoints()
+
+ local removeTalent = function (_, _, talentID)
+ f.OptionsTable.talent [talentID] = nil
+ GameCooltip2:Hide()
+ f.OnRadioStateChanged (talentGroup, f.OptionsTable [talentGroup.DBKey])
+ f.CanShowTalentWarning()
+ end
+
+ local buildTalentMenu = function()
+ local playerTalents = DF:GetCharacterTalents()
+ local indexedTalents = {}
+ for _, talentTable in ipairs (playerTalents) do
+ tinsert (indexedTalents, talentTable.ID)
+ end
+
+ --talents selected to load
+ GameCooltip2:AddLine ("select a talent to remove it (added from a different spec or character)", "", 1, "orange", "orange", 9)
+ GameCooltip2:AddLine ("$div", nil, nil, -1, -1)
+
+ for talentID, _ in pairs (f.OptionsTable.talent) do
+ if (type (talentID) == "number" and not DF.table.find (indexedTalents, talentID)) then
+ local talentID, name, texture, selected, available = GetTalentInfoByID (talentID)
+ if (name) then
+ GameCooltip2:AddLine (name)
+ GameCooltip2:AddIcon (texture, 1, 1, 16, 16, .1, .9, .1, .9)
+ GameCooltip2:AddMenu (1, removeTalent, talentID)
+ end
+ end
+ end
+ end
+
+ otherTalents.CoolTip = {
+ Type = "menu",
+ BuildFunc = buildTalentMenu,
+ OnEnterFunc = function (self) end,
+ OnLeaveFunc = function (self) end,
+ FixedValue = "none",
+ ShowSpeed = 0.05,
+ Options = function()
+ GameCooltip2:SetOption ("TextFont", "Friz Quadrata TT")
+ GameCooltip2:SetOption ("TextColor", "orange")
+ GameCooltip2:SetOption ("TextSize", 12)
+ GameCooltip2:SetOption ("FixedWidth", 220)
+ GameCooltip2:SetOption ("ButtonsYMod", -4)
+ GameCooltip2:SetOption ("YSpacingMod", -4)
+ GameCooltip2:SetOption ("IgnoreButtonAutoHeight", true)
+
+ GameCooltip2:SetColor (1, 0.5, 0.5, 0.5, 0)
+
+ local preset2_backdrop = {bgFile = DF.folder .. "background", edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+ local gray_table = {0.37, 0.37, 0.37, 0.95}
+ local black_table = {0.2, 0.2, 0.2, 1}
+ GameCooltip2:SetBackdrop (1, preset2_backdrop, gray_table, black_table)
+ GameCooltip2:SetBackdrop (2, preset2_backdrop, gray_table, black_table)
+ end,
+ }
+ GameCooltip2:CoolTipInject (otherTalents)
+
+ function f.CanShowTalentWarning()
+ local playerTalents = DF:GetCharacterTalents()
+ local indexedTalents = {}
+ for _, talentTable in ipairs (playerTalents) do
+ tinsert (indexedTalents, talentTable.ID)
+ end
+ for talentID, _ in pairs (f.OptionsTable.talent) do
+ if (type (talentID) == "number" and not DF.table.find (indexedTalents, talentID)) then
+ otherTalents:Show()
+ return
+ end
+ end
+ otherTalents:Hide()
+ end
+ end
+
+ --create radio group for pvp talents
+ local pvpTalentList = {}
+ for _, talentTable in ipairs (DF:GetCharacterPvPTalents()) do
+ tinsert (pvpTalentList, {
+ name = talentTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = talentTable.ID,
+ get = function() return f.OptionsTable.pvptalent [talentTable.ID] end,
+ texture = talentTable.Texture,
+ })
+ end
+ local pvpTalentGroup = DF:CreateRadionGroup (f, pvpTalentList, name, {width = 200, height = 200, title = "Characer PvP Talents"}, {offset_x = 150, amount_per_line = 3})
+ pvpTalentGroup:SetPoint ("topleft", f, "topleft", anchorPositions.pvptalent [1], anchorPositions.pvptalent [2])
+ pvpTalentGroup.DBKey = "pvptalent"
+ tinsert (f.AllRadioGroups, pvpTalentGroup)
+ f.PvPTalentGroup = pvpTalentGroup
+
+ do
+ --create a frame to show talents selected in other specs or characters
+ local otherTalents = CreateFrame ("frame", nil, f)
+ otherTalents:SetSize (26, 26)
+ otherTalents:SetPoint ("left", pvpTalentGroup.Title.widget, "right", 10, -2)
+ otherTalents.Texture = DF:CreateImage (otherTalents, [[Interface\BUTTONS\AdventureGuideMicrobuttonAlert]], 24, 24)
+ otherTalents.Texture:SetAllPoints()
+
+ local removeTalent = function (_, _, talentID)
+ f.OptionsTable.pvptalent [talentID] = nil
+ GameCooltip2:Hide()
+ f.OnRadioStateChanged (pvpTalentGroup, f.OptionsTable [pvpTalentGroup.DBKey])
+ f.CanShowPvPTalentWarning()
+ end
+
+ local buildTalentMenu = function()
+ local playerTalents = DF:GetCharacterPvPTalents()
+ local indexedTalents = {}
+ for _, talentTable in ipairs (playerTalents) do
+ tinsert (indexedTalents, talentTable.ID)
+ end
+
+ --talents selected to load
+ GameCooltip2:AddLine ("select a talent to remove it (added from a different spec or character)", "", 1, "orange", "orange", 9)
+ GameCooltip2:AddLine ("$div", nil, nil, -1, -1)
+
+ for talentID, _ in pairs (f.OptionsTable.pvptalent) do
+ if (type (talentID) == "number" and not DF.table.find (indexedTalents, talentID)) then
+ local _, name, texture = GetPvpTalentInfoByID (talentID)
+ if (name) then
+ GameCooltip2:AddLine (name)
+ GameCooltip2:AddIcon (texture, 1, 1, 16, 16, .1, .9, .1, .9)
+ GameCooltip2:AddMenu (1, removeTalent, talentID)
+ end
+ end
+ end
+ end
+
+ otherTalents.CoolTip = {
+ Type = "menu",
+ BuildFunc = buildTalentMenu,
+ OnEnterFunc = function (self) end,
+ OnLeaveFunc = function (self) end,
+ FixedValue = "none",
+ ShowSpeed = 0.05,
+ Options = function()
+ GameCooltip2:SetOption ("TextFont", "Friz Quadrata TT")
+ GameCooltip2:SetOption ("TextColor", "orange")
+ GameCooltip2:SetOption ("TextSize", 12)
+ GameCooltip2:SetOption ("FixedWidth", 220)
+ GameCooltip2:SetOption ("ButtonsYMod", -4)
+ GameCooltip2:SetOption ("YSpacingMod", -4)
+ GameCooltip2:SetOption ("IgnoreButtonAutoHeight", true)
+
+ GameCooltip2:SetColor (1, 0.5, 0.5, 0.5, 0)
+
+ local preset2_backdrop = {bgFile = DF.folder .. "background", edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}
+ local gray_table = {0.37, 0.37, 0.37, 0.95}
+ local black_table = {0.2, 0.2, 0.2, 1}
+ GameCooltip2:SetBackdrop (1, preset2_backdrop, gray_table, black_table)
+ GameCooltip2:SetBackdrop (2, preset2_backdrop, gray_table, black_table)
+ end,
+ }
+ GameCooltip2:CoolTipInject (otherTalents)
+
+ function f.CanShowPvPTalentWarning()
+ local playerTalents = DF:GetCharacterPvPTalents()
+ local indexedTalents = {}
+ for _, talentTable in ipairs (playerTalents) do
+ tinsert (indexedTalents, talentTable.ID)
+ end
+ for talentID, _ in pairs (f.OptionsTable.pvptalent) do
+ if (type (talentID) == "number" and not DF.table.find (indexedTalents, talentID)) then
+ otherTalents:Show()
+ return
+ end
+ end
+ otherTalents:Hide()
+ end
+ end
+
+ --create radio for group types
+ local groupTypes = {}
+ for _, groupTable in ipairs (DF:GetGroupTypes()) do
+ tinsert (groupTypes, {
+ name = groupTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = groupTable.ID,
+ get = function() return f.OptionsTable.group [groupTable.ID] end,
+ })
+ end
+ local groupTypesGroup = DF:CreateRadionGroup (f, groupTypes, name, {width = 200, height = 200, title = "Group Types"})
+ groupTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.group [1], anchorPositions.group [2])
+ groupTypesGroup.DBKey = "group"
+ tinsert (f.AllRadioGroups, groupTypesGroup)
+
+ --create radio for character roles
+ local roleTypes = {}
+ for _, roleTable in ipairs (DF:GetRoleTypes()) do
+ tinsert (roleTypes, {
+ name = roleTable.Texture .. " " .. roleTable.Name,
+ set = f.OnRadioCheckboxClick,
+ param = roleTable.ID,
+ get = function() return f.OptionsTable.role [roleTable.ID] end,
+ })
+ end
+ local roleTypesGroup = DF:CreateRadionGroup (f, roleTypes, name, {width = 200, height = 200, title = "Role Types"})
+ roleTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.role [1], anchorPositions.role [2])
+ roleTypesGroup.DBKey = "role"
+ tinsert (f.AllRadioGroups, roleTypesGroup)
+
+ --create radio group for mythic+ affixes
+ local affixes = {}
+ for i = 2, 1000 do
+ local affixName, desc, texture = C_ChallengeMode.GetAffixInfo (i)
+ if (affixName) then
+ tinsert (affixes, {
+ name = affixName,
+ set = f.OnRadioCheckboxClick,
+ param = i,
+ get = function() return f.OptionsTable.affix [i] end,
+ texture = texture,
+ })
+ end
+ end
+ local affixTypesGroup = DF:CreateRadionGroup (f, affixes, name, {width = 200, height = 200, title = "M+ Affixes"})
+ affixTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.affix [1], anchorPositions.affix [2])
+ affixTypesGroup.DBKey = "affix"
+ tinsert (f.AllRadioGroups, affixTypesGroup)
+
+ --text entries functions
+ local textEntryRefresh = function (self)
+ local idList = f.OptionsTable [self.DBKey]
+ self:SetText ("")
+ for i = 1, #idList do
+ self:SetText (self:GetText() .. " " .. idList [i])
+ end
+ self:SetText (self:GetText():gsub ("^ ", ""))
+ end
+
+ local textEntryOnEnterPressed = function (_, self)
+ wipe (f.OptionsTable [self.DBKey])
+ local text = self:GetText()
+
+ for _, ID in ipairs ({strsplit ("", text)}) do
+ ID = DF:trim (ID)
+ ID = tonumber (ID)
+ if (ID) then
+ tinsert (f.OptionsTable [self.DBKey], ID)
+ f.OptionsTable [self.DBKey].Enabled = true
+ end
+ end
+ end
+
+ --create the text entry to type the encounter ID
+ local encounterIDLabel = DF:CreateLabel (f, "Encounter ID", DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ local encounterIDEditbox = DF:CreateTextEntry (f, function()end, 200, 20, "EncounterEditbox", _, _, DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ encounterIDLabel:SetPoint ("topleft", f, "topleft", anchorPositions.encounter_ids [1], anchorPositions.encounter_ids [2])
+ encounterIDEditbox:SetPoint ("topleft", encounterIDLabel, "bottomleft", 0, -2)
+ encounterIDEditbox.DBKey = "encounter_ids"
+ encounterIDEditbox.Refresh = textEntryRefresh
+ encounterIDEditbox.tooltip = "Enter multiple IDs separating with a semicolon ()\nExample: 35 45 95\n\nUldir:\n"
+ for _, encounterTable in ipairs (DF:GetCLEncounterIDs()) do
+ encounterIDEditbox.tooltip = encounterIDEditbox.tooltip .. encounterTable.ID .. " - " .. encounterTable.Name .. "\n"
+ end
+ encounterIDEditbox:SetHook ("OnEnterPressed", textEntryOnEnterPressed)
+ tinsert (f.AllTextEntries, encounterIDEditbox)
+
+ --create the text entry for map ID
+ local mapIDLabel = DF:CreateLabel (f, "Map ID", DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
+ local mapIDEditbox = DF:CreateTextEntry (f, function()end, 200, 20, "MapEditbox", _, _, DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
+ mapIDLabel:SetPoint ("topleft", f, "topleft", anchorPositions.map_ids [1], anchorPositions.map_ids [2])
+ mapIDEditbox:SetPoint ("topleft", mapIDLabel, "bottomleft", 0, -2)
+ mapIDEditbox.DBKey = "map_ids"
+ mapIDEditbox.Refresh = textEntryRefresh
+ mapIDEditbox.tooltip = "Enter multiple IDs separating with a semicolon ()\nExample: 35 45 95"
+ mapIDEditbox:SetHook ("OnEnterPressed", textEntryOnEnterPressed)
+ tinsert (f.AllTextEntries, mapIDEditbox)
+
+ function f.Refresh (self)
+ do
+ --update the talents (might have changed if the player changed its specialization)
+ local talentList = {}
+ for _, talentTable in ipairs (DF:GetCharacterTalents()) do
+ tinsert (talentList, {
+ name = talentTable.Name,
+ set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
+ param = talentTable.ID,
+ get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID] end,
+ texture = talentTable.Texture,
+ })
+ end
+ DetailsFrameworkLoadConditionsPanel.TalentGroup:SetOptions (talentList)
+ end
+
+ do
+ local pvpTalentList = {}
+ for _, talentTable in ipairs (DF:GetCharacterPvPTalents()) do
+ tinsert (pvpTalentList, {
+ name = talentTable.Name,
+ set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
+ param = talentTable.ID,
+ get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID] end,
+ texture = talentTable.Texture,
+ })
+ end
+ DetailsFrameworkLoadConditionsPanel.PvPTalentGroup:SetOptions (pvpTalentList)
+ end
+
+ --refresh the radio group
+ for _, radioGroup in ipairs (DetailsFrameworkLoadConditionsPanel.AllRadioGroups) do
+ radioGroup:Refresh()
+ DetailsFrameworkLoadConditionsPanel.OnRadioStateChanged (radioGroup, DetailsFrameworkLoadConditionsPanel.OptionsTable [radioGroup.DBKey])
+ end
+
+ --refresh text entries
+ for _, textEntry in ipairs (DetailsFrameworkLoadConditionsPanel.AllTextEntries) do
+ textEntry:Refresh()
+ end
+
+ DetailsFrameworkLoadConditionsPanel.CanShowTalentWarning()
+ DetailsFrameworkLoadConditionsPanel.CanShowPvPTalentWarning()
+ end
+
+ end
+
+ --set the options table
+ DetailsFrameworkLoadConditionsPanel.OptionsTable = optionsTable
+
+ --set the callback func
+ DetailsFrameworkLoadConditionsPanel.CallbackFunc = callback
+ DetailsFrameworkLoadConditionsPanel.OptionsTable = optionsTable
+
+ --set title
+ DetailsFrameworkLoadConditionsPanel.EditingLabel:SetText (frameOptions.name)
+ DetailsFrameworkLoadConditionsPanel.Title:SetText (frameOptions.title)
+
+ --show the panel to the user
+ DetailsFrameworkLoadConditionsPanel:Show()
+
+ DetailsFrameworkLoadConditionsPanel:Refresh()
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> simple data scroll
+
+DF.DataScrollFunctions = {
+ RefreshScroll = function (self, data, offset, totalLines)
+ local filter = self.Filter
+ local currentData = {}
+ if (type (filter) == "string" and filter ~= "") then
+ for i = 1, #data do
+ for o = 1, #data[i] do
+ if (data[i][o]:find (filter)) then
+ tinsert (currentData, data[i])
+ break
+ end
+ end
+ end
+ else
+ currentData = data
+ end
+
+ if (self.SortAlphabetical) then
+ table.sort (currentData, function(t1, t2) return t1[1] < t2[1] end)
+ end
+
+ --update the scroll
+ for i = 1, totalLines do
+ local index = i + offset
+ local thisData = currentData [index]
+ if (thisData) then
+ local line = self:GetLine (i)
+ line:Update (index, thisData)
+ end
+ end
+ end,
+
+ CreateLine = function (self, index)
+ --create a new line
+ local line = CreateFrame ("button", "$parentLine" .. index, self)
+ line.Update = self.options.update_line_func
+
+ --set its parameters
+ line:SetPoint ("topleft", self, "topleft", 1, -((index-1) * (self.options.line_height+1)) - 1)
+ line:SetSize (self.options.width - 2, self.options.line_height)
+ line:RegisterForClicks ("LeftButtonDown", "RightButtonDown")
+
+ line:SetScript ("OnEnter", self.options.on_enter)
+ line:SetScript ("OnLeave", self.options.on_leave)
+ line:SetScript ("OnClick", self.options.on_click)
+
+ line:SetBackdrop (self.options.backdrop)
+ line:SetBackdropColor (unpack (self.options.backdrop_color))
+ line:SetBackdropBorderColor (unpack (self.options.backdrop_border_color))
+
+ local title = DF:CreateLabel (line, "", DF:GetTemplate ("font", self.options.title_template))
+ local date = DF:CreateLabel (line, "", DF:GetTemplate ("font", self.options.title_template))
+ local text = DF:CreateLabel (line, "", DF:GetTemplate ("font", self.options.text_tempate))
+
+ title.textsize = 14
+ date.textsize = 14
+ text:SetSize (self.options.width - 20, self.options.line_height)
+ text:SetJustifyV ("top")
+
+ --setup anchors
+ if (self.options.show_title) then
+ title:SetPoint ("topleft", line, "topleft", 2, 0)
+ date:SetPoint ("topright", line, "topright", -2, 0)
+ text:SetPoint ("topleft", title, "bottomleft", 0, -4)
+ else
+ text:SetPoint ("topleft", line, "topleft", 2, 0)
+ end
+
+ line.Title = title
+ line.Date = date
+ line.Text = text
+
+ line.backdrop_color = self.options.backdrop_color or {.1, .1, .1, .3}
+ line.backdrop_color_highlight = self.options.backdrop_color_highlight or {.3, .3, .3, .5}
+
+ return line
+ end,
+
+ LineOnEnter = function (self)
+ self:SetBackdropColor (unpack (self.backdrop_color_highlight))
+ end,
+
+ LineOnLeave = function (self)
+ self:SetBackdropColor (unpack (self.backdrop_color))
+ end,
+
+ OnClick = function (self)
+
+ end,
+
+ UpdateLine = function (line, lineIndex, data)
+ local parent = line:GetParent()
+
+ if (parent.options.show_title) then
+ line.Title.text = data [2] or ""
+ line.Date.text = data [3] or ""
+ line.Text.text = data [4] or ""
+ else
+ line.Text.text = data [2] or ""
+ end
+
+ if (line:GetParent().OnUpdateLineHook) then
+ DF:CoreDispatch ((line:GetName() or "ScrollBoxDataScrollUpdateLineHook") .. ":UpdateLineHook()", line:GetParent().OnUpdateLineHook, line, lineIndex, data)
+ end
+ end,
+}
+
+local default_datascroll_options = {
+ width = 400,
+ height = 700,
+ line_amount = 10,
+ line_height = 20,
+
+ show_title = true,
+
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {0, 0, 0, 0.2},
+ backdrop_color_highlight = {.2, .2, .2, 0.4},
+ backdrop_border_color = {0.1, 0.1, 0.1, .2},
+
+ title_template = "ORANGE_FONT_TEMPLATE",
+ text_tempate = "OPTIONS_FONT_TEMPLATE",
+
+ create_line_func = DF.DataScrollFunctions.CreateLine,
+ update_line_func = DF.DataScrollFunctions.UpdateLine,
+ refresh_func = DF.DataScrollFunctions.RefreshScroll,
+ on_enter = DF.DataScrollFunctions.LineOnEnter,
+ on_leave = DF.DataScrollFunctions.LineOnLeave,
+ on_click = DF.DataScrollFunctions.OnClick,
+
+ data = {},
+}
+
+--[=[
+ Create a scroll frame to show text in an organized way
+ Functions in the options table can be overritten to customize the layout
+ @parent = the parent of the frame
+ @name = the frame name to use in the CreateFrame call
+ @options = options table to override default values from the table above
+--]=]
+function DF:CreateDataScrollFrame (parent, name, options)
+ --call the mixin with a dummy table to built the default options before the frame creation
+ --this is done because CreateScrollBox needs parameters at creation time
+ local optionsTable = {}
+ DF.OptionsFunctions.BuildOptionsTable (optionsTable, default_datascroll_options, options)
+ optionsTable = optionsTable.options
+
+ --scroll frame
+ local newScroll = DF:CreateScrollBox (parent, name, optionsTable.refresh_func, optionsTable.data, optionsTable.width, optionsTable.height, optionsTable.line_amount, optionsTable.line_height)
+ DF:ReskinSlider (newScroll)
+
+ DF:Mixin (newScroll, DF.OptionsFunctions)
+ DF:Mixin (newScroll, DF.LayoutFrame)
+
+ newScroll:BuildOptionsTable (default_datascroll_options, options)
+
+ --create the scrollbox lines
+ for i = 1, newScroll.options.line_amount do
+ newScroll:CreateLine (newScroll.options.create_line_func)
+ end
+
+ newScroll:Refresh()
+
+ return newScroll
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> what's new window
+
+local default_newsframe_options = {
+ width = 400,
+ height = 700,
+
+ line_amount = 16,
+ line_height = 40,
+
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {0, 0, 0, 0.2},
+ backdrop_border_color = {0.1, 0.1, 0.1, .2},
+
+ title = "What's New?",
+ show_title = true,
+}
+
+DF.NewsFrameFunctions = {
+
+}
+
+--[=[
+ Get the amount of news that the player didn't see yet
+ @newsTable = an indexed table of tables
+ @lastNewsTime = last time the player opened the news window
+--]=]
+function DF:GetNumNews (newsTable, lastNewsTime)
+ local now = time()
+ local nonReadNews = 0
+
+ for _, news in ipairs (newsTable) do
+ if (news[1] > lastNewsTime) then
+ nonReadNews = nonReadNews + 1
+ end
+ end
+
+ return nonReadNews
+end
+
+--[=[
+ Creates a panel with a scroll to show texts organized in separated lines
+ @parent = the parent of the frame
+ @name = the frame name to use in the CreateFrame call
+ @options = options table to override default values from the table above
+ @newsTable = an indexed table of tables
+ @db = (optional) an empty table from the addon database to store the position of the frame between game sessions
+--]=]
+function DF:CreateNewsFrame (parent, name, options, newsTable, db)
+
+ local f = DF:CreateSimplePanel (parent, 400, 700, options and options.title or default_newsframe_options.title, name, {UseScaleBar = db and true}, db)
+ f:SetFrameStrata ("MEDIUM")
+ DF:ApplyStandardBackdrop (f)
+
+ DF:Mixin (f, DF.OptionsFunctions)
+ DF:Mixin (f, DF.LayoutFrame)
+
+ f:BuildOptionsTable (default_newsframe_options, options)
+
+ f:SetSize (f.options.width, f.options.height)
+ f:SetBackdrop (f.options.backdrop)
+ f:SetBackdropColor (unpack (f.options.backdrop_color))
+ f:SetBackdropBorderColor (unpack (f.options.backdrop_border_color))
+
+ local scrollOptions = {
+ data = newsTable,
+ width = f.options.width - 32, --frame distance from walls and scroll bar space
+ height = f.options.height - 40 + (not f.options.show_title and 20 or 0),
+ line_amount = f.options.line_amount,
+ line_height = f.options.line_height,
+ }
+ local newsScroll = DF:CreateDataScrollFrame (f, "$parentScroll", scrollOptions)
+
+ if (not f.options.show_title) then
+ f.TitleBar:Hide()
+ newsScroll:SetPoint ("topleft", f, "topleft", 5, -10)
+ else
+ newsScroll:SetPoint ("topleft", f, "topleft", 5, -30)
+ end
+
+ f.NewsScroll = newsScroll
+
+ return f
+end
+
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> statusbar info
+
+function DF:BuildStatusbarAuthorInfo (f)
+
+ local authorName = DF:CreateLabel (f, "An addon by |cFFFFFFFFTercioo|r")
+ authorName.textcolor = "silver"
+ local discordLabel = DF:CreateLabel (f, "Discord: ")
+ discordLabel.textcolor = "silver"
+
+ local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
+ local discordTextEntry = DF:CreateTextEntry (f, function()end, 200, 18, "DiscordTextBox", _, _, options_dropdown_template)
+ discordTextEntry:SetText ("https://discord.gg/AGSzAZX")
+ discordTextEntry:SetFrameLevel (5000)
+
+ authorName:SetPoint ("left", f, "left", 2, 0)
+ discordLabel:SetPoint ("left", authorName, "right", 20, 0)
+ discordTextEntry:SetPoint ("left", discordLabel, "right", 2, 0)
+
+ --format
+ authorName:SetAlpha (.4)
+ discordLabel:SetAlpha (.4)
+ discordTextEntry:SetAlpha (.4)
+ discordTextEntry:SetBackdropBorderColor (1, 1, 1, 0)
+
+ discordTextEntry:SetHook ("OnEditFocusGained", function()
+ discordTextEntry:HighlightText()
+ end)
+end
+
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> statusbar mixin
+
+--[=[
+ collection of functions to embed into a statusbar
+ statusBar:GetTexture()
+ statusBar:SetTexture (texture)
+ statusBar:SetColor (unparsed color)
+ statusBar:GetColor()
+ statusBar:
+ statusBar:
+
+--]=]
+
+DF.StatusBarFunctions = {
+
+ GetTexture = function (self)
+ return self.barTexture:GetTexture()
+ end,
+
+ SetTexture = function (self, texture)
+ self.barTexture:SetTexture (texture)
+ end,
+
+ SetColor = function (self, r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self:SetStatusBarColor (r, g, b, a)
+ end,
+
+ GetColor = function (self)
+ return self:GetStatusBarColor()
+ end,
+
+}
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> health bar frame
+
+--[=[
+ DF:CreateHealthBar (parent, name, settingsOverride)
+ creates a health bar to show an unit health
+ @parent = frame to pass for the CreateFrame function
+ @name = absolute name of the frame, if omitted it uses the parent's name .. "HealthBar"
+ @settingsOverride = table with keys and values to replace the defaults from the framework
+
+ methods:
+ healthbar:SetUnit (unit)
+ healthBar:GetTexture()
+ healthBar:SetTexture (texture)
+--]=]
+
+local debugPerformance = {
+ eventCall = {},
+ unitCall = {},
+ functionCall = {},
+ CPUUsageByFunction = {},
+}
+
+local function CalcPerformance (type, data)
+ if (type == "event") then
+ debugPerformance.eventCall [data] = (debugPerformance.eventCall [data] or 0) + 1
+
+ elseif (type == "unit") then
+ debugPerformance.unitCall [data] = (debugPerformance.unitCall [data] or 0) + 1
+
+ elseif (type == "call") then
+ debugPerformance.functionCall [data] = (debugPerformance.functionCall [data] or 0) + 1
+
+ end
+end
+
+function DF_CalcCpuUsage (name)
+ local cpu = debugPerformance.CPUUsageByFunction [name] or {usage = 0, last = 0, active = false}
+ debugPerformance.CPUUsageByFunction [name] = cpu
+
+ if (cpu.active) then
+ cpu.active = false
+ local diff = debugprofilestop() - cpu.last
+ cpu.usage = cpu.usage + diff
+ else
+ cpu.active = true
+ cpu.last = debugprofilestop()
+ end
+end
+
+function UnitFrameStats()
+ for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do
+ debugPerformance.CPUUsageByFunction [functionName] = floor (functionTable.usage)
+ end
+
+ Details:Dump (debugPerformance)
+
+ for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do
+ debugPerformance.CPUUsageByFunction [functionName] = {usage = 0, last = 0, active = false}
+ end
+end
+
+
+--CalcPerformance ("unit", data)
+
+DF.HealthFrameFunctions = {
+
+ WidgetType = "healthBar",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+
+ HookList = {
+ OnHide = {},
+ OnShow = {},
+ },
+
+ Settings = {
+ CanTick = false, --> if true calls the method 'OnTick' every tick, the function needs to be overloaded, it receives self and deltaTime as parameters
+ ShowHealingPrediction = true, --> when casting a healing pass, show the amount of health that spell will heal
+ ShowShields = true, --> indicator of the amount of damage absortion the unit has
+
+ --appearance
+ BackgroundColor = DF:CreateColorTable (.2, .2, .2, .8),
+ Texture = [[Interface\RaidFrame\Raid-Bar-Hp-Fill]],
+ ShieldIndicatorTexture = [[Interface\RaidFrame\Shield-Fill]],
+ ShieldGlowTexture = [[Interface\RaidFrame\Shield-Overshield]],
+ ShieldGlowWidth = 16,
+
+ --default size
+ Width = 100,
+ Height = 20,
+ },
+
+ HealthBarEvents = {
+ {"PLAYER_ENTERING_WORLD"},
+ --{"UNIT_HEALTH", true},
+ {"UNIT_MAXHEALTH", true},
+ {"UNIT_HEALTH_FREQUENT", true},
+ {"UNIT_HEAL_PREDICTION", true},
+ {"UNIT_ABSORB_AMOUNT_CHANGED", true},
+ {"UNIT_HEAL_ABSORB_AMOUNT_CHANGED", true},
+ },
+
+ --> setup the castbar to be used by another unit
+ SetUnit = function (self, unit, displayedUnit)
+ if (self.unit ~= unit or self.displayedUnit ~= displayedUnit or unit == nil) then
+
+ CalcPerformance ("call", "SetUnit")
+
+ self.unit = unit
+ self.displayedUnit = displayedUnit or unit
+
+ --> register events
+ if (unit) then
+ self.currentHealth = UnitHealth (unit) or 0
+ self.currentHealthMax = UnitHealthMax (unit) or 0
+
+ for _, eventTable in ipairs (self.HealthBarEvents) do
+ local event = eventTable [1]
+ local isUnitEvent = eventTable [2]
+ if (isUnitEvent) then
+ self:RegisterUnitEvent (event, self.displayedUnit, self.unit)
+ else
+ self:RegisterEvent (event)
+ end
+ end
+
+ --> check for settings and update some events
+ if (not self.Settings.ShowHealingPrediction) then
+ self:UnregisterEvent ("UNIT_HEAL_PREDICTION")
+ self:UnregisterEvent ("UNIT_HEAL_ABSORB_AMOUNT_CHANGED")
+ self.incomingHealIndicator:Hide()
+ self.healAbsorbIndicator:Hide()
+ end
+ if (not self.Settings.ShowShields) then
+ self:UnregisterEvent ("UNIT_ABSORB_AMOUNT_CHANGED")
+ self.shieldAbsorbIndicator:Hide()
+ self.shieldAbsorbGlow:Hide()
+ end
+
+ --> set scripts
+ self:SetScript ("OnEvent", self.OnEvent)
+
+ if (self.Settings.CanTick) then
+ self:SetScript ("OnUpdate", self.OnTick)
+ end
+
+ self:PLAYER_ENTERING_WORLD (self.unit, self.displayedUnit)
+ else
+ --> remove all registered events
+ for _, eventTable in ipairs (self.HealthBarEvents) do
+ local event = eventTable [1]
+ self:UnregisterEvent (event)
+ end
+
+ --> remove scripts
+ self:SetScript ("OnEvent", nil)
+ self:SetScript ("OnUpdate", nil)
+ self:Hide()
+ end
+ end
+ end,
+
+ Initialize = function (self)
+ PixelUtil.SetWidth (self, self.Settings.Width, 1)
+ PixelUtil.SetHeight (self, self.Settings.Height, 1)
+
+ self:SetTexture (self.Settings.Texture)
+
+ self.background:SetAllPoints()
+ self.background:SetColorTexture (self.Settings.BackgroundColor:GetColor())
+
+ --setpoint of these widgets are set inside the function that updates the incoming heal
+ self.incomingHealIndicator:SetTexture (self:GetTexture())
+ self.healAbsorbIndicator:SetTexture (self:GetTexture())
+ self.healAbsorbIndicator:SetVertexColor (.1, .8, .8)
+ self.shieldAbsorbIndicator:SetTexture (self.Settings.ShieldIndicatorTexture, true, true)
+
+ self.shieldAbsorbGlow:SetWidth (self.Settings.ShieldGlowWidth)
+ self.shieldAbsorbGlow:SetTexture (self.Settings.ShieldGlowTexture)
+ self.shieldAbsorbGlow:SetBlendMode ("ADD")
+ self.shieldAbsorbGlow:SetPoint ("topright", self, "topright", 8, 0)
+ self.shieldAbsorbGlow:SetPoint ("bottomright", self, "bottomright", 8, 0)
+ self.shieldAbsorbGlow:Hide()
+
+ self:SetUnit (nil)
+
+ CalcPerformance ("call", "HealthBar-Initialize")
+ end,
+
+ --> call every tick
+ OnTick = function (self, deltaTime) end, --if overrided, set 'CanTick' to true on the settings table
+
+ --> when an event happen for this unit, send it to the apropriate function
+ OnEvent = function (self, event, ...)
+ CalcPerformance ("unit", self.unit)
+ CalcPerformance ("event", event)
+ CalcPerformance ("call", "HealthBar-OnEvent")
+
+ DF_CalcCpuUsage ("healthBar-OnEvent")
+ local eventFunc = self [event]
+ if (eventFunc) then
+ --the function doesn't receive which event was, only 'self' and the parameters
+ eventFunc (self, ...)
+ end
+ DF_CalcCpuUsage ("healthBar-OnEvent")
+ end,
+
+ --colocar mais coisas aqui, um member dizendo quanto de health e o health max da unit
+ UpdateMaxHealth = function (self)
+ DF_CalcCpuUsage ("HealthBar-UpdateMaxHealth")
+ local maxHealth = UnitHealthMax (self.displayedUnit)
+ self:SetMinMaxValues (0, maxHealth)
+ self.currentHealthMax = maxHealth
+ DF_CalcCpuUsage ("HealthBar-UpdateMaxHealth")
+
+ CalcPerformance ("call", "HealthBar-UpdateMaxHealth")
+ end,
+
+ UpdateHealth = function (self)
+ DF_CalcCpuUsage ("HealthBar-UpdateHealth")
+ local health = UnitHealth (self.displayedUnit)
+ self.currentHealth = health
+ PixelUtil.SetStatusBarValue (self, health)
+ DF_CalcCpuUsage ("HealthBar-UpdateHealth")
+
+ CalcPerformance ("call", "HealthBar-UpdateHealth")
+ end,
+
+ --isso aqui vai ser complicado!
+ UpdateHealPrediction = function (self)
+ CalcPerformance ("call", "HealthBar-UpdateHealPrediction")
+
+ DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction")
+
+ local currentHealth = self.currentHealth
+ local currentHealthMax = self.currentHealthMax
+ local healthPercent = currentHealth / currentHealthMax
+
+ if (not currentHealthMax or currentHealthMax <= 0) then
+ DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction")
+ return
+ end
+
+ --order is: the health of the unit > damage absorb > heal absorb > incoming heal
+ local width = self:GetWidth()
+
+ if (self.Settings.ShowHealingPrediction) then
+ --incoming heal on the unit from all sources
+ local unitHealIncoming = UnitGetIncomingHeals (self.displayedUnit) or 0
+ --heal absorbs
+ local unitHealAbsorb = UnitGetTotalHealAbsorbs (self.displayedUnit) or 0
+
+ if (unitHealIncoming > 0) then
+ --calculate what is the percent of health incoming based on the max health the player has
+ local incomingPercent = unitHealIncoming / currentHealthMax
+ self.incomingHealIndicator:Show()
+ self.incomingHealIndicator:SetWidth (max (1, min (width * incomingPercent, abs (healthPercent - 1) * width)))
+ self.incomingHealIndicator:SetPoint ("topleft", self, "topleft", width * healthPercent, 0)
+ self.incomingHealIndicator:SetPoint ("bottomleft", self, "bottomleft", width * healthPercent, 0)
+ else
+ self.incomingHealIndicator:Hide()
+ end
+
+ if (unitHealAbsorb > 0) then
+ local healAbsorbPercent = unitHealAbsorb / currentHealthMax
+ self.healAbsorbIndicator:Show()
+ self.healAbsorbIndicator:SetWidth (max (1, min (width * healAbsorbPercent, abs (healthPercent - 1) * width)))
+ self.healAbsorbIndicator:SetPoint ("topleft", self, "topleft", width * healthPercent, 0)
+ self.healAbsorbIndicator:SetPoint ("bottomleft", self, "bottomleft", width * healthPercent, 0)
+ else
+ self.healAbsorbIndicator:Hide()
+ end
+ end
+
+ if (self.Settings.ShowShields) then
+ --damage absorbs
+ local unitDamageAbsorb = UnitGetTotalAbsorbs (self.displayedUnit) or 0
+
+ if (unitDamageAbsorb > 0) then
+ local damageAbsorbPercent = unitDamageAbsorb / currentHealthMax
+ self.shieldAbsorbIndicator:Show()
+ --set the width where the max width size is what is lower: the absorb size or the missing amount of health in the health bar
+ --/dump NamePlate1PlaterUnitFrameHealthBar.shieldAbsorbIndicator:GetSize()
+ self.shieldAbsorbIndicator:SetWidth (max (1, min (width * damageAbsorbPercent, abs (healthPercent - 1) * width)))
+ self.shieldAbsorbIndicator:SetPoint ("topleft", self, "topleft", width * healthPercent, 0)
+ self.shieldAbsorbIndicator:SetPoint ("bottomleft", self, "bottomleft", width * healthPercent, 0)
+
+ --if the absorb percent pass 100%, show the glow
+ if ((healthPercent + damageAbsorbPercent) > 1) then
+ self.shieldAbsorbGlow:Show()
+ else
+ self.shieldAbsorbGlow:Hide()
+ end
+ else
+ self.shieldAbsorbIndicator:Hide()
+ self.shieldAbsorbGlow:Hide()
+ end
+ else
+ self.shieldAbsorbIndicator:Hide()
+ self.shieldAbsorbGlow:Hide()
+ end
+
+ DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction")
+ end,
+
+ PLAYER_ENTERING_WORLD = function (self, ...)
+ self:UpdateMaxHealth()
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+
+ --> health events
+ UNIT_HEALTH = function (self, ...)
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+
+ local unitName = UnitName (self.unit)
+ CalcPerformance ("call", "HealthBar-UNIT_HEALTH-" .. unitName)
+ end,
+ UNIT_HEALTH_FREQUENT = function (self, ...)
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+ UNIT_MAXHEALTH = function (self, ...)
+ self:UpdateMaxHealth()
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+
+ UNIT_HEAL_PREDICTION = function (self, ...)
+ self:UpdateMaxHealth()
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+ UNIT_ABSORB_AMOUNT_CHANGED = function (self, ...)
+ self:UpdateMaxHealth()
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+ UNIT_HEAL_ABSORB_AMOUNT_CHANGED = function (self, ...)
+ self:UpdateMaxHealth()
+ self:UpdateHealth()
+ self:UpdateHealPrediction()
+ end,
+}
+
+-- ~healthbar
+function DF:CreateHealthBar (parent, name, settingsOverride)
+
+ assert (name or parent:GetName(), "DetailsFramework:CreateHealthBar parameter 'name' omitted and parent has no name.")
+
+ local healthBar = CreateFrame ("StatusBar", name or (parent:GetName() .. "HealthBar"), parent)
+ do --layers
+ --background
+ healthBar.background = healthBar:CreateTexture (nil, "background")
+ healthBar.background:SetDrawLayer ("background", -6)
+
+ --artwork
+ --healing incoming
+ healthBar.incomingHealIndicator = healthBar:CreateTexture (nil, "artwork")
+ healthBar.incomingHealIndicator:SetDrawLayer ("artwork", 4)
+ --current shields on the unit
+ healthBar.shieldAbsorbIndicator = healthBar:CreateTexture (nil, "artwork")
+ healthBar.shieldAbsorbIndicator:SetDrawLayer ("artwork", 5)
+ --debuff absorbing heal
+ healthBar.healAbsorbIndicator = healthBar:CreateTexture (nil, "artwork")
+ healthBar.healAbsorbIndicator:SetDrawLayer ("artwork", 6)
+ --the shield fills all the bar, show that cool glow
+ healthBar.shieldAbsorbGlow = healthBar:CreateTexture (nil, "artwork")
+ healthBar.shieldAbsorbGlow:SetDrawLayer ("artwork", 7)
+ --statusbar texture
+ healthBar.barTexture = healthBar:CreateTexture (nil, "artwork")
+ healthBar:SetStatusBarTexture (healthBar.barTexture)
+ end
+
+ --> mixins
+ DF:Mixin (healthBar, DF.HealthFrameFunctions)
+ DF:Mixin (healthBar, DF.StatusBarFunctions)
+
+ --> settings and hooks
+ local settings = DF.table.copy ({}, DF.HealthFrameFunctions.Settings)
+ if (settingsOverride) then
+ DF.table.copy (settings, settingsOverride)
+ end
+ healthBar.Settings = settings
+
+ local hookList = DF.table.copy ({}, DF.HealthFrameFunctions.HookList)
+ healthBar.HookList = hookList
+
+ --> initialize the cast bar
+ healthBar:Initialize()
+
+ return healthBar
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> power bar frame
+
+--[=[
+ DF:CreatePowerBar (parent, name, settingsOverride)
+ creates statusbar frame to show the unit power bar
+ @parent = frame to pass for the CreateFrame function
+ @name = absolute name of the frame, if omitted it uses the parent's name .. "PPowerBar"
+ @settingsOverride = table with keys and values to replace the defaults from the framework
+--]=]
+
+DF.PowerFrameFunctions = {
+
+ WidgetType = "powerBar",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+
+ HookList = {
+ OnHide = {},
+ OnShow = {},
+ },
+
+ Settings = {
+ --> misc
+ ShowAlternatePower = true, --> if true it'll show alternate power over the regular power the unit uses
+ ShowPercentText = true, --> if true show a text with the current energy percent
+ HideIfNoPower = true, --> if true and the UnitMaxPower returns zero, it'll hide the power bar with self:Hide()
+ CanTick = false, --> if it calls the OnTick function every tick
+
+ --appearance
+ BackgroundColor = DF:CreateColorTable (.2, .2, .2, .8),
+ Texture = [[Interface\RaidFrame\Raid-Bar-Resource-Fill]],
+
+ --> default size
+ Width = 100,
+ Height = 20,
+ },
+
+ PowerBarEvents = {
+ {"PLAYER_ENTERING_WORLD"},
+ {"UNIT_DISPLAYPOWER", true},
+ {"UNIT_POWER_BAR_SHOW", true},
+ {"UNIT_POWER_BAR_HIDE", true},
+ {"UNIT_MAXPOWER", true},
+ {"UNIT_POWER_UPDATE", true},
+ {"UNIT_POWER_FREQUENT", true},
+ },
+
+ --> setup the castbar to be used by another unit
+ SetUnit = function (self, unit, displayedUnit)
+ if (self.unit ~= unit or self.displayedUnit ~= displayedUnit or unit == nil) then
+ self.unit = unit
+ self.displayedUnit = displayedUnit or unit
+
+ --> register events
+ if (unit) then
+ for _, eventTable in ipairs (self.PowerBarEvents) do
+ local event = eventTable [1]
+ local isUnitEvent = eventTable [2]
+
+ if (isUnitEvent) then
+ self:RegisterUnitEvent (event, self.displayedUnit)
+ else
+ self:RegisterEvent (event)
+ end
+ end
+
+ --> set scripts
+ self:SetScript ("OnEvent", self.OnEvent)
+
+ if (self.Settings.CanTick) then
+ self:SetScript ("OnUpdate", self.OnTick)
+ end
+
+ self:Show()
+ self:UpdatePowerBar()
+ else
+ --> remove all registered events
+ for _, eventTable in ipairs (self.PowerBarEvents) do
+ local event = eventTable [1]
+ self:UnregisterEvent (event)
+ end
+
+ --> remove scripts
+ self:SetScript ("OnEvent", nil)
+ self:SetScript ("OnUpdate", nil)
+ self:Hide()
+ end
+ end
+ end,
+
+ Initialize = function (self)
+ PixelUtil.SetWidth (self, self.Settings.Width)
+ PixelUtil.SetHeight (self, self.Settings.Height)
+
+ self:SetTexture (self.Settings.Texture)
+
+ self.background:SetAllPoints()
+ self.background:SetColorTexture (self.Settings.BackgroundColor:GetColor())
+
+ if (self.Settings.ShowPercentText) then
+ self.percentText:Show()
+ PixelUtil.SetPoint (self.percentText, "center", self, "center", 0, 0)
+
+ DF:SetFontSize (self.percentText, 9)
+ DF:SetFontColor (self.percentText, "white")
+ DF:SetFontOutline (self.percentText, "OUTLINE")
+ else
+ self.percentText:Hide()
+ end
+
+ self:SetUnit (nil)
+ end,
+
+ --> call every tick
+ OnTick = function (self, deltaTime) end, --if overrided, set 'CanTick' to true on the settings table
+
+ --> when an event happen for this unit, send it to the apropriate function
+ OnEvent = function (self, event, ...)
+ DF_CalcCpuUsage ("Powerbar-OnEvent")
+ local eventFunc = self [event]
+ if (eventFunc) then
+ --the function doesn't receive which event was, only 'self' and the parameters
+ eventFunc (self, ...)
+ end
+ DF_CalcCpuUsage ("Powerbar-OnEvent")
+ end,
+
+ UpdatePowerBar = function (self)
+ self:UpdatePowerInfo()
+ self:UpdateMaxPower()
+ self:UpdatePower()
+ self:UpdatePowerColor()
+ end,
+
+ --> power update
+ UpdateMaxPower = function (self)
+ self.currentPowerMax = UnitPowerMax (self.displayedUnit, self.powerType)
+ self:SetMinMaxValues (self.minPower, self.currentPowerMax)
+
+ if (self.currentPowerMax == 0 and self.Settings.HideIfNoPower) then
+ self:Hide()
+ end
+ end,
+ UpdatePower = function (self)
+ DF_CalcCpuUsage ("Powerbar-UpdatePower")
+ self.currentPower = UnitPower (self.displayedUnit, self.powerType)
+ PixelUtil.SetStatusBarValue (self, self.currentPower)
+
+ if (self.Settings.ShowPercentText) then
+ self.percentText:SetText (floor (self.currentPower / self.currentPowerMax * 100) .. "%")
+ end
+ DF_CalcCpuUsage ("Powerbar-UpdatePower")
+ end,
+
+ --> when a event different from unit_power_update is triggered, update which type of power the unit should show
+ UpdatePowerInfo = function (self)
+ DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo")
+ if (self.Settings.ShowAlternatePower) then
+ local _, minPower, _, _, _, _, showOnRaid = UnitAlternatePowerInfo (self.displayedUnit)
+ if (showOnRaid and IsInGroup()) then
+ self.powerType = ALTERNATE_POWER_INDEX
+ self.minPower = minPower
+ DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo")
+ return
+ end
+ end
+
+ self.powerType = UnitPowerType (self.displayedUnit)
+ self.minPower = 0
+ DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo")
+ end,
+
+ --> tint the bar with the color of the power, e.g. blue for a mana bar
+ UpdatePowerColor = function (self)
+ if (not UnitIsConnected (self.unit)) then
+ self:SetStatusBarColor (.5, .5, .5)
+ return
+ end
+
+ if (self.powerType == ALTERNATE_POWER_INDEX) then
+ --> don't change this, keep the same color as the game tints on CompactUnitFrame.lua
+ self:SetStatusBarColor (0.7, 0.7, 0.6)
+ return
+ end
+
+ local powerColor = PowerBarColor [self.powerType] --> don't appear to be, but PowerBarColor is a global table with all power colors /run Details:Dump (PowerBarColor)
+ if (powerColor) then
+ self:SetStatusBarColor (powerColor.r, powerColor.g, powerColor.b)
+ return
+ end
+
+ local _, _, r, g, b = UnitPowerType (self.displayedUnit)
+ if (r) then
+ self:SetStatusBarColor (r, g, b)
+ return
+ end
+
+ --> if everything else fails, tint as rogue energy
+ powerColor = PowerBarColor ["ENERGY"]
+ self:SetStatusBarColor (powerColor.r, powerColor.g, powerColor.b)
+ end,
+
+ --> events
+ PLAYER_ENTERING_WORLD = function (self, ...)
+ self:UpdatePowerBar()
+ end,
+ UNIT_DISPLAYPOWER = function (self, ...)
+ self:UpdatePowerBar()
+ end,
+ UNIT_POWER_BAR_SHOW = function (self, ...)
+ self:UpdatePowerBar()
+ end,
+ UNIT_POWER_BAR_HIDE = function (self, ...)
+ self:UpdatePowerBar()
+ end,
+
+ UNIT_MAXPOWER = function (self, ...)
+ self:UpdateMaxPower()
+ self:UpdatePower()
+ end,
+ UNIT_POWER_UPDATE = function (self, ...)
+ self:UpdatePower()
+ end,
+ UNIT_POWER_FREQUENT = function (self, ...)
+ self:UpdatePower()
+ end,
+}
+
+-- ~powerbar
+function DF:CreatePowerBar (parent, name, settingsOverride)
+
+ assert (name or parent:GetName(), "DetailsFramework:CreatePowerBar parameter 'name' omitted and parent has no name.")
+
+ local powerBar = CreateFrame ("StatusBar", name or (parent:GetName() .. "PowerBar"), parent)
+ do --layers
+ --background
+ powerBar.background = powerBar:CreateTexture (nil, "background")
+ powerBar.background:SetDrawLayer ("background", -6)
+
+ --artwork
+ powerBar.barTexture = powerBar:CreateTexture (nil, "artwork")
+ powerBar:SetStatusBarTexture (powerBar.barTexture)
+
+ --overlay
+ powerBar.percentText = powerBar:CreateFontString (nil, "overlay", "GameFontNormal")
+ end
+
+ --> mixins
+ DF:Mixin (powerBar, DF.PowerFrameFunctions)
+ DF:Mixin (powerBar, DF.StatusBarFunctions)
+
+ --> settings and hooks
+ local settings = DF.table.copy ({}, DF.PowerFrameFunctions.Settings)
+ if (settingsOverride) then
+ DF.table.copy (settings, settingsOverride)
+ end
+ powerBar.Settings = settings
+
+ local hookList = DF.table.copy ({}, DF.PowerFrameFunctions.HookList)
+ powerBar.HookList = hookList
+
+ --> initialize the cast bar
+ powerBar:Initialize()
+
+ return powerBar
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> cast bar frame
+
+--[=[
+ DF:CreateCastBar (parent, name, settingsOverride)
+ creates a cast bar to show an unit cast
+ @parent = frame to pass for the CreateFrame function
+ @name = absolute name of the frame, if omitted it uses the parent's name .. "CastBar"
+ @settingsOverride = table with keys and values to replace the defaults from the framework
+--]=]
+
+DF.CastFrameFunctions = {
+
+ WidgetType = "castBar",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+
+ HookList = {
+ OnHide = {},
+ OnShow = {},
+
+ --can be regular cast or channel
+ OnCastStart = {},
+ },
+
+ CastBarEvents = {
+ {"UNIT_SPELLCAST_INTERRUPTED"},
+ {"UNIT_SPELLCAST_DELAYED"},
+ {"UNIT_SPELLCAST_CHANNEL_START"},
+ {"UNIT_SPELLCAST_CHANNEL_UPDATE"},
+ {"UNIT_SPELLCAST_CHANNEL_STOP"},
+ {"UNIT_SPELLCAST_INTERRUPTIBLE"},
+ {"UNIT_SPELLCAST_NOT_INTERRUPTIBLE"},
+ {"PLAYER_ENTERING_WORLD"},
+ {"UNIT_SPELLCAST_START", true},
+ {"UNIT_SPELLCAST_STOP", true},
+ {"UNIT_SPELLCAST_FAILED", true},
+ },
+
+ Settings = {
+ NoFadeEffects = false, --if true it won't play fade effects when a cast if finished
+ ShowTradeSkills = false, --if true, it shows cast for trade skills, e.g. creating an icon with blacksmith
+ ShowShield = true, --if true, shows the shield above the spell icon for non interruptible casts
+ CanTick = true, --if true it will run its OnTick function every tick.
+ ShowCastTime = true, --if true, show the remaining time to finish the cast, lazy tick must be enabled
+ FadeInTime = 0.1, --amount of time in seconds to go from zero to 100% alpha when starting to cast
+ FadeOutTime = 0.5, --amount of time in seconds to go from 100% to zero alpha when the cast finishes
+ CanLazyTick = true, --if true, it'll execute the lazy tick function, it ticks in a much slower pace comparece with the regular tick
+ LazyUpdateCooldown = 0.2, --amount of time to wait for the next lazy update, this updates non critical things like the cast timer
+
+ --default size
+ Width = 100,
+ Height = 20,
+
+ --colour the castbar statusbar by the type of the cast
+ Colors = {
+ Casting = DF:CreateColorTable (1, 0.73, .1, 1),
+ Channeling = DF:CreateColorTable (1, 0.73, .1, 1),
+ Finished = DF:CreateColorTable (0, 1, 0, 1),
+ NonInterruptible = DF:CreateColorTable (.7, .7, .7, 1),
+ Failed = DF:CreateColorTable (.4, .4, .4, 1),
+ Interrupted = DF:CreateColorTable (.965, .754, .154, 1),
+ },
+
+ --appearance
+ BackgroundColor = DF:CreateColorTable (.2, .2, .2, .8),
+ Texture = [[Interface\TargetingFrame\UI-StatusBar]],
+ BorderShieldWidth = 10,
+ BorderShieldHeight = 12,
+ BorderShieldCoords = {0.26171875, 0.31640625, 0.53125, 0.65625},
+ BorderShieldTexture = 1300837,
+ SpellIconWidth = 10,
+ SpellIconHeight = 10,
+ ShieldIndicatorTexture = [[Interface\RaidFrame\Shield-Fill]],
+ ShieldGlowTexture = [[Interface\RaidFrame\Shield-Overshield]],
+ SparkTexture = [[Interface\CastingBar\UI-CastingBar-Spark]],
+ SparkWidth = 16,
+ SparkHeight = 16,
+ SparkOffset = 0,
+ },
+
+ Initialize = function (self)
+ self.unit = "unutilized unit"
+ self.lazyUpdateCooldown = self.Settings.LazyUpdateCooldown
+ self.Colors = self.Settings.Colors
+
+ self:SetUnit (nil)
+ PixelUtil.SetWidth (self, self.Settings.Width)
+ PixelUtil.SetHeight (self, self.Settings.Height)
+
+ self.background:SetColorTexture (self.Settings.BackgroundColor:GetColor())
+ self.background:SetAllPoints()
+ self.extraBackground:SetColorTexture (0, 0, 0, 1)
+ self.extraBackground:SetVertexColor (self.Settings.BackgroundColor:GetColor())
+ self.extraBackground:SetAllPoints()
+
+ self:SetTexture (self.Settings.Texture)
+
+ self.BorderShield:SetPoint ("center", self, "left", 0, 0)
+ self.BorderShield:SetTexture (self.Settings.BorderShieldTexture)
+ self.BorderShield:SetTexCoord (unpack (self.Settings.BorderShieldCoords))
+ self.BorderShield:SetSize (self.Settings.BorderShieldWidth, self.Settings.BorderShieldHeight)
+
+ self.Icon:SetPoint ("center", self, "left", 2, 0)
+ self.Icon:SetSize (self.Settings.SpellIconWidth, self.Settings.SpellIconHeight)
+
+ self.Spark:SetTexture (self.Settings.SparkTexture)
+ self.Spark:SetSize (self.Settings.SparkWidth, self.Settings.SparkHeight)
+
+ self.percentText:SetPoint ("right", self, "right", -2, 0)
+ self.percentText:SetJustifyH ("right")
+
+ self.fadeOutAnimation.alpha1:SetDuration (self.Settings.FadeOutTime)
+ self.fadeInAnimation.alpha1:SetDuration (self.Settings.FadeInTime)
+ end,
+
+ SetDefaultColor = function (self, colorType, r, g, b, a)
+ assert (type (colorType) == "string", "DetailsFramework: CastBar:SetDefaultColor require a string in the first argument.")
+ self.Colors [colorType]:SetColor (r, g, b, a)
+ end,
+
+ --> this get a color suggestion based on the type of cast being shown in the cast bar
+ GetCastColor = function (self)
+ if (not self.canInterrupt) then
+ return self.Colors.NonInterruptible
+
+ elseif (self.channeling) then
+ return self.Colors.Channeling
+
+ elseif (self.failed) then
+ return self.Colors.Failed
+
+ elseif (self.interrupted) then
+ return self.Colors.Interrupted
+
+ elseif (self.finished) then
+ return self.Colors.Finished
+
+ else
+ return self.Colors.Casting
+ end
+ end,
+
+ --> update all colors of the cast bar
+ UpdateCastColor = function (self)
+ local castColor = self:GetCastColor()
+ self:SetColor (castColor) --SetColor handles with ParseColors()
+ end,
+
+ --> initial checks to know if this is a valid cast and should show the cast bar, if this fails the cast bar won't show
+ IsValid = function (self, unit, castName, isTradeSkill, ignoreVisibility)
+ if (not ignoreVisibility and not self:IsShown()) then
+ return false
+ end
+
+ if (not self.Settings.ShowTradeSkills) then
+ if (isTradeSkill) then
+ return false
+ end
+ end
+
+ if (not castName) then
+ return false
+ end
+
+ return true
+ end,
+
+ --> handle the interrupt state of the cast
+ --> this does not change the cast bar color because this function is called inside the start cast where is already handles the cast color
+ UpdateInterruptState = function (self)
+ if (self.Settings.ShowShield and not self.canInterrupt) then
+ self.BorderShield:Show()
+ else
+ self.BorderShield:Hide()
+ end
+ end,
+
+ --> this check if the cast did reach 100% in the statusbar, mostly called from OnTick
+ CheckCastIsDone = function (self, event, isFinished)
+
+ --> check max value
+ if (not isFinished and not self.finished) then
+ if (self.casting) then
+ if (self.value >= self.maxValue or self.value < 0) then
+ isFinished = true
+ end
+
+ elseif (self.channeling) then
+ if (self.value > self.maxValue or self.value <= 0) then
+ isFinished = true
+ end
+ end
+
+ --> check if passed an event (not begin used at the moment)
+ if (event) then
+ if (event == UNIT_SPELLCAST_STOP or event == UNIT_SPELLCAST_CHANNEL_STOP) then
+ isFinished = true
+ end
+ end
+ end
+
+ --> the cast is finished
+ if (isFinished) then
+ if (self.casting) then
+ self.UNIT_SPELLCAST_STOP (self, self.unit, self.unit, self.castID, self.spellID)
+
+ elseif (self.channeling) then
+ self.UNIT_SPELLCAST_CHANNEL_STOP (self, self.unit, self.unit, self.castID, self.spellID)
+ end
+
+ return true
+ end
+ end,
+
+ --> setup the castbar to be used by another unit
+ SetUnit = function (self, unit, displayedUnit)
+ if (self.unit ~= unit or self.displayedUnit ~= displayedUnit or unit == nil) then
+ self.unit = unit
+ self.displayedUnit = displayedUnit or unit
+
+ --> reset the cast bar
+ self.casting = nil
+ self.channeling = nil
+ self.caninterrupt = nil
+
+ --> register events
+ if (unit) then
+ for _, eventTable in ipairs (self.CastBarEvents) do
+ local event = eventTable [1]
+ local isUnitEvent = eventTable [2]
+
+ if (isUnitEvent) then
+ self:RegisterUnitEvent (event, unit)
+ else
+ self:RegisterEvent (event)
+ end
+ end
+
+ --> set scripts
+ self:SetScript ("OnEvent", self.OnEvent)
+ self:SetScript ("OnShow", self.OnShow)
+ self:SetScript ("OnHide", self.OnHide)
+
+ if (self.Settings.CanTick) then
+ self:SetScript ("OnUpdate", self.OnTick)
+ end
+
+ --> check is can show the cast time text
+ if (self.Settings.ShowCastTime and self.Settings.CanLazyTick) then
+ self.percentText:Show()
+ else
+ self.percentText:Hide()
+ end
+
+ --> setup animtions
+ self:CancelScheduleToHide()
+
+ --self:PLAYER_ENTERING_WORLD (unit, unit)
+ self:OnEvent ("PLAYER_ENTERING_WORLD", unit, unit)
+
+ else
+ for _, eventTable in ipairs (self.CastBarEvents) do
+ local event = eventTable [1]
+ self:UnregisterEvent (event)
+ end
+
+ --> register main events
+ self:SetScript ("OnUpdate", nil)
+ self:SetScript ("OnEvent", nil)
+ self:SetScript ("OnShow", nil)
+ self:SetScript ("OnHide", nil)
+
+ self:Hide()
+ end
+ end
+ end,
+
+ --> executed after a scheduled to hide timer is done
+ DoScheduledHide = function (timerObject)
+ timerObject.castBar.scheduledHideTime = nil
+
+ --just to make sure it isn't casting
+ if (not timerObject.castBar.casting and not timerObject.castBar.channeling) then
+ if (not timerObject.castBar.Settings.NoFadeEffects) then
+ timerObject.castBar:Animation_FadeOut()
+ else
+ timerObject.castBar:Hide()
+ end
+ end
+ end,
+
+ HasScheduledHide = function (self)
+ return self.scheduledHideTime and not self.scheduledHideTime._cancelled
+ end,
+
+ CancelScheduleToHide = function (self)
+ if (self:HasScheduledHide()) then
+ self.scheduledHideTime:Cancel()
+ end
+ end,
+
+ --> after an interrupt, do not immediately hide the cast bar, let it up for short amount of time to give feedback to the player
+ ScheduleToHide = function (self, delay)
+ if (not delay) then
+ if (self.scheduledHideTime and not self.scheduledHideTime._cancelled) then
+ self.scheduledHideTime:Cancel()
+ end
+
+ self.scheduledHideTime = nil
+ return
+ end
+
+ --> already have a scheduled timer?
+ if (self.scheduledHideTime and not self.scheduledHideTime._cancelled) then
+ self.scheduledHideTime:Cancel()
+ end
+
+ self.scheduledHideTime = C_Timer.NewTimer (delay, self.DoScheduledHide)
+ self.scheduledHideTime.castBar = self
+ end,
+
+ OnHide = function (self)
+ --> just in case some other effects made it have a different alpha since SetUnit won't load if the unit is the same.
+ self:SetAlpha (1)
+ --> cancel any timer to hide scheduled
+ self:CancelScheduleToHide()
+ end,
+
+ --> just update the current value if a spell is being cast since it wasn't running its tick function during the hide state
+ --> everything else should be in the correct state
+ OnShow = function (self)
+ self.flashTexture:Hide()
+
+ if (self.unit) then
+ if (self.casting) then
+ local name, text, texture, startTime = UnitCastingInfo (self.unit)
+ if (name) then
+ self.value = GetTime() - self.spellStartTime
+ end
+
+ self:RunHooksForWidget ("OnShow", self, self.unit)
+
+ elseif (self.channeling) then
+ local name, text, texture, endTime = UnitChannelInfo (self.unit)
+ if (name) then
+ self.value = self.spellEndTime - GetTime()
+ end
+
+ self:RunHooksForWidget ("OnShow", self, self.unit)
+ end
+ end
+ end,
+
+ --it's triggering several events since it's not registered for the unit with RegisterUnitEvent
+ OnEvent = function (self, event, ...)
+ local arg1 = ...
+ local unit = self.unit
+
+ if (event == "PLAYER_ENTERING_WORLD") then
+ local newEvent = self.PLAYER_ENTERING_WORLD (self, unit, ...)
+ if (newEvent) then
+ self.OnEvent (self, newEvent, unit)
+ return
+ end
+
+ elseif (arg1 ~= unit) then
+ return
+ end
+
+ local eventFunc = self [event]
+ if (eventFunc) then
+ eventFunc (self, unit, ...)
+ end
+ end,
+
+ OnTick_LazyTick = function (self)
+ --> run the lazy tick if allowed
+ if (self.Settings.CanLazyTick) then
+ --> update the cast time
+ if (self.Settings.ShowCastTime) then
+ if (self.casting) then
+ self.percentText:SetText (format ("%.1f", abs (self.value - self.maxValue)))
+
+ elseif (self.channeling) then
+ local remainingTime = abs (self.value)
+ if (remainingTime > 999) then
+ self.percentText:SetText ("")
+ else
+ self.percentText:SetText (format ("%.1f", remainingTime))
+ end
+ else
+ self.percentText:SetText ("")
+ end
+ end
+
+ return true
+ else
+ return false
+ end
+ end,
+
+ --> tick function for regular casts
+ OnTick_Casting = function (self, deltaTime)
+ self.value = self.value + deltaTime
+
+ if (self:CheckCastIsDone()) then
+ return
+ else
+ self:SetValue (self.value)
+ end
+
+ --update spark position
+ local sparkPosition = self.value / self.maxValue * self:GetWidth()
+ self.Spark:SetPoint ("center", self, "left", sparkPosition + self.Settings.SparkOffset, 0)
+
+ --in order to allow the lazy tick run, it must return true, it tell that the cast didn't finished
+ return true
+ end,
+
+ --> tick function for channeling casts
+ OnTick_Channeling = function (self, deltaTime)
+ self.value = self.value - deltaTime
+
+ if (self:CheckCastIsDone()) then
+ return
+ else
+ self:SetValue (self.value)
+ end
+
+ --update spark position
+ local sparkPosition = self.value / self.maxValue * self:GetWidth()
+ self.Spark:SetPoint ("center", self, "left", sparkPosition + self.Settings.SparkOffset, 0)
+
+ return true
+ end,
+
+ OnTick = function (self, deltaTime)
+ DF_CalcCpuUsage ("CastBar-OnTick")
+ if (self.casting) then
+ if (not self:OnTick_Casting (deltaTime)) then
+ DF_CalcCpuUsage ("CastBar-OnTick")
+ return
+ end
+
+ --lazy tick
+ self.lazyUpdateCooldown = self.lazyUpdateCooldown - deltaTime
+ if (self.lazyUpdateCooldown < 0) then
+ self:OnTick_LazyTick()
+ self.lazyUpdateCooldown = self.Settings.LazyUpdateCooldown
+ end
+
+ elseif (self.channeling) then
+ if (not self:OnTick_Channeling (deltaTime)) then
+ DF_CalcCpuUsage ("CastBar-OnTick")
+ return
+ end
+
+ --lazy tick
+ self.lazyUpdateCooldown = self.lazyUpdateCooldown - deltaTime
+ if (self.lazyUpdateCooldown < 0) then
+ self:OnTick_LazyTick()
+ self.lazyUpdateCooldown = self.Settings.LazyUpdateCooldown
+ end
+ end
+ DF_CalcCpuUsage ("CastBar-OnTick")
+ end,
+
+ --> animation start script
+ Animation_FadeOutStarted = function (self)
+
+ end,
+
+ --> animation finished script
+ Animation_FadeOutFinished = function (self)
+ local castBar = self:GetParent()
+ castBar:SetAlpha (1)
+ castBar:Hide()
+ end,
+
+ --> animation start script
+ Animation_FadeInStarted = function (self)
+
+ end,
+
+ --> animation finished script
+ Animation_FadeInFinished = function (self)
+ local castBar = self:GetParent()
+ castBar:Show()
+ castBar:SetAlpha (1)
+ end,
+
+ --> animation calls
+ Animation_FadeOut = function (self)
+ self:ScheduleToHide (false)
+
+ if (self.fadeInAnimation:IsPlaying()) then
+ self.fadeInAnimation:Stop()
+ end
+
+ if (not self.fadeOutAnimation:IsPlaying()) then
+ self.fadeOutAnimation:Play()
+ end
+ end,
+
+ Animation_FadeIn = function (self)
+ self:ScheduleToHide (false)
+
+ if (self.fadeOutAnimation:IsPlaying()) then
+ self.fadeOutAnimation:Stop()
+ end
+
+ if (not self.fadeInAnimation:IsPlaying()) then
+ self.fadeInAnimation:Play()
+ end
+ end,
+
+ Animation_Flash = function (self)
+ if (not self.flashAnimation:IsPlaying()) then
+ self.flashAnimation:Play()
+ end
+ end,
+
+ Animation_StopAllAnimations = function (self)
+ if (self.flashAnimation:IsPlaying()) then
+ self.flashAnimation:Stop()
+ end
+
+ if (self.fadeOutAnimation:IsPlaying()) then
+ self.fadeOutAnimation:Stop()
+ end
+
+ if (self.fadeInAnimation:IsPlaying()) then
+ self.fadeInAnimation:Stop()
+ end
+ end,
+
+ PLAYER_ENTERING_WORLD = function (self, unit, arg1)
+ local isChannel = UnitChannelInfo (unit)
+ local isRegularCast = UnitCastingInfo (unit)
+
+ if (isChannel) then
+ self.channeling = true
+ return self.unit == arg1 and "UNIT_SPELLCAST_CHANNEL_START"
+
+ elseif (isRegularCast) then
+ self.casting = true
+ return self.unit == arg1 and "UNIT_SPELLCAST_START"
+
+ else
+ self.casting = nil
+ self.channeling = nil
+ self.failed = nil
+ self.finished = nil
+ self.interrupted = nil
+ self.Spark:Hide()
+ self:Hide()
+ end
+ end,
+
+ UNIT_SPELLCAST_START = function (self, unit)
+
+ local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo (unit)
+
+ --> is valid?
+ if (not self:IsValid (unit, name, isTradeSkill, true)) then
+ return
+ end
+
+ --> setup cast
+ self.casting = true
+ self.channeling = nil
+ self.interrupted = nil
+ self.failed = nil
+ self.finished = nil
+ self.canInterrupt = not notInterruptible
+ self.spellID = spellID
+ self.castID = castID
+ self.spellName = name
+ self.spellTexture = texture
+ self.spellStartTime = startTime / 1000
+ self.spellEndTime = endTime / 1000
+ self.value = GetTime() - self.spellStartTime
+ self.maxValue = self.spellEndTime - self.spellStartTime
+
+ self:SetMinMaxValues (0, self.maxValue)
+ self:SetValue (self.value)
+ self:SetAlpha (1)
+ self.Icon:SetTexture (texture)
+ self.Icon:Show()
+ self.Text:SetText (text)
+
+ if (self.Settings.ShowCastTime and self.Settings.CanLazyTick) then
+ self.percentText:Show()
+ end
+
+ self.flashTexture:Hide()
+ self:Animation_StopAllAnimations()
+
+ if (not self:IsShown()) then
+ self:Animation_FadeIn()
+ end
+
+ self.Spark:Show()
+ self:SetAlpha (1)
+ self:Show()
+
+ --> set the statusbar color
+ self:UpdateCastColor()
+
+ --> update the interrupt cast border
+ self:UpdateInterruptState()
+
+ self:RunHooksForWidget ("OnCastStart", self, self.unit, "UNIT_SPELLCAST_START")
+ end,
+
+ UNIT_SPELLCAST_CHANNEL_START = function (self, unit, ...)
+ local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID = UnitChannelInfo (unit)
+
+ --> is valid?
+ if (not self:IsValid (unit, name, isTradeSkill, true)) then
+ return
+ end
+
+ --> setup cast
+ self.casting = nil
+ self.channeling = true
+ self.interrupted = nil
+ self.failed = nil
+ self.finished = nil
+ self.canInterrupt = not notInterruptible
+ self.spellID = spellID
+ self.castID = castID
+ self.spellName = name
+ self.spellTexture = texture
+ self.spellStartTime = startTime / 1000
+ self.spellEndTime = endTime / 1000
+ self.value = self.spellEndTime - GetTime()
+ self.maxValue = self.spellEndTime - self.spellStartTime
+
+ self:SetMinMaxValues (0, self.maxValue)
+ self:SetValue (self.value)
+
+ self:SetAlpha (1)
+ self.Icon:SetTexture (texture)
+ self.Icon:Show()
+ self.Text:SetText (text)
+
+ if (self.Settings.ShowCastTime and self.Settings.CanLazyTick) then
+ self.percentText:Show()
+ end
+
+ self.flashTexture:Hide()
+ self:Animation_StopAllAnimations()
+
+ if (not self:IsShown()) then
+ self:Animation_FadeIn()
+ end
+
+ self.Spark:Show()
+ self:SetAlpha (1)
+ self:Show()
+
+ --> set the statusbar color
+ self:UpdateCastColor()
+
+ --> update the interrupt cast border
+ self:UpdateInterruptState()
+
+ self:RunHooksForWidget ("OnCastStart", self, self.unit, "UNIT_SPELLCAST_CHANNEL_START")
+ end,
+
+ UNIT_SPELLCAST_STOP = function (self, unit, ...)
+ local unitID, castID, spellID = ...
+ if (self.castID == castID) then
+ self.Spark:Hide()
+ self.percentText:Hide()
+
+ local value = self:GetValue()
+ local _, maxValue = self:GetMinMaxValues()
+ self:SetValue (self.maxValue or maxValue or 1)
+
+ self.casting = nil
+ self.finished = true
+
+ if (not self:HasScheduledHide()) then
+ --> check if settings has no fade option or if its parents are not visible
+ if (not self:IsVisible()) then
+ self:Hide()
+
+ elseif (self.Settings.NoFadeEffects) then
+ self:ScheduleToHide (0.3)
+
+ else
+ self:Animation_Flash()
+ self:Animation_FadeOut()
+ end
+ end
+
+ self:UpdateCastColor()
+ end
+ end,
+
+ UNIT_SPELLCAST_CHANNEL_STOP = function (self, unit, ...)
+ local unitID, castID, spellID = ...
+
+ if (self.channeling and castID == self.castID) then
+ self.Spark:Hide()
+ self.percentText:Hide()
+
+ local value = self:GetValue()
+ local _, maxValue = self:GetMinMaxValues()
+ self:SetValue (self.maxValue or maxValue or 1)
+
+ self.channeling = nil
+ self.finished = true
+
+ if (not self:HasScheduledHide()) then
+ --> check if settings has no fade option or if its parents are not visible
+ if (not self:IsVisible()) then
+ self:Hide()
+
+ elseif (self.Settings.NoFadeEffects) then
+ self:ScheduleToHide (0.3)
+
+ else
+ self:Animation_Flash()
+ self:Animation_FadeOut()
+ end
+ end
+
+ self:UpdateCastColor()
+ end
+ end,
+
+ UNIT_SPELLCAST_FAILED = function (self, unit, ...)
+ local unitID, castID, spellID = ...
+
+ if (self.casting and castID == self.castID and not self.fadeOut) then
+ self.casting = nil
+ self.channeling = nil
+ self.failed = true
+ self.finished = true
+ self:SetValue (self.maxValue or select (2, self:GetMinMaxValues()) or 1)
+
+ --> set the statusbar color
+ self:UpdateCastColor()
+
+ self.Spark:Hide()
+ self.percentText:Hide()
+ self.Text:SetText (FAILED) --> auto locale within the global namespace
+
+ self:ScheduleToHide (1)
+ end
+ end,
+
+ UNIT_SPELLCAST_INTERRUPTED = function (self, unit, ...)
+ local unitID, castID, spellID = ...
+
+ if (self.casting and castID == self.castID and not self.fadeOut) then
+ self.casting = nil
+ self.channeling = nil
+ self.interrupted = true
+ self.finished = true
+ self:SetValue (self.maxValue or select (2, self:GetMinMaxValues()) or 1)
+
+ local castColor = self:GetCastColor()
+ self:SetColor (castColor) --SetColor handles with ParseColors()
+
+ self.Spark:Hide()
+ self.percentText:Hide()
+ self.Text:SetText (INTERRUPTED) --> auto locale within the global namespace
+
+ self:ScheduleToHide (1)
+ end
+ end,
+
+ UNIT_SPELLCAST_DELAYED = function (self, unit, ...)
+ local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo (unit)
+
+ if (not self:IsValid (unit, name, isTradeSkill)) then
+ return
+ end
+
+ --> update the cast time
+ self.spellStartTime = startTime / 1000
+ self.spellEndTime = endTime / 1000
+ self.value = GetTime() - self.spellStartTime
+ self.maxValue = self.spellEndTime - self.spellStartTime
+ self:SetMinMaxValues (0, self.maxValue)
+ end,
+
+ UNIT_SPELLCAST_CHANNEL_UPDATE = function (self, unit, ...)
+ local name, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo (unit)
+
+ if (not self:IsValid (unit, name, isTradeSkill)) then
+ return
+ end
+
+ --> update the cast time
+ self.spellStartTime = startTime / 1000
+ self.spellEndTime = endTime / 1000
+ self.value = self.spellEndTime - GetTime()
+ self.maxValue = self.spellEndTime - self.spellStartTime
+ self:SetMinMaxValues (0, self.maxValue)
+ self:SetValue (self.value)
+ end,
+
+ --> cast changed its state to interruptable
+ UNIT_SPELLCAST_INTERRUPTIBLE = function (self, unit, ...)
+ self.canInterrupt = true
+ self:UpdateCastColor()
+ self:UpdateInterruptState()
+ end,
+
+ --> cast changed its state to non interruptable
+ UNIT_SPELLCAST_NOT_INTERRUPTIBLE = function (self, unit, ...)
+ self.canInterrupt = false
+ self:UpdateCastColor()
+ self:UpdateInterruptState()
+ end,
+
+}
+
+-- ~castbar
+
+function DF:CreateCastBar (parent, name, settingsOverride)
+
+ assert (name or parent:GetName(), "DetailsFramework:CreateCastBar parameter 'name' omitted and parent has no name.")
+
+ local castBar = CreateFrame ("StatusBar", name or (parent:GetName() .. "CastBar"), parent)
+
+ do --layers
+
+ --these widgets was been made with back compatibility in mind
+ --they are using the same names as the retail game uses on the nameplate castbar
+ --this should make Plater core and Plater scripts made by users compatible with the new unit frame made on the framework
+
+ --background
+ castBar.background = castBar:CreateTexture (nil, "background")
+ castBar.background:SetDrawLayer ("background", -6)
+
+ castBar.extraBackground = castBar:CreateTexture (nil, "background")
+ castBar.extraBackground:SetDrawLayer ("background", -5)
+
+ --overlay
+ castBar.Text = castBar:CreateFontString (nil, "overlay", "SystemFont_Shadow_Small")
+ castBar.Text:SetPoint ("center", 0, 0)
+ castBar.Text:SetDrawLayer ("overlay", 1)
+
+ castBar.BorderShield = castBar:CreateTexture (nil, "overlay")
+ castBar.BorderShield:SetDrawLayer ("overlay", 5)
+ castBar.BorderShield:Hide()
+
+ castBar.Icon = castBar:CreateTexture (nil, "overlay")
+ castBar.Icon:SetDrawLayer ("overlay", 4)
+ castBar.Icon:Hide()
+
+ castBar.Spark = castBar:CreateTexture (nil, "overlay")
+ castBar.Spark:SetDrawLayer ("overlay", 3)
+ castBar.Spark:SetBlendMode ("ADD")
+
+ --time left on the cast
+ castBar.percentText = castBar:CreateFontString (nil, "overlay", "SystemFont_Shadow_Small")
+ castBar.percentText:SetDrawLayer ("overlay", 7)
+
+ --statusbar texture
+ castBar.barTexture = castBar:CreateTexture (nil, "artwork")
+ castBar:SetStatusBarTexture (castBar.barTexture)
+
+ --animations fade in and out
+ local fadeOutAnimationHub = DF:CreateAnimationHub (castBar, DF.CastFrameFunctions.Animation_FadeOutStarted, DF.CastFrameFunctions.Animation_FadeOutFinished)
+ fadeOutAnimationHub.alpha1 = DF:CreateAnimation (fadeOutAnimationHub, "ALPHA", 1, 1, 1, 0)
+ castBar.fadeOutAnimation = fadeOutAnimationHub
+
+ local fadeInAnimationHub = DF:CreateAnimationHub (castBar, DF.CastFrameFunctions.Animation_FadeInStarted, DF.CastFrameFunctions.Animation_FadeInFinished)
+ fadeInAnimationHub.alpha1 = DF:CreateAnimation (fadeInAnimationHub, "ALPHA", 1, 0.150, 0, 1)
+ castBar.fadeInAnimation = fadeInAnimationHub
+
+ --animatios flash
+ local flashTexture = castBar:CreateTexture (nil, "overlay")
+ flashTexture:SetDrawLayer ("overlay", 7)
+ flashTexture:SetColorTexture (1, 1, 1, 1)
+ flashTexture:SetAllPoints()
+ flashTexture:SetAlpha (0)
+ flashTexture:Hide()
+ flashTexture:SetBlendMode ("ADD")
+ castBar.flashTexture = flashTexture
+
+ local flashAnimationHub = DF:CreateAnimationHub (flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end)
+ DF:CreateAnimation (flashAnimationHub, "ALPHA", 1, 0.2, 0, 0.8)
+ DF:CreateAnimation (flashAnimationHub, "ALPHA", 2, 0.2, 1, 0)
+ castBar.flashAnimation = flashAnimationHub
+ end
+
+ --> mixins
+ DF:Mixin (castBar, DF.CastFrameFunctions)
+ DF:Mixin (castBar, DF.StatusBarFunctions)
+
+ --> settings and hooks
+ local settings = DF.table.copy ({}, DF.CastFrameFunctions.Settings)
+ if (settingsOverride) then
+ DF.table.copy (settings, settingsOverride)
+ end
+ castBar.Settings = settings
+
+ local hookList = DF.table.copy ({}, DF.CastFrameFunctions.HookList)
+ castBar.HookList = hookList
+
+ --> initialize the cast bar
+ castBar:Initialize()
+
+ return castBar
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> border frame
+
+--[=[
+ DF:CreateBorderFrame (parent, name)
+ creates a frame with 4 child textures attached to each one of the 4 sides of a frame
+ @parent = parent frame to pass to CreateFrame function
+ @name = name of the frame, if omitted a random name is created
+--]=]
+
+DF.BorderFunctions = {
+ SetBorderColor = function (self, r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ for _, texture in ipairs (self.allTextures) do
+ texture:SetVertexColor (r, g, b, a)
+ end
+ end,
+
+ SetBorderThickness = function (self, newThickness)
+ PixelUtil.SetWidth (f.leftBorder, newThickness, newThickness)
+ PixelUtil.SetWidth (f.rightBorder, newThickness, newThickness)
+ PixelUtil.SetHeight (f.topBorder, newThickness, newThickness)
+ PixelUtil.SetHeight (f.bottomBorder, newThickness, newThickness)
+ end,
+
+ WidgetType = "border",
+}
+
+-- ~borderframe
+function DF:CreateBorderFrame (parent, name)
+
+ local parentName = name or "DetailsFrameworkBorderFrame" .. tostring (math.random (1, 100000000))
+
+ local f = CreateFrame ("frame", parentName, parent)
+ f:SetFrameLevel (f:GetFrameLevel()+1)
+ f:SetAllPoints()
+
+ DF:Mixin (f, DF.BorderFunctions)
+
+ f.allTextures = {}
+
+ --> create left border
+ local leftBorder = f:CreateTexture (nil, "overlay")
+ leftBorder:SetDrawLayer ("overlay", 7)
+ leftBorder:SetColorTexture (1, 1, 1, 1)
+ tinsert (f.allTextures, leftBorder)
+ f.leftBorder = leftBorder
+ PixelUtil.SetPoint (leftBorder, "topright", f, "topleft", 0, 1, 0, 1)
+ PixelUtil.SetPoint (leftBorder, "bottomright", f, "bottomleft", 0, -1, 0, -1)
+ PixelUtil.SetWidth (leftBorder, 1, 1)
+
+ --> create right border
+ local rightBorder = f:CreateTexture (nil, "overlay")
+ rightBorder:SetDrawLayer ("overlay", 7)
+ rightBorder:SetColorTexture (1, 1, 1, 1)
+ tinsert (f.allTextures, rightBorder)
+ f.rightBorder = rightBorder
+ PixelUtil.SetPoint (rightBorder, "topleft", f, "topright", 0, 1, 0, 1)
+ PixelUtil.SetPoint (rightBorder, "bottomleft", f, "bottomright", 0, -1, 0, -1)
+ PixelUtil.SetWidth (rightBorder, 1, 1)
+
+ --> create top border
+ local topBorder = f:CreateTexture (nil, "overlay")
+ topBorder:SetDrawLayer ("overlay", 7)
+ topBorder:SetColorTexture (1, 1, 1, 1)
+ tinsert (f.allTextures, topBorder)
+ f.topBorder = topBorder
+ PixelUtil.SetPoint (topBorder, "bottomleft", f, "topleft", 0, 0, 0, 0)
+ PixelUtil.SetPoint (topBorder, "bottomright", f, "topright", 0, 0, 0, 0)
+ PixelUtil.SetHeight (topBorder, 1, 1)
+
+ --> create border
+ local bottomBorder = f:CreateTexture (nil, "overlay")
+ bottomBorder:SetDrawLayer ("overlay", 7)
+ bottomBorder:SetColorTexture (1, 1, 1, 1)
+ tinsert (f.allTextures, bottomBorder)
+ f.bottomBorder = bottomBorder
+ PixelUtil.SetPoint (bottomBorder, "topleft", f, "bottomleft", 0, 0, 0, 0)
+ PixelUtil.SetPoint (bottomBorder, "topright", f, "bottomright", 0, 0, 0, 0)
+ PixelUtil.SetHeight (bottomBorder, 1, 1)
+
+ return f
+end
+
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> unit frame
+
+--[=[
+ DF:CreateUnitFrame (parent, name, settingsOverride)
+ creates a very basic unit frame with a healthbar, castbar and power bar
+ each unit frame has a .Settings table which isn't shared among other unit frames created with this method
+ all members names are the same as the unit frame from the retail game
+
+ @parent = frame to pass for the CreateFrame function
+ @name = absolute name of the frame, if omitted a random name is created
+ @settingsOverride = table with keys and values to replace the defaults from the framework
+
+--]=]
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> unit frame
+
+ --> return true if the unit has been claimed by another player (health bar is gray)
+ local unit_is_tap_denied = function (unit)
+ return unit and not UnitPlayerControlled (unit) and UnitIsTapDenied (unit)
+ end
+
+ DF.UnitFrameFunctions = {
+
+ WidgetType = "unitFrame",
+
+ Settings = {
+ --> unit frames
+ ClearUnitOnHide = true, --> if tue it'll set the unit to nil when the unit frame is set to hide
+ ShowCastBar = true, --if this is false, the cast bar for the unit won't be shown
+ ShowPowerBar = true, --if true it'll show the power bar for the unit, e.g. the mana bar
+ ShowUnitName = true, --if false, the unit name won't show
+ ShowBorder = true, --if false won't show the border frame
+
+ --> health bar color
+ CanModifyHealhBarColor = true, --> if false it won't change the color of the health bar
+ ColorByAggro = false, --if true it'll color the healthbar with red color when the unit has aggro on player
+ FixedHealthColor = false, --color override with a table {r=1, g=1, b=1}
+ UseFriendlyClassColor = true, --make the healthbar class color for friendly players
+ UseEnemyClassColor = true, --make the healthbar class color for enemy players
+
+ --> misc
+ ShowTargetOverlay = true, --shows a highlighht for the player current target
+ BorderColor = DF:CreateColorTable (0, 0, 0, 1), --border color, set to alpha zero for no border
+ CanTick = false, --if true it'll run the OnTick event
+
+ --> size
+ Width = 100,
+ Height = 20,
+ PowerBarHeight = 4,
+ CastBarHeight = 8,
+ },
+
+ UnitFrameEvents = {
+ --> run for all units
+ {"PLAYER_ENTERING_WORLD"},
+ {"PARTY_MEMBER_DISABLE"},
+ {"PARTY_MEMBER_ENABLE"},
+ {"PLAYER_TARGET_CHANGED"},
+
+ --> run for one unit
+ {"UNIT_NAME_UPDATE", true},
+ {"UNIT_CONNECTION", true},
+ {"UNIT_ENTERED_VEHICLE", true},
+ {"UNIT_EXITED_VEHICLE", true},
+ {"UNIT_PET", true},
+ {"UNIT_THREAT_LIST_UPDATE", true},
+ },
+
+ --> used when a event is triggered to quickly check if is a unit event
+ IsUnitEvent = {
+ ["UNIT_NAME_UPDATE"] = true,
+ ["UNIT_CONNECTION"] = true,
+ ["UNIT_ENTERED_VEHICLE"] = true,
+ ["UNIT_EXITED_VEHICLE"] = true,
+ ["UNIT_PET"] = true,
+ ["UNIT_THREAT_LIST_UPDATE"] = true,
+ },
+
+ Initialize = function (self)
+ self.border:SetBorderColor (self.Settings.BorderColor)
+
+ PixelUtil.SetWidth (self, self.Settings.Width, 1)
+ PixelUtil.SetHeight (self, self.Settings.Height, 1)
+
+ PixelUtil.SetPoint (self.powerBar, "bottomleft", self, "bottomleft", 0, 0, 1, 1)
+ PixelUtil.SetPoint (self.powerBar, "bottomright", self, "bottomright", 0, 0, 1, 1)
+ PixelUtil.SetHeight (self.powerBar, self.Settings.PowerBarHeight, 1)
+
+ --make the castbar overlap the powerbar
+ PixelUtil.SetPoint (self.castBar, "bottomleft", self, "bottomleft", 0, 0, 1, 1)
+ PixelUtil.SetPoint (self.castBar, "bottomright", self, "bottomright", 0, 0, 1, 1)
+ PixelUtil.SetHeight (self.castBar, self.Settings.CastBarHeight, 1)
+ end,
+
+ SetHealthBarColor = function (self, r, g, b, a)
+ self.healthBar:SetColor (r, g, b, a)
+ end,
+
+ --> register all events which will be used by the unit frame
+ RegisterEvents = function (self)
+ --> register events
+ for index, eventTable in ipairs (self.UnitFrameEvents) do
+ local event, isUnitEvent = unpack (eventTable)
+ if (not isUnitEvent) then
+ self:RegisterEvent (event)
+ else
+ self:RegisterUnitEvent (event, self.unit, self.displayedUnit ~= unit and self.displayedUnit or nil)
+ end
+ end
+
+ --> check settings and unregister events for disabled features
+ if (not self.Settings.ColorByAggro) then
+ self:UnregisterEvent ("UNIT_THREAT_LIST_UPDATE")
+ end
+
+ --> set scripts
+ self:SetScript ("OnEvent", self.OnEvent)
+ self:SetScript ("OnHide", self.OnHide)
+
+ if (self.Settings.CanTick) then
+ self:SetScript ("OnUpdate", self.OnTick)
+ end
+ end,
+
+ --> unregister events, called when this unit frame losses its unit
+ UnregisterEvents = function (self)
+ for index, eventTable in ipairs (self.UnitFrameEvents) do
+ local event, firstUnit, secondUnit = unpack (eventTable)
+ self:UnregisterEvent (event)
+ end
+
+ self:SetScript ("OnEvent", nil)
+ self:SetScript ("OnUpdate", nil)
+ self:SetScript ("OnHide", nil)
+ end,
+
+ --> call every tick
+ OnTick = function (self, deltaTime) end, --if overrided, set 'CanTick' to true on the settings table
+
+ --> when an event happen for this unit, send it to the apropriate function
+ OnEvent = function (self, event, ...)
+ --> run the function for this event
+ DF_CalcCpuUsage ("unitFrame-OnEvent")
+ local eventFunc = self [event]
+ if (eventFunc) then
+ --> is this event an unit event?
+ if (self.IsUnitEvent [event]) then
+ local unit = ...
+ --> check if is for this unit (even if the event is registered only for the unit)
+ if (unit == self.unit or unit == self.displayedUnit) then
+ eventFunc (self, ...)
+ end
+ else
+ eventFunc (self, ...)
+ end
+ end
+ DF_CalcCpuUsage ("unitFrame-OnEvent")
+ end,
+
+ OnHide = function (self)
+ if (self.Settings.ClearUnitOnHide) then
+ self:SetUnit (nil)
+ end
+ end,
+
+ --> run if the unit currently shown is different than the new one
+ SetUnit = function (self, unit)
+ if (unit ~= self.unit or unit == nil) then
+ self.unit = unit --absolute unit
+ self.displayedUnit = unit --~todo rename to 'displayedUnit' for back compatibility with older scripts in Plater
+ self.unitInVehicle = nil --true when the unit is in a vehicle
+
+ if (unit) then
+ self:RegisterEvents()
+
+ self.healthBar:SetUnit (unit, self.displayedUnit)
+
+ --> is using castbars?
+ if (self.Settings.ShowCastBar) then
+ self.castBar:SetUnit (unit, self.displayedUnit)
+ else
+ self.castBar:SetUnit (nil)
+ end
+
+ --> is using powerbars?
+ if (self.Settings.ShowPowerBar) then
+ self.powerBar:SetUnit (unit, self.displayedUnit)
+ else
+ self.powerBar:SetUnit (nil)
+ end
+
+ --> is using the border?
+ if (self.Settings.ShowBorder) then
+ self.border:Show()
+ else
+ self.border:Hide()
+ end
+
+ if (not self.Settings.ShowUnitName) then
+ self.unitName:Hide()
+ end
+ else
+ self:UnregisterEvents()
+ self.healthBar:SetUnit (nil)
+ self.castBar:SetUnit (nil)
+ self.powerBar:SetUnit (nil)
+ end
+
+ self:UpdateUnitFrame()
+ end
+ end,
+
+ --> if the unit is controlling a vehicle, need to show the vehicle instead
+ --> .unit and .displayedUnit is always the same execept when the unit is controlling a vehicle, then .displayedUnit is the unitID for the vehicle
+ --> todo: see what 'UnitTargetsVehicleInRaidUI' is, there's a call for this in the CompactUnitFrame.lua but zero documentation
+ CheckVehiclePossession = function (self)
+ --> this unit is possessing a vehicle?
+ local unitPossessVehicle = UnitHasVehicleUI (self.unit)
+ if (unitPossessVehicle) then
+ if (not self.unitInVehicle) then
+ if (UnitIsUnit ("player", self.unit)) then
+ self.displayedUnit = "vehicle"
+ self.unitInVehicle = true
+ self:RegisterEvents()
+ self:UpdateAllWidgets()
+ return true
+ end
+
+ local prefix, id, suffix = string.match (self.unit, "([^%d]+)([%d]*)(.*)") --CompactUnitFrame.lua
+ local vehicleUnitID = prefix .. "pet" .. id .. suffix
+ if (UnitExists (vehicleUnitID)) then
+ self.displayedUnit = vehicleUnitID
+ self.unitInVehicle = true
+ self:RegisterEvents()
+ self:UpdateAllWidgets()
+ return true
+ end
+ end
+ end
+
+ if (self.unitInVehicle) then
+ self.displayedUnit = self.unit
+ self.unitInVehicle = nil
+ self:RegisterEvents()
+ self:UpdateAllWidgets()
+ end
+ end,
+
+ --> find a color for the health bar, if a color has been passed in the arguments use it instead, 'CanModifyHealhBarColor' must be true for this function run
+ UpdateHealthColor = function (self, r, g, b)
+
+ --> check if color changes is disabled
+ if (not self.Settings.CanModifyHealhBarColor) then
+ return
+ end
+
+ local unit = self.displayedUnit
+
+ --> check if a color has been passed within the parameters
+ if (r) then
+ --> check if passed a special color
+ if (type (r) ~= "number") then
+ r, g, b = DF:ParseColors (r)
+ end
+
+ self:SetHealthBarColor (r, g, b)
+ return
+ end
+
+ --> check if there is a color override in the settings
+ if (self.Settings.FixedHealthColor) then
+ local FixedHealthColor = self.Settings.FixedHealthColor
+ r, g, b = FixedHealthColor.r, FixedHealthColor.g, FixedHealthColor.b
+ self:SetHealthBarColor (r, g, b)
+ return
+ end
+
+ --> check if the unit is a player
+ if (UnitIsPlayer (unit)) then
+
+ --> check if the unit is disconnected (in case it is a player
+ if (not UnitIsConnected (unit)) then
+ self:SetHealthBarColor (.5, .5, .5)
+ return
+ end
+
+ --is a friendly or enemy player?
+ if (UnitIsFriend ("player", unit)) then
+ if (self.Settings.UseFriendlyClassColor) then
+ local _, className = UnitClass (unit)
+ if (className) then
+ local classColor = RAID_CLASS_COLORS [className]
+ if (classColor) then
+ self:SetHealthBarColor (classColor.r, classColor.g, classColor.b)
+ return
+ end
+ end
+ else
+ self:SetHealthBarColor (0, 1, 0)
+ return
+ end
+ else
+ if (self.Settings.UseEnemyClassColor) then
+ local _, className = UnitClass (unit)
+ if (className) then
+ local classColor = RAID_CLASS_COLORS [className]
+ if (classColor) then
+ self:SetHealthBarColor (classColor.r, classColor.g, classColor.b)
+ return
+ end
+ end
+ else
+ self:SetHealthBarColor (1, 0, 0)
+ return
+ end
+ end
+ end
+
+ --> is tapped?
+ if (unit_is_tap_denied (unit)) then
+ self:SetHealthBarColor (.6, .6, .6)
+ return
+ end
+
+ --> is this is a npc attacking the player?
+ if (self.Settings.ColorByAggro) then
+ local _, threatStatus = UnitDetailedThreatSituation ("player", unit)
+ if (threatStatus) then
+ self:SetHealthBarColor (1, 0, 0)
+ return
+ end
+ end
+
+ --> get the regular color by selection
+ r, g, b = UnitSelectionColor (unit)
+ self:SetHealthBarColor (r, g, b)
+ end,
+
+ --> misc
+ UpdateName = function (self)
+ if (not self.Settings.ShowUnitName) then
+ return
+ end
+
+ --unit name without realm names by default
+ local name = UnitName (self.unit)
+ self.unitName:SetText (name)
+ self.unitName:Show()
+ end,
+
+ --> this runs when the player it self changes its target, need to update the current target overlay
+ --> todo: add focus overlay
+ UpdateTargetOverlay = function (self)
+ if (not self.Settings.ShowTargetOverlay) then
+ self.targetOverlay:Hide()
+ return
+ end
+
+ if (UnitIsUnit (self.displayedUnit, "target")) then
+ self.targetOverlay:Show()
+ else
+ self.targetOverlay:Hide()
+ end
+ end,
+
+ UpdateAllWidgets = function (self)
+ if (UnitExists (self.displayedUnit)) then
+ local unit = self.unit
+ local displayedUnit = self.displayedUnit
+
+ self:SetUnit (unit, displayedUnit)
+
+ --> is using castbars?
+ if (self.Settings.ShowCastBar) then
+ self.castBar:SetUnit (unit, displayedUnit)
+ end
+
+ --> is using powerbars?
+ if (self.Settings.ShowPowerBar) then
+ self.powerBar:SetUnit (unit, displayedUnit)
+ end
+
+ self:UpdateName()
+ self:UpdateTargetOverlay()
+ self:UpdateHealthColor()
+ end
+ end,
+
+ --> update the unit frame and its widgets
+ UpdateUnitFrame = function (self)
+ local unitInVehicle = self:CheckVehiclePossession()
+
+ --> if the unit is inside a vehicle, the vehicle possession function will call an update on all widgets
+ if (not unitInVehicle) then
+ self:UpdateAllWidgets()
+ end
+ end,
+
+ --> event handles
+ PLAYER_ENTERING_WORLD = function (self, ...)
+ self:UpdateUnitFrame()
+ end,
+
+ --> update overlays when the player changes its target
+ PLAYER_TARGET_CHANGED = function (self, ...)
+ self:UpdateTargetOverlay()
+ end,
+
+ --> unit received a name update
+ UNIT_NAME_UPDATE = function (self, ...)
+ self:UpdateName()
+ end,
+
+ --> this is registered only if .settings.ColorByAggro is true
+ UNIT_THREAT_LIST_UPDATE = function (self, ...)
+ if (self.Settings.ColorByAggro) then
+ self:UpdateHealthColor()
+ end
+ end,
+
+ --> vehicle
+ UNIT_ENTERED_VEHICLE = function (self, ...)
+ self:UpdateUnitFrame()
+ end,
+ UNIT_EXITED_VEHICLE = function (self, ...)
+ self:UpdateUnitFrame()
+ end,
+
+ --> pet
+ UNIT_PET = function (self, ...)
+ self:UpdateUnitFrame()
+ end,
+
+ --> player connection
+ UNIT_CONNECTION = function (self, ...)
+ if (UnitIsConnected (self.unit)) then
+ self:UpdateUnitFrame()
+ end
+ end,
+ PARTY_MEMBER_ENABLE = function (self, ...)
+ if (UnitIsConnected (self.unit)) then
+ self:UpdateName()
+ end
+ end,
+ }
+
+-- ~unitframe
+function DF:CreateUnitFrame (parent, name, unitFrameSettingsOverride, healthBarSettingsOverride, castBarSettingsOverride, powerBarSettingsOverride)
+
+ local parentName = name or ("DetailsFrameworkUnitFrame" .. tostring (math.random (1, 100000000)))
+
+ --> create the main unit frame
+ local f = CreateFrame ("button", parentName, parent)
+
+ --> base level
+ local baseFrameLevel = f:GetFrameLevel()
+
+ --> create the healthBar
+ local healthBar = DF:CreateHealthBar (f, false, healthBarSettingsOverride)
+ healthBar:SetFrameLevel (baseFrameLevel + 1)
+ f.healthBar = healthBar
+
+ --> create the power bar
+ local powerBar = DF:CreatePowerBar (f, false, powerBarSettingsOverride)
+ powerBar:SetFrameLevel (baseFrameLevel + 2)
+ f.powerBar = powerBar
+
+ --> create the castBar
+ local castBar = DF:CreateCastBar (f, false, castBarSettingsOverride)
+ castBar:SetFrameLevel (baseFrameLevel + 3)
+ f.castBar = castBar
+
+ --> border frame
+ local borderFrame = DF:CreateBorderFrame (f, f:GetName() .. "Border")
+ borderFrame:SetFrameLevel (f:GetFrameLevel() + 5)
+ f.border = borderFrame
+
+ --> overlay frame (widgets that need to stay above the unit frame)
+ local overlayFrame = CreateFrame ("frame", "$parentOverlayFrame", f)
+ borderFrame:SetFrameLevel (f:GetFrameLevel() + 6)
+ f.overlayFrame = overlayFrame
+
+ --> unit frame layers
+ do
+ --artwork
+ f.unitName = f:CreateFontString (nil, "artwork", "GameFontHighlightSmall")
+ PixelUtil.SetPoint (f.unitName, "topleft", healthBar, "topleft", 2, -2, 1, 1)
+
+ --target overlay - it's parented in the healthbar so other widgets won't get the overlay
+ f.targetOverlay = overlayFrame:CreateTexture (nil, "artwork")
+ f.targetOverlay:SetTexture (healthBar:GetTexture())
+ f.targetOverlay:SetBlendMode ("ADD")
+ f.targetOverlay:SetAlpha (.5)
+ f.targetOverlay:SetAllPoints (healthBar)
+ end
+
+ --> mixins
+ --inject mixins
+ DF:Mixin (f, DF.UnitFrameFunctions)
+
+ --create the settings table and copy the overrides into it, the table is set into the frame after the mixin
+ local unitFrameSettings = DF.table.copy ({}, DF.UnitFrameFunctions.Settings)
+ if (unitFrameSettingsOverride) then
+ unitFrameSettings = DF.table.copy (unitFrameSettings, unitFrameSettingsOverride)
+ end
+ f.Settings = unitFrameSettings
+
+ --> initialize scripts
+ --unitframe
+ f:Initialize()
+
+ return f
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> horizontal scroll frame
+
+local timeline_options = {
+ width = 400,
+ height = 700,
+ line_height = 20,
+ line_padding = 1,
+
+ show_elapsed_timeline = true,
+ elapsed_timeline_height = 20,
+
+ --space to put the player/spell name and icons
+ header_width = 150,
+
+ --how many pixels will be use to represent 1 second
+ pixels_per_second = 20,
+
+ backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {0, 0, 0, 0.2},
+ backdrop_color_highlight = {.2, .2, .2, 0.4},
+ backdrop_border_color = {0.1, 0.1, 0.1, .2},
+
+ title_template = "ORANGE_FONT_TEMPLATE",
+ text_tempate = "OPTIONS_FONT_TEMPLATE",
+
+ on_enter = DF.DataScrollFunctions.LineOnEnter,
+ on_leave = DF.DataScrollFunctions.LineOnLeave,
+}
+
+local elapsedtime_frame_options = {
+ backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
+ backdrop_color = {.3, .3, .3, .7},
+
+ text_color = {1, 1, 1, 1},
+ text_size = 12,
+ text_font = "Arial Narrow",
+ text_outline = "NONE",
+
+ height = 20,
+
+ distance = 200, --distance in pixels between each label informing the time
+ distance_min = 50, --minimum distance in pixels
+ draw_line = true, --if true it'll draw a vertical line to represent a segment
+ draw_line_color = {1, 1, 1, 0.3},
+ draw_line_thickness = 1,
+}
+
+DF.TimeLineElapsedTimeFunctions = {
+ --get a label and update its appearance
+ GetLabel = function (self, index)
+ local label = self.labels [index]
+
+ if (not label) then
+ label = self:CreateFontString (nil, "artwork", "GameFontNormal")
+ label.line = self:CreateTexture (nil, "artwork")
+ label.line:SetColorTexture (1, 1, 1)
+ label.line:SetPoint ("topleft", label, "bottomleft", 0, -2)
+ self.labels [index] = label
+ end
+
+ DF:SetFontColor (label, self.options.text_color)
+ DF:SetFontSize (label, self.options.text_size)
+ DF:SetFontFace (label, self.options.text_font)
+ DF:SetFontOutline (label, self.options.text_outline)
+
+ if (self.options.draw_line) then
+ label.line:SetVertexColor (unpack (self.options.draw_line_color))
+ label.line:SetWidth (self.options.draw_line_thickness)
+ label.line:Show()
+ else
+ label.line:Hide()
+ end
+
+ return label
+ end,
+
+ Reset = function (self)
+ for i = 1, #self.labels do
+ self.labels [i]:Hide()
+ end
+ end,
+
+ Refresh = function (self, elapsedTime, scale)
+ local parent = self:GetParent()
+
+ self:SetHeight (self.options.height)
+ local effectiveArea = self:GetWidth() --already scaled down width
+ local pixelPerSecond = elapsedTime / effectiveArea --how much 1 pixels correlate to time
+
+ local distance = self.options.distance --pixels between each segment
+ local minDistance = self.options.distance_min --min pixels between each segment
+
+ --scale the distance between each label showing the time with the parent's scale
+ distance = distance * scale
+ distance = max (distance, minDistance)
+
+ local amountSegments = ceil (effectiveArea / distance)
+
+ for i = 1, amountSegments do
+ local label = self:GetLabel (i)
+ local xOffset = distance * (i - 1)
+ label:SetPoint ("left", self, "left", xOffset, 0)
+
+ local secondsOfTime = pixelPerSecond * xOffset
+
+ label:SetText (DF:IntegerToTimer (floor (secondsOfTime)))
+
+ if (label.line:IsShown()) then
+ label.line:SetHeight (parent:GetParent():GetHeight())
+ end
+
+ label:Show()
+ end
+ end,
+}
+
+--creates a frame to show the elapsed time in a row
+function DF:CreateElapsedTimeFrame (parent, name, options)
+ local elapsedTimeFrame = CreateFrame ("frame", name, parent)
+
+ DF:Mixin (elapsedTimeFrame, DF.OptionsFunctions)
+ DF:Mixin (elapsedTimeFrame, DF.LayoutFrame)
+
+ elapsedTimeFrame:BuildOptionsTable (elapsedtime_frame_options, options)
+
+ DF:Mixin (elapsedTimeFrame, DF.TimeLineElapsedTimeFunctions)
+
+ elapsedTimeFrame:SetBackdrop (elapsedTimeFrame.options.backdrop)
+ elapsedTimeFrame:SetBackdropColor (unpack (elapsedTimeFrame.options.backdrop_color))
+
+ elapsedTimeFrame.labels = {}
+
+ return elapsedTimeFrame
+end
+
+
+DF.TimeLineBlockFunctions = {
+ --self is the line
+ SetBlock = function (self, index, blockInfo)
+ --get the block information
+ --see what is the current scale
+ --adjust the block position
+
+ local block = self:GetBlock (index)
+
+ --need:
+ --the total time of the timeline
+ --the current scale of the timeline
+ --the elapsed time of this block
+ --icon of the block
+ --text
+ --background color
+
+ end,
+
+ SetBlocksFromData = function (self)
+ local parent = self:GetParent():GetParent()
+ local data = parent.data
+ local defaultColor = parent.defaultColor --guarantee to have a value
+
+ self:Show()
+
+ --none of these values are scaled, need to calculate
+ local pixelPerSecond = parent.pixelPerSecond
+ local totalLength = parent.totalLength
+ local scale = parent.currentScale
+
+ pixelPerSecond = pixelPerSecond * scale
+
+ local headerWidth = parent.headerWidth
+
+ --dataIndex stores which line index from the data this line will use
+ --lineData store members: .text .icon .timeline
+ local lineData = data.lines [self.dataIndex]
+
+ --if there's an icon, anchor the text at the right side of the icon
+ --this is the title and icon of the title
+ if (lineData.icon) then
+ self.icon:SetTexture (lineData.icon)
+ self.text:SetText (lineData.text or "")
+ self.text:SetPoint ("left", self.icon.widget, "right", 2, 0)
+ else
+ self.icon:SetTexture (nil)
+ self.text:SetText (lineData.text or "")
+ text:SetPoint ("left", self, "left", 2, 0)
+ end
+
+ local timelineData = lineData.timeline
+
+ for i = 1, #timelineData do
+ local blockInfo = timelineData [i]
+
+ local time = blockInfo [1]
+ local length = blockInfo [2]
+ local color = blockInfo [3] or defaultColor
+ local text = blockInfo [4]
+ local icon = blockInfo [5]
+ local tooltip = blockInfo [6]
+
+ local xOffset = pixelPerSecond * time
+ local width = pixelPerSecond * length
+
+ local block = self:GetBlock (i)
+ block:Show()
+ PixelUtil.SetPoint (block, "left", self, "left", xOffset + headerWidth, 0)
+ PixelUtil.SetSize (block, width, self:GetHeight())
+ block.background:SetVertexColor (unpack (color))
+
+ --guess where it is anchored
+ --guess it's size
+ --both taking in consideration the scroll scale
+
+ end
+ end,
+
+ GetBlock = function (self, index)
+ local block = self.blocks [index]
+ if (not block) then
+ block = CreateFrame ("frame", nil, self)
+ self.blocks [index] = block
+
+ local background = block:CreateTexture (nil, "background")
+ background:SetColorTexture (1, 1, 1, 1)
+ local icon = block:CreateTexture (nil, "artwork")
+ local text = block:CreateFontString (nil, "artwork")
+
+ background:SetAllPoints()
+ icon:SetPoint ("left")
+ text:SetPoint ("left", icon, "left", 2, 0)
+
+ block.icon = icon
+ block.text = text
+ block.background = background
+ end
+
+ return block
+ end,
+
+ Reset = function (self)
+ --attention, it doesn't reset icon texture, text and background color
+ for i = 1, #self.blocks do
+ self.blocks [i]:Hide()
+ end
+ self:Hide()
+ end,
+}
+
+DF.TimeLineFunctions = {
+
+ GetLine = function (self, index)
+ local line = self.lines [index]
+ if (not line) then
+ --create a new line
+ line = CreateFrame ("frame", "$parentLine" .. index, self.body)
+ DF:Mixin (line, DF.TimeLineBlockFunctions)
+ self.lines [index] = line
+
+ --store the individual textures that shows the timeline information
+ line.blocks = {}
+ line.SetBlock = DF.TimeLineBlockFunctions.SetBlock
+ line.GetBlock = DF.TimeLineBlockFunctions.GetBlock
+
+ --set its parameters
+
+ if (self.options.show_elapsed_timeline) then
+ line:SetPoint ("topleft", self.body, "topleft", 1, -((index-1) * (self.options.line_height + 1)) - 2 - self.options.elapsed_timeline_height)
+ else
+ line:SetPoint ("topleft", self.body, "topleft", 1, -((index-1) * (self.options.line_height + 1)) - 1)
+ end
+ line:SetSize (1, self.options.line_height) --width is set when updating the frame
+
+ line:SetScript ("OnEnter", self.options.on_enter)
+ line:SetScript ("OnLeave", self.options.on_leave)
+
+ line:SetBackdrop (self.options.backdrop)
+ line:SetBackdropColor (unpack (self.options.backdrop_color))
+ line:SetBackdropBorderColor (unpack (self.options.backdrop_border_color))
+
+ local icon = DF:CreateImage (line, "", self.options.line_height, self.options.line_height)
+ icon:SetPoint ("left", line, "left", 2, 0)
+ line.icon = icon
+
+ local text = DF:CreateLabel (line, "", DF:GetTemplate ("font", self.options.title_template))
+ text:SetPoint ("left", icon.widget, "right", 2, 0)
+ line.text = text
+
+ line.backdrop_color = self.options.backdrop_color or {.1, .1, .1, .3}
+ line.backdrop_color_highlight = self.options.backdrop_color_highlight or {.3, .3, .3, .5}
+ end
+
+ return line
+ end,
+
+ ResetAllLines = function (self)
+ for i = 1, #self.lines do
+ self.lines [i]:Reset()
+ end
+ end,
+
+ AdjustScale = function (self, index)
+
+ end,
+
+ --~todo ~doing
+ --+ just finished the blocks alignment and scale, looks to be working okay
+ --+ at the moment the with and height doesn't look correct, the height is way to much and the width looks too short
+ --+ make the blocks start AFTER the title, currently it is in from of them
+ --+ need to create the time line with font string to show the time elapsed
+ --+ make them to scale with a scale bar
+
+ --make the on enter and leave tooltips
+ --set icons and texts
+ --skin the sliders
+
+ RefreshTimeLine = function (self)
+
+ --debug
+ --self.currentScale = 1
+
+ --calculate the total width
+ local pixelPerSecond = self.options.pixels_per_second
+ local totalLength = self.data.length
+ local currentScale = self.currentScale
+
+ --how many pixels represent 1 second
+ local bodyWidth = totalLength * pixelPerSecond * currentScale
+ self.body:SetWidth (bodyWidth + self.options.header_width)
+ self.body.effectiveWidth = bodyWidth
+
+ --reduce the default canvas size from the body with and don't allow the max value be negative
+ local newMaxValue = max (bodyWidth - (self:GetWidth() - self.options.header_width), 0)
+
+ --adjust the scale slider range
+ local oldMin, oldMax = self.horizontalSlider:GetMinMaxValues()
+ self.horizontalSlider:SetMinMaxValues (0, newMaxValue)
+ self.horizontalSlider:SetValue (DF:MapRangeClamped (oldMin, oldMax, 0, newMaxValue, self.horizontalSlider:GetValue()))
+
+ local defaultColor = self.data.defaultColor or {1, 1, 1, 1}
+
+ --cache values
+ self.pixelPerSecond = pixelPerSecond
+ self.totalLength = totalLength
+ self.defaultColor = defaultColor
+ self.headerWidth = self.options.header_width
+
+ --calculate the total height
+ local lineHeight = self.options.line_height
+ local linePadding = self.options.line_padding
+
+ local bodyHeight = (lineHeight + linePadding) * #self.data.lines
+ self.body:SetHeight (bodyHeight)
+ self.verticalSlider:SetMinMaxValues (0, max (bodyHeight - self:GetHeight(), 0))
+ self.verticalSlider:SetValue (0)
+
+ --refresh lines
+ self:ResetAllLines()
+ for i = 1, #self.data.lines do
+ local line = self:GetLine (i)
+ line.dataIndex = i --this index is used inside the line update function to know which data to get
+ line:SetBlocksFromData() --the function to update runs within the line object
+ end
+
+ --refresh elapsed time frame
+ --the elapsed frame must have a width before the refresh function is called
+ self.elapsedTimeFrame:ClearAllPoints()
+ self.elapsedTimeFrame:SetPoint ("topleft", self.body, "topleft", self.options.header_width, 0)
+ self.elapsedTimeFrame:SetPoint ("topright", self.body, "topright", 0, 0)
+ self.elapsedTimeFrame:Reset()
+
+ self.elapsedTimeFrame:Refresh (self.data.length, self.currentScale)
+ end,
+
+ SetData = function (self, data)
+ self.data = data
+ self:RefreshTimeLine()
+ end,
+
+
+ --[=[
+ receives a table with
+ --should be tables of indexes? to save memory on not using hash names
+
+ header = {icon = "", name = ""}, --player name and player icon / need support for more things like boss casts / can be spell name and the icon of the spell / must be as generic as possible
+ data = {time = when it happened, duration = size of the bar, spellID for tooltip, tooltip = {what to add to Cooltip} } --numeric table with data of spells used
+
+ will it scroll vertically too in case there's more data to show?
+ i think it can without any problem since the scroll bar does scroll on both directions
+
+ parts it'll need
+ - a time line
+ - a scructure of lines (rows)
+ - two sliders for vertical and horizontal
+
+ how the zoom scaling will work?
+ a slider in the bottom side of the main slider
+ it starts in 0.5?
+
+ how it will zoom?
+ - change the scale? problem is the height will also be modified, so NO
+
+ - change the width of each bar
+ - change the timeline time
+ - change the max value of the main slider
+
+
+ --]=]
+
+
+}
+
+--creates a regular scroll in horizontal position
+function DF:CreateTimeLineFrame (parent, name, options)
+
+ local width = options and options.width or timeline_options.width
+ local height = options and options.height or timeline_options.height
+ local scrollWidth = 800 --placeholder until the timeline receives data
+ local scrollHeight = 800 --placeholder until the timeline receives data
+
+ local frameCanvas = CreateFrame ("scrollframe", name, parent)
+ DF:Mixin (frameCanvas, DF.TimeLineFunctions)
+
+ frameCanvas.data = {}
+ frameCanvas.lines = {}
+ frameCanvas.currentScale = 1
+ frameCanvas:SetSize (width, height)
+ frameCanvas:SetBackdrop({
+ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+ tile = true, tileSize = 16,
+ insets = {left = 1, right = 1, top = 0, bottom = 1},})
+ frameCanvas:SetBackdropColor (.1, .1, .1, .3)
+
+ local frameBody = CreateFrame ("frame", nil, frameCanvas)
+ frameBody:SetSize (scrollWidth, scrollHeight)
+
+ frameCanvas:SetScrollChild (frameBody)
+ frameCanvas.body = frameBody
+
+ DF:Mixin (frameCanvas, DF.OptionsFunctions)
+ DF:Mixin (frameCanvas, DF.LayoutFrame)
+
+ frameCanvas:BuildOptionsTable (timeline_options, options)
+
+ --create elapsed time frame
+ frameCanvas.elapsedTimeFrame = DF:CreateElapsedTimeFrame (frameBody)
+
+ --create horizontal slider
+ local horizontalSlider = CreateFrame ("slider", nil, parent)
+ horizontalSlider.bg = horizontalSlider:CreateTexture (nil, "background")
+ horizontalSlider.bg:SetAllPoints (true)
+ horizontalSlider.bg:SetTexture (0, 0, 0, 0.5)
+
+ horizontalSlider.thumb = horizontalSlider:CreateTexture (nil, "OVERLAY")
+ horizontalSlider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ horizontalSlider.thumb:SetSize (25, 25)
+
+ horizontalSlider:SetThumbTexture (horizontalSlider.thumb)
+ horizontalSlider:SetOrientation ("horizontal")
+ horizontalSlider:SetSize (width, 20)
+ horizontalSlider:SetPoint ("topleft", frameCanvas, "bottomleft")
+ horizontalSlider:SetMinMaxValues (0, scrollWidth)
+ horizontalSlider:SetValue (0)
+ horizontalSlider:SetScript ("OnValueChanged", function (self)
+ frameCanvas:SetHorizontalScroll (self:GetValue())
+ end)
+
+ --[=[
+ frameCanvas:EnableMouseWheel (true)
+ frameCanvas:SetScript ("OnMouseWheel", function (self, delta)
+ delta = delta * -1
+
+ local current = horizontalSlider:GetValue()
+
+ if (IsShiftKeyDown() and (delta > 0)) then
+ horizontalSlider:SetValue(0)
+
+ elseif (IsShiftKeyDown() and (delta < 0)) then
+ horizontalSlider:SetValue (scrollWidth)
+
+ elseif ((delta < 0) and (current < scrollWidth)) then
+ horizontalSlider:SetValue (current + 20)
+
+ elseif ((delta > 0) and (current > 1)) then
+ horizontalSlider:SetValue (current - 20)
+
+ end
+ end)
+ --]=]
+
+ frameCanvas.horizontalSlider = horizontalSlider
+
+ --create scale slider
+ local scaleSlider = CreateFrame ("slider", nil, parent)
+ scaleSlider.bg = scaleSlider:CreateTexture (nil, "background")
+ scaleSlider.bg:SetAllPoints (true)
+ scaleSlider.bg:SetTexture (0, 0, 0, 0.5)
+
+ scaleSlider.thumb = scaleSlider:CreateTexture (nil, "OVERLAY")
+ scaleSlider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ scaleSlider.thumb:SetSize (25, 25)
+
+ scaleSlider:SetThumbTexture (scaleSlider.thumb)
+ scaleSlider:SetOrientation ("horizontal")
+ scaleSlider:SetSize (width, 20)
+ scaleSlider:SetPoint ("topleft", horizontalSlider, "bottomleft", 0, -2)
+ scaleSlider:SetMinMaxValues (0.1, 1)
+ scaleSlider:SetValue (1)
+ scaleSlider:SetScript ("OnValueChanged", function (self)
+ local current = scaleSlider:GetValue()
+ frameCanvas.currentScale = current
+ frameCanvas:RefreshTimeLine()
+ end)
+
+ --create vertical slider
+ local verticalSlider = CreateFrame ("slider", nil, parent)
+ verticalSlider.bg = verticalSlider:CreateTexture (nil, "background")
+ verticalSlider.bg:SetAllPoints (true)
+ verticalSlider.bg:SetTexture (0, 0, 0, 0.5)
+
+ verticalSlider.thumb = verticalSlider:CreateTexture (nil, "OVERLAY")
+ verticalSlider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ verticalSlider.thumb:SetSize (25, 25)
+
+ verticalSlider:SetThumbTexture (verticalSlider.thumb)
+ verticalSlider:SetOrientation ("vertical")
+ verticalSlider:SetSize (20, height)
+ verticalSlider:SetPoint ("topleft", frameCanvas, "topright", 2, 0)
+ verticalSlider:SetMinMaxValues (0, scrollHeight)
+ verticalSlider:SetValue (0)
+ verticalSlider:SetScript ("OnValueChanged", function (self)
+ frameCanvas:SetVerticalScroll (self:GetValue())
+ end)
+
+ frameCanvas:EnableMouseWheel (true)
+ frameCanvas:SetScript ("OnMouseWheel", function (self, delta)
+ delta = delta
+
+ local current = verticalSlider:GetValue()
+
+ if (IsShiftKeyDown() and (delta > 0)) then
+ verticalSlider:SetValue(0)
+
+ elseif (IsShiftKeyDown() and (delta < 0)) then
+ verticalSlider:SetValue (scrollWidth)
+
+ elseif ((delta < 0) and (current < scrollWidth)) then
+ verticalSlider:SetValue (current + 20)
+
+ elseif ((delta > 0) and (current > 1)) then
+ verticalSlider:SetValue (current - 20)
+
+ end
+ end)
+
+ frameCanvas.verticalSlider = verticalSlider
+
+ return frameCanvas
+end
+
+
+--[=[
+local f = CreateFrame ("frame", "TestFrame", UIParent)
+f:SetPoint ("center")
+f:SetSize (900, 420)
+f:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = 1, right = 1, top = 0, bottom = 1}})
+
+local scroll = DF:CreateTimeLineFrame (f, "$parentTimeLine", {width = 880, height = 400})
+scroll:SetPoint ("topleft", f, "topleft", 0, 0)
+
+--need fake data to test fills
+scroll:SetData ({
+ length = 360,
+ defaultColor = {1, 1, 1, 1},
+ lines = {
+ {text = "player 1", icon = "", timeline = {
+ --each table here is a block shown in the line
+ --is an indexed table with: [1] time [2] length [3] color (if false, use the default) [4] text [5] icon [6] tooltip: if number = spellID tooltip, if table is text lines
+ {1, 10}, {13, 11}, {25, 7}, {36, 5}, {55, 18}, {76, 30}, {105, 20}, {130, 11}, {155, 11}, {169, 7}, {199, 16}, {220, 18}, {260, 10}, {290, 23}, {310, 30}, {350, 10}
+ }
+ }, --end of line 1
+ },
+})
+
+
+f:Hide()
+
+--scroll.body:SetScale (0.5)
+
+--]=]
+
+--functionn falsee truee breakk elsea endz
\ No newline at end of file
diff --git a/libs/DF/panel.xml b/libs/DF/panel.xml
new file mode 100644
index 0000000..b9b2336
--- /dev/null
+++ b/libs/DF/panel.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/libs/DF/picture.lua b/libs/DF/picture.lua
new file mode 100644
index 0000000..0aa1210
--- /dev/null
+++ b/libs/DF/picture.lua
@@ -0,0 +1,296 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APIImageFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "image",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["image"]] = _G [DF.GlobalWidgetControlNames ["image"]] or metaPrototype
+end
+
+local ImageMetaFunctions = _G [DF.GlobalWidgetControlNames ["image"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ ImageMetaFunctions.__call = function (_table, value)
+ return self.image:SetTexture (value)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.image:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.image:GetHeight()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object.image:GetTexture()
+ end
+ --> alpha
+ local gmember_alpha = function (_object)
+ return _object.image:GetAlpha()
+ end
+
+ ImageMetaFunctions.GetMembers = ImageMetaFunctions.GetMembers or {}
+ ImageMetaFunctions.GetMembers ["shown"] = gmember_shown
+ ImageMetaFunctions.GetMembers ["alpha"] = gmember_alpha
+ ImageMetaFunctions.GetMembers ["width"] = gmember_width
+ ImageMetaFunctions.GetMembers ["height"] = gmember_height
+ ImageMetaFunctions.GetMembers ["texture"] = gmember_texture
+
+ ImageMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = ImageMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return ImageMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r, g, b, a or 1)
+ else
+ if (DF:IsHtmlColor (_value)) then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r, g, b, a or 1)
+ else
+ _object.image:SetTexture (_value)
+ end
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.image:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.image:SetHeight (_value)
+ end
+ --> alpha
+ local smember_alpha = function (_object, _value)
+ return _object.image:SetAlpha (_value)
+ end
+ --> color
+ local smember_color = function (_object, _value)
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetColorTexture (r, g, b, a or 1)
+ end
+ --> vertex color
+ local smember_vertexcolor = function (_object, _value)
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetVertexColor (r, g, b, a or 1)
+ end
+ --> desaturated
+ local smember_desaturated = function (_object, _value)
+ if (_value) then
+ _object:SetDesaturated (true)
+ else
+ _object:SetDesaturated (false)
+ end
+ end
+ --> texcoords
+ local smember_texcoord = function (_object, _value)
+ if (_value) then
+ _object:SetTexCoord (unpack (_value))
+ else
+ _object:SetTexCoord (0, 1, 0, 1)
+ end
+ end
+
+ ImageMetaFunctions.SetMembers = ImageMetaFunctions.SetMembers or {}
+ ImageMetaFunctions.SetMembers ["show"] = smember_show
+ ImageMetaFunctions.SetMembers ["hide"] = smember_hide
+ ImageMetaFunctions.SetMembers ["alpha"] = smember_alpha
+ ImageMetaFunctions.SetMembers ["width"] = smember_width
+ ImageMetaFunctions.SetMembers ["height"] = smember_height
+ ImageMetaFunctions.SetMembers ["texture"] = smember_texture
+ ImageMetaFunctions.SetMembers ["texcoord"] = smember_texcoord
+ ImageMetaFunctions.SetMembers ["color"] = smember_color
+ ImageMetaFunctions.SetMembers ["vertexcolor"] = smember_vertexcolor
+ ImageMetaFunctions.SetMembers ["blackwhite"] = smember_desaturated
+
+ ImageMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = ImageMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+--> show & hide
+ function ImageMetaFunctions:IsShown()
+ return self.image:IsShown()
+ end
+ function ImageMetaFunctions:Show()
+ return self.image:Show()
+ end
+ function ImageMetaFunctions:Hide()
+ return self.image:Hide()
+ end
+
+-- setpoint
+ function ImageMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function ImageMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.image:SetWidth (w)
+ end
+ if (h) then
+ return self.image:SetHeight (h)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateImage (parent, texture, w, h, layer, coords, member, name)
+ return DF:NewImage (parent, texture, w, h, layer, coords, member, name)
+end
+
+function DF:NewImage (parent, texture, w, h, layer, coords, member, name)
+
+ if (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+
+ if (not name) then
+ name = "DetailsFrameworkPictureNumber" .. DF.PictureNameCounter
+ DF.PictureNameCounter = DF.PictureNameCounter + 1
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local ImageObject = {type = "image", dframework = true}
+
+ if (member) then
+ parent [member] = ImageObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+
+ texture = texture or ""
+
+ ImageObject.image = parent:CreateTexture (name, layer or "OVERLAY")
+ ImageObject.widget = ImageObject.image
+ DF:Mixin (ImageObject.image, DF.WidgetFunctions)
+
+ if (not APIImageFunctions) then
+ APIImageFunctions = true
+ local idx = getmetatable (ImageObject.image).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not ImageMetaFunctions [funcName]) then
+ ImageMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.image:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ ImageObject.image.MyObject = ImageObject
+
+ if (w) then
+ ImageObject.image:SetWidth (w)
+ end
+ if (h) then
+ ImageObject.image:SetHeight (h)
+ end
+ if (texture) then
+ if (type (texture) == "table") then
+ local r, g, b = DF:ParseColors (texture)
+ ImageObject.image:SetTexture (r,g,b)
+ else
+ if (DF:IsHtmlColor (texture)) then
+ local r, g, b = DF:ParseColors (texture)
+ ImageObject.image:SetTexture (r, g, b)
+ else
+ ImageObject.image:SetTexture (texture)
+ end
+ end
+ end
+
+ if (coords and type (coords) == "table" and coords [4]) then
+ ImageObject.image:SetTexCoord (unpack (coords))
+ end
+
+ ImageObject.HookList = {
+ }
+
+ setmetatable (ImageObject, ImageMetaFunctions)
+
+ return ImageObject
+end
diff --git a/libs/DF/pictureedit.lua b/libs/DF/pictureedit.lua
new file mode 100644
index 0000000..44ea289
--- /dev/null
+++ b/libs/DF/pictureedit.lua
@@ -0,0 +1,601 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+
+ local window = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEdit", nil, 100, 100, false)
+ window:SetPoint ("center", UIParent, "center")
+ window:SetResizable (true)
+ window:SetMovable (true)
+ tinsert (UISpecialFrames, "DetailsFrameworkImageEdit")
+ window:SetFrameStrata ("TOOLTIP")
+ window:SetMaxResize (650, 500)
+
+ window.hooks = {}
+
+ local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground")
+ background:SetAllPoints()
+ background:SetTexture (0, 0, 0, .8)
+
+ local edit_texture = DF:NewImage (window, nil, 650, 500, "artwork", nil, nil, "$parentImage")
+ edit_texture:SetAllPoints()
+
+ local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit)
+ background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12)
+ background_frame:SetFrameStrata ("DIALOG")
+ background_frame:SetSize (800, 540)
+
+ background_frame:SetResizable (true)
+ background_frame:SetMovable (true)
+
+ background_frame:SetScript ("OnMouseDown", function()
+ window:StartMoving()
+ end)
+ background_frame:SetScript ("OnMouseUp", function()
+ window:StopMovingOrSizing()
+ end)
+
+ background_frame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
+ background_frame:SetBackdropColor (0, 0, 0, 0.9)
+ background_frame:SetBackdropBorderColor (0, 0, 0, 1)
+
+ local haveHFlip = false
+ local haveVFlip = false
+
+--> Top Slider
+
+ local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
+ topCoordTexture:SetPoint ("topleft", window, "topleft")
+ topCoordTexture:SetPoint ("topright", window, "topright")
+ topCoordTexture:SetColorTexture (1, 0, 0)
+ topCoordTexture.height = 1
+ topCoordTexture.alpha = .2
+
+ local topSlider = DF:NewSlider (window, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
+ topSlider:SetAllPoints (window.widget)
+ topSlider:SetOrientation ("VERTICAL")
+ topSlider.backdrop = nil
+ topSlider.fractional = true
+ topSlider:SetHook ("OnEnter", function() return true end)
+ topSlider:SetHook ("OnLeave", function() return true end)
+
+ local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay")
+ topSliderThumpTexture:SetColorTexture (1, 1, 1)
+ topSliderThumpTexture:SetWidth (512)
+ topSliderThumpTexture:SetHeight (1)
+ topSlider:SetThumbTexture (topSliderThumpTexture)
+
+ topSlider:SetHook ("OnValueChange", function (_, _, value)
+ topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value)
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+ topSlider:Hide()
+
+--> Bottom Slider
+
+ local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
+ bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
+ bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
+ bottomCoordTexture:SetColorTexture (1, 0, 0)
+ bottomCoordTexture.height = 1
+ bottomCoordTexture.alpha = .2
+
+ local bottomSlider= DF:NewSlider (window, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
+ bottomSlider:SetAllPoints (window.widget)
+ bottomSlider:SetOrientation ("VERTICAL")
+ bottomSlider.backdrop = nil
+ bottomSlider.fractional = true
+ bottomSlider:SetHook ("OnEnter", function() return true end)
+ bottomSlider:SetHook ("OnLeave", function() return true end)
+
+ local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay")
+ bottomSliderThumpTexture:SetColorTexture (1, 1, 1)
+ bottomSliderThumpTexture:SetWidth (512)
+ bottomSliderThumpTexture:SetHeight (1)
+ bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
+
+ bottomSlider:SetHook ("OnValueChange", function (_, _, value)
+ value = math.abs (value-100)
+ bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1))
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+ bottomSlider:Hide()
+
+--> Left Slider
+
+ local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
+ leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0)
+ leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
+ leftCoordTexture:SetColorTexture (1, 0, 0)
+ leftCoordTexture.width = 1
+ leftCoordTexture.alpha = .2
+
+ local leftSlider = DF:NewSlider (window, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1)
+ leftSlider:SetAllPoints (window.widget)
+ leftSlider.backdrop = nil
+ leftSlider.fractional = true
+ leftSlider:SetHook ("OnEnter", function() return true end)
+ leftSlider:SetHook ("OnLeave", function() return true end)
+
+ local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay")
+ leftSliderThumpTexture:SetColorTexture (1, 1, 1)
+ leftSliderThumpTexture:SetWidth (1)
+ leftSliderThumpTexture:SetHeight (512)
+ leftSlider:SetThumbTexture (leftSliderThumpTexture)
+
+ leftSlider:SetHook ("OnValueChange", function (_, _, value)
+ leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value)
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+ leftSlider:Hide()
+
+--> Right Slider
+
+ local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
+ rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0)
+ rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
+ rightCoordTexture:SetColorTexture (1, 0, 0)
+ rightCoordTexture.width = 1
+ rightCoordTexture.alpha = .2
+
+ local rightSlider = DF:NewSlider (window, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100)
+ rightSlider:SetAllPoints (window.widget)
+ rightSlider.backdrop = nil
+ rightSlider.fractional = true
+ rightSlider:SetHook ("OnEnter", function() return true end)
+ rightSlider:SetHook ("OnLeave", function() return true end)
+ --[
+ local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay")
+ rightSliderThumpTexture:SetColorTexture (1, 1, 1)
+ rightSliderThumpTexture:SetWidth (1)
+ rightSliderThumpTexture:SetHeight (512)
+ rightSlider:SetThumbTexture (rightSliderThumpTexture)
+ --]]
+ rightSlider:SetHook ("OnValueChange", function (_, _, value)
+ value = math.abs (value-100)
+ rightCoordTexture.image:SetWidth (math.max (window.frame:GetWidth()/100*value, 1))
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+ rightSlider:Hide()
+
+--> Edit Buttons
+
+ local buttonsBackground = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEditButtonsBg", nil, 115, 230)
+ --buttonsBackground:SetPoint ("topleft", window, "topright", 2, 0)
+ buttonsBackground:SetPoint ("topright", background_frame, "topright", -8, -10)
+ buttonsBackground:Hide()
+ --buttonsBackground:SetMovable (true)
+ tinsert (UISpecialFrames, "DetailsFrameworkImageEditButtonsBg")
+ buttonsBackground:SetFrameStrata ("TOOLTIP")
+
+ local alphaFrameShown = false
+
+ local editingSide = nil
+ local lastButton = nil
+ local alphaFrame
+ local originalColor = {0.9999, 0.8196, 0}
+
+ local enableTexEdit = function (button, b, side)
+
+ if (alphaFrameShown) then
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ button.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (ColorPickerFrame:IsShown()) then
+ ColorPickerFrame:Hide()
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (editingSide == side) then
+ window [editingSide.."Slider"]:Hide()
+ editingSide = nil
+ return
+
+ elseif (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+
+ editingSide = side
+ button.text:SetTextColor (1, 1, 1)
+ lastButton = button
+
+ window [side.."Slider"]:Show()
+ end
+
+ local leftTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentLeftTexButton", nil, 100, 20, enableTexEdit, "left", nil, nil, "Crop Left", 1)
+ leftTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -10)
+ local rightTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentRightTexButton", nil, 100, 20, enableTexEdit, "right", nil, nil, "Crop Right", 1)
+ rightTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -30)
+ local topTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentTopTexButton", nil, 100, 20, enableTexEdit, "top", nil, nil, "Crop Top", 1)
+ topTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -50)
+ local bottomTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentBottomTexButton", nil, 100, 20, enableTexEdit, "bottom", nil, nil, "Crop Bottom", 1)
+ bottomTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -70)
+ leftTexCoordButton:InstallCustomTexture()
+ rightTexCoordButton:InstallCustomTexture()
+ topTexCoordButton:InstallCustomTexture()
+ bottomTexCoordButton:InstallCustomTexture()
+
+ local Alpha = DF:NewButton (buttonsBackground, nil, "$parentBottomAlphaButton", nil, 100, 20, alpha, nil, nil, nil, "Alpha", 1)
+ Alpha:SetPoint ("topright", buttonsBackground, "topright", -8, -115)
+ Alpha:InstallCustomTexture()
+
+ --> overlay color
+ local selectedColor = function (default)
+ if (default) then
+ edit_texture:SetVertexColor (unpack (default))
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ else
+ edit_texture:SetVertexColor (ColorPickerFrame:GetColorRGB())
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end
+ end
+
+ local changeColor = function()
+
+ ColorPickerFrame.func = nil
+ ColorPickerFrame.opacityFunc = nil
+ ColorPickerFrame.cancelFunc = nil
+ ColorPickerFrame.previousValues = nil
+
+ local r, g, b = edit_texture:GetVertexColor()
+ ColorPickerFrame:SetColorRGB (r, g, b)
+ ColorPickerFrame:SetParent (buttonsBackground.widget)
+ ColorPickerFrame.hasOpacity = false
+ ColorPickerFrame.previousValues = {r, g, b}
+ ColorPickerFrame.func = selectedColor
+ ColorPickerFrame.cancelFunc = selectedColor
+ ColorPickerFrame:ClearAllPoints()
+ ColorPickerFrame:SetPoint ("left", buttonsBackground.widget, "right")
+ ColorPickerFrame:Show()
+
+ if (alphaFrameShown) then
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ Alpha.button.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ if (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+ end
+ end
+
+ local changeColorButton = DF:NewButton (buttonsBackground, nil, "$parentOverlayColorButton", nil, 100, 20, changeColor, nil, nil, nil, "Color", 1)
+ changeColorButton:SetPoint ("topright", buttonsBackground, "topright", -8, -95)
+ changeColorButton:InstallCustomTexture()
+
+ alphaFrame = DF:NewPanel (buttonsBackground, nil, "DetailsFrameworkImageEditAlphaBg", nil, 40, 225)
+ alphaFrame:SetPoint ("topleft", buttonsBackground, "topright", 2, 0)
+ alphaFrame:Hide()
+ local alphaSlider = DF:NewSlider (alphaFrame, nil, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
+ alphaSlider:SetPoint ("top", alphaFrame, "top", 0, -5)
+ alphaSlider:SetOrientation ("VERTICAL")
+ alphaSlider.thumb:SetSize (40, 30)
+ --leftSlider.backdrop = nil
+ --leftSlider.fractional = true
+
+ local alpha = function (button)
+
+ if (ColorPickerFrame:IsShown()) then
+ ColorPickerFrame:Hide()
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ if (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+ end
+
+ if (not alphaFrameShown) then
+ alphaFrame:Show()
+ alphaSlider:SetValue (edit_texture:GetAlpha()*100)
+ alphaFrameShown = true
+ button.text:SetTextColor (1, 1, 1)
+ else
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ button.text:SetTextColor (unpack (originalColor))
+ end
+ end
+
+ Alpha.clickfunction = alpha
+
+ alphaSlider:SetHook ("OnValueChange", function (_, _, value)
+ edit_texture:SetAlpha (value/100)
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+ local resizer = CreateFrame ("Button", nil, window.widget)
+ resizer:SetNormalTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
+ resizer:SetHighlightTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
+ resizer:GetNormalTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
+ resizer:GetHighlightTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
+ resizer:SetWidth (16)
+ resizer:SetHeight (16)
+ resizer:SetPoint ("BOTTOMRIGHT", window.widget, "BOTTOMRIGHT", 0, 0)
+ resizer:EnableMouse (true)
+ resizer:SetFrameLevel (window.widget:GetFrameLevel() + 2)
+
+ resizer:SetScript ("OnMouseDown", function (self, button)
+ window.widget:StartSizing ("BOTTOMRIGHT")
+ end)
+
+ resizer:SetScript ("OnMouseUp", function (self, button)
+ window.widget:StopMovingOrSizing()
+ end)
+
+ window.widget:SetScript ("OnMouseDown", function()
+ window.widget:StartMoving()
+ end)
+ window.widget:SetScript ("OnMouseUp", function()
+ window.widget:StopMovingOrSizing()
+ end)
+
+ window.widget:SetScript ("OnSizeChanged", function()
+ edit_texture.width = window.width
+ edit_texture.height = window.height
+ leftSliderThumpTexture:SetHeight (window.height)
+ rightSliderThumpTexture:SetHeight (window.height)
+ topSliderThumpTexture:SetWidth (window.width)
+ bottomSliderThumpTexture:SetWidth (window.width)
+
+ rightCoordTexture.image:SetWidth (math.max ( (window.frame:GetWidth() / 100 * math.abs (rightSlider:GetValue()-100)), 1))
+ leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*leftSlider:GetValue())
+ bottomCoordTexture:SetHeight (math.max ( (window.frame:GetHeight() / 100 * math.abs (bottomSlider:GetValue()-100)), 1))
+ topCoordTexture:SetHeight (window.frame:GetHeight()/100*topSlider:GetValue())
+
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end)
+
+
+
+ --> flip
+ local flip = function (button, b, side)
+ if (side == 1) then
+ haveHFlip = not haveHFlip
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ elseif (side == 2) then
+ haveVFlip = not haveVFlip
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+ end
+ end
+
+ local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1)
+ flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140)
+ flipButtonH:InstallCustomTexture()
+ --
+
+
+ --> select area to crop
+ local DragFrame = CreateFrame ("frame", nil, background_frame)
+ DragFrame:EnableMouse (false)
+ DragFrame:SetFrameStrata ("TOOLTIP")
+ DragFrame:SetPoint ("topleft", edit_texture.widget, "topleft")
+ DragFrame:SetPoint ("bottomright", edit_texture.widget, "bottomright")
+ DragFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Worldmap\UI-QuestBlob-Inside]], tileSize = 256, tile = true})
+ DragFrame:SetBackdropColor (1, 1, 1, .2)
+ DragFrame:Hide()
+
+ local SelectionBox_Up = DragFrame:CreateTexture (nil, "overlay")
+ SelectionBox_Up:SetHeight (1)
+ SelectionBox_Up:SetColorTexture (1, 1, 1)
+ local SelectionBox_Down = DragFrame:CreateTexture (nil, "overlay")
+ SelectionBox_Down:SetHeight (1)
+ SelectionBox_Down:SetColorTexture (1, 1, 1)
+ local SelectionBox_Left = DragFrame:CreateTexture (nil, "overlay")
+ SelectionBox_Left:SetWidth (1)
+ SelectionBox_Left:SetColorTexture (1, 1, 1)
+ local SelectionBox_Right = DragFrame:CreateTexture (nil, "overlay")
+ SelectionBox_Right:SetWidth (1)
+ SelectionBox_Right:SetColorTexture (1, 1, 1)
+
+ function DragFrame.ClearSelectionBoxPoints()
+ SelectionBox_Up:ClearAllPoints()
+ SelectionBox_Down:ClearAllPoints()
+ SelectionBox_Left:ClearAllPoints()
+ SelectionBox_Right:ClearAllPoints()
+ end
+
+ local StartCrop = function()
+ DragFrame:Show()
+ DragFrame:EnableMouse (true)
+ end
+
+ local CropSelection = DF:NewButton (buttonsBackground, nil, "$parentCropSelection", nil, 100, 20, StartCrop, 2, nil, nil, "Crop Selection", 1)
+ --CropSelection:SetPoint ("topright", buttonsBackground, "topright", -8, -260)
+ CropSelection:InstallCustomTexture()
+
+ DragFrame.OnTick = function (self, deltaTime)
+ local x1, y1 = unpack (self.ClickedAt)
+ local x2, y2 = GetCursorPosition()
+ DragFrame.ClearSelectionBoxPoints()
+
+ print (x1, y1, x2, y2)
+
+ if (x2 > x1) then
+ --right
+ if (y1 > y2) then
+ --top
+ SelectionBox_Up:SetPoint ("topleft", UIParent, "bottomleft", x1, y1)
+ SelectionBox_Up:SetPoint ("topright", UIParent, "bottomleft", x2, y1)
+
+ SelectionBox_Left:SetPoint ("topleft", UIParent, "bottomleft", x1, y1)
+ SelectionBox_Left:SetPoint ("bottomleft", UIParent, "bottomleft", x1, y2)
+
+ print (1)
+ else
+ --bottom
+
+ end
+ else
+ --left
+ if (y2 > y1) then
+ --top
+
+ else
+ --bottom
+
+ end
+ end
+
+ end
+
+ DragFrame:SetScript ("OnMouseDown", function (self, MouseButton)
+ if (MouseButton == "LeftButton") then
+ self.ClickedAt = {GetCursorPosition()}
+ DragFrame:SetScript ("OnUpdate", DragFrame.OnTick)
+
+ end
+ end)
+ DragFrame:SetScript ("OnMouseUp", function (self, MouseButton)
+ if (MouseButton == "LeftButton") then
+ self.ReleaseAt = {GetCursorPosition()}
+ DragFrame:EnableMouse (false)
+ DragFrame:Hide()
+ DragFrame:SetScript ("OnUpdate", nil)
+ print (self.ClickedAt[1], self.ClickedAt[2], self.ReleaseAt[1], self.ReleaseAt[2])
+ end
+ end)
+
+ --> accept
+ window.accept = function (self, b, keep_editing)
+
+ if (not keep_editing) then
+ buttonsBackground:Hide()
+ window:Hide()
+ alphaFrame:Hide()
+ ColorPickerFrame:Hide()
+ end
+
+ local coords = {}
+ local l, r, t, b = leftSlider.value/100, rightSlider.value/100, topSlider.value/100, bottomSlider.value/100
+
+ if (haveHFlip) then
+ coords [1] = r
+ coords [2] = l
+ else
+ coords [1] = l
+ coords [2] = r
+ end
+
+ if (haveVFlip) then
+ coords [3] = b
+ coords [4] = t
+ else
+ coords [3] = t
+ coords [4] = b
+ end
+
+ return window.callback_func (edit_texture.width, edit_texture.height, {edit_texture:GetVertexColor()}, edit_texture:GetAlpha(), coords, window.extra_param)
+ end
+
+ local acceptButton = DF:NewButton (buttonsBackground, nil, "$parentAcceptButton", nil, 100, 20, window.accept, nil, nil, nil, "Done", 1)
+ acceptButton:SetPoint ("topright", buttonsBackground, "topright", -8, -200)
+ acceptButton:InstallCustomTexture()
+
+
+
+window:Hide()
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ local ttexcoord
+ function DF:ImageEditor (callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize)
+
+ texcoord = texcoord or {0, 1, 0, 1}
+ ttexcoord = texcoord
+
+ colors = colors or {1, 1, 1, 1}
+
+ alpha = alpha or 1
+
+ edit_texture:SetTexture (texture)
+ edit_texture.width = width
+ edit_texture.height = height
+ edit_texture.maximize = maximize
+
+ edit_texture:SetVertexColor (colors [1], colors [2], colors [3])
+
+ edit_texture:SetAlpha (alpha)
+
+ DF:ScheduleTimer ("RefreshImageEditor", 0.2)
+
+ window:Show()
+ window.callback_func = callback
+ window.extra_param = extraParam
+ buttonsBackground:Show()
+ buttonsBackground.widget:SetBackdrop (nil)
+
+ table.wipe (window.hooks)
+ end
+
+ function DF:RefreshImageEditor()
+
+ if (edit_texture.maximize) then
+ DetailsFrameworkImageEdit:SetSize (266, 226)
+ else
+ DetailsFrameworkImageEdit:SetSize (edit_texture.width, edit_texture.height)
+ end
+
+ local l, r, t, b = unpack (ttexcoord)
+
+ if (l > r) then
+ haveHFlip = true
+ leftSlider:SetValue (r * 100)
+ rightSlider:SetValue (l * 100)
+ else
+ haveHFlip = false
+ leftSlider:SetValue (l * 100)
+ rightSlider:SetValue (r * 100)
+ end
+
+ if (t > b) then
+ haveVFlip = true
+ topSlider:SetValue (b * 100)
+ bottomSlider:SetValue (t * 100)
+ else
+ haveVFlip = false
+ topSlider:SetValue (t * 100)
+ bottomSlider:SetValue (b * 100)
+ end
+
+ if (window.callback_func) then
+ window.accept (nil, nil, true)
+ end
+
+ end
+
diff --git a/libs/DF/scrollbar.lua b/libs/DF/scrollbar.lua
new file mode 100644
index 0000000..fae545c
--- /dev/null
+++ b/libs/DF/scrollbar.lua
@@ -0,0 +1,235 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+function DF:CreateScrollBar (master, slave, x, y)
+ return DF:NewScrollBar (master, slave, x, y)
+end
+
+function DF:NewScrollBar (master, slave, x, y)
+
+ local new_slider = CreateFrame ("Slider", nil, master)
+ new_slider.scrollMax = 560 --default - tamanho da janela de fundo
+
+ -- ///// SLIDER /////
+ new_slider:SetPoint ("TOPLEFT", master, "TOPRIGHT", x, y)
+ new_slider.ativo = true
+
+ new_slider.bg = new_slider:CreateTexture (nil, "BACKGROUND")
+ new_slider.bg:SetAllPoints (true)
+ new_slider.bg:SetTexture (0, 0, 0, 0)
+ --coisinha do meio
+ new_slider.thumb = new_slider:CreateTexture (nil, "OVERLAY")
+ new_slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ new_slider.thumb:SetSize (29, 30)
+ new_slider:SetThumbTexture (new_slider.thumb)
+
+ new_slider:SetOrientation ("VERTICAL")
+ new_slider:SetSize(16, 100)
+ new_slider:SetMinMaxValues(0, new_slider.scrollMax)
+ new_slider:SetValue(0)
+ new_slider.ultimo = 0
+
+ local botao_cima = CreateFrame ("Button", nil, master)
+
+ botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", 0, -12)
+ botao_cima.x = 0
+ botao_cima.y = -12
+
+ botao_cima:SetWidth (29)
+ botao_cima:SetHeight (32)
+ botao_cima:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up")
+ botao_cima:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down")
+ botao_cima:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled")
+ botao_cima:Show()
+ botao_cima:Disable()
+
+ local botao_baixo = CreateFrame ("Button", nil, master)
+ botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", 0, 12)
+ botao_baixo.x = 0
+ botao_baixo.y = 12
+
+ botao_baixo:SetWidth (29)
+ botao_baixo:SetHeight (32)
+ botao_baixo:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up")
+ botao_baixo:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down")
+ botao_baixo:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled")
+ botao_baixo:Show()
+ botao_baixo:Disable()
+
+ master.baixo = botao_baixo
+ master.cima = botao_cima
+ master.slider = new_slider
+
+ botao_baixo:SetScript ("OnMouseDown", function(self)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current+5 < maxValue) then
+ new_slider:SetValue (current+5)
+ else
+ new_slider:SetValue (maxValue)
+ end
+ self.precionado = true
+ self.last_up = -0.3
+ self:SetScript ("OnUpdate", function(self, elapsed)
+ self.last_up = self.last_up + elapsed
+ if (self.last_up > 0.03) then
+ self.last_up = 0
+ local current = new_slider:GetValue()
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current+2 < maxValue) then
+ new_slider:SetValue (current+2)
+ else
+ new_slider:SetValue (maxValue)
+ end
+ end
+ end)
+ end)
+ botao_baixo:SetScript ("OnMouseUp", function(self)
+ self.precionado = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ botao_cima:SetScript ("OnMouseDown", function(self)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ if (current-5 > 0) then
+ new_slider:SetValue (current-5)
+ else
+ new_slider:SetValue (0)
+ end
+ self.precionado = true
+ self.last_up = -0.3
+ self:SetScript ("OnUpdate", function(self, elapsed)
+ self.last_up = self.last_up + elapsed
+ if (self.last_up > 0.03) then
+ self.last_up = 0
+ local current = new_slider:GetValue()
+ if (current-2 > 0) then
+ new_slider:SetValue (current-2)
+ else
+ new_slider:SetValue (0)
+ end
+ end
+ end)
+ end)
+ botao_cima:SetScript ("OnMouseUp", function(self)
+ self.precionado = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+ --> isso aqui pra quando o slider ativar, o scroll fica na posi��o zero
+ botao_cima:SetScript ("OnEnable", function (self)
+ local current = new_slider:GetValue()
+ if (current == 0) then
+ botao_cima:Disable()
+ end
+ end)
+
+ new_slider:SetScript ("OnValueChanged", function (self)
+ local current = self:GetValue()
+ master:SetVerticalScroll (current)
+
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+
+ if (current == minValue) then
+ botao_cima:Disable()
+ elseif (not botao_cima:IsEnabled()) then
+ botao_cima:Enable()
+ end
+
+ if (current == maxValue) then
+ botao_baixo:Disable()
+ elseif (not botao_baixo:IsEnabled()) then
+ botao_baixo:Enable()
+ end
+
+ end)
+
+ new_slider:SetScript ("OnShow", function (self)
+ botao_cima:Show()
+ botao_baixo:Show()
+ end)
+
+ new_slider:SetScript ("OnDisable", function (self)
+ botao_cima:Disable()
+ botao_baixo:Disable()
+ end)
+
+ new_slider:SetScript ("OnEnable", function (self)
+ botao_cima:Enable()
+ botao_baixo:Enable()
+ end)
+
+ master:SetScript ("OnMouseWheel", function (self, delta)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ if (delta < 0) then
+ --baixo
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current + (master.wheel_jump or 20) < maxValue) then
+ new_slider:SetValue (current + (master.wheel_jump or 20))
+ else
+ new_slider:SetValue (maxValue)
+ end
+ elseif (delta > 0) then
+ --cima
+ if (current + (master.wheel_jump or 20) > 0) then
+ new_slider:SetValue (current - (master.wheel_jump or 20))
+ else
+ new_slider:SetValue (0)
+ end
+ end
+ end)
+
+ function new_slider:Altura (h)
+ self:SetHeight (h)
+ end
+
+ function new_slider:Update (desativar)
+
+ if (desativar) then
+ new_slider:Disable()
+ new_slider:SetValue(0)
+ new_slider.ativo = false
+ master:EnableMouseWheel (false)
+ return
+ end
+
+ self.scrollMax = slave:GetHeight()-master:GetHeight()
+ if (self.scrollMax > 0) then
+ new_slider:SetMinMaxValues (0, self.scrollMax)
+ if (not new_slider.ativo) then
+ new_slider:Enable()
+ new_slider.ativo = true
+ master:EnableMouseWheel (true)
+ end
+ else
+ new_slider:Disable()
+ new_slider:SetValue(0)
+ new_slider.ativo = false
+ master:EnableMouseWheel (false)
+ end
+ end
+
+ function new_slider:cimaPoint (x, y)
+ botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", x, (y)-12)
+ end
+
+ function new_slider:baixoPoint (x, y)
+ botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", x, (y)+12)
+ end
+
+ return new_slider
+end
diff --git a/libs/DF/slider.lua b/libs/DF/slider.lua
new file mode 100644
index 0000000..4ed8636
--- /dev/null
+++ b/libs/DF/slider.lua
@@ -0,0 +1,1235 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+
+local cleanfunction = function() end
+local APISliderFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "slider",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["slider"]] = _G [DF.GlobalWidgetControlNames ["slider"]] or metaPrototype
+end
+
+local DFSliderMetaFunctions = _G [DF.GlobalWidgetControlNames ["slider"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ DFSliderMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ if (_table.isSwitch) then
+
+ if (type (value) == "boolean") then --> false
+ return _table.slider:SetValue (1)
+ end
+
+ if (_table.slider:GetValue() == 1) then
+ return false
+ else
+ return true
+ end
+ end
+ return _table.slider:GetValue()
+ else
+ if (_table.isSwitch) then
+ if (type (value) == "boolean") then
+ if (value) then
+ _table.slider:SetValue (2)
+ else
+ _table.slider:SetValue (1)
+ end
+ else
+ _table.slider:SetValue (value)
+ end
+ return
+ end
+
+ return _table.slider:SetValue (value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.slider:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.slider:GetHeight()
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "lockdown")
+ end
+ --> fractional
+ local gmember_fractional = function (_object)
+ return _rawget (_object, "useDecimals")
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object()
+ end
+
+ DFSliderMetaFunctions.GetMembers = DFSliderMetaFunctions.GetMembers or {}
+ DFSliderMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ DFSliderMetaFunctions.GetMembers ["shown"] = gmember_shown
+ DFSliderMetaFunctions.GetMembers ["width"] = gmember_width
+ DFSliderMetaFunctions.GetMembers ["height"] = gmember_height
+ DFSliderMetaFunctions.GetMembers ["locked"] = gmember_locked
+ DFSliderMetaFunctions.GetMembers ["fractional"] = gmember_fractional
+ DFSliderMetaFunctions.GetMembers ["value"] = gmember_value
+
+ DFSliderMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = DFSliderMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return DFSliderMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.slider:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.slider:SetHeight (_value)
+ end
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ return self:Disable()
+ else
+ return self:Enable()
+ end
+ end
+ --> backdrop
+ local smember_backdrop = function (_object, _value)
+ return _object.slider:SetBackdrop (_value)
+ end
+ --> fractional
+ local smember_fractional = function (_object, _value)
+ return _rawset (_object, "useDecimals", _value)
+ end
+ --> value
+ local smember_value = function (_object, _value)
+ _object (_value)
+ end
+
+ DFSliderMetaFunctions.SetMembers = DFSliderMetaFunctions.SetMembers or {}
+ DFSliderMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
+ DFSliderMetaFunctions.SetMembers ["show"] = smember_show
+ DFSliderMetaFunctions.SetMembers ["hide"] = smember_hide
+ DFSliderMetaFunctions.SetMembers ["backdrop"] = smember_backdrop
+ DFSliderMetaFunctions.SetMembers ["width"] = smember_width
+ DFSliderMetaFunctions.SetMembers ["height"] = smember_height
+ DFSliderMetaFunctions.SetMembers ["locked"] = smember_locked
+ DFSliderMetaFunctions.SetMembers ["fractional"] = smember_fractional
+ DFSliderMetaFunctions.SetMembers ["value"] = smember_value
+
+ DFSliderMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = DFSliderMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function DFSliderMetaFunctions:IsShown()
+ return self.slider:IsShown()
+ end
+ function DFSliderMetaFunctions:Show()
+ return self.slider:Show()
+ end
+ function DFSliderMetaFunctions:Hide()
+ return self.slider:Hide()
+ end
+
+--> fixed value
+ function DFSliderMetaFunctions:SetFixedParameter (value)
+ _rawset (self, "FixedValue", value)
+ end
+
+--> set value
+ function DFSliderMetaFunctions:SetValue (value)
+ return self (value)
+ end
+
+-- thumb size
+ function DFSliderMetaFunctions:SetThumbSize (w, h)
+ if (not w) then
+ w = self.thumb:GetWidth()
+ end
+ if (not h) then
+ h = self.thumb:GetHeight()
+ end
+ return self.thumb:SetSize (w, h)
+ end
+
+
+-- setpoint
+ function DFSliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function DFSliderMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.slider:SetWidth (w)
+ end
+ if (h) then
+ return self.slider:SetHeight (h)
+ end
+ end
+
+-- tooltip
+ function DFSliderMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function DFSliderMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function DFSliderMetaFunctions:GetFrameLevel()
+ return self.slider:GetFrameLevel()
+ end
+ function DFSliderMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.slider:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.slider:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function DFSliderMetaFunctions:SetFrameStrata()
+ return self.slider:GetFrameStrata()
+ end
+ function DFSliderMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.slider:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.slider:SetFrameStrata (strata)
+ end
+ end
+
+-- enabled
+ function DFSliderMetaFunctions:IsEnabled()
+ return not _rawget (self, "lockdown")
+ end
+
+ function DFSliderMetaFunctions:Enable()
+ self.slider:Enable()
+ if (not self.is_checkbox) then
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self.amt, "center")
+ end
+ self.lock_texture:Hide()
+ end
+ self.slider.amt:Show()
+ self:SetAlpha (1)
+
+ if (self.is_checkbox) then
+ self.checked_texture:Show()
+ end
+ return _rawset (self, "lockdown", false)
+ end
+
+ function DFSliderMetaFunctions:Disable()
+
+ self.slider:Disable()
+ self.slider.amt:Hide()
+ self:SetAlpha (.4)
+
+ if (not self.is_checkbox) then
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self.amt, "center")
+ end
+ self.lock_texture:Show()
+ end
+
+ if (self.is_checkbox) then
+ self.checked_texture:Show()
+ end
+
+ --print ("result 2:", self.checked_texture:IsShown(), self.checked_texture:GetAlpha(), self.checked_texture:GetSize())
+
+ return _rawset (self, "lockdown", true)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (slider)
+ if (_rawget (slider.MyObject, "lockdown")) then
+ return
+ end
+
+ DetailsFrameworkSliderButtons1:ShowMe (slider)
+
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnEnter", slider, capsule)
+ if (kill) then
+ return
+ end
+
+ slider.thumb:SetAlpha (1)
+
+ if (slider.MyObject.onenter_backdrop_border_color) then
+ slider:SetBackdropBorderColor (unpack (slider.MyObject.onenter_backdrop_border_color))
+ end
+
+ if (slider.MyObject.have_tooltip and slider.MyObject.have_tooltip ~= "Right Click to Type the Value") then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine (slider.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (slider, "tooltip")
+ else
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine ("Right Click to Type the Value", "", 1, "", "", 10)
+ GameCooltip2:AddIcon ([[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]], 1, 1, 16, 16, 0.015625, 0.15671875, 0.640625, 0.798828125)
+ GameCooltip2:ShowCooltip (slider, "tooltip")
+ end
+ end
+
+ local OnLeave = function (slider)
+
+ if (_rawget (slider.MyObject, "lockdown")) then
+ return
+ end
+
+ DetailsFrameworkSliderButtons1:PrepareToHide()
+
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnLeave", slider, capsule)
+ if (kill) then
+ return
+ end
+
+ slider.thumb:SetAlpha (.7)
+
+ if (slider.MyObject.onleave_backdrop_border_color) then
+ slider:SetBackdropBorderColor (unpack (slider.MyObject.onleave_backdrop_border_color))
+ end
+
+ GameCooltip2:ShowMe (false)
+
+ end
+
+
+ local f = CreateFrame ("frame", "DetailsFrameworkSliderButtons1", UIParent)
+ f:Hide()
+ f:SetHeight (18)
+
+ local t = 0
+ f.is_going_hide = false
+ local going_hide = function (self, elapsed)
+ t = t + elapsed
+ if (t > 0.3) then
+ f:Hide()
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end
+
+ function f:ShowMe (host)
+ f:SetPoint ("bottomleft", host, "topleft", -3, -5)
+ f:SetPoint ("bottomright", host, "topright", 3, -5)
+ --f:SetFrameStrata (host:GetFrameStrata())
+ f:SetFrameStrata ("FULLSCREEN")
+ f:SetFrameLevel (host:GetFrameLevel() + 1000)
+ f:Show()
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+
+ f.host = host.MyObject
+ end
+
+ function f:PrepareToHide()
+ f.is_going_hide = true
+ t = 0
+ f:SetScript ("OnUpdate", going_hide)
+ end
+
+ local button_plus = CreateFrame ("button", "DetailsFrameworkSliderButtonsPlusButton", f)
+ local button_minor = CreateFrame ("button", "DetailsFrameworkSliderButtonsMinorButton", f)
+ button_plus:SetFrameStrata (f:GetFrameStrata())
+ button_minor:SetFrameStrata (f:GetFrameStrata())
+
+ button_plus:SetScript ("OnEnter", function (self)
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end)
+ button_minor:SetScript ("OnEnter", function (self)
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end)
+
+ button_plus:SetScript ("OnLeave", function (self)
+ f:PrepareToHide()
+ end)
+ button_minor:SetScript ("OnLeave", function (self)
+ f:PrepareToHide()
+ end)
+
+ button_plus:SetNormalTexture ([[Interface\Buttons\UI-PlusButton-Up]])
+ button_minor:SetNormalTexture ([[Interface\Buttons\UI-MinusButton-Up]])
+
+ button_plus:SetPushedTexture ([[Interface\Buttons\UI-PlusButton-Down]])
+ button_minor:SetPushedTexture ([[Interface\Buttons\UI-MinusButton-Down]])
+
+ button_plus:SetDisabledTexture ([[Interface\Buttons\UI-PlusButton-Disabled]])
+ button_minor:SetDisabledTexture ([[Interface\Buttons\UI-MinusButton-Disabled]])
+
+ button_plus:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
+ button_minor:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
+
+ --button_minor:SetPoint ("bottomleft", f, "bottomleft", -6, -13)
+ --button_plus:SetPoint ("bottomright", f, "bottomright", 6, -13)
+
+ button_minor:SetPoint ("bottomright", f, "bottomright", 13, -13)
+ button_plus:SetPoint ("left", button_minor, "right", -2, 0)
+
+ button_plus:SetSize (16, 16)
+ button_minor:SetSize (16, 16)
+
+ local timer = 0
+ local change_timer = 0
+
+ -- -- --
+
+ local plus_button_script = function()
+
+ local current = f.host.value
+ local editbox = DFSliderMetaFunctions.editbox_typevalue
+
+ if (f.host.fine_tuning) then
+ f.host:SetValue (current + f.host.fine_tuning)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current + f.host.fine_tuning)))
+ end
+ else
+ if (f.host.useDecimals) then
+ f.host:SetValue (current + 0.1)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current + 0.1))
+ end
+ else
+ f.host:SetValue (current + 1)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current + 1)))
+ end
+ end
+ end
+
+ end
+
+ button_plus:SetScript ("OnMouseUp", function (self)
+ if (not button_plus.got_click) then
+ plus_button_script()
+ end
+ button_plus.got_click = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ local on_update = function (self, elapsed)
+ timer = timer + elapsed
+ if (timer > 0.4) then
+ change_timer = change_timer + elapsed
+ if (change_timer > 0.1) then
+ change_timer = 0
+ plus_button_script()
+ button_plus.got_click = true
+ end
+ end
+ end
+ button_plus:SetScript ("OnMouseDown", function (self)
+ timer = 0
+ change_timer = 0
+ self:SetScript ("OnUpdate", on_update)
+ end)
+
+ -- -- --
+
+ local minor_button_script = function()
+ local current = f.host.value
+ local editbox = DFSliderMetaFunctions.editbox_typevalue
+
+ if (f.host.fine_tuning) then
+ f.host:SetValue (current - f.host.fine_tuning)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current - f.host.fine_tuning)))
+ end
+ else
+ if (f.host.useDecimals) then
+ f.host:SetValue (current - 0.1)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current - 0.1))
+ end
+ else
+ f.host:SetValue (current - 1)
+ if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current - 1)))
+ end
+ end
+ end
+ end
+
+ button_minor:SetScript ("OnMouseUp", function (self)
+ if (not button_minor.got_click) then
+ minor_button_script()
+ end
+ button_minor.got_click = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ local on_update = function (self, elapsed)
+ timer = timer + elapsed
+ if (timer > 0.4) then
+ change_timer = change_timer + elapsed
+ if (change_timer > 0.1) then
+ change_timer = 0
+ minor_button_script()
+ button_minor.got_click = true
+ end
+ end
+ end
+ button_minor:SetScript ("OnMouseDown", function (self)
+ timer = 0
+ change_timer = 0
+ self:SetScript ("OnUpdate", on_update)
+ end)
+
+ local do_precision = function (text)
+ if (type (text) == "string" and text:find ("%.")) then
+ local left, right = strsplit (".", text)
+ left = tonumber (left)
+ right = tonumber (right)
+
+ if (left and right) then
+ local newString = tostring (left) .. "." .. tostring (right)
+ local newNumber = tonumber (newString)
+
+ if (newNumber) then
+ return newNumber
+ end
+ end
+ end
+
+ return tonumber (text)
+ end
+
+ function DFSliderMetaFunctions:TypeValue()
+ if (not self.isSwitch) then
+
+ if (not DFSliderMetaFunctions.editbox_typevalue) then
+
+ local editbox = CreateFrame ("EditBox", "DetailsFrameworkSliderEditBox", UIParent)
+
+ editbox:SetSize (40, 20)
+ editbox:SetJustifyH ("center")
+ editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", --edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = true, edgeSize = 8, tileSize = 5})
+ editbox:SetFontObject ("GameFontHighlightSmall")
+
+ editbox:SetScript ("OnEnterPressed", function()
+ editbox:ClearFocus()
+ editbox:Hide()
+ editbox:GetParent().MyObject.typing_value = false
+ editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) --do_precision (editbox:GetText())
+ end)
+
+ editbox:SetScript ("OnEscapePressed", function()
+ editbox:ClearFocus()
+ editbox:Hide()
+ editbox:GetParent().MyObject.typing_value = false
+ editbox:GetParent().MyObject.value = self.typing_value_started --do_precision (self.typing_value_started)
+ end)
+
+ editbox:SetScript ("OnTextChanged", function()
+ editbox:GetParent().MyObject.typing_can_change = true
+ editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) --do_precision
+ editbox:GetParent().MyObject.typing_can_change = false
+ end)
+
+ DFSliderMetaFunctions.editbox_typevalue = editbox
+ end
+
+ local pvalue = self.previous_value [2]
+ self:SetValue (pvalue)
+
+ self.typing_value = true
+ self.typing_value_started = pvalue
+
+ DFSliderMetaFunctions.editbox_typevalue:SetSize (self.width, self.height)
+ DFSliderMetaFunctions.editbox_typevalue:SetPoint ("center", self.widget, "center")
+ DFSliderMetaFunctions.editbox_typevalue:SetFocus()
+ DFSliderMetaFunctions.editbox_typevalue:SetParent (self.widget)
+ DFSliderMetaFunctions.editbox_typevalue:SetFrameLevel (self.widget:GetFrameLevel()+1)
+
+ if (self.useDecimals) then
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.1f", self.value)))
+ else
+ DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (self.value)))
+ end
+
+ DFSliderMetaFunctions.editbox_typevalue:HighlightText()
+
+ DFSliderMetaFunctions.editbox_typevalue:Show()
+ end
+ end
+
+ local OnMouseDown = function (slider, button)
+ slider.MyObject.IsValueChanging = true
+
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseDown", slider, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (button == "RightButton") then
+ slider.MyObject:TypeValue()
+ end
+ end
+
+ local OnMouseUp = function (slider, button)
+ slider.MyObject.IsValueChanging = nil
+
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseUp", slider, button, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnHide = function (slider)
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", slider, capsule)
+ if (kill) then
+ return
+ end
+
+ if (slider.MyObject.typing_value) then
+ DFSliderMetaFunctions.editbox_typevalue:ClearFocus()
+ DFSliderMetaFunctions.editbox_typevalue:SetText ("")
+ slider.MyObject.typing_valu = false
+ end
+ end
+
+ local OnShow = function (slider)
+ local capsule = slider.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", slider, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local table_insert = table.insert
+ local table_remove = table.remove
+
+ local OnValueChanged = function (slider)
+
+ local amt
+ if (slider.MyObject.useDecimals) then
+ amt = slider:GetValue()
+ else
+ amt = do_precision (slider:GetValue())
+ end
+
+ if (slider.MyObject.typing_value and not slider.MyObject.typing_can_change) then
+ slider.MyObject:SetValue (slider.MyObject.typing_value_started)
+ return
+ end
+
+ table_insert (slider.MyObject.previous_value, 1, amt)
+ table_remove (slider.MyObject.previous_value, 4)
+
+ local capsule = slider.MyObject
+
+ --some plugins registered OnValueChanged and others with OnValueChange
+ local kill = capsule:RunHooksForWidget ("OnValueChanged", slider, capsule.FixedValue, amt, capsule)
+ if (kill) then
+ return
+ end
+ local kill = capsule:RunHooksForWidget ("OnValueChange", slider, capsule.FixedValue, amt, capsule)
+ if (kill) then
+ return
+ end
+
+ if (slider.MyObject.OnValueChanged) then
+ slider.MyObject.OnValueChanged (slider, slider.MyObject.FixedValue, amt)
+ end
+
+ if (amt < 10 and amt >= 1) then
+ amt = "0"..amt
+ end
+
+ if (slider.MyObject.useDecimals) then
+ slider.amt:SetText (string.format ("%.2f", amt))
+ else
+ slider.amt:SetText (math.floor (amt))
+ end
+ slider.MyObject.ivalue = amt
+
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+local SwitchOnClick = function (self, button, forced_value, value)
+
+ local slider = self.MyObject
+
+ if (_rawget (slider, "lockdown")) then
+ return
+ end
+
+ if (forced_value) then
+ _rawset (slider, "value", not value)
+ end
+
+ if (_rawget (slider, "value")) then --actived
+ _rawset (slider, "value", false)
+
+ if (slider.backdrop_disabledcolor) then
+ slider:SetBackdropColor (unpack (slider.backdrop_disabledcolor))
+ else
+ slider:SetBackdropColor (1, 0, 0, 0.4)
+ end
+
+ if (slider.is_checkbox) then
+ slider.checked_texture:Hide()
+ else
+ slider._text:SetText (slider._ltext)
+ slider._thumb:ClearAllPoints()
+ slider._thumb:SetPoint ("left", slider.widget, "left")
+ end
+ else
+ _rawset (slider, "value", true)
+ if (slider.backdrop_enabledcolor) then
+ slider:SetBackdropColor (unpack (slider.backdrop_enabledcolor))
+ else
+ slider:SetBackdropColor (0, 0, 1, 0.4)
+ end
+ if (slider.is_checkbox) then
+ slider.checked_texture:Show()
+ else
+ slider._text:SetText (slider._rtext)
+ slider._thumb:ClearAllPoints()
+ slider._thumb:SetPoint ("right", slider.widget, "right")
+ end
+ end
+
+ if (slider.OnSwitch and not forced_value) then
+ local value = _rawget (slider, "value")
+ if (slider.return_func) then
+ value = slider:return_func (value)
+ end
+
+ --> safe call
+ local success, errorText = pcall (slider.OnSwitch, slider, slider.FixedValue, value)
+ if (not success) then
+ error ("Details! Framework: OnSwitch() " .. (button.GetName and button:GetName() or "-NONAME-") .. " error: " .. (errorText or ""))
+ end
+
+ --> trigger hooks
+ slider:RunHooksForWidget ("OnSwitch", slider, slider.FixedValue, value)
+ end
+
+end
+
+local default_switch_func = function (self, passed_value)
+ if (self.value) then
+ return false
+ else
+ return true
+ end
+end
+
+local switch_get_value = function (self)
+ return self.value
+end
+
+local switch_set_value = function (self, value)
+ if (self.switch_func) then
+ value = self:switch_func (value)
+ end
+
+ SwitchOnClick (self.widget, nil, true, value)
+end
+
+local switch_set_fixparameter = function (self, value)
+ _rawset (self, "FixedValue", value)
+end
+
+local switch_disable = function (self)
+
+ if (self.is_checkbox) then
+ self.checked_texture:Hide()
+ else
+ self._text:Hide()
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self._thumb, "center")
+ end
+ self.lock_texture:Show()
+ end
+
+ self:SetAlpha (.4)
+ _rawset (self, "lockdown", true)
+end
+local switch_enable = function (self)
+ if (self.is_checkbox) then
+ if (_rawget (self, "value")) then
+ self.checked_texture:Show()
+ else
+ self.checked_texture:Hide()
+ end
+ else
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self._thumb, "center")
+ end
+ self.lock_texture:Hide()
+ self._text:Show()
+ end
+
+ self:SetAlpha (1)
+ return _rawset (self, "lockdown", false)
+end
+
+local set_switch_func = function (self, newFunction)
+ self.OnSwitch = newFunction
+end
+
+local set_as_checkbok = function (self)
+ local checked = self:CreateTexture (self:GetName() .. "CheckTexture", "overlay")
+ checked:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
+ checked:SetPoint ("center", self.button, "center", -1, -1)
+ local size_pct = self:GetWidth()/32
+ checked:SetSize (32*size_pct, 32*size_pct)
+ self.checked_texture = checked
+
+ self._thumb:Hide()
+ self._text:Hide()
+
+ self.is_checkbox = true
+
+ if (_rawget (self, "value")) then
+ self.checked_texture:Show()
+ if (self.backdrop_enabledcolor) then
+ self:SetBackdropColor (unpack (self.backdrop_enabledcolor))
+ else
+ self:SetBackdropColor (0, 0, 1, 0.4)
+ end
+ else
+ self.checked_texture:Hide()
+ if (self.backdrop_disabledcolor) then
+ self:SetBackdropColor (unpack (self.backdrop_disabledcolor))
+ else
+ self:SetBackdropColor (0, 0, 1, 0.4)
+ end
+ end
+
+end
+
+function DF:CreateSwitch (parent, on_switch, default_value, w, h, ltext, rtext, member, name, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
+ local switch, label = DF:NewSwitch (parent, parent, name, member, w or 60, h or 20, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
+ if (on_switch) then
+ switch.OnSwitch = on_switch
+ end
+ return switch, label
+end
+
+function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
+
+--> early checks
+ if (not name) then
+ name = "DetailsFrameWorkSlider" .. DF.SwitchCounter
+ DF.SwitchCounter = DF.SwitchCounter + 1
+ elseif (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+--> defaults
+ ltext = ltext or "OFF"
+ rtext = rtext or "ON"
+
+--> build frames
+ w = w or 60
+ h = h or 20
+
+ local slider = DF:NewButton (parent, container, name, member, w, h)
+ slider.HookList.OnSwitch = {}
+
+ slider.switch_func = switch_func
+ slider.return_func = return_func
+ slider.SetValue = switch_set_value
+ slider.GetValue = switch_get_value
+ slider.SetFixedParameter = switch_set_fixparameter
+ slider.Disable = switch_disable
+ slider.Enable = switch_enable
+ slider.SetAsCheckBox = set_as_checkbok
+ slider.SetTemplate = DFSliderMetaFunctions.SetTemplate
+ slider.SetSwitchFunction = set_switch_func
+
+ if (member) then
+ parent [member] = slider
+ end
+
+ slider:SetBackdrop ({edgeFile = [[Interface\Buttons\UI-SliderBar-Border]], edgeSize = 8,
+ bgFile = [[Interface\AddOns\Details\images\background]], insets = {left = 3, right = 3, top = 5, bottom = 5}})
+
+ local thumb = slider:CreateTexture (nil, "artwork")
+ thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ thumb:SetSize (34+(h*0.2), h*1.2)
+ thumb:SetAlpha (0.7)
+ thumb:SetPoint ("left", slider.widget, "left")
+
+ local text = slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ text:SetTextColor (.8, .8, .8, 1)
+ text:SetPoint ("center", thumb, "center")
+
+ slider._text = text
+ slider._thumb = thumb
+ slider._ltext = ltext
+ slider._rtext = rtext
+ slider.thumb = thumb
+
+ slider.invert_colors = color_inverted
+
+ slider:SetScript ("OnClick", SwitchOnClick)
+
+ slider:SetValue (default_value)
+
+ slider.isSwitch = true
+
+ if (switch_template) then
+ slider:SetTemplate (switch_template)
+ end
+
+ if (with_label) then
+ local label = DF:CreateLabel (slider.widget, with_label, nil, nil, nil, "label", nil, "overlay")
+ label.text = with_label
+ slider.widget:SetPoint ("left", label.widget, "right", 2, 0)
+ with_label = label
+
+ if (label_template) then
+ label:SetTemplate (label_template)
+ end
+ end
+
+ return slider, with_label
+end
+
+function DFSliderMetaFunctions:SetTemplate (template)
+
+ --slider e switch
+ if (template.width) then
+ self:SetWidth (template.width)
+ end
+ if (template.height) then
+ self:SetHeight (template.height)
+ end
+
+ if (template.backdrop) then
+ self:SetBackdrop (template.backdrop)
+ end
+ if (template.backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropcolor)
+ self:SetBackdropColor (r, g, b, a)
+ end
+ if (template.backdropbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
+ self:SetBackdropBorderColor (r, g, b, a)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onenterbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onenterbordercolor)
+ self.onenter_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.onleavebordercolor) then
+ local r, g, b, a = DF:ParseColors (template.onleavebordercolor)
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+
+ if (template.thumbtexture) then
+ if (self.thumb) then
+ self.thumb:SetTexture (template.thumbtexture)
+ end
+ end
+ if (template.thumbwidth) then
+ if (self.thumb) then
+ self.thumb:SetWidth (template.thumbwidth)
+ end
+ end
+ if (template.thumbheight) then
+ if (self.thumb) then
+ self.thumb:SetHeight (template.thumbheight)
+ end
+ end
+ if (template.thumbcolor) then
+ if (self.thumb) then
+ local r, g, b, a = DF:ParseColors (template.thumbcolor)
+ self.thumb:SetVertexColor (r, g, b, a)
+ end
+ end
+
+ --switch only
+ if (template.enabled_backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.enabled_backdropcolor)
+ self.backdrop_enabledcolor = {r, g, b, a}
+ end
+ if (template.disabled_backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.disabled_backdropcolor)
+ self.backdrop_disabledcolor = {r, g, b, a}
+ end
+end
+
+function DF:CreateSlider (parent, w, h, min, max, step, defaultv, isDecemal, member, name, with_label, slider_template, label_template)
+ local slider, label = DF:NewSlider (parent, parent, name, member, w, h, min, max, step, defaultv, isDecemal, false, with_label, slider_template, label_template)
+ return slider, label
+end
+
+function DF:NewSlider (parent, container, name, member, w, h, min, max, step, defaultv, isDecemal, isSwitch, with_label, slider_template, label_template)
+
+--> early checks
+ if (not name) then
+ name = "DetailsFrameworkSlider" .. DF.SliderCounter
+ DF.SliderCounter = DF.SliderCounter + 1
+ end
+ if (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local SliderObject = {type = "slider", dframework = true}
+
+ if (member) then
+ parent [member] = SliderObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+--> defaults
+ min = min or 1
+ max = max or 2
+ step = step or 1
+ defaultv = defaultv or min
+
+ w = w or 130
+ h = h or 19
+
+ --> default members:
+ SliderObject.lockdown = false
+ SliderObject.container = container
+
+ SliderObject.slider = CreateFrame ("slider", name, parent)
+ SliderObject.widget = SliderObject.slider
+
+ SliderObject.useDecimals = isDecemal or false
+
+ if (SliderObject.useDecimals) then
+ SliderObject.slider:SetValueStep (0.01)
+ else
+ SliderObject.slider:SetValueStep (step)
+ end
+
+ if (not APISliderFunctions) then
+ APISliderFunctions = true
+ local idx = getmetatable (SliderObject.slider).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not DFSliderMetaFunctions [funcName]) then
+ DFSliderMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.slider:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ SliderObject.slider.MyObject = SliderObject
+ SliderObject.slider:SetWidth (w)
+ SliderObject.slider:SetHeight (h)
+ SliderObject.slider:SetOrientation ("horizontal")
+ SliderObject.slider:SetMinMaxValues (min, max)
+ SliderObject.slider:SetValue (defaultv)
+ SliderObject.ivalue = defaultv
+
+ SliderObject.slider:SetBackdrop ({edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", edgeSize = 8})
+ SliderObject.slider:SetBackdropColor (0.9, 0.7, 0.7, 1.0)
+
+ SliderObject.thumb = SliderObject.slider:CreateTexture (nil, "artwork")
+ SliderObject.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ SliderObject.thumb:SetSize (30+(h*0.2), h*1.2)
+ SliderObject.thumb:SetAlpha (0.7)
+ SliderObject.slider:SetThumbTexture (SliderObject.thumb)
+ SliderObject.slider.thumb = SliderObject.thumb
+
+ if (not isSwitch) then
+ SliderObject.have_tooltip = "Right Click to Type the Value"
+ end
+
+ SliderObject.amt = SliderObject.slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+
+ local amt = defaultv
+ if (amt < 10 and amt >= 1) then
+ amt = "0"..amt
+ end
+
+ if (SliderObject.useDecimals) then
+ SliderObject.amt:SetText (string.format ("%.2f", amt))
+ else
+ SliderObject.amt:SetText (math.floor (amt))
+ end
+
+ SliderObject.amt:SetTextColor (.8, .8, .8, 1)
+ SliderObject.amt:SetPoint ("center", SliderObject.thumb, "center")
+ SliderObject.slider.amt = SliderObject.amt
+
+ SliderObject.previous_value = {defaultv or 0, 0, 0}
+
+ --> hooks
+ SliderObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnMouseDown = {},
+ OnMouseUp = {},
+
+ OnValueChange = {},
+ OnValueChanged = {},
+ }
+
+ SliderObject.slider:SetScript ("OnEnter", OnEnter)
+ SliderObject.slider:SetScript ("OnLeave", OnLeave)
+ SliderObject.slider:SetScript ("OnHide", OnHide)
+ SliderObject.slider:SetScript ("OnShow", OnShow)
+ SliderObject.slider:SetScript ("OnValueChanged", OnValueChanged)
+ SliderObject.slider:SetScript ("OnMouseDown", OnMouseDown)
+ SliderObject.slider:SetScript ("OnMouseUp", OnMouseUp)
+
+ _setmetatable (SliderObject, DFSliderMetaFunctions)
+
+ if (with_label) then
+ local label = DF:CreateLabel (SliderObject.slider, with_label, nil, nil, nil, "label", nil, "overlay")
+ label.text = with_label
+ SliderObject.slider:SetPoint ("left", label.widget, "right", 2, 0)
+ with_label = label
+
+ if (label_template) then
+ label:SetTemplate (label_template)
+ end
+ end
+
+ if (slider_template) then
+ SliderObject:SetTemplate (slider_template)
+ end
+
+ return SliderObject, with_label
+
+end
diff --git a/libs/DF/spells.lua b/libs/DF/spells.lua
new file mode 100644
index 0000000..2c66f7c
--- /dev/null
+++ b/libs/DF/spells.lua
@@ -0,0 +1,884 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+DF_COOLDOWN_RAID = 4
+DF_COOLDOWN_EXTERNAL = 3
+
+DF.CooldownsBySpec = {
+ -- 1 attack cooldown
+ -- 2 personal defensive cooldown
+ -- 3 targetted defensive cooldown
+ -- 4 raid defensive cooldown
+ -- 5 personal utility cooldown
+
+ --MAGE
+ --arcane
+ [62] = {
+ [12042] = 1, --Arcane Power
+ [55342] = 1, --Mirror Image
+ [45438] = 2, --Ice Block
+ [12051] = 5, --Evocation
+ [110960] = 5, --Greater Invisibility
+ },
+ --fire
+ [63] = {
+ [190319] = 1, --Combustion
+ [55342] = 1, --Mirror Image
+ [45438] = 2, --Ice Block
+ [66] = 5, --Invisibility
+ },
+ --frost
+ [64] = {
+ [12472] = 1, --Icy Veins
+ [205021] = 1, --Ray of Frost
+ [55342] = 1, --Mirror Image
+ [45438] = 2, --Ice Block
+ [66] = 5, --Invisibility
+ [235219] = 5, --Cold Snap
+ },
+
+ --PRIEST
+ --discipline
+ [256] = {
+ [34433] = 1, --Shadowfiend
+ [123040] = 1, --Mindbender
+ [33206] = 3, --Pain Suppression
+ [62618] = 4, --Power Word: Barrier
+ [271466] = 4, --Luminous Barrier (talent)
+ [47536] = 5, --Rapture
+ [19236] = 5, --Desperate Prayer
+ [8122] = 5, --Psychic Scream
+ },
+ --holy
+ [257] = {
+ [200183] = 2, --Apotheosis
+ [47788] = 3, --Guardian Spirit
+ [64844] = 4, --Divine Hymn
+ [64901] = 4, --Symbol of Hope
+ [265202] = 4, --Holy Word: Salvation
+ [88625] = 5, --Holy Word: Chastise
+ [34861] = 5, --Holy Word: Sanctify
+ [2050] = 5, --Holy Word: Serenity
+ [19236] = 5, --Desperate Prayer
+ [8122] = 5, --Psychic Scream
+ },
+ --shadow priest
+ [258] = {
+ [34433] = 1, --Shadowfiend
+ [200174] = 1, --Mindbender
+ [193223] = 1, --Surrender to Madness
+ [47585] = 2, --Dispersion
+ [15286] = 4, --Vampiric Embrace
+ [64044] = 5, --Psychic Horror
+ [8122] = 5, --Psychic Scream
+ },
+
+ --ROGUE
+ --assassination
+ [259] = {
+ [79140] = 1, --Vendetta
+ [1856] = 2, --Vanish
+ [5277] = 2, --Evasion
+ [31224] = 2, --Cloak of Shadows
+ [2094] = 5, --Blind
+ [114018] = 5, --Shroud of Concealment
+ },
+ --outlaw
+ [260] = {
+ [13750] = 1, --Adrenaline Rush
+ [51690] = 1, --Killing Spree (talent)
+ [199754] = 2, --Riposte
+ [31224] = 2, --Cloak of Shadows
+ [1856] = 2, --Vanish
+ [2094] = 5, --Blind
+ [114018] = 5, --Shroud of Concealment
+ },
+ --subtlety
+ [261] = {
+ [121471] = 1, --Shadow Blades
+ [31224] = 2, --Cloak of Shadows
+ [1856] = 2, --Vanish
+ [5277] = 2, --Evasion
+ [2094] = 5, --Blind
+ [114018] = 5, --Shroud of Concealment
+ },
+
+ --WARLOCK
+ --affliction
+ [265] = {
+ [205180] = 1, --Summon Darkglare
+ [113860] = 1, --Dark Soul: Misery (talent)
+ [104773] = 2, --Unending Resolve
+
+ [108416] = 2, --Dark Pact (talent)
+
+ [30283] = 5, --Shadowfury
+ [6789] = 5, --Mortal Coil
+ },
+ --demo
+ [266] = {
+ [265187] = 1, --Summon Demonic Tyrant
+ [111898] = 1, --Grimoire: Felguard (talent)
+ [267217] = 1, --Nether Portal (talent)
+
+ [104773] = 2, --Unending Resolve
+ [108416] = 2, --Dark Pact (talent)
+
+ [30283] = 5, --Shadowfury
+ [6789] = 5, --Mortal Coil
+ },
+ --destro
+ [267] = {
+ [1122] = 1, --Summon Infernal
+ [113858] = 1, --Dark Soul: Instability (talent)
+
+ [104773] = 2, --Unending Resolve
+ [108416] = 2, --Dark Pact (talent)
+
+ [6789] = 5, --Mortal Coil
+ [30283] = 5, --Shadowfury
+ },
+
+ --WARRIOR
+ --Arms
+ [71] = {
+ [107574] = 1, --Avatar
+ [227847] = 1, --Bladestorm
+ [152277] = 1, --Ravager (talent)
+
+ [118038] = 2, --Die by the Sword
+
+ [97462] = 4, --Rallying Cry
+
+ [18499] = 5, --Berserker Rage
+ [5246] = 5, --Intimidating Shout
+ },
+ --Fury
+ [72] = {
+ [1719] = 1, --Recklessness
+ [46924] = 1, --Bladestorm (talent)
+
+ [184364] = 2, --Enraged Regeneration
+
+ [97462] = 4, --Rallying Cry
+
+ [18499] = 5, --Berserker Rage
+ [5246] = 5, --Intimidating Shout
+ },
+ --Protection
+ [73] = {
+ [228920] = 1, --Ravager (talent)
+ [107574] = 1, --Avatar
+
+ [12975] = 2, --Last Stand
+ [871] = 2, --Shield Wall
+
+ [97462] = 4, --Rallying Cry
+
+ [18499] = 5, --Berserker Rage
+ [5246] = 5, --Intimidating Shout
+ },
+
+ --PALADIN
+ --holy
+ [65] = {
+ [31884] = 1, --Avenging Wrath
+ [216331] = 1, --Avenging Crusader (talent)
+
+ [498] = 2, --Divine Protection
+ [642] = 2, --Divine Shield
+ [105809] = 2, --Holy Avenger (talent)
+
+ [1022] = 3, --Blessing of Protection
+ [633] = 3, --Lay on Hands
+
+ [31821] = 4, --Aura Mastery
+
+ [1044] = 5, --Blessing of Freedom
+ [853] = 5, --Hammer of Justice
+ [115750] = 5, --Blinding Light (talent)
+ },
+
+ --protection
+ [66] = {
+ [31884] = 1, --Avenging Wrath
+
+ [31850] = 2, --Ardent Defender
+ [86659] = 2, --Guardian of Ancient Kings
+
+ [1022] = 3, --Blessing of Protection
+ [204018] = 3, --Blessing of Spellwarding (talent)
+ [6940] = 3, --Blessing of Sacrifice
+
+ [204150] = 4, --Aegis of Light (talent)
+
+ [1044] = 5, --Blessing of Freedom
+ [853] = 5, --Hammer of Justice
+ [115750] = 5, --Blinding Light (talent)
+ },
+
+ --retribution
+ [70] = {
+ [31884] = 1, --Avenging Wrath
+ [231895] = 1, --Crusade (talent)
+
+ [184662] = 2, --Shield of Vengeance
+ [642] = 2, --Divine Shield
+
+ [1022] = 3, --Blessing of Protection
+ [633] = 3, --Lay on Hands
+
+ [1044] = 5, --Blessing of Freedom
+ [853] = 5, --Hammer of Justice
+ [115750] = 5, --Blinding Light (talent)
+ },
+
+ --DEMON HUNTER
+ --havoc
+ [577] = {
+ [200166] = 1, --Metamorphosis
+ [206491] = 1, --Nemesis (talent)
+
+ [196555] = 2, --Netherwalk (talent)
+
+ [196718] = 4, --Darkness
+ },
+ --vengeance
+ [581] = {
+ [187827] = 2, --Metamorphosis
+
+ [207684] = 5, --Sigil of Misery
+ [202137] = 5, --Sigil of Silence
+ [202138] = 5, --Sigil of Chains (talent)
+ },
+
+ --DEATH KNIGHT
+ --unholy
+ [252] = {
+ [275699] = 1, --Apocalypse
+ [42650] = 1, --Army of the Dead
+ [49206] = 1, --Summon Gargoyle (talent)
+
+ [48792] = 2, --Icebound Fortitude
+ [48743] = 2, --Death Pact (talent)
+
+ },
+ --frost
+ [251] = {
+ [152279] = 1, --Breath of Sindragosa (talent)
+ [47568] = 1, --Empower Rune Weapon
+ [279302] = 1, --Frostwyrm's Fury (talent)
+
+ [48792] = 2, --Icebound Fortitude
+ [48743] = 2, --Death Pact (talent)
+
+ [207167] = 5, --Blinding Sleet (talent)
+ },
+ --blood
+ [250] = {
+ [49028] = 1, --Dancing Rune Weapon
+
+ [55233] = 2, --Vampiric Blood
+ [48792] = 2, --Icebound Fortitude
+
+ [108199] = 5, --Gorefiend's Grasp
+ },
+
+ --DRUID
+ --balance
+ [102] = {
+ [194223] = 1, --Celestial Alignment
+ [102560] = 1, --Incarnation: Chosen of Elune (talent)
+
+ [22812] = 2, --Barkskin
+ [108238] = 2, --Renewal (talent)
+
+ [29166] = 3, --Innervate
+
+ [78675] = 5, --Solar Beam
+ },
+ --feral
+ [103] = {
+ [106951] = 1, --Berserk
+ [102543] = 1, --Incarnation: King of the Jungle (talent)
+
+ [61336] = 2, --Survival Instincts
+ [108238] = 2, --Renewal (talent)
+
+ [77764] = 4, --Stampeding Roar
+ },
+ --guardian
+ [104] = {
+ [22812] = 2, --Barkskin
+ [61336] = 2, --Survival Instincts
+ [102558] = 2, --Incarnation: Guardian of Ursoc (talent)
+
+ [77761] = 4, --Stampeding Roar
+
+ [99] = 5, --Incapacitating Roar
+ },
+ --restoration
+ [105] = {
+
+ [22812] = 2, --Barkskin
+ [108238] = 2, --Renewal (talent)
+ [33891] = 2, --Incarnation: Tree of Life (talent)
+
+ [102342] = 3, --Ironbark
+ [29166] = 3, --Innervate
+
+ [740] = 4, --Tranquility
+ [197721] = 4, --Flourish (talent)
+
+ [102793] = 5, --Ursol's Vortex
+ },
+
+ --HUNTER
+ --beast mastery
+ [253] = {
+ [193530] = 1, --Aspect of the Wild
+ [19574] = 1, --Bestial Wrath
+ [201430] = 1, --Stampede (talent)
+ [194407] = 1, --Spitting Cobra (talent)
+
+ [186265] = 2, --Aspect of the Turtle
+
+ [19577] = 5, --Intimidation
+ },
+ --marksmanship
+ [254] = {
+ [193526] = 1, --Trueshot
+
+ [186265] = 2, --Aspect of the Turtle
+ [109304] = 2, --Exhilaration
+ [281195] = 2, --Survival of the Fittest
+
+ [187650] = 5, --Freezing Trap
+ },
+ --survival
+ [255] = {
+ [266779] = 1, --Coordinated Assault
+
+ [186265] = 2, --Aspect of the Turtle
+ [109304] = 2, --Exhilaration
+
+ [19577] = 5, --Intimidation
+ },
+
+ --MONK
+ --brewmaster
+ [268] = {
+ [115203] = 2, --Fortifying Brew
+ [115176] = 2, --Zen Meditation
+ [122278] = 2, --Dampen Harm (talent)
+ },
+ --windwalker
+ [269] = {
+ [137639] = 1, --Storm, Earth, and Fire
+ [123904] = 1, --Invoke Xuen, the White Tiger (talent)
+ [152173] = 1, --Serenity (talent)
+
+ [122470] = 2, --Touch of Karma
+ [122278] = 2, --Dampen Harm (talent)
+ [122783] = 2, --Diffuse Magic (talent)
+
+ [119381] = 5, --Leg Sweep
+ },
+ --mistweaver
+ [270] = {
+ [122278] = 2, --Dampen Harm (talent)
+ [243435] = 2, --Fortifying Brew
+ [122783] = 2, --Diffuse Magic (talent)
+
+ [116849] = 3, --Life Cocoon
+
+ [198664] = 4, --Invoke Chi-Ji, the Red Crane (talent)
+
+ [115310] = 4, --Revival
+ },
+
+ --SHAMAN
+ --elemental
+ [262] = {
+ [198067] = 1, --Fire Elemental
+ [192249] = 1, --Storm Elemental (talent)
+ [114050] = 1, --Ascendance (talent)
+
+ [108271] = 2, --Astral Shift
+
+ [108281] = 4, --Ancestral Guidance (talent)
+ },
+ --enhancement
+ [263] = {
+ [51533] = 1, --Feral Spirit
+ [114051] = 1, --Ascendance (talent)
+
+ [108271] = 2, --Astral Shift
+ },
+ --restoration
+ [263] = {
+ [108271] = 2, --Astral Shift
+ [114052] = 2, --Ascendance (talent)
+ [98008] = 4, --Spirit Link Totem
+ [108280] = 4, --Healing Tide Totem
+ [207399] = 4, --Ancestral Protection Totem (talent)
+ },
+}
+
+--> tells the duration, requirements and cooldown of a cooldown
+DF.CooldownsInfo = {
+ --> paladin
+ [31884] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "PALADIN", type = 1}, --Avenging Wrath
+ [216331] = {cooldown = 120, duration = 20, talent = 22190, charges = 1, class = "PALADIN", type = 1}, --Avenging Crusader (talent)
+ [498] = {cooldown = 60, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 2}, --Divine Protection
+ [642] = {cooldown = 300, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 2}, --Divine Shield
+ [105809] = {cooldown = 90, duration = 20, talent = 22164, charges = 1, class = "PALADIN", type = 2}, --Holy Avenger (talent)
+ [1022] = {cooldown = 300, duration = 10, talent = false, charges = 1, class = "PALADIN", type = 3}, --Blessing of Protection
+ [633] = {cooldown = 600, duration = false, talent = false, charges = 1, class = "PALADIN", type = 3}, --Lay on Hands
+ [31821] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 4}, --Aura Mastery
+ [1044] = {cooldown = 25, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 5}, --Blessing of Freedom
+ [31850] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 2}, --Ardent Defender
+ [86659] = {cooldown = 300, duration = 8, talent = false, charges = 1, class = "PALADIN", type = 2}, --Guardian of Ancient Kings
+ [204018] = {cooldown = 180, duration = 10, talent = 22435, charges = 1, class = "PALADIN", type = 3}, --Blessing of Spellwarding (talent)
+ [6940] = {cooldown = 120, duration = 12, talent = false, charges = 1, class = "PALADIN", type = 3}, --Blessing of Sacrifice
+ [204150] = {cooldown = 180, duration = 6, talent = 23087, charges = 1, class = "PALADIN", type = 4}, --Aegis of Light (talent)
+ [231895] = {cooldown = 120, duration = 25, talent = 22215, charges = 1, class = "PALADIN", type = 1}, --Crusade (talent)
+ [184662] = {cooldown = 120, duration = 15, talent = false, charges = 1, class = "PALADIN", type = 2}, --Shield of Vengeance
+
+ --> warrior
+ [107574] = {cooldown = 90, duration = 20, talent = 22397, charges = 1, class = "WARRIOR", type = 1}, --Avatar
+ [227847] = {cooldown = 90, duration = 5, talent = false, charges = 1, class = "WARRIOR", type = 1}, --Bladestorm
+ [152277] = {cooldown = 60, duration = 6, talent = 21667, charges = 1, class = "WARRIOR", type = 1}, --Ravager (talent)
+ [118038] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "WARRIOR", type = 2}, --Die by the Sword
+ [97462] = {cooldown = 180, duration = 10, talent = false, charges = 1, class = "WARRIOR", type = 4}, --Rallying Cry
+ [1719] = {cooldown = 90, duration = 10, talent = false, charges = 1, class = "WARRIOR", type = 1}, --Recklessness
+ [46924] = {cooldown = 60, duration = 4, talent = 22400, charges = 1, class = "WARRIOR", type = 1}, --Bladestorm (talent)
+ [184364] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "WARRIOR", type = 2}, --Enraged Regeneration
+ [228920] = {cooldown = 60, duration = 6, talent = 23099, charges = 1, class = "WARRIOR", type = 1}, --Ravager (talent)
+ [12975] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "WARRIOR", type = 2}, --Last Stand
+ [871] = {cooldown = 8, duration = 240, talent = false, charges = 1, class = "WARRIOR", type = 2}, --Shield Wall
+
+ --> warlock
+ [205180] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Summon Darkglare
+ [113860] = {cooldown = 120, duration = 20, talent = 19293, charges = 1, class = "WARLOCK", type = 1}, --Dark Soul: Misery (talent)
+ [104773] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "WARLOCK", type = 2}, --Unending Resolve
+ [108416] = {cooldown = 60, duration = 20, talent = 19286, charges = 1, class = "WARLOCK", type = 2}, --Dark Pact (talent)
+ [265187] = {cooldown = 90, duration = 15, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Summon Demonic Tyrant
+ [111898] = {cooldown = 120, duration = 15, talent = 21717, charges = 1, class = "WARLOCK", type = 1}, --Grimoire: Felguard
+ [267217] = {cooldown = 180, duration = 20, talent = 23091, charges = 1, class = "WARLOCK", type = 1}, --Nether Portal
+ [1122] = {cooldown = 180, duration = 30, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Summon Infernal
+ [113858] = {cooldown = 120, duration = 20, talent = 23092, charges = 1, class = "WARLOCK", type = 1}, --Dark Soul: Instability (talent)
+
+ --> shaman
+ [198067] = {cooldown = 150, duration = 30, talent = false, charges = 1, class = "SHAMAN", type = 1}, --Fire Elemental
+ [192249] = {cooldown = 150, duration = 30, talent = 19272, charges = 1, class = "SHAMAN", type = 1}, --Storm Elemental (talent)
+ [114050] = {cooldown = 180, duration = 15, talent = 21675, charges = 1, class = "SHAMAN", type = 1}, --Ascendance (talent)
+ [108271] = {cooldown = 90, duration = 8, talent = false, charges = 1, class = "SHAMAN", type = 2}, --Astral Shift
+ [108281] = {cooldown = 120, duration = 10, talent = 22172, charges = 1, class = "SHAMAN", type = 4}, --Ancestral Guidance (talent)
+ [51533] = {cooldown = 120, duration = 15, talent = false, charges = 1, class = "SHAMAN", type = 1}, --Feral Spirit
+ [114051] = {cooldown = 180, duration = 15, talent = 21972, charges = 1, class = "SHAMAN", type = 1}, --Ascendance (talent)
+ [114052] = {cooldown = 180, duration = 15, talent = 22359, charges = 1, class = "SHAMAN", type = 2}, --Ascendance (talent)
+ [98008] = {cooldown = 180, duration = 6, talent = false, charges = 1, class = "SHAMAN", type = 4}, --Spirit Link Totem
+ [108280] = {cooldown = 180, duration = 10, talent = false, charges = 1, class = "SHAMAN", type = 4}, --Healing Tide Totem
+ [207399] = {cooldown = 240, duration = 30, talent = 22323, charges = 1, class = "SHAMAN", type = 4}, --Ancestral Protection Totem (talent)
+
+ --> monk
+ [115203] = {cooldown = 420, duration = 15, talent = false, charges = 1, class = "MONK", type = 2}, --Fortifying Brew
+ [115176] = {cooldown = 300, duration = 8, talent = false, charges = 1, class = "MONK", type = 2}, --Zen Meditation
+ [122278] = {cooldown = 120, duration = 10, talent = 20175, charges = 1, class = "MONK", type = 2}, --Dampen Harm (talent)
+ [137639] = {cooldown = 90, duration = 15, talent = false, charges = 1, class = "MONK", type = 1}, --Storm, Earth, and Fire
+ [123904] = {cooldown = 120, duration = 20, talent = 22102, charges = 1, class = "MONK", type = 1}, --Invoke Xuen, the White Tiger (talent)
+ [152173] = {cooldown = 90, duration = 12, talent = 21191, charges = 1, class = "MONK", type = 1}, --Serenity (talent)
+ [122470] = {cooldown = 90, duration = 6, talent = false, charges = 1, class = "MONK", type = 2}, --Touch of Karma
+ [198664] = {cooldown = 180, duration = 25, talent = 22214, charges = 1, class = "MONK", type = 4}, --Invoke Chi-Ji, the Red Crane (talent)
+ [243435] = {cooldown = 90, duration = 15, talent = false, charges = 1, class = "MONK", type = 2}, --Fortifying Brew
+ [122783] = {cooldown = 90, duration = 6, talent = 20173, charges = 1, class = "MONK", type = 2}, --Diffuse Magic (talent)
+ [116849] = {cooldown = 120, duration = 12, talent = false, charges = 1, class = "MONK", type = 3}, --Life Cocoon
+ [115310] = {cooldown = 180, duration = false, talent = false, charges = 1, class = "MONK", type = 4}, --Revival
+
+ --> hunter
+ [193530] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "HUNTER", type = 1}, --Aspect of the Wild
+ [19574] = {cooldown = 90, duration = 12, talent = false, charges = 1, class = "HUNTER", type = 1}, --Bestial Wrath
+ [201430] = {cooldown = 180, duration = 12, talent = 23044, charges = 1, class = "HUNTER", type = 1}, --Stampede (talent)
+ [194407] = {cooldown = 90, duration = 20, talent = 22295, charges = 1, class = "HUNTER", type = 1}, --Spitting Cobra (talent)
+ [193526] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "HUNTER", type = 1}, --Trueshot
+ [281195] = {cooldown = 180, duration = 6, talent = false, charges = 1, class = "HUNTER", type = 2}, --Survival of the Fittest
+ [266779] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "HUNTER", type = 1}, --Coordinated Assault
+ [186265] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "HUNTER", type = 2}, --Aspect of the Turtle
+ [109304] = {cooldown = 120, duration = false, talent = false, charges = 1, class = "HUNTER", type = 2}, --Exhilaration
+
+ --> druid
+ [194223] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "DRUID", type = 1}, --Celestial Alignment
+ [102560] = {cooldown = 180, duration = 30, talent = 21702, charges = 1, class = "DRUID", type = 1}, --Incarnation: Chosen of Elune (talent)
+ [22812] = {cooldown = 60, duration = 12, talent = false, charges = 1, class = "DRUID", type = 2}, --Barkskin
+ [108238] = {cooldown = 90, duration = false, talent = 18570, charges = 1, class = "DRUID", type = 2}, --Renewal (talent)
+ [29166] = {cooldown = 180, duration = 12, talent = false, charges = 1, class = "DRUID", type = 3}, --Innervate
+ [78675] = {cooldown = 60, duration = 8, talent = false, charges = 1, class = "DRUID", type = 5}, --Solar Beam
+ [106951] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "DRUID", type = 1}, --Berserk
+ [102543] = {cooldown = 30, duration = 180, talent = 21704, charges = 1, class = "DRUID", type = 1}, --Incarnation: King of the Jungle (talent)
+ [61336] = {cooldown = 120, duration = 6, talent = false, charges = 2, class = "DRUID", type = 2}, --Survival Instincts (2min feral 4min guardian, same spellid)
+ [77764] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "DRUID", type = 4}, --Stampeding Roar (utility)
+ [102558] = {cooldown = 180, duration = 30, talent = 22388, charges = 1, class = "DRUID", type = 2}, --Incarnation: Guardian of Ursoc (talent)
+ [33891] = {cooldown = 180, duration = 30, talent = 22421, charges = 1, class = "DRUID", type = 2}, --Incarnation: Tree of Life (talent)
+ [102342] = {cooldown = 60, duration = 12, talent = false, charges = 1, class = "DRUID", type = 3}, --Ironbark
+ [740] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "DRUID", type = 4}, --Tranquility
+ [197721] = {cooldown = 90, duration = 8, talent = 22404, charges = 1, class = "DRUID", type = 4}, --Flourish (talent)
+
+ --> death knight
+ [275699] = {cooldown = 90, duration = 15, talent = false, charges = 1, class = "DEATHKNIGHT", type = 1}, --Apocalypse
+ [42650] = {cooldown = 480, duration = 30, talent = false, charges = 1, class = "DEATHKNIGHT", type = 1}, --Army of the Dead
+ [49206] = {cooldown = 180, duration = 30, talent = 22538, charges = 1, class = "DEATHKNIGHT", type = 1}, --Summon Gargoyle (talent)
+ [48743] = {cooldown = 120, duration = 15, talent = 23373, charges = 1, class = "DEATHKNIGHT", type = 2}, --Death Pact (talent)
+ [152279] = {cooldown = 120, duration = 5, talent = 22537, charges = 1, class = "DEATHKNIGHT", type = 1}, --Breath of Sindragosa (talent)
+ [47568] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "DEATHKNIGHT", type = 1}, --Empower Rune Weapon
+ [279302] = {cooldown = 120, duration = 10, talent = 22535, charges = 1, class = "DEATHKNIGHT", type = 1}, --Frostwyrm's Fury (talent)
+ [49028] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "DEATHKNIGHT", type = 1}, --Dancing Rune Weapon
+ [55233] = {cooldown = 90, duration = 10, talent = false, charges = 1, class = "DEATHKNIGHT", type = 2}, --Vampiric Blood
+ [48792] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "DEATHKNIGHT", type = 2}, --Icebound Fortitude
+ [108199] = {cooldown = 120, duration = false, talent = false, charges = 1, class = "DEATHKNIGHT", type = 5}, --Gorefiend's Grasp (utility)
+
+ --> demon hunter
+ [200166] = {cooldown = 240, duration = 30, talent = false, charges = 1, class = "DEMONHUNTER", type = 1}, --Metamorphosis
+ [206491] = {cooldown = 120, duration = 60, talent = 22547, charges = 1, class = "DEMONHUNTER", type = 1}, --Nemesis (talent)
+ [196555] = {cooldown = 120, duration = 5, talent = 21865, charges = 1, class = "DEMONHUNTER", type = 2}, --Netherwalk (talent)
+ [196718] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "DEMONHUNTER", type = 4}, --Darkness
+ [187827] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "DEMONHUNTER", type = 2}, --Metamorphosis
+
+ --> mage
+ [12042] = {cooldown = 90, duration = 10, talent = false, charges = 1, class = "MAGE", type = 1}, --Arcane Power
+ [12051] = {cooldown = 90, duration = 6, talent = false, charges = 1, class = "MAGE", type = 1}, --Evocation
+ [110960] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "MAGE", type = 2}, --Greater Invisibility
+ [190319] = {cooldown = 120, duration = 10, talent = false, charges = 1, class = "MAGE", type = 1}, --Combustion
+ [55342] = {cooldown = 120, duration = 40, talent = 22445, charges = 1, class = "MAGE", type = 1}, --Mirror Image (talent)
+ [66] = {cooldown = 300, duration = 20, talent = false, charges = 1, class = "MAGE", type = 2}, --Invisibility
+ [12472] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "MAGE", type = 1}, --Icy Veins
+ [205021] = {cooldown = 78, duration = 5, talent = 22309, charges = 1, class = "MAGE", type = 1}, --Ray of Frost (talent)
+ [45438] = {cooldown = 240, duration = 10, talent = false, charges = 1, class = "MAGE", type = 2}, --Ice Block
+ [235219] = {cooldown = 300, duration = false, talent = false, charges = 1, class = "MAGE", type = 5}, --Cold Snap
+
+ --> priest
+ [34433] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "PRIEST", type = 1}, --Shadowfiend
+ [123040] = {cooldown = 60, duration = 12, talent = 22094, charges = 1, class = "PRIEST", type = 1}, --Mindbender (talent)
+ [33206] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "PRIEST", type = 3}, --Pain Suppression
+ [62618] = {cooldown = 180, duration = 10, talent = false, charges = 1, class = "PRIEST", type = 4}, --Power Word: Barrier
+ [271466] = {cooldown = 180, duration = 10, talent = 21184, charges = 1, class = "PRIEST", type = 4}, --Luminous Barrier (talent)
+ [47536] = {cooldown = 90, duration = 10, talent = false, charges = 1, class = "PRIEST", type = 5}, --Rapture
+ [19236] = {cooldown = 90, duration = 10, talent = false, charges = 1, class = "PRIEST", type = 5}, --Desperate Prayer
+ [200183] = {cooldown = 120, duration = 20, talent = 21644, charges = 1, class = "PRIEST", type = 2}, --Apotheosis (talent)
+ [47788] = {cooldown = 180, duration = 10, talent = false, charges = 1, class = "PRIEST", type = 3}, --Guardian Spirit
+ [64844] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "PRIEST", type = 4}, --Divine Hymn
+ [64901] = {cooldown = 300, duration = 6, talent = false, charges = 1, class = "PRIEST", type = 4}, --Symbol of Hope
+ [265202] = {cooldown = 720, duration = false, talent = 23145, charges = 1, class = "PRIEST", type = 4}, --Holy Word: Salvation (talent)
+ [8122] = {cooldown = 60, duration = 8, talent = false, charges = 1, class = "PRIEST", type = 5}, --Psychic Scream
+ [200174] = {cooldown = 60, duration = 15, talent = 21719, charges = 1, class = "PRIEST", type = 1}, --Mindbender (talent)
+ [193223] = {cooldown = 240, duration = 60, talent = 21979, charges = 1, class = "PRIEST", type = 1}, --Surrender to Madness (talent)
+ [47585] = {cooldown = 120, duration = 6, talent = false, charges = 1, class = "PRIEST", type = 2}, --Dispersion
+ [15286] = {cooldown = 120, duration = 15, talent = false, charges = 1, class = "PRIEST", type = 4}, --Vampiric Embrace
+
+ --> rogue
+ [79140] = {cooldown = 120, duration = 20, talent = false, charges = 1, class = "ROGUE", type = 1}, --Vendetta
+ [1856] = {cooldown = 120, duration = 3, talent = false, charges = 1, class = "ROGUE", type = 2}, --Vanish
+ [5277] = {cooldown = 120, duration = 10, talent = false, charges = 1, class = "ROGUE", type = 2}, --Evasion
+ [31224] = {cooldown = 120, duration = 5, talent = false, charges = 1, class = "ROGUE", type = 2}, --Cloak of Shadows
+ [2094] = {cooldown = 120, duration = 60, talent = false, charges = 1, class = "ROGUE", type = 5}, --Blind
+ [114018] = {cooldown = 360, duration = 15, talent = false, charges = 1, class = "ROGUE", type = 5}, --Shroud of Concealment
+ [13750] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "ROGUE", type = 1}, --Adrenaline Rush
+ [51690] = {cooldown = 120, duration = 2, talent = 23175, charges = 1, class = "ROGUE", type = 1}, --Killing Spree (talent)
+ [199754] = {cooldown = 120, duration = 10, talent = false, charges = 1, class = "ROGUE", type = 2}, --Riposte
+ [121471] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "ROGUE", type = 1}, --Shadow Blades
+}
+
+-- {cooldown = , duration = , talent = false, charges = 1}
+
+DF.CrowdControlSpells = {
+ [5246] = "WARRIOR", --Intimidating Shout
+ [132168] = "WARRIOR", --Shockwave (debuff spellid)
+ [132169] = "WARRIOR", --Storm Bolt (talent debuff spellid)
+
+ [118699] = "WARLOCK", --Fear (debuff spellid)
+ [6789] = "WARLOCK", --Mortal Coil
+ [30283] = "WARLOCK", --Shadowfury
+ [710] = "WARLOCK", --Banish
+
+ [118] = "MAGE", --Polymorph
+ [61305] = "MAGE", --Polymorph (black cat)
+ [28271] = "MAGE", --Polymorph Turtle
+ [161354] = "MAGE", --Polymorph Monkey
+ [161353] = "MAGE", --Polymorph Polar Bear Cub
+ [126819] = "MAGE", --Polymorph Porcupine
+ [277787] = "MAGE", --Polymorph Direhorn
+ [61721] = "MAGE", --Polymorph Rabbit
+ [28272] = "MAGE", --Polymorph Pig
+ [277792] = "MAGE", --Polymorph Bumblebee
+
+ [82691] = "MAGE", --Ring of Frost (debuff spellid)
+ [122] = "MAGE", --Frost Nova
+ [157997] = "MAGE", --Ice Nova
+ [31661] = "MAGE", --Dragon's Breath
+
+ [205364] = "PRIEST", --Mind Control (talent)
+ [605] = "PRIEST", --Mind Control
+ [8122] = "PRIEST", --Psychic Scream
+ [9484] = "PRIEST", --Shackle Undead
+ [200196] = "PRIEST", --Holy Word: Chastise (debuff spellid)
+ [200200] = "PRIEST", --Holy Word: Chastise (talent debuff spellid)
+ [226943] = "PRIEST", --Mind Bomb (talent)
+ [64044] = "PRIEST", --Psychic Horror (talent)
+
+ [2094] = "ROGUE", --Blind
+ [1833] = "ROGUE", --Cheap Shot
+ [408] = "ROGUE", --Kidney Shot
+ [6770] = "ROGUE", --Sap
+ [1776] = "ROGUE", --Gouge
+ [199804] = "ROGUE", --Between the Eyes
+
+ [853] = "PALADIN", --Hammer of Justice
+ [20066] = "PALADIN", --Repentance (talent)
+ [105421] = "PALADIN", --Blinding Light (talent)
+
+ [221562] = "DEATHKNIGHT", --Asphyxiate
+ [108194] = "DEATHKNIGHT", --Asphyxiate (talent)
+ [207167] = "DEATHKNIGHT", --Blinding Sleet
+
+ [339] = "DRUID", --Entangling Roots
+ [2637] = "DRUID", --Hibernate
+ [61391] = "DRUID", --Typhoon
+ [102359] = "DRUID", --Mass Entanglement
+ [99] = "DRUID", --Incapacitating Roar
+ [236748] = "DRUID", --Intimidating Roar
+ [5211] = "DRUID", --Mighty Bash
+ [45334] = "DRUID", --Immobilized
+ [203123] = "DRUID", --Maim
+ [50259] = "DRUID", --Dazed (from Wild Charge)
+ [209753] = "DRUID", --Cyclone (from pvp talent)
+ [33786] = "DRUID", --Cyclone (from pvp talent - resto druid)
+
+ [3355] = "HUNTER", --Freezing Trap
+ [19577] = "HUNTER", --Intimidation
+ [190927] = "HUNTER", --Harpoon
+ [162480] = "HUNTER", --Steel Trap
+ [24394] = "HUNTER", --Intimidation
+
+ [119381] = "MONK", --Leg Sweep
+ [115078] = "MONK", --Paralysis
+ [198909] = "MONK", --Song of Chi-Ji (talent)
+ [116706] = "MONK", --Disable
+ [107079] = "MONK", --Quaking Palm (racial)
+
+ [118905] = "SHAMAN", --Static Charge (Capacitor Totem)
+ [51514] = "SHAMAN", --Hex
+ [64695] = "SHAMAN", --Earthgrab (talent)
+ [197214] = "SHAMAN", --Sundering (talent)
+
+ [179057] = "DEMONHUNTER", --Chaos Nova
+ [217832] = "DEMONHUNTER", --Imprison
+ [200166] = "DEMONHUNTER", --Metamorphosis
+ [207685] = "DEMONHUNTER", --Sigil of Misery
+}
+
+DF.SpecIds = {
+ [577] = "DEMONHUNTER",
+ [581] = "DEMONHUNTER",
+
+ [250] = "DEATHKNIGHT",
+ [251] = "DEATHKNIGHT",
+ [252] = "DEATHKNIGHT",
+
+ [71] = "WARRIOR",
+ [72] = "WARRIOR",
+ [73] = "WARRIOR",
+
+ [62] = "MAGE",
+ [63] = "MAGE",
+ [64] = "MAGE",
+
+ [259] = "ROGUE",
+ [260] = "ROGUE",
+ [261] = "ROGUE",
+
+ [102] = "DRUID",
+ [103] = "DRUID",
+ [104] = "DRUID",
+ [105] = "DRUID",
+
+ [253] = "HUNTER",
+ [254] = "HUNTER",
+ [255] = "HUNTER",
+
+ [262] = "SHAMAN",
+ [263] = "SHAMAN",
+ [254] = "SHAMAN",
+
+ [256] = "PRIEST",
+ [257] = "PRIEST",
+ [258] = "PRIEST",
+
+ [265] = "WARLOCK",
+ [266] = "WARLOCK",
+ [267] = "WARLOCK",
+
+ [65] = "PALADIN",
+ [66] = "PALADIN",
+ [70] = "PALADIN",
+
+ [268] = "MONK",
+ [269] = "MONK",
+ [270] = "MONK",
+}
+
+DF.CooldownToClass = {}
+
+DF.CooldownsAttack = {}
+DF.CooldownsDeffense = {}
+DF.CooldownsExternals = {}
+DF.CooldownsRaid = {}
+
+DF.CooldownsAllDeffensive = {}
+
+for specId, cooldownTable in pairs (DF.CooldownsBySpec) do
+
+ for spellId, cooldownType in pairs (cooldownTable) do
+
+ if (cooldownType == 1) then
+ DF.CooldownsAttack [spellId] = true
+
+ elseif (cooldownType == 2) then
+ DF.CooldownsDeffense [spellId] = true
+ DF.CooldownsAllDeffensive [spellId] = true
+
+ elseif (cooldownType == 3) then
+ DF.CooldownsExternals [spellId] = true
+ DF.CooldownsAllDeffensive [spellId] = true
+
+ elseif (cooldownType == 4) then
+ DF.CooldownsRaid [spellId] = true
+ DF.CooldownsAllDeffensive [spellId] = true
+
+ elseif (cooldownType == 5) then
+
+
+ end
+
+ DF.CooldownToClass [spellId] = DF.SpecIds [spellId]
+
+ end
+
+end
+
+function DF:FindClassForCooldown (spellId)
+ for specId, cooldownTable in pairs (DF.CooldownsBySpec) do
+ local hasCooldown = cooldownTable [spellId]
+ if (hasCooldown) then
+ return DF.SpecIds [specId]
+ end
+ end
+end
+
+function DF:GetCooldownInfo (spellId)
+ return DF.CooldownsInfo [spellId]
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--consumables
+
+DF.FlaskIDs = {
+ [251836] = true, -- Flask of the Currents agility
+ [251837] = true, -- Flask of Endless Fathoms intellect
+ [251838] = true, -- Flask of the Vast Horizon stamina
+ [251839] = true, -- Flask of the Undertow strength
+}
+
+DF.FoodIDs = {
+ [257422] = 41, --Mon'Dazi versatility
+ [257413] = 41, --Ravenberry Tarts haste
+ [257418] = 41, --Loa Loaf mastery
+ [257408] = 41, --Kul Tiramisu critical
+
+ [257424] = 55, --Spiced Snapper versatility
+ [257415] = 55, --Swamp Fish 'n Chips haste
+ [257420] = 55, --Sailor's Pie mastery
+ [257410] = 55, --Honey-Glazed Haunches critical
+
+ [259448] = 75, --Galley Banquet agility
+ [259449] = 75, --Galley Banquet intellect
+ [259453] = 75, --Galley Banquet stamina
+ [259452] = 75, --Galley Banquet strength
+
+ [259454] = 100, --Bountiful Captain's Feast agility
+ [259455] = 100, --Bountiful Captain's Feast intellect
+ [259457] = 100, --Bountiful Captain's Feast stamina
+ [257427] = 100, --Bountiful Captain's Feast strength
+}
+
+DF.PotionIDs = {
+ [279152] = true, --Battle Potion of Agility
+ [279151] = true, --Battle Potion of Intellect
+ [279154] = true, --Battle Potion of Stamina
+ [279153] = true, --Battle Potion of Strength
+
+ [269853] = true, --Potion of Rising Death (range)
+ [251316] = true, --Potion of Bursting Blood (melee)
+ [251231] = true, --Steelskin Potion (tank)
+}
+
+DF.RuneIDs = {
+ [270058] = true, --Battle-Scarred Augment Rune
+}
+
+-- /dump UnitAura ("player", 1)
+-- /dump UnitAura ("player", 2)
+
+function DF:GetSpellsForEncounterFromJournal (instanceEJID, encounterEJID)
+
+ EJ_SelectInstance (instanceEJID)
+ local name, description, encounterID, rootSectionID, link = EJ_GetEncounterInfo (encounterEJID) --taloc (primeiro boss de Uldir)
+
+ if (not name) then
+ print ("DetailsFramework: Encounter Info Not Found!", instanceEJID, encounterEJID)
+ return {}
+ end
+
+ local spellIDs = {}
+
+ --overview
+ local sectionInfo = C_EncounterJournal.GetSectionInfo (rootSectionID)
+ local nextID = {sectionInfo.siblingSectionID}
+
+ while (nextID [1]) do
+ --> get the deepest section in the hierarchy
+ local ID = tremove (nextID)
+ local sectionInfo = C_EncounterJournal.GetSectionInfo (ID)
+
+ if (sectionInfo) then
+ if (sectionInfo.spellID and type (sectionInfo.spellID) == "number" and sectionInfo.spellID ~= 0) then
+ tinsert (spellIDs, sectionInfo.spellID)
+ end
+
+ local nextChild, nextSibling = sectionInfo.firstChildSectionID, sectionInfo.siblingSectionID
+ if (nextSibling) then
+ tinsert (nextID, nextSibling)
+ end
+ if (nextChild) then
+ tinsert (nextID, nextChild)
+ end
+ else
+ break
+ end
+ end
+
+ return spellIDs
+end
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/DF/split_bar.lua b/libs/DF/split_bar.lua
new file mode 100644
index 0000000..2208e02
--- /dev/null
+++ b/libs/DF/split_bar.lua
@@ -0,0 +1,666 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+
+local cleanfunction = function() end
+local APISplitBarFunctions
+
+do
+ local metaPrototype = {
+ WidgetType = "split_bar",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["split_bar"]] = _G [DF.GlobalWidgetControlNames ["split_bar"]] or metaPrototype
+end
+
+local SplitBarMetaFunctions = _G [DF.GlobalWidgetControlNames ["split_bar"]]
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ SplitBarMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ return _table.statusbar:GetValue()
+ else
+ _table.div:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
+ return _table.statusbar:SetValue (value)
+ end
+ end
+
+ SplitBarMetaFunctions.__add = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v + v2
+ v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v + v1
+ v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+ SplitBarMetaFunctions.__sub = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v - v2
+ v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v - v1
+ v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local function gmember_tooltip (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object.statusbar:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.statusbar:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.statusbar:GetHeight()
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object.statusbar:GetValue()
+ end
+ --> right text
+ local gmember_rtext = function (_object)
+ return _object.textright:GetText()
+ end
+ --> left text
+ local gmember_ltext = function (_object)
+ return _object.textleft:GetText()
+ end
+ --> right color
+ local gmember_rcolor = function (_object)
+ return _object.background.original_colors
+ end
+ --> left color
+ local gmember_lcolor = function (_object)
+ return _object.texture.original_colors
+ end
+ --> right icon
+ local gmember_ricon = function (_object)
+ return _object.iconright:GetTexture()
+ end
+ --> left icon
+ local gmember_licon = function (_object)
+ return _object.iconleft:GetTexture()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object.texture:GetTexture()
+ end
+ --> font size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.textleft:GetFont()
+ return fontsize
+ end
+ --> font face
+ local gmember_textfont = function (_object)
+ local fontface = _object.textleft:GetFont()
+ return fontface
+ end
+ --> font color
+ local gmember_textcolor = function (_object)
+ return _object.textleft:GetTextColor()
+ end
+
+ SplitBarMetaFunctions.GetMembers = SplitBarMetaFunctions.GetMembers or {}
+ SplitBarMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ SplitBarMetaFunctions.GetMembers ["shown"] = gmember_shown
+ SplitBarMetaFunctions.GetMembers ["width"] = gmember_width
+ SplitBarMetaFunctions.GetMembers ["height"] = gmember_height
+ SplitBarMetaFunctions.GetMembers ["value"] = gmember_value
+ SplitBarMetaFunctions.GetMembers ["righttext"] = gmember_rtext
+ SplitBarMetaFunctions.GetMembers ["lefttext"] = gmember_ltext
+ SplitBarMetaFunctions.GetMembers ["rightcolor"] = gmember_rcolor
+ SplitBarMetaFunctions.GetMembers ["leftcolor"] = gmember_lcolor
+ SplitBarMetaFunctions.GetMembers ["righticon"] = gmember_ricon
+ SplitBarMetaFunctions.GetMembers ["lefticon"] = gmember_licon
+ SplitBarMetaFunctions.GetMembers ["texture"] = gmember_texture
+ SplitBarMetaFunctions.GetMembers ["fontsize"] = gmember_textsize
+ SplitBarMetaFunctions.GetMembers ["fontface"] = gmember_textfont
+ SplitBarMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor
+ SplitBarMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias
+ SplitBarMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias
+ SplitBarMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias
+
+ SplitBarMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = SplitBarMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return SplitBarMetaFunctions [_member_requested]
+ end
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_shown = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (_value) then
+ return _object:Hide()
+ else
+ return _object:Show()
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.statusbar:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.statusbar:SetHeight (_value)
+ end
+ --> statusbar value
+ local smember_value = function (_object, _value)
+ _object.statusbar:SetValue (_value)
+ return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
+ end
+ --> right text
+ local smember_rtext = function (_object, _value)
+ return _object.textright:SetText (_value)
+ end
+ --> left text
+ local smember_ltext = function (_object, _value)
+ return _object.textleft:SetText (_value)
+ end
+ --> right color
+ local smember_rcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.background.original_colors = {_value1, _value2, _value3, _value4}
+ return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> left color
+ local smember_lcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+
+ _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
+ _object.texture.original_colors = {_value1, _value2, _value3, _value4}
+ return _object.texture:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> right icon
+ local smember_ricon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.iconright:SetTexture (_value1)
+ if (_value2) then
+ _object.iconright:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.iconright:SetTexture (_value)
+ end
+ return
+ end
+ --> left icon
+ local smember_licon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.iconleft:SetTexture (_value1)
+ if (_value2) then
+ _object.iconleft:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.iconleft:SetTexture (_value)
+ end
+ return
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.texture:SetTexture (_value1)
+ _object.background:SetTexture (_value1)
+ if (_value2) then
+ _object.texture:SetTexCoord (_unpack (_value2))
+ _object.background:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.texture:SetTexture (_value)
+ _object.background:SetTexture (_value)
+ end
+ return
+ end
+ --> font face
+ local smember_textfont = function (_object, _value)
+ DF:SetFontFace (_object.textleft, _value)
+ return DF:SetFontFace (_object.textright, _value)
+ end
+ --> font size
+ local smember_textsize = function (_object, _value)
+ DF:SetFontSize (_object.textleft, _value)
+ return DF:SetFontSize (_object.textright, _value)
+ end
+ --> font color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
+ return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+ SplitBarMetaFunctions.SetMembers = SplitBarMetaFunctions.SetMembers or {}
+ SplitBarMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
+ SplitBarMetaFunctions.SetMembers ["shown"] = smember_shown
+ SplitBarMetaFunctions.SetMembers ["width"] = smember_width
+ SplitBarMetaFunctions.SetMembers ["height"] = smember_height
+ SplitBarMetaFunctions.SetMembers ["value"] = smember_value
+ SplitBarMetaFunctions.SetMembers ["righttext"] = smember_rtext
+ SplitBarMetaFunctions.SetMembers ["lefttext"] = smember_ltext
+ SplitBarMetaFunctions.SetMembers ["rightcolor"] = smember_rcolor
+ SplitBarMetaFunctions.SetMembers ["leftcolor"] = smember_lcolor
+ SplitBarMetaFunctions.SetMembers ["righticon"] = smember_ricon
+ SplitBarMetaFunctions.SetMembers ["lefticon"] = smember_licon
+ SplitBarMetaFunctions.SetMembers ["texture"] = smember_texture
+ SplitBarMetaFunctions.SetMembers ["fontsize"] = smember_textsize
+ SplitBarMetaFunctions.SetMembers ["fontface"] = smember_textfont
+ SplitBarMetaFunctions.SetMembers ["fontcolor"] = smember_textcolor
+ SplitBarMetaFunctions.SetMembers ["textsize"] = smember_textsize --alias
+ SplitBarMetaFunctions.SetMembers ["textfont"] = smember_textfont --alias
+ SplitBarMetaFunctions.SetMembers ["textcolor"] = smember_textcolor --alias
+
+ SplitBarMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = SplitBarMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function SplitBarMetaFunctions:Show()
+ return self.statusbar:Show()
+ end
+ function SplitBarMetaFunctions:Hide()
+ return self.statusbar:Hide()
+ end
+
+-- set split
+ function SplitBarMetaFunctions:SetSplit (value)
+ if (not value) then
+ value = self.statusbar:GetValue()
+ elseif (value < 0 or value > 100) then
+ return
+ end
+ self.statusbar:SetValue (value)
+ self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
+ end
+
+-- setpoint
+ function SplitBarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function SplitBarMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.statusbar:SetWidth (w)
+ end
+ if (h) then
+ self.statusbar:SetHeight (h)
+ end
+ end
+
+-- texture
+ function SplitBarMetaFunctions:SetTexture (texture)
+ self.background:SetTexture (texture)
+ self.texture:SetTexture (texture)
+ end
+
+-- texts
+ function SplitBarMetaFunctions:SetLeftText (text)
+ self.textleft:SetText (text)
+ end
+ function SplitBarMetaFunctions:SetRightText (text)
+ self.textright:SetText (text)
+ end
+
+-- colors
+ function SplitBarMetaFunctions:SetLeftColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self.texture:SetVertexColor (r, g, b, a)
+ self.texture.original_colors = {r, g, b, a}
+ end
+ function SplitBarMetaFunctions:SetRightColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self.background:SetVertexColor (r, g, b, a)
+ self.background.original_colors = {r, g, b, a}
+ end
+
+-- icons
+ function SplitBarMetaFunctions:SetLeftIcon (texture, ...)
+ self.iconleft:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = unpack (...)
+ self.iconleft:SetTexCoord (L, R, U, D)
+ end
+ end
+ function SplitBarMetaFunctions:SetRightIcon (texture, ...)
+ self.iconright:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = unpack (...)
+ self.iconright:SetTexCoord (L, R, U, D)
+ end
+ end
+
+-- tooltip
+ function SplitBarMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function SplitBarMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function SplitBarMetaFunctions:GetFrameLevel()
+ return self.statusbar:GetFrameLevel()
+ end
+ function SplitBarMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.statusbar:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.statusbar:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function SplitBarMetaFunctions:SetFrameStrata()
+ return self.statusbar:GetFrameStrata()
+ end
+ function SplitBarMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.statusbar:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.statusbar:SetFrameStrata (strata)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+ local OnEnter = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 18, 0)
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (frame, "tooltip")
+ end
+ end
+
+ local OnLeave = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ DF.popup:ShowMe (false)
+ end
+ end
+
+ local OnHide = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnShow = function (frame)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+ end
+
+ local OnMouseUp = function (frame, button)
+ local capsule = frame.MyObject
+ local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
+ if (kill) then
+ return
+ end
+
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+
+ local OnSizeChanged = function (statusbar)
+ statusbar.MyObject.div:SetPoint ("left", statusbar, "left", statusbar:GetValue() * (statusbar:GetWidth()/100) - 18, 0)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DetailsFrameworkSplitlBar_OnCreate (self)
+ self.texture.original_colors = {1, 1, 1, 1}
+ self.background.original_colors = {.5, .5, .5, 1}
+ self.spark:SetPoint ("left", self, "left", self:GetValue() * (self:GetWidth()/100) - 18, 0)
+ return true
+end
+
+function DF:CreateSplitBar (parent, parent, w, h, member, name)
+ return DF:NewSplitBar (parent, container, name, member, w, h)
+end
+
+local build_statusbar = function (self)
+ self:SetSize (300, 14)
+
+ self.background = self:CreateTexture ("$parent_StatusBarBackground", "BACKGROUND")
+ self.background:SetAllPoints()
+ self.background:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+ self.background:SetVertexColor (.5, .5, .5, 1)
+
+ self.texture = self:CreateTexture ("$parent_StatusBarTexture", "ARTWORK")
+ self.texture:Hide()
+ self.texture:SetSize (300, 14)
+ self.texture:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
+
+ self.lefticon = self:CreateTexture ("$parent_IconLeft", "OVERLAY")
+ self.lefticon:SetSize (14, 14)
+ self.lefticon:SetPoint ("LEFT", self, "LEFT")
+
+ self.righticon = self:CreateTexture ("$parent_IconRight", "OVERLAY")
+ self.righticon:SetSize (14, 14)
+ self.righticon:SetPoint ("RIGHT", self, "RIGHT")
+
+ self.spark = self:CreateTexture ("$parent_Spark", "OVERLAY")
+ self.spark:SetTexture ([[Interface\CastingBar\UI-CastingBar-Spark]])
+ self.spark:SetBlendMode ("ADD")
+ self.spark:SetSize (32, 32)
+ self.spark:SetPoint ("LEFT", self, "RIGHT", -17, -1)
+
+ self.lefttext = self:CreateFontString ("$parent_TextLeft", "OVERLAY", "GameFontHighlight")
+ DF:SetFontSize (self.lefttext, 10)
+ self.lefttext:SetJustifyH ("left")
+ self.lefttext:SetPoint ("LEFT", self.lefticon, "RIGHT", 3, 0)
+
+ self.righttext = self:CreateFontString ("$parent_TextRight", "OVERLAY", "GameFontHighlight")
+ DF:SetFontSize (self.righttext, 10)
+ self.righttext:SetJustifyH ("right")
+ self.righttext:SetPoint ("RIGHT", self.righticon, "LEFT", -3, 0)
+
+ self:SetStatusBarTexture (self.texture)
+ self:SetMinMaxValues (1, 100)
+ self:SetValue (50)
+ DetailsFrameworkSplitlBar_OnCreate (self)
+end
+
+
+function DF:NewSplitBar (parent, container, name, member, w, h)
+
+ if (not name) then
+ name = "DetailsFrameworkSplitbar" .. DF.SplitBarCounter
+ DF.SplitBarCounter = DF.SplitBarCounter + 1
+ end
+ if (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local SplitBarObject = {type = "barsplit", dframework = true}
+
+ if (member) then
+ parent [member] = SplitBarObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> misc
+ SplitBarObject.locked = false
+ SplitBarObject.container = container
+
+ --> create widgets
+ SplitBarObject.statusbar = CreateFrame ("statusbar", name, parent)
+ build_statusbar (SplitBarObject.statusbar)
+ SplitBarObject.widget = SplitBarObject.statusbar
+
+ if (not APISplitBarFunctions) then
+ APISplitBarFunctions = true
+ local idx = getmetatable (SplitBarObject.statusbar).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not SplitBarMetaFunctions [funcName]) then
+ SplitBarMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.statusbar:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ SplitBarObject.statusbar:SetHeight (h or 200)
+ SplitBarObject.statusbar:SetWidth (w or 14)
+
+ SplitBarObject.statusbar.MyObject = SplitBarObject
+
+ SplitBarObject.textleft = _G [name .. "_TextLeft"]
+ SplitBarObject.textright = _G [name .. "_TextRight"]
+
+ SplitBarObject.iconleft = _G [name .. "_IconLeft"]
+ SplitBarObject.iconright = _G [name .. "_IconRight"]
+
+ SplitBarObject.background = _G [name .. "_StatusBarBackground"]
+ SplitBarObject.texture = _G [name .. "_StatusBarTexture"]
+
+ SplitBarObject.div = _G [name .. "_Spark"]
+
+
+ --> hooks
+ SplitBarObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnMouseDown = {},
+ OnMouseUp = {},
+ OnSizeChanged = {},
+ }
+
+ SplitBarObject.statusbar:SetScript ("OnEnter", OnEnter)
+ SplitBarObject.statusbar:SetScript ("OnLeave", OnLeave)
+ SplitBarObject.statusbar:SetScript ("OnHide", OnHide)
+ SplitBarObject.statusbar:SetScript ("OnShow", OnShow)
+ SplitBarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
+ SplitBarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
+ SplitBarObject.statusbar:SetScript ("OnSizeChanged", OnSizeChanged)
+
+ _setmetatable (SplitBarObject, SplitBarMetaFunctions)
+
+ return SplitBarObject
+end
diff --git a/libs/DF/split_bar.xml b/libs/DF/split_bar.xml
new file mode 100644
index 0000000..1ca5f88
--- /dev/null
+++ b/libs/DF/split_bar.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/libs/DF/textentry.lua b/libs/DF/textentry.lua
new file mode 100644
index 0000000..f532ead
--- /dev/null
+++ b/libs/DF/textentry.lua
@@ -0,0 +1,2458 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+local _string_len = string.len --> lua local
+
+
+local cleanfunction = function() end
+local APITextEntryFunctions = false
+
+do
+ local metaPrototype = {
+ WidgetType = "textentry",
+ SetHook = DF.SetHook,
+ RunHooksForWidget = DF.RunHooksForWidget,
+ }
+
+ _G [DF.GlobalWidgetControlNames ["textentry"]] = _G [DF.GlobalWidgetControlNames ["textentry"]] or metaPrototype
+end
+
+local TextEntryMetaFunctions = _G [DF.GlobalWidgetControlNames ["textentry"]]
+DF.TextEntryCounter = DF.TextEntryCounter or 1
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ TextEntryMetaFunctions.__call = function (_table, value)
+ --> unknow
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.editbox:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.editbox:GetHeight()
+ end
+ --> get text
+ local gmember_text = function (_object)
+ return _object.editbox:GetText()
+ end
+
+ TextEntryMetaFunctions.GetMembers = TextEntryMetaFunctions.GetMembers or {}
+ TextEntryMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
+ TextEntryMetaFunctions.GetMembers ["shown"] = gmember_shown
+ TextEntryMetaFunctions.GetMembers ["width"] = gmember_width
+ TextEntryMetaFunctions.GetMembers ["height"] = gmember_height
+ TextEntryMetaFunctions.GetMembers ["text"] = gmember_text
+
+ TextEntryMetaFunctions.__index = function (_table, _member_requested)
+ local func = TextEntryMetaFunctions.GetMembers [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return TextEntryMetaFunctions [_member_requested]
+ end
+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.editbox:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.editbox:SetHeight (_value)
+ end
+ --> set text
+ local smember_text = function (_object, _value)
+ return _object.editbox:SetText (_value)
+ end
+ --> set multiline
+ local smember_multiline = function (_object, _value)
+ if (_value) then
+ return _object.editbox:SetMultiLine (true)
+ else
+ return _object.editbox:SetMultiLine (false)
+ end
+ end
+ --> text horizontal pos
+ local smember_horizontalpos = function (_object, _value)
+ return _object.editbox:SetJustifyH (string.lower (_value))
+ end
+
+ TextEntryMetaFunctions.SetMembers = TextEntryMetaFunctions.SetMembers or {}
+ TextEntryMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
+ TextEntryMetaFunctions.SetMembers ["show"] = smember_show
+ TextEntryMetaFunctions.SetMembers ["hide"] = smember_hide
+ TextEntryMetaFunctions.SetMembers ["width"] = smember_width
+ TextEntryMetaFunctions.SetMembers ["height"] = smember_height
+ TextEntryMetaFunctions.SetMembers ["text"] = smember_text
+ TextEntryMetaFunctions.SetMembers ["multiline"] = smember_multiline
+ TextEntryMetaFunctions.SetMembers ["align"] = smember_horizontalpos
+
+ TextEntryMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = TextEntryMetaFunctions.SetMembers [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+ local cleanfunction = function()end
+ function TextEntryMetaFunctions:SetEnterFunction (func, param1, param2)
+ if (func) then
+ _rawset (self, "func", func)
+ else
+ _rawset (self, "func", cleanfunction)
+ end
+
+ if (param1 ~= nil) then
+ _rawset (self, "param1", param1)
+ end
+ if (param2 ~= nil) then
+ _rawset (self, "param2", param2)
+ end
+ end
+
+--> set point
+ function TextEntryMetaFunctions:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y, Width)
+
+ if (type (MyAnchor) == "boolean" and MyAnchor and self.space) then
+ local textWidth = self.label:GetStringWidth()+2
+ self.editbox:SetWidth (self.space - textWidth - 15)
+ return
+
+ elseif (type (MyAnchor) == "boolean" and MyAnchor and not self.space) then
+ self.space = self.label:GetStringWidth()+2 + self.editbox:GetWidth()
+ end
+
+ if (Width) then
+ self.space = Width
+ end
+
+ MyAnchor, SnapTo, HisAnchor, x, y = DF:CheckPoints (MyAnchor, SnapTo, HisAnchor, x, y, self)
+ if (not MyAnchor) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+
+ if (self.space) then
+ self.label:ClearAllPoints()
+ self.editbox:ClearAllPoints()
+
+ self.label:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
+ self.editbox:SetPoint ("left", self.label, "right", 2, 0)
+
+ local textWidth = self.label:GetStringWidth()+2
+ self.editbox:SetWidth (self.space - textWidth - 15)
+ else
+ self.label:ClearAllPoints()
+ self.editbox:ClearAllPoints()
+ self.editbox:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
+ end
+
+ end
+
+ function TextEntryMetaFunctions:SetText (text)
+ self.editbox:SetText (text)
+ end
+ function TextEntryMetaFunctions:GetText()
+ return self.editbox:GetText()
+ end
+
+--> frame levels
+ function TextEntryMetaFunctions:GetFrameLevel()
+ return self.editbox:GetFrameLevel()
+ end
+ function TextEntryMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.editbox:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.editbox:SetFrameLevel (framelevel)
+ end
+ end
+
+--> select all text
+ function TextEntryMetaFunctions:SelectAll()
+ self.editbox:HighlightText()
+ end
+
+--> set labal description
+ function TextEntryMetaFunctions:SetLabelText (text)
+ if (text) then
+ self.label:SetText (text)
+ else
+ self.label:SetText ("")
+ end
+ self:SetPoint (true) --> refresh
+ end
+
+--> set tab order
+ function TextEntryMetaFunctions:SetNext (nextbox)
+ self.next = nextbox
+ end
+
+--> blink
+ function TextEntryMetaFunctions:Blink()
+ self.label:SetTextColor (1, .2, .2, 1)
+ end
+
+--> show & hide
+ function TextEntryMetaFunctions:IsShown()
+ return self.editbox:IsShown()
+ end
+ function TextEntryMetaFunctions:Show()
+ return self.editbox:Show()
+ end
+ function TextEntryMetaFunctions:Hide()
+ return self.editbox:Hide()
+ end
+
+-- tooltip
+ function TextEntryMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function TextEntryMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+--> hooks
+ function TextEntryMetaFunctions:Enable()
+ if (not self.editbox:IsEnabled()) then
+ self.editbox:Enable()
+ self.editbox:SetBackdropBorderColor (unpack (self.enabled_border_color))
+ self.editbox:SetBackdropColor (unpack (self.enabled_backdrop_color))
+ self.editbox:SetTextColor (unpack (self.enabled_text_color))
+ if (self.editbox.borderframe) then
+ self.editbox.borderframe:SetBackdropColor (unpack (self.editbox.borderframe.onleave_backdrop))
+ end
+ end
+ end
+
+ function TextEntryMetaFunctions:Disable()
+ if (self.editbox:IsEnabled()) then
+ self.enabled_border_color = {self.editbox:GetBackdropBorderColor()}
+ self.enabled_backdrop_color = {self.editbox:GetBackdropColor()}
+ self.enabled_text_color = {self.editbox:GetTextColor()}
+
+ self.editbox:Disable()
+
+ self.editbox:SetBackdropBorderColor (.5, .5, .5, .5)
+ self.editbox:SetBackdropColor (.5, .5, .5, .5)
+ self.editbox:SetTextColor (.5, .5, .5, .5)
+
+ if (self.editbox.borderframe) then
+ self.editbox.borderframe:SetBackdropColor (.5, .5, .5, .5)
+ end
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts and hooks
+
+ local OnEnter = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnEnter", textentry, capsule)
+ if (kill) then
+ return
+ end
+
+ if (capsule.have_tooltip) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine (capsule.have_tooltip)
+ GameCooltip2:ShowCooltip (textentry, "tooltip")
+ end
+
+ textentry.mouse_over = true
+
+ if (textentry:IsEnabled()) then
+ textentry.current_bordercolor = textentry.current_bordercolor or {textentry:GetBackdropBorderColor()}
+ textentry:SetBackdropBorderColor (1, 1, 1, 1)
+ end
+ end
+
+ local OnLeave = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnLeave", textentry, capsule)
+ if (kill) then
+ return
+ end
+
+ if (textentry.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ textentry.mouse_over = false
+
+ if (textentry:IsEnabled()) then
+ textentry:SetBackdropBorderColor (unpack (textentry.current_bordercolor))
+ end
+ end
+
+ local OnHide = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnHide", textentry, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnShow = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnShow", textentry, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnEnterPressed = function (textentry, byScript)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnEnterPressed", textentry, capsule, capsule.text)
+ if (kill) then
+ return
+ end
+
+ local texto = DF:trim (textentry:GetText())
+ if (_string_len (texto) > 0) then
+ textentry.text = texto
+ if (textentry.MyObject.func) then
+ textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, byScript or textentry)
+ end
+ else
+ textentry:SetText ("")
+ textentry.MyObject.currenttext = ""
+ end
+
+ if (not capsule.NoClearFocusOnEnterPressed) then
+ textentry.focuslost = true --> quando estiver editando e clicar em outra caixa
+ textentry:ClearFocus()
+
+ if (textentry.MyObject.tab_on_enter and textentry.MyObject.next) then
+ textentry.MyObject.next:SetFocus()
+ end
+ end
+ end
+
+ local OnEscapePressed = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnEscapePressed", textentry, capsule, capsule.text)
+ if (kill) then
+ return
+ end
+
+ textentry.focuslost = true
+ textentry:ClearFocus()
+ end
+
+ local OnSpacePressed = function (textentry)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnSpacePressed", textentry, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnEditFocusLost = function (textentry)
+
+ local capsule = textentry.MyObject
+
+ if (textentry:IsShown()) then
+
+ local kill = capsule:RunHooksForWidget ("OnEditFocusLost", textentry, capsule, capsule.text)
+ if (kill) then
+ return
+ end
+
+ if (not textentry.focuslost) then
+ local texto = DF:trim (textentry:GetText())
+ if (_string_len (texto) > 0) then
+ textentry.MyObject.currenttext = texto
+ if (textentry.MyObject.func) then
+ textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, nil)
+ end
+ else
+ textentry:SetText ("")
+ textentry.MyObject.currenttext = ""
+ end
+ else
+ textentry.focuslost = false
+ end
+
+ textentry.MyObject.label:SetTextColor (.8, .8, .8, 1)
+
+ end
+ end
+
+ local OnEditFocusGained = function (textentry)
+
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnEditFocusGained", textentry, capsule)
+ if (kill) then
+ return
+ end
+
+ textentry.MyObject.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ local OnChar = function (textentry, char)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnChar", textentry, char, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnTextChanged = function (textentry, byUser)
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnTextChanged", textentry, byUser, capsule)
+ if (kill) then
+ return
+ end
+ end
+
+ local OnTabPressed = function (textentry)
+
+ local capsule = textentry.MyObject
+
+ local kill = capsule:RunHooksForWidget ("OnTabPressed", textentry, byUser, capsule)
+ if (kill) then
+ return
+ end
+
+ if (textentry.MyObject.next) then
+ OnEnterPressed (textentry, false)
+ textentry.MyObject.next:SetFocus()
+ end
+ end
+
+ function TextEntryMetaFunctions:PressEnter (byScript)
+ OnEnterPressed (self.editbox, byScript)
+ end
+
+------------------------------------------------------------------------------------------------------------
+
+function TextEntryMetaFunctions:SetTemplate (template)
+ if (template.width) then
+ self.editbox:SetWidth (template.width)
+ end
+ if (template.height) then
+ self.editbox:SetHeight (template.height)
+ end
+
+ if (template.backdrop) then
+ self.editbox:SetBackdrop (template.backdrop)
+ end
+ if (template.backdropcolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropcolor)
+ self.editbox:SetBackdropColor (r, g, b, a)
+ self.onleave_backdrop = {r, g, b, a}
+ end
+ if (template.backdropbordercolor) then
+ local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
+ self.editbox:SetBackdropBorderColor (r, g, b, a)
+ self.editbox.current_bordercolor[1] = r
+ self.editbox.current_bordercolor[2] = g
+ self.editbox.current_bordercolor[3] = b
+ self.editbox.current_bordercolor[4] = a
+ self.onleave_backdrop_border_color = {r, g, b, a}
+ end
+end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateTextEntry (parent, func, w, h, member, name, with_label, entry_template, label_template)
+ return DF:NewTextEntry (parent, parent, name, member, w, h, func, nil, nil, nil, with_label, entry_template, label_template)
+end
+
+function DF:NewTextEntry (parent, container, name, member, w, h, func, param1, param2, space, with_label, entry_template, label_template)
+
+ if (not name) then
+ name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter
+ DF.TextEntryCounter = DF.TextEntryCounter + 1
+
+ elseif (not parent) then
+ return error ("Details! FrameWork: parent not found.", 2)
+ end
+
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local TextEntryObject = {type = "textentry", dframework = true}
+
+ if (member) then
+ parent [member] = TextEntryObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> hooks
+ TextEntryObject.OnEnterHook = nil
+ TextEntryObject.OnLeaveHook = nil
+ TextEntryObject.OnHideHook = nil
+ TextEntryObject.OnShowHook = nil
+ TextEntryObject.OnEnterPressedHook = nil
+ TextEntryObject.OnEscapePressedHook = nil
+ TextEntryObject.OnEditFocusGainedHook = nil
+ TextEntryObject.OnEditFocusLostHook = nil
+ TextEntryObject.OnCharHook = nil
+ TextEntryObject.OnTextChangedHook = nil
+ TextEntryObject.OnTabPressedHook = nil
+
+ --> misc
+ TextEntryObject.container = container
+ TextEntryObject.have_tooltip = nil
+
+ TextEntryObject.editbox = CreateFrame ("EditBox", name, parent)
+ TextEntryObject.editbox:SetSize (232, 20)
+ TextEntryObject.editbox:SetBackdrop ({bgFile = [["Interface\DialogFrame\UI-DialogBox-Background"]], tileSize = 64, tile = true, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10, insets = {left = 1, right = 1, top = 0, bottom = 0}})
+
+ TextEntryObject.editbox.label = TextEntryObject.editbox:CreateFontString ("$parent_Desc", "OVERLAY", "GameFontHighlightSmall")
+ TextEntryObject.editbox.label:SetJustifyH ("left")
+ TextEntryObject.editbox.label:SetPoint ("RIGHT", TextEntryObject.editbox, "LEFT", -2, 0)
+
+ TextEntryObject.widget = TextEntryObject.editbox
+
+ TextEntryObject.editbox:SetTextInsets (3, 0, 0, -3)
+
+ if (not APITextEntryFunctions) then
+ APITextEntryFunctions = true
+ local idx = getmetatable (TextEntryObject.editbox).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not TextEntryMetaFunctions [funcName]) then
+ TextEntryMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G['"..object.editbox:GetName().."']:"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ TextEntryObject.editbox.MyObject = TextEntryObject
+
+ if (not w and space) then
+ w = space
+ elseif (w and space) then
+ if (DF.debug) then
+ --print ("warning: you are using width and space, try use only space for better results.")
+ end
+ end
+
+ TextEntryObject.editbox:SetWidth (w)
+ TextEntryObject.editbox:SetHeight (h)
+
+ TextEntryObject.editbox:SetJustifyH ("center")
+ TextEntryObject.editbox:EnableMouse (true)
+ TextEntryObject.editbox:SetText ("")
+
+ TextEntryObject.editbox:SetAutoFocus (false)
+ TextEntryObject.editbox:SetFontObject ("GameFontHighlightSmall")
+
+ TextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7}
+ TextEntryObject.editbox:SetBackdropBorderColor (1, 1, 1, 0.7)
+ TextEntryObject.enabled_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()}
+ TextEntryObject.enabled_backdrop_color = {TextEntryObject.editbox:GetBackdropColor()}
+ TextEntryObject.enabled_text_color = {TextEntryObject.editbox:GetTextColor()}
+ TextEntryObject.onleave_backdrop = {TextEntryObject.editbox:GetBackdropColor()}
+ TextEntryObject.onleave_backdrop_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()}
+
+ TextEntryObject.func = func
+ TextEntryObject.param1 = param1
+ TextEntryObject.param2 = param2
+ TextEntryObject.next = nil
+ TextEntryObject.space = space
+ TextEntryObject.tab_on_enter = false
+
+ TextEntryObject.label = _G [name .. "_Desc"]
+
+ TextEntryObject.editbox:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}})
+
+ --> hooks
+
+ TextEntryObject.HookList = {
+ OnEnter = {},
+ OnLeave = {},
+ OnHide = {},
+ OnShow = {},
+ OnEnterPressed = {},
+ OnEscapePressed = {},
+ OnSpacePressed = {},
+ OnEditFocusLost = {},
+ OnEditFocusGained = {},
+ OnChar = {},
+ OnTextChanged = {},
+ OnTabPressed = {},
+ }
+
+ TextEntryObject.editbox:SetScript ("OnEnter", OnEnter)
+ TextEntryObject.editbox:SetScript ("OnLeave", OnLeave)
+ TextEntryObject.editbox:SetScript ("OnHide", OnHide)
+ TextEntryObject.editbox:SetScript ("OnShow", OnShow)
+
+ TextEntryObject.editbox:SetScript ("OnEnterPressed", OnEnterPressed)
+ TextEntryObject.editbox:SetScript ("OnEscapePressed", OnEscapePressed)
+ TextEntryObject.editbox:SetScript ("OnSpacePressed", OnSpacePressed)
+ TextEntryObject.editbox:SetScript ("OnEditFocusLost", OnEditFocusLost)
+ TextEntryObject.editbox:SetScript ("OnEditFocusGained", OnEditFocusGained)
+ TextEntryObject.editbox:SetScript ("OnChar", OnChar)
+ TextEntryObject.editbox:SetScript ("OnTextChanged", OnTextChanged)
+ TextEntryObject.editbox:SetScript ("OnTabPressed", OnTabPressed)
+
+ _setmetatable (TextEntryObject, TextEntryMetaFunctions)
+
+ if (with_label) then
+ local label = DF:CreateLabel (TextEntryObject.editbox, with_label, nil, nil, nil, "label", nil, "overlay")
+ label.text = with_label
+ TextEntryObject.editbox:SetPoint ("left", label.widget, "right", 2, 0)
+ if (label_template) then
+ label:SetTemplate (label_template)
+ end
+ with_label = label
+ end
+
+ if (entry_template) then
+ TextEntryObject:SetTemplate (entry_template)
+ end
+
+ return TextEntryObject, with_label
+
+end
+
+function DF:NewSpellEntry (parent, func, w, h, param1, param2, member, name)
+ local editbox = DF:NewTextEntry (parent, parent, name, member, w, h, func, param1, param2)
+
+-- editbox:SetHook ("OnEditFocusGained", SpellEntryOnEditFocusGained)
+-- editbox:SetHook ("OnTextChanged", SpellEntryOnTextChanged)
+
+ return editbox
+end
+
+local function_gettext = function (self)
+ return self.editbox:GetText()
+end
+local function_settext = function (self, text)
+ return self.editbox:SetText (text)
+end
+local function_clearfocus = function (self)
+ return self.editbox:ClearFocus()
+end
+local function_setfocus = function (self)
+ return self.editbox:SetFocus (true)
+end
+
+
+
+
+------------------------------------------------------------------------------------
+--auto complete
+
+-- block -------------------
+--code author Saiket from http://www.wowinterface.com/forums/showpost.php?p=245759&postcount=6
+--- @return StartPos, EndPos of highlight in this editbox.
+local function GetTextHighlight ( self )
+ local Text, Cursor = self:GetText(), self:GetCursorPosition();
+ self:Insert( "" ); -- Delete selected text
+ local TextNew, CursorNew = self:GetText(), self:GetCursorPosition();
+ -- Restore previous text
+ self:SetText( Text );
+ self:SetCursorPosition( Cursor );
+ local Start, End = CursorNew, #Text - ( #TextNew - CursorNew );
+ self:HighlightText( Start, End );
+ return Start, End;
+end
+local StripColors;
+do
+ local CursorPosition, CursorDelta;
+ --- Callback for gsub to remove unescaped codes.
+ local function StripCodeGsub ( Escapes, Code, End )
+ if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code
+ if ( CursorPosition and CursorPosition >= End - 1 ) then
+ CursorDelta = CursorDelta - #Code;
+ end
+ return Escapes;
+ end
+ end
+ --- Removes a single escape sequence.
+ local function StripCode ( Pattern, Text, OldCursor )
+ CursorPosition, CursorDelta = OldCursor, 0;
+ return Text:gsub( Pattern, StripCodeGsub ), OldCursor and CursorPosition + CursorDelta;
+ end
+ --- Strips Text of all color escape sequences.
+ -- @param Cursor Optional cursor position to keep track of.
+ -- @return Stripped text, and the updated cursor position if Cursor was given.
+ function StripColors ( Text, Cursor )
+ Text, Cursor = StripCode( "(|*)(|c%x%x%x%x%x%x%x%x)()", Text, Cursor );
+ return StripCode( "(|*)(|r)()", Text, Cursor );
+ end
+end
+
+local COLOR_END = "|r";
+--- Wraps this editbox's selected text with the given color.
+local function ColorSelection ( self, ColorCode )
+ local Start, End = GetTextHighlight( self );
+ local Text, Cursor = self:GetText(), self:GetCursorPosition();
+ if ( Start == End ) then -- Nothing selected
+ --Start, End = Cursor, Cursor; -- Wrap around cursor
+ return; -- Wrapping the cursor in a color code and hitting backspace crashes the client!
+ end
+ -- Find active color code at the end of the selection
+ local ActiveColor;
+ if ( End < #Text ) then -- There is text to color after the selection
+ local ActiveEnd;
+ local CodeEnd, _, Escapes, Color = 0;
+ while ( true ) do
+ _, CodeEnd, Escapes, Color = Text:find( "(|*)(|c%x%x%x%x%x%x%x%x)", CodeEnd + 1 );
+ if ( not CodeEnd or CodeEnd > End ) then
+ break;
+ end
+ if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code
+ ActiveColor, ActiveEnd = Color, CodeEnd;
+ end
+ end
+
+ if ( ActiveColor ) then
+ -- Check if color gets terminated before selection ends
+ CodeEnd = 0;
+ while ( true ) do
+ _, CodeEnd, Escapes = Text:find( "(|*)|r", CodeEnd + 1 );
+ if ( not CodeEnd or CodeEnd > End ) then
+ break;
+ end
+ if ( CodeEnd > ActiveEnd and #Escapes % 2 == 0 ) then -- Terminates ActiveColor
+ ActiveColor = nil;
+ break;
+ end
+ end
+ end
+ end
+
+ local Selection = Text:sub( Start + 1, End );
+ -- Remove color codes from the selection
+ local Replacement, CursorReplacement = StripColors( Selection, Cursor - Start );
+
+ self:SetText( ( "" ):join(
+ Text:sub( 1, Start ),
+ ColorCode, Replacement, COLOR_END,
+ ActiveColor or "", Text:sub( End + 1 )
+ ) );
+
+ -- Restore cursor and highlight, adjusting for wrapper text
+ Cursor = Start + CursorReplacement;
+ if ( CursorReplacement > 0 ) then -- Cursor beyond start of color code
+ Cursor = Cursor + #ColorCode;
+ end
+ if ( CursorReplacement >= #Replacement ) then -- Cursor beyond end of color
+ Cursor = Cursor + #COLOR_END;
+ end
+
+ self:SetCursorPosition( Cursor );
+ -- Highlight selection and wrapper
+ self:HighlightText( Start, #ColorCode + ( #Replacement - #Selection ) + #COLOR_END + End );
+end
+-- end of the block ---------------------
+
+local get_last_word = function (self)
+ self.lastword = ""
+ local cursor_pos = self.editbox:GetCursorPosition()
+ local text = self.editbox:GetText()
+ for i = cursor_pos, 1, -1 do
+ local character = text:sub (i, i)
+ if (character:match ("%a")) then
+ self.lastword = character .. self.lastword
+ --print (self.lastword)
+ else
+ break
+ end
+ end
+end
+
+--On Text Changed
+local AutoComplete_OnTextChanged = function (editboxWidget, byUser, capsule)
+ capsule = capsule or editboxWidget.MyObject or editboxWidget
+
+ local chars_now = editboxWidget:GetText():len()
+ if (not editboxWidget.ignore_textchange) then
+ --> backspace
+ if (chars_now == capsule.characters_count -1) then
+ capsule.lastword = capsule.lastword:sub (1, capsule.lastword:len()-1)
+ --> delete lots of text
+ elseif (chars_now < capsule.characters_count) then
+ --o auto complete selecionou outra palavra bem menor e caiu nesse filtro
+ editboxWidget.end_selection = nil
+ capsule:GetLastWord()
+ end
+ else
+ editboxWidget.ignore_textchange = nil
+ end
+ capsule.characters_count = chars_now
+end
+
+local AutoComplete_OnSpacePressed = function (editboxWidget, capsule)
+ capsule = capsule or editboxWidget.MyObject or editboxWidget
+
+-- if (not gotMatch) then
+ --editboxWidget.end_selection = nil
+-- end
+end
+
+local AutoComplete_OnEscapePressed = function (editboxWidget)
+ editboxWidget.end_selection = nil
+end
+
+local AutoComplete_OnEnterPressed = function (editboxWidget)
+
+ local capsule = editboxWidget.MyObject or editboxWidget
+ if (editboxWidget.end_selection) then
+ editboxWidget:SetCursorPosition (editboxWidget.end_selection)
+ editboxWidget:HighlightText (0, 0)
+ editboxWidget.end_selection = nil
+ --editboxWidget:Insert (" ") --estava causando a adi��o de uma palavra a mais quando o pr�ximo catactere for um espa�o
+ else
+ if (editboxWidget:IsMultiLine()) then
+ editboxWidget:Insert ("\n")
+ --reseta a palavra se acabou de ganhar focus e apertou enter
+ if (editboxWidget.focusGained) then
+ capsule.lastword = ""
+ editboxWidget.focusGained = nil
+ end
+ else
+ editboxWidget:Insert ("")
+ editboxWidget.focuslost = true
+ editboxWidget:ClearFocus()
+ end
+ end
+ capsule.lastword = ""
+
+end
+
+local AutoComplete_OnEditFocusGained = function (editboxWidget)
+ local capsule = editboxWidget.MyObject or editboxWidget
+ capsule:GetLastWord()
+ --print ("last word:", editboxWidget.lastword)
+ editboxWidget.end_selection = nil
+ editboxWidget.focusGained = true
+ capsule.characters_count = editboxWidget:GetText():len()
+end
+
+local OptimizeAutoCompleteTable = function (self, wordList)
+ local optimizedTable = {}
+
+ local lower = string.lower
+ local sub = string.sub
+ local len = string.len
+
+ local subTables = 0
+
+ for i = 1, #wordList do
+ local thisWord = wordList [i]
+ if (len (thisWord) > 0) then
+ thisWord = lower (thisWord)
+
+ local firstCharacter = sub (thisWord, 1, 1)
+
+ local charTable = optimizedTable [firstCharacter]
+ if (not charTable) then
+ charTable = {}
+ optimizedTable [firstCharacter] = charTable
+
+ subTables = subTables + 1
+ end
+
+ charTable [#charTable+1] = thisWord
+ end
+ end
+
+ wordList.Optimized = optimizedTable
+end
+
+local AutoComplete_OnChar = function (editboxWidget, char, capsule)
+ if (char == "") then
+ return
+ end
+
+ capsule = capsule or editboxWidget.MyObject or editboxWidget
+ editboxWidget.end_selection = nil
+
+ if (editboxWidget.ignore_input) then
+ return
+ end
+
+ --reseta a palavra se acabou de ganhar focus e apertou espa�o
+ if (editboxWidget.focusGained and char == " ") then
+ capsule.lastword = ""
+ editboxWidget.focusGained = nil
+ else
+ editboxWidget.focusGained = nil
+ end
+
+ if (char:match ("%a") or (char == " " and capsule.lastword ~= "")) then
+ capsule.lastword = capsule.lastword .. char
+ else
+ capsule.lastword = ""
+ end
+
+ editboxWidget.ignore_input = true
+
+ if (capsule.lastword:len() >= 2) then
+
+ local wordList = capsule [capsule.poolName]
+ if (not wordList) then
+ error ("Details! Framework: TextEntry has AutoComplete but no word list table.")
+ return
+ end
+
+ if (capsule.ShouldOptimizeAutoComplete) then
+ if (not wordList.Optimized) then
+ OptimizeAutoCompleteTable (capsule, wordList)
+ end
+
+ local firstCharacter = string.lower (string.sub (capsule.lastword, 1, 1))
+ wordList = wordList.Optimized [firstCharacter]
+
+ if (wordList) then
+ for i = 1, #wordList do
+ local thisWord = wordList [i]
+ if (thisWord and (thisWord:find ("^" .. capsule.lastword) or thisWord:lower():find ("^" .. capsule.lastword))) then
+ local rest = thisWord:gsub (capsule.lastword, "")
+ rest = rest:lower():gsub (capsule.lastword, "")
+ local cursor_pos = editboxWidget:GetCursorPosition()
+ editboxWidget:Insert (rest)
+ editboxWidget:HighlightText (cursor_pos, cursor_pos + rest:len())
+ editboxWidget:SetCursorPosition (cursor_pos)
+ editboxWidget.end_selection = cursor_pos + rest:len()
+ editboxWidget.ignore_textchange = true
+ break
+ end
+ end
+ end
+
+ editboxWidget.ignore_input = false
+ return
+ end
+
+ for i = 1, #wordList do
+ local thisWord = wordList [i]
+ if (thisWord and (thisWord:find ("^" .. capsule.lastword) or thisWord:lower():find ("^" .. capsule.lastword))) then
+ local rest = thisWord:gsub (capsule.lastword, "")
+ rest = rest:lower():gsub (capsule.lastword, "")
+ local cursor_pos = editboxWidget:GetCursorPosition()
+ editboxWidget:Insert (rest)
+ editboxWidget:HighlightText (cursor_pos, cursor_pos + rest:len())
+ editboxWidget:SetCursorPosition (cursor_pos)
+ editboxWidget.end_selection = cursor_pos + rest:len()
+ editboxWidget.ignore_textchange = true
+ break
+ end
+ end
+ end
+
+ editboxWidget.ignore_input = false
+end
+
+function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOptimize)
+
+ if (not self.SetHook) then
+ --self is borderframe
+ self = self.editbox
+ self.editbox = self --compatible with fw functions
+
+ self.lastword = ""
+ self.characters_count = 0
+ self.poolName = poolName
+ self.GetLastWord = get_last_word --editbox:GetLastWord()
+ self.NoClearFocusOnEnterPressed = true --avoid auto clear focus
+ self.ShouldOptimizeAutoComplete = shouldOptimize
+
+ if (poolTable) then
+ self [poolName] = poolTable
+ end
+
+ self:HookScript ("OnEditFocusGained", AutoComplete_OnEditFocusGained)
+ self:HookScript ("OnEnterPressed", AutoComplete_OnEnterPressed)
+ self:HookScript ("OnEscapePressed", AutoComplete_OnEscapePressed)
+ self:HookScript ("OnTextChanged", AutoComplete_OnTextChanged)
+ self:HookScript ("OnChar", AutoComplete_OnChar)
+ self:HookScript ("OnSpacePressed", AutoComplete_OnSpacePressed)
+ else
+ --fw textfield
+ self.lastword = ""
+ self.characters_count = 0
+ self.poolName = poolName
+ self.GetLastWord = get_last_word --editbox:GetLastWord()
+ self.NoClearFocusOnEnterPressed = true --avoid auto clear focus
+ self.ShouldOptimizeAutoComplete = shouldOptimize
+
+ self:SetHook ("OnEditFocusGained", AutoComplete_OnEditFocusGained)
+ self:SetHook ("OnEnterPressed", AutoComplete_OnEnterPressed)
+ self.editbox:HookScript ("OnEscapePressed", AutoComplete_OnEscapePressed)
+ self.editbox:SetScript ("OnTextChanged", AutoComplete_OnTextChanged)
+ self.editbox:SetScript ("OnChar", AutoComplete_OnChar)
+ self.editbox:SetScript ("OnSpacePressed", AutoComplete_OnSpacePressed)
+ end
+
+end
+
+function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
+
+ if (name:find ("$parent")) then
+ local parentName = DF.GetParentName (parent)
+ name = name:gsub ("$parent", parentName)
+ end
+
+ local borderframe = CreateFrame ("Frame", name, parent)
+ borderframe:SetSize (w, h)
+
+ if (member) then
+ parent [member] = borderframe
+ end
+
+ local scrollframe = CreateFrame ("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate")
+ scrollframe:SetSize (232, 20)
+ scrollframe.editbox = CreateFrame ("editbox", "$parentEditBox", scrollframe)
+ scrollframe.editbox:SetMultiLine (true)
+ scrollframe.editbox:SetAutoFocus (false)
+ scrollframe.editbox:SetSize (232, 20)
+ scrollframe.editbox:SetAllPoints()
+
+ scrollframe.editbox:SetScript ("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged)
+ scrollframe.editbox:SetScript ("OnEscapePressed", _G.EditBox_ClearFocus)
+ scrollframe.editbox:SetFontObject ("GameFontHighlightSmall")
+
+ scrollframe:SetScrollChild (scrollframe.editbox)
+
+ --letters="255"
+ --countInvisibleLetters="true"
+
+ borderframe.SetAsAutoComplete = TextEntryMetaFunctions.SetAsAutoComplete
+
+ scrollframe:SetScript ("OnSizeChanged", function (self)
+ scrollframe.editbox:SetSize (self:GetSize())
+ end)
+
+ scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10)
+ scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -30, 10)
+
+ scrollframe.editbox:SetMultiLine (true)
+ scrollframe.editbox:SetJustifyH ("left")
+ scrollframe.editbox:SetJustifyV ("top")
+ scrollframe.editbox:SetMaxBytes (1024000)
+ scrollframe.editbox:SetMaxLetters (128000)
+
+ borderframe.GetText = function_gettext
+ borderframe.SetText = function_settext
+ borderframe.ClearFocus = function_clearfocus
+ borderframe.SetFocus = function_setfocus
+
+ borderframe.Enable = TextEntryMetaFunctions.Enable
+ borderframe.Disable = TextEntryMetaFunctions.Disable
+
+ borderframe.SetTemplate = TextEntryMetaFunctions.SetTemplate
+
+ if (not nointent) then
+ IndentationLib.enable (scrollframe.editbox, nil, 4)
+ end
+
+ borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}})
+
+ scrollframe.editbox.current_bordercolor = {1, 1, 1, 0.7}
+ borderframe:SetBackdropBorderColor (1, 1, 1, 0.7)
+ borderframe:SetBackdropColor (0.090195, 0.090195, 0.188234, 1)
+
+ borderframe.enabled_border_color = {borderframe:GetBackdropBorderColor()}
+ borderframe.enabled_backdrop_color = {borderframe:GetBackdropColor()}
+ borderframe.enabled_text_color = {scrollframe.editbox:GetTextColor()}
+
+ borderframe.onleave_backdrop = {scrollframe.editbox:GetBackdropColor()}
+ borderframe.onleave_backdrop_border_color = {scrollframe.editbox:GetBackdropBorderColor()}
+
+ borderframe.scroll = scrollframe
+ borderframe.editbox = scrollframe.editbox
+ borderframe.editbox.borderframe = borderframe
+
+ return borderframe
+end
+
+-- encryption table
+local base64chars = {[0]='A',[1]='B',[2]='C',[3]='D',[4]='E',[5]='F',[6]='G',[7]='H',[8]='I',[9]='J',[10]='K',[11]='L',[12]='M',[13]='N',[14]='O',[15]='P',[16]='Q',[17]='R',[18]='S',[19]='T',[20]='U',[21]='V',[22]='W',[23]='X',[24]='Y',[25]='Z',[26]='a',[27]='b',[28]='c',[29]='d',[30]='e',[31]='f',[32]='g',[33]='h',[34]='i',[35]='j',[36]='k',[37]='l',[38]='m',[39]='n',[40]='o',[41]='p',[42]='q',[43]='r',[44]='s',[45]='t',[46]='u',[47]='v',[48]='w',[49]='x',[50]='y',[51]='z',[52]='0',[53]='1',[54]='2',[55]='3',[56]='4',[57]='5',[58]='6',[59]='7',[60]='8',[61]='9',[62]='-',[63]='_'}
+
+-- decryption table
+local base64bytes = {['A']=0,['B']=1,['C']=2,['D']=3,['E']=4,['F']=5,['G']=6,['H']=7,['I']=8,['J']=9,['K']=10,['L']=11,['M']=12,['N']=13,['O']=14,['P']=15,['Q']=16,['R']=17,['S']=18,['T']=19,['U']=20,['V']=21,['W']=22,['X']=23,['Y']=24,['Z']=25,['a']=26,['b']=27,['c']=28,['d']=29,['e']=30,['f']=31,['g']=32,['h']=33,['i']=34,['j']=35,['k']=36,['l']=37,['m']=38,['n']=39,['o']=40,['p']=41,['q']=42,['r']=43,['s']=44,['t']=45,['u']=46,['v']=47,['w']=48,['x']=49,['y']=50,['z']=51,['0']=52,['1']=53,['2']=54,['3']=55,['4']=56,['5']=57,['6']=58,['7']=59,['8']=60,['9']=61,['-']=62,['_']=63,['=']=nil}
+
+-- shift left
+local function lsh (value,shift)
+ return (value*(2^shift)) % 256
+end
+
+-- shift right
+local function rsh (value,shift)
+ return math.floor(value/2^shift) % 256
+end
+
+-- return single bit (for OR)
+local function bit (x,b)
+ return (x % 2^b - x % 2^(b-1) > 0)
+end
+
+local function lor (x,y)
+ result = 0
+ for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
+ return result
+end
+
+function DF.EncodeString (data)
+ local bytes = {}
+ local result = ""
+ for spos=0,string.len(data)-1,3 do
+ for byte=1,3 do bytes[byte] = string.byte(string.sub(data,(spos+byte))) or 0 end
+ result = string.format('%s%s%s%s%s',result,base64chars[rsh(bytes[1],2)],base64chars[lor(lsh((bytes[1] % 4),4), rsh(bytes[2],4))] or "=",((#data-spos) > 1) and base64chars[lor(lsh(bytes[2] % 16,2), rsh(bytes[3],6))] or "=",((#data-spos) > 2) and base64chars[(bytes[3] % 64)] or "=")
+ end
+ return result
+end
+
+function DF.DecodeString (data)
+ local chars = {}
+ local result=""
+ for dpos=0,string.len(data)-1,4 do
+ for char=1,4 do chars[char] = base64bytes[(string.sub(data,(dpos+char),(dpos+char)) or "=")] end
+ result = string.format('%s%s%s%s',result,string.char(lor(lsh(chars[1],2), rsh(chars[2],4))),(chars[3] ~= nil) and string.char(lor(lsh(chars[2],4), rsh(chars[3],2))) or "",(chars[4] ~= nil) and string.char(lor(lsh(chars[3],6) % 192, (chars[4]))) or "")
+ end
+ return result
+end
+
+
+DF.AutoCompleteAPI = {
+ "local",
+ "AddTrackedAchievement", -- [1]
+ "CanShowAchievementUI", -- [2]
+ "ClearAchievementComparisonUnit", -- [3]
+ "GetAchievementCategory", -- [4]
+ "GetAchievementComparisonInfo", -- [5]
+ "GetAchievementCriteriaInfo", -- [6]
+ "GetAchievementInfo", -- [7]
+ "GetAchievementInfoFromCriteria", -- [8]
+ "GetAchievementLink", -- [9]
+ "GetAchievementNumCriteria", -- [10]
+ "GetAchievementNumRewards", -- [11]
+ "GetCategoryInfo", -- [12]
+ "GetCategoryList", -- [13]
+ "GetCategoryNumAchievements", -- [14]
+ "GetComparisonAchievementPoints", -- [15]
+ "GetComparisonCategoryNumAchievements", -- [16]
+ "GetComparisonStatistic", -- [17]
+ "GetLatestCompletedAchievements", -- [18]
+ "GetLatestCompletedComparisonAchievements", -- [19]
+ "GetLatestUpdatedComparisonStatsGetLatestUpdatedStats", -- [20]
+ "GetNextAchievement", -- [21]
+ "GetNumComparisonCompletedAchievements", -- [22]
+ "GetNumCompletedAchievements", -- [23]
+ "GetPreviousAchievement", -- [24]
+ "GetStatistic", -- [25]
+ "GetStatisticsCategoryList", -- [26]
+ "GetTotalAchievementPoints", -- [27]
+ "GetTrackedAchievements", -- [28]
+ "GetNumTrackedAchievements", -- [29]
+ "RemoveTrackedAchievement", -- [30]
+ "SetAchievementComparisonUnit", -- [31]
+ "ActionButtonDown", -- [32]
+ "ActionButtonUp", -- [33]
+ "ActionHasRange", -- [34]
+ "CameraOrSelectOrMoveStart", -- [35]
+ "CameraOrSelectOrMoveStop", -- [36]
+ "ChangeActionBarPage", -- [37]
+ "GetActionBarPage", -- [38]
+ "GetActionBarToggles", -- [39]
+ "GetActionCooldown", -- [40]
+ "GetActionCount", -- [41]
+ "GetActionInfo", -- [42]
+ "GetActionText", -- [43]
+ "GetActionTexture", -- [44]
+ "GetBonusBarOffset", -- [45]
+ "GetMouseButtonClicked", -- [46]
+ "GetMultiCastBarOffset", -- [47]
+ "GetPossessInfo", -- [48]
+ "HasAction", -- [49]
+ "IsActionInRange", -- [50]
+ "IsAttackAction", -- [51]
+ "IsAutoRepeatAction", -- [52]
+ "IsCurrentAction", -- [53]
+ "IsConsumableAction", -- [54]
+ "IsEquippedAction", -- [55]
+ "IsUsableAction", -- [56]
+ "PetHasActionBar", -- [57]
+ "PickupAction", -- [58]
+ "PickupPetAction", -- [59]
+ "PlaceAction", -- [60]
+ "SetActionBarToggles", -- [61]
+ "StopAttack", -- [62]
+ "TurnOrActionStart", -- [63]
+ "TurnOrActionStop", -- [64]
+ "UseAction", -- [65]
+ "AcceptDuel", -- [66]
+ "AttackTarget", -- [67]
+ "CancelDuel", -- [68]
+ "CancelLogout", -- [69]
+ "ClearTutorials", -- [70]
+ "CancelSummon", -- [71]
+ "ConfirmSummon", -- [72]
+ "DescendStop", -- [73]
+ "Dismount", -- [74]
+ "FlagTutorial", -- [75]
+ "ForceQuit", -- [76]
+ "GetPVPTimer", -- [77]
+ "GetSummonConfirmAreaName", -- [78]
+ "GetSummonConfirmSummoner", -- [79]
+ "GetSummonConfirmTimeLeft", -- [80]
+ "RandomRoll", -- [81]
+ "SetPVP", -- [82]
+ "StartDuel", -- [84]
+ "TogglePVP", -- [85]
+ "ToggleSheath", -- [86]
+ "UseSoulstone", -- [87]
+ "CanSolveArtifact", -- [89]
+ "UIParent", -- [90]
+ "GetArtifactInfoByRace", -- [91]
+ "GetArtifactProgress", -- [92]
+ "GetNumArtifactsByRace", -- [93]
+ "GetSelectedArtifactInfo", -- [94]
+ "IsArtifactCompletionHistoryAvailable", -- [95]
+ "ItemAddedToArtifact", -- [96]
+ "RemoveItemFromArtifact", -- [97]
+ "RequestArtifactCompletionHistory", -- [98]
+ "SocketItemToArtifact", -- [99]
+ "AcceptArenaTeam", -- [101]
+ "ArenaTeamInviteByName", -- [102]
+ "ArenaTeamSetLeaderByName", -- [103]
+ "ArenaTeamLeave", -- [104]
+ "ArenaTeamRoster", -- [105]
+ "ArenaTeamUninviteByName", -- [106]
+ "ArenaTeamDisband", -- [107]
+ "DeclineArenaTeam", -- [108]
+ "GetArenaTeam", -- [109]
+ "GetArenaTeamGdfInf", -- [110]
+ "oGetArenaTeamRosterInfo", -- [111]
+ "GetBattlefieldTeamInfo", -- [112]
+ "GetCurrentArenaSeason", -- [113]
+ "GetInspectArenaTeamData", -- [114]
+ "GetNumArenaTeamMembers", -- [115]
+ "GetPreviousArenaSeason", -- [116]
+ "IsActiveBattlefieldArena", -- [117]
+ "IsArenaTeamCaptain", -- [118]
+ "IsInArenaTeam", -- [119]
+ "CalculateAuctionDeposit", -- [121]
+ "CanCancelAuction", -- [122]
+ "CancelSell", -- [123]
+ "CanSendAuctionQuery", -- [124]
+ "CancelAuction", -- [125]
+ "ClickAuctionSellItemButton", -- [126]
+ "CloseAuctionHouse", -- [127]
+ "GetAuctionHouseDepositRate", -- [128]
+ "GetAuctionInvTypes", -- [129]
+ "GetAuctionItemClasses", -- [130]
+ "GetAuctionItemInfo", -- [131]
+ "GetAuctionItemLink", -- [132]
+ "GetAuctionItemSubClasses", -- [133]
+ "GetAuctionItemTimeLeft", -- [134]
+ "GetAuctionSellItemInfo", -- [135]
+ "GetBidderAuctionItems", -- [136]
+ "GetNumAuctionItems", -- [137]
+ "GetOwnerAuctionItems", -- [138]
+ "GetSelectedAuctionItem", -- [139]
+ "IsAuctionSortReversed", -- [140]
+ "PlaceAuctionBid", -- [141]
+ "QueryAuctionItems", -- [142]
+ "SetAuctionsTabShowing", -- [143]
+ "SetSelectedAuctionItem", -- [144]
+ "SortAuctionItems", -- [145]
+ "StartAuction", -- [146]
+ "BankButtonIDToInvSlotID", -- [148]
+ "CloseBankFrame", -- [149]
+ "GetBankSlotCost", -- [150]
+ "GetNumBankSlots", -- [151]
+ "PurchaseSlot", -- [152]
+ "AcceptAreaSpiritHeal", -- [154]
+ "AcceptBattlefieldPort", -- [155]
+ "CancelAreaSpiritHeal", -- [156]
+ "CanJoinBattlefieldAsGroup", -- [157]
+ "CheckSpiritHealerDist", -- [158]
+ "GetAreaSpiritHealerTime", -- [159]
+ "GetBattlefieldEstimatedWaitTime", -- [160]
+ "GetBattlefieldFlagPosition", -- [161]
+ "GetBattlefieldInstanceExpiration", -- [162]
+ "GetBattlefieldInstanceRunTime", -- [163]
+ "GetBattlefieldMapIconScale", -- [164]
+ "GetBattlefieldPortExpiration", -- [165]
+ "GetBattlefieldPosition", -- [166]
+ "GetBattlefieldScore", -- [167]
+ "GetBattlefieldStatData", -- [168]
+ "GetBattlefieldStatInfo", -- [169]
+ "GetBattlefieldStatus", -- [170]
+ "GetBattlefieldTimeWaited", -- [171]
+ "GetBattlefieldWinner", -- [172]
+ "GetBattlegroundInfo", -- [173]
+ "GetNumBattlefieldFlagPositions", -- [174]
+ "GetNumBattlefieldPositions", -- [175]
+ "GetNumBattlefieldScores", -- [176]
+ "GetNumBattlefieldStats", -- [177]
+ "GetNumWorldStateUI", -- [178]
+ "GetWintergraspWaitTime", -- [179]
+ "GetWorldStateUIInfo", -- [180]
+ "IsPVPTimerRunning", -- [181]
+ "JoinBattlefield", -- [182]
+ "LeaveBattlefield", -- [183]
+ "ReportPlayerIsPVPAFK", -- [184]
+ "RequestBattlefieldPositions", -- [185]
+ "RequestBattlefieldScoreData", -- [186]
+ "RequestBattlegroundInstanceInfo", -- [187]
+ "SetBattlefieldScoreFaction", -- [188]
+ "GetBinding", -- [190]
+ "GetBindingAction", -- [191]
+ "GetBindingKey", -- [192]
+ "GetBindingText", -- [193]
+ "GetCurrentBindingSet", -- [194]
+ "GetNumBindings", -- [195]
+ "LoadBindings", -- [196]
+ "RunBinding", -- [197]
+ "SaveBindings", -- [198]
+ "SetBinding", -- [199]
+ "SetBindingSpell", -- [200]
+ "SetBindingClick", -- [201]
+ "SetBindingItem", -- [202]
+ "SetBindingMacro", -- [203]
+ "SetConsoleKey", -- [204]
+ "SetOverrideBinding", -- [205]
+ "SetOverrideBindingSpell", -- [206]
+ "SetOverrideBindingClick", -- [207]
+ "SetOverrideBindingItem", -- [208]
+ "SetOverrideBindingMacro", -- [209]
+ "ClearOverrideBindings", -- [210]
+ "SetMouselookOverrideBinding", -- [211]
+ "IsModifierKeyDown", -- [212]
+ "IsModifiedClick", -- [213]
+ "IsMouseButtonDown", -- [214]
+ "CancelUnitBuff", -- [216]
+ "CancelShapeshiftForm", -- [217]
+ "CancelItemTempEnchantment", -- [218]
+ "GetWeaponEnchantInfo", -- [219]
+ "UnitAura", -- [220]
+ "UnitBuff", -- [221]
+ "UnitDebuff", -- [222]
+ "AddChatWindowChannel", -- [224]
+ "ChannelBan", -- [225]
+ "ChannelInvite", -- [226]
+ "ChannelKick", -- [227]
+ "ChannelModerator", -- [228]
+ "ChannelMute", -- [229]
+ "ChannelToggleAnnouncements", -- [230]
+ "ChannelUnban", -- [231]
+ "ChannelUnmoderator", -- [232]
+ "ChannelUnmute", -- [233]
+ "DisplayChannelOwner", -- [234]
+ "DeclineInvite", -- [235]
+ "EnumerateServerChannels", -- [236]
+ "GetChannelList", -- [237]
+ "GetChannelName", -- [238]
+ "GetChatWindowChannels", -- [239]
+ "JoinChannelByName", -- [240]
+ "LeaveChannelByName", -- [241]
+ "ListChannelByName", -- [242]
+ "ListChannels", -- [243]
+ "RemoveChatWindowChannel", -- [244]
+ "SendChatMessage", -- [245]
+ "SetChannelOwner", -- [246]
+ "SetChannelPassword", -- [247]
+ "AcceptResurrect", -- [249]
+ "AcceptXPLoss", -- [250]
+ "CheckBinderDist", -- [251]
+ "ConfirmBinder", -- [252]
+ "DeclineResurrect", -- [253]
+ "DestroyTotem", -- [254]
+ "GetBindLocation", -- [255]
+ "GetComboPoints", -- [256]
+ "GetCorpseRecoveryDelay", -- [257]
+ "GetCurrentTitle", -- [258]
+ "GetMirrorTimerInfo", -- [259]
+ "GetMirrorTimerProgress", -- [260]
+ "GetMoney", -- [261]
+ "GetNumTitles", -- [262]
+ "GetPlayerFacing", -- [263]
+ "GetPVPDesired", -- [264]
+ "GetReleaseTimeRemaining", -- [265]
+ "GetResSicknessDuration", -- [266]
+ "GetRestState", -- [267]
+ "GetRuneCooldown", -- [268]
+ "GetRuneCount", -- [269]
+ "GetRuneType", -- [270]
+ "GetTimeToWellRested", -- [271]
+ "GetTitleName", -- [272]
+ "GetUnitPitch", -- [273]
+ "GetXPExhaustion", -- [274]
+ "HasFullControl", -- [275]
+ "HasSoulstone", -- [276]
+ "IsFalling", -- [277]
+ "IsFlying", -- [278]
+ "IsFlyableArea", -- [279]
+ "IsIndoors", -- [280]
+ "IsMounted", -- [281]
+ "IsOutdoors", -- [282]
+ "IsOutOfBounds", -- [283]
+ "IsResting", -- [284]
+ "IsStealthed", -- [285]
+ "IsSwimming", -- [286]
+ "IsTitleKnown", -- [287]
+ "IsXPUserDisabled", -- [288]
+ "NotWhileDeadError", -- [289]
+ "ResurrectHasSickness", -- [290]
+ "ResurrectHasTimer", -- [291]
+ "ResurrectGetOfferer", -- [292]
+ "RetrieveCorpse", -- [293]
+ "SetCurrentTitle", -- [294]
+ "TargetTotem", -- [295]
+ "GetArmorPenetration", -- [296]
+ "GetAttackPowerForStat", -- [297]
+ "GetAverageItemLevel", -- [298]
+ "GetBlockChance", -- [299]
+ "GetCombatRating", -- [300]
+ "GetCombatRatingBonus", -- [301]
+ "GetCritChance", -- [302]
+ "GetCritChanceFromAgility", -- [303]
+ "GetDodgeChance", -- [304]
+ "GetExpertise", -- [305]
+ "GetExpertisePercent", -- [306]
+ "GetManaRegen", -- [307]
+ "GetMaxCombatRatingBonus", -- [308]
+ "GetParryChance", -- [309]
+ "GetPetSpellBonusDamage", -- [310]
+ "GetPowerRegen", -- [311]
+ "GetSpellBonusDamage", -- [312]
+ "GetRangedCritChance", -- [313]
+ "GetSpellBonusHealing", -- [314]
+ "GetSpellCritChance", -- [315]
+ "GetShieldBlock", -- [316]
+ "GetSpellCritChanceFromIntellect", -- [317]
+ "GetSpellPenetration", -- [318]
+ "AddChatWindowChannel", -- [319]
+ "ChangeChatColor", -- [320]
+ "ChatFrame_AddChannel", -- [321]
+ "ChatFrame_AddMessageEventFilter", -- [322]
+ "ChatFrame_GetMessageEventFilters", -- [323]
+ "ChatFrame_OnHyperlinkShow", -- [324]
+ "ChatFrame_RemoveMessageEventFilter", -- [325]
+ "GetAutoCompleteResults", -- [326]
+ "GetChatTypeIndex", -- [327]
+ "GetChatWindowChannels", -- [328]
+ "GetChatWindowInfo", -- [329]
+ "GetChatWindowMessages", -- [330]
+ "JoinChannelByName", -- [331]
+ "LoggingChat", -- [332]
+ "LoggingCombat", -- [333]
+ "RemoveChatWindowChannel", -- [334]
+ "RemoveChatWindowMessages", -- [335]
+ "SetChatWindowAlpha", -- [336]
+ "SetChatWindowColor", -- [337]
+ "SetChatWindowDocked", -- [338]
+ "SetChatWindowLocked", -- [339]
+ "SetChatWindowName", -- [340]
+ "SetChatWindowShown", -- [341]
+ "SetChatWindowSize", -- [342]
+ "SetChatWindowUninteractable", -- [343]
+ "DoEmote", -- [345]
+ "GetDefaultLanguage", -- [346]
+ "GetLanguageByIndex", -- [347]
+ "GetNumLanguages", -- [348]
+ "GetRegisteredAddonMessagePrefixes", -- [349]
+ "IsAddonMessagePrefixRegistered", -- [350]
+ "RegisterAddonMessagePrefix", -- [352]
+ "SendAddonMessage", -- [353]
+ "SendChatMessage", -- [354]
+ "CallCompanion", -- [356]
+ "DismissCompanion", -- [357]
+ "GetCompanionInfo", -- [358]
+ "GetNumCompanions", -- [359]
+ "GetCompanionCooldown", -- [360]
+ "PickupCompanion", -- [361]
+ "SummonRandomCritter", -- [362]
+ "ContainerIDToInventoryID", -- [364]
+ "GetBagName", -- [365]
+ "GetContainerItemCooldown", -- [366]
+ "GetContainerItemDurability", -- [367]
+ "GetContainerItemGems", -- [368]
+ "GetContainerItemID", -- [369]
+ "GetContainerItemInfo", -- [370]
+ "GetContainerItemLink", -- [371]
+ "GetContainerNumSlots", -- [372]
+ "GetContainerItemQuestInfo", -- [373]
+ "GetContainerNumFreeSlots", -- [374]
+ "OpenAllBags", -- [376]
+ "CloseAllBags", -- [377]
+ "PickupBagFromSlot", -- [378]
+ "PickupContainerItem", -- [379]
+ "PutItemInBackpack", -- [380]
+ "PutItemInBag", -- [381]
+ "PutKeyInKeyRing", -- [382]
+ "SplitContainerItem", -- [383]
+ "ToggleBackpack", -- [384]
+ "ToggleBag", -- [385]
+ "GetCoinText", -- [388]
+ "GetCoinTextureString", -- [389]
+ "GetCurrencyInfo", -- [390]
+ "GetCurrencyListSize", -- [391]
+ "GetCurrencyListInfo", -- [392]
+ "ExpandCurrencyList", -- [393]
+ "SetCurrencyUnused", -- [394]
+ "GetNumWatchedTokens", -- [395]
+ "GetBackpackCurrencyInfo", -- [396]
+ "SetCurrencyBackpack", -- [397]
+ "AutoEquipCursorItem", -- [399]
+ "ClearCursor", -- [400]
+ "CursorCanGoInSlot", -- [401]
+ "CursorHasItem", -- [402]
+ "CursorHasMoney", -- [403]
+ "CursorHasSpell", -- [404]
+ "DeleteCursorItem", -- [405]
+ "DropCursorMoney", -- [406]
+ "DropItemOnUnit", -- [407]
+ "EquipCursorItem", -- [408]
+ "GetCursorInfo", -- [409]
+ "GetCursorPosition", -- [410]
+ "HideRepairCursor", -- [411]
+ "InRepairMode", -- [412]
+ "PickupAction", -- [413]
+ "PickupBagFromSlot", -- [414]
+ "PickupContainerItem", -- [415]
+ "PickupInventoryItem", -- [416]
+ "PickupItem", -- [417]
+ "PickupMacro", -- [418]
+ "PickupMerchantItem", -- [419]
+ "PickupPetAction", -- [420]
+ "PickupSpell", -- [421]
+ "PickupStablePet", -- [422]
+ "PickupTradeMoney", -- [423]
+ "PlaceAction", -- [424]
+ "PutItemInBackpack", -- [425]
+ "PutItemInBag", -- [426]
+ "ResetCursor", -- [427]
+ "SetCursor", -- [428]
+ "ShowContainerSellCursor", -- [429]
+ "ShowInspectCursor", -- [430]
+ "ShowInventorySellCursor", -- [431]
+ "ShowMerchantSellCursor", -- [432]
+ "ShowRepairCursor", -- [433]
+ "SplitContainerItem", -- [434]
+ "GetWeaponEnchantInfo", -- [435]
+ "ReplaceEnchant", -- [436]
+ "ReplaceTradeEnchant", -- [437]
+ "BindEnchant", -- [438]
+ "CollapseFactionHeader", -- [439]
+ "CollapseAllFactionHeaders", -- [440]
+ "ExpandFactionHeader", -- [441]
+ "ExpandAllFactionHeaders", -- [442]
+ "FactionToggleAtWar", -- [443]
+ "GetFactionInfo", -- [444]
+ "GetNumFactions", -- [445]
+ "GetSelectedFaction", -- [446]
+ "GetWatchedFactionInfo", -- [447]
+ "IsFactionInactive", -- [448]
+ "SetFactionActive", -- [449]
+ "SetFactionInactive", -- [450]
+ "SetSelectedFaction", -- [451]
+ "SetWatchedFactionIndex", -- [452]
+ "UnitFactionGroup", -- [453]
+ "CreateFrame", -- [454]
+ "CreateFont", -- [455]
+ "GetFramesRegisteredForEvent", -- [456]
+ "GetNumFrames", -- [457]
+ "EnumerateFrames", -- [458]
+ "GetMouseFocus", -- [459]
+ "ToggleDropDownMenu", -- [460]
+ "UIFrameFadeIn", -- [461]
+ "UIFrameFadeOut", -- [462]
+ "UIFrameFlash", -- [463]
+ "EasyMenu", -- [464]
+ "AddFriend", -- [466]
+ "AddOrRemoveFriend", -- [467]
+ "GetFriendInfo", -- [468]
+ "SetFriendNotes", -- [469]
+ "GetNumFriends", -- [470]
+ "GetSelectedFriend", -- [471]
+ "RemoveFriend", -- [472]
+ "SetSelectedFriend", -- [473]
+ "ShowFriends", -- [474]
+ "ToggleFriendsFrame", -- [475]
+ "GetNumGlyphSockets", -- [477]
+ "GetGlyphSocketInfo", -- [478]
+ "GetGlyphLink", -- [479]
+ "GlyphMatchesSocket", -- [480]
+ "PlaceGlyphInSocket", -- [481]
+ "RemoveGlyphFromSocket", -- [482]
+ "SpellCanTargetGlyph", -- [483]
+ "CanComplainChat", -- [485]
+ "CanComplainInboxItem", -- [486]
+ "ComplainChat", -- [487]
+ "ComplainInboxItem", -- [488]
+ "CloseGossip", -- [501]
+ "ForceGossip", -- [502]
+ "GetGossipActiveQuests", -- [503]
+ "GetGossipAvailableQuests", -- [504]
+ "GetGossipOptions", -- [505]
+ "GetGossipText", -- [506]
+ "GetNumGossipActiveQuests", -- [507]
+ "GetNumGossipAvailableQuests", -- [508]
+ "GetNumGossipOptions", -- [509]
+ "SelectGossipActiveQuest", -- [510]
+ "SelectGossipAvailableQuest", -- [511]
+ "SelectGossipOption", -- [512]
+ "AcceptGroup", -- [514]
+ "ConfirmReadyCheck", -- [515]
+ "ConvertToRaid", -- [516]
+ "DeclineGroup", -- [517]
+ "DoReadyCheck", -- [518]
+ "GetLootMethod", -- [519]
+ "GetLootThreshold", -- [520]
+ "GetMasterLootCandidate", -- [521]
+ "GetNumPartyMembers", -- [522]
+ "GetRealNumPartyMembers", -- [523]
+ "GetPartyLeaderIndex", -- [524]
+ "GetPartyMember", -- [525]
+ "InviteUnit", -- [526]
+ "IsPartyLeader", -- [527]
+ "LeaveParty", -- [528]
+ "PromoteToLeader", -- [529]
+ "SetLootMethod", -- [530]
+ "SetLootThreshold", -- [531]
+ "UninviteUnit", -- [532]
+ "UnitInParty", -- [533]
+ "UnitIsPartyLeader", -- [534]
+ "AcceptGuild", -- [536]
+ "BuyGuildCharter", -- [537]
+ "CanEditGuildEvent", -- [538]
+ "CanEditGuildInfo", -- [539]
+ "CanEditMOTD", -- [540]
+ "CanEditOfficerNote", -- [541]
+ "CanEditPublicNote", -- [542]
+ "CanGuildDemote", -- [543]
+ "CanGuildInvite", -- [544]
+ "CanGuildPromote", -- [545]
+ "CanGuildRemove", -- [546]
+ "CanViewOfficerNote", -- [547]
+ "CloseGuildRegistrar", -- [548]
+ "CloseGuildRoster", -- [549]
+ "CloseTabardCreation", -- [550]
+ "DeclineGuild", -- [551]
+ "GetGuildCharterCost", -- [552]
+ "GetGuildEventInfo", -- [553]
+ "GetGuildInfo", -- [554]
+ "GetGuildInfoText", -- [555]
+ "GetGuildRosterInfo", -- [556]
+ "GetGuildRosterLastOnline", -- [557]
+ "GetGuildRosterMOTD", -- [558]
+ "GetGuildRosterSelection", -- [559]
+ "GetGuildRosterShowOffline", -- [560]
+ "GetNumGuildEvents", -- [561]
+ "GetNumGuildMembers", -- [562]
+ "GetTabardCreationCost", -- [563]
+ "GetTabardInfo", -- [564]
+ "GuildControlAddRank", -- [565]
+ "GuildControlDelRank", -- [566]
+ "GuildControlGetNumRanks", -- [567]
+ "GuildControlGetRankFlags", -- [568]
+ "GuildControlGetRankName", -- [569]
+ "GuildControlSaveRank", -- [570]
+ "GuildControlSetRank", -- [571]
+ "GuildControlSetRankFlag", -- [572]
+ "GuildDemote", -- [573]
+ "GuildDisband", -- [574]
+ "GuildInfo", -- [575]
+ "GuildInvite", -- [576]
+ "GuildLeave", -- [577]
+ "GuildPromote", -- [578]
+ "GuildRoster", -- [579]
+ "GuildRosterSetOfficerNote", -- [580]
+ "GuildRosterSetPublicNote", -- [581]
+ "GuildSetMOTD", -- [582]
+ "GuildSetLeader", -- [583]
+ "GuildUninvite", -- [584]
+ "IsGuildLeader", -- [585]
+ "IsInGuild", -- [586]
+ "QueryGuildEventLog", -- [587]
+ "SetGuildInfoText", -- [588]
+ "SetGuildRosterSelection", -- [589]
+ "SetGuildRosterShowOffline", -- [590]
+ "SortGuildRoster", -- [591]
+ "UnitGetGuildXP", -- [592]
+ "AutoStoreGuildBankItem", -- [593]
+ "BuyGuildBankTab", -- [594]
+ "CanGuildBankRepair", -- [595]
+ "CanWithdrawGuildBankMoney", -- [596]
+ "CloseGuildBankFrame", -- [597]
+ "DepositGuildBankMoney", -- [598]
+ "GetCurrentGuildBankTab", -- [599]
+ "GetGuildBankItemInfo", -- [600]
+ "GetGuildBankItemLink", -- [601]
+ "GetGuildBankMoney", -- [602]
+ "GetGuildBankMoneyTransaction", -- [603]
+ "GetGuildBankTabCost", -- [604]
+ "GetGuildBankTabInfo", -- [605]
+ "GetGuildBankTabPermissions", -- [606]
+ "GetGuildBankText", -- [607]
+ "GetGuildBankTransaction", -- [608]
+ "GetGuildTabardFileNames", -- [611]
+ "GetNumGuildBankMoneyTransactions", -- [612]
+ "GetNumGuildBankTabs", -- [613]
+ "GetNumGuildBankTransactions", -- [614]
+ "PickupGuildBankItem", -- [615]
+ "PickupGuildBankMoney", -- [616]
+ "QueryGuildBankLog", -- [617]
+ "QueryGuildBankTab", -- [618]
+ "SetCurrentGuildBankTab", -- [619]
+ "SetGuildBankTabInfo", -- [620]
+ "SetGuildBankTabPermissions", -- [621]
+ "SplitGuildBankItem", -- [624]
+ "WithdrawGuildBankMoney", -- [625]
+ "GetHolidayBGHonorCurrencyBonuses", -- [627]
+ "GetInspectHonorData", -- [628]
+ "GetPVPLifetimeStats", -- [629]
+ "GetPVPRankInfo", -- [630]
+ "GetPVPRankProgress", -- [631]
+ "GetPVPSessionStats", -- [632]
+ "GetPVPYesterdayStats", -- [633]
+ "GetRandomBGHonorCurrencyBonuses", -- [634]
+ "HasInspectHonorData", -- [635]
+ "RequestInspectHonorData", -- [636]
+ "UnitPVPName", -- [637]
+ "UnitPVPRank", -- [638]
+ "AddIgnore", -- [640]
+ "AddOrDelIgnore", -- [641]
+ "DelIgnore", -- [642]
+ "GetIgnoreName", -- [643]
+ "GetNumIgnores", -- [644]
+ "GetSelectedIgnore", -- [645]
+ "SetSelectedIgnore", -- [646]
+ "CanInspect", -- [648]
+ "CheckInteractDistance", -- [649]
+ "ClearInspectPlayer", -- [650]
+ "GetInspectArenaTeamData", -- [651]
+ "HasInspectHonorData", -- [652]
+ "RequestInspectHonorData", -- [653]
+ "GetInspectHonorData", -- [654]
+ "NotifyInspect", -- [655]
+ "InspectUnit", -- [656]
+ "CanShowResetInstances", -- [658]
+ "GetBattlefieldInstanceExpiration", -- [659]
+ "GetBattlefieldInstanceInfo", -- [660]
+ "GetBattlefieldInstanceRunTime", -- [661]
+ "GetInstanceBootTimeRemaining", -- [662]
+ "GetInstanceInfo", -- [663]
+ "GetNumSavedInstances", -- [664]
+ "GetSavedInstanceInfo", -- [665]
+ "IsInInstance", -- [666]
+ "ResetInstances", -- [667]
+ "GetDungeonDifficulty", -- [668]
+ "SetDungeonDifficulty", -- [669]
+ "GetInstanceDifficulty", -- [670]
+ "GetInstanceLockTimeRemaining", -- [671]
+ "GetInstanceLockTimeRemainingEncounter", -- [672]
+ "AutoEquipCursorItem", -- [674]
+ "BankButtonIDToInvSlotID", -- [675]
+ "CancelPendingEquip", -- [676]
+ "ConfirmBindOnUse", -- [677]
+ "ContainerIDToInventoryID", -- [678]
+ "CursorCanGoInSlot", -- [679]
+ "EquipCursorItem", -- [680]
+ "EquipPendingItem", -- [681]
+ "GetInventoryAlertStatus", -- [682]
+ "GetInventoryItemBroken", -- [683]
+ "GetInventoryItemCooldown", -- [684]
+ "GetInventoryItemCount", -- [685]
+ "GetInventoryItemDurability", -- [686]
+ "GetInventoryItemGems", -- [687]
+ "GetInventoryItemID", -- [688]
+ "GetInventoryItemLink", -- [689]
+ "GetInventoryItemQuality", -- [690]
+ "GetInventoryItemTexture", -- [691]
+ "GetInventorySlotInfo", -- [692]
+ "GetWeaponEnchantInfo", -- [693]
+ "HasWandEquipped", -- [694]
+ "IsInventoryItemLocked", -- [695]
+ "KeyRingButtonIDToInvSlotID", -- [696]
+ "PickupBagFromSlot", -- [697]
+ "PickupInventoryItem", -- [698]
+ "UpdateInventoryAlertStatus", -- [699]
+ "UseInventoryItem", -- [700]
+ "EquipItemByName", -- [702]
+ "GetAuctionItemLink", -- [703]
+ "GetContainerItemLink", -- [704]
+ "GetItemCooldown", -- [705]
+ "GetItemCount", -- [706]
+ "GetItemFamily", -- [707]
+ "GetItemIcon", -- [708]
+ "GetItemInfo", -- [709]
+ "GetItemQualityColor", -- [710]
+ "GetItemSpell", -- [711]
+ "GetItemStats", -- [712]
+ "GetMerchantItemLink", -- [713]
+ "GetQuestItemLink", -- [714]
+ "GetQuestLogItemLink", -- [715]
+ "GetTradePlayerItemLink", -- [716]
+ "GetTradeSkillItemLink", -- [717]
+ "GetTradeSkillReagentItemLink", -- [718]
+ "GetTradeTargetItemLink", -- [719]
+ "IsUsableItem", -- [720]
+ "IsConsumableItem", -- [721]
+ "IsCurrentItem", -- [722]
+ "IsEquippedItem", -- [723]
+ "IsEquippableItem", -- [724]
+ "IsEquippedItemType", -- [725]
+ "IsItemInRange", -- [726]
+ "ItemHasRange", -- [727]
+ "OffhandHasWeapon", -- [728]
+ "SplitContainerItem", -- [729]
+ "SetItemRef", -- [730]
+ "AcceptSockets", -- [731]
+ "ClickSocketButton", -- [732]
+ "CloseSocketInfo", -- [733]
+ "GetSocketItemInfo", -- [734]
+ "GetSocketItemRefundable", -- [735]
+ "GetSocketItemBoundTradeable", -- [736]
+ "GetNumSockets", -- [737]
+ "GetSocketTypes", -- [738]
+ "GetExistingSocketInfo", -- [739]
+ "GetExistingSocketLink", -- [740]
+ "GetNewSocketInfo", -- [741]
+ "GetNewSocketLink", -- [742]
+ "SocketInventoryItem", -- [743]
+ "SocketContainerItem", -- [744]
+ "CloseItemText", -- [745]
+ "ItemTextGetCreator", -- [746]
+ "ItemTextGetItem", -- [747]
+ "ItemTextGetMaterial", -- [748]
+ "ItemTextGetPage", -- [749]
+ "ItemTextGetText", -- [750]
+ "ItemTextHasNextPage", -- [751]
+ "ItemTextNextPage", -- [752]
+ "ItemTextPrevPage", -- [753]
+ "GetMinimapZoneText", -- [755]
+ "GetRealZoneText", -- [756]
+ "GetSubZoneText", -- [757]
+ "GetZonePVPInfo", -- [758]
+ "GetZoneText", -- [759]
+ "CompleteLFGRoleCheck", -- [760]
+ "GetLFGDeserterExpiration", -- [761]
+ "GetLFGRandomCooldownExpiration", -- [762]
+ "GetLFGBootProposal", -- [763]
+ "GetLFGMode", -- [764]
+ "GetLFGQueueStats", -- [765]
+ "GetLFGRoles", -- [766]
+ "GetLFGRoleUpdate", -- [767]
+ "GetLFGRoleUpdateSlot", -- [768]
+ "SetLFGBootVote", -- [769]
+ "SetLFGComment", -- [770]
+ "SetLFGRoles", -- [771]
+ "UninviteUnit", -- [772]
+ "UnitGroupRolesAssigned", -- [773]
+ "UnitHasLFGDeserter", -- [774]
+ "UnitHasLFGRandomCooldown", -- [775]
+ "CloseLoot", -- [777]
+ "ConfirmBindOnUse", -- [778]
+ "ConfirmLootRoll", -- [779]
+ "ConfirmLootSlot", -- [780]
+ "GetLootMethod", -- [781]
+ "GetLootRollItemInfo", -- [782]
+ "GetLootRollItemLink", -- [783]
+ "GetLootRollTimeLeft", -- [784]
+ "GetLootSlotInfo", -- [785]
+ "GetLootSlotLink", -- [786]
+ "GetLootThreshold", -- [787]
+ "GetMasterLootCandidate", -- [788]
+ "GetNumLootItems", -- [789]
+ "GetOptOutOfLoot", -- [790]
+ "GiveMasterLoot", -- [791]
+ "IsFishingLoot", -- [792]
+ "LootSlot", -- [793]
+ "LootSlotIsCoin", -- [794]
+ "LootSlotIsCurrency", -- [795]
+ "LootSlotIsItem", -- [796]
+ "RollOnLoot", -- [797]
+ "SetLootMethod", -- [798]
+ "SetLootPortrait", -- [799]
+ "SetLootThreshold", -- [800]
+ "SetOptOutOfLoot", -- [801]
+ "CursorHasMacro", -- [804]
+ "DeleteMacro", -- [805]
+ "GetMacroBody", -- [807]
+ "GetMacroIconInfo", -- [808]
+ "GetMacroItemIconInfo", -- [809]
+ "GetMacroIndexByName", -- [810]
+ "GetMacroInfo", -- [811]
+ "GetNumMacroIcons", -- [812]
+ "GetNumMacroItemIcons", -- [813]
+ "GetNumMacros", -- [814]
+ "PickupMacro", -- [815]
+ "RunMacro", -- [816]
+ "RunMacroText", -- [817]
+ "SecureCmdOptionParse", -- [818]
+ "StopMacro", -- [819]
+ "AutoLootMailItem", -- [821]
+ "CheckInbox", -- [822]
+ "ClearSendMail", -- [823]
+ "ClickSendMailItemButton", -- [824]
+ "CloseMail", -- [825]
+ "DeleteInboxItem", -- [826]
+ "GetCoinIcon", -- [827]
+ "GetInboxHeaderInfo", -- [828]
+ "GetInboxItem", -- [829]
+ "GetInboxItemLink", -- [830]
+ "GetInboxNumItems", -- [831]
+ "GetInboxText", -- [832]
+ "GetInboxInvoiceInfo", -- [833]
+ "GetNumPackages", -- [834]
+ "GetNumStationeries", -- [835]
+ "GetPackageInfo", -- [836]
+ "GetSelectedStationeryTexture", -- [837]
+ "GetSendMailCOD", -- [838]
+ "GetSendMailItem", -- [839]
+ "GetSendMailItemLink", -- [840]
+ "GetSendMailMoney", -- [841]
+ "GetSendMailPrice", -- [842]
+ "GetStationeryInfo", -- [843]
+ "HasNewMail", -- [844]
+ "InboxItemCanDelete", -- [845]
+ "ReturnInboxItem", -- [846]
+ "SelectPackage", -- [847]
+ "SelectStationery", -- [848]
+ "SendMail", -- [849]
+ "SetSendMailCOD", -- [850]
+ "SetSendMailMoney", -- [851]
+ "TakeInboxItem", -- [852]
+ "TakeInboxMoney", -- [853]
+ "TakeInboxTextItem", -- [854]
+ "ClickLandmark", -- [856]
+ "GetCorpseMapPosition", -- [857]
+ "GetCurrentMapContinent", -- [858]
+ "GetCurrentMapDungeonLevel", -- [859]
+ "GetNumDungeonMapLevels", -- [860]
+ "GetCurrentMapAreaID", -- [861]
+ "GetCurrentMapZone", -- [862]
+ "GetMapContinents", -- [863]
+ "GetMapDebugObjectInfo", -- [864]
+ "GetMapInfo", -- [865]
+ "GetMapLandmarkInfo", -- [866]
+ "GetMapOverlayInfo", -- [867]
+ "GetMapZones", -- [868]
+ "GetNumMapDebugObjects", -- [869]
+ "GetNumMapLandmarks", -- [870]
+ "GetNumMapOverlays", -- [871]
+ "GetPlayerMapPosition", -- [872]
+ "ProcessMapClick", -- [873]
+ "RequestBattlefieldPositions", -- [874]
+ "SetDungeonMapLevel", -- [875]
+ "SetMapByID", -- [876]
+ "SetMapToCurrentZone", -- [877]
+ "SetMapZoom", -- [878]
+ "SetupFullscreenScale", -- [879]
+ "UpdateMapHighlight", -- [880]
+ "CreateWorldMapArrowFrame", -- [881]
+ "UpdateWorldMapArrowFrames", -- [882]
+ "ShowWorldMapArrowFrame", -- [883]
+ "PositionWorldMapArrowFrame", -- [884]
+ "ZoomOut", -- [885]
+ "BuyMerchantItem", -- [887]
+ "BuybackItem", -- [888]
+ "CanMerchantRepair", -- [889]
+ "CloseMerchant", -- [890]
+ "GetBuybackItemInfo", -- [891]
+ "GetBuybackItemLink", -- [892]
+ "GetMerchantItemCostInfo", -- [893]
+ "GetMerchantItemCostItem", -- [894]
+ "GetMerchantItemInfo", -- [895]
+ "GetMerchantItemLink", -- [896]
+ "GetMerchantItemMaxStack", -- [897]
+ "GetMerchantNumItems", -- [898]
+ "GetRepairAllCost", -- [899]
+ "HideRepairCursor", -- [900]
+ "InRepairMode", -- [901]
+ "PickupMerchantItem", -- [902]
+ "RepairAllItems", -- [903]
+ "ShowMerchantSellCursor", -- [904]
+ "ShowRepairCursor", -- [905]
+ "GetNumBuybackItems", -- [906]
+ "CastPetAction", -- [908]
+ "ClosePetStables", -- [909]
+ "DropItemOnUnit", -- [910]
+ "GetPetActionCooldown", -- [911]
+ "GetPetActionInfo", -- [912]
+ "GetPetActionSlotUsable", -- [913]
+ "GetPetActionsUsable", -- [914]
+ "GetPetExperience", -- [915]
+ "GetPetFoodTypes", -- [916]
+ "GetPetHappiness", -- [917]
+ "GetPetIcon", -- [918]
+ "GetPetTimeRemaining", -- [919]
+ "GetStablePetFoodTypes", -- [920]
+ "GetStablePetInfo", -- [921]
+ "HasPetSpells", -- [922]
+ "HasPetUI", -- [923]
+ "PetAbandon", -- [924]
+ "PetAggressiveMode", -- [925]
+ "PetAttack", -- [926]
+ "IsPetAttackActive", -- [927]
+ "PetStopAttack", -- [928]
+ "PetCanBeAbandoned", -- [929]
+ "PetCanBeDismissed", -- [930]
+ "PetCanBeRenamed", -- [931]
+ "PetDefensiveMode", -- [932]
+ "PetDismiss", -- [933]
+ "PetFollow", -- [934]
+ "PetHasActionBar", -- [935]
+ "PetPassiveMode", -- [936]
+ "PetRename", -- [937]
+ "PetWait", -- [938]
+ "PickupPetAction", -- [939]
+ "PickupStablePet", -- [940]
+ "SetPetStablePaperdoll", -- [941]
+ "TogglePetAutocast", -- [942]
+ "ToggleSpellAutocast", -- [943]
+ "GetSpellAutocast", -- [944]
+ "AddQuestWatch", -- [946]
+ "GetActiveLevel", -- [947]
+ "GetActiveTitle", -- [948]
+ "GetAvailableLevel", -- [949]
+ "GetAvailableTitle", -- [950]
+ "GetAvailableQuestInfo", -- [951]
+ "GetGreetingText", -- [952]
+ "GetNumQuestLeaderBoards", -- [953]
+ "GetNumQuestWatches", -- [954]
+ "GetObjectiveText", -- [955]
+ "GetProgressText", -- [956]
+ "GetQuestGreenRange", -- [957]
+ "GetQuestIndexForWatch", -- [958]
+ "GetQuestLink", -- [959]
+ "GetQuestLogGroupNum", -- [960]
+ "GetQuestLogLeaderBoard", -- [961]
+ "GetQuestLogTitle", -- [962]
+ "GetQuestReward", -- [963]
+ "GetRewardArenaPoints", -- [964]
+ "GetRewardHonor", -- [965]
+ "GetRewardMoney", -- [966]
+ "GetRewardSpell", -- [967]
+ "GetRewardTalents", -- [968]
+ "GetRewardText", -- [969]
+ "GetRewardTitle", -- [970]
+ "GetRewardXP", -- [971]
+ "IsQuestWatched", -- [972]
+ "IsUnitOnQuest", -- [973]
+ "QuestFlagsPVP", -- [974]
+ "QuestGetAutoAccept", -- [975]
+ "RemoveQuestWatch", -- [976]
+ "ShiftQuestWatches", -- [977]
+ "SortQuestWatches", -- [978]
+ "QueryQuestsCompleted", -- [979]
+ "GetQuestsCompleted", -- [980]
+ "QuestIsDaily", -- [981]
+ "QuestIsWeekly", -- [982]
+ "ClearRaidMarker", -- [984]
+ "ConvertToRaid", -- [985]
+ "ConvertToParty", -- [986]
+ "DemoteAssistant", -- [987]
+ "GetAllowLowLevelRaid", -- [988]
+ "GetNumRaidMembers", -- [989]
+ "GetRealNumRaidMembers", -- [990]
+ "GetPartyAssignment", -- [991]
+ "GetPartyAssignment", -- [992]
+ "GetRaidRosterInfo", -- [993]
+ "GetRaidTargetIndex", -- [994]
+ "GetReadyCheckStatus", -- [995]
+ "InitiateRolePoll", -- [996]
+ "IsRaidLeader", -- [997]
+ "IsRaidOfficer", -- [998]
+ "PlaceRaidMarker", -- [999]
+ "PromoteToAssistant", -- [1000]
+ "RequestRaidInfo", -- [1001]
+ "SetPartyAssignment", -- [1002]
+ "SetAllowLowLevelRaid", -- [1003]
+ "SetRaidRosterSelection", -- [1004]
+ "SetRaidSubgroup", -- [1005]
+ "SwapRaidSubgroup", -- [1006]
+ "SetRaidTarget", -- [1007]
+ "UnitInRaid", -- [1008]
+ "LFGGetDungeonInfoByID", -- [1009]
+ "GetInstanceLockTimeRemainingEncounter", -- [1010]
+ "RefreshLFGList", -- [1011]
+ "SearchLFGGetEncounterResults", -- [1012]
+ "SearchLFGGetJoinedID", -- [1013]
+ "SearchLFGGetNumResults", -- [1014]
+ "SearchLFGGetPartyResults", -- [1015]
+ "SearchLFGGetResults", -- [1016]
+ "SearchLFGJoin", -- [1017]
+ "SearchLFGLeave", -- [1018]
+ "SearchLFGSort", -- [1019]
+ "SetLFGComment", -- [1020]
+ "ClearAllLFGDungeons", -- [1021]
+ "JoinLFG", -- [1022]
+ "LeaveLFG", -- [1023]
+ "RequestLFDPartyLockInfo", -- [1024]
+ "RequestLFDPlayerLockInfo", -- [1025]
+ "SetLFGDungeon", -- [1026]
+ "SetLFGDungeonEnabled", -- [1027]
+ "SetLFGHeaderCollapsed", -- [1028]
+ "GetAddOnCPUUsage", -- [1029]
+ "GetAddOnMemoryUsage", -- [1030]
+ "GetEventCPUUsage", -- [1031]
+ "GetFrameCPUUsage", -- [1032]
+ "GetFunctionCPUUsage", -- [1033]
+ "GetScriptCPUUsage", -- [1034]
+ "ResetCPUUsage", -- [1035]
+ "UpdateAddOnCPUUsage", -- [1036]
+ "UpdateAddOnMemoryUsage", -- [1037]
+ "issecure", -- [1038]
+ "forceinsecure", -- [1039]
+ "issecurevariable", -- [1040]
+ "securecall", -- [1041]
+ "hooksecurefunc", -- [1042]
+ "InCombatLockdown", -- [1043]
+ "CombatTextSetActiveUnit", -- [1046]
+ "DownloadSettings", -- [1047]
+ "GetCVar", -- [1048]
+ "GetCVarDefault", -- [1049]
+ "GetCVarBool", -- [1050]
+ "GetCVarInfo", -- [1051]
+ "GetCurrentMultisampleFormat", -- [1052]
+ "GetCurrentResolution", -- [1053]
+ "GetGamma", -- [1054]
+ "GetMultisampleFormats", -- [1055]
+ "GetRefreshRates", -- [1056]
+ "GetScreenResolutions", -- [1057]
+ "GetVideoCaps", -- [1058]
+ "IsThreatWarningEnabled", -- [1059]
+ "RegisterCVar", -- [1060]
+ "ResetPerformanceValues", -- [1061]
+ "ResetTutorials", -- [1062]
+ "SetCVar", -- [1063]
+ "SetEuropeanNumbers", -- [1064]
+ "SetGamma", -- [1065]
+ "SetLayoutMode", -- [1066]
+ "SetMultisampleFormat", -- [1067]
+ "SetScreenResolution", -- [1068]
+ "ShowCloak", -- [1069]
+ "ShowHelm", -- [1070]
+ "ShowNumericThreat", -- [1071]
+ "ShowingCloak", -- [1072]
+ "ShowingHelm", -- [1073]
+ "UploadSettings", -- [1074]
+ "AbandonSkill", -- [1076]
+ "CastShapeshiftForm", -- [1078]
+ "CastSpell", -- [1079]
+ "CastSpellByName", -- [1080]
+ "GetMultiCastTotemSpells", -- [1081]
+ "GetNumShapeshiftForms", -- [1082]
+ "GetNumSpellTabs", -- [1083]
+ "GetShapeshiftForm", -- [1084]
+ "GetShapeshiftFormCooldown", -- [1085]
+ "GetShapeshiftFormInfo", -- [1086]
+ "GetSpellAutocast", -- [1087]
+ "GetSpellBookItemInfo", -- [1088]
+ "GetSpellBookItemName", -- [1089]
+ "GetSpellCooldown", -- [1090]
+ "GetSpellDescription", -- [1091]
+ "GetSpellInfo", -- [1092]
+ "GetSpellLink", -- [1093]
+ "GetSpellTabInfo", -- [1094]
+ "GetSpellTexture", -- [1095]
+ "GetTotemInfo", -- [1096]
+ "IsAttackSpell", -- [1097]
+ "IsAutoRepeatSpell", -- [1098]
+ "IsPassiveSpell", -- [1099]
+ "IsSpellInRange", -- [1100]
+ "IsUsableSpell", -- [1101]
+ "PickupSpell", -- [1102]
+ "QueryCastSequence", -- [1103]
+ "SetMultiCastSpell", -- [1104]
+ "SpellCanTargetUnit", -- [1105]
+ "SpellHasRange", -- [1106]
+ "SpellIsTargeting", -- [1107]
+ "SpellStopCasting", -- [1108]
+ "SpellStopTargeting", -- [1109]
+ "SpellTargetUnit", -- [1110]
+ "ToggleSpellAutocast", -- [1111]
+ "UnitCastingInfo", -- [1112]
+ "UnitChannelInfo", -- [1113]
+ "ConsoleExec", -- [1115]
+ "DetectWowMouse", -- [1116]
+ "GetBuildInfo", -- [1117]
+ "geterrorhandler", -- [1118]
+ "GetCurrentKeyBoardFocus", -- [1119]
+ "GetExistingLocales", -- [1120]
+ "GetFramerate", -- [1121]
+ "GetGameTime", -- [1122]
+ "GetLocale", -- [1123]
+ "GetCursorPosition", -- [1124]
+ "GetNetStats", -- [1125]
+ "GetRealmName", -- [1126]
+ "GetScreenHeight", -- [1127]
+ "GetScreenWidth", -- [1128]
+ "GetText", -- [1129]
+ "GetTime", -- [1130]
+ "IsAltKeyDown", -- [1131]
+ "InCinematic", -- [1132]
+ "IsControlKeyDown", -- [1133]
+ "IsDebugBuild", -- [1134]
+ "IsDesaturateSupported", -- [1135]
+ "IsLeftAltKeyDown", -- [1136]
+ "IsLeftControlKeyDown", -- [1137]
+ "IsLeftShiftKeyDown", -- [1138]
+ "IsLinuxClient", -- [1139]
+ "IsLoggedIn", -- [1140]
+ "IsMacClient", -- [1141]
+ "IsRightAltKeyDown", -- [1142]
+ "IsRightControlKeyDown", -- [1143]
+ "IsRightShiftKeyDown", -- [1144]
+ "IsShiftKeyDown", -- [1145]
+ "IsStereoVideoAvailable", -- [1146]
+ "IsWindowsClient", -- [1147]
+ "OpeningCinematic", -- [1148]
+ "PlayMusic", -- [1149]
+ "PlaySound", -- [1150]
+ "PlaySoundFile", -- [1151]
+ "ReloadUI", -- [1152]
+ "RepopMe", -- [1153]
+ "RequestTimePlayed", -- [1154]
+ "RestartGx", -- [1155]
+ "RunScript", -- [1156]
+ "Screenshot", -- [1157]
+ "SetAutoDeclineGuildInvites", -- [1158]
+ "seterrorhandler", -- [1159]
+ "StopCinematic", -- [1160]
+ "StopMusic", -- [1161]
+ "UIParentLoadAddOn", -- [1162]
+ "TakeScreenshot", -- [1163]
+ "BuyTrainerService", -- [1168]
+ "CheckTalentMasterDist", -- [1169]
+ "ConfirmTalentWipe", -- [1170]
+ "GetActiveTalentGroup", -- [1171]
+ "GetNumTalentTabs", -- [1172]
+ "GetNumTalents", -- [1173]
+ "GetTalentInfo", -- [1174]
+ "GetTalentLink", -- [1175]
+ "GetTalentPrereqs", -- [1176]
+ "GetTalentTabInfo", -- [1177]
+ "LearnTalent", -- [1178]
+ "SetActiveTalentGroup", -- [1179]
+ "GetNumTalentGroups", -- [1180]
+ "GetActiveTalentGroup", -- [1181]
+ "AddPreviewTalentPoints", -- [1182]
+ "GetGroupPreviewTalentPointsSpent", -- [1183]
+ "GetPreviewTalentPointsSpent", -- [1184]
+ "GetUnspentTalentPoints", -- [1185]
+ "LearnPreviewTalents", -- [1186]
+ "ResetGroupPreviewTalentPoints", -- [1187]
+ "ResetPreviewTalentPoints", -- [1188]
+ "AssistUnit", -- [1190]
+ "AttackTarget", -- [1191]
+ "ClearTarget", -- [1192]
+ "ClickTargetTradeButton", -- [1193]
+ "TargetLastEnemy", -- [1194]
+ "TargetLastTarget", -- [1195]
+ "TargetNearestEnemy", -- [1196]
+ "TargetNearestEnemyPlayer", -- [1197]
+ "TargetNearestFriend", -- [1198]
+ "TargetNearestFriendPlayer", -- [1199]
+ "TargetNearestPartyMember", -- [1200]
+ "TargetNearestRaidMember", -- [1201]
+ "TargetUnit", -- [1202]
+ "ToggleBackpack", -- [1204]
+ "ToggleBag", -- [1205]
+ "ToggleCharacter", -- [1206]
+ "ToggleFriendsFrame", -- [1207]
+ "ToggleSpellBook", -- [1208]
+ "TradeSkill", -- [1209]
+ "CloseTradeSkill", -- [1210]
+ "CollapseTradeSkillSubClass", -- [1211]
+ "PickupPlayerMoney", -- [1212]
+ "PickupTradeMoney", -- [1213]
+ "SetTradeMoney", -- [1214]
+ "ReplaceTradeEnchant", -- [1215]
+ "AssistUnit", -- [1217]
+ "CheckInteractDistance", -- [1218]
+ "DropItemOnUnit", -- [1219]
+ "FollowUnit", -- [1220]
+ "FocusUnit", -- [1221]
+ "ClearFocus", -- [1222]
+ "GetUnitName", -- [1223]
+ "GetUnitPitch", -- [1224]
+ "GetUnitSpeed", -- [1225]
+ "InviteUnit", -- [1226]
+ "IsUnitOnQuest", -- [1227]
+ "SpellCanTargetUnit", -- [1228]
+ "SpellTargetUnit", -- [1229]
+ "TargetUnit", -- [1230]
+ "UnitAffectingCombat", -- [1231]
+ "UnitArmor", -- [1232]
+ "UnitAttackBothHands", -- [1233]
+ "UnitAttackPower", -- [1234]
+ "UnitAttackSpeed", -- [1235]
+ "UnitAura", -- [1236]
+ "UnitBuff", -- [1237]
+ "UnitCanAssist", -- [1238]
+ "UnitCanAttack", -- [1239]
+ "UnitCanCooperate", -- [1240]
+ "UnitClass", -- [1241]
+ "UnitClassification", -- [1242]
+ "UnitCreatureFamily", -- [1243]
+ "UnitCreatureType", -- [1244]
+ "UnitDamage", -- [1245]
+ "UnitDebuff", -- [1246]
+ "UnitDefense", -- [1247]
+ "UnitDetailedThreatSituation", -- [1248]
+ "UnitExists", -- [1249]
+ "UnitFactionGroup", -- [1250]
+ "UnitGroupRolesAssigned", -- [1251]
+ "UnitGUID", -- [1252]
+ "GetPlayerInfoByGUID", -- [1253]
+ "UnitHasLFGDeserter", -- [1254]
+ "UnitHasLFGRandomCooldown", -- [1255]
+ "UnitHasRelicSlot", -- [1256]
+ "UnitHealth", -- [1257]
+ "UnitHealthMax", -- [1258]
+ "UnitInParty", -- [1259]
+ "UnitInRaid", -- [1260]
+ "UnitInBattleground", -- [1261]
+ "UnitIsInMyGuild", -- [1262]
+ "UnitInRange", -- [1263]
+ "UnitIsAFK", -- [1264]
+ "UnitIsCharmed", -- [1265]
+ "UnitIsConnected", -- [1266]
+ "UnitIsCorpse", -- [1267]
+ "UnitIsDead", -- [1268]
+ "UnitIsDeadOrGhost", -- [1269]
+ "UnitIsDND", -- [1270]
+ "UnitIsEnemy", -- [1271]
+ "UnitIsFeignDeath", -- [1272]
+ "UnitIsFriend", -- [1273]
+ "UnitIsGhost", -- [1274]
+ "UnitIsPVP", -- [1275]
+ "UnitIsPVPFreeForAll", -- [1276]
+ "UnitIsPVPSanctuary", -- [1277]
+ "UnitIsPartyLeader", -- [1278]
+ "UnitIsPlayer", -- [1279]
+ "UnitIsPossessed", -- [1280]
+ "UnitIsRaidOfficer", -- [1281]
+ "UnitIsSameServer", -- [1282]
+ "UnitIsTapped", -- [1283]
+ "UnitIsTappedByPlayer", -- [1284]
+ "UnitIsTappedByAllThreatList", -- [1285]
+ "UnitIsTrivial", -- [1286]
+ "UnitIsUnit", -- [1287]
+ "UnitIsVisible", -- [1288]
+ "UnitLevel", -- [1289]
+ "UnitMana", -- [1290]
+ "UnitManaMax", -- [1291]
+ "UnitName", -- [1292]
+ "UnitOnTaxi", -- [1293]
+ "UnitPlayerControlled", -- [1294]
+ "UnitPlayerOrPetInParty", -- [1295]
+ "UnitPlayerOrPetInRaid", -- [1296]
+ "UnitPVPName", -- [1297]
+ "UnitPVPRank", -- [1298]
+ "UnitPower", -- [1299]
+ "UnitPowerMax", -- [1300]
+ "UnitPowerType", -- [1301]
+ "UnitRace", -- [1302]
+ "UnitRangedAttack", -- [1303]
+ "UnitRangedAttackPower", -- [1304]
+ "UnitRangedDamage", -- [1305]
+ "UnitReaction", -- [1306]
+ "UnitResistance", -- [1307]
+ "UnitSelectionColor", -- [1308]
+ "UnitSex", -- [1309]
+ "UnitStat", -- [1310]
+ "UnitThreatSituation", -- [1311]
+ "UnitUsingVehicle", -- [1312]
+ "GetThreatStatusColor", -- [1313]
+ "UnitXP", -- [1314]
+ "UnitXPMax", -- [1315]
+ "SetPortraitTexture", -- [1316]
+ "SetPortraitToTexture", -- [1317]
+ "tinsert", -- [1318]
+}
+
+-- endp
diff --git a/libs/DF/textentry.xml b/libs/DF/textentry.xml
new file mode 100644
index 0000000..a8ec0b7
--- /dev/null
+++ b/libs/DF/textentry.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/libs/DF/tutorial_alert.xml b/libs/DF/tutorial_alert.xml
new file mode 100644
index 0000000..0545213
--- /dev/null
+++ b/libs/DF/tutorial_alert.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/libs/LibDBIcon-1.0/LibDBIcon-1.0.lua b/libs/LibDBIcon-1.0/LibDBIcon-1.0.lua
new file mode 100644
index 0000000..438171b
--- /dev/null
+++ b/libs/LibDBIcon-1.0/LibDBIcon-1.0.lua
@@ -0,0 +1,334 @@
+
+-----------------------------------------------------------------------
+-- LibDBIcon-1.0
+--
+-- Allows addons to easily create a lightweight minimap icon as an alternative to heavier LDB displays.
+--
+
+local DBICON10 = "LibDBIcon-1.0"
+local DBICON10_MINOR = 36 -- Bump on changes
+if not LibStub then error(DBICON10 .. " requires LibStub.") end
+local ldb = LibStub("LibDataBroker-1.1", true)
+if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end
+local lib = LibStub:NewLibrary(DBICON10, DBICON10_MINOR)
+if not lib then return end
+
+lib.disabled = lib.disabled or nil
+lib.objects = lib.objects or {}
+lib.callbackRegistered = lib.callbackRegistered or nil
+lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
+lib.notCreated = lib.notCreated or {}
+lib.tooltip = lib.tooltip or CreateFrame("GameTooltip", "LibDBIconTooltip", UIParent, "GameTooltipTemplate")
+
+function lib:IconCallback(event, name, key, value)
+ if lib.objects[name] then
+ if key == "icon" then
+ lib.objects[name].icon:SetTexture(value)
+ elseif key == "iconCoords" then
+ lib.objects[name].icon:UpdateCoord()
+ elseif key == "iconR" then
+ local _, g, b = lib.objects[name].icon:GetVertexColor()
+ lib.objects[name].icon:SetVertexColor(value, g, b)
+ elseif key == "iconG" then
+ local r, _, b = lib.objects[name].icon:GetVertexColor()
+ lib.objects[name].icon:SetVertexColor(r, value, b)
+ elseif key == "iconB" then
+ local r, g = lib.objects[name].icon:GetVertexColor()
+ lib.objects[name].icon:SetVertexColor(r, g, value)
+ end
+ end
+end
+if not lib.callbackRegistered then
+ ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__icon", "IconCallback")
+ ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconCoords", "IconCallback")
+ ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconR", "IconCallback")
+ ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconG", "IconCallback")
+ ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconB", "IconCallback")
+ lib.callbackRegistered = true
+end
+
+local function getAnchors(frame)
+ local x, y = frame:GetCenter()
+ if not x or not y then return "CENTER" end
+ local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
+ local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
+ return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
+end
+
+local function onEnter(self)
+ if self.isMoving then return end
+ local obj = self.dataObject
+ if obj.OnTooltipShow then
+ lib.tooltip:SetOwner(self, "ANCHOR_NONE")
+ lib.tooltip:SetPoint(getAnchors(self))
+ obj.OnTooltipShow(lib.tooltip)
+ lib.tooltip:Show()
+ elseif obj.OnEnter then
+ obj.OnEnter(self)
+ end
+end
+
+local function onLeave(self)
+ local obj = self.dataObject
+ lib.tooltip:Hide()
+ if obj.OnLeave then obj.OnLeave(self) end
+end
+
+--------------------------------------------------------------------------------
+
+local onClick, onMouseUp, onMouseDown, onDragStart, onDragStop, updatePosition
+
+do
+ local minimapShapes = {
+ ["ROUND"] = {true, true, true, true},
+ ["SQUARE"] = {false, false, false, false},
+ ["CORNER-TOPLEFT"] = {false, false, false, true},
+ ["CORNER-TOPRIGHT"] = {false, false, true, false},
+ ["CORNER-BOTTOMLEFT"] = {false, true, false, false},
+ ["CORNER-BOTTOMRIGHT"] = {true, false, false, false},
+ ["SIDE-LEFT"] = {false, true, false, true},
+ ["SIDE-RIGHT"] = {true, false, true, false},
+ ["SIDE-TOP"] = {false, false, true, true},
+ ["SIDE-BOTTOM"] = {true, true, false, false},
+ ["TRICORNER-TOPLEFT"] = {false, true, true, true},
+ ["TRICORNER-TOPRIGHT"] = {true, false, true, true},
+ ["TRICORNER-BOTTOMLEFT"] = {true, true, false, true},
+ ["TRICORNER-BOTTOMRIGHT"] = {true, true, true, false},
+ }
+
+ function updatePosition(button)
+ local angle = math.rad(button.db and button.db.minimapPos or button.minimapPos or 225)
+ local x, y, q = math.cos(angle), math.sin(angle), 1
+ if x < 0 then q = q + 1 end
+ if y > 0 then q = q + 2 end
+ local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
+ local quadTable = minimapShapes[minimapShape]
+ if quadTable[q] then
+ x, y = x*80, y*80
+ else
+ local diagRadius = 103.13708498985 --math.sqrt(2*(80)^2)-10
+ x = math.max(-80, math.min(x*diagRadius, 80))
+ y = math.max(-80, math.min(y*diagRadius, 80))
+ end
+ button:SetPoint("CENTER", Minimap, "CENTER", x, y)
+ end
+end
+
+function onClick(self, b) if self.dataObject.OnClick then self.dataObject.OnClick(self, b) end end
+function onMouseDown(self) self.isMouseDown = true; self.icon:UpdateCoord() end
+function onMouseUp(self) self.isMouseDown = false; self.icon:UpdateCoord() end
+
+do
+ local function onUpdate(self)
+ local mx, my = Minimap:GetCenter()
+ local px, py = GetCursorPosition()
+ local scale = Minimap:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ if self.db then
+ self.db.minimapPos = math.deg(math.atan2(py - my, px - mx)) % 360
+ else
+ self.minimapPos = math.deg(math.atan2(py - my, px - mx)) % 360
+ end
+ updatePosition(self)
+ end
+
+ function onDragStart(self)
+ self:LockHighlight()
+ self.isMouseDown = true
+ self.icon:UpdateCoord()
+ self:SetScript("OnUpdate", onUpdate)
+ self.isMoving = true
+ lib.tooltip:Hide()
+ end
+end
+
+function onDragStop(self)
+ self:SetScript("OnUpdate", nil)
+ self.isMouseDown = false
+ self.icon:UpdateCoord()
+ self:UnlockHighlight()
+ self.isMoving = nil
+end
+
+local defaultCoords = {0, 1, 0, 1}
+local function updateCoord(self)
+ local coords = self:GetParent().dataObject.iconCoords or defaultCoords
+ local deltaX, deltaY = 0, 0
+ if not self:GetParent().isMouseDown then
+ deltaX = (coords[2] - coords[1]) * 0.05
+ deltaY = (coords[4] - coords[3]) * 0.05
+ end
+ self:SetTexCoord(coords[1] + deltaX, coords[2] - deltaX, coords[3] + deltaY, coords[4] - deltaY)
+end
+
+local function createButton(name, object, db)
+ local button = CreateFrame("Button", "LibDBIcon10_"..name, Minimap)
+ button.dataObject = object
+ button.db = db
+ button:SetFrameStrata("MEDIUM")
+ button:SetSize(31, 31)
+ button:SetFrameLevel(8)
+ button:RegisterForClicks("anyUp")
+ button:RegisterForDrag("LeftButton")
+ button:SetHighlightTexture(136477) --"Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight"
+ local overlay = button:CreateTexture(nil, "OVERLAY")
+ overlay:SetSize(53, 53)
+ overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
+ overlay:SetPoint("TOPLEFT")
+ local background = button:CreateTexture(nil, "BACKGROUND")
+ background:SetSize(20, 20)
+ background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
+ background:SetPoint("TOPLEFT", 7, -5)
+ local icon = button:CreateTexture(nil, "ARTWORK")
+ icon:SetSize(17, 17)
+ icon:SetTexture(object.icon)
+ icon:SetPoint("TOPLEFT", 7, -6)
+ button.icon = icon
+ button.isMouseDown = false
+
+ local r, g, b = icon:GetVertexColor()
+ icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b)
+
+ icon.UpdateCoord = updateCoord
+ icon:UpdateCoord()
+
+ button:SetScript("OnEnter", onEnter)
+ button:SetScript("OnLeave", onLeave)
+ button:SetScript("OnClick", onClick)
+ if not db or not db.lock then
+ button:SetScript("OnDragStart", onDragStart)
+ button:SetScript("OnDragStop", onDragStop)
+ end
+ button:SetScript("OnMouseDown", onMouseDown)
+ button:SetScript("OnMouseUp", onMouseUp)
+
+ lib.objects[name] = button
+
+ if lib.loggedIn then
+ updatePosition(button)
+ if not db or not db.hide then button:Show()
+ else button:Hide() end
+ end
+ lib.callbacks:Fire("LibDBIcon_IconCreated", button, name) -- Fire 'Icon Created' callback
+end
+
+-- We could use a metatable.__index on lib.objects, but then we'd create
+-- the icons when checking things like :IsRegistered, which is not necessary.
+local function check(name)
+ if lib.notCreated[name] then
+ createButton(name, lib.notCreated[name][1], lib.notCreated[name][2])
+ lib.notCreated[name] = nil
+ end
+end
+
+lib.loggedIn = lib.loggedIn or false
+-- Wait a bit with the initial positioning to let any GetMinimapShape addons
+-- load up.
+if not lib.loggedIn then
+ local f = CreateFrame("Frame")
+ f:SetScript("OnEvent", function()
+ for _, object in pairs(lib.objects) do
+ updatePosition(object)
+ if not lib.disabled and (not object.db or not object.db.hide) then object:Show()
+ else object:Hide() end
+ end
+ lib.loggedIn = true
+ f:SetScript("OnEvent", nil)
+ f = nil
+ end)
+ f:RegisterEvent("PLAYER_LOGIN")
+end
+
+local function getDatabase(name)
+ return lib.notCreated[name] and lib.notCreated[name][2] or lib.objects[name].db
+end
+
+function lib:Register(name, object, db)
+ if not object.icon then error("Can't register LDB objects without icons set!") end
+ if lib.objects[name] or lib.notCreated[name] then error("Already registered, nubcake.") end
+ if not lib.disabled and (not db or not db.hide) then
+ createButton(name, object, db)
+ else
+ lib.notCreated[name] = {object, db}
+ end
+end
+
+function lib:Lock(name)
+ if not lib:IsRegistered(name) then return end
+ if lib.objects[name] then
+ lib.objects[name]:SetScript("OnDragStart", nil)
+ lib.objects[name]:SetScript("OnDragStop", nil)
+ end
+ local db = getDatabase(name)
+ if db then db.lock = true end
+end
+
+function lib:Unlock(name)
+ if not lib:IsRegistered(name) then return end
+ if lib.objects[name] then
+ lib.objects[name]:SetScript("OnDragStart", onDragStart)
+ lib.objects[name]:SetScript("OnDragStop", onDragStop)
+ end
+ local db = getDatabase(name)
+ if db then db.lock = nil end
+end
+
+function lib:Hide(name)
+ if not lib.objects[name] then return end
+ lib.objects[name]:Hide()
+end
+function lib:Show(name)
+ if lib.disabled then return end
+ check(name)
+ lib.objects[name]:Show()
+ updatePosition(lib.objects[name])
+end
+function lib:IsRegistered(name)
+ return (lib.objects[name] or lib.notCreated[name]) and true or false
+end
+function lib:Refresh(name, db)
+ if lib.disabled then return end
+ check(name)
+ local button = lib.objects[name]
+ if db then button.db = db end
+ updatePosition(button)
+ if not button.db or not button.db.hide then
+ button:Show()
+ else
+ button:Hide()
+ end
+ if not button.db or not button.db.lock then
+ button:SetScript("OnDragStart", onDragStart)
+ button:SetScript("OnDragStop", onDragStop)
+ else
+ button:SetScript("OnDragStart", nil)
+ button:SetScript("OnDragStop", nil)
+ end
+end
+function lib:GetMinimapButton(name)
+ return lib.objects[name]
+end
+
+function lib:EnableLibrary()
+ lib.disabled = nil
+ for name, object in pairs(lib.objects) do
+ if not object.db or not object.db.hide then
+ object:Show()
+ updatePosition(object)
+ end
+ end
+ for name, data in pairs(lib.notCreated) do
+ if not data.db or not data.db.hide then
+ createButton(name, data[1], data[2])
+ lib.notCreated[name] = nil
+ end
+ end
+end
+
+function lib:DisableLibrary()
+ lib.disabled = true
+ for name, object in pairs(lib.objects) do
+ object:Hide()
+ end
+end
+
diff --git a/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua b/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua
new file mode 100644
index 0000000..f47c0cd
--- /dev/null
+++ b/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua
@@ -0,0 +1,90 @@
+
+assert(LibStub, "LibDataBroker-1.1 requires LibStub")
+assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0")
+
+local lib, oldminor = LibStub:NewLibrary("LibDataBroker-1.1", 4)
+if not lib then return end
+oldminor = oldminor or 0
+
+
+lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
+lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {}
+local attributestorage, namestorage, callbacks = lib.attributestorage, lib.namestorage, lib.callbacks
+
+if oldminor < 2 then
+ lib.domt = {
+ __metatable = "access denied",
+ __index = function(self, key) return attributestorage[self] and attributestorage[self][key] end,
+ }
+end
+
+if oldminor < 3 then
+ lib.domt.__newindex = function(self, key, value)
+ if not attributestorage[self] then attributestorage[self] = {} end
+ if attributestorage[self][key] == value then return end
+ attributestorage[self][key] = value
+ local name = namestorage[self]
+ if not name then return end
+ callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value, self)
+ end
+end
+
+if oldminor < 2 then
+ function lib:NewDataObject(name, dataobj)
+ if self.proxystorage[name] then return end
+
+ if dataobj then
+ assert(type(dataobj) == "table", "Invalid dataobj, must be nil or a table")
+ self.attributestorage[dataobj] = {}
+ for i,v in pairs(dataobj) do
+ self.attributestorage[dataobj][i] = v
+ dataobj[i] = nil
+ end
+ end
+ dataobj = setmetatable(dataobj or {}, self.domt)
+ self.proxystorage[name], self.namestorage[dataobj] = dataobj, name
+ self.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj)
+ return dataobj
+ end
+end
+
+if oldminor < 1 then
+ function lib:DataObjectIterator()
+ return pairs(self.proxystorage)
+ end
+
+ function lib:GetDataObjectByName(dataobjectname)
+ return self.proxystorage[dataobjectname]
+ end
+
+ function lib:GetNameByDataObject(dataobject)
+ return self.namestorage[dataobject]
+ end
+end
+
+if oldminor < 4 then
+ local next = pairs(attributestorage)
+ function lib:pairs(dataobject_or_name)
+ local t = type(dataobject_or_name)
+ assert(t == "string" or t == "table", "Usage: ldb:pairs('dataobjectname') or ldb:pairs(dataobject)")
+
+ local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
+ assert(attributestorage[dataobj], "Data object not found")
+
+ return next, attributestorage[dataobj], nil
+ end
+
+ local ipairs_iter = ipairs(attributestorage)
+ function lib:ipairs(dataobject_or_name)
+ local t = type(dataobject_or_name)
+ assert(t == "string" or t == "table", "Usage: ldb:ipairs('dataobjectname') or ldb:ipairs(dataobject)")
+
+ local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
+ assert(attributestorage[dataobj], "Data object not found")
+
+ return ipairs_iter, attributestorage[dataobj], 0
+ end
+end
diff --git a/libs/LibDeflate/LICENSE.txt b/libs/LibDeflate/LICENSE.txt
new file mode 100644
index 0000000..7da0484
--- /dev/null
+++ b/libs/LibDeflate/LICENSE.txt
@@ -0,0 +1,147 @@
+
GNU GENERAL PUBLIC LICENSE
+
Version 3, 29 June 2007
+
Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
Preamble
+
The GNU General Public License is a free, copyleft license for software and other kinds of works.
+
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
+
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
+
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
+
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
+
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
+
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
+
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
+
The precise terms and conditions for copying, distribution and modification follow.
+
TERMS AND CONDITIONS
+
0. Definitions.
+
“This License” refers to version 3 of the GNU General Public License.
+
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
+
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
+
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
+
A “covered work” means either the unmodified Program or a work based on the Program.
+
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
+
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
+
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
+
1. Source Code.
+
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
+
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
+
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
+
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
+
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
+
The Corresponding Source for a work in source code form is that same work.
+
2. Basic Permissions.
+
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
+
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
+
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
+
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
+
4. Conveying Verbatim Copies.
+
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
+
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
+
5. Conveying Modified Source Versions.
+
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
+
+
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
+
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
+
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
+
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
+
+
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
+
6. Conveying Non-Source Forms.
+
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
+
+
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
+
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
+
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
+
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
+
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
+
+
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
+
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
+
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
+
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
+
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
+
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
+
7. Additional Terms.
+
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
+
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
+
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
+
+
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
+
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
+
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
+
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
+
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
+
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
+
+
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
+
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
+
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
+
8. Termination.
+
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
+
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
+
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
+
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
+
9. Acceptance Not Required for Having Copies.
+
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
+
10. Automatic Licensing of Downstream Recipients.
+
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
+
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
+
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
+
11. Patents.
+
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
+
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
+
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
+
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
+
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
+
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
+
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
+
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
+
12. No Surrender of Others' Freedom.
+
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
+
13. Use with the GNU Affero General Public License.
+
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
+
14. Revised Versions of this License.
+
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
+
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
+
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
+
15. Disclaimer of Warranty.
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
16. Limitation of Liability.
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
17. Interpretation of Sections 15 and 16.
+
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
+
END OF TERMS AND CONDITIONS
+
How to Apply These Terms to Your New Programs
+
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
+
<one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see http://www.gnu.org/licenses.
+
+
Also add information on how to contact you by electronic and paper mail.
+
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
+
<program> Copyright (C) <year> <name of author>
+
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
+
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see http://www.gnu.org/licenses.
+
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read http://www.gnu.org/philosophy/why-not-lgpl.html.
\ No newline at end of file
diff --git a/libs/LibDeflate/LibDeflate.lua b/libs/LibDeflate/LibDeflate.lua
new file mode 100644
index 0000000..7daf70f
--- /dev/null
+++ b/libs/LibDeflate/LibDeflate.lua
@@ -0,0 +1,3509 @@
+--[[--
+LibDeflate 1.0.0-release
+Pure Lua compressor and decompressor with high compression ratio using
+DEFLATE/zlib format.
+
+@file LibDeflate.lua
+@author Haoqian He (Github: SafeteeWoW; World of Warcraft: Safetyy-Illidan(US))
+@copyright LibDeflate <2018> Haoqian He
+@license GNU General Public License Version 3 or later
+
+This library is implemented according to the following specifications.
+Report a bug if LibDeflate is not fully compliant with those specs.
+Both compressors and decompressors have been implemented in the library.
+1. RFC1950: DEFLATE Compressed Data Format Specification version 1.3
+https://tools.ietf.org/html/rfc1951
+2. RFC1951: ZLIB Compressed Data Format Specification version 3.3
+https://tools.ietf.org/html/rfc1950
+
+This library requires Lua 5.1/5.2/5.3 interpreter or LuaJIT v2.0+.
+This library does not have any dependencies.
+
+This file "LibDeflate.lua" is the only source file of
+the library.
+Submit suggestions or report bugs to
+https://github.com/safeteeWow/LibDeflate/issues
+]]
+
+--[[
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see https://www.gnu.org/licenses/.
+
+Credits:
+1. zlib, by Jean-loup Gailly (compression) and Mark Adler (decompression).
+ http://www.zlib.net/
+ Licensed under zlib License. http://www.zlib.net/zlib_license.html
+ For the compression algorithm.
+2. puff, by Mark Adler. https://github.com/madler/zlib/tree/master/contrib/puff
+ Licensed under zlib License. http://www.zlib.net/zlib_license.html
+ For the decompression algorithm.
+3. LibCompress, by jjsheets and Galmok of European Stormrage (Horde)
+ https://www.wowace.com/projects/libcompress
+ Licensed under GPLv2.
+ https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ For the code to create customized codec.
+4. WeakAuras2,
+ https://github.com/WeakAuras/WeakAuras2
+ Licensed under GPLv2.
+ For the 6bit encoding and decoding.
+]]
+
+--[[
+ Curseforge auto-packaging replacements:
+
+ Project Date: 2018-07-29T18:58:38Z
+ Project Hash: 420f583c8c1ad0d4fc12398c86e99a65cf37a79a
+ Project Version: 1.0.0-release
+--]]
+
+local LibDeflate
+
+do
+ -- Semantic version. all lowercase.
+ -- Suffix can be alpha1, alpha2, beta1, beta2, rc1, rc2, etc.
+ -- NOTE: Two version numbers needs to modify.
+ -- 1. On the top of LibDeflate.lua
+ -- 2. HERE
+ local _VERSION = "1.0.0-release"
+
+ local _COPYRIGHT =
+ "LibDeflate ".._VERSION
+ .." Copyright (C) 2018 Haoqian He."
+ .." License GPLv3+: GNU GPL version 3 or later"
+
+ -- Register in the World of Warcraft library "LibStub" if detected.
+ if LibStub then
+ local MAJOR, MINOR = "LibDeflate", -1
+ -- When MAJOR is changed, I should name it as LibDeflate2
+ local lib, minor = LibStub:GetLibrary(MAJOR, true)
+ if lib and minor and minor >= MINOR then -- No need to update.
+ return lib
+ else -- Update or first time register
+ LibDeflate = LibStub:NewLibrary(MAJOR, _VERSION)
+ -- NOTE: It is important that new version has implemented
+ -- all exported APIs and tables in the old version,
+ -- so the old library is fully garbage collected,
+ -- and we 100% ensure the backward compatibility.
+ end
+ else -- "LibStub" is not detected.
+ LibDeflate = {}
+ end
+
+ LibDeflate._VERSION = _VERSION
+ LibDeflate._COPYRIGHT = _COPYRIGHT
+end
+
+-- localize Lua api for faster access.
+local assert = assert
+local error = error
+local pairs = pairs
+local string_byte = string.byte
+local string_char = string.char
+local string_find = string.find
+local string_gsub = string.gsub
+local string_sub = string.sub
+local table_concat = table.concat
+local table_sort = table.sort
+local tostring = tostring
+local type = type
+
+-- Converts i to 2^i, (0<=i<=32)
+-- This is used to implement bit left shift and bit right shift.
+-- "x >> y" in C: "(x-x%_pow2[y])/_pow2[y]" in Lua
+-- "x << y" in C: "x*_pow2[y]" in Lua
+local _pow2 = {}
+
+-- Converts any byte to a character, (0<=byte<=255)
+local _byte_to_char = {}
+
+-- _reverseBitsTbl[len][val] stores the bit reverse of
+-- the number with bit length "len" and value "val"
+-- For example, decimal number 6 with bits length 5 is binary 00110
+-- It's reverse is binary 01100,
+-- which is decimal 12 and 12 == _reverseBitsTbl[5][6]
+-- 1<=len<=9, 0<=val<=2^len-1
+-- The reason for 1<=len<=9 is that the max of min bitlen of huffman code
+-- of a huffman alphabet is 9?
+local _reverse_bits_tbl = {}
+
+-- Convert a LZ77 length (3<=len<=258) to
+-- a deflate literal/LZ77_length code (257<=code<=285)
+local _length_to_deflate_code = {}
+
+-- convert a LZ77 length (3<=len<=258) to
+-- a deflate literal/LZ77_length code extra bits.
+local _length_to_deflate_extra_bits = {}
+
+-- Convert a LZ77 length (3<=len<=258) to
+-- a deflate literal/LZ77_length code extra bit length.
+local _length_to_deflate_extra_bitlen = {}
+
+-- Convert a small LZ77 distance (1<=dist<=256) to a deflate code.
+local _dist256_to_deflate_code = {}
+
+-- Convert a small LZ77 distance (1<=dist<=256) to
+-- a deflate distance code extra bits.
+local _dist256_to_deflate_extra_bits = {}
+
+-- Convert a small LZ77 distance (1<=dist<=256) to
+-- a deflate distance code extra bit length.
+local _dist256_to_deflate_extra_bitlen = {}
+
+-- Convert a literal/LZ77_length deflate code to LZ77 base length
+-- The key of the table is (code - 256), 257<=code<=285
+local _literal_deflate_code_to_base_len = {
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258,
+}
+
+-- Convert a literal/LZ77_length deflate code to base LZ77 length extra bits
+-- The key of the table is (code - 256), 257<=code<=285
+local _literal_deflate_code_to_extra_bitlen = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0,
+}
+
+-- Convert a distance deflate code to base LZ77 distance. (0<=code<=29)
+local _dist_deflate_code_to_base_dist = {
+ [0] = 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+ 8193, 12289, 16385, 24577,
+}
+
+-- Convert a distance deflate code to LZ77 bits length. (0<=code<=29)
+local _dist_deflate_code_to_extra_bitlen = {
+ [0] = 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
+}
+
+-- The code order of the first huffman header in the dynamic deflate block.
+-- See the page 12 of RFC1951
+local _rle_codes_huffman_bitlen_order = {16, 17, 18,
+ 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
+}
+
+-- The following tables are used by fixed deflate block.
+-- The value of these tables are assigned at the bottom of the source.
+
+-- The huffman code of the literal/LZ77_length deflate codes,
+-- in fixed deflate block.
+local _fix_block_literal_huffman_code
+
+-- Convert huffman code of the literal/LZ77_length to deflate codes,
+-- in fixed deflate block.
+local _fix_block_literal_huffman_to_deflate_code
+
+-- The bit length of the huffman code of literal/LZ77_length deflate codes,
+-- in fixed deflate block.
+local _fix_block_literal_huffman_bitlen
+
+-- The count of each bit length of the literal/LZ77_length deflate codes,
+-- in fixed deflate block.
+local _fix_block_literal_huffman_bitlen_count
+
+-- The huffman code of the distance deflate codes,
+-- in fixed deflate block.
+local _fix_block_dist_huffman_code
+
+-- Convert huffman code of the distance to deflate codes,
+-- in fixed deflate block.
+local _fix_block_dist_huffman_to_deflate_code
+
+-- The bit length of the huffman code of the distance deflate codes,
+-- in fixed deflate block.
+local _fix_block_dist_huffman_bitlen
+
+-- The count of each bit length of the huffman code of
+-- the distance deflate codes,
+-- in fixed deflate block.
+local _fix_block_dist_huffman_bitlen_count
+
+for i = 0, 255 do
+ _byte_to_char[i] = string_char(i)
+end
+
+do
+ local pow = 1
+ for i = 0, 32 do
+ _pow2[i] = pow
+ pow = pow * 2
+ end
+end
+
+for i = 1, 9 do
+ _reverse_bits_tbl[i] = {}
+ for j=0, _pow2[i+1]-1 do
+ local reverse = 0
+ local value = j
+ for _ = 1, i do
+ -- The following line is equivalent to "res | (code %2)" in C.
+ reverse = reverse - reverse%2
+ + (((reverse%2==1) or (value % 2) == 1) and 1 or 0)
+ value = (value-value%2)/2
+ reverse = reverse * 2
+ end
+ _reverse_bits_tbl[i][j] = (reverse-reverse%2)/2
+ end
+end
+
+-- The source code is written according to the pattern in the numbers
+-- in RFC1951 Page10.
+do
+ local a = 18
+ local b = 16
+ local c = 265
+ local bitlen = 1
+ for len = 3, 258 do
+ if len <= 10 then
+ _length_to_deflate_code[len] = len + 254
+ _length_to_deflate_extra_bitlen[len] = 0
+ elseif len == 258 then
+ _length_to_deflate_code[len] = 285
+ _length_to_deflate_extra_bitlen[len] = 0
+ else
+ if len > a then
+ a = a + b
+ b = b * 2
+ c = c + 4
+ bitlen = bitlen + 1
+ end
+ local t = len-a-1+b/2
+ _length_to_deflate_code[len] = (t-(t%(b/8)))/(b/8) + c
+ _length_to_deflate_extra_bitlen[len] = bitlen
+ _length_to_deflate_extra_bits[len] = t % (b/8)
+ end
+ end
+end
+
+-- The source code is written according to the pattern in the numbers
+-- in RFC1951 Page11.
+do
+ _dist256_to_deflate_code[1] = 0
+ _dist256_to_deflate_code[2] = 1
+ _dist256_to_deflate_extra_bitlen[1] = 0
+ _dist256_to_deflate_extra_bitlen[2] = 0
+
+ local a = 3
+ local b = 4
+ local code = 2
+ local bitlen = 0
+ for dist = 3, 256 do
+ if dist > b then
+ a = a * 2
+ b = b * 2
+ code = code + 2
+ bitlen = bitlen + 1
+ end
+ _dist256_to_deflate_code[dist] = (dist <= a) and code or (code+1)
+ _dist256_to_deflate_extra_bitlen[dist] = (bitlen < 0) and 0 or bitlen
+ if b >= 8 then
+ _dist256_to_deflate_extra_bits[dist] = (dist-b/2-1) % (b/4)
+ end
+ end
+end
+
+--- Calculate the Adler-32 checksum of the string.
+-- See RFC1950 Page 9 https://tools.ietf.org/html/rfc1950 for the
+-- definition of Adler-32 checksum.
+-- @param str [string] the input string to calcuate its Adler-32 checksum.
+-- @return [integer] The Adler-32 checksum, which is greater or equal to 0,
+-- and less than 2^32 (4294967296).
+function LibDeflate:Adler32(str)
+ -- This function is loop unrolled by better performance.
+ --
+ -- Here is the minimum code:
+ --
+ -- local a = 1
+ -- local b = 0
+ -- for i=1, #str do
+ -- local s = string.byte(str, i, i)
+ -- a = (a+s)%65521
+ -- b = (b+a)%65521
+ -- end
+ -- return b*65536+a
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:Adler32(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ local strlen = #str
+
+ local i = 1
+ local a = 1
+ local b = 0
+ while i <= strlen - 15 do
+ local x1, x2, x3, x4, x5, x6, x7, x8,
+ x9, x10, x11, x12, x13, x14, x15, x16 = string_byte(str, i, i+15)
+ b = (b+16*a+16*x1+15*x2+14*x3+13*x4+12*x5+11*x6+10*x7+9*x8+8*x9
+ +7*x10+6*x11+5*x12+4*x13+3*x14+2*x15+x16)%65521
+ a = (a+x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16)%65521
+ i = i + 16
+ end
+ while (i <= strlen) do
+ local x = string_byte(str, i, i)
+ a = (a + x) % 65521
+ b = (b + a) % 65521
+ i = i + 1
+ end
+ return (b*65536+a) % 4294967296
+end
+
+-- Compare adler32 checksum.
+-- adler32 should be compared with a mod to avoid sign problem
+-- 4072834167 (unsigned) is the same adler32 as -222133129
+local function IsEqualAdler32(actual, expected)
+ return (actual % 4294967296) == (expected % 4294967296)
+end
+
+--- Create a preset dictionary.
+--
+-- This function is not fast, and the memory consumption of the produced
+-- dictionary is about 50 times of the input string. Therefore, it is suggestted
+-- to run this function only once in your program.
+--
+-- It is very important to know that if you do use a preset dictionary,
+-- compressors and decompressors MUST USE THE SAME dictionary. That is,
+-- dictionary must be created using the same string. If you update your program
+-- with a new dictionary, people with the old version won't be able to transmit
+-- data with people with the new version. Therefore, changing the dictionary
+-- must be very careful.
+--
+-- The parameters "strlen" and "adler32" add a layer of verification to ensure
+-- the parameter "str" is not modified unintentionally during the program
+-- development.
+--
+-- @usage local dict_str = "1234567890"
+--
+-- -- print(dict_str:len(), LibDeflate:Adler32(dict_str))
+-- -- Hardcode the print result below to verify it to avoid acciently
+-- -- modification of 'str' during the program development.
+-- -- string length: 10, Adler-32: 187433486,
+-- -- Don't calculate string length and its Adler-32 at run-time.
+--
+-- local dict = LibDeflate:CreateDictionary(dict_str, 10, 187433486)
+--
+-- @param str [string] The string used as the preset dictionary.
+-- You should put stuffs that frequently appears in the dictionary
+-- string and preferablely put more frequently appeared stuffs toward the end
+-- of the string.
+-- Empty string and string longer than 32768 bytes are not allowed.
+-- @param strlen [integer] The length of 'str'. Please pass in this parameter
+-- as a hardcoded constant, in order to verify the content of 'str'. The value
+-- of this parameter should be known before your program runs.
+-- @param adler32 [integer] The Adler-32 checksum of 'str'. Please pass in this
+-- parameter as a hardcoded constant, in order to verify the content of 'str'.
+-- The value of this parameter should be known before your program runs.
+-- @return [table] The dictionary used for preset dictionary compression and
+-- decompression.
+-- @raise error if 'strlen' does not match the length of 'str',
+-- or if 'adler32' does not match the Adler-32 checksum of 'str'.
+function LibDeflate:CreateDictionary(str, strlen, adler32)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if type(strlen) ~= "number" then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'strlen' - number expected got '%s'."):format(
+ type(strlen)), 2)
+ end
+ if type(adler32) ~= "number" then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'adler32' - number expected got '%s'."):format(
+ type(adler32)), 2)
+ end
+ if strlen ~= #str then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'strlen' does not match the actual length of 'str'."
+ .." 'strlen': %u, '#str': %u ."
+ .." Please check if 'str' is modified unintentionally.")
+ :format(strlen, #str))
+ end
+ if strlen == 0 then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'str' - Empty string is not allowed."), 2)
+ end
+ if strlen > 32768 then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'str' - string longer than 32768 bytes is not allowed."
+ .." Got %d bytes."):format(strlen), 2)
+ end
+ local actual_adler32 = self:Adler32(str)
+ if not IsEqualAdler32(adler32, actual_adler32) then
+ error(("Usage: LibDeflate:CreateDictionary(str, strlen, adler32):"
+ .." 'adler32' does not match the actual adler32 of 'str'."
+ .." 'adler32': %u, 'Adler32(str)': %u ."
+ .." Please check if 'str' is modified unintentionally.")
+ :format(adler32, actual_adler32))
+ end
+
+ local dictionary = {}
+ dictionary.adler32 = adler32
+ dictionary.hash_tables = {}
+ dictionary.string_table = {}
+ dictionary.strlen = strlen
+ local string_table = dictionary.string_table
+ local hash_tables = dictionary.hash_tables
+ string_table[1] = string_byte(str, 1, 1)
+ string_table[2] = string_byte(str, 2, 2)
+ if strlen >= 3 then
+ local i = 1
+ local hash = string_table[1]*256+string_table[2]
+ while i <= strlen - 2 - 3 do
+ local x1, x2, x3, x4 = string_byte(str, i+2, i+5)
+ string_table[i+2] = x1
+ string_table[i+3] = x2
+ string_table[i+4] = x3
+ string_table[i+5] = x4
+ hash = (hash*256+x1)%16777216
+ local t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = i-strlen
+ i = i + 1
+ hash = (hash*256+x2)%16777216
+ t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = i-strlen
+ i = i + 1
+ hash = (hash*256+x3)%16777216
+ t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = i-strlen
+ i = i + 1
+ hash = (hash*256+x4)%16777216
+ t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = i-strlen
+ i = i + 1
+ end
+ while i <= strlen - 2 do
+ local x = string_byte(str, i+2)
+ string_table[i+2] = x
+ hash = (hash*256+x)%16777216
+ local t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = i-strlen
+ i = i + 1
+ end
+ end
+ return dictionary
+end
+
+-- Check if the dictionary is valid.
+-- @param dictionary The preset dictionary for compression and decompression.
+-- @return true if valid, false if not valid.
+-- @return if not valid, the error message.
+local function IsValidDictionary(dictionary)
+ if type(dictionary) ~= "table" then
+ return false, ("'dictionary' - table expected got '%s'.")
+ :format(type(dictionary))
+ end
+ if type(dictionary.adler32) ~= "number"
+ or type(dictionary.string_table) ~= "table"
+ or type(dictionary.strlen) ~= "number"
+ or dictionary.strlen <= 0
+ or dictionary.strlen > 32768
+ or dictionary.strlen ~= #dictionary.string_table
+ or type(dictionary.hash_tables) ~= "table"
+ then
+ return false, ("'dictionary' - corrupted dictionary.")
+ :format(type(dictionary))
+ end
+ return true, ""
+end
+
+--[[
+ key of the configuration table is the compression level,
+ and its value stores the compression setting.
+ These numbers come from zlib source code.
+
+ Higher compression level usually means better compression.
+ (Because LibDeflate uses a simplified version of zlib algorithm,
+ there is no guarantee that higher compression level does not create
+ bigger file than lower level, but I can say it's 99% likely)
+
+ Be careful with the high compression level. This is a pure lua
+ implementation compressor/decompressor, which is significant slower than
+ a C/C++ equivalant compressor/decompressor. Very high compression level
+ costs significant more CPU time, and usually compression size won't be
+ significant smaller when you increase compression level by 1, when the
+ level is already very high. Benchmark yourself if you can afford it.
+
+ See also https://github.com/madler/zlib/blob/master/doc/algorithm.txt,
+ https://github.com/madler/zlib/blob/master/deflate.c for more information.
+
+ The meaning of each field:
+ @field 1 use_lazy_evaluation:
+ true/false. Whether the program uses lazy evaluation.
+ See what is "lazy evaluation" in the link above.
+ lazy_evaluation improves ratio, but relatively slow.
+ @field 2 good_prev_length:
+ Only effective if lazy is set, Only use 1/4 of max_chain,
+ if prev length of lazy match is above this.
+ @field 3 max_insert_length/max_lazy_match:
+ If not using lazy evaluation,
+ insert new strings in the hash table only if the match length is not
+ greater than this length.
+ If using lazy evaluation, only continue lazy evaluation,
+ if previous match length is strictly smaller than this value.
+ @field 4 nice_length:
+ Number. Don't continue to go down the hash chain,
+ if match length is above this.
+ @field 5 max_chain:
+ Number. The maximum number of hash chains we look.
+--]]
+local _compression_level_configs = {
+ [0] = {false, nil, 0, 0, 0}, -- level 0, no compression
+ [1] = {false, nil, 4, 8, 4}, -- level 1, similar to zlib level 1
+ [2] = {false, nil, 5, 18, 8}, -- level 2, similar to zlib level 2
+ [3] = {false, nil, 6, 32, 32}, -- level 3, similar to zlib level 3
+ [4] = {true, 4, 4, 16, 16}, -- level 4, similar to zlib level 4
+ [5] = {true, 8, 16, 32, 32}, -- level 5, similar to zlib level 5
+ [6] = {true, 8, 16, 128, 128}, -- level 6, similar to zlib level 6
+ [7] = {true, 8, 32, 128, 256}, -- (SLOW) level 7, similar to zlib level 7
+ [8] = {true, 32, 128, 258, 1024} , --(SLOW) level 8,similar to zlib level 8
+ [9] = {true, 32, 258, 258, 4096},
+ -- (VERY SLOW) level 9, similar to zlib level 9
+}
+
+-- Check if the compression/decompression arguments is valid
+-- @param str The input string.
+-- @param check_dictionary if true, check if dictionary is valid.
+-- @param dictionary The preset dictionary for compression and decompression.
+-- @param check_configs if true, check if config is valid.
+-- @param configs The compression configuration table
+-- @return true if valid, false if not valid.
+-- @return if not valid, the error message.
+local function IsValidArguments(str,
+ check_dictionary, dictionary,
+ check_configs, configs)
+
+ if type(str) ~= "string" then
+ return false,
+ ("'str' - string expected got '%s'."):format(type(str))
+ end
+ if check_dictionary then
+ local dict_valid, dict_err = IsValidDictionary(dictionary)
+ if not dict_valid then
+ return false, dict_err
+ end
+ end
+ if check_configs then
+ local type_configs = type(configs)
+ if type_configs ~= "nil" and type_configs ~= "table" then
+ return false,
+ ("'configs' - nil or table expected got '%s'.")
+ :format(type(configs))
+ end
+ if type_configs == "table" then
+ for k, v in pairs(configs) do
+ if k ~= "level" and k ~= "strategy" then
+ return false,
+ ("'configs' - unsupported table key in the configs: '%s'.")
+ :format(k)
+ elseif k == "level" and not _compression_level_configs[v] then
+ return false,
+ ("'configs' - unsupported 'level': %s."):format(tostring(v))
+ elseif k == "strategy" and v ~= "fixed" and v ~= "huffman_only"
+ and v ~= "dynamic" then
+ -- random_block_type is for testing purpose
+ return false, ("'configs' - unsupported 'strategy': '%s'.")
+ :format(tostring(v))
+ end
+ end
+ end
+ end
+ return true, ""
+end
+
+
+
+--[[ --------------------------------------------------------------------------
+ Compress code
+--]] --------------------------------------------------------------------------
+
+-- partial flush to save memory
+local _FLUSH_MODE_MEMORY_CLEANUP = 0
+-- full flush with partial bytes
+local _FLUSH_MODE_OUTPUT = 1
+-- write bytes to get to byte boundary
+local _FLUSH_MODE_BYTE_BOUNDARY = 2
+-- no flush, just get num of bits written so far
+local _FLUSH_MODE_NO_FLUSH = 3
+
+--[[
+ Create an empty writer to easily write stuffs as the unit of bits.
+ Return values:
+ 1. WriteBits(code, bitlen):
+ 2. WriteString(str):
+ 3. Flush(mode):
+--]]
+local function CreateWriter()
+ local buffer_size = 0
+ local cache = 0
+ local cache_bitlen = 0
+ local total_bitlen = 0
+ local buffer = {}
+ -- When buffer is big enough, flush into result_buffer to save memory.
+ local result_buffer = {}
+
+ -- Write bits with value "value" and bit length of "bitlen" into writer.
+ -- @param value: The value being written
+ -- @param bitlen: The bit length of "value"
+ -- @return nil
+ local function WriteBits(value, bitlen)
+ cache = cache + value * _pow2[cache_bitlen]
+ cache_bitlen = cache_bitlen + bitlen
+ total_bitlen = total_bitlen + bitlen
+ -- Only bulk to buffer every 4 bytes. This is quicker.
+ if cache_bitlen >= 32 then
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] =
+ _byte_to_char[cache % 256]
+ .._byte_to_char[((cache-cache%256)/256 % 256)]
+ .._byte_to_char[((cache-cache%65536)/65536 % 256)]
+ .._byte_to_char[((cache-cache%16777216)/16777216 % 256)]
+ local rshift_mask = _pow2[32 - cache_bitlen + bitlen]
+ cache = (value - value%rshift_mask)/rshift_mask
+ cache_bitlen = cache_bitlen - 32
+ end
+ end
+
+ -- Write the entire string into the writer.
+ -- @param str The string being written
+ -- @return nil
+ local function WriteString(str)
+ for _ = 1, cache_bitlen, 8 do
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = string_char(cache % 256)
+ cache = (cache-cache%256)/256
+ end
+ cache_bitlen = 0
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = str
+ total_bitlen = total_bitlen + #str*8
+ end
+
+ -- Flush current stuffs in the writer and return it.
+ -- This operation will free most of the memory.
+ -- @param mode See the descrtion of the constant and the source code.
+ -- @return The total number of bits stored in the writer right now.
+ -- for byte boundary mode, it includes the padding bits.
+ -- for output mode, it does not include padding bits.
+ -- @return Return the outputs if mode is output.
+ local function FlushWriter(mode)
+ if mode == _FLUSH_MODE_NO_FLUSH then
+ return total_bitlen
+ end
+
+ if mode == _FLUSH_MODE_OUTPUT
+ or mode == _FLUSH_MODE_BYTE_BOUNDARY then
+ -- Full flush, also output cache.
+ -- Need to pad some bits if cache_bitlen is not multiple of 8.
+ local padding_bitlen = (8 - cache_bitlen % 8) % 8
+
+ if cache_bitlen > 0 then
+ -- padding with all 1 bits, mainly because "\000" is not
+ -- good to be tranmitted. I do this so "\000" is a little bit
+ -- less frequent.
+ cache = cache - _pow2[cache_bitlen]
+ + _pow2[cache_bitlen+padding_bitlen]
+ for _ = 1, cache_bitlen, 8 do
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = _byte_to_char[cache % 256]
+ cache = (cache-cache%256)/256
+ end
+
+ cache = 0
+ cache_bitlen = 0
+ end
+ if mode == _FLUSH_MODE_BYTE_BOUNDARY then
+ total_bitlen = total_bitlen + padding_bitlen
+ return total_bitlen
+ end
+ end
+
+ local flushed = table_concat(buffer)
+ buffer = {}
+ buffer_size = 0
+ result_buffer[#result_buffer+1] = flushed
+
+ if mode == _FLUSH_MODE_MEMORY_CLEANUP then
+ return total_bitlen
+ else
+ return total_bitlen, table_concat(result_buffer)
+ end
+ end
+
+ return WriteBits, WriteString, FlushWriter
+end
+
+-- Push an element into a max heap
+-- @param heap A max heap whose max element is at index 1.
+-- @param e The element to be pushed. Assume element "e" is a table
+-- and comparison is done via its first entry e[1]
+-- @param heap_size current number of elements in the heap.
+-- NOTE: There may be some garbage stored in
+-- heap[heap_size+1], heap[heap_size+2], etc..
+-- @return nil
+local function MinHeapPush(heap, e, heap_size)
+ heap_size = heap_size + 1
+ heap[heap_size] = e
+ local value = e[1]
+ local pos = heap_size
+ local parent_pos = (pos-pos%2)/2
+
+ while (parent_pos >= 1 and heap[parent_pos][1] > value) do
+ local t = heap[parent_pos]
+ heap[parent_pos] = e
+ heap[pos] = t
+ pos = parent_pos
+ parent_pos = (parent_pos-parent_pos%2)/2
+ end
+end
+
+-- Pop an element from a max heap
+-- @param heap A max heap whose max element is at index 1.
+-- @param heap_size current number of elements in the heap.
+-- @return the poped element
+-- Note: This function does not change table size of "heap" to save CPU time.
+local function MinHeapPop(heap, heap_size)
+ local top = heap[1]
+ local e = heap[heap_size]
+ local value = e[1]
+ heap[1] = e
+ heap[heap_size] = top
+ heap_size = heap_size - 1
+
+ local pos = 1
+ local left_child_pos = pos * 2
+ local right_child_pos = left_child_pos + 1
+
+ while (left_child_pos <= heap_size) do
+ local left_child = heap[left_child_pos]
+ if (right_child_pos <= heap_size
+ and heap[right_child_pos][1] < left_child[1]) then
+ local right_child = heap[right_child_pos]
+ if right_child[1] < value then
+ heap[right_child_pos] = e
+ heap[pos] = right_child
+ pos = right_child_pos
+ left_child_pos = pos * 2
+ right_child_pos = left_child_pos + 1
+ else
+ break
+ end
+ else
+ if left_child[1] < value then
+ heap[left_child_pos] = e
+ heap[pos] = left_child
+ pos = left_child_pos
+ left_child_pos = pos * 2
+ right_child_pos = left_child_pos + 1
+ else
+ break
+ end
+ end
+ end
+
+ return top
+end
+
+-- Deflate defines a special huffman tree, which is unique once the bit length
+-- of huffman code of all symbols are known.
+-- @param bitlen_count Number of symbols with a specific bitlen
+-- @param symbol_bitlen The bit length of a symbol
+-- @param max_symbol The max symbol among all symbols,
+-- which is (number of symbols - 1)
+-- @param max_bitlen The max huffman bit length among all symbols.
+-- @return The huffman code of all symbols.
+local function GetHuffmanCodeFromBitlen(bitlen_counts, symbol_bitlens
+ , max_symbol, max_bitlen)
+ local huffman_code = 0
+ local next_codes = {}
+ local symbol_huffman_codes = {}
+ for bitlen = 1, max_bitlen do
+ huffman_code = (huffman_code+(bitlen_counts[bitlen-1] or 0))*2
+ next_codes[bitlen] = huffman_code
+ end
+ for symbol = 0, max_symbol do
+ local bitlen = symbol_bitlens[symbol]
+ if bitlen then
+ huffman_code = next_codes[bitlen]
+ next_codes[bitlen] = huffman_code + 1
+
+ -- Reverse the bits of huffman code,
+ -- because most signifant bits of huffman code
+ -- is stored first into the compressed data.
+ -- @see RFC1951 Page5 Section 3.1.1
+ if bitlen <= 9 then -- Have cached reverse for small bitlen.
+ symbol_huffman_codes[symbol] =
+ _reverse_bits_tbl[bitlen][huffman_code]
+ else
+ local reverse = 0
+ for _ = 1, bitlen do
+ reverse = reverse - reverse%2
+ + (((reverse%2==1)
+ or (huffman_code % 2) == 1) and 1 or 0)
+ huffman_code = (huffman_code-huffman_code%2)/2
+ reverse = reverse*2
+ end
+ symbol_huffman_codes[symbol] = (reverse-reverse%2)/2
+ end
+ end
+ end
+ return symbol_huffman_codes
+end
+
+-- A helper function to sort heap elements
+-- a[1], b[1] is the huffman frequency
+-- a[2], b[2] is the symbol value.
+local function SortByFirstThenSecond(a, b)
+ return a[1] < b[1] or
+ (a[1] == b[1] and a[2] < b[2])
+end
+
+-- Calculate the huffman bit length and huffman code.
+-- @param symbol_count: A table whose table key is the symbol, and table value
+-- is the symbol frenquency (nil means 0 frequency).
+-- @param max_bitlen: See description of return value.
+-- @param max_symbol: The maximum symbol
+-- @return a table whose key is the symbol, and the value is the huffman bit
+-- bit length. We guarantee that all bit length <= max_bitlen.
+-- For 0<=symbol<=max_symbol, table value could be nil if the frequency
+-- of the symbol is 0 or nil.
+-- @return a table whose key is the symbol, and the value is the huffman code.
+-- @return a number indicating the maximum symbol whose bitlen is not 0.
+local function GetHuffmanBitlenAndCode(symbol_counts, max_bitlen, max_symbol)
+ local heap_size
+ local max_non_zero_bitlen_symbol = -1
+ local leafs = {}
+ local heap = {}
+ local symbol_bitlens = {}
+ local symbol_codes = {}
+ local bitlen_counts = {}
+
+ --[[
+ tree[1]: weight, temporarily used as parent and bitLengths
+ tree[2]: symbol
+ tree[3]: left child
+ tree[4]: right child
+ --]]
+ local number_unique_symbols = 0
+ for symbol, count in pairs(symbol_counts) do
+ number_unique_symbols = number_unique_symbols + 1
+ leafs[number_unique_symbols] = {count, symbol}
+ end
+
+ if (number_unique_symbols == 0) then
+ -- no code.
+ return {}, {}, -1
+ elseif (number_unique_symbols == 1) then
+ -- Only one code. In this case, its huffman code
+ -- needs to be assigned as 0, and bit length is 1.
+ -- This is the only case that the return result
+ -- represents an imcomplete huffman tree.
+ local symbol = leafs[1][2]
+ symbol_bitlens[symbol] = 1
+ symbol_codes[symbol] = 0
+ return symbol_bitlens, symbol_codes, symbol
+ else
+ table_sort(leafs, SortByFirstThenSecond)
+ heap_size = number_unique_symbols
+ for i = 1, heap_size do
+ heap[i] = leafs[i]
+ end
+
+ while (heap_size > 1) do
+ -- Note: pop does not change table size of heap
+ local leftChild = MinHeapPop(heap, heap_size)
+ heap_size = heap_size - 1
+ local rightChild = MinHeapPop(heap, heap_size)
+ heap_size = heap_size - 1
+ local newNode =
+ {leftChild[1]+rightChild[1], -1, leftChild, rightChild}
+ MinHeapPush(heap, newNode, heap_size)
+ heap_size = heap_size + 1
+ end
+
+ -- Number of leafs whose bit length is greater than max_len.
+ local number_bitlen_overflow = 0
+
+ -- Calculate bit length of all nodes
+ local fifo = {heap[1], 0, 0, 0} -- preallocate some spaces.
+ local fifo_size = 1
+ local index = 1
+ heap[1][1] = 0
+ while (index <= fifo_size) do -- Breath first search
+ local e = fifo[index]
+ local bitlen = e[1]
+ local symbol = e[2]
+ local left_child = e[3]
+ local right_child = e[4]
+ if left_child then
+ fifo_size = fifo_size + 1
+ fifo[fifo_size] = left_child
+ left_child[1] = bitlen + 1
+ end
+ if right_child then
+ fifo_size = fifo_size + 1
+ fifo[fifo_size] = right_child
+ right_child[1] = bitlen + 1
+ end
+ index = index + 1
+
+ if (bitlen > max_bitlen) then
+ number_bitlen_overflow = number_bitlen_overflow + 1
+ bitlen = max_bitlen
+ end
+ if symbol >= 0 then
+ symbol_bitlens[symbol] = bitlen
+ max_non_zero_bitlen_symbol =
+ (symbol > max_non_zero_bitlen_symbol)
+ and symbol or max_non_zero_bitlen_symbol
+ bitlen_counts[bitlen] = (bitlen_counts[bitlen] or 0) + 1
+ end
+ end
+
+ -- Resolve bit length overflow
+ -- @see ZLib/trees.c:gen_bitlen(s, desc), for reference
+ if (number_bitlen_overflow > 0) then
+ repeat
+ local bitlen = max_bitlen - 1
+ while ((bitlen_counts[bitlen] or 0) == 0) do
+ bitlen = bitlen - 1
+ end
+ -- move one leaf down the tree
+ bitlen_counts[bitlen] = bitlen_counts[bitlen] - 1
+ -- move one overflow item as its brother
+ bitlen_counts[bitlen+1] = (bitlen_counts[bitlen+1] or 0) + 2
+ bitlen_counts[max_bitlen] = bitlen_counts[max_bitlen] - 1
+ number_bitlen_overflow = number_bitlen_overflow - 2
+ until (number_bitlen_overflow <= 0)
+
+ index = 1
+ for bitlen = max_bitlen, 1, -1 do
+ local n = bitlen_counts[bitlen] or 0
+ while (n > 0) do
+ local symbol = leafs[index][2]
+ symbol_bitlens[symbol] = bitlen
+ n = n - 1
+ index = index + 1
+ end
+ end
+ end
+
+ symbol_codes = GetHuffmanCodeFromBitlen(bitlen_counts, symbol_bitlens,
+ max_symbol, max_bitlen)
+ return symbol_bitlens, symbol_codes, max_non_zero_bitlen_symbol
+ end
+end
+
+-- Calculate the first huffman header in the dynamic huffman block
+-- @see RFC1951 Page 12
+-- @param lcode_bitlen: The huffman bit length of literal/LZ77_length.
+-- @param max_non_zero_bitlen_lcode: The maximum literal/LZ77_length symbol
+-- whose huffman bit length is not zero.
+-- @param dcode_bitlen: The huffman bit length of LZ77 distance.
+-- @param max_non_zero_bitlen_dcode: The maximum LZ77 distance symbol
+-- whose huffman bit length is not zero.
+-- @return The run length encoded codes.
+-- @return The extra bits. One entry for each rle code that needs extra bits.
+-- (code == 16 or 17 or 18).
+-- @return The count of appearance of each rle codes.
+local function RunLengthEncodeHuffmanBitlen(
+ lcode_bitlens,
+ max_non_zero_bitlen_lcode,
+ dcode_bitlens,
+ max_non_zero_bitlen_dcode)
+ local rle_code_tblsize = 0
+ local rle_codes = {}
+ local rle_code_counts = {}
+ local rle_extra_bits_tblsize = 0
+ local rle_extra_bits = {}
+ local prev = nil
+ local count = 0
+
+ -- If there is no distance code, assume one distance code of bit length 0.
+ -- RFC1951: One distance code of zero bits means that
+ -- there are no distance codes used at all (the data is all literals).
+ max_non_zero_bitlen_dcode = (max_non_zero_bitlen_dcode < 0)
+ and 0 or max_non_zero_bitlen_dcode
+ local max_code = max_non_zero_bitlen_lcode+max_non_zero_bitlen_dcode+1
+
+ for code = 0, max_code+1 do
+ local len = (code <= max_non_zero_bitlen_lcode)
+ and (lcode_bitlens[code] or 0)
+ or ((code <= max_code)
+ and (dcode_bitlens[code-max_non_zero_bitlen_lcode-1] or 0) or nil)
+ if len == prev then
+ count = count + 1
+ if len ~= 0 and count == 6 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = 16
+ rle_extra_bits_tblsize = rle_extra_bits_tblsize + 1
+ rle_extra_bits[rle_extra_bits_tblsize] = 3
+ rle_code_counts[16] = (rle_code_counts[16] or 0) + 1
+ count = 0
+ elseif len == 0 and count == 138 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = 18
+ rle_extra_bits_tblsize = rle_extra_bits_tblsize + 1
+ rle_extra_bits[rle_extra_bits_tblsize] = 127
+ rle_code_counts[18] = (rle_code_counts[18] or 0) + 1
+ count = 0
+ end
+ else
+ if count == 1 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = prev
+ rle_code_counts[prev] = (rle_code_counts[prev] or 0) + 1
+ elseif count == 2 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = prev
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = prev
+ rle_code_counts[prev] = (rle_code_counts[prev] or 0) + 2
+ elseif count >= 3 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ local rleCode = (prev ~= 0) and 16 or (count <= 10 and 17 or 18)
+ rle_codes[rle_code_tblsize] = rleCode
+ rle_code_counts[rleCode] = (rle_code_counts[rleCode] or 0) + 1
+ rle_extra_bits_tblsize = rle_extra_bits_tblsize + 1
+ rle_extra_bits[rle_extra_bits_tblsize] =
+ (count <= 10) and (count - 3) or (count - 11)
+ end
+
+ prev = len
+ if len and len ~= 0 then
+ rle_code_tblsize = rle_code_tblsize + 1
+ rle_codes[rle_code_tblsize] = len
+ rle_code_counts[len] = (rle_code_counts[len] or 0) + 1
+ count = 0
+ else
+ count = 1
+ end
+ end
+ end
+
+ return rle_codes, rle_extra_bits, rle_code_counts
+end
+
+-- Load the string into a table, in order to speed up LZ77.
+-- Loop unrolled 16 times to speed this function up.
+-- @param str The string to be loaded.
+-- @param t The load destination
+-- @param start str[index] will be the first character to be loaded.
+-- @param end str[index] will be the last character to be loaded
+-- @param offset str[index] will be loaded into t[index-offset]
+-- @return t
+local function LoadStringToTable(str, t, start, stop, offset)
+ local i = start - offset
+ while i <= stop - 15 - offset do
+ t[i], t[i+1], t[i+2], t[i+3], t[i+4], t[i+5], t[i+6], t[i+7], t[i+8],
+ t[i+9], t[i+10], t[i+11], t[i+12], t[i+13], t[i+14], t[i+15] =
+ string_byte(str, i + offset, i + 15 + offset)
+ i = i + 16
+ end
+ while (i <= stop - offset) do
+ t[i] = string_byte(str, i + offset, i + offset)
+ i = i + 1
+ end
+ return t
+end
+
+-- Do LZ77 process. This function uses the majority of the CPU time.
+-- @see zlib/deflate.c:deflate_fast(), zlib/deflate.c:deflate_slow()
+-- @see https://github.com/madler/zlib/blob/master/doc/algorithm.txt
+-- This function uses the algorithms used above. You should read the
+-- algorithm.txt above to understand what is the hash function and the
+-- lazy evaluation.
+--
+-- The special optimization used here is hash functions used here.
+-- The hash function is just the multiplication of the three consective
+-- characters. So if the hash matches, it guarantees 3 characters are matched.
+-- This optimization can be implemented because Lua table is a hash table.
+--
+-- @param level integer that describes compression level.
+-- @param string_table table that stores the value of string to be compressed.
+-- The index of this table starts from 1.
+-- The caller needs to make sure all values needed by this function
+-- are loaded.
+-- Assume "str" is the origin input string into the compressor
+-- str[block_start]..str[block_end+3] needs to be loaded into
+-- string_table[block_start-offset]..string_table[block_end-offset]
+-- If dictionary is presented, the last 258 bytes of the dictionary
+-- needs to be loaded into sing_table[-257..0]
+-- (See more in the description of offset.)
+-- @param hash_tables. The table key is the hash value (0<=hash<=16777216=256^3)
+-- The table value is an array0 that stores the indexes of the
+-- input data string to be compressed, such that
+-- hash == str[index]*str[index+1]*str[index+2]
+-- Indexes are ordered in this array.
+-- @param block_start The indexes of the input data string to be compressed.
+-- that starts the LZ77 block.
+-- @param block_end The indexes of the input data string to be compressed.
+-- that stores the LZ77 block.
+-- @param offset str[index] is stored in string_table[index-offset],
+-- This offset is mainly an optimization to limit the index
+-- of string_table, so lua can access this table quicker.
+-- @param dictionary See LibDeflate:CreateDictionary
+-- @return literal/LZ77_length deflate codes.
+-- @return the extra bits of literal/LZ77_length deflate codes.
+-- @return the count of each literal/LZ77 deflate code.
+-- @return LZ77 distance deflate codes.
+-- @return the extra bits of LZ77 distance deflate codes.
+-- @return the count of each LZ77 distance deflate code.
+local function GetBlockLZ77Result(level, string_table, hash_tables, block_start,
+ block_end, offset, dictionary)
+ local config = _compression_level_configs[level]
+ local config_use_lazy
+ , config_good_prev_length
+ , config_max_lazy_match
+ , config_nice_length
+ , config_max_hash_chain =
+ config[1], config[2], config[3], config[4], config[5]
+
+ local config_max_insert_length = (not config_use_lazy)
+ and config_max_lazy_match or 2147483646
+ local config_good_hash_chain =
+ (config_max_hash_chain-config_max_hash_chain%4/4)
+
+ local hash
+
+ local dict_hash_tables
+ local dict_string_table
+ local dict_string_len = 0
+
+ if dictionary then
+ dict_hash_tables = dictionary.hash_tables
+ dict_string_table = dictionary.string_table
+ dict_string_len = dictionary.strlen
+ assert(block_start == 1)
+ if block_end >= block_start and dict_string_len >= 2 then
+ hash = dict_string_table[dict_string_len-1]*65536
+ + dict_string_table[dict_string_len]*256 + string_table[1]
+ local t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = -1
+ end
+ if block_end >= block_start+1 and dict_string_len >= 1 then
+ hash = dict_string_table[dict_string_len]*65536
+ + string_table[1]*256 + string_table[2]
+ local t = hash_tables[hash]
+ if not t then t = {}; hash_tables[hash] = t end
+ t[#t+1] = 0
+ end
+ end
+
+ hash = (string_table[block_start-offset] or 0)*256
+ + (string_table[block_start+1-offset] or 0)
+
+ local lcodes = {}
+ local lcode_tblsize = 0
+ local lcodes_counts = {}
+ local dcodes = {}
+ local dcodes_tblsize = 0
+ local dcodes_counts = {}
+
+ local lextra_bits = {}
+ local lextra_bits_tblsize = 0
+ local dextra_bits = {}
+ local dextra_bits_tblsize = 0
+
+ local match_available = false
+ local prev_len
+ local prev_dist
+ local cur_len = 0
+ local cur_dist = 0
+
+ local index = block_start
+ local index_end = block_end + (config_use_lazy and 1 or 0)
+
+ -- the zlib source code writes separate code for lazy evaluation and
+ -- not lazy evaluation, which is easier to understand.
+ -- I put them together, so it is a bit harder to understand.
+ -- because I think this is easier for me to maintain it.
+ while (index <= index_end) do
+ local string_table_index = index - offset
+ prev_len = cur_len
+ prev_dist = cur_dist
+ cur_len = 0
+
+ hash = (hash*256+(string_table[string_table_index+2] or 0))%16777216
+
+ local chain_index
+ local cur_chain
+ local hash_chain = hash_tables[hash]
+ local chain_old_size
+ if not hash_chain then
+ chain_old_size = 0
+ hash_chain = {}
+ hash_tables[hash] = hash_chain
+ if dict_hash_tables then
+ cur_chain = dict_hash_tables[hash]
+ chain_index = cur_chain and #cur_chain or 0
+ else
+ chain_index = 0
+ end
+ else
+ chain_old_size = #hash_chain
+ cur_chain = hash_chain
+ chain_index = chain_old_size
+ end
+
+ if index <= block_end then
+ hash_chain[chain_old_size+1] = index
+ end
+
+ if (chain_index > 0 and index + 2 <= block_end
+ and (not config_use_lazy or prev_len < config_max_lazy_match)) then
+
+ local depth =
+ (config_use_lazy and prev_len >= config_good_prev_length)
+ and config_good_hash_chain or config_max_hash_chain
+
+ while chain_index >= 1 and depth > 0 do
+ local prev = cur_chain[chain_index]
+
+ if index - prev > 32768 then
+ break
+ end
+ if prev < index then
+ local j = 3
+
+ if prev >= -257 then
+ local prev_table_index = prev-offset
+ -- NOTE for author:
+ -- j < 258 and index + j <= block_end
+ -- This is the right condition
+ while (j < 258 and index + j <= block_end) do
+ if (string_table[prev_table_index+j]
+ == string_table[string_table_index+j]) then
+ j = j + 1
+ else
+ break
+ end
+ end
+ else
+ local prev_table_index = dict_string_len+prev
+ -- NOTE for author:
+ -- j < 258 and index + j <= block_end
+ -- This is the right condition
+ while (j < 258 and index + j <= block_end) do
+ if (dict_string_table[prev_table_index+j]
+ == string_table[string_table_index+j]) then
+ j = j + 1
+ else
+ break
+ end
+ end
+ end
+ if j > cur_len then
+ cur_len = j
+ cur_dist = index - prev
+ end
+ if cur_len >= config_nice_length then
+ break
+ end
+ end
+
+ chain_index = chain_index - 1
+ depth = depth - 1
+ if chain_index == 0 and prev > 0 and dict_hash_tables then
+ cur_chain = dict_hash_tables[hash]
+ chain_index = cur_chain and #cur_chain or 0
+ end
+ end
+ end
+
+ if not config_use_lazy then
+ prev_len, prev_dist = cur_len, cur_dist
+ end
+ if ((not config_use_lazy or match_available)
+ and (prev_len > 3 or (prev_len == 3 and prev_dist < 4096))
+ and cur_len <= prev_len )then
+ local code = _length_to_deflate_code[prev_len]
+ local length_extra_bits_bitlen =
+ _length_to_deflate_extra_bitlen[prev_len]
+ local dist_code, dist_extra_bits_bitlen, dist_extra_bits
+ if prev_dist <= 256 then -- have cached code for small distance.
+ dist_code = _dist256_to_deflate_code[prev_dist]
+ dist_extra_bits = _dist256_to_deflate_extra_bits[prev_dist]
+ dist_extra_bits_bitlen =
+ _dist256_to_deflate_extra_bitlen[prev_dist]
+ else
+ dist_code = 16
+ dist_extra_bits_bitlen = 7
+ local a = 384
+ local b = 512
+
+ while true do
+ if prev_dist <= a then
+ dist_extra_bits = (prev_dist-(b/2)-1) % (b/4)
+ break
+ elseif prev_dist <= b then
+ dist_extra_bits = (prev_dist-(b/2)-1) % (b/4)
+ dist_code = dist_code + 1
+ break
+ else
+ dist_code = dist_code + 2
+ dist_extra_bits_bitlen = dist_extra_bits_bitlen + 1
+ a = a*2
+ b = b*2
+ end
+ end
+ end
+ lcode_tblsize = lcode_tblsize + 1
+ lcodes[lcode_tblsize] = code
+ lcodes_counts[code] = (lcodes_counts[code] or 0) + 1
+
+ dcodes_tblsize = dcodes_tblsize + 1
+ dcodes[dcodes_tblsize] = dist_code
+ dcodes_counts[dist_code] = (dcodes_counts[dist_code] or 0) + 1
+
+ if length_extra_bits_bitlen > 0 then
+ local lenExtraBits = _length_to_deflate_extra_bits[prev_len]
+ lextra_bits_tblsize = lextra_bits_tblsize + 1
+ lextra_bits[lextra_bits_tblsize] = lenExtraBits
+ end
+ if dist_extra_bits_bitlen > 0 then
+ dextra_bits_tblsize = dextra_bits_tblsize + 1
+ dextra_bits[dextra_bits_tblsize] = dist_extra_bits
+ end
+
+ for i=index+1, index+prev_len-(config_use_lazy and 2 or 1) do
+ hash = (hash*256+(string_table[i-offset+2] or 0))%16777216
+ if prev_len <= config_max_insert_length then
+ hash_chain = hash_tables[hash]
+ if not hash_chain then
+ hash_chain = {}
+ hash_tables[hash] = hash_chain
+ end
+ hash_chain[#hash_chain+1] = i
+ end
+ end
+ index = index + prev_len - (config_use_lazy and 1 or 0)
+ match_available = false
+ elseif (not config_use_lazy) or match_available then
+ local code = string_table[config_use_lazy
+ and (string_table_index-1) or string_table_index]
+ lcode_tblsize = lcode_tblsize + 1
+ lcodes[lcode_tblsize] = code
+ lcodes_counts[code] = (lcodes_counts[code] or 0) + 1
+ index = index + 1
+ else
+ match_available = true
+ index = index + 1
+ end
+ end
+
+ -- Write "end of block" symbol
+ lcode_tblsize = lcode_tblsize + 1
+ lcodes[lcode_tblsize] = 256
+ lcodes_counts[256] = (lcodes_counts[256] or 0) + 1
+
+ return lcodes, lextra_bits, lcodes_counts, dcodes, dextra_bits
+ , dcodes_counts
+end
+
+-- Get the header data of dynamic block.
+-- @param lcodes_count The count of each literal/LZ77_length codes.
+-- @param dcodes_count The count of each Lz77 distance codes.
+-- @return a lots of stuffs.
+-- @see RFC1951 Page 12
+local function GetBlockDynamicHuffmanHeader(lcodes_counts, dcodes_counts)
+ local lcodes_huffman_bitlens, lcodes_huffman_codes
+ , max_non_zero_bitlen_lcode =
+ GetHuffmanBitlenAndCode(lcodes_counts, 15, 285)
+ local dcodes_huffman_bitlens, dcodes_huffman_codes
+ , max_non_zero_bitlen_dcode =
+ GetHuffmanBitlenAndCode(dcodes_counts, 15, 29)
+
+ local rle_deflate_codes, rle_extra_bits, rle_codes_counts =
+ RunLengthEncodeHuffmanBitlen(lcodes_huffman_bitlens
+ ,max_non_zero_bitlen_lcode, dcodes_huffman_bitlens
+ , max_non_zero_bitlen_dcode)
+
+ local rle_codes_huffman_bitlens, rle_codes_huffman_codes =
+ GetHuffmanBitlenAndCode(rle_codes_counts, 7, 18)
+
+ local HCLEN = 0
+ for i = 1, 19 do
+ local symbol = _rle_codes_huffman_bitlen_order[i]
+ local length = rle_codes_huffman_bitlens[symbol] or 0
+ if length ~= 0 then
+ HCLEN = i
+ end
+ end
+
+ HCLEN = HCLEN - 4
+ local HLIT = max_non_zero_bitlen_lcode + 1 - 257
+ local HDIST = max_non_zero_bitlen_dcode + 1 - 1
+ if HDIST < 0 then HDIST = 0 end
+
+ return HLIT, HDIST, HCLEN, rle_codes_huffman_bitlens
+ , rle_codes_huffman_codes, rle_deflate_codes, rle_extra_bits
+ , lcodes_huffman_bitlens, lcodes_huffman_codes
+ , dcodes_huffman_bitlens, dcodes_huffman_codes
+end
+
+-- Get the size of dynamic block without writing any bits into the writer.
+-- @param ... Read the source code of GetBlockDynamicHuffmanHeader()
+-- @return the bit length of the dynamic block
+local function GetDynamicHuffmanBlockSize(lcodes, dcodes, HCLEN
+ , rle_codes_huffman_bitlens, rle_deflate_codes
+ , lcodes_huffman_bitlens, dcodes_huffman_bitlens)
+
+ local block_bitlen = 17 -- 1+2+5+5+4
+ block_bitlen = block_bitlen + (HCLEN+4)*3
+
+ for i = 1, #rle_deflate_codes do
+ local code = rle_deflate_codes[i]
+ block_bitlen = block_bitlen + rle_codes_huffman_bitlens[code]
+ if code >= 16 then
+ block_bitlen = block_bitlen +
+ ((code == 16) and 2 or (code == 17 and 3 or 7))
+ end
+ end
+
+ local length_code_count = 0
+ for i = 1, #lcodes do
+ local code = lcodes[i]
+ local huffman_bitlen = lcodes_huffman_bitlens[code]
+ block_bitlen = block_bitlen + huffman_bitlen
+ if code > 256 then -- Length code
+ length_code_count = length_code_count + 1
+ if code > 264 and code < 285 then -- Length code with extra bits
+ local extra_bits_bitlen =
+ _literal_deflate_code_to_extra_bitlen[code-256]
+ block_bitlen = block_bitlen + extra_bits_bitlen
+ end
+ local dist_code = dcodes[length_code_count]
+ local dist_huffman_bitlen = dcodes_huffman_bitlens[dist_code]
+ block_bitlen = block_bitlen + dist_huffman_bitlen
+
+ if dist_code > 3 then -- dist code with extra bits
+ local dist_extra_bits_bitlen = (dist_code-dist_code%2)/2 - 1
+ block_bitlen = block_bitlen + dist_extra_bits_bitlen
+ end
+ end
+ end
+ return block_bitlen
+end
+
+-- Write dynamic block.
+-- @param ... Read the source code of GetBlockDynamicHuffmanHeader()
+local function CompressDynamicHuffmanBlock(WriteBits, is_last_block
+ , lcodes, lextra_bits, dcodes, dextra_bits, HLIT, HDIST, HCLEN
+ , rle_codes_huffman_bitlens, rle_codes_huffman_codes
+ , rle_deflate_codes, rle_extra_bits
+ , lcodes_huffman_bitlens, lcodes_huffman_codes
+ , dcodes_huffman_bitlens, dcodes_huffman_codes)
+
+ WriteBits(is_last_block and 1 or 0, 1) -- Last block identifier
+ WriteBits(2, 2) -- Dynamic Huffman block identifier
+
+ WriteBits(HLIT, 5)
+ WriteBits(HDIST, 5)
+ WriteBits(HCLEN, 4)
+
+ for i = 1, HCLEN+4 do
+ local symbol = _rle_codes_huffman_bitlen_order[i]
+ local length = rle_codes_huffman_bitlens[symbol] or 0
+ WriteBits(length, 3)
+ end
+
+ local rleExtraBitsIndex = 1
+ for i=1, #rle_deflate_codes do
+ local code = rle_deflate_codes[i]
+ WriteBits(rle_codes_huffman_codes[code]
+ , rle_codes_huffman_bitlens[code])
+ if code >= 16 then
+ local extraBits = rle_extra_bits[rleExtraBitsIndex]
+ WriteBits(extraBits, (code == 16) and 2 or (code == 17 and 3 or 7))
+ rleExtraBitsIndex = rleExtraBitsIndex + 1
+ end
+ end
+
+ local length_code_count = 0
+ local length_code_with_extra_count = 0
+ local dist_code_with_extra_count = 0
+
+ for i=1, #lcodes do
+ local deflate_codee = lcodes[i]
+ local huffman_code = lcodes_huffman_codes[deflate_codee]
+ local huffman_bitlen = lcodes_huffman_bitlens[deflate_codee]
+ WriteBits(huffman_code, huffman_bitlen)
+ if deflate_codee > 256 then -- Length code
+ length_code_count = length_code_count + 1
+ if deflate_codee > 264 and deflate_codee < 285 then
+ -- Length code with extra bits
+ length_code_with_extra_count = length_code_with_extra_count + 1
+ local extra_bits = lextra_bits[length_code_with_extra_count]
+ local extra_bits_bitlen =
+ _literal_deflate_code_to_extra_bitlen[deflate_codee-256]
+ WriteBits(extra_bits, extra_bits_bitlen)
+ end
+ -- Write distance code
+ local dist_deflate_code = dcodes[length_code_count]
+ local dist_huffman_code = dcodes_huffman_codes[dist_deflate_code]
+ local dist_huffman_bitlen =
+ dcodes_huffman_bitlens[dist_deflate_code]
+ WriteBits(dist_huffman_code, dist_huffman_bitlen)
+
+ if dist_deflate_code > 3 then -- dist code with extra bits
+ dist_code_with_extra_count = dist_code_with_extra_count + 1
+ local dist_extra_bits = dextra_bits[dist_code_with_extra_count]
+ local dist_extra_bits_bitlen =
+ (dist_deflate_code-dist_deflate_code%2)/2 - 1
+ WriteBits(dist_extra_bits, dist_extra_bits_bitlen)
+ end
+ end
+ end
+end
+
+-- Get the size of fixed block without writing any bits into the writer.
+-- @param lcodes literal/LZ77_length deflate codes
+-- @param decodes LZ77 distance deflate codes
+-- @return the bit length of the fixed block
+local function GetFixedHuffmanBlockSize(lcodes, dcodes)
+ local block_bitlen = 3
+ local length_code_count = 0
+ for i=1, #lcodes do
+ local code = lcodes[i]
+ local huffman_bitlen = _fix_block_literal_huffman_bitlen[code]
+ block_bitlen = block_bitlen + huffman_bitlen
+ if code > 256 then -- Length code
+ length_code_count = length_code_count + 1
+ if code > 264 and code < 285 then -- Length code with extra bits
+ local extra_bits_bitlen =
+ _literal_deflate_code_to_extra_bitlen[code-256]
+ block_bitlen = block_bitlen + extra_bits_bitlen
+ end
+ local dist_code = dcodes[length_code_count]
+ block_bitlen = block_bitlen + 5
+
+ if dist_code > 3 then -- dist code with extra bits
+ local dist_extra_bits_bitlen =
+ (dist_code-dist_code%2)/2 - 1
+ block_bitlen = block_bitlen + dist_extra_bits_bitlen
+ end
+ end
+ end
+ return block_bitlen
+end
+
+-- Write fixed block.
+-- @param lcodes literal/LZ77_length deflate codes
+-- @param decodes LZ77 distance deflate codes
+local function CompressFixedHuffmanBlock(WriteBits, is_last_block,
+ lcodes, lextra_bits, dcodes, dextra_bits)
+ WriteBits(is_last_block and 1 or 0, 1) -- Last block identifier
+ WriteBits(1, 2) -- Fixed Huffman block identifier
+ local length_code_count = 0
+ local length_code_with_extra_count = 0
+ local dist_code_with_extra_count = 0
+ for i=1, #lcodes do
+ local deflate_code = lcodes[i]
+ local huffman_code = _fix_block_literal_huffman_code[deflate_code]
+ local huffman_bitlen = _fix_block_literal_huffman_bitlen[deflate_code]
+ WriteBits(huffman_code, huffman_bitlen)
+ if deflate_code > 256 then -- Length code
+ length_code_count = length_code_count + 1
+ if deflate_code > 264 and deflate_code < 285 then
+ -- Length code with extra bits
+ length_code_with_extra_count = length_code_with_extra_count + 1
+ local extra_bits = lextra_bits[length_code_with_extra_count]
+ local extra_bits_bitlen =
+ _literal_deflate_code_to_extra_bitlen[deflate_code-256]
+ WriteBits(extra_bits, extra_bits_bitlen)
+ end
+ -- Write distance code
+ local dist_code = dcodes[length_code_count]
+ local dist_huffman_code = _fix_block_dist_huffman_code[dist_code]
+ WriteBits(dist_huffman_code, 5)
+
+ if dist_code > 3 then -- dist code with extra bits
+ dist_code_with_extra_count = dist_code_with_extra_count + 1
+ local dist_extra_bits = dextra_bits[dist_code_with_extra_count]
+ local dist_extra_bits_bitlen = (dist_code-dist_code%2)/2 - 1
+ WriteBits(dist_extra_bits, dist_extra_bits_bitlen)
+ end
+ end
+ end
+end
+
+-- Get the size of store block without writing any bits into the writer.
+-- @param block_start The start index of the origin input string
+-- @param block_end The end index of the origin input string
+-- @param Total bit lens had been written into the compressed result before,
+-- because store block needs to shift to byte boundary.
+-- @return the bit length of the fixed block
+local function GetStoreBlockSize(block_start, block_end, total_bitlen)
+ assert(block_end-block_start+1 <= 65535)
+ local block_bitlen = 3
+ total_bitlen = total_bitlen + 3
+ local padding_bitlen = (8-total_bitlen%8)%8
+ block_bitlen = block_bitlen + padding_bitlen
+ block_bitlen = block_bitlen + 32
+ block_bitlen = block_bitlen + (block_end - block_start + 1) * 8
+ return block_bitlen
+end
+
+-- Write the store block.
+-- @param ... lots of stuffs
+-- @return nil
+local function CompressStoreBlock(WriteBits, WriteString, is_last_block, str
+ , block_start, block_end, total_bitlen)
+ assert(block_end-block_start+1 <= 65535)
+ WriteBits(is_last_block and 1 or 0, 1) -- Last block identifer.
+ WriteBits(0, 2) -- Store block identifier.
+ total_bitlen = total_bitlen + 3
+ local padding_bitlen = (8-total_bitlen%8)%8
+ if padding_bitlen > 0 then
+ WriteBits(_pow2[padding_bitlen]-1, padding_bitlen)
+ end
+ local size = block_end - block_start + 1
+ WriteBits(size, 16)
+
+ -- Write size's one's complement
+ local comp = (255 - size % 256) + (255 - (size-size%256)/256)*256
+ WriteBits(comp, 16)
+
+ WriteString(str:sub(block_start, block_end))
+end
+
+-- Do the deflate
+-- Currently using a simple way to determine the block size
+-- (This is why the compression ratio is little bit worse than zlib when
+-- the input size is very large
+-- The first block is 64KB, the following block is 32KB.
+-- After each block, there is a memory cleanup operation.
+-- This is not a fast operation, but it is needed to save memory usage, so
+-- the memory usage does not grow unboundly. If the data size is less than
+-- 64KB, then memory cleanup won't happen.
+-- This function determines whether to use store/fixed/dynamic blocks by
+-- calculating the block size of each block type and chooses the smallest one.
+local function Deflate(configs, WriteBits, WriteString, FlushWriter, str
+ , dictionary)
+ local string_table = {}
+ local hash_tables = {}
+ local is_last_block = nil
+ local block_start
+ local block_end
+ local bitlen_written
+ local total_bitlen = FlushWriter(_FLUSH_MODE_NO_FLUSH)
+ local strlen = #str
+ local offset
+
+ local level
+ local strategy
+ if configs then
+ if configs.level then
+ level = configs.level
+ end
+ if configs.strategy then
+ strategy = configs.strategy
+ end
+ end
+
+ if not level then
+ if strlen < 2048 then
+ level = 7
+ elseif strlen > 65536 then
+ level = 3
+ else
+ level = 5
+ end
+ end
+
+ while not is_last_block do
+ if not block_start then
+ block_start = 1
+ block_end = 64*1024 - 1
+ offset = 0
+ else
+ block_start = block_end + 1
+ block_end = block_end + 32*1024
+ offset = block_start - 32*1024 - 1
+ end
+
+ if block_end >= strlen then
+ block_end = strlen
+ is_last_block = true
+ else
+ is_last_block = false
+ end
+
+ local lcodes, lextra_bits, lcodes_counts, dcodes, dextra_bits
+ , dcodes_counts
+
+ local HLIT, HDIST, HCLEN, rle_codes_huffman_bitlens
+ , rle_codes_huffman_codes, rle_deflate_codes
+ , rle_extra_bits, lcodes_huffman_bitlens, lcodes_huffman_codes
+ , dcodes_huffman_bitlens, dcodes_huffman_codes
+
+ local dynamic_block_bitlen
+ local fixed_block_bitlen
+ local store_block_bitlen
+
+ if level ~= 0 then
+
+ -- GetBlockLZ77 needs block_start to block_end+3 to be loaded.
+ LoadStringToTable(str, string_table, block_start, block_end + 3
+ , offset)
+ if block_start == 1 and dictionary then
+ local dict_string_table = dictionary.string_table
+ local dict_strlen = dictionary.strlen
+ for i=0, (-dict_strlen+1)<-257
+ and -257 or (-dict_strlen+1), -1 do
+ string_table[i] = dict_string_table[dict_strlen+i]
+ end
+ end
+
+ if strategy == "huffman_only" then
+ lcodes = {}
+ LoadStringToTable(str, lcodes, block_start, block_end
+ , block_start-1)
+ lextra_bits = {}
+ lcodes_counts = {}
+ lcodes[block_end - block_start+2] = 256 -- end of block
+ for i=1, block_end - block_start+2 do
+ local code = lcodes[i]
+ lcodes_counts[code] = (lcodes_counts[code] or 0) + 1
+ end
+ dcodes = {}
+ dextra_bits = {}
+ dcodes_counts = {}
+ else
+ lcodes, lextra_bits, lcodes_counts, dcodes, dextra_bits
+ , dcodes_counts = GetBlockLZ77Result(level, string_table
+ , hash_tables, block_start, block_end, offset, dictionary
+ )
+ end
+
+ HLIT, HDIST, HCLEN, rle_codes_huffman_bitlens
+ , rle_codes_huffman_codes, rle_deflate_codes
+ , rle_extra_bits, lcodes_huffman_bitlens, lcodes_huffman_codes
+ , dcodes_huffman_bitlens, dcodes_huffman_codes =
+ GetBlockDynamicHuffmanHeader(lcodes_counts, dcodes_counts)
+ dynamic_block_bitlen = GetDynamicHuffmanBlockSize(
+ lcodes, dcodes, HCLEN, rle_codes_huffman_bitlens
+ , rle_deflate_codes, lcodes_huffman_bitlens
+ , dcodes_huffman_bitlens)
+ fixed_block_bitlen = GetFixedHuffmanBlockSize(lcodes, dcodes)
+ end
+
+ store_block_bitlen = GetStoreBlockSize(block_start, block_end
+ , total_bitlen)
+
+ local min_bitlen = store_block_bitlen
+ min_bitlen = (fixed_block_bitlen and fixed_block_bitlen < min_bitlen)
+ and fixed_block_bitlen or min_bitlen
+ min_bitlen = (dynamic_block_bitlen
+ and dynamic_block_bitlen < min_bitlen)
+ and dynamic_block_bitlen or min_bitlen
+
+ if level == 0 or (strategy ~= "fixed" and strategy ~= "dynamic" and
+ store_block_bitlen == min_bitlen) then
+ CompressStoreBlock(WriteBits, WriteString, is_last_block
+ , str, block_start, block_end, total_bitlen)
+ total_bitlen = total_bitlen + store_block_bitlen
+ elseif strategy ~= "dynamic" and (
+ strategy == "fixed" or fixed_block_bitlen == min_bitlen) then
+ CompressFixedHuffmanBlock(WriteBits, is_last_block,
+ lcodes, lextra_bits, dcodes, dextra_bits)
+ total_bitlen = total_bitlen + fixed_block_bitlen
+ elseif strategy == "dynamic" or dynamic_block_bitlen == min_bitlen then
+ CompressDynamicHuffmanBlock(WriteBits, is_last_block, lcodes
+ , lextra_bits, dcodes, dextra_bits, HLIT, HDIST, HCLEN
+ , rle_codes_huffman_bitlens, rle_codes_huffman_codes
+ , rle_deflate_codes, rle_extra_bits
+ , lcodes_huffman_bitlens, lcodes_huffman_codes
+ , dcodes_huffman_bitlens, dcodes_huffman_codes)
+ total_bitlen = total_bitlen + dynamic_block_bitlen
+ end
+
+ if is_last_block then
+ bitlen_written = FlushWriter(_FLUSH_MODE_NO_FLUSH)
+ else
+ bitlen_written = FlushWriter(_FLUSH_MODE_MEMORY_CLEANUP)
+ end
+
+ assert(bitlen_written == total_bitlen)
+
+ -- Memory clean up, so memory consumption does not always grow linearly
+ -- , even if input string is > 64K.
+ -- Not a very efficient operation, but this operation won't happen
+ -- when the input data size is less than 64K.
+ if not is_last_block then
+ local j
+ if dictionary and block_start == 1 then
+ j = 0
+ while (string_table[j]) do
+ string_table[j] = nil
+ j = j - 1
+ end
+ end
+ dictionary = nil
+ j = 1
+ for i = block_end-32767, block_end do
+ string_table[j] = string_table[i-offset]
+ j = j + 1
+ end
+
+ for k, t in pairs(hash_tables) do
+ local tSize = #t
+ if tSize > 0 and block_end+1 - t[1] > 32768 then
+ if tSize == 1 then
+ hash_tables[k] = nil
+ else
+ local new = {}
+ local newSize = 0
+ for i = 2, tSize do
+ j = t[i]
+ if block_end+1 - j <= 32768 then
+ newSize = newSize + 1
+ new[newSize] = j
+ end
+ end
+ hash_tables[k] = new
+ end
+ end
+ end
+ end
+ end
+end
+
+--- The description to compression configuration table.
+-- Any field can be nil to use its default.
+-- Table with keys other than those below is an invalid table.
+-- @class table
+-- @name compression_configs
+-- @field level The compression level ranged from 0 to 9. 0 is no compression.
+-- 9 is the slowest but best compression. Use nil for default level.
+-- @field strategy The compression strategy. "fixed" to only use fixed deflate
+-- compression block. "dynamic" to only use dynamic block. "huffman_only" to
+-- do no LZ77 compression. Only do huffman compression.
+
+
+-- @see LibDeflate:CompressDeflate(str, configs)
+-- @see LibDeflate:CompressDeflateWithDict(str, dictionary, configs)
+local function CompressDeflateInternal(str, dictionary, configs)
+ local WriteBits, WriteString, FlushWriter = CreateWriter()
+ Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary)
+ local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT)
+ local padding_bitlen = (8-total_bitlen%8)%8
+ return result, padding_bitlen
+end
+
+-- @see LibDeflate:CompressZlib
+-- @see LibDeflate:CompressZlibWithDict
+local function CompressZlibInternal(str, dictionary, configs)
+ local WriteBits, WriteString, FlushWriter = CreateWriter()
+
+ local CM = 8 -- Compression method
+ local CINFO = 7 --Window Size = 32K
+ local CMF = CINFO*16+CM
+ WriteBits(CMF, 8)
+
+ local FDIST = dictionary and 1 or 0
+ local FLEVEL = 2 -- Default compression
+ local FLG = FLEVEL*64+FDIST*32
+ local FCHECK = (31-(CMF*256+FLG)%31)
+ -- The FCHECK value must be such that CMF and FLG,
+ -- when viewed as a 16-bit unsigned integer stored
+ -- in MSB order (CMF*256 + FLG), is a multiple of 31.
+ FLG = FLG + FCHECK
+ WriteBits(FLG, 8)
+
+ if FDIST == 1 then
+ local adler32 = dictionary.adler32
+ local byte0 = adler32 % 256
+ adler32 = (adler32 - byte0) / 256
+ local byte1 = adler32 % 256
+ adler32 = (adler32 - byte1) / 256
+ local byte2 = adler32 % 256
+ adler32 = (adler32 - byte2) / 256
+ local byte3 = adler32 % 256
+ WriteBits(byte3, 8)
+ WriteBits(byte2, 8)
+ WriteBits(byte1, 8)
+ WriteBits(byte0, 8)
+ end
+
+ Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary)
+ FlushWriter(_FLUSH_MODE_BYTE_BOUNDARY)
+
+ local adler32 = LibDeflate:Adler32(str)
+
+ -- Most significant byte first
+ local byte3 = adler32%256
+ adler32 = (adler32 - byte3) / 256
+ local byte2 = adler32%256
+ adler32 = (adler32 - byte2) / 256
+ local byte1 = adler32%256
+ adler32 = (adler32 - byte1) / 256
+ local byte0 = adler32%256
+
+ WriteBits(byte0, 8)
+ WriteBits(byte1, 8)
+ WriteBits(byte2, 8)
+ WriteBits(byte3, 8)
+ local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT)
+ local padding_bitlen = (8-total_bitlen%8)%8
+ return result, padding_bitlen
+end
+
+--- Compress using the raw deflate format.
+-- @param str [string] The data to be compressed.
+-- @param configs [table/nil] The configuration table to control the compression
+-- . If nil, use the default configuration.
+-- @return [string] The compressed data.
+-- @return [integer] The number of bits padded at the end of output.
+-- 0 <= bits < 8
+-- This means the most significant "bits" of the last byte of the returned
+-- compressed data are padding bits and they don't affect decompression.
+-- You don't need to use this value unless you want to do some postprocessing
+-- to the compressed data.
+-- @see compression_configs
+-- @see LibDeflate:DecompressDeflate
+function LibDeflate:CompressDeflate(str, configs)
+ local arg_valid, arg_err = IsValidArguments(str, false, nil, true, configs)
+ if not arg_valid then
+ error(("Usage: LibDeflate:CompressDeflate(str, configs): "
+ ..arg_err), 2)
+ end
+ return CompressDeflateInternal(str, nil, configs)
+end
+
+--- Compress using the raw deflate format with a preset dictionary.
+-- @param str [string] The data to be compressed.
+-- @param dictionary [table] The preset dictionary produced by
+-- LibDeflate:CreateDictionary
+-- @param configs [table/nil] The configuration table to control the compression
+-- . If nil, use the default configuration.
+-- @return [string] The compressed data.
+-- @return [integer] The number of bits padded at the end of output.
+-- 0 <= bits < 8
+-- This means the most significant "bits" of the last byte of the returned
+-- compressed data are padding bits and they don't affect decompression.
+-- You don't need to use this value unless you want to do some postprocessing
+-- to the compressed data.
+-- @see compression_configs
+-- @see LibDeflate:CreateDictionary
+-- @see LibDeflate:DecompressDeflateWithDict
+function LibDeflate:CompressDeflateWithDict(str, dictionary, configs)
+ local arg_valid, arg_err = IsValidArguments(str, true, dictionary
+ , true, configs)
+ if not arg_valid then
+ error(("Usage: LibDeflate:CompressDeflateWithDict"
+ .."(str, dictionary, configs): "
+ ..arg_err), 2)
+ end
+ return CompressDeflateInternal(str, dictionary, configs)
+end
+
+--- Compress using the zlib format.
+-- @param str [string] the data to be compressed.
+-- @param configs [table/nil] The configuration table to control the compression
+-- . If nil, use the default configuration.
+-- @return [string] The compressed data.
+-- @return [integer] The number of bits padded at the end of output.
+-- Should always be 0.
+-- Zlib formatted compressed data never has padding bits at the end.
+-- @see compression_configs
+-- @see LibDeflate:DecompressZlib
+function LibDeflate:CompressZlib(str, configs)
+ local arg_valid, arg_err = IsValidArguments(str, false, nil, true, configs)
+ if not arg_valid then
+ error(("Usage: LibDeflate:CompressZlib(str, configs): "
+ ..arg_err), 2)
+ end
+ return CompressZlibInternal(str, nil, configs)
+end
+
+--- Compress using the zlib format with a preset dictionary.
+-- @param str [string] the data to be compressed.
+-- @param dictionary [table] A preset dictionary produced
+-- by LibDeflate:CreateDictionary()
+-- @param configs [table/nil] The configuration table to control the compression
+-- . If nil, use the default configuration.
+-- @return [string] The compressed data.
+-- @return [integer] The number of bits padded at the end of output.
+-- Should always be 0.
+-- Zlib formatted compressed data never has padding bits at the end.
+-- @see compression_configs
+-- @see LibDeflate:CreateDictionary
+-- @see LibDeflate:DecompressZlibWithDict
+function LibDeflate:CompressZlibWithDict(str, dictionary, configs)
+ local arg_valid, arg_err = IsValidArguments(str, true, dictionary
+ , true, configs)
+ if not arg_valid then
+ error(("Usage: LibDeflate:CompressZlibWithDict"
+ .."(str, dictionary, configs): "
+ ..arg_err), 2)
+ end
+ return CompressZlibInternal(str, dictionary, configs)
+end
+
+--[[ --------------------------------------------------------------------------
+ Decompress code
+--]] --------------------------------------------------------------------------
+
+--[[
+ Create a reader to easily reader stuffs as the unit of bits.
+ Return values:
+ 1. ReadBits(bitlen)
+ 2. ReadBytes(bytelen, buffer, buffer_size)
+ 3. Decode(huffman_bitlen_count, huffman_symbol, min_bitlen)
+ 4. ReaderBitlenLeft()
+ 5. SkipToByteBoundary()
+--]]
+local function CreateReader(input_string)
+ local input = input_string
+ local input_strlen = #input_string
+ local input_next_byte_pos = 1
+ local cache_bitlen = 0
+ local cache = 0
+
+ -- Read some bits.
+ -- To improve speed, this function does not
+ -- check if the input has been exhausted.
+ -- Use ReaderBitlenLeft() < 0 to check it.
+ -- @param bitlen the number of bits to read
+ -- @return the data is read.
+ local function ReadBits(bitlen)
+ local rshift_mask = _pow2[bitlen]
+ local code
+ if bitlen <= cache_bitlen then
+ code = cache % rshift_mask
+ cache = (cache - code) / rshift_mask
+ cache_bitlen = cache_bitlen - bitlen
+ else -- Whether input has been exhausted is not checked.
+ local lshift_mask = _pow2[cache_bitlen]
+ local byte1, byte2, byte3, byte4 = string_byte(input
+ , input_next_byte_pos, input_next_byte_pos+3)
+ -- This requires lua number to be at least double ()
+ cache = cache + ((byte1 or 0)+(byte2 or 0)*256
+ + (byte3 or 0)*65536+(byte4 or 0)*16777216)*lshift_mask
+ input_next_byte_pos = input_next_byte_pos + 4
+ cache_bitlen = cache_bitlen + 32 - bitlen
+ code = cache % rshift_mask
+ cache = (cache - code) / rshift_mask
+ end
+ return code
+ end
+
+ -- Read some bytes from the reader.
+ -- Assume reader is on the byte boundary.
+ -- @param bytelen The number of bytes to be read.
+ -- @param buffer The byte read will be stored into this buffer.
+ -- @param buffer_size The buffer will be modified starting from
+ -- buffer[buffer_size+1], ending at buffer[buffer_size+bytelen-1]
+ -- @return the new buffer_size
+ local function ReadBytes(bytelen, buffer, buffer_size)
+ assert(cache_bitlen % 8 == 0)
+
+ local byte_from_cache = (cache_bitlen/8 < bytelen)
+ and (cache_bitlen/8) or bytelen
+ for _=1, byte_from_cache do
+ local byte = cache % 256
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = string_char(byte)
+ cache = (cache - byte) / 256
+ end
+ cache_bitlen = cache_bitlen - byte_from_cache*8
+ bytelen = bytelen - byte_from_cache
+ if (input_strlen - input_next_byte_pos - bytelen + 1) * 8
+ + cache_bitlen < 0 then
+ return -1 -- out of input
+ end
+ for i=input_next_byte_pos, input_next_byte_pos+bytelen-1 do
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = string_sub(input, i, i)
+ end
+
+ input_next_byte_pos = input_next_byte_pos + bytelen
+ return buffer_size
+ end
+
+ -- Decode huffman code
+ -- To improve speed, this function does not check
+ -- if the input has been exhausted.
+ -- Use ReaderBitlenLeft() < 0 to check it.
+ -- Credits for Mark Adler. This code is from puff:Decode()
+ -- @see puff:Decode(...)
+ -- @param huffman_bitlen_count
+ -- @param huffman_symbol
+ -- @param min_bitlen The minimum huffman bit length of all symbols
+ -- @return The decoded deflate code.
+ -- Negative value is returned if decoding fails.
+ local function Decode(huffman_bitlen_counts, huffman_symbols, min_bitlen)
+ local code = 0
+ local first = 0
+ local index = 0
+ local count
+ if min_bitlen > 0 then
+ if cache_bitlen < 15 and input then
+ local lshift_mask = _pow2[cache_bitlen]
+ local byte1, byte2, byte3, byte4 =
+ string_byte(input, input_next_byte_pos
+ , input_next_byte_pos+3)
+ -- This requires lua number to be at least double ()
+ cache = cache + ((byte1 or 0)+(byte2 or 0)*256
+ +(byte3 or 0)*65536+(byte4 or 0)*16777216)*lshift_mask
+ input_next_byte_pos = input_next_byte_pos + 4
+ cache_bitlen = cache_bitlen + 32
+ end
+
+ local rshift_mask = _pow2[min_bitlen]
+ cache_bitlen = cache_bitlen - min_bitlen
+ code = cache % rshift_mask
+ cache = (cache - code) / rshift_mask
+ -- Reverse the bits
+ code = _reverse_bits_tbl[min_bitlen][code]
+
+ count = huffman_bitlen_counts[min_bitlen]
+ if code < count then
+ return huffman_symbols[code]
+ end
+ index = count
+ first = count * 2
+ code = code * 2
+ end
+
+ for bitlen = min_bitlen+1, 15 do
+ local bit
+ bit = cache % 2
+ cache = (cache - bit) / 2
+ cache_bitlen = cache_bitlen - 1
+
+ code = (bit==1) and (code + 1 - code % 2) or code
+ count = huffman_bitlen_counts[bitlen] or 0
+ local diff = code - first
+ if diff < count then
+ return huffman_symbols[index + diff]
+ end
+ index = index + count
+ first = first + count
+ first = first * 2
+ code = code * 2
+ end
+ -- invalid literal/length or distance code
+ -- in fixed or dynamic block (run out of code)
+ return -10
+ end
+
+ local function ReaderBitlenLeft()
+ return (input_strlen - input_next_byte_pos + 1) * 8 + cache_bitlen
+ end
+
+ local function SkipToByteBoundary()
+ local skipped_bitlen = cache_bitlen%8
+ local rshift_mask = _pow2[skipped_bitlen]
+ cache_bitlen = cache_bitlen - skipped_bitlen
+ cache = (cache - cache % rshift_mask) / rshift_mask
+ end
+
+ return ReadBits, ReadBytes, Decode, ReaderBitlenLeft, SkipToByteBoundary
+end
+
+-- Create a deflate state, so I can pass in less arguments to functions.
+-- @param str the whole string to be decompressed.
+-- @param dictionary The preset dictionary. nil if not provided.
+-- This dictionary should be produced by LibDeflate:CreateDictionary(str)
+-- @return The decomrpess state.
+local function CreateDecompressState(str, dictionary)
+ local ReadBits, ReadBytes, Decode, ReaderBitlenLeft
+ , SkipToByteBoundary = CreateReader(str)
+ local state =
+ {
+ ReadBits = ReadBits,
+ ReadBytes = ReadBytes,
+ Decode = Decode,
+ ReaderBitlenLeft = ReaderBitlenLeft,
+ SkipToByteBoundary = SkipToByteBoundary,
+ buffer_size = 0,
+ buffer = {},
+ result_buffer = {},
+ dictionary = dictionary,
+ }
+ return state
+end
+
+-- Get the stuffs needed to decode huffman codes
+-- @see puff.c:construct(...)
+-- @param huffman_bitlen The huffman bit length of the huffman codes.
+-- @param max_symbol The maximum symbol
+-- @param max_bitlen The min huffman bit length of all codes
+-- @return zero or positive for success, negative for failure.
+-- @return The count of each huffman bit length.
+-- @return A table to convert huffman codes to deflate codes.
+-- @return The minimum huffman bit length.
+local function GetHuffmanForDecode(huffman_bitlens, max_symbol, max_bitlen)
+ local huffman_bitlen_counts = {}
+ local min_bitlen = max_bitlen
+ for symbol = 0, max_symbol do
+ local bitlen = huffman_bitlens[symbol] or 0
+ min_bitlen = (bitlen > 0 and bitlen < min_bitlen)
+ and bitlen or min_bitlen
+ huffman_bitlen_counts[bitlen] = (huffman_bitlen_counts[bitlen] or 0)+1
+ end
+
+ if huffman_bitlen_counts[0] == max_symbol+1 then -- No Codes
+ return 0, huffman_bitlen_counts, {}, 0 -- Complete, but decode will fail
+ end
+
+ local left = 1
+ for len = 1, max_bitlen do
+ left = left * 2
+ left = left - (huffman_bitlen_counts[len] or 0)
+ if left < 0 then
+ return left -- Over-subscribed, return negative
+ end
+ end
+
+ -- Generate offsets info symbol table for each length for sorting
+ local offsets = {}
+ offsets[1] = 0
+ for len = 1, max_bitlen-1 do
+ offsets[len + 1] = offsets[len] + (huffman_bitlen_counts[len] or 0)
+ end
+
+ local huffman_symbols = {}
+ for symbol = 0, max_symbol do
+ local bitlen = huffman_bitlens[symbol] or 0
+ if bitlen ~= 0 then
+ local offset = offsets[bitlen]
+ huffman_symbols[offset] = symbol
+ offsets[bitlen] = offsets[bitlen] + 1
+ end
+ end
+
+ -- Return zero for complete set, positive for incomplete set.
+ return left, huffman_bitlen_counts, huffman_symbols, min_bitlen
+end
+
+-- Decode a fixed or dynamic huffman blocks, excluding last block identifier
+-- and block type identifer.
+-- @see puff.c:codes()
+-- @param state decompression state that will be modified by this function.
+-- @see CreateDecompressState
+-- @param ... Read the source code
+-- @return 0 on success, other value on failure.
+local function DecodeUntilEndOfBlock(state, lcodes_huffman_bitlens
+ , lcodes_huffman_symbols, lcodes_huffman_min_bitlen
+ , dcodes_huffman_bitlens, dcodes_huffman_symbols
+ , dcodes_huffman_min_bitlen)
+ local buffer, buffer_size, ReadBits, Decode, ReaderBitlenLeft
+ , result_buffer =
+ state.buffer, state.buffer_size, state.ReadBits, state.Decode
+ , state.ReaderBitlenLeft, state.result_buffer
+ local dictionary = state.dictionary
+ local dict_string_table
+ local dict_strlen
+
+ local buffer_end = 1
+ if dictionary and not buffer[0] then
+ -- If there is a dictionary, copy the last 258 bytes into
+ -- the string_table to make the copy in the main loop quicker.
+ -- This is done only once per decompression.
+ dict_string_table = dictionary.string_table
+ dict_strlen = dictionary.strlen
+ buffer_end = -dict_strlen + 1
+ for i=0, (-dict_strlen+1)<-257 and -257 or (-dict_strlen+1), -1 do
+ buffer[i] = _byte_to_char[dict_string_table[dict_strlen+i]]
+ end
+ end
+
+ repeat
+ local symbol = Decode(lcodes_huffman_bitlens
+ , lcodes_huffman_symbols, lcodes_huffman_min_bitlen)
+ if symbol < 0 or symbol > 285 then
+ -- invalid literal/length or distance code in fixed or dynamic block
+ return -10
+ elseif symbol < 256 then -- Literal
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = _byte_to_char[symbol]
+ elseif symbol > 256 then -- Length code
+ symbol = symbol - 256
+ local bitlen = _literal_deflate_code_to_base_len[symbol]
+ bitlen = (symbol >= 8)
+ and (bitlen
+ + ReadBits(_literal_deflate_code_to_extra_bitlen[symbol]))
+ or bitlen
+ symbol = Decode(dcodes_huffman_bitlens, dcodes_huffman_symbols
+ , dcodes_huffman_min_bitlen)
+ if symbol < 0 or symbol > 29 then
+ -- invalid literal/length or distance code in fixed or dynamic block
+ return -10
+ end
+ local dist = _dist_deflate_code_to_base_dist[symbol]
+ dist = (dist > 4) and (dist
+ + ReadBits(_dist_deflate_code_to_extra_bitlen[symbol])) or dist
+
+ local char_buffer_index = buffer_size-dist+1
+ if char_buffer_index < buffer_end then
+ -- distance is too far back in fixed or dynamic block
+ return -11
+ end
+ if char_buffer_index >= -257 then
+ for _=1, bitlen do
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = buffer[char_buffer_index]
+ char_buffer_index = char_buffer_index + 1
+ end
+ else
+ char_buffer_index = dict_strlen + char_buffer_index
+ for _=1, bitlen do
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] =
+ _byte_to_char[dict_string_table[char_buffer_index]]
+ char_buffer_index = char_buffer_index + 1
+ end
+ end
+ end
+
+ if ReaderBitlenLeft() < 0 then
+ return 2 -- available inflate data did not terminate
+ end
+
+ if buffer_size >= 65536 then
+ result_buffer[#result_buffer+1] =
+ table_concat(buffer, "", 1, 32768)
+ for i=32769, buffer_size do
+ buffer[i-32768] = buffer[i]
+ end
+ buffer_size = buffer_size - 32768
+ buffer[buffer_size+1] = nil
+ -- NOTE: buffer[32769..end] and buffer[-257..0] are not cleared.
+ -- This is why "buffer_size" variable is needed.
+ end
+ until symbol == 256
+
+ state.buffer_size = buffer_size
+
+ return 0
+end
+
+-- Decompress a store block
+-- @param state decompression state that will be modified by this function.
+-- @return 0 if succeeds, other value if fails.
+local function DecompressStoreBlock(state)
+ local buffer, buffer_size, ReadBits, ReadBytes, ReaderBitlenLeft
+ , SkipToByteBoundary, result_buffer =
+ state.buffer, state.buffer_size, state.ReadBits, state.ReadBytes
+ , state.ReaderBitlenLeft, state.SkipToByteBoundary, state.result_buffer
+
+ SkipToByteBoundary()
+ local bytelen = ReadBits(16)
+ if ReaderBitlenLeft() < 0 then
+ return 2 -- available inflate data did not terminate
+ end
+ local bytelenComp = ReadBits(16)
+ if ReaderBitlenLeft() < 0 then
+ return 2 -- available inflate data did not terminate
+ end
+
+ if bytelen % 256 + bytelenComp % 256 ~= 255 then
+ return -2 -- Not one's complement
+ end
+ if (bytelen-bytelen % 256)/256
+ + (bytelenComp-bytelenComp % 256)/256 ~= 255 then
+ return -2 -- Not one's complement
+ end
+
+ -- Note that ReadBytes will skip to the next byte boundary first.
+ buffer_size = ReadBytes(bytelen, buffer, buffer_size)
+ if buffer_size < 0 then
+ return 2 -- available inflate data did not terminate
+ end
+
+ -- memory clean up when there are enough bytes in the buffer.
+ if buffer_size >= 65536 then
+ result_buffer[#result_buffer+1] = table_concat(buffer, "", 1, 32768)
+ for i=32769, buffer_size do
+ buffer[i-32768] = buffer[i]
+ end
+ buffer_size = buffer_size - 32768
+ buffer[buffer_size+1] = nil
+ end
+ state.buffer_size = buffer_size
+ return 0
+end
+
+-- Decompress a fixed block
+-- @param state decompression state that will be modified by this function.
+-- @return 0 if succeeds other value if fails.
+local function DecompressFixBlock(state)
+ return DecodeUntilEndOfBlock(state
+ , _fix_block_literal_huffman_bitlen_count
+ , _fix_block_literal_huffman_to_deflate_code, 7
+ , _fix_block_dist_huffman_bitlen_count
+ , _fix_block_dist_huffman_to_deflate_code, 5)
+end
+
+-- Decompress a dynamic block
+-- @param state decompression state that will be modified by this function.
+-- @return 0 if success, other value if fails.
+local function DecompressDynamicBlock(state)
+ local ReadBits, Decode = state.ReadBits, state.Decode
+ local nlen = ReadBits(5) + 257
+ local ndist = ReadBits(5) + 1
+ local ncode = ReadBits(4) + 4
+ if nlen > 286 or ndist > 30 then
+ -- dynamic block code description: too many length or distance codes
+ return -3
+ end
+
+ local rle_codes_huffman_bitlens = {}
+
+ for i = 1, ncode do
+ rle_codes_huffman_bitlens[_rle_codes_huffman_bitlen_order[i]] =
+ ReadBits(3)
+ end
+
+ local rle_codes_err, rle_codes_huffman_bitlen_counts,
+ rle_codes_huffman_symbols, rle_codes_huffman_min_bitlen =
+ GetHuffmanForDecode(rle_codes_huffman_bitlens, 18, 7)
+ if rle_codes_err ~= 0 then -- Require complete code set here
+ -- dynamic block code description: code lengths codes incomplete
+ return -4
+ end
+
+ local lcodes_huffman_bitlens = {}
+ local dcodes_huffman_bitlens = {}
+ -- Read length/literal and distance code length tables
+ local index = 0
+ while index < nlen + ndist do
+ local symbol -- Decoded value
+ local bitlen -- Last length to repeat
+
+ symbol = Decode(rle_codes_huffman_bitlen_counts
+ , rle_codes_huffman_symbols, rle_codes_huffman_min_bitlen)
+
+ if symbol < 0 then
+ return symbol -- Invalid symbol
+ elseif symbol < 16 then
+ if index < nlen then
+ lcodes_huffman_bitlens[index] = symbol
+ else
+ dcodes_huffman_bitlens[index-nlen] = symbol
+ end
+ index = index + 1
+ else
+ bitlen = 0
+ if symbol == 16 then
+ if index == 0 then
+ -- dynamic block code description: repeat lengths
+ -- with no first length
+ return -5
+ end
+ if index-1 < nlen then
+ bitlen = lcodes_huffman_bitlens[index-1]
+ else
+ bitlen = dcodes_huffman_bitlens[index-nlen-1]
+ end
+ symbol = 3 + ReadBits(2)
+ elseif symbol == 17 then -- Repeat zero 3..10 times
+ symbol = 3 + ReadBits(3)
+ else -- == 18, repeat zero 11.138 times
+ symbol = 11 + ReadBits(7)
+ end
+ if index + symbol > nlen + ndist then
+ -- dynamic block code description:
+ -- repeat more than specified lengths
+ return -6
+ end
+ while symbol > 0 do -- Repeat last or zero symbol times
+ symbol = symbol - 1
+ if index < nlen then
+ lcodes_huffman_bitlens[index] = bitlen
+ else
+ dcodes_huffman_bitlens[index-nlen] = bitlen
+ end
+ index = index + 1
+ end
+ end
+ end
+
+ if (lcodes_huffman_bitlens[256] or 0) == 0 then
+ -- dynamic block code description: missing end-of-block code
+ return -9
+ end
+
+ local lcodes_err, lcodes_huffman_bitlen_counts
+ , lcodes_huffman_symbols, lcodes_huffman_min_bitlen =
+ GetHuffmanForDecode(lcodes_huffman_bitlens, nlen-1, 15)
+ --dynamic block code description: invalid literal/length code lengths,
+ -- Incomplete code ok only for single length 1 code
+ if (lcodes_err ~=0 and (lcodes_err < 0
+ or nlen ~= (lcodes_huffman_bitlen_counts[0] or 0)
+ +(lcodes_huffman_bitlen_counts[1] or 0))) then
+ return -7
+ end
+
+ local dcodes_err, dcodes_huffman_bitlen_counts
+ , dcodes_huffman_symbols, dcodes_huffman_min_bitlen =
+ GetHuffmanForDecode(dcodes_huffman_bitlens, ndist-1, 15)
+ -- dynamic block code description: invalid distance code lengths,
+ -- Incomplete code ok only for single length 1 code
+ if (dcodes_err ~=0 and (dcodes_err < 0
+ or ndist ~= (dcodes_huffman_bitlen_counts[0] or 0)
+ + (dcodes_huffman_bitlen_counts[1] or 0))) then
+ return -8
+ end
+
+ -- Build buffman table for literal/length codes
+ return DecodeUntilEndOfBlock(state, lcodes_huffman_bitlen_counts
+ , lcodes_huffman_symbols, lcodes_huffman_min_bitlen
+ , dcodes_huffman_bitlen_counts, dcodes_huffman_symbols
+ , dcodes_huffman_min_bitlen)
+end
+
+-- Decompress a deflate stream
+-- @param state: a decompression state
+-- @return the decompressed string if succeeds. nil if fails.
+local function Inflate(state)
+ local ReadBits = state.ReadBits
+
+ local is_last_block
+ while not is_last_block do
+ is_last_block = (ReadBits(1) == 1)
+ local block_type = ReadBits(2)
+ local status
+ if block_type == 0 then
+ status = DecompressStoreBlock(state)
+ elseif block_type == 1 then
+ status = DecompressFixBlock(state)
+ elseif block_type == 2 then
+ status = DecompressDynamicBlock(state)
+ else
+ return nil, -1 -- invalid block type (type == 3)
+ end
+ if status ~= 0 then
+ return nil, status
+ end
+ end
+
+ state.result_buffer[#state.result_buffer+1] =
+ table_concat(state.buffer, "", 1, state.buffer_size)
+ local result = table_concat(state.result_buffer)
+ return result
+end
+
+-- @see LibDeflate:DecompressDeflate(str)
+-- @see LibDeflate:DecompressDeflateWithDict(str, dictionary)
+local function DecompressDeflateInternal(str, dictionary)
+ local state = CreateDecompressState(str, dictionary)
+ local result, status = Inflate(state)
+ if not result then
+ return nil, status
+ end
+
+ local bitlen_left = state.ReaderBitlenLeft()
+ local bytelen_left = (bitlen_left - bitlen_left % 8) / 8
+ return result, bytelen_left
+end
+
+-- @see LibDeflate:DecompressZlib(str)
+-- @see LibDeflate:DecompressZlibWithDict(str)
+local function DecompressZlibInternal(str, dictionary)
+ local state = CreateDecompressState(str, dictionary)
+ local ReadBits = state.ReadBits
+
+ local CMF = ReadBits(8)
+ if state.ReaderBitlenLeft() < 0 then
+ return nil, 2 -- available inflate data did not terminate
+ end
+ local CM = CMF % 16
+ local CINFO = (CMF - CM) / 16
+ if CM ~= 8 then
+ return nil, -12 -- invalid compression method
+ end
+ if CINFO > 7 then
+ return nil, -13 -- invalid window size
+ end
+
+ local FLG = ReadBits(8)
+ if state.ReaderBitlenLeft() < 0 then
+ return nil, 2 -- available inflate data did not terminate
+ end
+ if (CMF*256+FLG)%31 ~= 0 then
+ return nil, -14 -- invalid header checksum
+ end
+
+ local FDIST = ((FLG-FLG%32)/32 % 2)
+ local FLEVEL = ((FLG-FLG%64)/64 % 4) -- luacheck: ignore FLEVEL
+
+ if FDIST == 1 then
+ if not dictionary then
+ return nil, -16 -- need dictonary, but dictionary is not provided.
+ end
+ local byte3 = ReadBits(8)
+ local byte2 = ReadBits(8)
+ local byte1 = ReadBits(8)
+ local byte0 = ReadBits(8)
+ local actual_adler32 = byte3*16777216+byte2*65536+byte1*256+byte0
+ if state.ReaderBitlenLeft() < 0 then
+ return nil, 2 -- available inflate data did not terminate
+ end
+ if not IsEqualAdler32(actual_adler32, dictionary.adler32) then
+ return nil, -17 -- dictionary adler32 does not match
+ end
+ end
+ local result, status = Inflate(state)
+ if not result then
+ return nil, status
+ end
+ state.SkipToByteBoundary()
+
+ local adler_byte0 = ReadBits(8)
+ local adler_byte1 = ReadBits(8)
+ local adler_byte2 = ReadBits(8)
+ local adler_byte3 = ReadBits(8)
+ if state.ReaderBitlenLeft() < 0 then
+ return nil, 2 -- available inflate data did not terminate
+ end
+
+ local adler32_expected = adler_byte0*16777216
+ + adler_byte1*65536 + adler_byte2*256 + adler_byte3
+ local adler32_actual = LibDeflate:Adler32(result)
+ if not IsEqualAdler32(adler32_expected, adler32_actual) then
+ return nil, -15 -- Adler32 checksum does not match
+ end
+
+ local bitlen_left = state.ReaderBitlenLeft()
+ local bytelen_left = (bitlen_left - bitlen_left % 8) / 8
+ return result, bytelen_left
+end
+
+--- Decompress a raw deflate compressed data.
+-- @param str [string] The data to be decompressed.
+-- @return [string/nil] If the decompression succeeds, return the decompressed
+-- data. If the decompression fails, return nil. You should check if this return
+-- value is non-nil to know if the decompression succeeds.
+-- @return [integer] If the decompression succeeds, return the number of
+-- unprocessed bytes in the input compressed data. This return value is a
+-- positive integer if the input data is a valid compressed data appended by an
+-- arbitary non-empty string. This return value is 0 if the input data does not
+-- contain any extra bytes.
+-- If the decompression fails (The first return value of this function is nil),
+-- this return value is undefined.
+-- @see LibDeflate:CompressDeflate
+function LibDeflate:DecompressDeflate(str)
+ local arg_valid, arg_err = IsValidArguments(str)
+ if not arg_valid then
+ error(("Usage: LibDeflate:DecompressDeflate(str): "
+ ..arg_err), 2)
+ end
+ return DecompressDeflateInternal(str)
+end
+
+--- Decompress a raw deflate compressed data with a preset dictionary.
+-- @param str [string] The data to be decompressed.
+-- @param dictionary [table] The preset dictionary used by
+-- LibDeflate:CompressDeflateWithDict when the compressed data is produced.
+-- Decompression and compression must use the same dictionary.
+-- Otherwise wrong decompressed data could be produced without generating any
+-- error.
+-- @return [string/nil] If the decompression succeeds, return the decompressed
+-- data. If the decompression fails, return nil. You should check if this return
+-- value is non-nil to know if the decompression succeeds.
+-- @return [integer] If the decompression succeeds, return the number of
+-- unprocessed bytes in the input compressed data. This return value is a
+-- positive integer if the input data is a valid compressed data appended by an
+-- arbitary non-empty string. This return value is 0 if the input data does not
+-- contain any extra bytes.
+-- If the decompression fails (The first return value of this function is nil),
+-- this return value is undefined.
+-- @see LibDeflate:CompressDeflateWithDict
+function LibDeflate:DecompressDeflateWithDict(str, dictionary)
+ local arg_valid, arg_err = IsValidArguments(str, true, dictionary)
+ if not arg_valid then
+ error(("Usage: LibDeflate:DecompressDeflateWithDict(str, dictionary): "
+ ..arg_err), 2)
+ end
+ return DecompressDeflateInternal(str, dictionary)
+end
+
+--- Decompress a zlib compressed data.
+-- @param str [string] The data to be decompressed
+-- @return [string/nil] If the decompression succeeds, return the decompressed
+-- data. If the decompression fails, return nil. You should check if this return
+-- value is non-nil to know if the decompression succeeds.
+-- @return [integer] If the decompression succeeds, return the number of
+-- unprocessed bytes in the input compressed data. This return value is a
+-- positive integer if the input data is a valid compressed data appended by an
+-- arbitary non-empty string. This return value is 0 if the input data does not
+-- contain any extra bytes.
+-- If the decompression fails (The first return value of this function is nil),
+-- this return value is undefined.
+-- @see LibDeflate:CompressZlib
+function LibDeflate:DecompressZlib(str)
+ local arg_valid, arg_err = IsValidArguments(str)
+ if not arg_valid then
+ error(("Usage: LibDeflate:DecompressZlib(str): "
+ ..arg_err), 2)
+ end
+ return DecompressZlibInternal(str)
+end
+
+--- Decompress a zlib compressed data with a preset dictionary.
+-- @param str [string] The data to be decompressed
+-- @param dictionary [table] The preset dictionary used by
+-- LibDeflate:CompressDeflateWithDict when the compressed data is produced.
+-- Decompression and compression must use the same dictionary.
+-- Otherwise wrong decompressed data could be produced without generating any
+-- error.
+-- @return [string/nil] If the decompression succeeds, return the decompressed
+-- data. If the decompression fails, return nil. You should check if this return
+-- value is non-nil to know if the decompression succeeds.
+-- @return [integer] If the decompression succeeds, return the number of
+-- unprocessed bytes in the input compressed data. This return value is a
+-- positive integer if the input data is a valid compressed data appended by an
+-- arbitary non-empty string. This return value is 0 if the input data does not
+-- contain any extra bytes.
+-- If the decompression fails (The first return value of this function is nil),
+-- this return value is undefined.
+-- @see LibDeflate:CompressZlibWithDict
+function LibDeflate:DecompressZlibWithDict(str, dictionary)
+ local arg_valid, arg_err = IsValidArguments(str, true, dictionary)
+ if not arg_valid then
+ error(("Usage: LibDeflate:DecompressZlibWithDict(str, dictionary): "
+ ..arg_err), 2)
+ end
+ return DecompressZlibInternal(str, dictionary)
+end
+
+-- Calculate the huffman code of fixed block
+do
+ _fix_block_literal_huffman_bitlen = {}
+ for sym=0, 143 do
+ _fix_block_literal_huffman_bitlen[sym] = 8
+ end
+ for sym=144, 255 do
+ _fix_block_literal_huffman_bitlen[sym] = 9
+ end
+ for sym=256, 279 do
+ _fix_block_literal_huffman_bitlen[sym] = 7
+ end
+ for sym=280, 287 do
+ _fix_block_literal_huffman_bitlen[sym] = 8
+ end
+
+ _fix_block_dist_huffman_bitlen = {}
+ for dist=0, 31 do
+ _fix_block_dist_huffman_bitlen[dist] = 5
+ end
+ local status
+ status, _fix_block_literal_huffman_bitlen_count
+ , _fix_block_literal_huffman_to_deflate_code =
+ GetHuffmanForDecode(_fix_block_literal_huffman_bitlen, 287, 9)
+ assert(status == 0)
+ status, _fix_block_dist_huffman_bitlen_count,
+ _fix_block_dist_huffman_to_deflate_code =
+ GetHuffmanForDecode(_fix_block_dist_huffman_bitlen, 31, 5)
+ assert(status == 0)
+
+ _fix_block_literal_huffman_code =
+ GetHuffmanCodeFromBitlen(_fix_block_literal_huffman_bitlen_count
+ , _fix_block_literal_huffman_bitlen, 287, 9)
+ _fix_block_dist_huffman_code =
+ GetHuffmanCodeFromBitlen(_fix_block_dist_huffman_bitlen_count
+ , _fix_block_dist_huffman_bitlen, 31, 5)
+end
+
+-- Encoding algorithms
+-- Prefix encoding algorithm
+-- implemented by Galmok of European Stormrage (Horde), galmok@gmail.com
+-- From LibCompress ,
+-- which is licensed under GPLv2
+-- The code has been modified by the author of LibDeflate.
+------------------------------------------------------------------------------
+
+-- to be able to match any requested byte value, the search
+-- string must be preprocessed characters to escape with %:
+-- ( ) . % + - * ? [ ] ^ $
+-- "illegal" byte values:
+-- 0 is replaces %z
+local _gsub_escape_table = {
+ ["\000"] = "%z", ["("] = "%(", [")"] = "%)", ["."] = "%.",
+ ["%"] = "%%", ["+"] = "%+", ["-"] = "%-", ["*"] = "%*",
+ ["?"] = "%?", ["["] = "%[", ["]"] = "%]", ["^"] = "%^",
+ ["$"] = "%$",
+}
+
+local function escape_for_gsub(str)
+ return str:gsub("([%z%(%)%.%%%+%-%*%?%[%]%^%$])", _gsub_escape_table)
+end
+
+--- Create a custom codec with encoder and decoder.
+-- This codec is used to convert an input string to make it not contain
+-- some specific bytes.
+-- This created codec and the parameters of this function do NOT take
+-- localization into account. One byte (0-255) in the string is exactly one
+-- character (0-255).
+-- Credits to LibCompress.
+-- @param reserved_chars [string] The created encoder will ensure encoded
+-- data does not contain any single character in reserved_chars. This parameter
+-- should be non-empty.
+-- @param escape_chars [string] The escape character(s) used in the created
+-- codec. The codec converts any character included in reserved\_chars /
+-- escape\_chars / map\_chars to (one escape char + one character not in
+-- reserved\_chars / escape\_chars / map\_chars).
+-- You usually only need to provide a length-1 string for this parameter.
+-- Length-2 string is only needed when
+-- reserved\_chars + escape\_chars + map\_chars is longer than 127.
+-- This parameter should be non-empty.
+-- @param map_chars [string] The created encoder will map every
+-- reserved\_chars:sub(i, i) (1 <= i <= #map\_chars) to map\_chars:sub(i, i).
+-- This parameter CAN be empty string.
+-- @return [table/nil] If the codec cannot be created, return nil.
+-- If the codec can be created according to the given
+-- parameters, return the codec, which is a encode/decode table.
+-- The table contains two functions:
+-- t:Encode(str) returns the encoded string.
+-- t:Decode(str) returns the decoded string if succeeds. nil if fails.
+-- @return [nil/string] If the codec is successfully created, return nil.
+-- If not, return a string that describes the reason why the codec cannot be
+-- created.
+-- @usage
+-- -- Create an encoder/decoder that maps all "\000" to "\003",
+-- -- and escape "\001" (and "\002" and "\003") properly
+-- local codec = LibDeflate:CreateCodec("\000\001", "\002", "\003")
+--
+-- local encoded = codec:Encode(SOME_STRING)
+-- -- "encoded" does not contain "\000" or "\001"
+-- local decoded = codec:Decode(encoded)
+-- -- assert(decoded == SOME_STRING)
+function LibDeflate:CreateCodec(reserved_chars, escape_chars
+ , map_chars)
+ -- select a default escape character
+ if type(reserved_chars) ~= "string"
+ or type(escape_chars) ~= "string"
+ or type(map_chars) ~= "string" then
+ error(
+ "Usage: LibDeflate:CreateCodec(reserved_chars,"
+ .." escape_chars, map_chars):"
+ .." All arguments must be string.", 2)
+ end
+
+ if escape_chars == "" then
+ return nil, "No escape characters supplied."
+ end
+ if #reserved_chars < #map_chars then
+ return nil, "The number of reserved characters must be"
+ .." at least as many as the number of mapped chars."
+ end
+ if reserved_chars == "" then
+ return nil, "No characters to encode."
+ end
+
+ local encode_bytes = reserved_chars..escape_chars..map_chars
+ -- build list of bytes not available as a suffix to a prefix byte
+ local taken = {}
+ for i = 1, #encode_bytes do
+ local byte = string_byte(encode_bytes, i, i)
+ if taken[byte] then -- Modified by LibDeflate:
+ return nil, "There must be no duplicate characters in the"
+ .." concatenation of reserved_chars, escape_chars and"
+ .." map_chars."
+ end
+ taken[byte] = true
+ end
+
+ -- Modified by LibDeflate:
+ -- Store the patterns and replacement in tables for later use.
+ -- This function is modified that loadstring() lua api is no longer used.
+ local decode_patterns = {}
+ local decode_repls = {}
+
+ -- the encoding can be a single gsub
+ -- , but the decoding can require multiple gsubs
+ local encode_search = {}
+ local encode_translate = {}
+
+ -- map single byte to single byte
+ if #map_chars > 0 then
+ local decode_search = {}
+ local decode_translate = {}
+ for i = 1, #map_chars do
+ local from = string_sub(reserved_chars, i, i)
+ local to = string_sub(map_chars, i, i)
+ encode_translate[from] = to
+ encode_search[#encode_search+1] = from
+ decode_translate[to] = from
+ decode_search[#decode_search+1] = to
+ end
+ decode_patterns[#decode_patterns+1] =
+ "([".. escape_for_gsub(table_concat(decode_search)).."])"
+ decode_repls[#decode_repls+1] = decode_translate
+ end
+
+ local escape_char_index = 1
+ local escape_char = string_sub(escape_chars
+ , escape_char_index, escape_char_index)
+ -- map single byte to double-byte
+ local r = 0 -- suffix char value to the escapeChar
+
+ local decode_search = {}
+ local decode_translate = {}
+ for i = 1, #encode_bytes do
+ local c = string_sub(encode_bytes, i, i)
+ if not encode_translate[c] then
+ -- this loop will update escapeChar and r
+ while r >= 256 or taken[r] do
+ -- Bug in LibCompress r81
+ -- while r < 256 and taken[r] do
+ r = r + 1
+ if r > 255 then -- switch to next escapeChar
+ decode_patterns[#decode_patterns+1] =
+ escape_for_gsub(escape_char)
+ .."(["
+ .. escape_for_gsub(table_concat(decode_search)).."])"
+ decode_repls[#decode_repls+1] = decode_translate
+
+ escape_char_index = escape_char_index + 1
+ escape_char = string_sub(escape_chars, escape_char_index
+ , escape_char_index)
+ r = 0
+ decode_search = {}
+ decode_translate = {}
+
+ -- Fixes Another bug in LibCompress r82.
+ -- LibCompress checks this error condition
+ -- right after "if r > 255 then"
+ -- This is why error case should also be tested.
+ if not escape_char or escape_char == "" then
+ -- actually I don't need to check
+ -- "not ecape_char", but what if Lua changes
+ -- the behavior of string.sub() in the future?
+ -- we are out of escape chars and we need more!
+ return nil, "Out of escape characters."
+ end
+ end
+ end
+
+ local char_r = _byte_to_char[r]
+ encode_translate[c] = escape_char..char_r
+ encode_search[#encode_search+1] = c
+ decode_translate[char_r] = c
+ decode_search[#decode_search+1] = char_r
+ r = r + 1
+ end
+ if i == #encode_bytes then
+ decode_patterns[#decode_patterns+1] =
+ escape_for_gsub(escape_char).."(["
+ .. escape_for_gsub(table_concat(decode_search)).."])"
+ decode_repls[#decode_repls+1] = decode_translate
+ end
+ end
+
+ local codec = {}
+
+ local encode_pattern = "(["
+ .. escape_for_gsub(table_concat(encode_search)).."])"
+ local encode_repl = encode_translate
+
+ function codec:Encode(str)
+ if type(str) ~= "string" then
+ error(("Usage: codec:Encode(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ return string_gsub(str, encode_pattern, encode_repl)
+ end
+
+ local decode_tblsize = #decode_patterns
+ local decode_fail_pattern = "(["
+ .. escape_for_gsub(reserved_chars).."])"
+
+ function codec:Decode(str)
+ if type(str) ~= "string" then
+ error(("Usage: codec:Decode(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if string_find(str, decode_fail_pattern) then
+ return nil
+ end
+ for i = 1, decode_tblsize do
+ str = string_gsub(str, decode_patterns[i], decode_repls[i])
+ end
+ return str
+ end
+
+ return codec
+end
+
+local _addon_channel_codec
+
+local function GenerateWoWAddonChannelCodec()
+ return LibDeflate:CreateCodec("\000", "\001", "")
+end
+
+--- Encode the string to make it ready to be transmitted in World of
+-- Warcraft addon channel.
+-- The encoded string is guaranteed to contain no NULL ("\000") character.
+-- @param str [string] The string to be encoded.
+-- @return The encoded string.
+-- @see LibDeflate:DecodeForWoWAddonChannel
+function LibDeflate:EncodeForWoWAddonChannel(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:EncodeForWoWAddonChannel(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if not _addon_channel_codec then
+ _addon_channel_codec = GenerateWoWAddonChannelCodec()
+ end
+ return _addon_channel_codec:Encode(str)
+end
+
+--- Decode the string produced by LibDeflate:EncodeForWoWAddonChannel
+-- @param str [string] The string to be decoded.
+-- @return [string/nil] The decoded string if succeeds. nil if fails.
+-- @see LibDeflate:EncodeForWoWAddonChannel
+function LibDeflate:DecodeForWoWAddonChannel(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:DecodeForWoWAddonChannel(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if not _addon_channel_codec then
+ _addon_channel_codec = GenerateWoWAddonChannelCodec()
+ end
+ return _addon_channel_codec:Decode(str)
+end
+
+-- For World of Warcraft Chat Channel Encoding
+-- implemented by Galmok of European Stormrage (Horde), galmok@gmail.com
+-- From LibCompress ,
+-- which is licensed under GPLv2
+-- The code has been modified by the author of LibDeflate.
+-- Following byte values are not allowed:
+-- \000, s, S, \010, \013, \124, %
+-- Because SendChatMessage will error
+-- if an UTF8 multibyte character is incomplete,
+-- all character values above 127 have to be encoded to avoid this.
+-- This costs quite a bit of bandwidth (about 13-14%)
+-- Also, because drunken status is unknown for the received
+-- , strings used with SendChatMessage should be terminated with
+-- an identifying byte value, after which the server MAY add "...hic!"
+-- or as much as it can fit(!).
+-- Pass the identifying byte as a reserved character to this function
+-- to ensure the encoding doesn't contain that value.
+-- or use this: local message, match = arg1:gsub("^(.*)\029.-$", "%1")
+-- arg1 is message from channel, \029 is the string terminator
+-- , but may be used in the encoded datastream as well. :-)
+-- This encoding will expand data anywhere from:
+-- 0% (average with pure ascii text)
+-- 53.5% (average with random data valued zero to 255)
+-- 100% (only encoding data that encodes to two bytes)
+local function GenerateWoWChatChannelCodec()
+ local r = {}
+ for i = 128, 255 do
+ r[#r+1] = _byte_to_char[i]
+ end
+
+ local reserved_chars = "sS\000\010\013\124%"..table_concat(r)
+ return LibDeflate:CreateCodec(reserved_chars
+ , "\029\031", "\015\020")
+end
+
+local _chat_channel_codec
+
+--- Encode the string to make it ready to be transmitted in World of
+-- Warcraft chat channel.
+-- See also https://wow.gamepedia.com/ValidChatMessageCharacters
+-- @param str [string] The string to be encoded.
+-- @return [string] The encoded string.
+-- @see LibDeflate:DecodeForWoWChatChannel
+function LibDeflate:EncodeForWoWChatChannel(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:EncodeForWoWChatChannel(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if not _chat_channel_codec then
+ _chat_channel_codec = GenerateWoWChatChannelCodec()
+ end
+ return _chat_channel_codec:Encode(str)
+end
+
+--- Decode the string produced by LibDeflate:EncodeForWoWChatChannel.
+-- @param str [string] The string to be decoded.
+-- @return [string/nil] The decoded string if succeeds. nil if fails.
+-- @see LibDeflate:EncodeForWoWChatChannel
+function LibDeflate:DecodeForWoWChatChannel(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:DecodeForWoWChatChannel(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ if not _chat_channel_codec then
+ _chat_channel_codec = GenerateWoWChatChannelCodec()
+ end
+ return _chat_channel_codec:Decode(str)
+end
+
+-- Credits to WeakAuras ,
+-- and Galmok (galmok@gmail.com) for the 6 bit encoding algorithm.
+-- The result of encoding will be 25% larger than the
+-- origin string, but every single byte of the encoding result will be
+-- printable characters as the following.
+local _byte_to_6bit_char = {
+ [0]="a", "b", "c", "d", "e", "f", "g", "h",
+ "i", "j", "k", "l", "m", "n", "o", "p",
+ "q", "r", "s", "t", "u", "v", "w", "x",
+ "y", "z", "A", "B", "C", "D", "E", "F",
+ "G", "H", "I", "J", "K", "L", "M", "N",
+ "O", "P", "Q", "R", "S", "T", "U", "V",
+ "W", "X", "Y", "Z", "0", "1", "2", "3",
+ "4", "5", "6", "7", "8", "9", "(", ")",
+}
+
+local _6bit_to_byte = {
+ [97]=0,[98]=1,[99]=2,[100]=3,[101]=4,[102]=5,[103]=6,[104]=7,
+ [105]=8,[106]=9,[107]=10,[108]=11,[109]=12,[110]=13,[111]=14,[112]=15,
+ [113]=16,[114]=17,[115]=18,[116]=19,[117]=20,[118]=21,[119]=22,[120]=23,
+ [121]=24,[122]=25,[65]=26,[66]=27,[67]=28,[68]=29,[69]=30,[70]=31,
+ [71]=32,[72]=33,[73]=34,[74]=35,[75]=36,[76]=37,[77]=38,[78]=39,
+ [79]=40,[80]=41,[81]=42,[82]=43,[83]=44,[84]=45,[85]=46,[86]=47,
+ [87]=48,[88]=49,[89]=50,[90]=51,[48]=52,[49]=53,[50]=54,[51]=55,
+ [52]=56,[53]=57,[54]=58,[55]=59,[56]=60,[57]=61,[40]=62,[41]=63,
+}
+
+--- Encode the string to make it printable.
+--
+-- Credis to WeakAuras2, this function is equivalant to the implementation
+-- it is using right now.
+-- The encoded string will be 25% larger than the origin string. However, every
+-- single byte of the encoded string will be one of 64 printable ASCII
+-- characters, which are can be easier copied, pasted and displayed.
+-- (26 lowercase letters, 26 uppercase letters, 10 numbers digits,
+-- left parenthese, or right parenthese)
+-- @param str [string] The string to be encoded.
+-- @return [string] The encoded string.
+function LibDeflate:EncodeForPrint(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:EncodeForPrint(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ local strlen = #str
+ local strlenMinus2 = strlen - 2
+ local i = 1
+ local buffer = {}
+ local buffer_size = 0
+ while i <= strlenMinus2 do
+ local x1, x2, x3 = string_byte(str, i, i+2)
+ i = i + 3
+ local cache = x1+x2*256+x3*65536
+ local b1 = cache % 64
+ cache = (cache - b1) / 64
+ local b2 = cache % 64
+ cache = (cache - b2) / 64
+ local b3 = cache % 64
+ local b4 = (cache - b3) / 64
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] =
+ _byte_to_6bit_char[b1].._byte_to_6bit_char[b2]
+ .._byte_to_6bit_char[b3].._byte_to_6bit_char[b4]
+ end
+
+ local cache = 0
+ local cache_bitlen = 0
+ while i <= strlen do
+ local x = string_byte(str, i, i)
+ cache = cache + x * _pow2[cache_bitlen]
+ cache_bitlen = cache_bitlen + 8
+ i = i + 1
+ end
+ while cache_bitlen > 0 do
+ local bit6 = cache % 64
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = _byte_to_6bit_char[bit6]
+ cache = (cache - bit6) / 64
+ cache_bitlen = cache_bitlen - 6
+ end
+
+ return table_concat(buffer)
+end
+
+--- Decode the printable string produced by LibDeflate:EncodeForPrint.
+-- "str" will have its prefixed and trailing control characters or space
+-- removed before it is decoded, so it is easier to use if "str" comes form
+-- user copy and paste with some prefixed or trailing spaces.
+-- Then decode fails if the string contains any characters cant be produced by
+-- LibDeflate:EncodeForPrint. That means, decode fails if the string contains a
+-- characters NOT one of 26 lowercase letters, 26 uppercase letters,
+-- 10 numbers digits, left parenthese, or right parenthese.
+-- @param str [string] The string to be decoded
+-- @return [string/nil] The decoded string if succeeds. nil if fails.
+function LibDeflate:DecodeForPrint(str)
+ if type(str) ~= "string" then
+ error(("Usage: LibDeflate:DecodeForPrint(str):"
+ .." 'str' - string expected got '%s'."):format(type(str)), 2)
+ end
+ str = str:gsub("^[%c ]+", "")
+ str = str:gsub("[%c ]+$", "")
+
+ local strlen = #str
+ if strlen == 1 then
+ return nil
+ end
+ local strlenMinus3 = strlen - 3
+ local i = 1
+ local buffer = {}
+ local buffer_size = 0
+ while i <= strlenMinus3 do
+ local x1, x2, x3, x4 = string_byte(str, i, i+3)
+ x1 = _6bit_to_byte[x1]
+ x2 = _6bit_to_byte[x2]
+ x3 = _6bit_to_byte[x3]
+ x4 = _6bit_to_byte[x4]
+ if not (x1 and x2 and x3 and x4) then
+ return nil
+ end
+ i = i + 4
+ local cache = x1+x2*64+x3*4096+x4*262144
+ local b1 = cache % 256
+ cache = (cache - b1) / 256
+ local b2 = cache % 256
+ local b3 = (cache - b2) / 256
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] =
+ _byte_to_char[b1].._byte_to_char[b2].._byte_to_char[b3]
+ end
+
+ local cache = 0
+ local cache_bitlen = 0
+ while i <= strlen do
+ local x = string_byte(str, i, i)
+ x = _6bit_to_byte[x]
+ if not x then
+ return nil
+ end
+ cache = cache + x * _pow2[cache_bitlen]
+ cache_bitlen = cache_bitlen + 6
+ i = i + 1
+ end
+
+ while cache_bitlen >= 8 do
+ local byte = cache % 256
+ buffer_size = buffer_size + 1
+ buffer[buffer_size] = _byte_to_char[byte]
+ cache = (cache - byte) / 256
+ cache_bitlen = cache_bitlen - 8
+ end
+
+ return table_concat(buffer)
+end
+
+local function InternalClearCache()
+ _chat_channel_codec = nil
+ _addon_channel_codec = nil
+end
+
+-- For test. Don't use the functions in this table for real application.
+-- Stuffs in this table is subject to change.
+LibDeflate.internals = {
+ LoadStringToTable = LoadStringToTable,
+ IsValidDictionary = IsValidDictionary,
+ IsEqualAdler32 = IsEqualAdler32,
+ _byte_to_6bit_char = _byte_to_6bit_char,
+ _6bit_to_byte = _6bit_to_byte,
+ InternalClearCache = InternalClearCache,
+}
+
+--[[-- Commandline options
+@class table
+@name CommandlineOptions
+@usage lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT]
+\-0 store only. no compression.
+\-1 fastest compression.
+\-9 slowest and best compression.
+\-d do decompression instead of compression.
+\--dict specify the file that contains
+the entire preset dictionary.
+\-h give this help.
+\--strategy specify a special compression strategy.
+\-v print the version and copyright info.
+\--zlib use zlib format instead of raw deflate.
+]]
+
+-- currently no plan to support stdin and stdout.
+-- Because Lua in Windows does not set stdout with binary mode.
+if io and os and debug and _G.arg then
+ local io = io
+ local os = os
+ local debug = debug
+ local arg = _G.arg
+ local debug_info = debug.getinfo(1)
+ if debug_info.source == arg[0]
+ or debug_info.short_src == arg[0] then
+ -- We are indeed runnning THIS file from the commandline.
+ local input
+ local output
+ local i = 1
+ local status
+ local is_zlib = false
+ local is_decompress = false
+ local level
+ local strategy
+ local dictionary
+ while (arg[i]) do
+ local a = arg[i]
+ if a == "-h" then
+ print(LibDeflate._COPYRIGHT
+ .."\nUsage: lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT]\n"
+ .." -0 store only. no compression.\n"
+ .." -1 fastest compression.\n"
+ .." -9 slowest and best compression.\n"
+ .." -d do decompression instead of compression.\n"
+ .." --dict specify the file that contains"
+ .." the entire preset dictionary.\n"
+ .." -h give this help.\n"
+ .." --strategy "
+ .." specify a special compression strategy.\n"
+ .." -v print the version and copyright info.\n"
+ .." --zlib use zlib format instead of raw deflate.\n")
+ os.exit(0)
+ elseif a == "-v" then
+ print(LibDeflate._COPYRIGHT)
+ os.exit(0)
+ elseif a:find("^%-[0-9]$") then
+ level = tonumber(a:sub(2, 2))
+ elseif a == "-d" then
+ is_decompress = true
+ elseif a == "--dict" then
+ i = i + 1
+ local dict_filename = arg[i]
+ if not dict_filename then
+ io.stderr:write("You must speicify the dict filename")
+ os.exit(1)
+ end
+ local dict_file, dict_status = io.open(dict_filename, "rb")
+ if not dict_file then
+ io.stderr:write(
+ ("LibDeflate: Cannot read the dictionary file '%s': %s")
+ :format(dict_filename, dict_status))
+ os.exit(1)
+ end
+ local dict_str = dict_file:read("*all")
+ dict_file:close()
+ -- In your lua program, you should pass in adler32 as a CONSTANT
+ -- , so it actually prevent you from modifying dictionary
+ -- unintentionally during the program development. I do this
+ -- here just because no convenient way to verify in commandline.
+ dictionary = LibDeflate:CreateDictionary(dict_str,
+ #dict_str, LibDeflate:Adler32(dict_str))
+ elseif a == "--strategy" then
+ -- Not sure if I should check error here
+ -- If I do, redudant code.
+ i = i + 1
+ strategy = arg[i]
+ elseif a == "--zlib" then
+ is_zlib = true
+ elseif a:find("^%-") then
+ io.stderr:write(("LibDeflate: Invalid argument: %s")
+ :format(a))
+ os.exit(1)
+ else
+ if not input then
+ input, status = io.open(a, "rb")
+ if not input then
+ io.stderr:write(
+ ("LibDeflate: Cannot read the file '%s': %s")
+ :format(a, tostring(status)))
+ os.exit(1)
+ end
+ elseif not output then
+ output, status = io.open(a, "wb")
+ if not output then
+ io.stderr:write(
+ ("LibDeflate: Cannot write the file '%s': %s")
+ :format(a, tostring(status)))
+ os.exit(1)
+ end
+ end
+ end
+ i = i + 1
+ end -- while (arg[i])
+
+ if not input or not output then
+ io.stderr:write("LibDeflate:"
+ .." You must specify both input and output files.")
+ os.exit(1)
+ end
+
+ local input_data = input:read("*all")
+ local configs = {
+ level = level,
+ strategy = strategy,
+ }
+ local output_data
+ if not is_decompress then
+ if not is_zlib then
+ if not dictionary then
+ output_data =
+ LibDeflate:CompressDeflate(input_data, configs)
+ else
+ output_data =
+ LibDeflate:CompressDeflateWithDict(input_data, dictionary
+ , configs)
+ end
+ else
+ if not dictionary then
+ output_data =
+ LibDeflate:CompressZlib(input_data, configs)
+ else
+ output_data =
+ LibDeflate:CompressZlibWithDict(input_data, dictionary
+ , configs)
+ end
+ end
+ else
+ if not is_zlib then
+ if not dictionary then
+ output_data = LibDeflate:DecompressDeflate(input_data)
+ else
+ output_data = LibDeflate:DecompressDeflateWithDict(
+ input_data, dictionary)
+ end
+ else
+ if not dictionary then
+ output_data = LibDeflate:DecompressZlib(input_data)
+ else
+ output_data = LibDeflate:DecompressZlibWithDict(
+ input_data, dictionary)
+ end
+ end
+ end
+
+ if not output_data then
+ io.stderr:write("LibDeflate: Decompress fails.")
+ os.exit(1)
+ end
+
+ output:write(output_data)
+ if input and input ~= io.stdin then
+ input:close()
+ end
+ if output and output ~= io.stdout then
+ output:close()
+ end
+
+ io.stderr:write(("Successfully writes %d bytes"):format(
+ output_data:len()))
+ os.exit(0)
+ end
+end
+
+return LibDeflate
diff --git a/libs/LibDeflate/LibDeflate.toc b/libs/LibDeflate/LibDeflate.toc
new file mode 100644
index 0000000..7406574
--- /dev/null
+++ b/libs/LibDeflate/LibDeflate.toc
@@ -0,0 +1,12 @@
+## Interface: 80000
+## Title: Lib: LibDeflate
+## Notes: Compressor and decompressor with high compression ratio using DEFLATE/zlib format.
+## Author: Haoqian He (WoW: Safetyy at Illidan-US (Horde))
+## Version: 1.0.0-release
+## X-Website: https://wow.curseforge.com/projects/libdeflate
+## X-Category: Library
+## X-License: GPLv3
+## LoadOnDemand: 1
+
+LibStub\LibStub.lua
+lib.xml
diff --git a/libs/LibDeflate/LibStub/LibStub.lua b/libs/LibDeflate/LibStub/LibStub.lua
new file mode 100644
index 0000000..7e9b5cd
--- /dev/null
+++ b/libs/LibDeflate/LibStub/LibStub.lua
@@ -0,0 +1,51 @@
+-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
+-- LibStub is hereby placed in the Public Domain
+-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
+local LibStub = _G[LIBSTUB_MAJOR]
+
+-- Check to see is this version of the stub is obsolete
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ -- LibStub:NewLibrary(major, minor)
+ -- major (string) - the major version of the library
+ -- minor (string or number ) - the minor version of the library
+ --
+ -- returns nil if a newer or same version of the lib is already present
+ -- returns empty library object or old library object if upgrade is needed
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ -- LibStub:GetLibrary(major, [silent])
+ -- major (string) - the major version of the library
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
+ --
+ -- throws an error if the library can not be found (except silent is set)
+ -- returns the library object if found
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ -- LibStub:IterateLibraries()
+ --
+ -- Returns an iterator for the currently registered libraries
+ function LibStub:IterateLibraries()
+ return pairs(self.libs)
+ end
+
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/libs/LibDeflate/LibStub/LibStub.toc b/libs/LibDeflate/LibStub/LibStub.toc
new file mode 100644
index 0000000..92e164f
--- /dev/null
+++ b/libs/LibDeflate/LibStub/LibStub.toc
@@ -0,0 +1,9 @@
+## Interface: 70000
+## Title: Lib: LibStub
+## Notes: Universal Library Stub
+## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
+## X-Website: http://www.wowace.com/addons/libstub/
+## X-Category: Library
+## X-License: Public Domain
+
+LibStub.lua
diff --git a/libs/LibDeflate/LibStub/tests/test.lua b/libs/LibDeflate/LibStub/tests/test.lua
new file mode 100644
index 0000000..276ddab
--- /dev/null
+++ b/libs/LibDeflate/LibStub/tests/test.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
+assert(lib) -- should return the library table
+assert(not oldMinor) -- should not return the old minor, since it didn't exist
+
+-- the following is to create data and then be able to check if the same data exists after the fact
+function lib:MyMethod()
+end
+local MyMethod = lib.MyMethod
+lib.MyTable = {}
+local MyTable = lib.MyTable
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
+assert(newLib) -- library table
+assert(rawequal(newLib, lib)) -- should be the same reference as the previous
+assert(newOldMinor == 1) -- should return the minor version of the previous version
+
+assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
+assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib) -- library table
+assert(newOldMinor == 2) -- previous version was 2
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib)
+assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
+assert(newLib)
+assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
\ No newline at end of file
diff --git a/libs/LibDeflate/LibStub/tests/test2.lua b/libs/LibDeflate/LibStub/tests/test2.lua
new file mode 100644
index 0000000..eae7172
--- /dev/null
+++ b/libs/LibDeflate/LibStub/tests/test2.lua
@@ -0,0 +1,27 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib doesn't exist yet, by iterating through all the libraries
+ assert(major ~= "MyLib")
+end
+
+assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
+assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
+local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
+assert(lib) -- check it exists
+assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
+
+assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
+
+local count=0
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
+ if major == "MyLib" then -- we found it!
+ count = count +1
+ assert(rawequal(library, lib)) -- verify that the references are equal
+ end
+end
+assert(count == 1) -- verify that we actually found it, and only once
diff --git a/libs/LibDeflate/LibStub/tests/test3.lua b/libs/LibDeflate/LibStub/tests/test3.lua
new file mode 100644
index 0000000..30f7b94
--- /dev/null
+++ b/libs/LibDeflate/LibStub/tests/test3.lua
@@ -0,0 +1,14 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local proxy = newproxy() -- non-string
+
+assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
+local success, ret = pcall(LibStub.GetLibrary, proxy, true)
+assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
+
+assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
+
+assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
\ No newline at end of file
diff --git a/libs/LibDeflate/LibStub/tests/test4.lua b/libs/LibDeflate/LibStub/tests/test4.lua
new file mode 100644
index 0000000..43eb338
--- /dev/null
+++ b/libs/LibDeflate/LibStub/tests/test4.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+
+-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
+assert(LibStub.minor)
+LibStub.minor = LibStub.minor - 0.0001
+LibStub.IterateLibraries = nil
+
+loadfile("../LibStub.lua")()
+
+assert(type(LibStub.IterateLibraries)=="function")
+
+
+-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
+LibStub.IterateLibraries = 123
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
+LibStub.minor = LibStub.minor + 0.0001
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Again with a huge number
+LibStub.minor = LibStub.minor + 1234567890
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+print("OK")
\ No newline at end of file
diff --git a/libs/LibDeflate/README.md b/libs/LibDeflate/README.md
new file mode 100644
index 0000000..53e2d83
--- /dev/null
+++ b/libs/LibDeflate/README.md
@@ -0,0 +1,198 @@
+[![Build Status](https://www.travis-ci.org/SafeteeWoW/LibDeflate.svg?branch=master)](https://www.travis-ci.org/SafeteeWoW/LibDeflate)
+[![Build status](https://ci.appveyor.com/api/projects/status/owdccv4jrc0g1s2x/branch/master?svg=true&passingText=Windows%20Build%20passing&failingText=Windows%20Build%20failing)](https://ci.appveyor.com/project/SafeteeWoW/libdeflate/branch/master)
+[![AppVeyor tests branch](https://img.shields.io/appveyor/tests/SafeteeWoW/LibDeflate/master.svg)](https://ci.appveyor.com/project/SafeteeWoW/libdeflate/branch/master)
+[![codecov.io](http://codecov.io/github/safeteeWoW/LibDeflate/branch/master/graphs/badge.svg)](http://codecov.io/github/safeteeWoW/LibDeflate)
+[![license](https://img.shields.io/github/license/SafeteeWoW/LibDeflate.svg)](LICENSE.txt)
+[![LuaRocks](https://img.shields.io/luarocks/v/SafeteeWoW/libdeflate.svg)](http://luarocks.org/modules/SafeteeWoW/libdeflate)
+[![GitHub issues](https://img.shields.io/github/issues/SafeteeWoW/LibDeflate.svg)](https://github.com/SafeteeWoW/LibDeflate/issues)
+
+# LibDeflate
+## Pure Lua compressor and decompressor with high compression ratio using DEFLATE/zlib format.
+
+Copyright (C) 2018 Haoqian He
+
+## Introduction
+LibDeflate is pure Lua compressor and decompressor with high compression ratio,
+which compresses almost as good as [zlib](https://github.com/madler/zlib). The
+purpose of this project is to give a reasonable good compression when you only
+have access to a pure Lua environment, without accessing to Lua C bindings or
+any external Lua libraries. LibDeflate does not have any dependencies except you
+need to have a working Lua interpreter.
+
+LibDeflate uses the following compression formats:
+1. *DEFLATE*, as defined by the specification
+[RFC1951](https://tools.ietf.org/html/rfc1951). DEFLATE is the default compression method of ZIP.
+2. *zlib*, as defined by the specification
+[RFC1950](https://tools.ietf.org/html/rfc1950).
+zlib format uses DEFLATE formats to compress data and adds several bytes as
+headers and checksum.
+
+A simple C program utilizing [zlib](https://github.com/madler/zlib) should be
+compatible with LibDeflate. If you are not sure how to write this program,
+goto the [zlib](https://github.com/madler/zlib) repository, or read
+[tests/zdeflate.c](https://github.com/SafeteeWoW/LibDeflate/blob/master/tests/zdeflate.c) in this repository.
+
+## Supported Lua Versions
+LibDeflate supports and is fully tested under Lua 5.1/5.2/5.3, LuaJIT 2.0/2.1,
+for Linux, MaxOS and Windows. Click the Travis CI(Linux/MaxOS) and
+Appveyor(Windows) badge on the top of this README for the test results. Click
+the CodeCov badge to see the test coverage (should be 100%).
+
+## Documentation
+[Documentation](https://safeteewow.github.io/LibDeflate/source/LibDeflate.lua.html) is hosted on Github.
+Beside run as a library, LibDeflate can also be run directly in commmandline.
+See the documentation for detail.
+
+## Limitation
+Though many performance optimization has been done in the source code, as a
+pure Lua implementation, the compression speed of LibDeflate is significantly
+slower than a C compressor. LibDeflate aims to compress small files, and it is
+suggested to not compress files with the order of several Megabytes. If you
+need to compress files hundreds of MetaBytes, please use a C compressor, or a
+Lua compressor with C binding.
+
+## Performance
+Below is a simple benchmark compared with another pure Lua compressor [LibCompress](https://www.wowace.com/projects/libcompress).
+More benchmarks can be viewed in the [documentation](https://safeteewow.github.io/LibDeflate/topics/benchmark.md.html).
+
++ Interpreter: Lua 5.1.5
++ Input data: [WeakAuras2 String](https://raw.githubusercontent.com/SafeteeWoW/LibDeflate/master/tests/data/warlockWeakAuras.txt), Size: 132462 bytes
+
+
+
+
+
+
LibDeflate
+
LibDeflate
+
LibDeflate
+
LibCompress
+
LibCompress
+
LibCompress
+
+
+
+
+
+
CompressDeflate Level 1
+
CompressDeflate Level 5
+
CompressDeflate Level 8
+
Compress
+
CompressLZW
+
CompressHuffman
+
+
+
compress ratio
+
3.15
+
3.68
+
3.71
+
1.36
+
1.20
+
1.36
+
+
+
compress time(ms)
+
70
+
120
+
200
+
127
+
58
+
64
+
+
+
decompress time(ms)
+
35
+
32
+
32
+
62
+
36
+
62
+
+
+
compress+decompress time(ms)
+
105
+
152
+
232
+
189
+
94
+
126
+
+
+
+
+
+LibDeflate with compression level 1 compresses as fast as LibCompress, but already produces significantly smaller data than LibCompress. High compression level takes a bit more time to get better compression.
+
+## Download And Install
+
++ The [official repository](https://github.com/SafeteeWoW/LibDeflate) locates on Github.
+[LibDeflate.lua](https://github.com/SafeteeWoW/LibDeflate/blob/master/LibDeflate.lua) is the only file of LibDeflate. Copy the file
+to your LUA_PATH to install it.
+
++ To download as a World of Warcraft library, goto [LibDeflate Curseforge Page](https://wow.curseforge.com/projects/libdeflate)
+
++ You can also install via Luarocks using the command "luarocks install libdeflate"
+
++ To use after installation, ```require("LibDeflate")``` (case sensitive) in your Lua interpreter,
+or ```LibStub:GetLibrary("LibDeflate")``` (case sensitive) for World of Warcraft.
+
+
+## Usage
+```
+local LibDeflate
+if LibStub then -- You are using LibDeflate as WoW addon
+ LibDeflate = LibStub:GetLibrary("LibDeflate")
+else
+ LibDeflate = require("LibDeflate")
+end
+
+local example_input = "12123123412345123456123456712345678123456789"
+
+--- Compress using raw deflate format
+local compress_deflate = LibDeflate:CompressDeflate(example_input)
+
+-- decompress
+local decompress_deflate = LibDeflate:DecompressDeflate(compress_deflate)
+
+-- Check if the first return value of DecompressXXXX is non-nil to know if the
+-- decompression succeeds.
+if decompress_deflate == nil then
+ error("Decompression fails.")
+else
+ -- Decompression succeeds.
+ assert(example_input == decompress_deflate)
+end
+
+
+-- To transmit through WoW addon channel, data must be encoded so NULL ("\000")
+-- is not in the data.
+local data_to_trasmit_WoW_addon = LibDeflate:EncodeForWoWAddonChannel(
+ compress_deflate)
+-- When the receiver gets the data, decoded it first.
+local data_decoded_WoW_addon = LibDeflate:DecodeForWoWAddonChannel(
+ data_to_trasmit_WoW_addon)
+-- Then decomrpess it
+local decompress_deflate = LibDeflate:DecompressDeflate(data_decoded_WoW_addon)
+
+assert(decompress_deflate == example_input)
+
+-- The compressed output is not printable. EncodeForPrint will convert to
+-- a printable format, in case you want to export to the user to
+-- copy and paste. This encoding will make the data 25% bigger.
+local printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
+
+-- DecodeForPrint to convert back.
+-- DecodeForPrint will remove prefixed and trailing control or space characters
+-- in the string before decode it.
+assert(LibDeflate:DecodeForPrint(printable_compressed) == compress_deflate)
+```
+See Full examples in [examples/example.lua](https://github.com/SafeteeWoW/LibDeflate/blob/master/examples/example.lua)
+
+## Credits
+
+1. [zlib](http://www.zlib.net), by Jean-loup Gailly (compression) and Mark Adler (decompression). Licensed under [zlib License](http://www.zlib.net/zlib_license.html).
+2. [puff](https://github.com/madler/zlib/tree/master/contrib/puff), by Mark Adler. Licensed under zlib License.
+3. [LibCompress](https://www.wowace.com/projects/libcompress), by jjsheets and Galmok of European Stormrage (Horde). Licensed under GPLv2.
+4. [WeakAuras2](https://github.com/WeakAuras/WeakAuras2). Licensed under GPLv2.
+
+## License
+LibDeflate is licensed under GNU General Public License Version 3 or later.
\ No newline at end of file
diff --git a/libs/LibDeflate/changelog.md b/libs/LibDeflate/changelog.md
new file mode 100644
index 0000000..6211803
--- /dev/null
+++ b/libs/LibDeflate/changelog.md
@@ -0,0 +1,41 @@
+### v1.0.0-release
+
+* 2018/7/30
+* Documentation updates.
+
+### v0.9.0-beta4
+
+* 2018/5/25
+* "DecodeForPrint" always remove prefixed or trailing control or space characters before decoding. This makes this API easier to use.
+
+### v0.9.0-beta3
+
+* 2018/5/23
+* Fix an issue in "DecodeForPrint" that certain undecodable string
+ could cause an Lua error.
+* Add an parameter to "DecodeForPrint". If set, remove trailing spaces in the
+input string before decode it.
+* Add input type checks for all encode/decode functions.
+
+### v0.9.0-beta2
+
+* 2018/5/22
+* API "Encode6Bit" is renamed to "EncodeForPrint"
+* API "Decode6Bit" is renamed to "DecodeForPrint"
+
+### v0.9.0-beta1
+
+* 2018/5/22
+* No change
+
+### v0.9.0-alpha2
+
+* 2018/5/21
+* Remove API LibDeflate:VerifyDictionary
+* Remove API LibDeflate:DictForWoW
+* Changed API LibDeflate:CreateDictionary
+
+### v0.9.0-alpha1
+
+* 2018/5/20
+* The first working version.
diff --git a/libs/LibDeflate/docs/benchmark.md b/libs/LibDeflate/docs/benchmark.md
new file mode 100644
index 0000000..4684d5d
--- /dev/null
+++ b/libs/LibDeflate/docs/benchmark.md
@@ -0,0 +1,279 @@
+# Performance Benchmark
+
++ Operating System: Windows 10 version 1803
++ Lua Interpreters:
+ + Lua 5.1.5
+ + LuaJIT 2.0.5
++ CPU: Intel Core i7-7700K@4.2 GHz
+
+---
+
++ For LibDeflate, `CompressDeflate` is used for all compressions in this benchmark, `DecompressDeflate` is used for decompression. Different compression level configurations (Level 1, Level 5 and Level 8) are used.
+
++ For LibCompress, `Compress`, `CompressLZW`, `CompressHuffman` are used for
+compression. `Decompress` is used to decompress all compression results.
+`Compress` runs both CompressLZW and CompressHuffman and pick the smallest result.
+
+---
+
++ Interpreter: Lua 5.1.5
++ Input data: [WeakAuras2 String](https://raw.githubusercontent.com/SafeteeWoW/LibDeflate/master/tests/data/warlockWeakAuras.txt), Size: 132462 bytes
+
+
+--- LibDeflate usage example
+-- @author Haoqian He
+-- @file example.lua
+
+local LibDeflate
+
+if LibStub then-- You are using LibDeflate as WoW addon
+ LibDeflate = LibStub:GetLibrary("LibDeflate")
+else
+ -- You are using LibDeflate as Lua library.
+-- Setup the path to locate LibDeflate.lua,
+-- if 'require("LibDeflate")' fails, for example:
+-- package.path = ("?.lua;../?.lua;")..(package.path or "")
+ LibDeflate = require("LibDeflate")
+end
+
+local example_input = "12123123412345123456123456712345678123456789"
+
+-- Compress using raw deflate format
+local compress_deflate = LibDeflate:CompressDeflate(example_input)
+
+-- decompress
+local decompress_deflate = LibDeflate:DecompressDeflate(compress_deflate)
+-- Check if the first return value of DecompressXXXX is non-nil to know if the
+-- decompression succeeds.
+if decompress_deflate == nilthen
+ error("Decompression fails.")
+else
+ -- Decompression succeeds.
+assert(example_input == decompress_deflate)
+end
+
+
+-- If it is to transmit through WoW addon channel,
+-- compressed data must be encoded so NULL ("\000") is not transmitted.
+local data_to_trasmit_WoW_addon = LibDeflate:EncodeForWoWAddonChannel(
+ compress_deflate)
+-- When the receiver gets the data, decoded it first.
+local data_decoded_WoW_addon = LibDeflate:DecodeForWoWAddonChannel(
+ data_to_trasmit_WoW_addon)
+-- Then decomrpess it
+assert(LibDeflate:DecompressDeflate(data_decoded_WoW_addon) == example_input)
+
+-- The compressed output is not printable. EncodeForPrint will convert to
+-- a printable format, in case you want to export to the user to
+-- copy and paste. This encoding will make the data 25% bigger.
+local printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
+
+-- DecodeForPrint to convert back.
+-- DecodeForPrint will remove prefixed and trailing control or space characters
+-- in the string before decode it.
+assert(LibDeflate:DecodeForPrint(printable_compressed) == compress_deflate)
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+--- Compress and decompress using zlib format
+local compress_zlib = LibDeflate:CompressZlib(example_input)
+local decompress_zlib = LibDeflate:DecompressZlib(compress_zlib)
+assert(decompress_zlib == example_input)
+
+--- Control the compression level
+-- NOTE: High compression level does not make a difference here,
+-- because the input data is very small
+local compress_deflate_with_level = LibDeflate:CompressDeflate(example_input
+ , {level = 9})
+local decompress_deflate_with_level = LibDeflate:DecompressDeflate(
+ compress_deflate_with_level)
+assert(decompress_deflate_with_level == example_input)
+
+
+-- Compress with a preset dictionary
+local dict_str = "121231234"-- example preset dictionary string.
+-- print(LibDeflate:Adler32(dict_str), #dict_str)
+-- 9 147325380
+-- hardcode the print result above, the ensure it is not modified
+-- accidenttaly during the program development.
+--
+-- WARNING: The compressor and decompressor must use the same dictionary.
+-- You should be aware of this when tranmitting compressed data over the
+-- internet.
+local dict = LibDeflate:CreateDictionary(dict_str, 9, 147325380)
+
+-- Using the dictionary with raw deflate format
+local compress_deflate_with_dict = LibDeflate:CompressDeflateWithDict(
+ example_input, dict)
+assert(#compress_deflate_with_dict < #compress_deflate)
+local decompress_deflate_with_dict = LibDeflate:DecompressDeflateWithDict(
+ compress_deflate_with_dict, dict)
+assert(decompress_deflate_with_dict == example_input)
+
+-- Using the dictionary with zlib format, specifying compression level
+local compress_zlib_with_dict = LibDeflate:CompressZlibWithDict(
+ example_input, dict, {level = 9})
+assert(#compress_zlib_with_dict < #compress_zlib)
+local decompress_zlib_with_dict = LibDeflate:DecompressZlibWithDict(
+ compress_zlib_with_dict, dict)
+assert(decompress_zlib_with_dict == example_input)
+
+
+
+
+
+generated by LDoc 1.4.6
+Last updated 2018-07-30 02:06:38
+
LibDeflate 1.0.0-release
+Pure Lua compressor and decompressor with high compression ratio using
+DEFLATE/zlib format.
+
+
+
+
Info:
+
+
Copyright: LibDeflate <2018> Haoqian He
+
License: GNU General Public License Version 3 or later
+
+
This library is implemented according to the following specifications.
+Report a bug if LibDeflate is not fully compliant with those specs.
+Both compressors and decompressors have been implemented in the library.
+1. RFC1950: DEFLATE Compressed Data Format Specification version 1.3
+https://tools.ietf.org/html/rfc1951
+2. RFC1951: ZLIB Compressed Data Format Specification version 3.3
+https://tools.ietf.org/html/rfc1950
+
+
This library requires Lua 5.1/5.2/5.3 interpreter or LuaJIT v2.0+.
+This library does not have any dependencies.
+
+This file "LibDeflate.lua" is the only source file of
+the library.
+Submit suggestions or report bugs to
+https://github.com/safeteeWow/LibDeflate/issues
+
Author: Haoqian He (Github: SafeteeWoW; World of Warcraft: Safetyy-Illidan(US))
The description to compression configuration table.
+
+
+
+
+
+
+
+
Functions
+
+
+
+
+ LibDeflate:Adler32 (str)
+
+
+ Calculate the Adler-32 checksum of the string.
+ See RFC1950 Page 9 https://tools.ietf.org/html/rfc1950 for the
+ definition of Adler-32 checksum.
+
+
+
Parameters:
+
+
str
+ [string] the input string to calcuate its Adler-32 checksum.
+
+
+
+
Returns:
+
+
+ [integer] The Adler-32 checksum, which is greater or equal to 0,
+ and less than 2^32 (4294967296).
+
+
+
+
+
+
+
+
+ LibDeflate:CompressDeflate (str, configs)
+
+
+ Compress using the raw deflate format.
+
+
+
Parameters:
+
+
str
+ [string] The data to be compressed.
+
+
configs
+ [table/nil] The configuration table to control the compression
+ . If nil, use the default configuration.
+
+
+
+
Returns:
+
+
+ [string] The compressed data.
+
+ [integer] The number of bits padded at the end of output.
+ 0 <= bits < 8
+ This means the most significant "bits" of the last byte of the returned
+ compressed data are padding bits and they don't affect decompression.
+ You don't need to use this value unless you want to do some postprocessing
+ to the compressed data.
+ Compress using the raw deflate format with a preset dictionary.
+
+
+
Parameters:
+
+
str
+ [string] The data to be compressed.
+
+
dictionary
+ [table] The preset dictionary produced by
+ LibDeflate:CreateDictionary
+
+
configs
+ [table/nil] The configuration table to control the compression
+ . If nil, use the default configuration.
+
+
+
+
Returns:
+
+
+ [string] The compressed data.
+
+ [integer] The number of bits padded at the end of output.
+ 0 <= bits < 8
+ This means the most significant "bits" of the last byte of the returned
+ compressed data are padding bits and they don't affect decompression.
+ You don't need to use this value unless you want to do some postprocessing
+ to the compressed data.
+ Create a custom codec with encoder and decoder.
+ This codec is used to convert an input string to make it not contain
+ some specific bytes.
+ This created codec and the parameters of this function do NOT take
+ localization into account. One byte (0-255) in the string is exactly one
+ character (0-255).
+ Credits to LibCompress.
+
+
+
Parameters:
+
+
reserved_chars
+ [string] The created encoder will ensure encoded
+ data does not contain any single character in reserved_chars. This parameter
+ should be non-empty.
+
+
escape_chars
+ [string] The escape character(s) used in the created
+ codec. The codec converts any character included in reserved_chars /
+ escape_chars / map_chars to (one escape char + one character not in
+ reserved_chars / escape_chars / map_chars).
+ You usually only need to provide a length-1 string for this parameter.
+ Length-2 string is only needed when
+ reserved_chars + escape_chars + map_chars is longer than 127.
+ This parameter should be non-empty.
+
+
map_chars
+ [string] The created encoder will map every
+ reserved_chars:sub(i, i) (1 <= i <= #map_chars) to map_chars:sub(i, i).
+ This parameter CAN be empty string.
+
+
+
+
Returns:
+
+
+ [table/nil] If the codec cannot be created, return nil.
+ If the codec can be created according to the given
+ parameters, return the codec, which is a encode/decode table.
+ The table contains two functions:
+ t:Encode(str) returns the encoded string.
+ t:Decode(str) returns the decoded string if succeeds. nil if fails.
+
+ [nil/string] If the codec is successfully created, return nil.
+ If not, return a string that describes the reason why the codec cannot be
+ created.
+
+
+
+
+
Usage:
+
+
-- Create an encoder/decoder that maps all "\000" to "\003",
+-- and escape "\001" (and "\002" and "\003") properly
+local codec = LibDeflate:CreateCodec("\000\001", "\002", "\003")
+
+local encoded = codec:Encode(SOME_STRING)
+-- "encoded" does not contain "\000" or "\001"
+local decoded = codec:Decode(encoded)
+-- assert(decoded == SOME_STRING)
This function is not fast, and the memory consumption of the produced
+ dictionary is about 50 times of the input string. Therefore, it is suggestted
+ to run this function only once in your program.
+
+
It is very important to know that if you do use a preset dictionary,
+ compressors and decompressors MUST USE THE SAME dictionary. That is,
+ dictionary must be created using the same string. If you update your program
+ with a new dictionary, people with the old version won't be able to transmit
+ data with people with the new version. Therefore, changing the dictionary
+ must be very careful.
+
+
The parameters "strlen" and "adler32" add a layer of verification to ensure
+ the parameter "str" is not modified unintentionally during the program
+ development.
+
+
+
Parameters:
+
+
str
+ [string] The string used as the preset dictionary.
+ You should put stuffs that frequently appears in the dictionary
+ string and preferablely put more frequently appeared stuffs toward the end
+ of the string.
+ Empty string and string longer than 32768 bytes are not allowed.
+
+
strlen
+ [integer] The length of 'str'. Please pass in this parameter
+ as a hardcoded constant, in order to verify the content of 'str'. The value
+ of this parameter should be known before your program runs.
+
+
adler32
+ [integer] The Adler-32 checksum of 'str'. Please pass in this
+ parameter as a hardcoded constant, in order to verify the content of 'str'.
+ The value of this parameter should be known before your program runs.
+
+
+
+
Returns:
+
+
+ [table] The dictionary used for preset dictionary compression and
+ decompression.
+
+
+
Raises:
+ error if 'strlen' does not match the length of 'str',
+ or if 'adler32' does not match the Adler-32 checksum of 'str'.
+
+
+
Usage:
+
+
local dict_str = "1234567890"
+
+-- print(dict_str:len(), LibDeflate:Adler32(dict_str))
+-- Hardcode the print result below to verify it to avoid acciently
+-- modification of 'str' during the program development.
+-- string length: 10, Adler-32: 187433486,
+-- Don't calculate string length and its Adler-32 at run-time.
+
+local dict = LibDeflate:CreateDictionary(dict_str, 10, 187433486)
+
+
+
+
+
+ LibDeflate:DecodeForPrint (str)
+
+
+ Decode the printable string produced by LibDeflate:EncodeForPrint.
+ "str" will have its prefixed and trailing control characters or space
+ removed before it is decoded, so it is easier to use if "str" comes form
+ user copy and paste with some prefixed or trailing spaces.
+ Then decode fails if the string contains any characters cant be produced by
+ LibDeflate:EncodeForPrint. That means, decode fails if the string contains a
+ characters NOT one of 26 lowercase letters, 26 uppercase letters,
+ 10 numbers digits, left parenthese, or right parenthese.
+
+
+
Parameters:
+
+
str
+ [string] The string to be decoded
+
+
+
+
Returns:
+
+
+ [string/nil] The decoded string if succeeds. nil if fails.
+
+
+
+
+
+
+
+
+ LibDeflate:DecodeForWoWAddonChannel (str)
+
+
+ Decode the string produced by LibDeflate:EncodeForWoWAddonChannel
+
+
+
Parameters:
+
+
str
+ [string] The string to be decoded.
+
+
+
+
Returns:
+
+
+ [string/nil] The decoded string if succeeds. nil if fails.
+
+
+
+
+ [string/nil] If the decompression succeeds, return the decompressed
+ data. If the decompression fails, return nil. You should check if this return
+ value is non-nil to know if the decompression succeeds.
+
+ [integer] If the decompression succeeds, return the number of
+ unprocessed bytes in the input compressed data. This return value is a
+ positive integer if the input data is a valid compressed data appended by an
+ arbitary non-empty string. This return value is 0 if the input data does not
+ contain any extra bytes.
+ If the decompression fails (The first return value of this function is nil),
+ this return value is undefined.
+ Decompress a raw deflate compressed data with a preset dictionary.
+
+
+
Parameters:
+
+
str
+ [string] The data to be decompressed.
+
+
dictionary
+ [table] The preset dictionary used by
+ LibDeflate:CompressDeflateWithDict when the compressed data is produced.
+ Decompression and compression must use the same dictionary.
+ Otherwise wrong decompressed data could be produced without generating any
+ error.
+
+
+
+
Returns:
+
+
+ [string/nil] If the decompression succeeds, return the decompressed
+ data. If the decompression fails, return nil. You should check if this return
+ value is non-nil to know if the decompression succeeds.
+
+ [integer] If the decompression succeeds, return the number of
+ unprocessed bytes in the input compressed data. This return value is a
+ positive integer if the input data is a valid compressed data appended by an
+ arbitary non-empty string. This return value is 0 if the input data does not
+ contain any extra bytes.
+ If the decompression fails (The first return value of this function is nil),
+ this return value is undefined.
+ [string/nil] If the decompression succeeds, return the decompressed
+ data. If the decompression fails, return nil. You should check if this return
+ value is non-nil to know if the decompression succeeds.
+
+ [integer] If the decompression succeeds, return the number of
+ unprocessed bytes in the input compressed data. This return value is a
+ positive integer if the input data is a valid compressed data appended by an
+ arbitary non-empty string. This return value is 0 if the input data does not
+ contain any extra bytes.
+ If the decompression fails (The first return value of this function is nil),
+ this return value is undefined.
+ Decompress a zlib compressed data with a preset dictionary.
+
+
+
Parameters:
+
+
str
+ [string] The data to be decompressed
+
+
dictionary
+ [table] The preset dictionary used by
+ LibDeflate:CompressDeflateWithDict when the compressed data is produced.
+ Decompression and compression must use the same dictionary.
+ Otherwise wrong decompressed data could be produced without generating any
+ error.
+
+
+
+
Returns:
+
+
+ [string/nil] If the decompression succeeds, return the decompressed
+ data. If the decompression fails, return nil. You should check if this return
+ value is non-nil to know if the decompression succeeds.
+
+ [integer] If the decompression succeeds, return the number of
+ unprocessed bytes in the input compressed data. This return value is a
+ positive integer if the input data is a valid compressed data appended by an
+ arbitary non-empty string. This return value is 0 if the input data does not
+ contain any extra bytes.
+ If the decompression fails (The first return value of this function is nil),
+ this return value is undefined.
Credis to WeakAuras2, this function is equivalant to the implementation
+ it is using right now.
+ The encoded string will be 25% larger than the origin string. However, every
+ single byte of the encoded string will be one of 64 printable ASCII
+ characters, which are can be easier copied, pasted and displayed.
+ (26 lowercase letters, 26 uppercase letters, 10 numbers digits,
+ left parenthese, or right parenthese)
+
+
+
Parameters:
+
+
str
+ [string] The string to be encoded.
+
+
+
+
Returns:
+
+
+ [string] The encoded string.
+
+
+
+
+
+
+
+
+ LibDeflate:EncodeForWoWAddonChannel (str)
+
+
+ Encode the string to make it ready to be transmitted in World of
+ Warcraft addon channel.
+ The encoded string is guaranteed to contain no NULL ("\000") character.
+
+
+
+ Encode the string to make it ready to be transmitted in World of
+ Warcraft chat channel.
+ See also https://wow.gamepedia.com/ValidChatMessageCharacters
+
+
+
lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT]
+-0 store only. no compression.
+-1 fastest compression.
+-9 slowest and best compression.
+-d do decompression instead of compression.
+--dict <filename> specify the file that contains
+he entire preset dictionary.
+-h give this help.
+--strategy <fixed/huffman_only/dynamic> specify a special compression strategy.
+-v print the version and copyright info.
+--zlib use zlib format instead of raw deflate.
+
+
+
+
+
+ compression_configs
+
+
+ The description to compression configuration table.
+ Any field can be nil to use its default.
+ Table with keys other than those below is an invalid table.
+
+
+
Fields:
+
+
level
+ The compression level ranged from 0 to 9. 0 is no compression.
+ 9 is the slowest but best compression. Use nil for default level.
+
+
strategy
+ The compression strategy. "fixed" to only use fixed deflate
+ compression block. "dynamic" to only use dynamic block. "huffman_only" to
+ do no LZ77 compression. Only do huffman compression.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.6
+Last updated 2018-07-30 02:06:38
+
For LibDeflate, CompressDeflate is used for all compressions in this benchmark, DecompressDeflate is used for decompression. Different compression level configurations (Level 1, Level 5 and Level 8) are used.
+
For LibCompress, Compress, CompressLZW, CompressHuffman are used for
+ compression. Decompress is used to decompress all compression results.
+ Compress runs both CompressLZW and CompressHuffman and pick the smallest result.
Pure Lua compressor and decompressor with high compression ratio using DEFLATE/zlib format.
+
+
Copyright (C) 2018 Haoqian He
+
+
+
Introduction
+
LibDeflate is pure Lua compressor and decompressor with high compression ratio,
+which compresses almost as good as zlib. The
+purpose of this project is to give a reasonable good compression when you only
+have access to a pure Lua environment, without accessing to Lua C bindings or
+any external Lua libraries. LibDeflate does not have any dependencies except you
+need to have a working Lua interpreter.
+
+
LibDeflate uses the following compression formats:
+1. DEFLATE, as defined by the specification
+RFC1951. DEFLATE is the default compression method of ZIP.
+2. zlib, as defined by the specification
+RFC1950.
+zlib format uses DEFLATE formats to compress data and adds several bytes as
+headers and checksum.
+
+
A simple C program utilizing zlib should be
+compatible with LibDeflate. If you are not sure how to write this program,
+goto the zlib repository, or read
+tests/zdeflate.c in this repository.
+
+
+
Supported Lua Versions
+
LibDeflate supports and is fully tested under Lua 5.1/5.2/5.3, LuaJIT 2.0/2.1,
+for Linux, MaxOS and Windows. Click the Travis CI(Linux/MaxOS) and
+Appveyor(Windows) badge on the top of this README for the test results. Click
+the CodeCov badge to see the test coverage (should be 100%).
+
+
+
Documentation
+
Documentation is hosted on Github.
+Beside run as a library, LibDeflate can also be run directly in commmandline.
+See the documentation for detail.
+
+
+
Limitation
+
Though many performance optimization has been done in the source code, as a
+pure Lua implementation, the compression speed of LibDeflate is significantly
+slower than a C compressor. LibDeflate aims to compress small files, and it is
+suggested to not compress files with the order of several Megabytes. If you
+need to compress files hundreds of MetaBytes, please use a C compressor, or a
+Lua compressor with C binding.
+
+
+
Performance
+
Below is a simple benchmark compared with another pure Lua compressor LibCompress.
+More benchmarks can be viewed in the documentation.
LibDeflate with compression level 1 compresses as fast as LibCompress, but already produces significantly smaller data than LibCompress. High compression level takes a bit more time to get better compression.
+
+
+
Download And Install
+
+
+
The official repository locates on Github.
+ LibDeflate.lua is the only file of LibDeflate. Copy the file
+ to your LUA_PATH to install it.
You can also install via Luarocks using the command "luarocks install libdeflate"
+
To use after installation, <code>require("LibDeflate")</code> (case sensitive) in your Lua interpreter,
+ or <code>LibStub:GetLibrary("LibDeflate")</code> (case sensitive) for World of Warcraft.
+
+
+
+
+
Usage
+
local LibDeflate
+ if LibStub then -- You are using LibDeflate as WoW addon
+ LibDeflate = LibStub:GetLibrary("LibDeflate")
+ else
+ LibDeflate = require("LibDeflate")
+ end
+
+ local example_input = "12123123412345123456123456712345678123456789"
+
+ --- Compress using raw deflate format
+ local compress_deflate = LibDeflate:CompressDeflate(example_input)
+
+ -- decompress
+ local decompress_deflate = LibDeflate:DecompressDeflate(compress_deflate)
+
+ -- Check if the first return value of DecompressXXXX is non-nil to know if the
+ -- decompression succeeds.
+ if decompress_deflate == nil then
+ error("Decompression fails.")
+ else
+ -- Decompression succeeds.
+ assert(example_input == decompress_deflate)
+ end
+
+
+ -- To transmit through WoW addon channel, data must be encoded so NULL ("\000")
+ -- is not in the data.
+ local data_to_trasmit_WoW_addon = LibDeflate:EncodeForWoWAddonChannel(
+ compress_deflate)
+ -- When the receiver gets the data, decoded it first.
+ local data_decoded_WoW_addon = LibDeflate:DecodeForWoWAddonChannel(
+ data_to_trasmit_WoW_addon)
+ -- Then decomrpess it
+ local decompress_deflate = LibDeflate:DecompressDeflate(data_decoded_WoW_addon)
+
+ assert(decompress_deflate == example_input)
+
+ -- The compressed output is not printable. EncodeForPrint will convert to
+ -- a printable format, in case you want to export to the user to
+ -- copy and paste. This encoding will make the data 25% bigger.
+ local printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
+
+ -- DecodeForPrint to convert back.
+ -- DecodeForPrint will remove prefixed and trailing control or space characters
+ -- in the string before decode it.
+ assert(LibDeflate:DecodeForPrint(printable_compressed) == compress_deflate)
+
LibDeflate is licensed under GNU General Public License Version 3 or later.
+
+
+
+
+generated by LDoc 1.4.6
+Last updated 2018-07-30 02:06:38
+
+
+
+
diff --git a/libs/LibDeflate/examples/example.lua b/libs/LibDeflate/examples/example.lua
new file mode 100644
index 0000000..ff9604f
--- /dev/null
+++ b/libs/LibDeflate/examples/example.lua
@@ -0,0 +1,100 @@
+--- LibDeflate usage example
+-- @author Haoqian He
+-- @file example.lua
+
+local LibDeflate
+
+if LibStub then -- You are using LibDeflate as WoW addon
+ LibDeflate = LibStub:GetLibrary("LibDeflate")
+else
+ -- You are using LibDeflate as Lua library.
+ -- Setup the path to locate LibDeflate.lua,
+ -- if 'require("LibDeflate")' fails, for example:
+ -- package.path = ("?.lua;../?.lua;")..(package.path or "")
+ LibDeflate = require("LibDeflate")
+end
+
+local example_input = "12123123412345123456123456712345678123456789"
+
+-- Compress using raw deflate format
+local compress_deflate = LibDeflate:CompressDeflate(example_input)
+
+-- decompress
+local decompress_deflate = LibDeflate:DecompressDeflate(compress_deflate)
+-- Check if the first return value of DecompressXXXX is non-nil to know if the
+-- decompression succeeds.
+if decompress_deflate == nil then
+ error("Decompression fails.")
+else
+ -- Decompression succeeds.
+ assert(example_input == decompress_deflate)
+end
+
+
+-- If it is to transmit through WoW addon channel,
+-- compressed data must be encoded so NULL ("\000") is not transmitted.
+local data_to_trasmit_WoW_addon = LibDeflate:EncodeForWoWAddonChannel(
+ compress_deflate)
+-- When the receiver gets the data, decoded it first.
+local data_decoded_WoW_addon = LibDeflate:DecodeForWoWAddonChannel(
+ data_to_trasmit_WoW_addon)
+-- Then decomrpess it
+assert(LibDeflate:DecompressDeflate(data_decoded_WoW_addon) == example_input)
+
+-- The compressed output is not printable. EncodeForPrint will convert to
+-- a printable format, in case you want to export to the user to
+-- copy and paste. This encoding will make the data 25% bigger.
+local printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
+
+-- DecodeForPrint to convert back.
+-- DecodeForPrint will remove prefixed and trailing control or space characters
+-- in the string before decode it.
+assert(LibDeflate:DecodeForPrint(printable_compressed) == compress_deflate)
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+--- Compress and decompress using zlib format
+local compress_zlib = LibDeflate:CompressZlib(example_input)
+local decompress_zlib = LibDeflate:DecompressZlib(compress_zlib)
+assert(decompress_zlib == example_input)
+
+--- Control the compression level
+-- NOTE: High compression level does not make a difference here,
+-- because the input data is very small
+local compress_deflate_with_level = LibDeflate:CompressDeflate(example_input
+ , {level = 9})
+local decompress_deflate_with_level = LibDeflate:DecompressDeflate(
+ compress_deflate_with_level)
+assert(decompress_deflate_with_level == example_input)
+
+
+-- Compress with a preset dictionary
+local dict_str = "121231234" -- example preset dictionary string.
+-- print(LibDeflate:Adler32(dict_str), #dict_str)
+-- 9 147325380
+-- hardcode the print result above, the ensure it is not modified
+-- accidenttaly during the program development.
+--
+-- WARNING: The compressor and decompressor must use the same dictionary.
+-- You should be aware of this when tranmitting compressed data over the
+-- internet.
+local dict = LibDeflate:CreateDictionary(dict_str, 9, 147325380)
+
+-- Using the dictionary with raw deflate format
+local compress_deflate_with_dict = LibDeflate:CompressDeflateWithDict(
+ example_input, dict)
+assert(#compress_deflate_with_dict < #compress_deflate)
+local decompress_deflate_with_dict = LibDeflate:DecompressDeflateWithDict(
+ compress_deflate_with_dict, dict)
+assert(decompress_deflate_with_dict == example_input)
+
+-- Using the dictionary with zlib format, specifying compression level
+local compress_zlib_with_dict = LibDeflate:CompressZlibWithDict(
+ example_input, dict, {level = 9})
+assert(#compress_zlib_with_dict < #compress_zlib)
+local decompress_zlib_with_dict = LibDeflate:DecompressZlibWithDict(
+ compress_zlib_with_dict, dict)
+assert(decompress_zlib_with_dict == example_input)
diff --git a/libs/LibDeflate/lib.xml b/libs/LibDeflate/lib.xml
new file mode 100644
index 0000000..0c5cc49
--- /dev/null
+++ b/libs/LibDeflate/lib.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua b/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua
new file mode 100644
index 0000000..ce5ff14
--- /dev/null
+++ b/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua
@@ -0,0 +1,292 @@
+--[[
+Name: LibSharedMedia-3.0
+Revision: $Revision: 91 $
+Author: Elkano (elkano@gmx.de)
+Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com)
+Website: http://www.wowace.com/projects/libsharedmedia-3-0/
+Description: Shared handling of media data (fonts, sounds, textures, ...) between addons.
+Dependencies: LibStub, CallbackHandler-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR, MINOR = "LibSharedMedia-3.0", 6010002 -- 6.1.0 v2 / increase manually on changes
+local lib = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not lib then return end
+
+local _G = getfenv(0)
+
+local pairs = _G.pairs
+local type = _G.type
+
+local band = _G.bit.band
+
+local table_insert = _G.table.insert
+local table_sort = _G.table.sort
+
+local locale = GetLocale()
+local locale_is_western
+local LOCALE_MASK = 0
+lib.LOCALE_BIT_koKR = 1
+lib.LOCALE_BIT_ruRU = 2
+lib.LOCALE_BIT_zhCN = 4
+lib.LOCALE_BIT_zhTW = 8
+lib.LOCALE_BIT_western = 128
+
+local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
+
+lib.callbacks = lib.callbacks or CallbackHandler:New(lib)
+
+lib.DefaultMedia = lib.DefaultMedia or {}
+lib.MediaList = lib.MediaList or {}
+lib.MediaTable = lib.MediaTable or {}
+lib.MediaType = lib.MediaType or {}
+lib.OverrideMedia = lib.OverrideMedia or {}
+
+local defaultMedia = lib.DefaultMedia
+local mediaList = lib.MediaList
+local mediaTable = lib.MediaTable
+local overrideMedia = lib.OverrideMedia
+
+
+-- create mediatype constants
+lib.MediaType.BACKGROUND = "background" -- background textures
+lib.MediaType.BORDER = "border" -- border textures
+lib.MediaType.FONT = "font" -- fonts
+lib.MediaType.STATUSBAR = "statusbar" -- statusbar textures
+lib.MediaType.SOUND = "sound" -- sound files
+
+-- populate lib with default Blizzard data
+-- BACKGROUND
+if not lib.MediaTable.background then lib.MediaTable.background = {} end
+lib.MediaTable.background["None"] = [[]]
+lib.MediaTable.background["Blizzard Collections Background"] = [[Interface\Collections\CollectionsBackgroundTile]]
+lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]]
+lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
+lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]
+lib.MediaTable.background["Blizzard Garrison Background"] = [[Interface\Garrison\GarrisonUIBackground]]
+lib.MediaTable.background["Blizzard Garrison Background 2"] = [[Interface\Garrison\GarrisonUIBackground2]]
+lib.MediaTable.background["Blizzard Garrison Background 3"] = [[Interface\Garrison\GarrisonMissionUIInfoBoxBackgroundTile]]
+lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
+lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]]
+lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
+lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
+lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]]
+lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]]
+lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
+lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
+lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
+lib.DefaultMedia.background = "None"
+
+-- BORDER
+if not lib.MediaTable.border then lib.MediaTable.border = {} end
+lib.MediaTable.border["None"] = [[]]
+lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]]
+lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]]
+lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
+lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]]
+lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]]
+lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]]
+lib.DefaultMedia.border = "None"
+
+-- FONT
+if not lib.MediaTable.font then lib.MediaTable.font = {} end
+local SML_MT_font = lib.MediaTable.font
+--[[
+All font files are currently in all clients, the following table depicts which font supports which charset as of 5.0.4
+Fonts were checked using langcover.pl from DejaVu fonts (http://sourceforge.net/projects/dejavu/) and FontForge (http://fontforge.org/)
+latin means check for: de, en, es, fr, it, pt
+
+file name latin koKR ruRU zhCN zhTW
+2002.ttf 2002 X X X - -
+2002B.ttf 2002 Bold X X X - -
+ARHei.ttf AR CrystalzcuheiGBK Demibold X - X X X
+ARIALN.TTF Arial Narrow X - X - -
+ARKai_C.ttf AR ZhongkaiGBK Medium (Combat) X - X X X
+ARKai_T.ttf AR ZhongkaiGBK Medium X - X X X
+bHEI00M.ttf AR Heiti2 Medium B5 - - - - X
+bHEI01B.ttf AR Heiti2 Bold B5 - - - - X
+bKAI00M.ttf AR Kaiti Medium B5 - - - - X
+bLEI00D.ttf AR Leisu Demi B5 - - - - X
+FRIZQT__.TTF Friz Quadrata TT X - - - -
+FRIZQT___CYR.TTF FrizQuadrataCTT x - X - -
+K_Damage.TTF YDIWingsM - X X - -
+K_Pagetext.TTF MoK X X X - -
+MORPHEUS.TTF Morpheus X - - - -
+MORPHEUS_CYR.TTF Morpheus X - X - -
+NIM_____.ttf Nimrod MT X - X - -
+SKURRI.TTF Skurri X - - - -
+SKURRI_CYR.TTF Skurri X - X - -
+
+WARNING: Although FRIZQT___CYR is available on western clients, it doesn't support special European characters e.g. é, ï, ö
+Due to this, we cannot use it as a replacement for FRIZQT__.TTF
+]]
+
+if locale == "koKR" then
+ LOCALE_MASK = lib.LOCALE_BIT_koKR
+--
+ SML_MT_font["굵은 글꼴"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["기본 글꼴"] = [[Fonts\2002.TTF]]
+ SML_MT_font["데미지 글꼴"] = [[Fonts\K_Damage.TTF]]
+ SML_MT_font["퀘스트 글꼴"] = [[Fonts\K_Pagetext.TTF]]
+--
+ lib.DefaultMedia["font"] = "기본 글꼴" -- someone from koKR please adjust if needed
+--
+elseif locale == "zhCN" then
+ LOCALE_MASK = lib.LOCALE_BIT_zhCN
+--
+ SML_MT_font["伤害数字"] = [[Fonts\ARKai_C.ttf]]
+ SML_MT_font["默认"] = [[Fonts\ARKai_T.ttf]]
+ SML_MT_font["聊天"] = [[Fonts\ARHei.ttf]]
+--
+ lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed
+--
+elseif locale == "zhTW" then
+ LOCALE_MASK = lib.LOCALE_BIT_zhTW
+--
+ SML_MT_font["提示訊息"] = [[Fonts\bHEI00M.ttf]]
+ SML_MT_font["聊天"] = [[Fonts\bHEI01B.ttf]]
+ SML_MT_font["傷害數字"] = [[Fonts\bKAI00M.ttf]]
+ SML_MT_font["預設"] = [[Fonts\bLEI00D.ttf]]
+--
+ lib.DefaultMedia["font"] = "預設" -- someone from zhTW please adjust if needed
+
+elseif locale == "ruRU" then
+ LOCALE_MASK = lib.LOCALE_BIT_ruRU
+--
+ SML_MT_font["2002"] = [[Fonts\2002.TTF]]
+ SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
+ SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
+ SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT___CYR.TTF]]
+ SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
+ SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
+ SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
+ SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
+--
+ lib.DefaultMedia.font = "Friz Quadrata TT"
+--
+else
+ LOCALE_MASK = lib.LOCALE_BIT_western
+ locale_is_western = true
+--
+ SML_MT_font["2002"] = [[Fonts\2002.TTF]]
+ SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
+ SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
+ SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
+ SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
+ SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
+ SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
+ SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
+--
+ lib.DefaultMedia.font = "Friz Quadrata TT"
+--
+end
+
+-- STATUSBAR
+if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end
+lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]]
+lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]]
+lib.MediaTable.statusbar["Blizzard Raid Bar"] = [[Interface\RaidFrame\Raid-Bar-Hp-Fill]]
+lib.DefaultMedia.statusbar = "Blizzard"
+
+-- SOUND
+if not lib.MediaTable.sound then lib.MediaTable.sound = {} end
+lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input.
+lib.DefaultMedia.sound = "None"
+
+local function rebuildMediaList(mediatype)
+ local mtable = mediaTable[mediatype]
+ if not mtable then return end
+ if not mediaList[mediatype] then mediaList[mediatype] = {} end
+ local mlist = mediaList[mediatype]
+ -- list can only get larger, so simply overwrite it
+ local i = 0
+ for k in pairs(mtable) do
+ i = i + 1
+ mlist[i] = k
+ end
+ table_sort(mlist)
+end
+
+function lib:Register(mediatype, key, data, langmask)
+ if type(mediatype) ~= "string" then
+ error(MAJOR..":Register(mediatype, key, data, langmask) - mediatype must be string, got "..type(mediatype))
+ end
+ if type(key) ~= "string" then
+ error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key))
+ end
+ mediatype = mediatype:lower()
+ if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then return false end
+ if mediatype == lib.MediaType.SOUND and type(data) == "string" then
+ local path = data:lower()
+ -- Only ogg and mp3 are valid sounds.
+ if not path:find(".ogg", nil, true) and not path:find(".mp3", nil, true) then
+ return false
+ end
+ end
+ if not mediaTable[mediatype] then mediaTable[mediatype] = {} end
+ local mtable = mediaTable[mediatype]
+ if mtable[key] then return false end
+
+ mtable[key] = data
+ rebuildMediaList(mediatype)
+ self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key)
+ return true
+end
+
+function lib:Fetch(mediatype, key, noDefault)
+ local mtt = mediaTable[mediatype]
+ local overridekey = overrideMedia[mediatype]
+ local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
+ return result ~= "" and result or nil
+end
+
+function lib:IsValid(mediatype, key)
+ return mediaTable[mediatype] and (not key or mediaTable[mediatype][key]) and true or false
+end
+
+function lib:HashTable(mediatype)
+ return mediaTable[mediatype]
+end
+
+function lib:List(mediatype)
+ if not mediaTable[mediatype] then
+ return nil
+ end
+ if not mediaList[mediatype] then
+ rebuildMediaList(mediatype)
+ end
+ return mediaList[mediatype]
+end
+
+function lib:GetGlobal(mediatype)
+ return overrideMedia[mediatype]
+end
+
+function lib:SetGlobal(mediatype, key)
+ if not mediaTable[mediatype] then
+ return false
+ end
+ overrideMedia[mediatype] = (key and mediaTable[mediatype][key]) and key or nil
+ self.callbacks:Fire("LibSharedMedia_SetGlobal", mediatype, overrideMedia[mediatype])
+ return true
+end
+
+function lib:GetDefault(mediatype)
+ return defaultMedia[mediatype]
+end
+
+function lib:SetDefault(mediatype, key)
+ if mediaTable[mediatype] and mediaTable[mediatype][key] and not defaultMedia[mediatype] then
+ defaultMedia[mediatype] = key
+ return true
+ else
+ return false
+ end
+end
diff --git a/libs/LibSharedMedia-3.0/lib.xml b/libs/LibSharedMedia-3.0/lib.xml
new file mode 100644
index 0000000..7f2fd53
--- /dev/null
+++ b/libs/LibSharedMedia-3.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/libs/LibStub/LibStub.lua b/libs/LibStub/LibStub.lua
new file mode 100644
index 0000000..0a41ac0
--- /dev/null
+++ b/libs/LibStub/LibStub.lua
@@ -0,0 +1,30 @@
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
+-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
+local LibStub = _G[LIBSTUB_MAJOR]
+
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ function LibStub:IterateLibraries() return pairs(self.libs) end
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/libs/LibStub/LibStub.toc b/libs/LibStub/LibStub.toc
new file mode 100644
index 0000000..b963a95
--- /dev/null
+++ b/libs/LibStub/LibStub.toc
@@ -0,0 +1,13 @@
+## Interface: 40200
+## Title: Lib: LibStub
+## Notes: Universal Library Stub
+## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
+## X-Website: http://www.wowace.com/addons/libstub/
+## X-Category: Library
+## X-License: Public Domain
+## X-Curse-Packaged-Version: r95
+## X-Curse-Project-Name: LibStub
+## X-Curse-Project-ID: libstub
+## X-Curse-Repository-ID: wow/libstub/mainline
+
+LibStub.lua
diff --git a/libs/LibStub/tests/test.lua b/libs/LibStub/tests/test.lua
new file mode 100644
index 0000000..276ddab
--- /dev/null
+++ b/libs/LibStub/tests/test.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
+assert(lib) -- should return the library table
+assert(not oldMinor) -- should not return the old minor, since it didn't exist
+
+-- the following is to create data and then be able to check if the same data exists after the fact
+function lib:MyMethod()
+end
+local MyMethod = lib.MyMethod
+lib.MyTable = {}
+local MyTable = lib.MyTable
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
+assert(newLib) -- library table
+assert(rawequal(newLib, lib)) -- should be the same reference as the previous
+assert(newOldMinor == 1) -- should return the minor version of the previous version
+
+assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
+assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib) -- library table
+assert(newOldMinor == 2) -- previous version was 2
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib)
+assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
+assert(newLib)
+assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
\ No newline at end of file
diff --git a/libs/LibStub/tests/test2.lua b/libs/LibStub/tests/test2.lua
new file mode 100644
index 0000000..eae7172
--- /dev/null
+++ b/libs/LibStub/tests/test2.lua
@@ -0,0 +1,27 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib doesn't exist yet, by iterating through all the libraries
+ assert(major ~= "MyLib")
+end
+
+assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
+assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
+local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
+assert(lib) -- check it exists
+assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
+
+assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
+
+local count=0
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
+ if major == "MyLib" then -- we found it!
+ count = count +1
+ assert(rawequal(library, lib)) -- verify that the references are equal
+ end
+end
+assert(count == 1) -- verify that we actually found it, and only once
diff --git a/libs/LibStub/tests/test3.lua b/libs/LibStub/tests/test3.lua
new file mode 100644
index 0000000..30f7b94
--- /dev/null
+++ b/libs/LibStub/tests/test3.lua
@@ -0,0 +1,14 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local proxy = newproxy() -- non-string
+
+assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
+local success, ret = pcall(LibStub.GetLibrary, proxy, true)
+assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
+
+assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
+
+assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
\ No newline at end of file
diff --git a/libs/LibStub/tests/test4.lua b/libs/LibStub/tests/test4.lua
new file mode 100644
index 0000000..43eb338
--- /dev/null
+++ b/libs/LibStub/tests/test4.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+
+-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
+assert(LibStub.minor)
+LibStub.minor = LibStub.minor - 0.0001
+LibStub.IterateLibraries = nil
+
+loadfile("../LibStub.lua")()
+
+assert(type(LibStub.IterateLibraries)=="function")
+
+
+-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
+LibStub.IterateLibraries = 123
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
+LibStub.minor = LibStub.minor + 0.0001
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Again with a huge number
+LibStub.minor = LibStub.minor + 1234567890
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+print("OK")
\ No newline at end of file
diff --git a/libs/libs.xml b/libs/libs.xml
new file mode 100644
index 0000000..fb4acd4
--- /dev/null
+++ b/libs/libs.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/locales/deDE.lua b/locales/deDE.lua
new file mode 100644
index 0000000..574b142
--- /dev/null
+++ b/locales/deDE.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "deDE")
+if not L then return end
+
+@localization(locale="deDE", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/enUS.lua b/locales/enUS.lua
new file mode 100644
index 0000000..4a5199f
--- /dev/null
+++ b/locales/enUS.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale ("FlashTaskbarLocales", "enUS", true)
+if not L then return end
+
+@localization(locale="enUS", format="lua_additive_table")@
diff --git a/locales/esES.lua b/locales/esES.lua
new file mode 100644
index 0000000..6e3618e
--- /dev/null
+++ b/locales/esES.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "esES")
+if not L then return end
+
+@localization(locale="esES", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/esMX.lua b/locales/esMX.lua
new file mode 100644
index 0000000..d427bca
--- /dev/null
+++ b/locales/esMX.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "esMX")
+if not L then return end
+
+@localization(locale="esMX", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/frFR.lua b/locales/frFR.lua
new file mode 100644
index 0000000..ed42142
--- /dev/null
+++ b/locales/frFR.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "frFR")
+if not L then return end
+
+@localization(locale="frFR", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/itIT.lua b/locales/itIT.lua
new file mode 100644
index 0000000..92731f4
--- /dev/null
+++ b/locales/itIT.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "itIT")
+if not L then return end
+
+@localization(locale="itIT", format="lua_additive_table")@
diff --git a/locales/koKR.lua b/locales/koKR.lua
new file mode 100644
index 0000000..96980e9
--- /dev/null
+++ b/locales/koKR.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "koKR")
+if not L then return end
+
+@localization(locale="koKR", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/ptBR.lua b/locales/ptBR.lua
new file mode 100644
index 0000000..61e9dba
--- /dev/null
+++ b/locales/ptBR.lua
@@ -0,0 +1,7 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "ptBR")
+if not L then return end
+
+@localization(locale="ptBR", format="lua_additive_table")@
+
+
+
diff --git a/locales/ruRU.lua b/locales/ruRU.lua
new file mode 100644
index 0000000..e131a03
--- /dev/null
+++ b/locales/ruRU.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "ruRU")
+if not L then return end
+
+@localization(locale="ruRU", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/zhCN.lua b/locales/zhCN.lua
new file mode 100644
index 0000000..54951a1
--- /dev/null
+++ b/locales/zhCN.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "zhCN")
+if not L then return end
+
+@localization(locale="zhCN", format="lua_additive_table")@
\ No newline at end of file
diff --git a/locales/zhTW.lua b/locales/zhTW.lua
new file mode 100644
index 0000000..7137161
--- /dev/null
+++ b/locales/zhTW.lua
@@ -0,0 +1,4 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("FlashTaskbarLocales", "zhTW")
+if not L then return end
+
+@localization(locale="zhTW", format="lua_additive_table")@
\ No newline at end of file
diff --git a/sounds/sound_whip1.ogg b/sounds/sound_whip1.ogg
new file mode 100644
index 0000000..09d7e61
Binary files /dev/null and b/sounds/sound_whip1.ogg differ