fix(class): resolve player class at login and defer class-specific defaults/options (was hardcoded DRUID)
This commit is contained in:
@@ -352,7 +352,11 @@ Spi -> MP5, MP5NC, HP5, SpellDmg, Healing
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Class specific defaults
|
-- Class specific defaults
|
||||||
if class == "DRUID" then
|
-- Applied at OnInitialize after UnitClass("player") is available.
|
||||||
|
-- CoA custom classes (not in the vanilla if/elseif ladder) fall through
|
||||||
|
-- to no block, which is the correct generic fallback for classless chars.
|
||||||
|
local function applyClassProfileDefaults(cls)
|
||||||
|
if cls == "DRUID" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
@@ -381,7 +385,7 @@ if class == "DRUID" then
|
|||||||
profileDefault.showHealingFromSpi = true
|
profileDefault.showHealingFromSpi = true
|
||||||
profileDefault.sumIgnoreCloth = false
|
profileDefault.sumIgnoreCloth = false
|
||||||
profileDefault.sumIgnoreLeather = false
|
profileDefault.sumIgnoreLeather = false
|
||||||
elseif class == "HUNTER" then
|
elseif cls == "HUNTER" then
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumMP = true
|
profileDefault.sumMP = true
|
||||||
@@ -399,7 +403,7 @@ elseif class == "HUNTER" then
|
|||||||
profileDefault.showAPFromSta = true
|
profileDefault.showAPFromSta = true
|
||||||
profileDefault.sumIgnoreLeather = false
|
profileDefault.sumIgnoreLeather = false
|
||||||
profileDefault.sumIgnoreMail = false
|
profileDefault.sumIgnoreMail = false
|
||||||
elseif class == "MAGE" then
|
elseif cls == "MAGE" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumMP = true
|
profileDefault.sumMP = true
|
||||||
@@ -417,7 +421,7 @@ elseif class == "MAGE" then
|
|||||||
profileDefault.showMP5FromSpi = true
|
profileDefault.showMP5FromSpi = true
|
||||||
profileDefault.showSpellCritFromSpi = true -- Molten Armor
|
profileDefault.showSpellCritFromSpi = true -- Molten Armor
|
||||||
profileDefault.sumIgnoreCloth = false
|
profileDefault.sumIgnoreCloth = false
|
||||||
elseif class == "PALADIN" then
|
elseif cls == "PALADIN" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
@@ -448,7 +452,7 @@ elseif class == "PALADIN" then
|
|||||||
profileDefault.sumIgnoreLeather = false
|
profileDefault.sumIgnoreLeather = false
|
||||||
profileDefault.sumIgnoreMail = false
|
profileDefault.sumIgnoreMail = false
|
||||||
profileDefault.sumIgnorePlate = false
|
profileDefault.sumIgnorePlate = false
|
||||||
elseif class == "PRIEST" then
|
elseif cls == "PRIEST" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumMP = true
|
profileDefault.sumMP = true
|
||||||
@@ -466,7 +470,7 @@ elseif class == "PRIEST" then
|
|||||||
profileDefault.showSpellDmgFromSpi = true
|
profileDefault.showSpellDmgFromSpi = true
|
||||||
profileDefault.showHealingFromSpi = true
|
profileDefault.showHealingFromSpi = true
|
||||||
profileDefault.sumIgnoreCloth = false
|
profileDefault.sumIgnoreCloth = false
|
||||||
elseif class == "ROGUE" then
|
elseif cls == "ROGUE" then
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumResilience = true
|
profileDefault.sumResilience = true
|
||||||
@@ -478,7 +482,7 @@ elseif class == "ROGUE" then
|
|||||||
profileDefault.sumArmorPenetration = true
|
profileDefault.sumArmorPenetration = true
|
||||||
profileDefault.showSpellCritFromInt = false
|
profileDefault.showSpellCritFromInt = false
|
||||||
profileDefault.sumIgnoreLeather = false
|
profileDefault.sumIgnoreLeather = false
|
||||||
elseif class == "SHAMAN" then
|
elseif cls == "SHAMAN" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
@@ -499,7 +503,7 @@ elseif class == "SHAMAN" then
|
|||||||
profileDefault.sumIgnoreCloth = false
|
profileDefault.sumIgnoreCloth = false
|
||||||
profileDefault.sumIgnoreLeather = false
|
profileDefault.sumIgnoreLeather = false
|
||||||
profileDefault.sumIgnoreMail = false
|
profileDefault.sumIgnoreMail = false
|
||||||
elseif class == "WARLOCK" then
|
elseif cls == "WARLOCK" then
|
||||||
profileDefault.ratingSpell = true
|
profileDefault.ratingSpell = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumMP = true
|
profileDefault.sumMP = true
|
||||||
@@ -515,7 +519,7 @@ elseif class == "WARLOCK" then
|
|||||||
profileDefault.showMP5FromSpi = true
|
profileDefault.showMP5FromSpi = true
|
||||||
profileDefault.showSpellDmgFromSpi = true
|
profileDefault.showSpellDmgFromSpi = true
|
||||||
profileDefault.sumIgnoreCloth = false
|
profileDefault.sumIgnoreCloth = false
|
||||||
elseif class == "WARRIOR" then
|
elseif cls == "WARRIOR" then
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumResilience = true
|
profileDefault.sumResilience = true
|
||||||
@@ -536,7 +540,7 @@ elseif class == "WARRIOR" then
|
|||||||
profileDefault.sumIgnoreMail = false
|
profileDefault.sumIgnoreMail = false
|
||||||
end
|
end
|
||||||
profileDefault.sumIgnorePlate = false
|
profileDefault.sumIgnorePlate = false
|
||||||
elseif class == "DEATHKNIGHT" then
|
elseif cls == "DEATHKNIGHT" then
|
||||||
profileDefault.ratingPhysical = true
|
profileDefault.ratingPhysical = true
|
||||||
profileDefault.sumHP = true
|
profileDefault.sumHP = true
|
||||||
profileDefault.sumResilience = true
|
profileDefault.sumResilience = true
|
||||||
@@ -554,6 +558,7 @@ elseif class == "DEATHKNIGHT" then
|
|||||||
profileDefault.showAPFromArmor = true
|
profileDefault.showAPFromArmor = true
|
||||||
profileDefault.sumIgnorePlate = false
|
profileDefault.sumIgnorePlate = false
|
||||||
end
|
end
|
||||||
|
end -- applyClassProfileDefaults
|
||||||
|
|
||||||
local defaults = {}
|
local defaults = {}
|
||||||
defaults.profile = profileDefault
|
defaults.profile = profileDefault
|
||||||
@@ -2252,7 +2257,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Class specific options
|
-- Class specific options
|
||||||
if class == "DRUID" then
|
-- Applied at OnInitialize (before SetupOptions) after UnitClass("player") is available.
|
||||||
|
-- CoA custom classes fall through to no block: no class-specific UI entries shown.
|
||||||
|
local function applyClassOptions(cls)
|
||||||
|
if cls == "DRUID" then
|
||||||
options.args.stat.args.agi.args.heal = { -- Nurturing Instinct (Rank 2) - 2,14
|
options.args.stat.args.agi.args.heal = { -- Nurturing Instinct (Rank 2) - 2,14
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2307,7 +2315,7 @@ if class == "DRUID" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "HUNTER" then
|
elseif cls == "HUNTER" then
|
||||||
options.args.stat.args.int.args.rap = { -- Careful Aim
|
options.args.stat.args.int.args.rap = { -- Careful Aim
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2326,7 +2334,7 @@ elseif class == "HUNTER" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "MAGE" then
|
elseif cls == "MAGE" then
|
||||||
options.args.stat.args.int.args.dmg = { -- Mind Mastery (Rank 5) - 1,22
|
options.args.stat.args.int.args.dmg = { -- Mind Mastery (Rank 5) - 1,22
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2363,7 +2371,7 @@ elseif class == "MAGE" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "PALADIN" then
|
elseif cls == "PALADIN" then
|
||||||
options.args.stat.args.int.args.dmg = { -- Paladin: Holy Guidance (Rank 5) - 1,19
|
options.args.stat.args.int.args.dmg = { -- Paladin: Holy Guidance (Rank 5) - 1,19
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2400,7 +2408,7 @@ elseif class == "PALADIN" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "PRIEST" then
|
elseif cls == "PRIEST" then
|
||||||
options.args.stat.args.spi.args.mp5 = { -- Meditation (Rank 3) - 1,9
|
options.args.stat.args.spi.args.mp5 = { -- Meditation (Rank 3) - 1,9
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2428,8 +2436,8 @@ elseif class == "PRIEST" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "ROGUE" then
|
elseif cls == "ROGUE" then
|
||||||
elseif class == "SHAMAN" then
|
elseif cls == "SHAMAN" then
|
||||||
options.args.stat.args.str.args.dmg = { -- Mental Quickness (Rank 3) - 2,15
|
options.args.stat.args.str.args.dmg = { -- Mental Quickness (Rank 3) - 2,15
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2475,7 +2483,7 @@ elseif class == "SHAMAN" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "WARLOCK" then
|
elseif cls == "WARLOCK" then
|
||||||
options.args.stat.args.sta.args.dmg = { -- Demonic Knowledge (Rank 3) - 2,20 - UnitExists("pet")
|
options.args.stat.args.sta.args.dmg = { -- Demonic Knowledge (Rank 3) - 2,20 - UnitExists("pet")
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2512,7 +2520,7 @@ elseif class == "WARLOCK" then
|
|||||||
get = getProfileOption,
|
get = getProfileOption,
|
||||||
set = setProfileOptionAndClearCache,
|
set = setProfileOptionAndClearCache,
|
||||||
}
|
}
|
||||||
elseif class == "WARRIOR" then
|
elseif cls == "WARRIOR" then
|
||||||
options.args.stat.args.armor = { -- Armored to the Teeth (Rank 3) - 2,1
|
options.args.stat.args.armor = { -- Armored to the Teeth (Rank 3) - 2,1
|
||||||
type = 'group',
|
type = 'group',
|
||||||
order = 7,
|
order = 7,
|
||||||
@@ -2530,7 +2538,7 @@ elseif class == "WARRIOR" then
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
elseif class == "DEATHKNIGHT" then
|
elseif cls == "DEATHKNIGHT" then
|
||||||
options.args.stat.args.str.args.parry = { -- Death Knight: Forceful Deflection - Passive
|
options.args.stat.args.str.args.parry = { -- Death Knight: Forceful Deflection - Passive
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
width = "full",
|
width = "full",
|
||||||
@@ -2558,6 +2566,7 @@ elseif class == "DEATHKNIGHT" then
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end -- applyClassOptions
|
||||||
|
|
||||||
function RatingBuster:SetupOptions()
|
function RatingBuster:SetupOptions()
|
||||||
-- Inject profile options
|
-- Inject profile options
|
||||||
@@ -2660,6 +2669,16 @@ end
|
|||||||
|
|
||||||
-- OnInitialize(name) called at ADDON_LOADED
|
-- OnInitialize(name) called at ADDON_LOADED
|
||||||
function RatingBuster:OnInitialize()
|
function RatingBuster:OnInitialize()
|
||||||
|
-- Resolve player class as early as possible (ADDON_LOADED).
|
||||||
|
-- UnitClass("player") is nil at file-load time on this client (CoA 3.3.5a)
|
||||||
|
-- but is populated by ADDON_LOADED. Apply class-specific profileDefault
|
||||||
|
-- mutations BEFORE AceDB:New() so that first-install defaults are correct,
|
||||||
|
-- and apply class-specific options mutations BEFORE SetupOptions/RegisterOptionsTable.
|
||||||
|
local _, resolvedClass = UnitClass("player")
|
||||||
|
if resolvedClass then
|
||||||
|
class = resolvedClass
|
||||||
|
end
|
||||||
|
applyClassProfileDefaults(class)
|
||||||
-- Create DB
|
-- Create DB
|
||||||
self.db = AceDB:New("RatingBusterDB", defaults)
|
self.db = AceDB:New("RatingBusterDB", defaults)
|
||||||
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
|
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
|
||||||
@@ -2668,6 +2687,7 @@ function RatingBuster:OnInitialize()
|
|||||||
|
|
||||||
profileDB = self.db.profile
|
profileDB = self.db.profile
|
||||||
|
|
||||||
|
applyClassOptions(class)
|
||||||
self:SetupOptions()
|
self:SetupOptions()
|
||||||
|
|
||||||
-- Hook ShoppingTooltips to enable options to Hide Blizzard Item Comparisons
|
-- Hook ShoppingTooltips to enable options to Hide Blizzard Item Comparisons
|
||||||
@@ -2680,6 +2700,13 @@ end
|
|||||||
function RatingBuster:OnEnable()
|
function RatingBuster:OnEnable()
|
||||||
-- Hook item tooltips
|
-- Hook item tooltips
|
||||||
TipHooker:Hook(self.ProcessTooltip, "item")
|
TipHooker:Hook(self.ProcessTooltip, "item")
|
||||||
|
-- Ensure class is resolved at PLAYER_LOGIN in case ADDON_LOADED fired too early.
|
||||||
|
-- This guards the runtime stat-conversion paths (class is used throughout
|
||||||
|
-- ProcessTooltip and StatLogic calls).
|
||||||
|
local _, resolvedClass = UnitClass("player")
|
||||||
|
if resolvedClass then
|
||||||
|
class = resolvedClass
|
||||||
|
end
|
||||||
-- Initialize playerLevel
|
-- Initialize playerLevel
|
||||||
playerLevel = UnitLevel("player")
|
playerLevel = UnitLevel("player")
|
||||||
-- for setting a new level
|
-- for setting a new level
|
||||||
|
|||||||
Reference in New Issue
Block a user