diff --git a/Details.toc b/Details.toc index 5cd1c28fa..db41e7ea9 100644 --- a/Details.toc +++ b/Details.toc @@ -28,9 +28,10 @@ locales\Details-zhTW.lua boot.lua indent.lua core\util.lua +functions\mixin.lua API.lua -functions\events.lua +functions\events.lua functions\private.lua functions\profiles.lua functions\hooks.lua diff --git a/Details_Wrath.toc b/Details_Wrath.toc index 0f6e1db86..36f29ba6e 100644 --- a/Details_Wrath.toc +++ b/Details_Wrath.toc @@ -24,6 +24,7 @@ locales\Details-zhTW.lua boot.lua indent.lua core\util.lua +functions\mixin.lua API.lua functions\private.lua diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index f5565b9fb..6bc3dcaf3 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -4174,6 +4174,10 @@ function DF:QuickDispatch(func, ...) return true end +---call a function in safe mode with payload +---@param func function +---@param ... any +---@return any function DF:Dispatch(func, ...) if (type(func) ~= "function") then return dispatch_error (_, "DF:Dispatch expect a function as parameter 1.") @@ -4183,7 +4187,7 @@ function DF:Dispatch(func, ...) local okay = dispatchResult[1] if (not okay) then - return nil + return false end tremove(dispatchResult, 1) diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index 4c1906197..f30199e03 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -8593,7 +8593,7 @@ detailsFramework.CastFrameFunctions = { self.value = self.empowered and (GetTime() - self.spellStartTime) or (self.spellEndTime - GetTime()) self.maxValue = self.spellEndTime - self.spellStartTime - if (self.value < 0 or self.value >= self.maxValue) then + if (self.value < 0 or self.value > self.maxValue) then self.value = 0 end diff --git a/Libs/DF/spells.lua b/Libs/DF/spells.lua index ffc29edbe..00b758a35 100644 --- a/Libs/DF/spells.lua +++ b/Libs/DF/spells.lua @@ -944,6 +944,7 @@ DF.CrowdControlSpells = { [122] = "MAGE", --Frost Nova [157997] = "MAGE", --Ice Nova [31661] = "MAGE", --Dragon's Breath + [157981] = "MAGE", --Blast Wave [205364] = "PRIEST", --Mind Control (talent) [605] = "PRIEST", --Mind Control diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index e57e3969a..f6c8b684f 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -64,8 +64,7 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t end local major = "LibOpenRaid-1.0" ---local CONST_LIB_VERSION = 87 -local CONST_LIB_VERSION = 92 --this is a rollback version, due to some zero hour bug issues +local CONST_LIB_VERSION = 93 if (not LIB_OPEN_RAID_MAX_VERSION) then LIB_OPEN_RAID_MAX_VERSION = CONST_LIB_VERSION @@ -98,6 +97,11 @@ local unpack = table.unpack or _G.unpack local CONST_CVAR_TEMPCACHE = "LibOpenRaidTempCache" local CONST_CVAR_TEMPCACHE_DEBUG = "LibOpenRaidTempCacheDebug" + --delay to request all data from other players + local CONST_REQUEST_ALL_DATA_COOLDOWN = 30 + --delay to send all data to other players + local CONST_SEND_ALL_DATA_COOLDOWN = 30 + --show failures (when the function return an error) results to chat local CONST_DIAGNOSTIC_ERRORS = false --show the data to be sent and data received from comm @@ -764,7 +768,7 @@ end openRaidLib.internalCallback.TriggerEvent("talentUpdate") end local delayedTalentChange = function() - openRaidLib.Schedules.NewUniqueTimer(0.5 + math.random(), talentChangedCallback, "TalentChangeEventGroup", "talentChangedCallback_Schedule") + openRaidLib.Schedules.NewUniqueTimer(math.random(3, 6), talentChangedCallback, "TalentChangeEventGroup", "talentChangedCallback_Schedule") end local eventFunctions = { @@ -789,7 +793,7 @@ end --the group has changed, trigger a long timer to send full data --as the timer is unique, a new change to the group will replace and refresh the time --using random time, players won't trigger all at the same time - local randomTime = 0.3 + math.random(0, 0.7) + local randomTime = 5 + math.random() + math.random(1, 5) openRaidLib.Schedules.NewUniqueTimer(randomTime, openRaidLib.mainControl.SendFullData, "mainControl", "sendFullData_Schedule") end @@ -1124,12 +1128,14 @@ end --send a request to all players in the group to send their data function openRaidLib.RequestAllData() + --the the player isn't in group, don't send the request if (not IsInGroup()) then return end openRaidLib.requestAllInfoCooldown = openRaidLib.requestAllInfoCooldown or 0 + --check if the player can sent another request if (openRaidLib.requestAllInfoCooldown > GetTime()) then return end @@ -1137,22 +1143,30 @@ end openRaidLib.commHandler.SendCommData(CONST_COMM_FULLINFO_PREFIX) diagnosticComm("RequestAllInfo| " .. CONST_COMM_FULLINFO_PREFIX) --debug - openRaidLib.requestAllInfoCooldown = GetTime() + 5 + openRaidLib.requestAllInfoCooldown = GetTime() + CONST_REQUEST_ALL_DATA_COOLDOWN return true end + --this function handles the request from another player to send all data + function openRaidLib.commHandler.SendFullData() + openRaidLib.mainControl.SendFullData() + end + openRaidLib.commHandler.RegisterComm(CONST_COMM_FULLINFO_PREFIX, function(data, sourceName) openRaidLib.sendRequestedAllInfoCooldown = openRaidLib.sendRequestedAllInfoCooldown or 0 - --some player in the group requested all information from all players + --check if there's some delay before sending the data if (openRaidLib.sendRequestedAllInfoCooldown > GetTime()) then + --reschedule the function call + openRaidLib.Schedules.NewUniqueTimer(openRaidLib.sendRequestedAllInfoCooldown - GetTime(), openRaidLib.commHandler.SendFullData, "CommHandler", "sendFullData_Schedule") return end - openRaidLib.Schedules.NewUniqueTimer(random() + math.random(0, 3), openRaidLib.mainControl.SendFullData, "mainControl", "sendFullData_Schedule") - openRaidLib.sendRequestedAllInfoCooldown = GetTime() + 5 - end) + openRaidLib.Schedules.NewUniqueTimer(math.random(1, 6), openRaidLib.commHandler.SendFullData, "CommHandler", "sendFullData_Schedule") + --set the delay for the next request + openRaidLib.sendRequestedAllInfoCooldown = GetTime() + CONST_SEND_ALL_DATA_COOLDOWN + end) -------------------------------------------------------------------------------------------------------------------------------- --~player general ~info ~unit diff --git a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua index f5ccd2aa1..96b17ac5e 100644 --- a/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua +++ b/Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua @@ -191,6 +191,17 @@ do [371339] = {tier = {[562] = 3, [476] = 1, [519] = 2}}, --Phial of Elemental Chaos } + LIB_OPEN_RAID_ALL_POTIONS = { + [370511] = 1, --Refreshing Healing Potion + [371039] = 1, --Potion of Withering Vitality + [370607] = 1, --Aerated Mana Potion + [371024] = 1, --Elemental Potion of Power + [371028] = 1, --Elemental Potion of Ultimate Power + [371033] = 1, --Potion of Frozen Focus + [371125] = 1, --Potion of the Hushed Zephyr + [371052] = 1, --Potion of Chilled Clarity + } + --spellId of healing from potions LIB_OPEN_RAID_HEALING_POTIONS = { [370511] = 1, --Refreshing Healing Potion diff --git a/Libs/LibOpenRaid/ThingsToMantain_Wrath.lua b/Libs/LibOpenRaid/ThingsToMantain_Wrath.lua index a0eb48632..b8e2ebbaa 100644 --- a/Libs/LibOpenRaid/ThingsToMantain_Wrath.lua +++ b/Libs/LibOpenRaid/ThingsToMantain_Wrath.lua @@ -122,6 +122,8 @@ LIB_OPEN_RAID_FOOD_BUFF = {} LIB_OPEN_RAID_FLASK_BUFF = {} +LIB_OPEN_RAID_ALL_POTIONS = {} + LIB_OPEN_RAID_MELEE_SPECS = { [251] = "DEATHKNIGHT", [252] = "DEATHKNIGHT", diff --git a/boot.lua b/boot.lua index 3498084a4..06c941894 100644 --- a/boot.lua +++ b/boot.lua @@ -7,8 +7,8 @@ local addonName, Details222 = ... local version, build, date, tocversion = GetBuildInfo() - _detalhes.build_counter = 10406 - _detalhes.alpha_build_counter = 10406 --if this is higher than the regular counter, use it instead + _detalhes.build_counter = 10407 + _detalhes.alpha_build_counter = 10407 --if this is higher than the regular counter, use it instead _detalhes.dont_open_news = true _detalhes.game_version = version _detalhes.userversion = version .. " " .. _detalhes.build_counter @@ -75,6 +75,7 @@ Details222.EJCache = {} Details222.Segments = {} Details222.Tables = {} + Details222.Mixins = {} ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --initialization stuff @@ -1117,4 +1118,6 @@ function Details222.Tables.MakeWeakTable(mode) local newTable = {} setmetatable(newTable, {__mode = mode or "v"}) return newTable -end \ No newline at end of file +end + +--STRING_CUSTOM_POT_DEFAULT \ No newline at end of file diff --git a/classes/class_custom.lua b/classes/class_custom.lua index eb7e03bf4..006193e4c 100644 --- a/classes/class_custom.lua +++ b/classes/class_custom.lua @@ -47,31 +47,31 @@ return combatContainers [attribute] end - function classCustom:RefreshWindow (instance, combat, force, export) + function classCustom:RefreshWindow(instanceObject, combatObject, force, export) --get the custom object - local custom_object = instance:GetCustomObject() + local customObject = instanceObject:GetCustomObject() - if (not custom_object) then - return instance:ResetAttribute() + if (not customObject) then + return instanceObject:ResetAttribute() end --save the custom name in the instance - instance.customName = custom_object:GetName() + instanceObject.customName = customObject.name --get the container holding the custom actor objects for this instance - local instance_container = classCustom:GetInstanceCustomActorContainer (instance) + local instance_container = classCustom:GetInstanceCustomActorContainer (instanceObject) - local last_shown = classCustom._InstanceLastCustomShown [instance:GetId()] - if (last_shown and last_shown ~= custom_object:GetName()) then + local last_shown = classCustom._InstanceLastCustomShown [instanceObject:GetId()] + if (last_shown and last_shown ~= customObject:GetName()) then instance_container:WipeCustomActorContainer() end - classCustom._InstanceLastCustomShown [instance:GetId()] = custom_object:GetName() + classCustom._InstanceLastCustomShown [instanceObject:GetId()] = customObject:GetName() - local last_combat_shown = classCustom._InstanceLastCombatShown [instance:GetId()] - if (last_combat_shown and last_combat_shown ~= combat) then + local last_combat_shown = classCustom._InstanceLastCombatShown [instanceObject:GetId()] + if (last_combat_shown and last_combat_shown ~= combatObject) then instance_container:WipeCustomActorContainer() end - classCustom._InstanceLastCombatShown [instance:GetId()] = combat + classCustom._InstanceLastCombatShown [instanceObject:GetId()] = combatObject --declare the main locals local total = 0 @@ -79,65 +79,69 @@ local amount = 0 --check if is a custom script (if has .script) - if (custom_object:IsScripted()) then - + if (customObject:IsScripted()) then --be save reseting the values on every refresh instance_container:ResetCustomActorContainer() local func + local scriptTypeName = "search" - if (_detalhes.custom_function_cache [instance.customName]) then - func = _detalhes.custom_function_cache [instance.customName] + if (_detalhes.custom_function_cache [instanceObject.customName]) then + func = _detalhes.custom_function_cache [instanceObject.customName] else local errortext - func, errortext = loadstring (custom_object.script) + func, errortext = loadstring (customObject.script) if (func) then DetailsFramework:SetEnvironment(func) - _detalhes.custom_function_cache [instance.customName] = func + _detalhes.custom_function_cache [instanceObject.customName] = func else - _detalhes:Msg("|cFFFF9900error compiling code for custom display " .. (instance.customName or "") .. " |r:", errortext) + _detalhes:Msg("|cFFFF9900error compiling code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext) end - if (custom_object.tooltip) then - local tooltip_script, errortext = loadstring (custom_object.tooltip) + if (customObject.tooltip) then + local tooltip_script, errortext = loadstring (customObject.tooltip) if (tooltip_script) then DetailsFramework:SetEnvironment(tooltip_script) - _detalhes.custom_function_cache [instance.customName .. "Tooltip"] = tooltip_script + _detalhes.custom_function_cache [instanceObject.customName .. "Tooltip"] = tooltip_script else - _detalhes:Msg("|cFFFF9900error compiling tooltip code for custom display " .. (instance.customName or "") .. " |r:", errortext) + _detalhes:Msg("|cFFFF9900error compiling tooltip code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext) end + scriptTypeName = "tooltip" end - if (custom_object.total_script) then - local total_script, errortext = loadstring (custom_object.total_script) + if (customObject.total_script) then + local total_script, errortext = loadstring (customObject.total_script) if (total_script) then DetailsFramework:SetEnvironment(total_script) - _detalhes.custom_function_cache [instance.customName .. "Total"] = total_script + _detalhes.custom_function_cache [instanceObject.customName .. "Total"] = total_script else - _detalhes:Msg("|cFFFF9900error compiling total code for custom display " .. (instance.customName or "") .. " |r:", errortext) + _detalhes:Msg("|cFFFF9900error compiling total code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext) end + scriptTypeName = "total" end - if (custom_object.percent_script) then - local percent_script, errortext = loadstring (custom_object.percent_script) + if (customObject.percent_script) then + local percent_script, errortext = loadstring (customObject.percent_script) if (percent_script) then DetailsFramework:SetEnvironment(percent_script) - _detalhes.custom_function_cache [instance.customName .. "Percent"] = percent_script + _detalhes.custom_function_cache [instanceObject.customName .. "Percent"] = percent_script else - _detalhes:Msg("|cFFFF9900error compiling percent code for custom display " .. (instance.customName or "") .. " |r:", errortext) + _detalhes:Msg("|cFFFF9900error compiling percent code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext) end + scriptTypeName = "percent" end end if (not func) then _detalhes:Msg(Loc ["STRING_CUSTOM_FUNC_INVALID"], func) - _detalhes:EndRefresh (instance, 0, combat, combat [1]) + _detalhes:EndRefresh (instanceObject, 0, combatObject, combatObject [1]) end - local okey, _total, _top, _amount = pcall (func, combat, instance_container, instance) + local okey, _total, _top, _amount = pcall (func, combatObject, instance_container, instanceObject) if (not okey) then - _detalhes:Msg("|cFFFF9900error on custom display function|r:", _total) - return _detalhes:EndRefresh (instance, 0, combat, combat [1]) + local errorText = _total + _detalhes:Msg("|cFFFF9900error on display " .. customObject:GetName() .. " (" .. scriptTypeName .. ")|r:", errorText) + return _detalhes:EndRefresh(instanceObject, 0, combatObject, combatObject[1]) end total = _total or 0 @@ -146,20 +150,20 @@ else --does not have a .script --get the attribute - local attribute = custom_object:GetAttribute() --"damagedone" + local attribute = customObject:GetAttribute() --"damagedone" --get the custom function(actor, source, target, spellid) local func = classCustom [attribute] --get the combat container local container_index = self:GetCombatContainerIndex (attribute) - local combat_container = combat [container_index]._ActorTable + local combat_container = combatObject [container_index]._ActorTable --build container - total, top, amount = classCustom:BuildActorList (func, custom_object.source, custom_object.target, custom_object.spellid, combat, combat_container, container_index, instance_container, instance, custom_object) + total, top, amount = classCustom:BuildActorList (func, customObject.source, customObject.target, customObject.spellid, combatObject, combat_container, container_index, instance_container, instanceObject, customObject) end - if (custom_object:IsSpellTarget()) then + if (customObject:IsSpellTarget()) then amount = classCustom._TargetActorsProcessedAmt total = classCustom._TargetActorsProcessedTotal top = classCustom._TargetActorsProcessedTop @@ -167,21 +171,21 @@ if (amount == 0) then if (force) then - if (instance:IsGroupMode()) then - for i = 1, instance.rows_fit_in_window do - Details.FadeHandler.Fader(instance.barras [i], "in", Details.fade_speed) + if (instanceObject:IsGroupMode()) then + for i = 1, instanceObject.rows_fit_in_window do + Details.FadeHandler.Fader(instanceObject.barras [i], "in", Details.fade_speed) end end end - instance:EsconderScrollBar() - return _detalhes:EndRefresh (instance, total, combat, nil) + instanceObject:EsconderScrollBar() + return _detalhes:EndRefresh (instanceObject, total, combatObject, nil) end if (amount > #instance_container._ActorTable) then amount = #instance_container._ActorTable end - combat.totals [custom_object:GetName()] = total + combatObject.totals [customObject:GetName()] = total instance_container:Sort() instance_container:Remap() @@ -189,10 +193,10 @@ if (export) then -- key name value need to be formated - if (custom_object) then + if (customObject) then - local percent_script = _detalhes.custom_function_cache [instance.customName .. "Percent"] - local total_script = _detalhes.custom_function_cache [instance.customName .. "Total"] + local percent_script = _detalhes.custom_function_cache [instanceObject.customName .. "Percent"] + local total_script = _detalhes.custom_function_cache [instanceObject.customName .. "Total"] local okey for index, actor in ipairs(instance_container._ActorTable) do @@ -200,20 +204,20 @@ local percent, ptotal if (percent_script) then - okey, percent = pcall (percent_script, floor(actor.value), top, total, combat, instance, actor) + okey, percent = pcall (percent_script, floor(actor.value), top, total, combatObject, instanceObject, actor) if (not okey) then _detalhes:Msg("|cFFFF9900percent script error|r:", percent) - return _detalhes:EndRefresh (instance, 0, combat, combat [1]) + return _detalhes:EndRefresh (instanceObject, 0, combatObject, combatObject [1]) end else percent = format ("%.1f", floor(actor.value) / total * 100) end if (total_script) then - local okey, value = pcall (total_script, floor(actor.value), top, total, combat, instance, actor) + local okey, value = pcall (total_script, floor(actor.value), top, total, combatObject, instanceObject, actor) if (not okey) then _detalhes:Msg("|cFFFF9900total script error|r:", value) - return _detalhes:EndRefresh (instance, 0, combat, combat [1]) + return _detalhes:EndRefresh (instanceObject, 0, combatObject, combatObject [1]) end if (type(value) == "number") then @@ -244,11 +248,11 @@ return total, instance_container._ActorTable, top, amount, "report_name" end - instance:RefreshScrollBar (amount) + instanceObject:RefreshScrollBar (amount) - classCustom:Refresh (instance, instance_container, combat, force, total, top, custom_object) + classCustom:Refresh (instanceObject, instance_container, combatObject, force, total, top, customObject) - return _detalhes:EndRefresh (instance, total, combat, combat [container_index]) + return _detalhes:EndRefresh (instanceObject, total, combatObject, combatObject [container_index]) end @@ -915,44 +919,29 @@ end end - function classCustom:ToolTip (instance, bar_number, row_object, keydown) + function classCustom:ToolTip (instanceObject, barNumber, rowObject, keydown) --get the custom object - local custom_object = instance:GetCustomObject() + local customObject = instanceObject:GetCustomObject() - if (custom_object.notooltip) then + if (customObject.notooltip) then return end --get the actor - local actor = self.my_actor + local actorObject = self.my_actor - local r, g, b - if (actor.id) then - local school_color = _detalhes.school_colors [actor.classe] - if (not school_color) then - school_color = _detalhes.school_colors ["unknown"] - end - r, g, b = unpack(school_color) + if (actorObject.id) then + _detalhes:AddTooltipSpellHeaderText (select(1, _GetSpellInfo(actorObject.id)), "yellow", 1, select(3, _GetSpellInfo(actorObject.id)), 0.90625, 0.109375, 0.15625, 0.875, false, 18) else - r, g, b = actor:GetClassColor() + _detalhes:AddTooltipSpellHeaderText (customObject:GetName(), "yellow", 1, customObject:GetIcon(), 0.90625, 0.109375, 0.15625, 0.875, false, 18) end - if (actor.id) then - _detalhes:AddTooltipSpellHeaderText (select(1, _GetSpellInfo(actor.id)), "yellow", 1, select(3, _GetSpellInfo(actor.id)), 0.90625, 0.109375, 0.15625, 0.875) - else - _detalhes:AddTooltipSpellHeaderText (custom_object:GetName(), "yellow", 1, custom_object:GetIcon(), 0.90625, 0.109375, 0.15625, 0.875) - end - - --GameCooltip:AddStatusBar (100, 1, r, g, b, 1) _detalhes:AddTooltipHeaderStatusbar (1, 1, 1, 0.6) - if (custom_object:IsScripted()) then - if (custom_object.tooltip) then - local func = _detalhes.custom_function_cache [instance.customName .. "Tooltip"] - if (func) then - - end - local okey, errortext = pcall (func, actor, instance.showing, instance, keydown) + if (customObject:IsScripted()) then + if (customObject.tooltip) then + local func = _detalhes.custom_function_cache [instanceObject.customName .. "Tooltip"] + local okey, errortext = pcall(func, actorObject, instanceObject.showing, instanceObject, keydown) if (not okey) then _detalhes:Msg("|cFFFF9900error on custom display tooltip function|r:", errortext) return false @@ -960,14 +949,14 @@ end else --get the attribute - local attribute = custom_object:GetAttribute() + local attribute = customObject:GetAttribute() local container_index = classCustom:GetCombatContainerIndex (attribute) --get the tooltip function local func = classCustom [attribute .. "Tooltip"] --build the tooltip - func (_, actor, custom_object.target, custom_object.spellid, instance.showing, instance) + func (_, actorObject, customObject.target, customObject.spellid, instanceObject.showing, instanceObject) end return true @@ -1169,113 +1158,109 @@ end function _detalhes:AddDefaultCustomDisplays() - local PotionUsed = { name = Loc ["STRING_CUSTOM_POT_DEFAULT"], icon = [[Interface\ICONS\INV_Potion_03]], attribute = false, spellid = false, - author = "Details!", + author = "Terciob", desc = Loc ["STRING_CUSTOM_POT_DEFAULT_DESC"], source = false, target = false, - script_version = 6, + script_version = 8, + import_string = "1EvBVnkoq4FlxKwDWDjCn6Q0kfD7kL(YwruUMOLK7JaoGPX3rSrgZwLV4F73yJ5LMxjPDfBBzHXZZZmEMhg7p0FHVxoRGhH9x57HkeRzCFVhWcejn)x89YWWROIG8iojt47LYIqPYWFGslW9LHcwM(3cuk83i2MvibCdHMlq0iSm8lYqhhh5e5e9s0pydsS2jjLX4w6hAREnhlk4uzyVEYWbdYfCc9fNeghm2Q3NCgM0RVb2)qd3Vn8MBSvohwYN6P8GCIVxmopY3ZBn7vz4RRzkMid3cXNmKJiXYWICm8BKmmJjim4LXfkKGyynqomnIvqfyUJVNgLpG4UkW2pQljV6Fg2tIyu)Nh(N3(5H367rrBW(EZn8CjqCyRkdNMsIv7vce)fSqD3oCSKnZw9V4ifNIkYfSn3ZOWwkfZBXYstA4Qz9vrvzmI2OYiAJUPV5hfBhmaq3K22qYJalJemUcEds1omLKlMLSuqsjITJvwLR9xBIo6jSq)QPGXwp84IXUt9cgVyX3DVB5Ihd(BxV7TlXnMzGfYLzJKtsuOg03qGQGsTXtYqeEU1bWhs(GBMidlVgmGrt3cffPOTaX1l(foRiRXesIm0QfcJCZFszXC9sSST1KI2SGQltsy13G8yC1Uje9jO0C8(MV)tANP17)a3XRksacvKjiBWVjNFe4lxXsT911cAE0oMGnbpfc1wy1RCH9S33Z6mYb97rZfnHuv7hdCscdQrbFfHO)Qq3IcScEqghBSd2CZzQkxrEtfjrDF6ROTWFhECSmjaniTs)hK41jG6kWVn7(LEbZNTWD2ZbUpyFCC0PJwOC2Kq1LUFtZjZD)(jJNQR9kOe8c85xMMMqRTm8Vay6mjBiBMgSoqqmn(8gnyakoUzpvu1BB6ep763rDB0444)rPU2UvTVoqNCr88WKVl9MxAN5v2xEYUYRPNulJQJb34(vFFCo71k9WsT0PU3fmB(Jph89XUpemE6utVH3okQNPBuJZc0Q0YpvEYwrdNS7yTDJRV4IBd5kNr4lTzPdSBq(bogTr0D3PPJzGdA9ShFf(a6fZStPvOD7f7PRu(4eX4x1QdxDOTRcZ1fwDs05891)SLTUszmvoXU7EVtjJtA07rBSujQvz2zlnAnRz1Th(BHVHb6)t5tGPdlh3EuZC3hCCw942ibCkJvfc9rFemwQGKvpf9Bt87mt9XMGUEK33POENfX)5iA)HksFPIYVtr4par32H)ZWHW6xE8IYqmYixwf5U0e2f8jQNqQ0NUut1KpfYIwTbQJD474gfRSQ5NAEhZpMdY7yQUDsb8cwJjVSwC632boywTc)fLo4ou0)Po2engoDQOiFfcoy07rCPQ12x47))d", script = [[ - --init: - local combat, instance_container, instance = ... + local combatObject, customContainer, instanceObject = ... local total, top, amount = 0, 0, 0 - + --get the misc actor container - local misc_container = combat:GetActorList ( DETAILS_ATTRIBUTE_MISC ) - + local listOfUtilityActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_MISC) + --do the loop: - for _, player in ipairs( misc_container ) do - + for _, actorObject in ipairs(listOfUtilityActors) do --only player in group - if (player:IsGroupPlayer()) then - - local found_potion = false - + if (actorObject:IsGroupPlayer()) then + local bFoundPotion = false + --get the spell debuff uptime container - local debuff_uptime_container = player.debuff_uptime and player.debuff_uptime_spells and player.debuff_uptime_spells._ActorTable - if (debuff_uptime_container) then + local debuffUptimeContainer = actorObject:GetSpellContainer("debuff") + if (debuffUptimeContainer) then --potion of focus (can't use as pre-potion, so, its amount is always 1 - local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID] - - if (focus_potion) then + local focusPotion = debuffUptimeContainer:GetSpell(DETAILS_FOCUS_POTION_ID) + if (focusPotion) then total = total + 1 - found_potion = true + bFoundPotion = true if (top < 1) then top = 1 end --add amount to the player - instance_container:AddValue (player, 1) + customContainer:AddValue(actorObject, 1) end end - + --get the spell buff uptime container - local buff_uptime_container = player.buff_uptime and player.buff_uptime_spells and player.buff_uptime_spells._ActorTable - if (buff_uptime_container) then - for spellId, _ in pairs(DetailsFramework.PotionIDs) do - local potionUsed = buff_uptime_container [spellId] - - if (potionUsed) then - local used = potionUsed.activedamt + local buffUptimeContainer = actorObject:GetSpellContainer("buff") + if (buffUptimeContainer) then + for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do + local spellTable = buffUptimeContainer:GetSpell(spellId) + if (spellTable) then + local used = spellTable.activedamt if (used and used > 0) then total = total + used - found_potion = true + bFoundPotion = true if (used > top) then top = used end - + --add amount to the player - instance_container:AddValue (player, used) + customContainer:AddValue(actorObject, used) end end end end - - if (found_potion) then + + if (bFoundPotion) then amount = amount + 1 end end end - + --return: return total, top, amount ]], tooltip = [[ - --init: - local player, combat, instance = ... - - --get the debuff container for potion of focus - local debuff_uptime_container = player.debuff_uptime and player.debuff_uptime_spells and player.debuff_uptime_spells._ActorTable - if (debuff_uptime_container) then - local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID] - if (focus_potion) then - local name, _, icon = GetSpellInfo(DETAILS_FOCUS_POTION_ID) - GameCooltip:AddLine(name, 1) --can use only 1 focus potion (can't be pre-potion) - _detalhes:AddTooltipBackgroundStatusbar() - GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) - end - end - - --get the misc actor container - local buff_uptime_container = player.buff_uptime and player.buff_uptime_spells and player.buff_uptime_spells._ActorTable - if (buff_uptime_container) then - for spellId, _ in pairs(DetailsFramework.PotionIDs) do - local potionUsed = buff_uptime_container [spellId] - - if (potionUsed) then - local name, _, icon = GetSpellInfo(spellId) - GameCooltip:AddLine(name, potionUsed.activedamt) - _detalhes:AddTooltipBackgroundStatusbar() - GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) + local actorObject, combatObject, instanceObject = ... + + local iconSize = 20 + + local buffUptimeContainer = actorObject:GetSpellContainer("buff") + if (buffUptimeContainer) then + for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do + local spellTable = buffUptimeContainer:GetSpell(spellId) + if (spellTable) then + local used = spellTable.activedamt + if (used and used > 0) then + local spellName, _, spellIcon = GetSpellInfo(spellId) + GameCooltip:AddLine(spellName, used) + GameCooltip:AddIcon(spellIcon, 1, 1, iconSize, iconSize) + Details:AddTooltipBackgroundStatusbar() + end + end end end - end - ]] + ]], + + total_script = [[ + local value, top, total, combat, instance = ... + return math.floor(value) .. " " + ]], + + percent_script = [[ + local value, top, total, combat, instance = ... + value = math.floor(value) + return "" + ]], } local have = false @@ -1304,82 +1289,65 @@ icon = [[Interface\ICONS\INV_Stone_04]], attribute = false, spellid = false, - author = "Details! Team", + author = "Terciob", desc = Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT_DESC"], source = false, target = false, script = [[ - --get the parameters passed - local combat, instance_container, instance = ... - --declade the values to return - local total, top, amount = 0, 0, 0 - - --do the loop - local AllHealCharacters = combat:GetActorList (DETAILS_ATTRIBUTE_HEAL) - for index, character in ipairs(AllHealCharacters) do - local AllSpells = character:GetSpellList() - local found = false - for spellid, spell in pairs(AllSpells) do - if (DETAILS_HEALTH_POTION_LIST [spellid]) then - instance_container:AddValue (character, spell.total) - total = total + spell.total - if (top < spell.total) then - top = spell.total + local combatObject, instanceContainer, instanceObject = ... + local total, top, amount = 0, 0, 0 + + local listOfHealingActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_HEAL) + for _, actorObject in ipairs(listOfHealingActors) do + local listOfSpells = actorObject:GetSpellList() + local found = false + + for spellId, spellTable in pairs(listOfSpells) do + if (LIB_OPEN_RAID_HEALING_POTIONS[spellId]) then + instanceContainer:AddValue(actorObject, spellTable.total) + total = total + spellTable.total + if (top < spellTable.total) then + top = spellTable.total + end + found = true end - found = true + end + + if (found) then + amount = amount + 1 end end - - if (found) then - amount = amount + 1 - end - end - --loop end - --return the values - return total, top, amount + + return total, top, amount ]], - tooltip = [[ - --get the parameters passed - local actor, combat, instance = ... - --get the cooltip object (we dont use the convencional GameTooltip here) - local GameCooltip = GameCooltip - local R, G, B, A = 0, 0, 0, 0.75 - - local hs = actor:GetSpell (6262) - if (hs) then - GameCooltip:AddLine(select(1, GetSpellInfo(6262)), _detalhes:ToK(hs.total)) - GameCooltip:AddIcon (select(3, GetSpellInfo(6262)), 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) - GameCooltip:AddStatusBar (100, 1, R, G, B, A) - end - - local pot = actor:GetSpell (DETAILS_HEALTH_POTION_ID) - if (pot) then - GameCooltip:AddLine(select(1, GetSpellInfo(DETAILS_HEALTH_POTION_ID)), _detalhes:ToK(pot.total)) - GameCooltip:AddIcon (select(3, GetSpellInfo(DETAILS_HEALTH_POTION_ID)), 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) - GameCooltip:AddStatusBar (100, 1, R, G, B, A) - end - - local pot = actor:GetSpell (DETAILS_HEALTH_POTION2_ID) - if (pot) then - GameCooltip:AddLine(select(1, GetSpellInfo(DETAILS_HEALTH_POTION2_ID)), _detalhes:ToK(pot.total)) - GameCooltip:AddIcon (select(3, GetSpellInfo(DETAILS_HEALTH_POTION2_ID)), 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) - GameCooltip:AddStatusBar (100, 1, R, G, B, A) - end - - local pot = actor:GetSpell (DETAILS_REJU_POTION_ID) - if (pot) then - GameCooltip:AddLine(select(1, GetSpellInfo(DETAILS_REJU_POTION_ID)), _detalhes:ToK(pot.total)) - GameCooltip:AddIcon (select(3, GetSpellInfo(DETAILS_REJU_POTION_ID)), 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height) - GameCooltip:AddStatusBar (100, 1, R, G, B, A) + tooltip = [[ + local actorObject, combatObject, instanceObject = ... + local spellContainer = actorObject:GetSpellContainer("spell") + + local iconSize = 20 + + local allHealingPotions = {6262} + for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do + allHealingPotions[#allHealingPotions+1] = spellId + end + + for i = 1, #allHealingPotions do + local spellId = allHealingPotions[i] + local spellTable = spellContainer:GetSpell(spellId) + if (spellTable) then + local spellName, _, spellIcon = GetSpellInfo(spellId) + GameCooltip:AddLine(spellName, Details:ToK(spellTable.total)) + GameCooltip:AddIcon(spellIcon, 1, 1, iconSize, iconSize) + GameCooltip:AddStatusBar (100, 1, 0, 0, 0, 0.75) + end end - - --Cooltip code ]], percent_script = false, total_script = false, - script_version = 16, + script_version = 18, } + -- /run _detalhes:AddDefaultCustomDisplays() local have = false for _, custom in ipairs(self.custom) do diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 618833537..22a6d75a8 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -12,6 +12,7 @@ local Translit = LibStub("LibTranslit-1.0") local gump = Details.gump local _ = nil + local detailsFramework = DetailsFramework local addonName, Details222 = ... ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -490,6 +491,7 @@ end } setmetatable(newDamageActor, atributo_damage) + detailsFramework:Mixin(newDamageActor, Details222.Mixins.ActorMixin) return newDamageActor end @@ -6287,6 +6289,7 @@ end function Details.refresh:r_atributo_damage (este_jogador, shadow) --restaura metas do ator + detailsFramework:Mixin(este_jogador, Details222.Mixins.ActorMixin) setmetatable(este_jogador, Details.atributo_damage) este_jogador.__index = Details.atributo_damage --restaura as metas dos containers diff --git a/classes/class_heal.lua b/classes/class_heal.lua index 0354c3b5d..848d84233 100644 --- a/classes/class_heal.lua +++ b/classes/class_heal.lua @@ -28,6 +28,8 @@ local IsInGroup = IsInGroup local _string_replace = _detalhes.string.replace --details api local gump = _detalhes.gump +local detailsFramework = DetailsFramework + local alvo_da_habilidade = _detalhes.alvo_da_habilidade local container_habilidades = _detalhes.container_habilidades local container_combatentes = _detalhes.container_combatentes @@ -65,12 +67,10 @@ local info = _detalhes.playerDetailWindow local keyName function atributo_heal:NovaTabela (serial, nome, link) - local alphabetical = _detalhes:GetOrderNumber(nome) --constructor - local _new_healActor = { - + local thisActor = { tipo = class_type, --atributo 2 = cura total = alphabetical, @@ -108,9 +108,10 @@ function atributo_heal:NovaTabela (serial, nome, link) targets_absorbs = {} } - setmetatable(_new_healActor, atributo_heal) + detailsFramework:Mixin(thisActor, Details222.Mixins.ActorMixin) + setmetatable(thisActor, atributo_heal) - return _new_healActor + return thisActor end @@ -2385,26 +2386,26 @@ function atributo_heal:MontaDetalhesHealingDone (spellid, barra) data[3] = t3 - local level1AverageDamage = "0" - local level2AverageDamage = "0" - local level3AverageDamage = "0" - local level4AverageDamage = "0" - local level5AverageDamage = "0" + local level1AverageHeal = "0" + local level2AverageHeal = "0" + local level3AverageHeal = "0" + local level4AverageHeal = "0" + local level5AverageHeal = "0" if (empowerHealPerLevel[1]) then - level1AverageDamage = Details:ToK(empowerHealPerLevel[1] / empowerAmountPerLevel[1]) + level1AverageHeal = Details:ToK(empowerHealPerLevel[1] / empowerAmountPerLevel[1]) end if (empowerHealPerLevel[2]) then - level2AverageDamage = Details:ToK(empowerHealPerLevel[2] / empowerAmountPerLevel[2]) + level2AverageHeal = Details:ToK(empowerHealPerLevel[2] / empowerAmountPerLevel[2]) end if (empowerHealPerLevel[3]) then - level3AverageDamage = Details:ToK(empowerHealPerLevel[3] / empowerAmountPerLevel[3]) + level3AverageHeal = Details:ToK(empowerHealPerLevel[3] / empowerAmountPerLevel[3]) end if (empowerHealPerLevel[4]) then - level4AverageDamage = Details:ToK(empowerHealPerLevel[4] / empowerAmountPerLevel[4]) + level4AverageHeal = Details:ToK(empowerHealPerLevel[4] / empowerAmountPerLevel[4]) end if (empowerHealPerLevel[5]) then - level5AverageDamage = Details:ToK(empowerHealPerLevel[5] / empowerAmountPerLevel[5]) + level5AverageHeal = Details:ToK(empowerHealPerLevel[5] / empowerAmountPerLevel[5]) end t3[1] = 0 @@ -2416,24 +2417,24 @@ function atributo_heal:MontaDetalhesHealingDone (spellid, barra) t3[10] = "" t3[11] = "" - if (level1AverageDamage ~= "0") then - t3[4] = "Level 1 Average: " .. level1AverageDamage .. " (" .. (empowerAmountPerLevel[1] or 0) .. ")" + if (level1AverageHeal ~= "0") then + t3[4] = "Level 1 Average: " .. level1AverageHeal .. " (" .. (empowerAmountPerLevel[1] or 0) .. ")" end - if (level2AverageDamage ~= "0") then - t3[6] = "Level 2 Average: " .. level2AverageDamage .. " (" .. (empowerAmountPerLevel[2] or 0) .. ")" + if (level2AverageHeal ~= "0") then + t3[6] = "Level 2 Average: " .. level2AverageHeal .. " (" .. (empowerAmountPerLevel[2] or 0) .. ")" end - if (level3AverageDamage ~= "0") then - t3[11] = "Level 3 Average: " .. level3AverageDamage .. " (" .. (empowerAmountPerLevel[3] or 0) .. ")" + if (level3AverageHeal ~= "0") then + t3[11] = "Level 3 Average: " .. level3AverageHeal .. " (" .. (empowerAmountPerLevel[3] or 0) .. ")" end - if (level4AverageDamage ~= "0") then - t3[10] = "Level 4 Average: " .. level4AverageDamage .. " (" .. (empowerAmountPerLevel[4] or 0) .. ")" + if (level4AverageHeal ~= "0") then + t3[10] = "Level 4 Average: " .. level4AverageHeal .. " (" .. (empowerAmountPerLevel[4] or 0) .. ")" end - if (level5AverageDamage ~= "0") then - t3[5] = "Level 5 Average: " .. level5AverageDamage .. " (" .. (empowerAmountPerLevel[5] or 0) .. ")" + if (level5AverageHeal ~= "0") then + t3[5] = "Level 5 Average: " .. level5AverageHeal .. " (" .. (empowerAmountPerLevel[5] or 0) .. ")" end end @@ -2983,11 +2984,12 @@ atributo_heal.__sub = function(tabela1, tabela2) return tabela1 end -function _detalhes.refresh:r_atributo_heal (este_jogador, shadow) - setmetatable(este_jogador, atributo_heal) - este_jogador.__index = atributo_heal +function _detalhes.refresh:r_atributo_heal(thisActor, shadow) + setmetatable(thisActor, atributo_heal) + thisActor.__index = atributo_heal + detailsFramework:Mixin(thisActor, Details222.Mixins.ActorMixin) - _detalhes.refresh:r_container_habilidades (este_jogador.spells, shadow and shadow.spells) + _detalhes.refresh:r_container_habilidades(thisActor.spells, shadow and shadow.spells) end function _detalhes.clear:c_atributo_heal (este_jogador) diff --git a/classes/class_resources.lua b/classes/class_resources.lua index e13b2d11b..1fa0ed9ad 100644 --- a/classes/class_resources.lua +++ b/classes/class_resources.lua @@ -22,6 +22,7 @@ local AceLocale = LibStub("AceLocale-3.0") local Loc = AceLocale:GetLocale ( "Details" ) local _ local addonName, Details222 = ... +local detailsFramework = DetailsFramework local gump = _detalhes.gump @@ -84,6 +85,7 @@ function atributo_energy:NovaTabela (serial, nome, link) spells = container_habilidades:NovoContainer (container_energy), } + detailsFramework:Mixin(_new_energyActor, Details222.Mixins.ActorMixin) setmetatable(_new_energyActor, atributo_energy) return _new_energyActor @@ -1520,6 +1522,7 @@ function atributo_energy:ColetarLixo (lastevent) end function _detalhes.refresh:r_atributo_energy (este_jogador, shadow) + detailsFramework:Mixin(este_jogador, Details222.Mixins.ActorMixin) setmetatable(este_jogador, _detalhes.atributo_energy) este_jogador.__index = _detalhes.atributo_energy @@ -1527,7 +1530,7 @@ function _detalhes.refresh:r_atributo_energy (este_jogador, shadow) if (shadow and not shadow.powertype) then shadow.powertype = este_jogador.powertype - end + end end function _detalhes.clear:c_atributo_energy (este_jogador) diff --git a/classes/class_utility.lua b/classes/class_utility.lua index 95d7a4722..a048ac996 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -26,6 +26,7 @@ local _detalhes = _G._detalhes local Details = _detalhes local AceLocale = LibStub("AceLocale-3.0") local Loc = AceLocale:GetLocale ( "Details" ) +local detailsFramework = DetailsFramework local addonName, Details222 = ... local gump = _detalhes.gump @@ -169,14 +170,17 @@ end end function atributo_misc:NovaTabela(serial, nome, link) - local newActor = { + local newUtilityActor = { last_event = 0, tipo = class_type, pets = {} } - setmetatable(newActor, atributo_misc) - return newActor + setmetatable(newUtilityActor, atributo_misc) + + detailsFramework:Mixin(newUtilityActor, Details222.Mixins.ActorMixin) + + return newUtilityActor end function atributo_misc:CreateBuffTargetObject() @@ -2738,107 +2742,109 @@ function atributo_misc:ColetarLixo (lastevent) return _detalhes:ColetarLixo (class_type, lastevent) end -function _detalhes.refresh:r_atributo_misc (este_jogador, shadow) - setmetatable(este_jogador, _detalhes.atributo_misc) - este_jogador.__index = _detalhes.atributo_misc +function _detalhes.refresh:r_atributo_misc(thisActor, shadow) + setmetatable(thisActor, _detalhes.atributo_misc) + detailsFramework:Mixin(thisActor, Details222.Mixins.ActorMixin) + + thisActor.__index = _detalhes.atributo_misc --refresh spell cast - if (este_jogador.spell_cast) then + if (thisActor.spell_cast) then if (shadow and not shadow.spell_cast) then shadow.spell_cast = {} end end --refresh cc done - if (este_jogador.cc_done) then + if (thisActor.cc_done) then if (shadow and not shadow.cc_done_targets) then shadow.cc_done = 0 shadow.cc_done_targets = {} shadow.cc_done_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) end - _detalhes.refresh:r_container_habilidades (este_jogador.cc_done_spells, shadow and shadow.cc_done_spells) + _detalhes.refresh:r_container_habilidades (thisActor.cc_done_spells, shadow and shadow.cc_done_spells) end --refresh interrupts - if (este_jogador.interrupt_targets) then + if (thisActor.interrupt_targets) then if (shadow and not shadow.interrupt_targets) then shadow.interrupt = 0 shadow.interrupt_targets = {} shadow.interrupt_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) shadow.interrompeu_oque = {} end - _detalhes.refresh:r_container_habilidades (este_jogador.interrupt_spells, shadow and shadow.interrupt_spells) + _detalhes.refresh:r_container_habilidades (thisActor.interrupt_spells, shadow and shadow.interrupt_spells) end --refresh buff uptime - if (este_jogador.buff_uptime_targets) then + if (thisActor.buff_uptime_targets) then if (shadow and not shadow.buff_uptime_targets) then shadow.buff_uptime = 0 shadow.buff_uptime_targets = {} shadow.buff_uptime_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) end - _detalhes.refresh:r_container_habilidades (este_jogador.buff_uptime_spells, shadow and shadow.buff_uptime_spells) + _detalhes.refresh:r_container_habilidades (thisActor.buff_uptime_spells, shadow and shadow.buff_uptime_spells) end --refresh buff uptime - if (este_jogador.debuff_uptime_targets) then + if (thisActor.debuff_uptime_targets) then if (shadow and not shadow.debuff_uptime_targets) then shadow.debuff_uptime = 0 - if (este_jogador.boss_debuff) then + if (thisActor.boss_debuff) then shadow.debuff_uptime_targets = {} shadow.boss_debuff = true - shadow.damage_twin = este_jogador.damage_twin - shadow.spellschool = este_jogador.spellschool - shadow.damage_spellid = este_jogador.damage_spellid + shadow.damage_twin = thisActor.damage_twin + shadow.spellschool = thisActor.spellschool + shadow.damage_spellid = thisActor.damage_spellid shadow.debuff_uptime = 0 else shadow.debuff_uptime_targets = {} end shadow.debuff_uptime_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) end - _detalhes.refresh:r_container_habilidades (este_jogador.debuff_uptime_spells, shadow and shadow.debuff_uptime_spells) + _detalhes.refresh:r_container_habilidades (thisActor.debuff_uptime_spells, shadow and shadow.debuff_uptime_spells) end --refresh cooldowns defensive - if (este_jogador.cooldowns_defensive_targets) then + if (thisActor.cooldowns_defensive_targets) then if (shadow and not shadow.cooldowns_defensive_targets) then shadow.cooldowns_defensive = 0 shadow.cooldowns_defensive_targets = {} shadow.cooldowns_defensive_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) end - _detalhes.refresh:r_container_habilidades (este_jogador.cooldowns_defensive_spells, shadow and shadow.cooldowns_defensive_spells) + _detalhes.refresh:r_container_habilidades (thisActor.cooldowns_defensive_spells, shadow and shadow.cooldowns_defensive_spells) end --refresh ressers - if (este_jogador.ress_targets) then + if (thisActor.ress_targets) then if (shadow and not shadow.ress_targets) then shadow.ress = 0 shadow.ress_targets = {} shadow.ress_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) end - _detalhes.refresh:r_container_habilidades (este_jogador.ress_spells, shadow and shadow.ress_spells) + _detalhes.refresh:r_container_habilidades (thisActor.ress_spells, shadow and shadow.ress_spells) end --refresh dispells - if (este_jogador.dispell_targets) then + if (thisActor.dispell_targets) then if (shadow and not shadow.dispell_targets) then shadow.dispell = 0 shadow.dispell_targets = {} shadow.dispell_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) --cria o container das habilidades usadas para interromper shadow.dispell_oque = {} end - _detalhes.refresh:r_container_habilidades (este_jogador.dispell_spells, shadow and shadow.dispell_spells) + _detalhes.refresh:r_container_habilidades (thisActor.dispell_spells, shadow and shadow.dispell_spells) end --refresh cc_breaks - if (este_jogador.cc_break_targets) then + if (thisActor.cc_break_targets) then if (shadow and not shadow.cc_break) then shadow.cc_break = 0 shadow.cc_break_targets = {} shadow.cc_break_spells = container_habilidades:NovoContainer (_detalhes.container_type.CONTAINER_MISC_CLASS) shadow.cc_break_oque = {} end - _detalhes.refresh:r_container_habilidades (este_jogador.cc_break_spells, shadow and shadow.cc_break_spells) + _detalhes.refresh:r_container_habilidades (thisActor.cc_break_spells, shadow and shadow.cc_break_spells) end end diff --git a/core/control.lua b/core/control.lua index b0442e4a0..91189b0a2 100644 --- a/core/control.lua +++ b/core/control.lua @@ -1631,14 +1631,16 @@ -- /run local a,b=Details.tooltip.header_statusbar,0.3;a[1]=b;a[2]=b;a[3]=b;a[4]=0.8; - function Details:AddTooltipSpellHeaderText (headerText, headerColor, amount, iconTexture, L, R, T, B, separator) - + function Details:AddTooltipSpellHeaderText (headerText, headerColor, amount, iconTexture, L, R, T, B, separator, iconSize) if (separator and separator == true) then GameCooltip:AddLine ("", "", nil, nil, 1, 1, 1, 1, 8) - return end + if (type(iconSize) ~= "number") then + iconSize = 14 + end + if (Details.tooltip.show_amount) then GameCooltip:AddLine (headerText, "x" .. amount .. "", nil, headerColor, 1, 1, 1, .4, Details.tooltip.fontsize_title) else @@ -1646,7 +1648,7 @@ end if (iconTexture) then - GameCooltip:AddIcon (iconTexture, 1, 1, 14, 14, L or 0, R or 1, T or 0, B or 1) + GameCooltip:AddIcon (iconTexture, 1, 1, iconSize, iconSize, L or 0, R or 1, T or 0, B or 1) end end diff --git a/frames/window_custom.lua b/frames/window_custom.lua index b9ed9e556..17082fb95 100644 --- a/frames/window_custom.lua +++ b/frames/window_custom.lua @@ -1,76 +1,54 @@ --custom window - local _detalhes = _G._detalhes local gump = _detalhes.gump local _ - - local AceComm = LibStub("AceComm-3.0") - local AceSerializer = LibStub("AceSerializer-3.0") - local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) + local Loc = LibStub("AceLocale-3.0"):GetLocale( "Details" ) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --local pointers - - - local _cstr = string.format --lua local - local _math_ceil = math.ceil --lua local - local _math_floor = math.floor --lua local local ipairs = ipairs --lua local local pairs = pairs --lua local - local _string_lower = string.lower --lua local - local _table_sort = table.sort --lua local local tinsert = table.insert --lua local - local _unpack = unpack --lua local local setmetatable = setmetatable --lua local - local _GetSpellInfo = _detalhes.getspellinfo --api local local CreateFrame = CreateFrame --api local - local GetTime = GetTime --api local - local _GetCursorPosition = GetCursorPosition --api local - local _GameTooltip = GameTooltip --api local local UIParent = UIParent --api local - local _GetScreenWidth = GetScreenWidth --api local - local _GetScreenHeight = GetScreenHeight --api local - local _IsAltKeyDown = IsAltKeyDown --api local - local _IsShiftKeyDown = IsShiftKeyDown --api local - local _IsControlKeyDown = IsControlKeyDown --api local - + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --constants - local CONST_MENU_X_POSITION = 10 local CONST_MENU_Y_POSITION = -40 local CONST_MENU_WIDTH = 160 local CONST_MENU_HEIGHT = 20 - + local CONST_INFOBOX_X_POSITION = 220 local CONST_EDITBUTTONS_X_POSITION = 560 - + local CONST_EDITBOX_Y_POSITION = -200 - local CONST_EDITBOX_WIDTH = 900 + local CONST_EDITBOX_WIDTH = 893 local CONST_EDITBOX_HEIGHT = 370 - + local CONST_EDITBOX_BUTTON_WIDTH = 80 local CONST_EDITBOX_BUTTON_HEIGHT = 20 - + local CONST_BUTTON_TEMPLATE = gump:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE") local CONST_TEXTENTRY_TEMPLATE = gump:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE") - - gump:InstallTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BUTTONS", + + gump:InstallTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BUTTONS", { icon = {texture = [[Interface\BUTTONS\UI-GuildButton-PublicNote-Up]]}, width = 160, - }, + }, "DETAILS_PLUGIN_BUTTON_TEMPLATE" ) - - gump:InstallTemplate("button", "DETAILS_CUSTOMDISPLAY_REGULAR_BUTTON", + + gump:InstallTemplate("button", "DETAILS_CUSTOMDISPLAY_REGULAR_BUTTON", { width = 130, - }, + }, "DETAILS_PLUGIN_BUTTON_TEMPLATE" ) - + gump:InstallTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BOX", { backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, backdropcolor = {.2, .2, .2, 0.6}, @@ -86,23 +64,15 @@ backdropcolor = {.2, .2, .2, 1}, backdropbordercolor = {0, 0, 0, 1}, }) - + gump:NewColor("DETAILS_CUSTOMDISPLAY_ICON", .7, .6, .5, 1) - + local CONST_CODETEXTENTRY_TEMPLATE = gump:GetTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BOX") local CONST_CODETEXTENTRYEXPANDED_TEMPLATE = gump:GetTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BOX_EXPANDED") local CONST_CODETEXTENTRYBUTTON_TEMPLATE = gump:GetTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BOX_BUTTON") local CONST_CODETEXTENTRY_OPENCODEBUTTONS_TEMPLATE = gump:GetTemplate("button", "DETAILS_CUSTOMDISPLAY_CODE_BUTTONS") local CONST_REGULAR_BUTTON_TEMPLATE = gump:GetTemplate("button", "DETAILS_CUSTOMDISPLAY_REGULAR_BUTTON") - - local atributos = _detalhes.atributos - local sub_atributos = _detalhes.sub_atributos - - local CLASS_ICON_TCOORDS = _G.CLASS_ICON_TCOORDS - local class_type_dano = _detalhes.atributos.dano - local class_type_misc = _detalhes.atributos.misc - local object_keys = { ["name"] = true, ["icon"] = true, @@ -117,12 +87,11 @@ ["total_script"] = true, ["percent_script"] = true, } - + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --create the window - + function _detalhes:CloseCustomDisplayWindow() - --cancel editing or creation if (DetailsCustomPanel.CodeEditing) then DetailsCustomPanel:CancelFunc() @@ -130,14 +99,14 @@ if (DetailsCustomPanel.IsEditing) then DetailsCustomPanel:CancelFunc() end - + DetailsCustomPanel:Reset() DetailsCustomPanel:ClearFocus() - + --hide the frame _G.DetailsCustomPanel:Hide() end - + function _detalhes:InitializeCustomDisplayWindow() local DetailsCustomPanel = CreateFrame("frame", "DetailsCustomPanel", UIParent,"BackdropTemplate") DetailsCustomPanel.Frame = DetailsCustomPanel @@ -148,30 +117,27 @@ DetailsCustomPanel.__iconcoords = {412/512, 441/512, 43/512, 79/512} DetailsCustomPanel.__iconcolor = "DETAILS_CUSTOMDISPLAY_ICON" DetailsPluginContainerWindow.EmbedPlugin (DetailsCustomPanel, DetailsCustomPanel, true) - + function DetailsCustomPanel.RefreshWindow() _detalhes:OpenCustomDisplayWindow() end end - + function _detalhes:OpenCustomDisplayWindow() - if (not _G.DetailsCustomPanel or not DetailsCustomPanel.Initialized) then - - DetailsPluginContainerWindow.OpenPlugin (DetailsCustomPanel) - + + DetailsPluginContainerWindow.OpenPlugin(DetailsCustomPanel) + local GameCooltip = GameCooltip DetailsCustomPanel.Initialized = true - + --main frame - local custom_window = DetailsCustomPanel or CreateFrame("frame", "DetailsCustomPanel", UIParent,"BackdropTemplate") - local f = custom_window - - custom_window:SetPoint("center", UIParent, "center") - custom_window:SetSize(850, 500) - custom_window:EnableMouse(true) - custom_window:SetMovable(true) - custom_window:SetScript("OnMouseDown", function(self, button) + local customWindow = DetailsCustomPanel or CreateFrame("frame", "DetailsCustomPanel", UIParent, "BackdropTemplate") + customWindow:SetPoint("center", UIParent, "center") + customWindow:SetSize(850, 500) + customWindow:EnableMouse(true) + customWindow:SetMovable(true) + customWindow:SetScript("OnMouseDown", function(self, button) if (button == "LeftButton") then if (not self.moving) then self.moving = true @@ -183,150 +149,155 @@ end end end) - custom_window:SetScript("OnMouseUp", function(self) + + customWindow:SetScript("OnMouseUp", function(self) if (self.moving) then self.moving = false self:StopMovingOrSizing() end end) - custom_window:SetScript("OnShow", function() + + customWindow:SetScript("OnShow", function() GameCooltip:Hide() end) - + tinsert(UISpecialFrames, "DetailsCustomPanel") - --menu title bar - local titlebar = CreateFrame("frame", nil, f,"BackdropTemplate") - titlebar:SetPoint("topleft", f, "topleft", 2, -3) - titlebar:SetPoint("topright", f, "topright", -2, -3) + local titlebar = CreateFrame("frame", nil, customWindow,"BackdropTemplate") + titlebar:SetPoint("topleft", customWindow, "topleft", 2, -3) + titlebar:SetPoint("topright", customWindow, "topright", -2, -3) titlebar:SetHeight(20) titlebar:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) titlebar:SetBackdropColor(.5, .5, .5, 1) titlebar:SetBackdropBorderColor(0, 0, 0, 1) - + --menu title local titleLabel = _detalhes.gump:NewLabel(titlebar, titlebar, nil, "titulo", "Details! Custom Displays", "GameFontNormal", 12) titleLabel:SetPoint("center", titlebar , "center") titleLabel:SetPoint("top", titlebar , "top", 0, -4) - + --close button - f.Close = CreateFrame("button", "$parentCloseButton", f) - f.Close:SetPoint("right", titlebar, "right", -2, 0) - f.Close:SetSize(16, 16) - - f.Close:SetNormalTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) - f.Close:SetHighlightTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) - f.Close:SetPushedTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) - f.Close:GetNormalTexture():SetDesaturated(true) - f.Close:GetHighlightTexture():SetDesaturated(true) - f.Close:GetPushedTexture():SetDesaturated(true) - - f.Close:SetAlpha(0.7) - f.Close:SetScript("OnClick", function() _detalhes:CloseCustomDisplayWindow() end) - f.Close:SetScript("OnHide", function() + customWindow.Close = CreateFrame("button", "$parentCloseButton", customWindow) + customWindow.Close:SetPoint("right", titlebar, "right", -2, 0) + customWindow.Close:SetSize(16, 16) + + customWindow.Close:SetNormalTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) + customWindow.Close:SetHighlightTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) + customWindow.Close:SetPushedTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]]) + customWindow.Close:GetNormalTexture():SetDesaturated(true) + customWindow.Close:GetHighlightTexture():SetDesaturated(true) + customWindow.Close:GetPushedTexture():SetDesaturated(true) + + customWindow.Close:SetAlpha(0.7) + customWindow.Close:SetScript("OnClick", function() _detalhes:CloseCustomDisplayWindow() end) + customWindow.Close:SetScript("OnHide", function() _detalhes:CloseCustomDisplayWindow() end) - + --background - f.bg1 = f:CreateTexture(nil, "background") - f.bg1:SetTexture([[Interface\AddOns\Details\images\background]], true) - f.bg1:SetAlpha(0.7) - f.bg1:SetVertexColor(0.27, 0.27, 0.27) - f.bg1:SetVertTile(true) - f.bg1:SetHorizTile(true) - f.bg1:SetAllPoints() - - f:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) - f:SetBackdropColor(.5, .5, .5, .5) - f:SetBackdropBorderColor(0, 0, 0, 1) + customWindow.bg1 = customWindow:CreateTexture(nil, "background") + customWindow.bg1:SetTexture([[Interface\AddOns\Details\images\background]], true) + customWindow.bg1:SetAlpha(0.7) + customWindow.bg1:SetVertexColor(0.27, 0.27, 0.27) + customWindow.bg1:SetVertTile(true) + customWindow.bg1:SetHorizTile(true) + customWindow.bg1:SetAllPoints() + + customWindow:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) + customWindow:SetBackdropColor(.5, .5, .5, .5) + customWindow:SetBackdropBorderColor(0, 0, 0, 1) DetailsCustomPanel.BoxType = 1 DetailsCustomPanel.IsEditing = false DetailsCustomPanel.IsImporting = false DetailsCustomPanel.CodeEditing = false DetailsCustomPanel.current_attribute = "damagedone" - + DetailsCustomPanel.code1_default = [[ --get the parameters passed local Combat, CustomContainer, Instance = ... --declade the values to return local total, top, amount = 0, 0, 0 - + --do the loop --CustomContainer:AddValue (actor, actor.value) --loop end - + --if not managed inside the loop, get the values of total, top and amount total, top = CustomContainer:GetTotalAndHighestValue() amount = CustomContainer:GetNumActors() - + --return the values return total, top, amount ]] + DetailsCustomPanel.code1 = DetailsCustomPanel.code1_default - + DetailsCustomPanel.code2_default = [[ --get the parameters passed local actor, combat, instance = ... - + --get the cooltip object (we dont use the convencional GameTooltip here) local GameCooltip = GameCooltip - + --Cooltip code ]] + DetailsCustomPanel.code2 = DetailsCustomPanel.code2_default - + DetailsCustomPanel.code3_default = [[ local value, top, total, combat, instance = ... return math.floor(value) ]] + DetailsCustomPanel.code3 = DetailsCustomPanel.code3_default - + DetailsCustomPanel.code4_default = [[ local value, top, total, combat, instance = ... return string.format("%.1f", value/total*100) ]] + DetailsCustomPanel.code4 = DetailsCustomPanel.code4_default - + function DetailsCustomPanel:ClearFocus() - custom_window.desc_field:ClearFocus() - custom_window.name_field:ClearFocus() - custom_window.author_field:ClearFocus() + customWindow.desc_field:ClearFocus() + customWindow.name_field:ClearFocus() + customWindow.author_field:ClearFocus() end - + function DetailsCustomPanel:Reset() self.name_field:SetText("") self.icon_image:SetTexture([[Interface\ICONS\TEMP]]) self.desc_field:SetText("") - + self.author_field:SetText(UnitName ("player") .. "-" .. GetRealmName()) self.author_field:Enable() - + self.source_dropdown:Select(1, true) self.source_field:SetText("") - + self.target_dropdown:Select(1, true) self.target_field:SetText("") - + self.spellid_entry:SetText("") - + DetailsCustomPanel.code1 = DetailsCustomPanel.code1_default DetailsCustomPanel.code2 = DetailsCustomPanel.code2_default DetailsCustomPanel.code3 = DetailsCustomPanel.code3_default DetailsCustomPanel.code4 = DetailsCustomPanel.code4_default - + DetailsCustomPanel.current_attribute = "damagedone" DetailsCustomPanelAttributeMenu1:Click() - + DetailsCustomPanel:ClearFocus() end - + function DetailsCustomPanel:RemoveDisplay (custom_object, index) table.remove (_detalhes.custom, index) - - for _, instance in ipairs(_detalhes.tabela_instancias) do - if (instance.atributo == 5 and instance.sub_atributo == index) then + + for _, instance in ipairs(_detalhes.tabela_instancias) do + if (instance.atributo == 5 and instance.sub_atributo == index) then instance:ResetAttribute() elseif (instance.atributo == 5 and instance.sub_atributo > index) then instance.sub_atributo = instance.sub_atributo - 1 @@ -335,46 +306,45 @@ instance.sub_atributo_last [5] = 1 end end - + _detalhes.switch:OnRemoveCustom (index) _detalhes:ResetCustomFunctionsCache() end - + function DetailsCustomPanel:StartEdit (custom_object, import) - DetailsCustomPanel:Reset() DetailsCustomPanel:ClearFocus() - + DetailsCustomPanel.IsEditing = custom_object DetailsCustomPanel.IsImporting = import - + self.name_field:SetText(custom_object:GetName()) self.desc_field:SetText(custom_object:GetDesc()) self.icon_image:SetTexture(custom_object:GetIcon()) - + self.author_field:SetText(custom_object:GetAuthor()) self.author_field:Disable() - - custom_window.codeeditor:SetText("") - + + customWindow.codeeditor:SetText("") + if (custom_object:IsScripted()) then - - custom_window.script_button_attribute:Click() - + + customWindow.script_button_attribute:Click() + DetailsCustomPanel.code1 = custom_object:GetScript() DetailsCustomPanel.code2 = custom_object:GetScriptToolip() DetailsCustomPanel.code3 = custom_object:GetScriptTotal() or DetailsCustomPanel.code3_default DetailsCustomPanel.code4 = custom_object:GetScriptPercent() or DetailsCustomPanel.code4_default - + else - + local attribute = custom_object:GetAttribute() if (attribute == "damagedone") then DetailsCustomPanelAttributeMenu1:Click() elseif (attribute == "healdone") then DetailsCustomPanelAttributeMenu2:Click() end - + local source = custom_object:GetSource() if (source == "[all]") then self.source_dropdown:Select(1, true) @@ -393,9 +363,9 @@ self.source_field:SetText(source) self.source_field:Enable() end - + local target = custom_object:GetTarget() - + if (not target) then self.target_dropdown:Select(5, true) self.target_field:SetText("") @@ -417,51 +387,50 @@ self.target_field:SetText(target) self.target_field:Enable() end - + self.spellid_entry:SetText(custom_object:GetSpellId() or "") - + end - + if (import) then DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_IMPORT_BUTTON"]) else DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_SAVE"]) end end - + function DetailsCustomPanel:CreateNewCustom() - local name = self.name_field:GetText() DetailsCustomPanel:ClearFocus() _detalhes.MicroButtonAlert:Hide() - + if (string.len(name) < 5) then return false, _detalhes:Msg(Loc ["STRING_CUSTOM_SHORTNAME"]) elseif (string.len(name) > 32) then return false, _detalhes:Msg(Loc ["STRING_CUSTOM_LONGNAME"]) end - + _detalhes:ResetCustomFunctionsCache() local icon = self.icon_image:GetTexture() local desc = self.desc_field:GetText() local author = self.author_field:GetText() - + if (DetailsCustomPanel.BoxType == 1) then local source = self.source_dropdown:GetValue() local target = self.target_dropdown:GetValue() local spellid = self.spellid_entry:GetText() - + if (not source) then source = self.source_field:GetText() end - + if (not target) then target = self.target_field:GetText() elseif (target == "[none]") then target = false end - + if (spellid == "") then spellid = false end @@ -484,11 +453,11 @@ else _detalhes:Msg(Loc ["STRING_CUSTOM_SAVED"]) end - + if (DetailsCustomPanel.IsImporting) then tinsert(_detalhes.custom, object) end - + DetailsCustomPanel.IsEditing = false DetailsCustomPanel.IsImporting = false self.author_field:Enable() @@ -512,16 +481,16 @@ new_custom_object.__index = _detalhes.atributo_custom _detalhes:Msg(Loc ["STRING_CUSTOM_CREATED"]) end - + DetailsCustomPanel:Reset() - + elseif (DetailsCustomPanel.BoxType == 2) then - + local main_code = DetailsCustomPanel.code1 local tooltip_code = DetailsCustomPanel.code2 local total_code = DetailsCustomPanel.code3 local percent_code = DetailsCustomPanel.code4 - + if (DetailsCustomPanel.IsEditing) then local object = DetailsCustomPanel.IsEditing object.name = name @@ -534,29 +503,29 @@ object.spellid = false object.script = main_code object.tooltip = tooltip_code - + if (total_code ~= DetailsCustomPanel.code3_default) then object.total_script = total_code else object.total_script = false end - + if (percent_code ~= DetailsCustomPanel.code4_default) then object.percent_script = percent_code else object.percent_script = false end - + if (DetailsCustomPanel.IsImporting) then _detalhes:Msg(Loc ["STRING_CUSTOM_IMPORTED"]) else _detalhes:Msg(Loc ["STRING_CUSTOM_SAVED"]) end - + if (DetailsCustomPanel.IsImporting) then tinsert(_detalhes.custom, object) end - + DetailsCustomPanel.IsEditing = false DetailsCustomPanel.IsImporting = false self.author_field:Enable() @@ -574,52 +543,52 @@ ["script"] = main_code, ["tooltip"] = tooltip_code, } - + local total_code = DetailsCustomPanel.code3 local percent_code = DetailsCustomPanel.code4 - + if (total_code ~= DetailsCustomPanel.code3_default) then new_custom_object.total_script = total_code else new_custom_object.total_script = false end - + if (percent_code ~= DetailsCustomPanel.code4_default) then new_custom_object.percent_script = percent_code else new_custom_object.percent_script = false end - + tinsert(_detalhes.custom, new_custom_object) setmetatable(new_custom_object, _detalhes.atributo_custom) new_custom_object.__index = _detalhes.atributo_custom _detalhes:Msg(Loc ["STRING_CUSTOM_CREATED"]) end - + DetailsCustomPanel:Reset() - + end end - + function DetailsCustomPanel:AcceptFunc() - + _detalhes.MicroButtonAlert:Hide() - + if (DetailsCustomPanel.CodeEditing) then --close the edit box saving the text if (DetailsCustomPanel.CodeEditing == 1) then - DetailsCustomPanel.code1 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code1 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 2) then - DetailsCustomPanel.code2 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code2 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 3) then - DetailsCustomPanel.code3 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code3 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 4) then - DetailsCustomPanel.code4 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code4 = customWindow.codeeditor:GetText() end - + DetailsCustomPanel.CodeEditing = false - + if (DetailsCustomPanel.IsImporting) then DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_IMPORT_BUTTON"]) elseif (DetailsCustomPanel.IsEditing) then @@ -627,10 +596,10 @@ else DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_CREATE"]) end - custom_window.codeeditor:Hide() - + customWindow.codeeditor:Hide() + elseif (DetailsCustomPanel.IsEditing) then - + local succesful_edit = DetailsCustomPanel:CreateNewCustom() if (succesful_edit) then DetailsCustomPanel.IsEditing = false @@ -641,19 +610,19 @@ else DetailsCustomPanel:CreateNewCustom() end - + end - + function DetailsCustomPanel:CancelFunc() - + DetailsCustomPanel:ClearFocus() _detalhes.MicroButtonAlert:Hide() - + if (DetailsCustomPanel.CodeEditing) then --close the edit box without save - custom_window.codeeditor:Hide() + customWindow.codeeditor:Hide() DetailsCustomPanel.CodeEditing = false - + if (DetailsCustomPanel.IsImporting) then DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_IMPORT_BUTTON"]) elseif (DetailsCustomPanel.IsEditing) then @@ -661,41 +630,41 @@ else DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_CREATE"]) end - + elseif (DetailsCustomPanel.IsEditing) then DetailsCustomPanel.IsEditing = false DetailsCustomPanel.IsImporting = false DetailsCustomPanel:SetAcceptButtonText (Loc ["STRING_CUSTOM_CREATE"]) DetailsCustomPanel:Reset() - + else _detalhes:CloseCustomDisplayWindow() end - + end - + function DetailsCustomPanel:SetAcceptButtonText (text) - custom_window.box0.acceptbutton:SetText(text) + customWindow.box0.acceptbutton:SetText(text) end function select_attribute (self) - + if (not self.attribute_table) then return end - + DetailsCustomPanel:ClearFocus() - - custom_window.selected_left:SetPoint("topleft", self, "topleft") - custom_window.selected_right:SetPoint("topright", self, "topright") - + + customWindow.selected_left:SetPoint("topleft", self, "topleft") + customWindow.selected_right:SetPoint("topright", self, "topright") + DetailsCustomPanel.current_attribute = self.attribute_table.attribute - + if (not self.attribute_table.attribute) then --is scripted DetailsCustomPanel.BoxType = 2 - custom_window.box1:Hide() - custom_window.box2:Show() + customWindow.box1:Hide() + customWindow.box2:Show() else --no scripted @@ -703,114 +672,114 @@ if (DetailsCustomPanel.CodeEditing) then DetailsCustomPanel.AcceptFunc() end - + DetailsCustomPanel.BoxType = 1 - custom_window.box1:Show() - custom_window.box2:Hide() - custom_window.codeeditor:Hide() + customWindow.box1:Show() + customWindow.box2:Hide() + customWindow.codeeditor:Hide() end end function DetailsCustomPanel.StartEditCode (_, _, code) if (code == 1) then --edit main code - - custom_window.codeeditor:SetText(DetailsCustomPanel.code1) - + + customWindow.codeeditor:SetText(DetailsCustomPanel.code1) + elseif (code == 2) then --edit tooltip code - - custom_window.codeeditor:SetText(DetailsCustomPanel.code2) - + + customWindow.codeeditor:SetText(DetailsCustomPanel.code2) + elseif (code == 3) then --edit total code - - custom_window.codeeditor:SetText(DetailsCustomPanel.code3) - + + customWindow.codeeditor:SetText(DetailsCustomPanel.code3) + elseif (code == 4) then --edit percent code - - custom_window.codeeditor:SetText(DetailsCustomPanel.code4) - + + customWindow.codeeditor:SetText(DetailsCustomPanel.code4) + end - - custom_window.codeeditor:Show() + + customWindow.codeeditor:Show() DetailsCustomPanel.CodeEditing = code - + DetailsCustomPanel:SetAcceptButtonText ("Save Code") --Loc ["STRING_CUSTOM_DONE"] end --left menu - custom_window.menu = {} + customWindow.menu = {} local menu_start = -50 - local menu_up_frame = CreateFrame("frame", nil, custom_window) - menu_up_frame:SetFrameLevel(custom_window:GetFrameLevel()+2) - + local menu_up_frame = CreateFrame("frame", nil, customWindow) + menu_up_frame:SetFrameLevel(customWindow:GetFrameLevel()+2) + local onenter = function(self) --self.icontexture:SetVertexColor(1, 1, 1, 1) end local onleave = function(self) --self.icontexture:SetVertexColor(.9, .9, .9, 1) end - - function custom_window:CreateMenuButton (label, icon, clickfunc, param1, param2, tooltip, name, coords) - local index = #custom_window.menu+1 + + function customWindow:CreateMenuButton (label, icon, clickfunc, param1, param2, tooltip, name, coords) + local index = #customWindow.menu+1 local button = gump:NewButton(self, nil, "$parent" .. name, nil, CONST_MENU_WIDTH, CONST_MENU_HEIGHT, clickfunc, param1, param2, nil, label) button:SetPoint("topleft", self, "topleft", CONST_MENU_X_POSITION, CONST_MENU_Y_POSITION + ((index-1)*-23)) - + --button:SetTemplate(CONST_BUTTON_TEMPLATE) button:SetTemplate(gump:GetTemplate("button", "DETAILS_PLUGIN_BUTTON_TEMPLATE")) button:SetWidth(160) button:SetIcon (icon, CONST_MENU_HEIGHT-4, CONST_MENU_HEIGHT-4, "overlay", {.1, .9, .1, .9}, nil, 4) - + button:SetHook("OnEnter", onenter) button:SetHook("OnLeave", onleave) button.widget.icontexture = texture button.tooltip = tooltip - custom_window.menu [index] = {circle = circle, icon = texture, button = button} + customWindow.menu [index] = {circle = circle, icon = texture, button = button} end - + local build_menu = function(self, button, func, param2) GameCooltip:Reset() - + for index, custom_object in ipairs(_detalhes.custom) do GameCooltip:AddLine(custom_object:GetName()) GameCooltip:AddIcon (custom_object:GetIcon()) GameCooltip:AddMenu (1, func, custom_object, index, true) end - + GameCooltip:SetOption("ButtonsYMod", -2) GameCooltip:SetOption("YSpacingMod", 0) GameCooltip:SetOption("TextHeightMod", 0) GameCooltip:SetOption("IgnoreButtonAutoHeight", false) GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + GameCooltip:SetBackdrop(1, _detalhes.tooltip_backdrop, nil, _detalhes.tooltip_border_color) GameCooltip:SetBackdrop(2, _detalhes.tooltip_backdrop, nil, _detalhes.tooltip_border_color) - + GameCooltip:SetType ("menu") GameCooltip:SetHost (self, "left", "right", -7, 0) GameCooltip:Show() end - + --edit button local start_edit = function(_, _, custom_object, index) GameCooltip:Hide() DetailsCustomPanel:StartEdit (custom_object) end - custom_window:CreateMenuButton (Loc ["STRING_CUSTOM_EDIT"], "Interface\\ICONS\\INV_Inscription_RunescrollOfFortitude_Red", build_menu, start_edit, nil, nil, "Edit", {0.07, 0.93, 0.07, 0.93}) - + customWindow:CreateMenuButton (Loc ["STRING_CUSTOM_EDIT"], "Interface\\ICONS\\INV_Inscription_RunescrollOfFortitude_Red", build_menu, start_edit, nil, nil, "Edit", {0.07, 0.93, 0.07, 0.93}) + --remove button local remove_display = function(_, _, custom_object, index) GameCooltip:Hide() DetailsCustomPanel:RemoveDisplay (custom_object, index) end - custom_window:CreateMenuButton (Loc ["STRING_CUSTOM_REMOVE"], "Interface\\ICONS\\Spell_BrokenHeart", build_menu, remove_display, nil, nil, "Remove", {1, 0, 0, 1}) - + customWindow:CreateMenuButton (Loc ["STRING_CUSTOM_REMOVE"], "Interface\\ICONS\\Spell_BrokenHeart", build_menu, remove_display, nil, nil, "Remove", {1, 0, 0, 1}) + --export button local export_display = function(_, _, custom_object, index) GameCooltip:Hide() local export_object = {} - + for key, value in pairs(custom_object) do if (object_keys [key]) then if (type(value) == "table") then @@ -820,120 +789,120 @@ end end end - + local encoded = Details:CompressData (export_object, "print") - - if (not custom_window.ExportBox) then - local editbox = _detalhes.gump:NewTextEntry(custom_window, nil, "$parentExportBox", "ExportBox", CONST_EDITBOX_WIDTH, 20) - editbox:SetPoint("bottomleft", custom_window, "bottomleft", 10, 6) + + if (not customWindow.ExportBox) then + local editbox = _detalhes.gump:NewTextEntry(customWindow, nil, "$parentExportBox", "ExportBox", CONST_EDITBOX_WIDTH, 20) + editbox:SetPoint("bottomleft", customWindow, "bottomleft", 10, 6) editbox:SetAutoFocus(false) editbox:SetTemplate(CONST_TEXTENTRY_TEMPLATE) - editbox:SetHook("OnEditFocusLost", function() + editbox:SetHook("OnEditFocusLost", function() editbox:Hide() end) - editbox:SetHook("OnChar", function() + editbox:SetHook("OnChar", function() editbox:Hide() end) - + local flashTexture = editbox:CreateTexture(nil, "overlay") flashTexture:SetColorTexture(1, 1, 1) flashTexture:SetAllPoints() flashTexture:SetAlpha(0) - + local flashAnimHub = DetailsFramework:CreateAnimationHub (flashTexture) DetailsFramework:CreateAnimation(flashAnimHub, "alpha", 1, 0.2, 0, 1) DetailsFramework:CreateAnimation(flashAnimHub, "alpha", 2, 0.2, 1, 0) editbox.FlashAnimation = flashAnimHub end - - if (custom_window.ImportBox) then - custom_window.ImportBox:Hide() - custom_window.exportLabel:Hide() - custom_window.ImportConfirm:Hide() + + if (customWindow.ImportBox) then + customWindow.ImportBox:Hide() + customWindow.exportLabel:Hide() + customWindow.ImportConfirm:Hide() end - - custom_window.ExportBox:Show() - custom_window.ExportBox:SetText(encoded) - custom_window.ExportBox:HighlightText() - custom_window.ExportBox:SetFocus() - - custom_window.ExportBox.FlashAnimation:Play() - + + customWindow.ExportBox:Show() + customWindow.ExportBox:SetText(encoded) + customWindow.ExportBox:HighlightText() + customWindow.ExportBox:SetFocus() + + customWindow.ExportBox.FlashAnimation:Play() + end - custom_window:CreateMenuButton (Loc ["STRING_CUSTOM_EXPORT"], "Interface\\ICONS\\INV_Misc_Gift_01", build_menu, export_display, nil, nil, "Export", {0.00, 0.9, 0.07, 0.93}) --localize + customWindow:CreateMenuButton (Loc ["STRING_CUSTOM_EXPORT"], "Interface\\ICONS\\INV_Misc_Gift_01", build_menu, export_display, nil, nil, "Export", {0.00, 0.9, 0.07, 0.93}) --localize --import buttonRaceChange local import_display = function(_, _, custom_object, index) GameCooltip:Hide() - - if (not custom_window.ImportBox) then - - local export_string = gump:NewLabel(custom_window, custom_window, "$parenImportLabel", "exportLabel", "Import String:", "GameFontNormal") --Loc ["STRING_CUSTOM_PASTE"] + + if (not customWindow.ImportBox) then + + local export_string = gump:NewLabel(customWindow, customWindow, "$parenImportLabel", "exportLabel", "Import String:", "GameFontNormal") --Loc ["STRING_CUSTOM_PASTE"] export_string:SetPoint("bottomleft", DetailsCustomPanel, "bottomleft", 10, 8) - - local editbox = _detalhes.gump:NewTextEntry(custom_window, nil, "$parentImportBox", "ImportBox", CONST_EDITBOX_WIDTH - export_string.width - CONST_EDITBOX_BUTTON_WIDTH - 4, 20) + + local editbox = _detalhes.gump:NewTextEntry(customWindow, nil, "$parentImportBox", "ImportBox", CONST_EDITBOX_WIDTH - export_string.width - CONST_EDITBOX_BUTTON_WIDTH - 4, 20) editbox:SetPoint("left", export_string, "right", 2, 0) editbox:SetAutoFocus(false) editbox:SetTemplate(CONST_TEXTENTRY_TEMPLATE) - + local import = function() local text = editbox:GetText() - + local deserialized_object = Details:DecompressData (text, "print") - + if (not deserialized_object) then _detalhes:Msg(Loc ["STRING_CUSTOM_IMPORT_ERROR"]) - return + return end - + if (DetailsCustomPanel.CodeEditing) then DetailsCustomPanel:CancelFunc() end setmetatable(deserialized_object, _detalhes.atributo_custom) deserialized_object.__index = _detalhes.atributo_custom - + _detalhes.MicroButtonAlert.Text:SetText(Loc ["STRING_CUSTOM_IMPORT_ALERT"]) - _detalhes.MicroButtonAlert:SetPoint("bottom", custom_window.box0.acceptbutton.widget, "top", 0, 20) + _detalhes.MicroButtonAlert:SetPoint("bottom", customWindow.box0.acceptbutton.widget, "top", 0, 20) _detalhes.MicroButtonAlert:SetHeight(200) _detalhes.MicroButtonAlert:Show() - + DetailsCustomPanel:StartEdit (deserialized_object, true) - - custom_window.ImportBox:ClearFocus() - custom_window.ImportBox:Hide() - custom_window.exportLabel:Hide() - custom_window.ImportConfirm:Hide() + + customWindow.ImportBox:ClearFocus() + customWindow.ImportBox:Hide() + customWindow.exportLabel:Hide() + customWindow.ImportConfirm:Hide() end - - local okey_button = gump:NewButton(custom_window, nil, "$parentImportConfirm", "ImportConfirm", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, import, nil, nil, nil, Loc ["STRING_CUSTOM_IMPORT_BUTTON"]) + + local okey_button = gump:NewButton(customWindow, nil, "$parentImportConfirm", "ImportConfirm", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, import, nil, nil, nil, Loc ["STRING_CUSTOM_IMPORT_BUTTON"]) okey_button:SetTemplate(CONST_BUTTON_TEMPLATE) okey_button:SetPoint("left", editbox, "right", 2, 0) end - - if (custom_window.ExportBox) then - custom_window.ExportBox:Hide() + + if (customWindow.ExportBox) then + customWindow.ExportBox:Hide() end - - custom_window.ImportBox:SetText("") - custom_window.ImportBox:Show() - custom_window.exportLabel:Show() - custom_window.ImportConfirm:Show() - custom_window.ImportBox:SetFocus() - + + customWindow.ImportBox:SetText("") + customWindow.ImportBox:Show() + customWindow.exportLabel:Show() + customWindow.ImportConfirm:Show() + customWindow.ImportBox:SetFocus() + end - custom_window:CreateMenuButton (Loc ["STRING_CUSTOM_IMPORT"], "Interface\\ICONS\\INV_MISC_NOTE_02", import_display, nil, nil, nil, "Import", {0.00, 0.9, 0.07, 0.93}) --localize - + customWindow:CreateMenuButton (Loc ["STRING_CUSTOM_IMPORT"], "Interface\\ICONS\\INV_MISC_NOTE_02", import_display, nil, nil, nil, "Import", {0.00, 0.9, 0.07, 0.93}) --localize + local box_types = { {}, --normal {}, --custom script } - + local attributes = { --{icon = [[Interface\ICONS\Spell_Fire_Fireball02]], label = Loc ["STRING_CUSTOM_ATTRIBUTE_DAMAGE"], box = 1, attribute = "damagedone", boxtype = 1}, --{icon = [[Interface\ICONS\SPELL_NATURE_HEALINGTOUCH]], label = Loc ["STRING_CUSTOM_ATTRIBUTE_HEAL"], box = 1, attribute = "healdone", boxtype = 1}, {icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = Loc ["STRING_CUSTOM_ATTRIBUTE_SCRIPT"], box = 2, attribute = false, boxtype = 2}, - + --{icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = "Custom Script", box = 2, attribute = false, boxtype = 2}, --{icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = "Custom Script", box = 2, attribute = false, boxtype = 2}, --{icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = "Custom Script", box = 2, attribute = false, boxtype = 2}, @@ -944,13 +913,13 @@ --{icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = "Custom Script", box = 2, attribute = false, boxtype = 2}, --{icon = [[Interface\ICONS\INV_Inscription_Scroll]], label = "Custom Script", box = 2, attribute = false, boxtype = 2}, } - + --create box - local attribute_box = CreateFrame("frame", nil, custom_window) - attribute_box:SetPoint("topleft", custom_window, "topleft", 200, -60) + local attribute_box = CreateFrame("frame", nil, customWindow) + attribute_box:SetPoint("topleft", customWindow, "topleft", 200, -60) attribute_box:SetSize(180, 260) attribute_box:Hide() - + local button_onenter = function(self) self:SetBackdropColor(.3, .3, .3, .3) self.icon:SetBlendMode("ADD") @@ -959,114 +928,114 @@ self:SetBackdropColor(0, 0, 0, .2) self.icon:SetBlendMode("BLEND") end - + local selected_left = attribute_box:CreateTexture(nil, "overlay") selected_left:SetTexture([[Interface\Store\Store-Main]]) selected_left:SetSize(50, 20) selected_left:SetVertexColor(1, .8, 0, 1) selected_left:SetTexCoord(960/1024, 1020/1024, 68/1024, 101/1024) - custom_window.selected_left = selected_left - + customWindow.selected_left = selected_left + local selected_right = attribute_box:CreateTexture(nil, "overlay") selected_right:SetTexture([[Interface\Store\Store-Main]]) selected_right:SetSize(31, 20) selected_right:SetVertexColor(1, .8, 0, 1) selected_right:SetTexCoord(270/1024, 311/1024, 873/1024, 906/1024) - custom_window.selected_right = selected_right - + customWindow.selected_right = selected_right + local selected_center = attribute_box:CreateTexture(nil, "overlay") selected_center:SetTexture([[Interface\Store\Store-Main]]) selected_center:SetSize(49, 20) selected_center:SetVertexColor(1, .8, 0, 1) selected_center:SetTexCoord(956/1024, 1004/1024, 164/1024, 197/1024) - + selected_center:SetPoint("left", selected_left, "right") selected_center:SetPoint("right", selected_right, "left") - + local p = 0.0625 --32/512 - + for i = 1, 10 do - + if (attributes [i]) then - + local button = CreateFrame("button", "DetailsCustomPanelAttributeMenu" .. i, attribute_box, "BackdropTemplate") button:SetPoint("topleft", attribute_box, "topleft", 2, ((i-1)*23*-1) + (-26)) button:SetPoint("topright", attribute_box, "topright", 2, ((i-1)*23*-1) + (-26)) button:SetHeight(20) - + button:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16}) button:SetBackdropColor(0, 0, 0, .2) - + button:SetScript("OnEnter", button_onenter) button:SetScript("OnLeave", button_onleave) - + button.attribute_table = attributes [i] - + if (attributes [i] and not attributes [i].attribute) then - custom_window.script_button_attribute = button + customWindow.script_button_attribute = button end - + button:SetScript("OnClick", select_attribute) - + button.icon = button:CreateTexture(nil, "overlay") button.icon:SetPoint("left", button, "left", 6, 0) button.icon:SetSize(22, 22) button.icon:SetTexture([[Interface\AddOns\Details\images\custom_icones]]) button.icon:SetTexCoord(p*(i-1), p*(i), 0, 1) - + button.text = button:CreateFontString(nil, "overlay", "GameFontHighlightSmall") button.text:SetPoint("left", button.icon, "right", 4, 0) button.text:SetText(attributes [i] and attributes [i].label or "") button.text:SetTextColor(.9, .9, .9, 1) - + end end - + --create box 0, holds the name, author, desc and icon - local box0 = CreateFrame("frame", "DetailsCustomPanelBox0", custom_window) - custom_window.box0 = box0 + local box0 = CreateFrame("frame", "DetailsCustomPanelBox0", customWindow) + customWindow.box0 = box0 box0:SetSize(450, 360) - box0:SetPoint("topleft", custom_window, "topleft", CONST_INFOBOX_X_POSITION, CONST_MENU_Y_POSITION-4) - + box0:SetPoint("topleft", customWindow, "topleft", CONST_INFOBOX_X_POSITION, CONST_MENU_Y_POSITION-4) + --name local name_label = gump:NewLabel(box0, box0, "$parenNameLabel", "name", Loc ["STRING_CUSTOM_NAME"], "GameFontHighlightLeft") --localize-me name_label:SetPoint("topleft", box0, "topleft", 10, 0) - + local name_field = gump:NewTextEntry(box0, nil, "$parentNameEntry", "nameentry", 200, 20) name_field:SetPoint("left", name_label, "left", 62, 0) name_field:SetTemplate(CONST_TEXTENTRY_TEMPLATE) name_field.tooltip = Loc ["STRING_CUSTOM_NAME_DESC"] - custom_window.name_field = name_field - + customWindow.name_field = name_field + --author local author_label = gump:NewLabel(box0, box0, "$parenAuthorLabel", "author", Loc ["STRING_CUSTOM_AUTHOR"], "GameFontHighlightLeft") --localize-me author_label:SetPoint("topleft", name_label, "bottomleft", 0, -12) - + local author_field = gump:NewTextEntry(box0, nil, "$parentAuthorEntry", "authorentry", 200, 20) author_field:SetPoint("left", author_label, "left", 62, 0) author_field:SetTemplate(CONST_TEXTENTRY_TEMPLATE) author_field.tooltip = Loc ["STRING_CUSTOM_AUTHOR_DESC"] author_field:SetText(UnitName ("player") .. "-" .. GetRealmName()) - custom_window.author_field = author_field - + customWindow.author_field = author_field + --description local desc_label = gump:NewLabel(box0, box0, "$parenDescLabel", "desc", Loc ["STRING_CUSTOM_DESCRIPTION"], "GameFontHighlightLeft") --localize-me desc_label:SetPoint("topleft", author_label, "bottomleft", 0, -12) - + local desc_field = gump:NewTextEntry(box0, nil, "$parentDescEntry", "descentry", 200, 20) desc_field:SetPoint("left", desc_label, "left", 62, 0) desc_field:SetTemplate(CONST_TEXTENTRY_TEMPLATE) desc_field.tooltip = Loc ["STRING_CUSTOM_DESCRIPTION_DESC"] - custom_window.desc_field = desc_field + customWindow.desc_field = desc_field --icon local icon_label = gump:NewLabel(box0, box0, "$parenIconLabel", "icon", Loc ["STRING_CUSTOM_ICON"], "GameFontHighlightLeft") --localize-me icon_label:SetPoint("topleft", desc_label, "bottomleft", 0, -12) - + local pickicon_callback = function(texture) box0.icontexture:SetTexture(texture) - + end local pickicon = function() gump:IconPick (pickicon_callback, true) @@ -1076,33 +1045,33 @@ icon_button:InstallCustomTexture() icon_button:SetPoint("left", icon_label, "left", 64, 0) icon_image:SetPoint("left", icon_label, "left", 64, 0) - custom_window.icon_image = icon_image + customWindow.icon_image = icon_image --cancel local cancel_button = gump:NewButton(box0, nil, "$parentCancelButton", "cancelbutton", 130, 20, DetailsCustomPanel.CancelFunc, nil, nil, nil, Loc ["STRING_CUSTOM_CANCEL"]) --cancel_button:SetPoint("bottomleft", attribute_box, "bottomleft", 2, 0) cancel_button:SetPoint("topleft", icon_label, "bottomleft", 0, -10) cancel_button:SetTemplate(CONST_REGULAR_BUTTON_TEMPLATE) - + --accept local accept_button = gump:NewButton(box0, nil, "$parentAcceptButton", "acceptbutton", 130, 20, DetailsCustomPanel.AcceptFunc, nil, nil, nil, Loc ["STRING_CUSTOM_CREATE"]) accept_button:SetPoint("left", cancel_button, "right", 2, 0) accept_button:SetTemplate(CONST_REGULAR_BUTTON_TEMPLATE) - + cancel_button:SetFrameLevel(500) accept_button:SetFrameLevel(500) - + --create box type 1 - local box1 = CreateFrame("frame", "DetailsCustomPanelBox1", custom_window) - custom_window.box1 = box1 + local box1 = CreateFrame("frame", "DetailsCustomPanelBox1", customWindow) + customWindow.box1 = box1 box1:SetSize(450, 180) box1:SetPoint("topleft", icon_label.widget, "bottomleft", -10, -20) box1:SetFrameLevel(box0:GetFrameLevel()+1) - + --source local source_label = gump:NewLabel(box1, box1, "$parenSourceLabel", "source", Loc ["STRING_CUSTOM_SOURCE"], "GameFontHighlightLeft") --localize-me source_label:SetPoint("topleft", box1, "topleft", 10, 0) - + local disable_source_field = function() box1.sourceentry:Disable() end @@ -1110,9 +1079,9 @@ box1.sourceentry:Enable() box1.sourceentry:SetFocus(true) end - + local source_icon = [[Interface\COMMON\Indicator-Yellow]] - + local targeting_options = { {value = "[all]", label = "All Characters", desc = "Search for matches in all characters.", onclick = disable_source_field, icon = source_icon}, {value = "[raid]", label = "Raid or Party Group", desc = "Search for matches in all characters which is part of your party or raid group.", onclick = disable_source_field, icon = source_icon}, @@ -1123,17 +1092,17 @@ local source_dropdown = gump:NewDropDown (box1, nil, "$parentSourceDropdown", "sourcedropdown", 178, 20, build_source_list, 1) source_dropdown:SetPoint("left", source_label, "left", 62, 0) source_dropdown.tooltip = Loc ["STRING_CUSTOM_SOURCE_DESC"] - custom_window.source_dropdown = source_dropdown - + customWindow.source_dropdown = source_dropdown + local source_field = gump:NewTextEntry(box1, nil, "$parentSourceEntry", "sourceentry", 201, 20) source_field:SetPoint("topleft", source_dropdown, "bottomleft", 0, -2) source_field:Disable() - custom_window.source_field = source_field - + customWindow.source_field = source_field + local adds_boss = CreateFrame("frame", nil, box1) adds_boss:SetPoint("left", source_dropdown.widget, "right", 2, 0) adds_boss:SetSize(20, 20) - + local adds_boss_image = adds_boss:CreateTexture(nil, "overlay") adds_boss_image:SetPoint("center", adds_boss) adds_boss_image:SetTexture("Interface\\Buttons\\UI-MicroButton-Raid-Up") @@ -1141,31 +1110,31 @@ adds_boss_image:SetWidth(20) adds_boss_image:SetHeight(16) - local actorsFrame = gump:NewPanel(custom_window, _, "DetailsCustomActorsFrame2", "actorsFrame", 1, 1) - actorsFrame:SetPoint("topleft", custom_window, "topright", 5, -60) + local actorsFrame = gump:NewPanel(customWindow, _, "DetailsCustomActorsFrame2", "actorsFrame", 1, 1) + actorsFrame:SetPoint("topleft", customWindow, "topright", 5, -60) actorsFrame:Hide() - - local modelFrame = CreateFrame("playermodel", "DetailsCustomActorsFrame2Model", custom_window) + + local modelFrame = CreateFrame("playermodel", "DetailsCustomActorsFrame2Model", customWindow) modelFrame:SetSize(138, 261) modelFrame:SetPoint("topright", actorsFrame.widget, "topleft", -15, -8) modelFrame:Hide() local modelFrameTexture = modelFrame:CreateTexture(nil, "background") modelFrameTexture:SetAllPoints() - - local modelFrameBackground = custom_window:CreateTexture(nil, "artwork") + + local modelFrameBackground = customWindow:CreateTexture(nil, "artwork") modelFrameBackground:SetSize(138, 261) modelFrameBackground:SetPoint("topright", actorsFrame.widget, "topleft", -15, -8) modelFrameBackground:SetTexture([[Interface\ACHIEVEMENTFRAME\UI-GuildAchievement-Parchment-Horizontal-Desaturated]]) modelFrameBackground:SetRotation (90) modelFrameBackground:SetVertexColor(.5, .5, .5, 0.5) - - local modelFrameBackgroundIcon = custom_window:CreateTexture(nil, "overlay") + + local modelFrameBackgroundIcon = customWindow:CreateTexture(nil, "overlay") modelFrameBackgroundIcon:SetPoint("center", modelFrameBackground, "center") modelFrameBackgroundIcon:SetTexture([[Interface\CHARACTERFRAME\Disconnect-Icon]]) modelFrameBackgroundIcon:SetVertexColor(.5, .5, .5, 0.7) modelFrameBackground:Hide() modelFrameBackgroundIcon:Hide() - + local selectedEncounterActor = function(actorName, model) source_field:SetText(actorName) source_dropdown:Select(4, true) @@ -1173,7 +1142,7 @@ actorsFrame:Hide() GameCooltip:Hide() end - + local actorsFrameButtons = {} local buttonMouseOver = function(button) @@ -1183,13 +1152,13 @@ GameTooltip:SetOwner(button, "ANCHOR_TOPLEFT") GameTooltip:AddLine(button.MyObject.actor) GameTooltip:Show() - + local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (button.MyObject.ej_id) - + modelFrameTexture:SetTexture(bgImage) modelFrameTexture:SetTexCoord(3/512, 370/512, 5/512, 429/512) modelFrame:Show() - + modelFrame:SetDisplayInfo (button.MyObject.model) end local buttonMouseOut = function(button) @@ -1199,64 +1168,64 @@ GameTooltip:Hide() modelFrame:Hide() end - + local EncounterSelect = function(_, _, instanceId, bossIndex, ej_id) - + DetailsCustomSpellsFrame:Hide() DetailsCustomActorsFrame:Hide() DetailsCustomActorsFrame2:Show() GameCooltip:Hide() - + local encounterID = _detalhes:GetEncounterIdFromBossIndex (instanceId, bossIndex) - + if (encounterID) then local actors = _detalhes:GetEncounterActorsName (encounterID) local x = 10 local y = 10 local i = 1 - - for actor, actorTable in pairs(actors) do - + + for actor, actorTable in pairs(actors) do + local thisButton = actorsFrameButtons [i] - + if (not thisButton) then thisButton = gump:NewButton(actorsFrame.frame, actorsFrame.frame, "DetailsCustomActorsFrame2Button"..i, "button"..i, 130, 20, selectedEncounterSpell) thisButton:SetPoint("topleft", "DetailsCustomActorsFrame2", "topleft", x, -y) thisButton:SetHook("OnEnter", buttonMouseOver) thisButton:SetHook("OnLeave", buttonMouseOut) - + local t = gump:NewImage(thisButton, nil, 20, 20, nil, nil, "image", "DetailsCustomActors2EncounterImageButton"..i) t:SetPoint("left", thisButton) t:SetTexture([[Interface\MINIMAP\TRACKING\Target]]) t:SetDesaturated(true) t:SetSize(20, 20) t:SetAlpha(0.7) - + local text = gump:NewLabel(thisButton, nil, "DetailsCustomActorsFrame2Button"..i.."Label", "label", "Spell", nil, 9.5, {.8, .8, .8, .8}) text:SetPoint("left", t.image, "right", 2, 0) text:SetWidth(123) text:SetHeight(10) - + local border = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 40, 38, nil, nil, "border", "DetailsCustomActors2EncounterBorderButton"..i) border:SetTexCoord(0.00390625, 0.27734375, 0.44140625,0.69531250) border:SetDrawLayer("background") border:SetPoint("topleft", thisButton.button, "topleft", -9, 9) - + local line = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 134, 25, nil, nil, "line", "DetailsCustomActors2EncounterLineButton"..i) line:SetTexCoord(0.31250000, 0.96484375, 0.37109375, 0.52343750) line:SetDrawLayer("background") line:SetPoint("left", thisButton.button, "right", -110, -3) - + table.insert(actorsFrameButtons, #actorsFrameButtons+1, thisButton) end - + y = y + 20 if (y >= 260) then y = 10 x = x + 150 end - + thisButton.label:SetText(actor) thisButton:SetClickFunction(selectedEncounterActor, actor, actorTable.model) thisButton.actor = actor @@ -1265,64 +1234,64 @@ thisButton:Show() i = i + 1 end - + for maxIndex = i, #actorsFrameButtons do actorsFrameButtons [maxIndex]:Hide() end - + i = i-1 actorsFrame:SetSize(math.ceil (i/13)*160, math.min (i*20 + 20, 280)) - + end end - + local BuildEncounterMenu = function() - + GameCooltip:Reset() GameCooltip:SetType ("menu") GameCooltip:SetOwner(adds_boss) - for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do - + for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do + if (_detalhes:InstanceIsRaid (instanceId)) then - + GameCooltip:AddLine(instanceTable.name, _, 1, "white") GameCooltip:AddIcon (instanceTable.icon, 1, 1, 64, 32) - for index, encounterName in ipairs(instanceTable.boss_names) do + for index, encounterName in ipairs(instanceTable.boss_names) do GameCooltip:AddMenu (2, EncounterSelect, instanceId, index, instanceTable.ej_id, encounterName, nil, true) local L, R, T, B, Texture = _detalhes:GetBossIcon (instanceId, index) GameCooltip:AddIcon (Texture, 2, 1, 20, 20, L, R, T, B) end - + GameCooltip:SetWallpaper (2, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + end end - + GameCooltip:SetOption("HeightAnchorMod", -10) GameCooltip:SetOption("ButtonsYMod", -2) GameCooltip:SetOption("YSpacingMod", 0) GameCooltip:SetOption("TextHeightMod", 0) GameCooltip:SetOption("IgnoreButtonAutoHeight", false) GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + GameCooltip:ShowCooltip() end - - adds_boss:SetScript("OnEnter", function() + + adds_boss:SetScript("OnEnter", function() adds_boss_image:SetBlendMode("ADD") BuildEncounterMenu() end) - - adds_boss:SetScript("OnLeave", function() + + adds_boss:SetScript("OnLeave", function() adds_boss_image:SetBlendMode("BLEND") end) - + --target local target_label = gump:NewLabel(box1, box1, "$parenTargetLabel", "target", Loc ["STRING_CUSTOM_TARGET"], "GameFontHighlightLeft") target_label:SetPoint("topleft", source_label, "bottomleft", 0, -40) - + local disable_target_field = function() box1.targetentry:Disable() end @@ -1330,10 +1299,10 @@ box1.targetentry:Enable() box1.targetentry:SetFocus(true) end - + local target_icon = [[Interface\COMMON\Indicator-Yellow]] local target_icon2 = [[Interface\COMMON\Indicator-Gray]] - + local targeting_options = { {value = "[all]", label = "All Characters", desc = "Search for matches in all characters.", onclick = disable_target_field, icon = target_icon}, {value = "[raid]", label = "Raid or Party Group", desc = "Search for matches in all characters which is part of your party or raid group.", onclick = disable_target_field, icon = target_icon}, @@ -1345,14 +1314,14 @@ local target_dropdown = gump:NewDropDown (box1, nil, "$parentTargetDropdown", "targetdropdown", 178, 20, build_target_list, 1) target_dropdown:SetPoint("left", target_label, "left", 62, 0) target_dropdown.tooltip = Loc ["STRING_CUSTOM_TARGET_DESC"] - custom_window.target_dropdown = target_dropdown - + customWindow.target_dropdown = target_dropdown + local target_field = gump:NewTextEntry(box1, nil, "$parentTargetEntry", "targetentry", 201, 20) target_field:SetPoint("topleft", target_dropdown, "bottomleft", 0, -2) target_field:Disable() - custom_window.target_field = target_field + customWindow.target_field = target_field -- - + local adds_boss = CreateFrame("frame", nil, box1) adds_boss:SetPoint("left", target_dropdown.widget, "right", 2, 0) adds_boss:SetSize(20, 20) @@ -1362,18 +1331,18 @@ adds_boss_image:SetTexCoord(0.046875, 0.90625, 0.40625, 0.953125) adds_boss_image:SetWidth(20) adds_boss_image:SetHeight(16) - - local actorsFrame = gump:NewPanel(custom_window, _, "DetailsCustomActorsFrame", "actorsFrame", 1, 1) - actorsFrame:SetPoint("topleft", custom_window, "topright", 5, -60) + + local actorsFrame = gump:NewPanel(customWindow, _, "DetailsCustomActorsFrame", "actorsFrame", 1, 1) + actorsFrame:SetPoint("topleft", customWindow, "topright", 5, -60) actorsFrame:Hide() - - local modelFrame = CreateFrame("playermodel", "DetailsCustomActorsFrameModel", custom_window) + + local modelFrame = CreateFrame("playermodel", "DetailsCustomActorsFrameModel", customWindow) modelFrame:SetSize(138, 261) modelFrame:SetPoint("topright", actorsFrame.widget, "topleft", -15, -8) modelFrame:Hide() local modelFrameTexture = modelFrame:CreateTexture(nil, "background") modelFrameTexture:SetAllPoints() - + local selectedEncounterActor = function(actorName) target_field:SetText(actorName) target_dropdown:Select(4, true) @@ -1381,7 +1350,7 @@ actorsFrame:Hide() GameCooltip:Hide() end - + local actorsFrameButtons = {} local buttonMouseOver = function(button) @@ -1391,13 +1360,13 @@ GameTooltip:SetOwner(button, "ANCHOR_TOPLEFT") GameTooltip:AddLine(button.MyObject.actor) GameTooltip:Show() - + local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (button.MyObject.ej_id) - + modelFrameTexture:SetTexture(bgImage) modelFrameTexture:SetTexCoord(3/512, 370/512, 5/512, 429/512) modelFrame:Show() - + modelFrame:SetDisplayInfo (button.MyObject.model) end local buttonMouseOut = function(button) @@ -1405,17 +1374,17 @@ button.MyObject.line:SetBlendMode("BLEND") button.MyObject.label:SetTextColor(.8, .8, .8, .8) GameTooltip:Hide() - + modelFrame:Hide() end - + local EncounterSelect = function(_, _, instanceId, bossIndex, ej_id) - + DetailsCustomSpellsFrame:Hide() DetailsCustomActorsFrame:Show() DetailsCustomActorsFrame2:Hide() GameCooltip:Hide() - + local encounterID = _detalhes:GetEncounterIdFromBossIndex (instanceId, bossIndex) if (encounterID) then local actors = _detalhes:GetEncounterActorsName (encounterID) @@ -1423,48 +1392,48 @@ local x = 10 local y = 10 local i = 1 - - for actor, actorTable in pairs(actors) do - + + for actor, actorTable in pairs(actors) do + local thisButton = actorsFrameButtons [i] - + if (not thisButton) then thisButton = gump:NewButton(actorsFrame.frame, actorsFrame.frame, "DetailsCustomActorsFrameButton"..i, "button"..i, 130, 20, selectedEncounterSpell) thisButton:SetPoint("topleft", "DetailsCustomActorsFrame", "topleft", x, -y) thisButton:SetHook("OnEnter", buttonMouseOver) thisButton:SetHook("OnLeave", buttonMouseOut) - + local t = gump:NewImage(thisButton, nil, 20, 20, nil, nil, "image", "DetailsCustomActorsEncounterImageButton"..i) t:SetPoint("left", thisButton) t:SetTexture([[Interface\MINIMAP\TRACKING\Target]]) t:SetDesaturated(true) t:SetSize(20, 20) t:SetAlpha(0.7) - + local text = gump:NewLabel(thisButton, nil, "DetailsCustomActorsFrameButton"..i.."Label", "label", "Spell", nil, 9.5, {.8, .8, .8, .8}) text:SetPoint("left", t.image, "right", 2, 0) text:SetWidth(123) text:SetHeight(10) - + local border = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 40, 38, nil, nil, "border", "DetailsCustomActorsEncounterBorderButton"..i) border:SetTexCoord(0.00390625, 0.27734375, 0.44140625,0.69531250) border:SetDrawLayer("background") border:SetPoint("topleft", thisButton.button, "topleft", -9, 9) - + local line = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 84, 25, nil, nil, "line", "DetailsCustomActorsEncounterLineButton"..i) line:SetTexCoord(0.31250000, 0.96484375, 0.37109375, 0.52343750) line:SetDrawLayer("background") line:SetPoint("left", thisButton.button, "right", -110, -3) - + table.insert(actorsFrameButtons, #actorsFrameButtons+1, thisButton) end - + y = y + 20 if (y >= 260) then y = 10 x = x + 150 end - + thisButton.label:SetText(actor) thisButton:SetClickFunction(selectedEncounterActor, actor) thisButton.actor = actor @@ -1473,41 +1442,41 @@ thisButton:Show() i = i + 1 end - + for maxIndex = i, #actorsFrameButtons do actorsFrameButtons [maxIndex]:Hide() end - + i = i-1 actorsFrame:SetSize(math.ceil (i/13)*160, math.min (i*20 + 20, 280)) - + end end - + local BuildEncounterMenu = function() - + GameCooltip:Reset() GameCooltip:SetType ("menu") GameCooltip:SetOwner(adds_boss) - - for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do - + + for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do + if (_detalhes:InstanceIsRaid (instanceId)) then - + GameCooltip:AddLine(instanceTable.name, _, 1, "white") GameCooltip:AddIcon (instanceTable.icon, 1, 1, 64, 32) - for index, encounterName in ipairs(instanceTable.boss_names) do + for index, encounterName in ipairs(instanceTable.boss_names) do GameCooltip:AddMenu (2, EncounterSelect, instanceId, index, instanceTable.ej_id, encounterName, nil, true) local L, R, T, B, Texture = _detalhes:GetBossIcon (instanceId, index) GameCooltip:AddIcon (Texture, 2, 1, 20, 20, L, R, T, B) end - + GameCooltip:SetWallpaper (2, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + end end - + GameCooltip:SetOption("HeightAnchorMod", -10) GameCooltip:SetOption("ButtonsYMod", -2) GameCooltip:SetOption("YSpacingMod", 0) @@ -1516,25 +1485,25 @@ GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) GameCooltip:ShowCooltip() end - - adds_boss:SetScript("OnEnter", function() + + adds_boss:SetScript("OnEnter", function() adds_boss_image:SetBlendMode("ADD") BuildEncounterMenu() end) - - adds_boss:SetScript("OnLeave", function() + + adds_boss:SetScript("OnLeave", function() adds_boss_image:SetBlendMode("BLEND") - end) - + end) + --spellid local spellid_label = gump:NewLabel(box1, box1, "$parenSpellidLabel", "spellid", Loc ["STRING_CUSTOM_SPELLID"], "GameFontHighlightLeft") --localize-me spellid_label:SetPoint("topleft", target_label, "bottomleft", 0, -40) - + local spellid_entry = gump:NewSpellEntry (box1, function()end, 178, 20, nil, nil, "spellidentry", "$parentSpellIdEntry") spellid_entry:SetPoint("left", spellid_label, "left", 62, 0) spellid_entry.tooltip = Loc ["STRING_CUSTOM_SPELLID_DESC"] - custom_window.spellid_entry = spellid_entry - + customWindow.spellid_entry = spellid_entry + local spell_id_boss = CreateFrame("frame", nil, box1) spell_id_boss:SetPoint("left", spellid_entry.widget, "right", 2, 0) spell_id_boss:SetSize(20, 20) @@ -1544,11 +1513,11 @@ spell_id_boss_image:SetTexCoord(0.046875, 0.90625, 0.40625, 0.953125) spell_id_boss_image:SetWidth(20) spell_id_boss_image:SetHeight(16) - - local spellsFrame = gump:NewPanel(custom_window, _, "DetailsCustomSpellsFrame", "spellsFrame", 1, 1) - spellsFrame:SetPoint("topleft", custom_window, "topright", 5, 0) + + local spellsFrame = gump:NewPanel(customWindow, _, "DetailsCustomSpellsFrame", "spellsFrame", 1, 1) + spellsFrame:SetPoint("topleft", customWindow, "topright", 5, 0) spellsFrame:Hide() - + local selectedEncounterSpell = function(spellId) local _, _, icon = _GetSpellInfo(spellId) spellid_entry:SetText(spellId) @@ -1556,7 +1525,7 @@ spellsFrame:Hide() GameCooltip:Hide() end - + local spellsFrameButtons = {} local buttonMouseOver = function(button) @@ -1574,58 +1543,58 @@ button.MyObject.label:SetTextColor(.8, .8, .8, .8) GameTooltip:Hide() end - + local EncounterSelect = function(_, _, instanceId, bossIndex) - + DetailsCustomSpellsFrame:Show() DetailsCustomActorsFrame:Hide() DetailsCustomActorsFrame2:Hide() - + GameCooltip:Hide() - + local spells = _detalhes:GetEncounterSpells (instanceId, bossIndex) - + local x = 10 local y = 10 local i = 1 - - for spell, _ in pairs(spells) do - + + for spell, _ in pairs(spells) do + local thisButton = spellsFrameButtons [i] - + if (not thisButton) then thisButton = gump:NewButton(spellsFrame.frame, spellsFrame.frame, "DetailsCustomSpellsFrameButton"..i, "button"..i, 80, 20, selectedEncounterSpell) thisButton:SetPoint("topleft", "DetailsCustomSpellsFrame", "topleft", x, -y) thisButton:SetHook("OnEnter", buttonMouseOver) thisButton:SetHook("OnLeave", buttonMouseOut) - + local t = gump:NewImage(thisButton, nil, 20, 20, nil, nil, "image", "DetailsCustomEncounterImageButton"..i) t:SetPoint("left", thisButton) - + local text = gump:NewLabel(thisButton, nil, "DetailsCustomSpellsFrameButton"..i.."Label", "label", "Spell", nil, 9.5, {.8, .8, .8, .8}) text:SetPoint("left", t.image, "right", 2, 0) text:SetWidth(73) text:SetHeight(10) - + local border = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 40, 38, nil, nil, "border", "DetailsCustomEncounterBorderButton"..i) border:SetTexCoord(0.00390625, 0.27734375, 0.44140625,0.69531250) border:SetDrawLayer("background") border:SetPoint("topleft", thisButton.button, "topleft", -9, 9) - + local line = gump:NewImage(thisButton, "Interface\\SPELLBOOK\\Spellbook-Parts", 84, 25, nil, nil, "line", "DetailsCustomEncounterLineButton"..i) line:SetTexCoord(0.31250000, 0.96484375, 0.37109375, 0.52343750) line:SetDrawLayer("background") line:SetPoint("left", thisButton.button, "right", -60, -3) - + table.insert(spellsFrameButtons, #spellsFrameButtons+1, thisButton) end - + y = y + 20 if (y >= 400) then y = 10 x = x + 100 end - + local nome_magia, _, icone_magia = _GetSpellInfo(spell) thisButton.image:SetTexture(icone_magia) thisButton.label:SetText(nome_magia) @@ -1634,104 +1603,122 @@ thisButton:Show() i = i + 1 end - + for maxIndex = i, #spellsFrameButtons do spellsFrameButtons [maxIndex]:Hide() end - + i = i-1 spellsFrame:SetSize(math.ceil (i/20)*110, math.min (i*20 + 20, 420)) - + end - + local BuildEncounterMenu = function() - + GameCooltip:Reset() GameCooltip:SetType ("menu") GameCooltip:SetOwner(spell_id_boss) - - for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do - + + for instanceId, instanceTable in pairs(_detalhes.EncounterInformation) do + if (_detalhes:InstanceisRaid (instanceId)) then - + GameCooltip:AddLine(instanceTable.name, _, 1, "white") GameCooltip:AddIcon (instanceTable.icon, 1, 1, 64, 32) - for index, encounterName in ipairs(instanceTable.boss_names) do + for index, encounterName in ipairs(instanceTable.boss_names) do GameCooltip:AddMenu (2, EncounterSelect, instanceId, index, nil, encounterName, nil, true) local L, R, T, B, Texture = _detalhes:GetBossIcon (instanceId, index) GameCooltip:AddIcon (Texture, 2, 1, 20, 20, L, R, T, B) end - + GameCooltip:SetWallpaper (2, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + end end - + GameCooltip:SetOption("ButtonsYMod", -2) GameCooltip:SetOption("YSpacingMod", 0) GameCooltip:SetOption("TextHeightMod", 0) GameCooltip:SetOption("IgnoreButtonAutoHeight", false) GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true) - + GameCooltip:SetOption("HeightAnchorMod", -10) GameCooltip:ShowCooltip() end - - spell_id_boss:SetScript("OnEnter", function() + + spell_id_boss:SetScript("OnEnter", function() spell_id_boss_image:SetBlendMode("ADD") BuildEncounterMenu() end) - - spell_id_boss:SetScript("OnLeave", function() + + spell_id_boss:SetScript("OnLeave", function() spell_id_boss_image:SetBlendMode("BLEND") end) - + --select target --select spell - + --create box type 2 - local box2 = CreateFrame("frame", "DetailsCustomPanelBox2", custom_window) - custom_window.box2 = box2 + local box2 = CreateFrame("frame", "DetailsCustomPanelBox2", customWindow) + customWindow.box2 = box2 box2:SetSize(450, 180) box2:SetPoint("topleft", icon_label.widget, "bottomleft", -10, -20) - + box2:SetFrameLevel(box0:GetFrameLevel()+1) - + --edit main code local maincode_button = gump:NewButton(box2, nil, "$parentMainCodeButton", "maiccodebutton", 160, 20, DetailsCustomPanel.StartEditCode, 1, nil, nil, Loc ["STRING_CUSTOM_EDIT_SEARCH_CODE"]) - maincode_button:SetPoint("topleft", custom_window, "topleft", CONST_EDITBUTTONS_X_POSITION, CONST_MENU_Y_POSITION) + maincode_button:SetPoint("topleft", customWindow, "topleft", CONST_EDITBUTTONS_X_POSITION, CONST_MENU_Y_POSITION) maincode_button.tooltip = Loc ["STRING_CUSTOM_EDITCODE_DESC"] maincode_button:SetTemplate(CONST_CODETEXTENTRY_OPENCODEBUTTONS_TEMPLATE) - + --edit tooltip code local tooltipcode_button = gump:NewButton(box2, nil, "$parentTooltipCodeButton", "tooltipcodebutton", 160, 20, DetailsCustomPanel.StartEditCode, 2, nil, nil, Loc ["STRING_CUSTOM_EDIT_TOOLTIP_CODE"]) tooltipcode_button:SetPoint("topleft", maincode_button, "bottomleft", 0, -8) tooltipcode_button.tooltip = Loc ["STRING_CUSTOM_EDITTOOLTIP_DESC"] tooltipcode_button:SetTemplate(CONST_CODETEXTENTRY_OPENCODEBUTTONS_TEMPLATE) - + --edit total code local totalcode_button = gump:NewButton(box2, nil, "$parentTotalCodeButton", "totalcodebutton", 160, 20, DetailsCustomPanel.StartEditCode, 3, nil, nil, "Edit Total Code") totalcode_button:SetPoint("topleft", tooltipcode_button, "bottomleft", 0, -8) totalcode_button.tooltip = "This code is responsible for edit the total number shown in the player bar.\n\nThis is not necessary if you want show exactly the value gotten in the search code." totalcode_button:SetTemplate(CONST_CODETEXTENTRY_OPENCODEBUTTONS_TEMPLATE) - + --edit percent code local percentcode_button = gump:NewButton(box2, nil, "$parentPercentCodeButton", "percentcodebutton", 160, 20, DetailsCustomPanel.StartEditCode, 4, nil, nil, "Edit Percent Code") percentcode_button:SetPoint("topleft", totalcode_button, "bottomleft", 0, -8) percentcode_button.tooltip = "Edit the code responsible for the percent number in the player bar.\n\nThis is not required if you want to use simple percentage (comparing with total)." percentcode_button:SetTemplate(CONST_CODETEXTENTRY_OPENCODEBUTTONS_TEMPLATE) - + box2:Hide() - - --create the code editbox - local code_editor = gump:NewSpecialLuaEditorEntry(custom_window, CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT, "codeeditor", "$parentCodeEditor") - code_editor:SetPoint("topleft", custom_window, "topleft", CONST_MENU_X_POSITION, CONST_EDITBOX_Y_POSITION) - code_editor:SetFrameLevel(custom_window:GetFrameLevel()+4) - code_editor:SetBackdrop(nil) - code_editor:HookScript ("OnUpdate", function() - local script = code_editor:GetText() - local func, errortext = loadstring (script) + + --create the code editbox + local codeEditor = gump:NewSpecialLuaEditorEntry(customWindow, CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT, "codeeditor", "$parentCodeEditor", false, true) + codeEditor:SetPoint("topleft", customWindow, "topleft", CONST_MENU_X_POSITION, CONST_EDITBOX_Y_POSITION) + codeEditor:SetFrameLevel(customWindow:GetFrameLevel()+4) + codeEditor:SetBackdrop(nil) + codeEditor.scroll:SetBackdrop(nil) + codeEditor.editbox:SetBackdrop(nil) + DetailsFramework:ReskinSlider(codeEditor.scroll) + + if (not codeEditor.__background) then + codeEditor.__background = codeEditor:CreateTexture(nil, "background") + end + + codeEditor:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}) + codeEditor:SetBackdropBorderColor(0, 0, 0, 1) + + codeEditor.__background:SetColorTexture(0.2317647, 0.2317647, 0.2317647) + codeEditor.__background:SetVertexColor(0.27, 0.27, 0.27) + codeEditor.__background:SetAlpha(0.8) + codeEditor.__background:SetVertTile(true) + codeEditor.__background:SetHorizTile(true) + codeEditor.__background:SetAllPoints() + + codeEditor:HookScript("OnUpdate", function() + local script = codeEditor:GetText() + local func, errortext = loadstring(script) if (not func) then local firstLine = strsplit("\n", script, 2) errortext = errortext:gsub(firstLine, "") @@ -1742,84 +1729,83 @@ else DetailsCustomPanel.ErrorString.text = "" end - -- end) - + --create a background area where the code editor is - local codeEditorBackground = gump:NewButton(custom_window, nil, nil, nil, 1, 1, function()end) - codeEditorBackground:SetAllPoints(code_editor) + local codeEditorBackground = gump:NewButton(customWindow, nil, nil, nil, 1, 1, function()end) + codeEditorBackground:SetAllPoints(codeEditor) codeEditorBackground:SetTemplate(CONST_CODETEXTENTRY_TEMPLATE) - - code_editor:Hide() - code_editor.font_size = 11 - - local file, size, flags = code_editor.editbox:GetFont() - code_editor.editbox:SetFont(file, 11, flags) - + + codeEditor:Hide() + codeEditor.font_size = 11 + + local file, size, flags = codeEditor.editbox:GetFont() + codeEditor.editbox:SetFont(file, 11, flags) + local expand_func = function() - if (code_editor.expanded) then - code_editor:SetSize(CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT) - code_editor.expanded = nil + if (codeEditor.expanded) then + codeEditor:SetSize(CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT) + codeEditor.expanded = nil codeEditorBackground:SetTemplate(CONST_CODETEXTENTRY_TEMPLATE) - + --custom_window.box0.cancelbutton:SetPoint("bottomleft", attribute_box, "bottomright", 37, -10) --custom_window.box0.acceptbutton:SetPoint("left", cancel_button, "right", 2, 0) else - code_editor:SetSize(CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT*1.9) - code_editor.expanded = true + codeEditor:SetSize(CONST_EDITBOX_WIDTH, CONST_EDITBOX_HEIGHT*1.9) + codeEditor.expanded = true codeEditorBackground:SetTemplate(CONST_CODETEXTENTRYEXPANDED_TEMPLATE) - + --custom_window.box0.cancelbutton:SetPoint("bottomleft", attribute_box, "bottomright", -237, -10) --custom_window.box0.acceptbutton:SetPoint end end - + local font_change = function(_, _, increase) if (increase) then - local file, size, flags = code_editor.editbox:GetFont() - code_editor.font_size = code_editor.font_size + 1 - code_editor.editbox:SetFont(file, code_editor.font_size, flags) + local file, size, flags = codeEditor.editbox:GetFont() + codeEditor.font_size = codeEditor.font_size + 1 + codeEditor.editbox:SetFont(file, codeEditor.font_size, flags) else - local file, size, flags = code_editor.editbox:GetFont() - code_editor.font_size = code_editor.font_size - 1 - code_editor.editbox:SetFont(file, code_editor.font_size, flags) + local file, size, flags = codeEditor.editbox:GetFont() + codeEditor.font_size = codeEditor.font_size - 1 + codeEditor.editbox:SetFont(file, codeEditor.font_size, flags) end end - + local apply_code = function() - + _detalhes:ResetCustomFunctionsCache() - + if (DetailsCustomPanel.CodeEditing == 1) then - DetailsCustomPanel.code1 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code1 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 2) then - DetailsCustomPanel.code2 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code2 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 3) then - DetailsCustomPanel.code3 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code3 = customWindow.codeeditor:GetText() elseif (DetailsCustomPanel.CodeEditing == 4) then - DetailsCustomPanel.code4 = custom_window.codeeditor:GetText() + DetailsCustomPanel.code4 = customWindow.codeeditor:GetText() end - + local main_code = DetailsCustomPanel.code1 local tooltip_code = DetailsCustomPanel.code2 local total_code = DetailsCustomPanel.code3 local percent_code = DetailsCustomPanel.code4 - + local object = DetailsCustomPanel.IsEditing - + if (type(object) ~= "table") then return _detalhes:Msg("This object need to be saved before.") end - + object.script = main_code object.tooltip = tooltip_code - + if (total_code ~= DetailsCustomPanel.code3_default) then object.total_script = total_code else object.total_script = false end - + if (percent_code ~= DetailsCustomPanel.code4_default) then object.percent_script = percent_code else @@ -1828,56 +1814,56 @@ return true end - - local supportFrame = CreateFrame("frame", "$parentSupportFrame", custom_window) + + local supportFrame = CreateFrame("frame", "$parentSupportFrame", customWindow) supportFrame:SetFrameLevel(500) - + local expand = gump:NewButton(supportFrame, nil, "$parentExpand", "expandbutton", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, expand_func, 4, nil, nil, "Expand") - expand:SetPoint("bottomleft", code_editor, "topleft", 0, 1) + expand:SetPoint("bottomleft", codeEditor, "topleft", 0, 1) expand:SetTemplate(CONST_CODETEXTENTRYBUTTON_TEMPLATE) - + local font_size1 = gump:NewButton(supportFrame, nil, "$parentFont1", "font1button", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, font_change, nil, nil, nil, "Aa") font_size1:SetPoint("left", expand, "right", 2, 0) font_size1:SetTemplate(CONST_CODETEXTENTRYBUTTON_TEMPLATE) - + local font_size2 = gump:NewButton(supportFrame, nil, "$parentFont2", "font2button", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, font_change, true, nil, nil, "aA") font_size2:SetPoint("left", font_size1, "right", 2, 0) font_size2:SetTemplate(CONST_CODETEXTENTRYBUTTON_TEMPLATE) - + local apply1 = gump:NewButton(supportFrame, nil, "$parentApply", "applybutton", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, apply_code, nil, nil, nil, "Apply") apply1:SetPoint("left", font_size2, "right", 2, 0) apply1:SetTemplate(CONST_CODETEXTENTRYBUTTON_TEMPLATE) - + local open_API = gump:NewButton(supportFrame, nil, "$parentOpenAPI", "openAPIbutton", CONST_EDITBOX_BUTTON_WIDTH, CONST_EDITBOX_BUTTON_HEIGHT, function()end, nil, nil, nil, "API") --_detalhes.OpenAPI - opening the api was cancelling the editing process open_API:SetPoint("left", apply1, "right", 2, 0) open_API:SetTemplate(CONST_CODETEXTENTRYBUTTON_TEMPLATE) - + local errorString = gump:CreateLabel(supportFrame) errorString:SetPoint("left", open_API, "right", 10, 0) errorString.color = "red" DetailsCustomPanel.ErrorString = errorString - - code_editor:SetScript("OnShow", function() + + codeEditor:SetScript("OnShow", function() expand:Show() font_size1:Show() font_size2:Show() apply1:Show() open_API:Show() end) - code_editor:SetScript("OnHide", function() + codeEditor:SetScript("OnHide", function() expand:Hide() font_size1:Hide() font_size2:Hide() apply1:Hide() open_API:Hide() end) - + expand:Hide() font_size1:Hide() font_size2:Hide() apply1:Hide() open_API:Hide() - + --select damage DetailsCustomPanelAttributeMenu1:Click() else @@ -1885,4 +1871,4 @@ --_G.DetailsCustomPanel:Show() end end - + diff --git a/functions/mixin.lua b/functions/mixin.lua new file mode 100644 index 000000000..634f0ec96 --- /dev/null +++ b/functions/mixin.lua @@ -0,0 +1,21 @@ + +local Details = _G.Details +local detailsFramework = _G.DetailsFramework +local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0", true) +local addonName, Details222 = ... + + +Details222.Mixins.ActorMixin = { + GetSpellContainer = function(self, containerType) + if (containerType == "debuff") then + return self.debuff_uptime_spells + + elseif (containerType == "buff") then + return self.buff_uptime_spells + + elseif (containerType == "spell") then + return self.spells + end + + end, +} \ No newline at end of file diff --git a/functions/slash.lua b/functions/slash.lua index bf515d670..284c391c0 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -2044,12 +2044,80 @@ function _detalhes:CreateListPanel() end +--this table store addons which want to replace the keystone command +--more than one addon can be registered and all of them will be called when the user type /keystone +--is up to the user to decide which addon to use +local keystoneCallbacks = {} + +---register an addon and a callback function to be called when the user type /keystone +---@param addonObject table +---@param memberName string +---@param ... any +---@return boolean true if the addon was registered, false if it was already registered and got unregistered +function Details:ReplaceKeystoneCommand(addonObject, memberName, ...) + --check if the parameters passed are valid types + if (type(addonObject) ~= "table") then + error("Details:ReplaceKeystoneCommand: addonObject must be a table") + + elseif (type(memberName) ~= "string") then + error("Details:ReplaceKeystoneCommand: memberName must be a string") + + elseif (type(addonObject[memberName]) ~= "function") then + error("Details:ReplaceKeystoneCommand: t[memberName] doesn't point to a function.") + end + + --check if the addonObject is already registered and remove it + for i = #keystoneCallbacks, 1, -1 do + if (keystoneCallbacks[i].addonObject == addonObject) then + --check if the memberName is the same + if (keystoneCallbacks[i].memberName == memberName) then + tremove(keystoneCallbacks, i) + return false + end + end + end + + local payload = {...} + + keystoneCallbacks[#keystoneCallbacks+1] = { + addonObject = addonObject, + memberName = memberName, + payload = payload + } + + return true +end + if (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) then SLASH_KEYSTONE1 = "/keystone" SLASH_KEYSTONE2 = "/keys" SLASH_KEYSTONE3 = "/key" function SlashCmdList.KEYSTONE(msg, editbox) + --if there is addons registered to use the keystone command, call them and do not show the default frame from details! + if (#keystoneCallbacks > 0) then + --loop through all registered addons and call their callback function + local bCallbackSuccess = false + for i = 1, #keystoneCallbacks do + local thisCallback = keystoneCallbacks[i] + + local addonObject = thisCallback.addonObject + local memberName = thisCallback.memberName + local payload = thisCallback.payload + + if (type(addonObject[memberName]) == "function") then + local result = DetailsFramework:Dispatch(addonObject[memberName], unpack(payload)) --uses xpcall + if (result ~= false) then + bCallbackSuccess = true + end + end + end + + if (bCallbackSuccess) then + return + end + end + local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0") if (openRaidLib) then if (not DetailsKeystoneInfoFrame) then @@ -2158,7 +2226,7 @@ if (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) then line.keystoneLevelText.text = level line.dungeonNameText.text = mapName DetailsFramework:TruncateText(line.dungeonNameText, 240) - line.classicDungeonNameText.text = mapNameChallenge or "" + line.classicDungeonNameText.text = "" --mapNameChallenge DetailsFramework:TruncateText(line.classicDungeonNameText, 120) line.inMyParty = inMyParty > 0 line.inMyGuild = isGuildMember