You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1670 lines
63 KiB

4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local _detalhes = _G.Details
3 years ago
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
4 years ago
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
local DEFAULT_CHILD_WIDTH = 60
local DEFAULT_CHILD_HEIGHT = 16
local DEFAULT_CHILD_FONTFACE = "Friz Quadrata TT"
local DEFAULT_CHILD_FONTCOLOR = {1, 0.733333, 0, 1}
local DEFAULT_CHILD_FONTSIZE = 10
local _
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--local pointers
4 years ago
3 years ago
local _math_floor = math.floor --api local
local ipairs = ipairs --api local
4 years ago
local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--status bar core functions
4 years ago
3 years ago
--hida all micro frames
4 years ago
function _detalhes.StatusBar:Hide (instance, side)
if (not side) then
if (instance.StatusBar.center and instance.StatusBar.left and instance.StatusBar.right) then
instance.StatusBar.center.frame:Hide()
instance.StatusBar.left.frame:Hide()
instance.StatusBar.right.frame:Hide()
end
end
end
function _detalhes.StatusBar:Show (instance, side)
if (not side) then
if (instance.StatusBar.center and instance.StatusBar.left and instance.StatusBar.right) then
instance.StatusBar.center.frame:Show()
instance.StatusBar.left.frame:Show()
instance.StatusBar.right.frame:Show()
end
end
end
function _detalhes.StatusBar:LockDisplays (instance, locked)
if (instance.StatusBar.center and instance.StatusBar.left and instance.StatusBar.right) then
if (locked) then
3 years ago
instance.StatusBar.center.frame:EnableMouse(false)
instance.StatusBar.left.frame:EnableMouse(false)
instance.StatusBar.right.frame:EnableMouse(false)
4 years ago
else
3 years ago
instance.StatusBar.center.frame:EnableMouse(true)
instance.StatusBar.left.frame:EnableMouse(true)
instance.StatusBar.right.frame:EnableMouse(true)
4 years ago
end
end
end
3 years ago
--create a plugin child for an instance
4 years ago
function _detalhes.StatusBar:CreateStatusBarChildForInstance (instance, pluginName)
local PluginObject = _detalhes.StatusBar.NameTable [pluginName]
if (PluginObject) then
local new_child = PluginObject:CreateChildObject (instance)
if (new_child) then
instance.StatusBar [#instance.StatusBar+1] = new_child
new_child.enabled = false
return new_child
end
end
return nil
end
3 years ago
--functions to set the three statusbar places: left, center and right
4 years ago
function _detalhes.StatusBar:SetCenterPlugin (instance, childObject, fromStartup)
childObject.frame:Show()
childObject.frame:ClearAllPoints()
childObject.options.textAlign = 2
3 years ago
if (instance.micro_displays_side == 2) then --default - bottom
childObject.frame:SetPoint("center", instance.baseframe.rodape.StatusBarCenterAnchor, "center")
elseif (instance.micro_displays_side == 1) then --top side
childObject.frame:SetPoint("center", instance.baseframe.cabecalho.StatusBarCenterAnchor, "center")
4 years ago
end
childObject.text:ClearAllPoints()
3 years ago
childObject.text:SetPoint("center", childObject.frame, "center", childObject.options.textXMod, childObject.options.textYMod)
4 years ago
instance.StatusBar.center = childObject
childObject.anchor = "center"
childObject.enabled = true
if (childObject.OnEnable) then
childObject:OnEnable()
end
if (fromStartup and childObject.options.isHidden) then
childObject.frame.text:Hide()
if (childObject.frame.texture) then
childObject.frame.texture:Hide()
end
end
return true
end
function _detalhes.StatusBar:SetLeftPlugin (instance, childObject, fromStartup)
if (not childObject) then
return
end
childObject.frame:Show()
childObject.frame:ClearAllPoints()
childObject.options.textAlign = 1
3 years ago
if (instance.micro_displays_side == 2) then --default - bottom
childObject.frame:SetPoint("left", instance.baseframe.rodape.StatusBarLeftAnchor, "left")
elseif (instance.micro_displays_side == 1) then --top side
childObject.frame:SetPoint("left", instance.baseframe.cabecalho.StatusBarLeftAnchor, "left")
4 years ago
end
childObject.text:ClearAllPoints()
3 years ago
childObject.text:SetPoint("left", childObject.frame, "left", childObject.options.textXMod, childObject.options.textYMod)
4 years ago
instance.StatusBar.left = childObject
childObject.anchor = "left"
childObject.enabled = true
if (childObject.OnEnable) then
childObject:OnEnable()
end
if (fromStartup and childObject.options.isHidden) then
childObject.frame.text:Hide()
if (childObject.frame.texture) then
childObject.frame.texture:Hide()
end
end
return true
end
function _detalhes.StatusBar:SetRightPlugin (instance, childObject, fromStartup)
childObject.frame:Show()
childObject.frame:ClearAllPoints()
childObject.options.textAlign = 3
3 years ago
if (instance.micro_displays_side == 2) then --default - bottom
childObject.frame:SetPoint("right", instance.baseframe.rodape.direita, "right", -20, 10)
elseif (instance.micro_displays_side == 1) then --top side
childObject.frame:SetPoint("right", instance.baseframe.cabecalho.StatusBarRightAnchor, "right")
4 years ago
end
childObject.text:ClearAllPoints()
3 years ago
childObject.text:SetPoint("right", childObject.frame, "right", childObject.options.textXMod, childObject.options.textYMod)
4 years ago
instance.StatusBar.right = childObject
childObject.anchor = "right"
childObject.enabled = true
if (childObject.OnEnable) then
childObject:OnEnable()
end
if (fromStartup and childObject.options.isHidden) then
childObject.frame.text:Hide()
if (childObject.frame.texture) then
childObject.frame.texture:Hide()
end
end
return true
end
3 years ago
--disable all plugin childs attached to an specified instance and reactive the childs taking the instance statusbar anchors
4 years ago
function _detalhes.StatusBar:ReloadAnchors (instance)
3 years ago
for _, child in ipairs(instance.StatusBar) do
4 years ago
child.frame:ClearAllPoints()
child.frame:Hide()
child.anchor = nil
child.enabled = false
if (child.OnDisable) then
child:OnDisable()
end
end
3 years ago
--enable only needed plugins
4 years ago
if (instance.StatusBar.right) then
_detalhes.StatusBar:SetRightPlugin (instance, instance.StatusBar.right)
end
if (instance.StatusBar.center) then
_detalhes.StatusBar:SetCenterPlugin (instance, instance.StatusBar.center)
end
if (instance.StatusBar.left) then
_detalhes.StatusBar:SetLeftPlugin (instance, instance.StatusBar.left)
end
if (not instance.show_statusbar and instance.micro_displays_side == 2) then
_detalhes.StatusBar:Hide (instance)
end
end
3 years ago
--select a new plugin in for an instance anchor
local ChoosePlugin = function(_, _, index, current_child, anchor)
4 years ago
GameCooltip:Close()
local byuser = false
3 years ago
if (type(index) == "table") then
index, current_child, anchor = unpack(index)
4 years ago
byuser = true
end
3 years ago
if (index and index == -1) then --hide
4 years ago
_detalhes.StatusBar:ApplyOptions (current_child, "hidden", true)
return
else
_detalhes.StatusBar:ApplyOptions (current_child, "hidden", false)
current_child.frame.text:Show()
if (current_child.frame.texture) then
current_child.frame.texture:Show()
end
end
local pluginMestre = _detalhes.StatusBar.Plugins [index]
if (not pluginMestre) then
if (anchor == "left") then
pluginMestre = _detalhes.StatusBar.Plugins [2]
elseif (anchor == "center") then
pluginMestre = _detalhes.StatusBar.Plugins [4]
elseif (anchor == "right") then
pluginMestre = _detalhes.StatusBar.Plugins [1]
end
end
local instance = current_child.instance -- instance que estamos usando agora
local chosenChild = nil
--procura pra ver se ja tem uma criada
3 years ago
for _, child_created in ipairs(instance.StatusBar) do
4 years ago
if (child_created.mainPlugin == pluginMestre) then
chosenChild = child_created
break
end
end
--se nao tiver cria uma
if (not chosenChild) then
chosenChild = _detalhes.StatusBar:CreateStatusBarChildForInstance (current_child.instance, pluginMestre.real_name)
end
instance.StatusBar [anchor] = chosenChild
3 years ago
--copia os atributos do current para o chosen
local options_current = Details.CopyTable(current_child.options)
4 years ago
if (chosenChild.anchor) then
--o widget escolhido ja estava sendo mostrado...
-- copia os atributos do chosen para o current
3 years ago
current_child.options = Details.CopyTable(chosenChild.options)
4 years ago
instance.StatusBar [chosenChild.anchor] = current_child
end
chosenChild.options = options_current
_detalhes.StatusBar:ReloadAnchors (instance)
_detalhes.StatusBar:UpdateOptions (instance)
end
function _detalhes.StatusBar:SetPlugin (instance, absolute_name, anchor)
3 years ago
if (absolute_name == -1) then --none
anchor = string.lower(anchor)
4 years ago
ChoosePlugin (nil, nil, -1, instance.StatusBar [anchor], anchor)
else
local index = _detalhes.StatusBar:GetIndexFromAbsoluteName (absolute_name)
if (index and anchor) then
3 years ago
anchor = string.lower(anchor)
4 years ago
ChoosePlugin (nil, nil, index, instance.StatusBar [anchor], anchor)
end
end
end
3 years ago
--on enter
4 years ago
local onEnterCooltipTexts = {
{text = "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:14:14:0:1:512:512:8:70:224:306|t " .. Loc ["STRING_PLUGIN_TOOLTIP_LEFTBUTTON"]},
{text = "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:14:14:0:1:512:512:8:70:328:409|t " .. Loc ["STRING_PLUGIN_TOOLTIP_RIGHTBUTTON"]}}
local on_enter_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16}
3 years ago
local OnEnter = function(frame)
4 years ago
--|TTexturePath: size X: size Y: point offset Y X : texture size : coordx1 L : coordx2 R : coordy1 T : coordy2 B |t
-- left click: 0.0019531:0.1484375:0.4257813:0.6210938 right click: 0.0019531:0.1484375:0.6269531:0.8222656
local instance = frame.child.instance
3 years ago
_detalhes.OnEnterMainWindow(instance)
4 years ago
3 years ago
frame:SetBackdrop(on_enter_backdrop)
frame:SetBackdropColor(0.7, 0.7, 0.7, 0.6)
4 years ago
GameCooltip:Reset()
3 years ago
GameCooltip:AddFromTable(onEnterCooltipTexts)
GameCooltip:SetOption("TextSize", 9)
4 years ago
GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true)
3 years ago
GameCooltip:SetOption("ButtonHeightMod", -4)
GameCooltip:SetOption("ButtonsYMod", -4)
GameCooltip:SetOption("YSpacingMod", -4)
GameCooltip:SetOption("FixedHeight", 46)
4 years ago
3 years ago
GameCooltip:ShowCooltip(frame, "tooltip")
4 years ago
return true
end
3 years ago
--on leave
local OnLeave = function(frame)
4 years ago
3 years ago
frame:SetBackdrop(nil)
4 years ago
3 years ago
_detalhes.OnLeaveMainWindow(frame.child.instance)
4 years ago
_detalhes.popup:Hide()
return true
end
3 years ago
local OnMouseUp = function(frame, mouse)
4 years ago
if (mouse == "LeftButton") then
if (not frame.child.Setup) then
3 years ago
print(Loc ["STRING_STATUSBAR_NOOPTIONS"])
4 years ago
return
end
frame.child:Setup()
else
GameCooltip:Reset()
GameCooltip:SetType ("menu")
GameCooltip:AddMenu (1, ChoosePlugin, -1, frame.child, frame.child.anchor, Loc ["STRING_PLUGIN_CLEAN"], [[Interface\Buttons\UI-GroupLoot-Pass-Down]], true)
local current
3 years ago
for index, _name_and_icon in ipairs(_detalhes.StatusBar.Menu) do
4 years ago
GameCooltip:AddMenu (1, ChoosePlugin, {index, frame.child, frame.child.anchor}, nil, nil, _name_and_icon [1], _name_and_icon [2], true)
local pluginMestre = _detalhes.StatusBar.Plugins [index]
if (pluginMestre and pluginMestre.real_name == frame.child.mainPlugin.real_name) then
current = index+1
end
end
if (current) then
GameCooltip:SetLastSelected (1, current)
else
3 years ago
GameCooltip:SetOption("NoLastSelectedBar", true)
4 years ago
end
3 years ago
GameCooltip:SetOption("HeightAnchorMod", -12)
4 years ago
GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true)
3 years ago
GameCooltip:ShowCooltip(frame, "menu")
4 years ago
end
return true
end
3 years ago
--reset micro frames
4 years ago
function _detalhes.StatusBar:Reset (instance)
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textcolor", {1, 0.82, 0, 1})
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textcolor", {1, 0.82, 0, 1})
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textcolor", {1, 0.82, 0, 1})
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textface", "Friz Quadrata TT")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textface", "Friz Quadrata TT")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textface", "Friz Quadrata TT")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textsize", 9)
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textsize", 9)
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textsize", 9)
end
function _detalhes.StatusBar:GetIndexFromAbsoluteName (AbsName)
3 years ago
for index, object in ipairs(_detalhes.StatusBar.Plugins) do
4 years ago
if (object.real_name == AbsName) then
return index
end
end
end
function _detalhes.StatusBar:UpdateOptions (instance)
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "hidden")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "hidden")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "hidden")
end
function _detalhes.StatusBar:UpdateChilds (instance)
local left = instance.StatusBarSaved.left
local center = instance.StatusBarSaved.center
local right = instance.StatusBarSaved.right
local left_index = _detalhes.StatusBar:GetIndexFromAbsoluteName (left)
ChoosePlugin (nil, nil, left_index, instance.StatusBar.left, "left")
local center_index = _detalhes.StatusBar:GetIndexFromAbsoluteName (center)
ChoosePlugin (nil, nil, center_index, instance.StatusBar.center, "center")
local right_index = _detalhes.StatusBar:GetIndexFromAbsoluteName (right)
ChoosePlugin (nil, nil, right_index, instance.StatusBar.right, "right")
if (instance.StatusBarSaved.options and instance.StatusBarSaved.options [left]) then
3 years ago
instance.StatusBar.left.options = Details.CopyTable(instance.StatusBarSaved.options [left])
4 years ago
end
if (instance.StatusBarSaved.options and instance.StatusBarSaved.options [center]) then
3 years ago
instance.StatusBar.center.options = Details.CopyTable(instance.StatusBarSaved.options [center])
4 years ago
end
if (instance.StatusBarSaved.options and instance.StatusBarSaved.options [right]) then
3 years ago
instance.StatusBar.right.options = Details.CopyTable(instance.StatusBarSaved.options [right])
4 years ago
end
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.left, "hidden")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.center, "hidden")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textcolor")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textsize")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textface")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textxmod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "textymod")
_detalhes.StatusBar:ApplyOptions (instance.StatusBar.right, "hidden")
end
3 years ago
--build-in function for create a frame for an plugin child
4 years ago
function _detalhes.StatusBar:CreateChildFrame (instance, name, w, h)
3 years ago
--local frame = _detalhes.gump:NewPanel(instance.baseframe.cabecalho.fechar, nil, name..instance:GetInstanceId(), nil, w or DEFAULT_CHILD_WIDTH, h or DEFAULT_CHILD_HEIGHT, false)
local frame = _detalhes.gump:NewPanel(instance.baseframe, nil, name..instance:GetInstanceId(), nil, w or DEFAULT_CHILD_WIDTH, h or DEFAULT_CHILD_HEIGHT, false)
frame:SetFrameLevel(instance.baseframe:GetFrameLevel()+4)
4 years ago
--create widgets
3 years ago
local text = _detalhes.gump:NewLabel(frame, nil, "$parentText", "text", "0")
text:SetPoint("right", frame, "right", 0, 0)
text:SetJustifyH("right")
_detalhes:SetFontSize(text, 9.8)
frame:SetHook("OnEnter", OnEnter)
frame:SetHook("OnLeave", OnLeave)
frame:SetHook("OnMouseUp", OnMouseUp)
4 years ago
return frame
end
3 years ago
--built-in function for create an table for the plugin child
4 years ago
function _detalhes.StatusBar:CreateChildTable (instance, mainObject, frame)
local _table = {}
3 years ago
--treat as a class
setmetatable(_table, mainObject)
4 years ago
3 years ago
--default members
4 years ago
_table.instance = instance
_table.frame = frame
_table.text = frame.text
_table.mainPlugin = mainObject
3 years ago
--options table
4 years ago
_table.options = instance.StatusBar.options [mainObject.real_name]
if (not _table.options) then
_table.options = {
textStyle = 2,
3 years ago
textColor = {unpack(DEFAULT_CHILD_FONTCOLOR)},
4 years ago
textSize = DEFAULT_CHILD_FONTSIZE,
textAlign = 0,
textXMod = 0,
textYMod = 0,
textFace = DEFAULT_CHILD_FONTFACE}
instance.StatusBar.options [mainObject.real_name] = _table.options
end
_detalhes.StatusBar:ApplyOptions (_table, "textcolor")
_detalhes.StatusBar:ApplyOptions (_table, "textsize")
_detalhes.StatusBar:ApplyOptions (_table, "textface")
_detalhes.StatusBar:ReloadAnchors (instance)
3 years ago
--table reference on frame widget
4 years ago
frame.frame.child = _table
3 years ago
--adds this new child to parent child container
4 years ago
mainObject.childs [#mainObject.childs+1] = _table
return _table
end
function _detalhes.StatusBar:ApplyOptions (child, option, value)
3 years ago
option = string.lower(option)
4 years ago
if (option == "textxmod") then
if (value == nil) then
value = child.options.textXMod
end
child.options.textXMod = value
_detalhes.StatusBar:ReloadAnchors (child.instance)
elseif (option == "textymod") then
if (value == nil) then
value = child.options.textYMod
end
child.options.textYMod = value
_detalhes.StatusBar:ReloadAnchors (child.instance)
elseif (option == "textcolor") then
if (value == nil) then
value = child.options.textColor
end
child.options.textColor = value
3 years ago
local r, g, b, a = _detalhes.gump:ParseColors(child.options.textColor)
child.text:SetTextColor(r, g, b, a)
4 years ago
elseif (option == "textsize") then
if (value == nil) then
value = child.options.textSize
end
child.options.textSize = value or 9
3 years ago
child:SetFontSize(child.text, child.options.textSize)
4 years ago
elseif (option == "textface") then
if (value == nil) then
value = child.options.textFace
end
child.options.textFace = value
child:SetFontFace (child.text, SharedMedia:Fetch ("font", child.options.textFace))
elseif (option == "hidden") then
if (value == nil) then
value = child.options.isHidden
end
child.options.isHidden = value
if (value) then
child.frame.text:Hide()
if (child.frame.texture) then
child.frame.texture:Hide()
end
else
child.frame.text:Show()
if (child.frame.texture) then
child.frame.texture:Show()
end
end
else
3 years ago
if (child [option] and type(child [option]) == "function") then
4 years ago
child [option] (nil, child, value)
end
end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--BUILT-IN DPS PLUGIN
4 years ago
do
3 years ago
--Create the plugin Object [1] = frame name on _G [2] options [3] plugin type
4 years ago
local PDps = _detalhes:NewPluginObject ("Details_StatusBarDps", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
--[[ Note: Declare all functions using : not . if you use . make sure to ignore first parameter and move all parameters 1 position to right ]]
-- handle event "COMBAT_PLAYER_ENTER"
function PDps:PlayerEnterCombat()
3 years ago
for index, child in ipairs(PDps.childs) do
4 years ago
if (child.enabled and child.instance:GetSegment() == 0) then
child.tick = _detalhes:ScheduleRepeatingTimer ("PluginDpsUpdate", 1, child)
end
end
end
-- handle event "COMBAT_PLAYER_LEAVE"
function PDps:PlayerLeaveCombat()
3 years ago
for index, child in ipairs(PDps.childs) do
4 years ago
if (child.tick) then
3 years ago
_detalhes:CancelTimer(child.tick)
4 years ago
child.tick = nil
end
end
end
-- handle event "DETAILS_INSTANCE_CHANGESEGMENT"
function PDps:ChangeSegment (instance, segment)
3 years ago
for index, child in ipairs(PDps.childs) do
4 years ago
if (child.enabled and child.instance == instance) then
_detalhes:PluginDpsUpdate (child)
end
end
end
--handle event "DETAILS_DATA_RESET"
function PDps:DataReset()
3 years ago
for index, child in ipairs(PDps.childs) do
4 years ago
if (child.enabled) then
3 years ago
child.text:SetText("0")
4 years ago
end
end
end
function PDps:Refresh (child)
_detalhes:PluginDpsUpdate (child)
end
--still a little buggy, working on
function _detalhes:PluginDpsUpdate (child)
3 years ago
--showing is the combat table which is current shown on instance
4 years ago
if (child.instance.showing) then
--GetCombatTime() return the time length of combat
local combatTime = child.instance.showing:GetCombatTime()
if (combatTime < 1) then
3 years ago
return child.text:SetText("0")
4 years ago
end
--GetTotal (attribute, sub attribute, onlyGroup) return the total of requested attribute
local total = child.instance.showing:GetTotal (child.instance.atributo, child.instance.sub_atributo, true)
3 years ago
local dps = _math_floor(total / combatTime)
4 years ago
local textStyle = child.options.textStyle
if (textStyle == 1) then
3 years ago
child.text:SetText(_detalhes:ToK (dps))
4 years ago
elseif (textStyle == 2) then
3 years ago
child.text:SetText(_detalhes:comma_value (dps))
4 years ago
else
3 years ago
child.text:SetText(dps)
4 years ago
end
end
end
3 years ago
--Create Plugin Frames
4 years ago
function PDps:CreateChildObject (instance)
3 years ago
--create main frame and widgets
--a statusbar frame is made of a panel with a member called 'text' which is a label
4 years ago
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsStatusBarDps", DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PDps, myframe)
return new_child
end
3 years ago
--Handle events (must have, we'll use direct call to functions)
4 years ago
function PDps:OnDetailsEvent (event)
return
end
3 years ago
--Install
4 years ago
-- _detalhes:InstallPlugin ( Plugin Type | Plugin Display Name | Plugin Icon | Plugin Object | Plugin Real Name )
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_PDPSNAME"], "Interface\\Icons\\Achievement_brewery_3", PDps, "DETAILS_STATUSBAR_PLUGIN_PDPS")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
3 years ago
--Register needed events
4 years ago
-- here we are redirecting the event to an specified function, otherwise events need to be handle inside "PDps:OnDetailsEvent (event)"
_detalhes:RegisterEvent(PDps, "DETAILS_INSTANCE_CHANGESEGMENT", PDps.ChangeSegment)
_detalhes:RegisterEvent(PDps, "DETAILS_DATA_RESET", PDps.DataReset)
_detalhes:RegisterEvent(PDps, "COMBAT_PLAYER_ENTER", PDps.PlayerEnterCombat)
_detalhes:RegisterEvent(PDps, "COMBAT_PLAYER_LEAVE", PDps.PlayerLeaveCombat)
4 years ago
end
3 years ago
---------BUILT-IN SEGMENT PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PSegment = _detalhes:NewPluginObject ("Details_Segmenter", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PSegment:OnDetailsEvent (event)
return
end
3 years ago
--initialize and reset 'can_schedule' variable
4 years ago
function PSegment:NewCombat()
PSegment.can_schedule = 1
PSegment:Change()
end
function PSegment:OnSegmentChange()
PSegment.can_schedule = 1
PSegment:Change()
end
3 years ago
--on 'can_schedule' timeout, re-run the Change() function
4 years ago
function PSegment:SchduleGetName()
PSegment:Change()
end
function PSegment:Change()
3 years ago
for index, child in ipairs(PSegment.childs) do
4 years ago
if (child.enabled and child.instance:IsEnabled()) then
child.options.segmentType = child.options.segmentType or 2
if (not child.instance.showing) then
3 years ago
return child.text:SetText(Loc ["STRING_EMPTY_SEGMENT"])
4 years ago
end
3 years ago
if (child.instance.segmento == -1) then --overall
child.text:SetText(Loc ["STRING_OVERALL"])
4 years ago
3 years ago
elseif (child.instance.segmento == 0) then --combate atual
4 years ago
if (child.options.segmentType == 1) then
3 years ago
child.text:SetText(Loc ["STRING_CURRENT"])
4 years ago
else
3 years ago
local name = _detalhes.tabela_vigente:GetCombatName(true)
4 years ago
if (name and name ~= Loc ["STRING_UNKNOW"]) then
if (child.options.segmentType == 2) then
3 years ago
child.text:SetText(name)
4 years ago
elseif (child.options.segmentType == 3) then
3 years ago
child.text:SetText(name)
4 years ago
end
else
3 years ago
child.text:SetText(Loc ["STRING_CURRENT"])
4 years ago
if (_detalhes.in_combat and PSegment.can_schedule <= 2) then
3 years ago
PSegment:ScheduleTimer("SchduleGetName", 2)
4 years ago
PSegment.can_schedule = PSegment.can_schedule + 1
return
end
end
end
3 years ago
else --alguma tabela do hist�rico
4 years ago
if (child.options.segmentType == 1) then
3 years ago
child.text:SetText(Loc ["STRING_FIGHTNUMBER"] .. child.instance.segmento)
4 years ago
else
3 years ago
local name = child.instance.showing:GetCombatName(true)
4 years ago
if (name ~= Loc ["STRING_UNKNOW"]) then
if (child.options.segmentType == 2) then
3 years ago
child.text:SetText(name)
4 years ago
elseif (child.options.segmentType == 3) then
3 years ago
child.text:SetText(name .. " #" .. child.instance.segmento)
4 years ago
end
else
if (child.options.segmentType == 2) then
3 years ago
child.text:SetText(Loc ["STRING_UNKNOW"])
4 years ago
elseif (child.options.segmentType == 3) then
3 years ago
child.text:SetText(Loc ["STRING_UNKNOW"] .. " #" .. child.instance.segmento)
4 years ago
end
end
end
end
end
end
end
function PSegment:ExtraOptions()
3 years ago
--all widgets need to be placed on a table
4 years ago
local widgets = {}
3 years ago
--reference of extra window for custom options
4 years ago
local window = _G.DetailsStatusBarOptions2.MyObject
3 years ago
--build all your widgets -----------------------------------------------------------------------------------------------------------------------------
_detalhes.gump:NewLabel(window, nil, "$parentSegmentOptionLabel", "segmentOptionLabel", Loc ["STRING_PLUGIN_SEGMENTTYPE"])
window.segmentOptionLabel:SetPoint(10, -15)
4 years ago
3 years ago
local onSelectSegmentType = function(_, child, thistype)
4 years ago
child.options.segmentType = thistype
PSegment:Change()
end
local segmentTypes = {
{value = 1, label = Loc ["STRING_PLUGIN_SEGMENTTYPE_1"], onclick = onSelectSegmentType, icon = [[Interface\ICONS\Ability_Rogue_KidneyShot]]},
{value = 2, label = Loc ["STRING_PLUGIN_SEGMENTTYPE_2"], onclick = onSelectSegmentType, icon = [[Interface\ICONS\Achievement_Boss_Ra_Den]]},
{value = 3, label = Loc ["STRING_PLUGIN_SEGMENTTYPE_3"], onclick = onSelectSegmentType, icon = [[Interface\ICONS\Achievement_Boss_Durumu]]},
}
_detalhes.gump:NewDropDown (window, nil, "$parentSegmentTypeDropdown", "segmentTypeDropdown", 200, 20, function() return segmentTypes end, 1) -- func, default
3 years ago
window.segmentTypeDropdown:SetPoint("left", window.segmentOptionLabel, "right", 2)
4 years ago
-----------------------------------------------------------------------------------------------------------------------------
3 years ago
--now we insert all widgets created on widgets table
table.insert(widgets, window.segmentOptionLabel)
table.insert(widgets, window.segmentTypeDropdown)
4 years ago
3 years ago
--after first call we replace this function with widgets table
4 years ago
PSegment.ExtraOptions = widgets
end
3 years ago
--ExtraOptionsOnOpen is called when options are opened and plugin have custom options
--here we setup options widgets for get the values of clicked child and also for tell options window what child we are configuring
4 years ago
function PSegment:ExtraOptionsOnOpen (child)
3 years ago
_G.DetailsStatusBarOptions2SegmentTypeDropdown.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptions2SegmentTypeDropdown.MyObject:Select(child.options.segmentType, true)
4 years ago
end
3 years ago
--Create Plugin Frames (must have)
4 years ago
function PSegment:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPSegmentInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PSegment, myframe)
new_child.options.segmentType = new_child.options.segmentType or 2
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_PSEGMENTNAME"], "Interface\\Icons\\inv_misc_enchantedscroll", PSegment, "DETAILS_STATUSBAR_PLUGIN_PSEGMENT")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
3 years ago
--Register needed events
_detalhes:RegisterEvent(PSegment, "DETAILS_INSTANCE_CHANGESEGMENT", PSegment.OnSegmentChange)
_detalhes:RegisterEvent(PSegment, "DETAILS_DATA_RESET", PSegment.Change)
_detalhes:RegisterEvent(PSegment, "COMBAT_PLAYER_ENTER", PSegment.NewCombat)
4 years ago
end
3 years ago
---------BUILT-IN ATTRIBUTE PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PAttribute = _detalhes:NewPluginObject ("Details_Attribute", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PAttribute:OnDetailsEvent (event)
return
end
function PAttribute:Change (instance, attribute, subAttribute)
if (not instance) then
instance, attribute, subAttribute = self.instance, self.instance.atributo, self.instance.sub_atributo
end
3 years ago
for index, child in ipairs(PAttribute.childs) do
4 years ago
if (child.instance == instance and child.enabled and child.instance:IsEnabled()) then
local sName = child.instance:GetInstanceAttributeText()
3 years ago
child.text:SetText(sName)
4 years ago
end
end
end
function PAttribute:OnEnable()
self:Change()
end
3 years ago
--Create Plugin Frames (must have)
4 years ago
function PAttribute:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPAttributeInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PAttribute, myframe)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_PATTRIBUTENAME"], "Interface\\Icons\\inv_misc_emberclothbolt", PAttribute, "DETAILS_STATUSBAR_PLUGIN_PATTRIBUTE")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
3 years ago
--Register needed events
_detalhes:RegisterEvent(PAttribute, "DETAILS_INSTANCE_CHANGEATTRIBUTE", PAttribute.Change)
4 years ago
end
3 years ago
---------BUILT-IN CLOCK PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local Clock = _detalhes:NewPluginObject ("Details_Clock", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events --must have this function
4 years ago
function Clock:OnDetailsEvent (event)
return
end
--enter combat
function Clock:PlayerEnterCombat()
Clock.tick = _detalhes:ScheduleRepeatingTimer ("ClockPluginTick", 1)
end
--leave combat
function Clock:PlayerLeaveCombat()
3 years ago
_detalhes:CancelTimer(Clock.tick)
4 years ago
end
function _detalhes:ClockPluginTickOnSegment()
_detalhes:ClockPluginTick (true)
end
--1 sec tick
function _detalhes:ClockPluginTick (force)
3 years ago
for index, child in ipairs(Clock.childs) do
4 years ago
local instance = child.instance
if (child.enabled and instance:IsEnabled()) then
if (instance.showing and ( (instance.segmento ~= -1) or (instance.segmento == -1 and not _detalhes.in_combat) or force) ) then
local timeType = child.options.timeType
if (timeType == 1) then
local combatTime = instance.showing:GetCombatTime()
3 years ago
local minutos, segundos = _math_floor(combatTime/60), _math_floor(combatTime%60)
child.text:SetText(minutos .. "m " .. segundos .. "s")
4 years ago
elseif (timeType == 2) then
local combatTime = instance.showing:GetCombatTime()
3 years ago
child.text:SetText(combatTime .. "s")
4 years ago
elseif (timeType == 3) then
local getSegment = instance.segmento
if (getSegment < 1) then
getSegment = 1
elseif (getSegment > _detalhes.segments_amount) then
getSegment = _detalhes.segments_amount
else
getSegment = getSegment+1
end
3 years ago
local lastFight = _detalhes:GetCombat(getSegment)
4 years ago
local currentCombatTime = instance.showing:GetCombatTime()
if (lastFight) then
3 years ago
child.text:SetText(currentCombatTime - lastFight:GetCombatTime() .. "s")
4 years ago
else
3 years ago
child.text:SetText(currentCombatTime .. "s")
4 years ago
end
end
end
end
end
end
--on reset
function Clock:DataReset()
3 years ago
for index, child in ipairs(Clock.childs) do
4 years ago
if (child.enabled and child.instance:IsEnabled()) then
3 years ago
child.text:SetText("0m 0s")
4 years ago
end
end
end
3 years ago
--this is a fixed member, put all your widgets for custom options inside this function
--if ExtraOptions isn't preset, secondary options box will be hided and only default options will be show
4 years ago
function Clock:ExtraOptions()
3 years ago
--all widgets need to be placed on a table
4 years ago
local widgets = {}
3 years ago
--reference of extra window for custom options
4 years ago
local window = _G.DetailsStatusBarOptions2.MyObject
3 years ago
--build all your widgets -----------------------------------------------------------------------------------------------------------------------------
_detalhes.gump:NewLabel(window, nil, "$parentClockTypeLabel", "ClockTypeLabel", Loc ["STRING_PLUGIN_CLOCKTYPE"])
window.ClockTypeLabel:SetPoint(10, -15)
4 years ago
3 years ago
local onSelectClockType = function(_, child, thistype)
4 years ago
child.options.timeType = thistype
_detalhes:ClockPluginTick()
end
local clockTypes = {{value = 1, label = Loc ["STRING_PLUGIN_MINSEC"], onclick = onSelectClockType},
{value = 2, label = Loc ["STRING_PLUGIN_SECONLY"], onclick = onSelectClockType},
{value = 3, label = Loc ["STRING_PLUGIN_TIMEDIFF"], onclick = onSelectClockType}}
_detalhes.gump:NewDropDown (window, nil, "$parentClockTypeDropdown", "ClockTypeDropdown", 200, 20, function() return clockTypes end, 1) -- func, default
3 years ago
window.ClockTypeDropdown:SetPoint("left", window.ClockTypeLabel, "right", 2)
4 years ago
-----------------------------------------------------------------------------------------------------------------------------
3 years ago
--now we insert all widgets created on widgets table
table.insert(widgets, window.ClockTypeLabel)
table.insert(widgets, window.ClockTypeDropdown)
4 years ago
3 years ago
--after first call we replace this function with widgets table
4 years ago
Clock.ExtraOptions = widgets
end
3 years ago
--ExtraOptionsOnOpen is called when options are opened and plugin have custom options
--here we setup options widgets for get the values of clicked child and also for tell options window what child we are configuring
4 years ago
function Clock:ExtraOptionsOnOpen (child)
3 years ago
_G.DetailsStatusBarOptions2ClockTypeDropdown.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptions2ClockTypeDropdown.MyObject:Select(child.options.timeType, true)
4 years ago
end
3 years ago
--Create Plugin Frames
4 years ago
function Clock:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsClockInstance"..instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
3 years ago
--we place custom frame, widgets inside this function
--local texture = myframe:CreateTexture(nil, "overlay")
--texture:SetTexture("Interface\\AddOns\\Details\\images\\clock")
--texture:SetPoint("right", myframe.text.widget, "left")
4 years ago
--myframe.texture = texture
local new_child = _detalhes.StatusBar:CreateChildTable (instance, Clock, myframe)
3 years ago
--default text
new_child.text:SetText("0m 0s")
4 years ago
3 years ago
--some changes from default options
4 years ago
if (new_child.options.textXMod == 0) then
new_child.options.textXMod = 6
end
3 years ago
--here we are adding a new option member
4 years ago
new_child.options.timeType = new_child.options.timeType or 1
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_CLOCKNAME"], "Interface\\Icons\\Achievement_BG_grab_cap_flagunderXseconds", Clock, "DETAILS_STATUSBAR_PLUGIN_CLOCK")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
3 years ago
--Register needed events
_detalhes:RegisterEvent(Clock, "COMBAT_PLAYER_ENTER", Clock.PlayerEnterCombat)
_detalhes:RegisterEvent(Clock, "COMBAT_PLAYER_LEAVE", Clock.PlayerLeaveCombat)
_detalhes:RegisterEvent(Clock, "DETAILS_INSTANCE_CHANGESEGMENT", _detalhes.ClockPluginTickOnSegment)
_detalhes:RegisterEvent(Clock, "DETAILS_DATA_SEGMENTREMOVED", _detalhes.ClockPluginTick)
_detalhes:RegisterEvent(Clock, "DETAILS_DATA_RESET", Clock.DataReset)
4 years ago
end
3 years ago
---------BUILT-IN THREAT PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
local _UnitDetailedThreatSituation = UnitDetailedThreatSituation --wow api
local _cstr = string.format --lua api
local abs = math.abs --lua api
4 years ago
3 years ago
--Create the plugin Object
4 years ago
local Threat = _detalhes:NewPluginObject ("Details_TargetThreat", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events
4 years ago
function Threat:OnDetailsEvent (event)
return
end
Threat.isTank = nil
function Threat:PlayerEnterCombat()
3 years ago
local role = UnitGroupRolesAssigned("player")
4 years ago
if (role == "TANK") then
Threat.isTank = true
else
Threat.isTank = nil
end
Threat.tick = _detalhes:ScheduleRepeatingTimer ("ThreatPluginTick", 1)
end
function Threat:PlayerLeaveCombat()
3 years ago
_detalhes:CancelTimer(Threat.tick)
4 years ago
end
function _detalhes:ThreatPluginTick()
3 years ago
for index, child in ipairs(Threat.childs) do
4 years ago
local instance = child.instance
if (child.enabled and instance:IsEnabled()) then
-- atualiza a threat
if (not DetailsFramework.IsClassicWow()) then
local isTanking, status, threatpct, rawthreatpct, threatvalue = _UnitDetailedThreatSituation ("player", "target")
if (threatpct) then
3 years ago
child.text:SetText(_math_floor(threatpct).."%")
4 years ago
if (Threat.isTank) then
3 years ago
child.text:SetTextColor(abs(threatpct-100)*0.01, threatpct*0.01, 0, 1)
4 years ago
else
3 years ago
child.text:SetTextColor(threatpct*0.01, abs(threatpct-100)*0.01, 0, 1)
4 years ago
end
else
3 years ago
child.text:SetText("0%")
child.text:SetTextColor(1, 1, 1, 1)
4 years ago
end
else
3 years ago
child.text:SetText("0%")
child.text:SetTextColor(1, 1, 1, 1)
4 years ago
end
end
end
end
3 years ago
--Create Plugin Frames
4 years ago
function Threat:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsThreatInstance"..instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, Threat, myframe)
myframe.widget:RegisterEvent("PLAYER_TARGET_CHANGED")
3 years ago
myframe.widget:SetScript("OnEvent", function()
4 years ago
_detalhes:ThreatPluginTick()
end)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_THREATNAME"], "Interface\\Icons\\Ability_Hunter_ResistanceIsFutile", Threat, "DETAILS_STATUSBAR_PLUGIN_THREAT")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
3 years ago
--Register needed events
_detalhes:RegisterEvent(Threat, "COMBAT_PLAYER_ENTER", Threat.PlayerEnterCombat)
_detalhes:RegisterEvent(Threat, "COMBAT_PLAYER_LEAVE", Threat.PlayerLeaveCombat)
4 years ago
end
3 years ago
---------BUILT-IN PFS PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PFps = _detalhes:NewPluginObject ("Details_Statusbar_Fps", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PFps:OnDetailsEvent (event)
return
end
function PFps:UpdateFps()
3 years ago
self.text:SetText(_math_floor(GetFramerate()) .. " fps")
4 years ago
end
function PFps:OnDisable()
3 years ago
self:CancelTimer(self.srt, true)
4 years ago
end
function PFps:OnEnable()
self.srt = self:ScheduleRepeatingTimer ("UpdateFps", 1, self)
self:UpdateFps()
end
function PFps:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPFpsInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PFps, myframe)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_FPS"], "Interface\\Icons\\Spell_Shadow_MindTwisting", PFps, "DETAILS_STATUSBAR_PLUGIN_PFPS")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
end
3 years ago
---------BUILT-IN LATENCY PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PLatency = _detalhes:NewPluginObject ("Details_Statusbar_Latency", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PLatency:OnDetailsEvent (event)
return
end
function PLatency:UpdateLatency()
local _, _, _, lagWorld = GetNetStats()
3 years ago
self.text:SetText(_math_floor(lagWorld) .. " ms")
4 years ago
end
function PLatency:OnDisable()
3 years ago
self:CancelTimer(self.srt, true)
4 years ago
end
function PLatency:OnEnable()
self.srt = self:ScheduleRepeatingTimer ("UpdateLatency", 30, self)
self:UpdateLatency()
end
function PLatency:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPLatencyInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PLatency, myframe)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_LATENCY"], "Interface\\FriendsFrame\\PlusManz-BattleNet", PLatency, "DETAILS_STATUSBAR_PLUGIN_PLATENCY")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
end
3 years ago
---------BUILT-IN DURABILITY PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
local _GetInventoryItemDurability = GetInventoryItemDurability
3 years ago
--Create the plugin Object
4 years ago
local PDurability = _detalhes:NewPluginObject ("Details_Statusbar_Latency", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PDurability:OnDetailsEvent (event)
return
end
function PDurability:UpdateDurability()
local percent, items = 0, 0
for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
local durability, maxdurability = _GetInventoryItemDurability (i)
if (durability and maxdurability) then
local p = durability / maxdurability * 100
percent = percent + p
items = items + 1
end
end
if (items == 0) then
3 years ago
self.text:SetText(Loc ["STRING_UPTADING"])
return self:ScheduleTimer("UpdateDurability", 5, self)
4 years ago
end
percent = percent / items
3 years ago
self.text:SetText(_math_floor(percent) .. "%")
4 years ago
end
function PDurability:OnDisable()
self.frame.widget:UnregisterEvent ("PLAYER_DEAD")
self.frame.widget:UnregisterEvent ("PLAYER_UNGHOST")
self.frame.widget:UnregisterEvent ("UPDATE_INVENTORY_DURABILITY")
self.frame.widget:UnregisterEvent ("MERCHANT_SHOW")
self.frame.widget:UnregisterEvent ("MERCHANT_CLOSED")
self.frame.widget:UnregisterEvent ("ZONE_CHANGED_NEW_AREA")
end
function PDurability:OnEnable()
self.frame.widget:RegisterEvent("PLAYER_DEAD")
self.frame.widget:RegisterEvent("PLAYER_UNGHOST")
self.frame.widget:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
self.frame.widget:RegisterEvent("MERCHANT_SHOW")
self.frame.widget:RegisterEvent("MERCHANT_CLOSED")
self.frame.widget:RegisterEvent("ZONE_CHANGED_NEW_AREA")
4 years ago
self:UpdateDurability()
end
function PDurability:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPDurabilityInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PDurability, myframe)
3 years ago
local texture = myframe:CreateTexture(nil, "overlay")
texture:SetTexture("Interface\\AddOns\\Details\\images\\icons")
texture:SetPoint("right", myframe.text.widget, "left", -2, -1)
texture:SetWidth(10)
texture:SetHeight(10)
texture:SetTexCoord(0.216796875, 0.26171875, 0.0078125, 0.052734375)
4 years ago
myframe.texture = texture
3 years ago
myframe.widget:SetScript("OnEvent", function()
4 years ago
new_child:UpdateDurability()
end)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_DURABILITY"], "Interface\\ICONS\\INV_Chest_Chain_10", PDurability, "DETAILS_STATUSBAR_PLUGIN_PDURABILITY")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
end
3 years ago
---------BUILT-IN GOLD PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PGold = _detalhes:NewPluginObject ("Details_Statusbar_Gold", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PGold:OnDetailsEvent (event)
return
end
function PGold:GoldPluginTick()
3 years ago
for index, child in ipairs(PGold.childs) do
4 years ago
local instance = child.instance
if (child.enabled and instance:IsEnabled()) then
child:UpdateGold()
end
end
end
function PGold:UpdateGold()
3 years ago
self.text:SetText(_math_floor(GetMoney() / 100 / 100))
4 years ago
end
function PGold:OnEnable()
self:UpdateGold()
end
function PGold:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPGoldInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PGold, myframe)
3 years ago
local texture = myframe:CreateTexture(nil, "overlay")
texture:SetTexture("Interface\\MONEYFRAME\\UI-GoldIcon")
texture:SetPoint("right", myframe.text.widget, "left")
texture:SetWidth(12)
texture:SetHeight(12)
4 years ago
myframe.texture = texture
myframe.widget:RegisterEvent("PLAYER_MONEY")
myframe.widget:RegisterEvent("PLAYER_ENTERING_WORLD")
3 years ago
myframe.widget:SetScript("OnEvent", function(event)
4 years ago
if (event == "PLAYER_ENTERING_WORLD") then
3 years ago
return PGold:ScheduleTimer("GoldPluginTick", 10)
4 years ago
end
PGold:GoldPluginTick()
end)
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_GOLD"], "Interface\\Icons\\INV_Ore_Gold_01", PGold, "DETAILS_STATUSBAR_PLUGIN_PGold")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
end
3 years ago
---------BUILT-IN TIME PLUGIN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
do
3 years ago
--Create the plugin Object
4 years ago
local PTime = _detalhes:NewPluginObject ("Details_Statusbar_Time", DETAILSPLUGIN_ALWAYSENABLED, "STATUSBAR")
3 years ago
--Handle events (must have)
4 years ago
function PTime:OnDetailsEvent (event)
return
end
function PTime:UpdateClock()
if (self.options.timeType == 1) then
3 years ago
self.text:SetText(date ("%I:%M %p"))
4 years ago
elseif (self.options.timeType == 2) then
3 years ago
self.text:SetText(date ("%H:%M"))
4 years ago
end
end
function PTime:OnDisable()
3 years ago
self:CancelTimer(self.srt, true)
4 years ago
end
function PTime:OnEnable()
self.srt = self:ScheduleRepeatingTimer ("UpdateClock", 60, self)
self:UpdateClock()
end
function PTime:ExtraOptions()
3 years ago
--all widgets need to be placed on a table
4 years ago
local widgets = {}
3 years ago
--reference of extra window for custom options
4 years ago
local window = _G.DetailsStatusBarOptions2.MyObject
3 years ago
--build all your widgets -----------------------------------------------------------------------------------------------------------------------------
_detalhes.gump:NewLabel(window, _, "$parentTimeTypeLabel", "TimeTypeLabel", Loc ["STRING_PLUGIN_CLOCKTYPE"])
window.TimeTypeLabel:SetPoint(10, -15)
4 years ago
3 years ago
local onSelectClockType = function(_, child, thistype)
4 years ago
child.options.timeType = thistype
child:UpdateClock()
end
local clockTypes = {{value = 1, label = date ("%I:%M %p"), onclick = onSelectClockType},
{value = 2, label = date ("%H:%M"), onclick = onSelectClockType}
}
_detalhes.gump:NewDropDown (window, _, "$parentTimeTypeDropdown", "TimeTypeDropdown", 200, 20, function() return clockTypes end, 1) -- func, default
3 years ago
window.TimeTypeDropdown:SetPoint("left", window.TimeTypeLabel, "right", 2)
4 years ago
-----------------------------------------------------------------------------------------------------------------------------
3 years ago
--now we insert all widgets created on widgets table
table.insert(widgets, window.TimeTypeLabel)
table.insert(widgets, window.TimeTypeDropdown)
4 years ago
3 years ago
--after first call we replace this function with widgets table
4 years ago
PTime.ExtraOptions = widgets
end
3 years ago
--ExtraOptionsOnOpen is called when options are opened and plugin have custom options
--here we setup options widgets for get the values of clicked child and also for tell options window what child we are configuring
4 years ago
function PTime:ExtraOptionsOnOpen (child)
3 years ago
_G.DetailsStatusBarOptions2TimeTypeDropdown.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptions2TimeTypeDropdown.MyObject:Select(child.options.timeType, true)
4 years ago
end
3 years ago
--Create Plugin Frames (must have)
4 years ago
function PTime:CreateChildObject (instance)
local myframe = _detalhes.StatusBar:CreateChildFrame (instance, "DetailsPTimeInstance" .. instance:GetInstanceId(), DEFAULT_CHILD_WIDTH, DEFAULT_CHILD_HEIGHT)
local new_child = _detalhes.StatusBar:CreateChildTable (instance, PTime, myframe)
new_child.options.timeType = new_child.options.timeType or 1
return new_child
end
3 years ago
--Install
4 years ago
local install = _detalhes:InstallPlugin ("STATUSBAR", Loc ["STRING_PLUGIN_TIME"], "Interface\\Icons\\Spell_Shadow_LastingAfflictions", PTime, "DETAILS_STATUSBAR_PLUGIN_PTIME")
3 years ago
if (type(install) == "table" and install.error) then
print(install.errortext)
4 years ago
return
end
end
3 years ago
---------default options panel ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 years ago
3 years ago
local window = _detalhes.gump:NewPanel(UIParent, nil, "DetailsStatusBarOptions", nil, 300, 180)
tinsert(UISpecialFrames, "DetailsStatusBarOptions")
window:SetPoint("center", UIParent, "center")
4 years ago
window.locked = false
window.close_with_right = true
window.child = nil
window.instance = nil
3 years ago
window:SetFrameStrata("FULLSCREEN")
4 years ago
DetailsFramework:ApplyStandardBackdrop(window)
3 years ago
--window:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, edgeFile = [[Interface\AddOns\Details\images\border_2]], edgeSize=12})
--window:SetBackdropColor(0, 0, 0, 0.9)
4 years ago
3 years ago
local extraWindow = _detalhes.gump:NewPanel(window, nil, "DetailsStatusBarOptions2", "extra", 300, 180)
extraWindow:SetPoint("left", window, "right")
4 years ago
extraWindow.close_with_right = true
extraWindow.locked = false
extraWindow:Hide()
DetailsFramework:ApplyStandardBackdrop(extraWindow)
3 years ago
extraWindow:SetHook("OnHide", function()
4 years ago
window:Hide()
end)
3 years ago
--text style
_detalhes.gump:NewLabel(window, _, "$parentTextStyleLabel", "textstyle", Loc ["STRING_PLUGINOPTIONS_TEXTSTYLE"])
window.textstyle:SetPoint(10, -15)
4 years ago
3 years ago
local onSelectTextStyle = function(_, child, style)
4 years ago
window.instance.StatusBar.left.options.textStyle = style
window.instance.StatusBar.center.options.textStyle = style
window.instance.StatusBar.right.options.textStyle = style
3 years ago
if (window.instance.StatusBar.left.Refresh and type(window.instance.StatusBar.left.Refresh) == "function") then
4 years ago
window.instance.StatusBar.left:Refresh (window.instance.StatusBar.left)
end
3 years ago
if (window.instance.StatusBar.center.Refresh and type(window.instance.StatusBar.center.Refresh) == "function") then
4 years ago
window.instance.StatusBar.center:Refresh (window.instance.StatusBar.center)
end
3 years ago
if (window.instance.StatusBar.right.Refresh and type(window.instance.StatusBar.right.Refresh) == "function") then
4 years ago
window.instance.StatusBar.right:Refresh (window.instance.StatusBar.right)
end
end
local textStyle = {{value = 1, label = Loc ["STRING_PLUGINOPTIONS_ABBREVIATE"] .. " (105.5K)", onclick = onSelectTextStyle},
{value = 2, label = Loc ["STRING_PLUGINOPTIONS_COMMA"] .. " (105.500)", onclick = onSelectTextStyle},
{value = 3, label = Loc ["STRING_PLUGINOPTIONS_NOFORMAT"] .. " (105500)", onclick = onSelectTextStyle}}
_detalhes.gump:NewDropDown (window, _, "$parentTextStyleDropdown", "textstyleDropdown", 200, 20, function() return textStyle end, 1) -- func, default
3 years ago
window.textstyleDropdown:SetPoint("left", window.textstyle, "right", 2)
4 years ago
3 years ago
--text color
_detalhes.gump:NewLabel(window, _, "$parentTextColorLabel", "textcolor", Loc ["STRING_PLUGINOPTIONS_TEXTCOLOR"])
window.textcolor:SetPoint(10, -35)
4 years ago
local selectedColor = function()
local r, g, b, a = ColorPickerFrame:GetColorRGB()
3 years ago
window.textcolortexture:SetTexture(r, g, b, a)
4 years ago
--_detalhes.StatusBar:ApplyOptions (window.child, "textcolor", {r, g, b, a})
local color = {r, g, b, a}
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.left, "textcolor", color)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.center, "textcolor", color)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.right, "textcolor", color)
end
local canceledColor = function()
3 years ago
local r, g, b, a = unpack(ColorPickerFrame.previousValues)
window.textcolortexture:SetTexture(r, g, b, a)
4 years ago
local color = {r, g, b, a}
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.left, "textcolor", color)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.center, "textcolor", color)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.right, "textcolor", color)
end
local colorpick = function()
ColorPickerFrame.func = selectedColor
ColorPickerFrame.cancelFunc = canceledColor
ColorPickerFrame.opacityFunc = nil
ColorPickerFrame.hasOpacity = false
ColorPickerFrame.previousValues = window.child.options.textColor
3 years ago
ColorPickerFrame:SetParent(window.widget)
ColorPickerFrame:SetColorRGB (unpack(window.child.options.textColor))
4 years ago
ColorPickerFrame:Show()
end
3 years ago
_detalhes.gump:NewImage(window, nil, 160, 16, nil, nil, "textcolortexture", "$parentTextColorTexture")
window.textcolortexture:SetPoint("left", window.textcolor, "right", 2)
window.textcolortexture:SetTexture(1, 1, 1)
4 years ago
3 years ago
_detalhes.gump:NewButton(window, _, "$parentTextColorButton", "textcolorbutton", 160, 20, colorpick)
window.textcolorbutton:SetPoint("left", window.textcolor, "right", 2)
4 years ago
--window.textcolorbutton:InstallCustomTexture()
3 years ago
--text size
_detalhes.gump:NewLabel(window, _, "$parentFontSizeLabel", "fonsizeLabel", Loc ["STRING_PLUGINOPTIONS_TEXTSIZE"])
window.fonsizeLabel:SetPoint(10, -55)
4 years ago
--
_detalhes.gump:NewSlider (window, _, "$parentSliderFontSize", "fonsizeSlider", 170, 20, 7, 20, 1, 1)
3 years ago
window.fonsizeSlider:SetPoint("left", window.fonsizeLabel, "right", 2)
4 years ago
window.fonsizeSlider:SetThumbSize (50)
--window.fonsizeSlider.useDecimals = true
3 years ago
window.fonsizeSlider:SetHook("OnValueChange", function(self, child, amount)
4 years ago
--_detalhes.StatusBar:ApplyOptions (child, "textsize", amount)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.left, "textsize", amount)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.center, "textsize", amount)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.right, "textsize", amount)
end)
3 years ago
--text font
local onSelectFont = function(_, child, fontName)
4 years ago
--_detalhes.StatusBar:ApplyOptions (child, "textface", fontName)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.left, "textface", fontName)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.center, "textface", fontName)
_detalhes.StatusBar:ApplyOptions (window.instance.StatusBar.right, "textface", fontName)
end
local buildFontMenu = function()
local fontObjects = SharedMedia:HashTable ("font")
local fontTable = {}
3 years ago
for name, fontPath in pairs(fontObjects) do
4 years ago
fontTable[#fontTable+1] = {value = name, label = name, onclick = onSelectFont, font = fontPath}
end
return fontTable
end
3 years ago
_detalhes.gump:NewLabel(window, _, "$parentFontFaceLabel", "fontfaceLabel", Loc ["STRING_PLUGINOPTIONS_FONTFACE"])
window.fontfaceLabel:SetPoint(10, -75)
4 years ago
--
_detalhes.gump:NewDropDown (window, _, "$parentFontDropdown", "fontDropdown", 170, 20, buildFontMenu, nil)
3 years ago
window.fontDropdown:SetPoint("left", window.fontfaceLabel, "right", 2)
4 years ago
window:Hide()
3 years ago
--align mod X
_detalhes.gump:NewLabel(window, _, "$parentAlignXLabel", "alignXLabel", Loc ["STRING_PLUGINOPTIONS_TEXTALIGN_X"])
window.alignXLabel:SetPoint(10, -115)
4 years ago
--
_detalhes.gump:NewSlider (window, _, "$parentSliderAlignX", "alignXSlider", 160, 20, -20, 20, 1, 0)
3 years ago
window.alignXSlider:SetPoint("left", window.alignXLabel, "right", 2)
4 years ago
window.alignXSlider:SetThumbSize (40)
3 years ago
window.alignXSlider:SetHook("OnValueChange", function(self, child, amount)
4 years ago
_detalhes.StatusBar:ApplyOptions (child, "textxmod", amount)
end)
3 years ago
--align modY
_detalhes.gump:NewLabel(window, _, "$parentAlignYLabel", "alignYLabel", Loc ["STRING_PLUGINOPTIONS_TEXTALIGN_Y"])
window.alignYLabel:SetPoint(10, -135)
4 years ago
--
_detalhes.gump:NewSlider (window, _, "$parentSliderAlignY", "alignYSlider", 160, 20, -10, 10, 1, 0)
3 years ago
window.alignYSlider:SetPoint("left", window.alignYLabel, "right", 2)
4 years ago
window.alignYSlider:SetThumbSize (40)
3 years ago
window.alignYSlider:SetHook("OnValueChange", function(self, child, amount)
4 years ago
_detalhes.StatusBar:ApplyOptions (child, "textymod", amount)
end)
3 years ago
--right click to close
4 years ago
local c = window:CreateRightClickLabel ("short")
3 years ago
c:SetPoint("bottomleft", window, "bottomleft", 8, 5)
4 years ago
3 years ago
--open options
4 years ago
function _detalhes.StatusBar:OpenOptionsForChild (child)
window.child = child
window.instance = child.instance
3 years ago
_G.DetailsStatusBarOptionsTextStyleDropdown.MyObject:Select(child.options.textStyle, true)
4 years ago
3 years ago
_G.DetailsStatusBarOptionsTextColorTexture:SetColorTexture(child.options.textColor[1], child.options.textColor[2], child.options.textColor[3], child.options.textColor[4])
4 years ago
3 years ago
_G.DetailsStatusBarOptionsSliderFontSize.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptionsSliderFontSize.MyObject:SetValue(child.options.textSize)
4 years ago
3 years ago
_G.DetailsStatusBarOptionsFontDropdown.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptionsFontDropdown.MyObject:Select(child.options.textFace)
4 years ago
3 years ago
_G.DetailsStatusBarOptionsSliderAlignX.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptionsSliderAlignX.MyObject:SetValue(child.options.textXMod)
4 years ago
3 years ago
_G.DetailsStatusBarOptionsSliderAlignY.MyObject:SetFixedParameter(child)
_G.DetailsStatusBarOptionsSliderAlignY.MyObject:SetValue(child.options.textYMod)
4 years ago
_G.DetailsStatusBarOptions:Show()
if (child.ExtraOptions) then
3 years ago
if (type(child.ExtraOptions) == "function") then
4 years ago
child.ExtraOptions()
end
extraWindow:HideWidgets()
3 years ago
for _, widget in pairs(child.ExtraOptions) do
4 years ago
widget:Show()
end
child:ExtraOptionsOnOpen (child)
extraWindow:Show()
else
extraWindow:Hide()
end
end