- Added an options to use a customized skin file.

- Added an options to use a customized bar texture file.
- A Package with photoshop files with examples and the skin file for Minimalistic skin are available at WoW Interface.
- Added 'API Custom Displays.txt' on Details! folder, this file explain how to create scripts for custom displays.
This commit is contained in:
Tercio
2015-09-21 18:30:01 -03:00
parent 2a9bc8317c
commit f7dccde8b9
9 changed files with 354 additions and 50 deletions
+134
View File
@@ -0,0 +1,134 @@
A custom display is made with 4 scripts:
Required:
Search - this is the main script, it's responsible to build a list of players to be show in the window.
Optional:
Tooltip - it run when the user hover over a bar.
Total - runs when showing the bar, and helps format the total done.
Percent - also runs when showing the bar, it formats the percentage amount.
Search Code:
- The script receives 3 parameters: *Combat, *Container and *Instance.
*Combat - is the reference for the selected combat shown in the window (the one selected on segments menu).
*Container - is the place where the display mantain stored the results, Details! get the content inside the container and use to update the window.
*Instance - is the reference of the window where the custom display is being shown.
- Also, the script must return three values: total made by all players, the amount of the top player and the amount of players found by the script.
- The search script basicaly begins getting these three parameters and declaring our three return values:
local combat, instance_container, instance = ...
local total, top, amount = 0, 0, 0
- Then, we build our search for wherever we want to show, here we are building an example for Damage Done by Pets and Guardians.
- So, as we are working with damage, we want to get a list of Actors from the Damage Container of the combat and iterate it with ipairs:
local damage_container = combat:GetActorList( DETAILS_ATTRIBUTE_DAMAGE )
for i, actor in ipairs( damage_container ) do
--do stuff
end
- Actor, can be anything, a monster, player, boss, etc, so, we need to check if actor is a pet:
if (actor:IsPetOrGuardian()) then
--do stuff
end
- Now we found a pet, we need to get the damage done and find who is the owner of this pet, after that, we also need to check if the owner is a player:
local petOwner = actor.owner
if (petOwner:IsPlayer()) then
local petDamage = actor.total
end
- The next step is add the pet owner into the Container:
Container:AddValue (petOwner, petDamage)
- And in the and, we need to get the total, top and amount values. This is generally calculated inside our loop above, but just calling the API for the result is more handy:
total, top = Container:GetTotalAndHighestValue()
amount = Container:GetNumActors()
return total, top, amount
The finished script looks like this:
local Combat, Container, Instance = ...
local total, top, amount = 0, 0, 0
local damage_container = Combat:GetActorList( DETAILS_ATTRIBUTE_DAMAGE )
for i, actor in ipairs( damage_container ) do
if (actor:IsPetOrGuardian()) then
local petOwner = actor.owner
if (petOwner:IsPlayer()) then
local petDamage = actor.total
Container:AddValue( petOwner, petDamage )
end
end
end
total, top = Container:GetTotalAndHighestValue()
amount = Container:GetNumActors()
return total, top, amount
Tooltip Code:
- The script receives 3 parameters: *Actor, *Combat and *Instance. This script has no return value.
*Actor - in our case, actor is the petOwner.
local Actor, Combat, Instance = ...
local Format = Details:GetCurrentToKFunction()
- What we want where is show all pets the player used in the combat and how much damage each one made.
- The member .pets gives us a table with pet names that belongs to the actor.
local actorPets = Actor.pets
- Next move is iterate this table and get the pet actor from the combat.
- In Details! always use ">= 1" not "> 0", also when not using our format functions, use at least floor()
for i, petName in ipairs( actorPets ) do
local petActor = Combat( DETAILS_ATTRIBUTE_DAMAGE, petName)
if (petActor and petActor.total >= 1) then
--do stuff
end
end
- With the pet in hands, what we have to do now is add this pet to our tooltip.
- Details! uses 'GameCooltip' which is slight different than 'GameTooltip':
GameCooltip:AddLine( petName, Format( nil, petActor.total ) )
Details:AddTooltipBackgroundStatusbar()
The finished script looks like this:
local Actor, Combat, Instance = ...
local Format = Details:GetCurrentToKFunction()
local actorPets = Actor.pets
for i, petName in ipairs( actorPets ) do
local petActor = Combat( DETAILS_ATTRIBUTE_DAMAGE, petName)
if (petActor and petActor.total >= 1) then
GameCooltip:AddLine( petName, Format( nil, petActor.total ) )
Details:AddTooltipBackgroundStatusbar()
end
end
Total Code and Percent Code:
- Details! build the total and the percent automatically, these scripts are for special cases where you want to show something different, e.g. convert total into seconds/minutes.
- Both scripts receives 5 parameters, three are new to us:
*Value - the total made by this actor.
*Top - the value made by the rank 1 actor.
*Total - the total made by all actors.
local value, top, total, combat, instance = ...
local result = floor (value)
return total
+5 -1
View File
@@ -94,7 +94,7 @@ width = number, most of the times is ignored due to anchors settings.
height = number, most of the times is ignored due to anchors settings.
overlay = table {r, b, g, a}
instance:SetBarSettings (height, texture, colorclass, fixedcolor, backgroundtexture, backgroundcolorclass, backgroundfixedcolor, alpha, iconfile, barstart, spacement)
instance:SetBarSettings (height, texture, colorclass, fixedcolor, backgroundtexture, backgroundcolorclass, backgroundfixedcolor, alpha, iconfile, barstart, spacement, customtexture)
height = number, the height of the bars.
texture = texture name (SharedMedia), used on the statubar bar.
colorclass = boolean, if true, the bar is painted with the player's class color.
@@ -106,6 +106,10 @@ alpha = number.
iconfile = string, icon file path to be used on bars.
barstart = boolean, if true the bar attaches on the right side of the icon, else, on the left side (useful for transparent icons).
spacement = number, how much space between bars.
customtexture = string, file name of a .tga file inside WoW/Interface/ folder.
instance:SetUserCustomSkinFile (filename)
filename = string, name of the .tga file inside Interface folder to be used as the skin texture.
instance:SetBarModel (upper_enabled, upper_model, upper_alpha, lower_enabled, lower_model, lower_alpha)
upper_enabled = boolean
+8 -26
View File
File diff suppressed because one or more lines are too long
+19
View File
@@ -752,6 +752,25 @@
actors.new_actor.classe = actors.actor.classe
end
function atributo_custom:HasActor (actor)
return self._NameIndexTable [actor.nome or actor.name] and true or false
end
function atributo_custom:GetNumActors()
return #self._ActorTable
end
function atributo_custom:GetTotalAndHighestValue()
local total, top = 0, 0
for i, actor in ipairs (self._ActorTable) do
if (actor.value > top) then
top = actor.value
end
total = total + actor.value
end
return total, top
end
local icon_cache = {}
function atributo_custom:GetActorTable (actor, name_complement)
+4
View File
@@ -157,6 +157,10 @@
return self.grupo
end
--[[ exported]] function _detalhes:IsPetOrGuardian()
return self.owner and true or false
end
--[[ exported]] function _detalhes:IsPlayer()
if (self.flag_original) then
if (_bit_band (self.flag_original, OBJECT_TYPE_PLAYER) ~= 0) then
+3
View File
@@ -95,6 +95,7 @@ _detalhes.instance_defaults = {
ignore_mass_showhide = false,
--skin
skin = _detalhes.default_skin_to_use,
skin_custom = "",
--scale
window_scale = 1.0,
libwindow = {},
@@ -203,8 +204,10 @@ _detalhes.instance_defaults = {
font_face_file = SharedMedia:Fetch ("font", "Arial Narrow"),
--bar texture
texture = "Details D'ictum",
texture_custom = "",
--bar texture name
texture_file = [[Interface\AddOns\Details\images\bar4]],
texture_custom_file = "Interface\\",
--bar texture on mouse over
texture_highlight = [[Interface\FriendsFrame\UI-FriendsList-Highlight]],
--bar background texture
+148 -21
View File
@@ -4847,6 +4847,63 @@ function window:CreateFrame3()
local frame3 = window.options [3][1]
--> custom skin texture
local custom_texture = g:NewTextEntry (frame3, _, "$parentCustomTextureEntry", "CustomTextureEntry", 120, TEXTENTRY_HEIGHT, nil, nil, nil, nil, nil, options_dropdown_template)
local custom_texture_label = g:NewLabel (frame3, _, "$parentCustomTextureLabel", "CustomTextureLabel", Loc ["STRING_CUSTOM_SKIN_TEXTURE"], "GameFontHighlightLeft")
custom_texture:SetPoint ("left", custom_texture_label, "right", 2, 0)
custom_texture:SetHook ("OnEnterPressed", function()
local instance = _G.DetailsOptionsWindow.instance
local file_name = custom_texture.text
instance:SetUserCustomSkinFile (file_name)
if (_detalhes.options_group_edit and not DetailsOptionsWindow.loading_settings) then
for _, this_instance in ipairs (instance:GetInstanceGroup()) do
if (this_instance ~= instance) then
this_instance:SetUserCustomSkinFile (file_name)
end
end
end
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end)
window:CreateLineBackground2 (frame3, "CustomTextureEntry", "CustomTextureLabel", Loc ["STRING_CUSTOM_SKIN_TEXTURE_DESC"])
local custom_texture_cancel = g:NewButton (frame3.CustomTextureEntry, _, "$parentCustomTextureCancel", "CustomTextureCancel", 20, 20, function (self)
local instance = _G.DetailsOptionsWindow.instance
instance:SetUserCustomSkinFile ("")
if (_detalhes.options_group_edit and not DetailsOptionsWindow.loading_settings) then
for _, this_instance in ipairs (instance:GetInstanceGroup()) do
if (this_instance ~= instance) then
this_instance:SetUserCustomSkinFile ("")
end
end
end
custom_texture:SetText ("")
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end)
custom_texture_cancel:SetPoint ("left", frame3.CustomTextureEntry, "right", 2, 0)
custom_texture_cancel:SetNormalTexture ([[Interface\Buttons\UI-GroupLoot-Pass-Down]])
custom_texture_cancel:SetPushedTexture ([[Interface\Buttons\UI-GroupLoot-Pass-Up]])
custom_texture_cancel:GetNormalTexture():SetDesaturated (true)
custom_texture_cancel.tooltip = "Stop using the custom texture"
custom_texture_cancel:SetHook ("OnEnter", function (self, capsule)
self:GetNormalTexture():SetBlendMode("ADD")
end)
custom_texture_cancel:SetHook ("OnLeave", function (self, capsule)
self:GetNormalTexture():SetBlendMode("BLEND")
end)
--> import box
function frame3:CreateImportBox()
local textbox = g:NewSpecialLuaEditorEntry (frame3, 443, 80, "TextBox", "$parentTextBox", true)
textbox:SetPoint ("bottomleft", frame3, "bottomleft", 30, 30)
@@ -5000,7 +5057,8 @@ function window:CreateFrame3()
local buildSkinMenu = function()
local skinOptions = {}
for skin_name, skin_table in pairs (_detalhes.skins) do
local desc = "Author: |cFFFFFFFF" .. skin_table.author .. "|r\nVersion: |cFFFFFFFF" .. skin_table.version .. "|r\nSite: |cFFFFFFFF" .. skin_table.site .. "|r\n\nDesc: |cFFFFFFFF" .. skin_table.desc .. "|r"
local file = skin_table.file:gsub ([[Interface\AddOns\Details\images\skins\]], "")
local desc = "Author: |cFFFFFFFF" .. skin_table.author .. "|r\nVersion: |cFFFFFFFF" .. skin_table.version .. "|r\nSite: |cFFFFFFFF" .. skin_table.site .. "|r\n\nDesc: |cFFFFFFFF" .. skin_table.desc .. "|r\n\nFile: |cFFFFFFFF" .. file .. ".tga|r"
skinOptions [#skinOptions+1] = {value = skin_name, label = skin_name, onclick = onSelectSkin, icon = "Interface\\GossipFrame\\TabardGossipIcon", desc = desc}
end
return skinOptions
@@ -5390,19 +5448,20 @@ function window:CreateFrame3()
local left_side = {
{"SkinSelectionAnchorLabel", 1, true},
{"skinLabel", 2},
{"SkinPresetAnchorLabel", 3, true},
{"saveSkinLabel", 4},
{custom_texture_label, 3},
{"SkinPresetAnchorLabel", 4, true},
{"saveSkinLabel", 5},
{"loadCustomSkinLabel", 5, true},
{"removeCustomSkinLabel", 6},
{"ExportCustomSkinLabel", 7},
{"loadCustomSkinLabel", 6, true},
{"removeCustomSkinLabel", 7},
{"ExportCustomSkinLabel", 8},
{"ImportButton", 9, true},
{"makeDefault", 10},
{"applyToAll", 11},
{"ImportButton", 10, true},
{"makeDefault", 11},
{"applyToAll", 12},
{"PDWAnchor", 12, true},
{"PDWSkinLabel", 13},
{"PDWAnchor", 13, true},
{"PDWSkinLabel", 14},
}
local right_side = {
@@ -5606,6 +5665,69 @@ function window:CreateFrame4()
frame4.textureDropdown:SetPoint ("left", frame4.textureLabel, "right", 2)
window:CreateLineBackground2 (frame4, "textureDropdown", "textureLabel", Loc ["STRING_OPTIONS_BAR_TEXTURE_DESC"])
--> custom bar texture
local custom_texture = g:NewTextEntry (frame4, _, "$parentCustomTextureEntry", "CustomTextureEntry", 120, TEXTENTRY_HEIGHT, nil, nil, nil, nil, nil, options_dropdown_template)
local custom_texture_label = g:NewLabel (frame4, _, "$parentCustomTextureLabel", "CustomTextureLabel", Loc ["STRING_OPTIONS_BARS_CUSTOM_TEXTURE"], "GameFontHighlightLeft")
custom_texture:SetPoint ("left", custom_texture_label, "right", 2, 0)
custom_texture:SetHook ("OnEnterPressed", function()
local instance = _G.DetailsOptionsWindow.instance
local file_name = custom_texture.text
instance:SetBarSettings (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, file_name)
if (_detalhes.options_group_edit and not DetailsOptionsWindow.loading_settings) then
for _, this_instance in ipairs (instance:GetInstanceGroup()) do
if (this_instance ~= instance) then
this_instance:SetBarSettings (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, file_name)
end
end
end
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end)
window:CreateLineBackground2 (frame4, "CustomTextureEntry", "CustomTextureLabel", Loc ["STRING_CUSTOM_SKIN_TEXTURE_DESC"] .. Loc ["STRING_OPTIONS_BARS_CUSTOM_TEXTURE_DESC"])
local custom_texture_cancel = g:NewButton (frame4.CustomTextureEntry, _, "$parentCustomTextureCancel", "CustomTextureCancel", 20, 20, function (self)
local instance = _G.DetailsOptionsWindow.instance
instance:SetBarSettings (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "")
if (_detalhes.options_group_edit and not DetailsOptionsWindow.loading_settings) then
for _, this_instance in ipairs (instance:GetInstanceGroup()) do
if (this_instance ~= instance) then
this_instance:SetBarSettings (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "")
end
end
end
custom_texture:SetText ("")
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end)
custom_texture_cancel:SetPoint ("left", frame4.CustomTextureEntry, "right", 2, 0)
custom_texture_cancel:SetNormalTexture ([[Interface\Buttons\UI-GroupLoot-Pass-Down]])
custom_texture_cancel:SetPushedTexture ([[Interface\Buttons\UI-GroupLoot-Pass-Up]])
custom_texture_cancel:GetNormalTexture():SetDesaturated (true)
custom_texture_cancel.tooltip = "Stop using the custom texture"
custom_texture_cancel:SetHook ("OnEnter", function (self, capsule)
self:GetNormalTexture():SetBlendMode("ADD")
end)
custom_texture_cancel:SetHook ("OnLeave", function (self, capsule)
self:GetNormalTexture():SetBlendMode("BLEND")
end)
-- row texture color
local rowcolor_callback = function (button, r, g, b, a)
_G.DetailsOptionsWindow.instance:SetBarSettings (nil, nil, nil, {r, g, b})
@@ -6020,18 +6142,19 @@ function window:CreateFrame4()
--textures
{frame4.rowUpperTextureLabel, 1, true},
{frame4.textureLabel, 2},
{frame4.classColorsLabel, 3},
{frame4.rowPickColorLabel, 4},
{custom_texture_label, 3},
{frame4.classColorsLabel, 4},
{frame4.rowPickColorLabel, 5},
{frame4.rowLowerTextureLabel, 5, true},
{frame4.rowBackgroundLabel, 6},
{frame4.rowBackgroundColorByClassLabel, 7},
{frame4.rowBackgroundPickLabel, 8},
{frame4.rowLowerTextureLabel, 6, true},
{frame4.rowBackgroundLabel, 7},
{frame4.rowBackgroundColorByClassLabel, 8},
{frame4.rowBackgroundPickLabel, 9},
--icon
{frame4.rowIconsLabel, 9, true},
{frame4.iconFileLabel, 10},
{frame4.iconFileLabel2, 11},
{frame4.barStartLabel, 12},
{frame4.rowIconsLabel, 10, true},
{frame4.iconFileLabel, 11},
{frame4.iconFileLabel2, 12},
{frame4.barStartLabel, 13},
}
local right_side = {
@@ -10258,6 +10381,8 @@ end --> if not window
local skin = editing_instance.skin
local frame3 = _G.DetailsOptionsWindow3
_G.DetailsOptionsWindow3CustomTextureEntry:SetText (editing_instance.skin_custom)
_G.DetailsOptionsWindow3SkinDropdown.MyObject:SetFixedParameter (editing_instance)
_G.DetailsOptionsWindow3SkinDropdown.MyObject:Select (skin)
@@ -10301,6 +10426,8 @@ end --> if not window
--> window 4
_G.DetailsOptionsWindow4CustomTextureEntry:SetText (editing_instance.row_info.texture_custom)
_G.DetailsOptionsWindow4OrientationDropdown.MyObject:SetFixedParameter (editing_instance)
_G.DetailsOptionsWindow4OrientationDropdown.MyObject:Select (editing_instance.bars_inverted and 2 or 1, true)
_G.DetailsOptionsWindow4SortDropdown.MyObject:SetFixedParameter (editing_instance)
+33 -2
View File
@@ -4108,7 +4108,7 @@ function _detalhes:SetBarSpecIconSettings (enabled, iconfile, fulltrack)
end
function _detalhes:SetBarSettings (height, texture, colorclass, fixedcolor, backgroundtexture, backgroundcolorclass, backgroundfixedcolor, alpha, iconfile, barstart, spacement)
function _detalhes:SetBarSettings (height, texture, colorclass, fixedcolor, backgroundtexture, backgroundcolorclass, backgroundfixedcolor, alpha, iconfile, barstart, spacement, texture_custom)
--> bar start
if (type (barstart) == "boolean") then
@@ -4148,6 +4148,11 @@ function _detalhes:SetBarSettings (height, texture, colorclass, fixedcolor, back
self.row_info.texture_file = SharedMedia:Fetch ("statusbar", texture)
end
if (texture_custom) then
self.row_info.texture_custom = texture_custom
self.row_info.texture_custom_file = "Interface\\" .. self.row_info.texture_custom
end
--> color by class
if (type (colorclass) == "boolean") then
self.row_info.texture_class_colors = colorclass
@@ -4350,7 +4355,16 @@ function _detalhes:InstanceRefreshRows (instancia)
--> texture
local texture_file = SharedMedia:Fetch ("statusbar", self.row_info.texture)
local texture_file2 = SharedMedia:Fetch ("statusbar", self.row_info.texture_background)
--> update texture files
self.row_info.texture_file = texture_file
self.row_info.texture_background_file = texture_file2
if (type (self.row_info.texture_custom) == "string" and self.row_info.texture_custom ~= "") then
texture_file = "Interface\\" .. self.row_info.texture_custom
--> update texture file
self.row_info.texture_custom_file = texture_file
end
--> outline values
local left_text_outline = self.row_info.textL_outline
local right_text_outline = self.row_info.textR_outline
@@ -6122,6 +6136,20 @@ local build_segment_list = function (self, elapsed)
end
-- ~skin
function _detalhes:SetUserCustomSkinFile (file)
if (type (file) ~= "string") then
error ("SetUserCustomSkinFile() file must be a string.")
end
if (file:find ("\\") or file:find ("/")) then
error ("SetUserCustomSkinFile() file must be only the file name (with out up folders) and slashes.")
end
self.skin_custom = file
self:ChangeSkin()
end
function _detalhes:ChangeSkin (skin_name)
if (not skin_name) then
@@ -6220,6 +6248,9 @@ function _detalhes:ChangeSkin (skin_name)
local skin_file = this_skin.file
--> set textures
if (self.skin_custom ~= "") then
skin_file = "Interface\\" .. self.skin_custom
end
self.baseframe.cabecalho.ball:SetTexture (skin_file) --> bola esquerda
self.baseframe.cabecalho.emenda:SetTexture (skin_file) --> emenda que liga a bola a textura do centro
Binary file not shown.