Skip to content

Commit

Permalink
- Added an options to use a customized skin file.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Tercio authored and Tercio committed Sep 21, 2015
1 parent 2a9bc83 commit f7dccde
Show file tree
Hide file tree
Showing 9 changed files with 355 additions and 51 deletions.
134 changes: 134 additions & 0 deletions API Custom Displays.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion API UI.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
34 changes: 8 additions & 26 deletions boot.lua

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions classes/classe_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions classes/classe_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions classes/classe_instancia_include.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit f7dccde

Please sign in to comment.