Files
coa-details/framework/framework.lua
T
tercio e406fe464b - Revamp on Death report.
- Data send to broker now is correctly formated.
- Modified the percentage method used on Comparison Panel.
- Added options panel for Encounter Details.

- New API: _detalhes:GetCurrentCombat() returns the current combat object
- New API: _detalhes:GetCombatSegments() returns a numeric table with all stored combats.
- New API: _detalhes:GetZoneType() returns the type from GetInstanceInfo().
- New API: _detalhes:InGroup()return true if Details! is considering the player inside a group.
- New API: _detalhes:GetOnlyName (string) return self.nome or string without realm name.

- New Event: ZONE_TYPE_CHANGED, it's triggered when the player change the zoze type.
- New Event: GROUP_ONENTER GROUP_ONLEAVE, trigger when the player left or enter in a group.
2014-07-17 17:57:32 -03:00

182 lines
5.6 KiB
Lua

--> details main objects
local _detalhes = _G._detalhes
local gump = _detalhes.gump
local _type = type
local _unpack = unpack
local _
gump.LabelNameCounter = 1
gump.PictureNameCounter = 1
gump.debug = false
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> points
function gump:CheckPoints (v1, v2, v3, v4, v5, object)
--bg_esq:SetPoint ("topleft", DmgRankFrame, 10, -215)
if (not v1 and not v2) then
return "topleft", object.widget:GetParent(), "topleft", 0, 0
end
if (_type (v1) == "string") then
local frameGlobal = _G [v1]
if (frameGlobal and frameGlobal.GetObjectType) then
return gump:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
end
elseif (_type (v2) == "string") then
local frameGlobal = _G [v2]
if (frameGlobal and frameGlobal.GetObjectType) then
return gump:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
end
end
if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
--else
--> :setpoint ("left", frame, "left", 10, 10)
end
elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
elseif (_type (v1) == "number") then --> :setpoint (x, y)
v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
end
if (not v2) then
v2 = object.widget:GetParent()
elseif (v2.dframework) then
v2 = v2.widget
end
return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> color scheme
function gump:NewColor (_colorname, _colortable, _green, _blue, _alpha)
if (_type (_colorname) ~= "string") then
return _detalhes:NewError ("color name must be a string.")
end
if (gump.alias_text_colors [_colorname]) then
return _detalhes:NewError (_colorname .. " already exists.")
end
if (_type (_colortable) == "table") then
if (_colortable[1] and _colortable[2] and _colortable[3]) then
_colortable[4] = _colortable[4] or 1
gump.alias_text_colors [_colorname] = _colortable
else
return _detalhes:NewError ("invalid color table.")
end
elseif (_colortable and _green and _blue) then
_alpha = _alpha or 1
gump.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
else
return _detalhes:NewError ("invalid parameter.")
end
return true
end
function gump:IsHtmlColor (color)
return gump.alias_text_colors [color]
end
local tn = tonumber
function gump:ParseColors (_arg1, _arg2, _arg3, _arg4)
if (_type (_arg1) == "table") then
_arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
elseif (_type (_arg1) == "string") then
if (string.find (_arg1, "#")) then
_arg1 = _arg1:gsub ("#","")
if (string.len (_arg1) == 8) then --alpha
_arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, tn ("0x" .. _arg1:sub (7, 8))/255, tn ("0x" .. _arg1:sub (1, 2))/255
else
_arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (1, 2))/255, tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, 1
end
else
local color = gump.alias_text_colors [_arg1]
if (color) then
_arg1, _arg2, _arg3, _arg4 = _unpack (color)
else
_arg1, _arg2, _arg3, _arg4 = _unpack (gump.alias_text_colors.none)
end
end
end
if (not _arg1) then
_arg1 = 1
end
if (not _arg2) then
_arg2 = 1
end
if (not _arg3) then
_arg3 = 1
end
if (not _arg4) then
_arg4 = 1
end
return _arg1, _arg2, _arg3, _arg4
end
function gump:BuildMenu (parent, menu, x_offset, y_offset, height)
local cur_x = x_offset
local cur_y = y_offset
local max_x = 0
for index, widget_table in ipairs (menu) do
if (widget_table.type == "select" or widget_table.type == "dropdown") then
local dropdown = self:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get())
dropdown.tooltip = widget_table.desc
local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
dropdown:SetPoint ("left", label, "right", 2)
label:SetPoint (cur_x, cur_y)
local size = label.widget:GetStringWidth() + 140 + 4
if (size > max_x) then
max_x = size
end
elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
local switch = self:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get())
switch.tooltip = widget_table.desc
switch.OnSwitch = widget_table.set
local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
switch:SetPoint ("left", label, "right", 2)
label:SetPoint (cur_x, cur_y)
local size = label.widget:GetStringWidth() + 60 + 4
if (size > max_x) then
max_x = size
end
end
cur_y = cur_y - 20
if (cur_y > height) then
cur_y = y_offset
cur_x = max_x
end
end
end