Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] TWW Support #678

Merged
merged 21 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ read_globals = {

-- FrameXML
'BossTargetFrameContainer',
'Clamp',
'ColorMixin',
'ComboFrame',
'CompactArenaFrame',
Expand Down Expand Up @@ -53,6 +54,7 @@ read_globals = {
'C_IncomingSummon',
'C_NamePlate',
'C_PvP',
'C_Spell',
'C_UnitAuras',

-- API
Expand All @@ -78,6 +80,7 @@ read_globals = {
'GetUnitPowerBarInfo',
'GetUnitPowerBarInfoByID',
'GetUnitPowerBarStringsByID',
'GetUnitTotalModifiedMaxHealthPercent',
'HasLFGRestrictions',
'InCombatLockdown',
'IsLoggedIn',
Expand Down
4 changes: 2 additions & 2 deletions blizzard.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local _, ns = ...
local oUF = ns.oUF

-- sourced from FrameXML/TargetFrame.lua
-- sourced from Blizzard_UnitFrame/TargetFrame.lua
local MAX_BOSS_FRAMES = _G.MAX_BOSS_FRAMES or 5

-- sourced from FrameXML/RaidFrame.lua
-- sourced from Blizzard_FrameXMLBase/Shared/Constants.lua
local MEMBERS_PER_RAID_GROUP = _G.MEMBERS_PER_RAID_GROUP or 5

local hookedFrames = {}
Expand Down
47 changes: 25 additions & 22 deletions colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local colorMixin = {
}

--[[ Colors: oUF:CreateColor(r, g, b[, a])
Wrapper for [SharedXML\Color.lua's ColorMixin](https://wowpedia.fandom.com/wiki/ColorMixin), extended to support indexed colors used in oUF, as
Wrapper for [SharedXML\Color.lua's ColorMixin](https://warcraft.wiki.gg/wiki/ColorMixin), extended to support indexed colors used in oUF, as
well as extra methods for dealing with atlases.

The rgb values can be either normalized (0-1) or bytes (0-255).
Expand Down Expand Up @@ -168,32 +168,35 @@ for power, color in next, PowerBarColor do
end
end

-- sourced from FrameXML/Constants.lua
colors.power[0] = colors.power.MANA
colors.power[1] = colors.power.RAGE
colors.power[2] = colors.power.FOCUS
colors.power[3] = colors.power.ENERGY
colors.power[4] = colors.power.COMBO_POINTS
colors.power[5] = colors.power.RUNES
colors.power[6] = colors.power.RUNIC_POWER
colors.power[7] = colors.power.SOUL_SHARDS
colors.power[8] = colors.power.LUNAR_POWER
colors.power[9] = colors.power.HOLY_POWER
colors.power[11] = colors.power.MAELSTROM
colors.power[12] = colors.power.CHI
colors.power[13] = colors.power.INSANITY
colors.power[16] = colors.power.ARCANE_CHARGES
colors.power[17] = colors.power.FURY
colors.power[18] = colors.power.PAIN
-- fallback integer index to named index
-- sourced from PowerBarColor - Blizzard_UnitFrame/Mainline/PowerBarColorUtil.lua
colors.power[Enum.PowerType.Mana or 0] = colors.power.MANA
colors.power[Enum.PowerType.Rage or 1] = colors.power.RAGE
colors.power[Enum.PowerType.Focus or 2] = colors.power.FOCUS
colors.power[Enum.PowerType.Energy or 3] = colors.power.ENERGY
colors.power[Enum.PowerType.ComboPoints or 4] = colors.power.COMBO_POINTS
colors.power[Enum.PowerType.Runes or 5] = colors.power.RUNES
colors.power[Enum.PowerType.RunicPower or 6] = colors.power.RUNIC_POWER
colors.power[Enum.PowerType.SoulShards or 7] = colors.power.SOUL_SHARDS
colors.power[Enum.PowerType.LunarPower or 8] = colors.power.LUNAR_POWER
colors.power[Enum.PowerType.HolyPower or 9] = colors.power.HOLY_POWER
colors.power[Enum.PowerType.Maelstrom or 11] = colors.power.MAELSTROM
colors.power[Enum.PowerType.Insanity or 13] = colors.power.INSANITY
colors.power[Enum.PowerType.Fury or 17] = colors.power.FURY
colors.power[Enum.PowerType.Pain or 18] = colors.power.PAIN

-- these two don't have fallback values in PowerBarColor, but we want them
colors.power[Enum.PowerType.Chi or 12] = colors.power.CHI
colors.power[Enum.PowerType.ArcaneCharges or 16] = colors.power.ARCANE_CHARGES

-- there's no official colour for evoker's essence
-- use the average colour of the essence texture instead
colors.power.ESSENCE = oUF:CreateColor(100, 173, 206)
colors.power[19] = colors.power.ESSENCE
colors.power[Enum.PowerType.Essence or 19] = colors.power.ESSENCE

-- alternate power, sourced from FrameXML/CompactUnitFrame.lua
-- alternate power, sourced from Blizzard_UnitFrame/Mainline/CompactUnitFrame.lua
colors.power.ALTERNATE = oUF:CreateColor(0.7, 0.7, 0.6)
colors.power[10] = colors.power.ALTERNATE
colors.power[Enum.PowerType.Alternate or 10] = colors.power.ALTERNATE

for i = 0, 3 do
colors.threat[i] = oUF:CreateColor(GetThreatStatusColor(i))
Expand All @@ -211,7 +214,7 @@ local function colorsAndPercent(a, b, ...)
return relperc, select((segment * 3) + 1, ...)
end

-- http://www.wowwiki.com/ColorGradient
-- https://warcraft.wiki.gg/wiki/ColorGradient
--[[ Colors: oUF:RGBColorGradient(a, b, ...)
Used to convert a percent value (the quotient of `a` and `b`) into a gradient from 2 or more RGB colors. If more than 2
colors are passed, the gradient will be between the two colors which perc lies in an evenly divided range. A RGB color
Expand Down
5 changes: 3 additions & 2 deletions elements/additionalpower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following options are listed by priority. The first check that returns true
.colorPower - Use `self.colors.power[token]` to color the bar based on the player's additional power type
(boolean)
.colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the
second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean)
second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean)
.colorSmooth - Use `self.colors.smooth` to color the bar with a smooth gradient based on the player's current
additional power percentage (boolean)

Expand Down Expand Up @@ -59,8 +59,9 @@ local oUF = ns.oUF

local _, playerClass = UnitClass('player')

-- sourced from FrameXML/AlternatePowerBar.lua
-- sourced from Blizzard_UnitFrame/AlternatePowerBar.lua
local ALT_POWER_BAR_PAIR_DISPLAY_INFO = _G.ALT_POWER_BAR_PAIR_DISPLAY_INFO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?

local ADDITIONAL_POWER_BAR_NAME = 'MANA'
local ADDITIONAL_POWER_BAR_INDEX = 0

Expand Down
11 changes: 6 additions & 5 deletions elements/alternativepower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ A default texture will be applied if the widget is a StatusBar and doesn't have
The following options are listed by priority. The first check that returns true decides the color of the bar.

.colorThreat - Use `self.colors.threat[threat]` to color the bar based on the unit's threat status. `threat` is
defined by the first return of [UnitThreatSituation](https://wow.gamepedia.com/API_UnitThreatSituation) (boolean)
defined by the first return of [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation) (boolean)
.colorPower - Use `self.colors.power[token]` to color the bar based on the unit's alternative power type
(boolean)
.colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the
second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean)
second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean)
.colorClassNPC - Use `self.colors.class[class]` to color the bar if the unit is a NPC (boolean)
.colorSelection - Use `self.colors.selection[selection]` to color the bar based on the unit's selection color.
`selection` is defined by the return value of Private.unitSelectionType, a wrapper function
for [UnitSelectionType](https://wow.gamepedia.com/API_UnitSelectionType) (boolean)
for [UnitSelectionType](https://warcraft.wiki.gg/wiki/API_UnitSelectionType) (boolean)
.colorReaction - Use `self.colors.reaction[reaction]` to color the bar based on the player's reaction towards the
unit. `reaction` is defined by the return value of
[UnitReaction](http://wowprogramming.com/docs/api/UnitReaction.html) (boolean)
[UnitReaction](https://warcraft.wiki.gg/wiki/API_UnitReaction) (boolean)
.colorSmooth - Use `self.colors.smooth` to color the bar with a smooth gradient based on the unit's current
alternative power percentage (boolean)

Expand All @@ -56,8 +56,9 @@ local Private = oUF.Private

local unitSelectionType = Private.unitSelectionType

-- sourced from FrameXML/UnitPowerBarAlt.lua
-- sourced from Blizzard_UnitFrame/UnitPowerBarAlt.lua
local ALTERNATE_POWER_INDEX = Enum.PowerType.Alternate or 10

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?

local ALTERNATE_POWER_NAME = 'ALTERNATE'

local function updateTooltip(self)
Expand Down
12 changes: 6 additions & 6 deletions elements/auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ local function updateAura(element, unit, data, position)
* self - the widget holding the aura buttons
* button - the updated aura button (Button)
* unit - the unit for which the update has been triggered (string)
* data - the [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
* data - the [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table)
* position - the actual position of the aura button (number)
--]]
if(element.PostUpdateButton) then
Expand Down Expand Up @@ -273,7 +273,7 @@ local function processData(element, unit, data)

* self - the widget holding the aura buttons
* unit - the unit for which the update has been triggered (string)
* data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
* data - [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table)

## Returns

Expand Down Expand Up @@ -333,7 +333,7 @@ local function UpdateAuras(self, event, unit, updateInfo)

* self - the widget holding the aura buttons
* unit - the unit for which the update has been triggered (string)
* data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table)
* data - [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table)

## Returns

Expand Down Expand Up @@ -449,12 +449,12 @@ local function UpdateAuras(self, event, unit, updateInfo)
--[[ Override: Auras:SortBuffs(a, b)
Defines a custom sorting algorithm for ordering the auras.

Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare).
Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare).
--]]
--[[ Override: Auras:SortAuras(a, b)
Defines a custom sorting algorithm for ordering the auras.

Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare).
Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare).

Overridden by the more specific SortBuffs and/or SortDebuffs overrides if they are defined.
--]]
Expand All @@ -480,7 +480,7 @@ local function UpdateAuras(self, event, unit, updateInfo)
--[[ Override: Auras:SortDebuffs(a, b)
Defines a custom sorting algorithm for ordering the auras.

Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare).
Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare).
--]]
table.sort(auras.sortedDebuffs, auras.SortDebuffs or auras.SortAuras or SortAuras)
end
Expand Down
6 changes: 4 additions & 2 deletions elements/classpower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Handles the visibility and updating of the player's class resources (like Chi Or

## Widget

ClassPower - An `table` consisting of as many StatusBars as the theoretical maximum return of [UnitPowerMax](http://wowprogramming.com/docs/api/UnitPowerMax.html).
ClassPower - An `table` consisting of as many StatusBars as the theoretical maximum return of [UnitPowerMax](https://warcraft.wiki.gg/wiki/API_UnitPowerMax).

## Sub-Widgets

Expand All @@ -22,6 +22,7 @@ If the sub-widgets are StatusBars, their minimum and maximum values will be set

Supported class powers:
- All - Combo Points
- Evoker - Essence
- Mage - Arcane Charges
- Monk - Chi Orbs
- Paladin - Holy Power
Expand Down Expand Up @@ -49,10 +50,11 @@ local oUF = ns.oUF

local _, PlayerClass = UnitClass('player')

-- sourced from FrameXML/Constants.lua
-- sourced from Blizzard_FrameXMLBase/Constants.lua
local SPEC_MAGE_ARCANE = _G.SPEC_MAGE_ARCANE or 1
local SPEC_MONK_WINDWALKER = _G.SPEC_MONK_WINDWALKER or 3
local SPEC_WARLOCK_DESTRUCTION = _G.SPEC_WARLOCK_DESTRUCTION or 3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?

local SPELL_POWER_ENERGY = Enum.PowerType.Energy or 3
local SPELL_POWER_COMBO_POINTS = Enum.PowerType.ComboPoints or 4
local SPELL_POWER_SOUL_SHARDS = Enum.PowerType.SoulShards or 7
Expand Down
13 changes: 12 additions & 1 deletion elements/grouproleindicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ A default texture will be applied if the widget is a Texture and doesn't have a
local _, ns = ...
local oUF = ns.oUF

-- originally sourced from Blizzard_Deprecated/Deprecated_10_1_5.lua
local function GetTexCoordsForRoleSmallCircle(role)
if(role == 'TANK') then
return 0, 19 / 64, 22 / 64, 41 / 64
elseif(role == 'HEALER') then
return 20 / 64, 39 / 64, 1 / 64, 20 / 64
elseif(role == 'DAMAGER') then
return 20 / 64, 39 / 64, 22 / 64, 41 / 64
end
end

local function Update(self, event)
local element = self.GroupRoleIndicator

Expand All @@ -49,7 +60,7 @@ local function Update(self, event)
Called after the element has been updated.

* self - the GroupRoleIndicator element
* role - the role as returned by [UnitGroupRolesAssigned](http://wowprogramming.com/docs/api/UnitGroupRolesAssigned.html)
* role - the role as returned by [UnitGroupRolesAssigned](https://warcraft.wiki.gg/wiki/API_UnitGroupRolesAssigned)
--]]
if(element.PostUpdate) then
return element:PostUpdate(role)
Expand Down
Loading