Skip to content

Commit

Permalink
Manual role selection in Wrath for DualSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
d87 committed Nov 22, 2023
1 parent 1d388e9 commit de2ff1e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
27 changes: 21 additions & 6 deletions Aptechka.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitPhaseReason = UnitPhaseReason
local GetSpecialization = GetSpecialization
local GetSpecializationRole = GetSpecializationRole
local GetActiveTalentGroup = GetActiveTalentGroup
local HasIncomingSummon = C_IncomingSummon and C_IncomingSummon.HasIncomingSummon
local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
local COMBATLOG_OBJECT_AFFILIATION_UPTORAID = COMBATLOG_OBJECT_AFFILIATION_RAID + COMBATLOG_OBJECT_AFFILIATION_PARTY + COMBATLOG_OBJECT_AFFILIATION_MINE
Expand All @@ -33,17 +34,22 @@ local dummyFalse = function() return false end
local dummy0 = function() return 0 end
if apiLevel <= 3 then
GetSpecialization = function() return 1 end
-- GetSpecializationRole = function(spec)
-- local tg = GetActiveTalentGroup()
-- return GetTalentGroupRole(tg)
-- end
GetSpecializationRole = function(spec)
local tg = GetActiveTalentGroup()
return GetTalentGroupRole(tg)
if not AptechkaDB_Char.forcedClassicRole then return "DAMAGER" end
return AptechkaDB_Char.forcedClassicRole[tg]
end
UnitGetTotalAbsorbs = dummy0
UnitGetTotalHealAbsorbs = dummy0
UnitPhaseReason = dummyFalse
HasIncomingSummon = dummyNil
end
if apiLevel <= 2 then
GetSpecializationRole = function(spec) return AptechkaDB_Char.forcedClassicRole end
GetActiveTalentGroup = function() return 1 end
UnitHasVehicleUI = dummyFalse
UnitInVehicle = dummyFalse
UnitUsingVehicle = dummyFalse
Expand Down Expand Up @@ -304,6 +310,12 @@ function Aptechka.PLAYER_LOGIN(self,event,arg1)
local firstTimeUse = AptechkaDB_Global == nil
AptechkaDB_Global = AptechkaDB_Global or {}
AptechkaDB_Char = AptechkaDB_Char or {}
if apiLevel <= 3 then
if type(AptechkaDB_Char.forcedClassicRole) == "string" then
local oldRole = AptechkaDB_Char.forcedClassicRole
AptechkaDB_Char.forcedClassicRole = { [1] = oldRole }
end
end
self:DoMigrations(AptechkaDB_Global)
self.db = LibStub("AceDB-3.0"):New("AptechkaDB_Global", defaults, "Default") -- Create a DB using defaults and using a shared default profile
AptechkaDB = self.db
Expand Down Expand Up @@ -3838,14 +3850,17 @@ Aptechka.Commands = {
end
end,
["setrole"] = function(v) -- Classic and BCC manual role selection
if apiLevel >= 3 then return end
v = string.upper(v)
if not AptechkaDB_Char.forcedClassicRole then
AptechkaDB_Char.forcedClassicRole = {}
end
local tg = GetActiveTalentGroup()
if v == "HEALER" then
AptechkaDB_Char.forcedClassicRole = v
AptechkaDB_Char.forcedClassicRole[tg] = v
else
AptechkaDB_Char.forcedClassicRole = "DAMAGER"
AptechkaDB_Char.forcedClassicRole[tg] = "DAMAGER"
end
print("Role changed to", AptechkaDB_Char.forcedClassicRole)
print("Talent Group's Role changed to", AptechkaDB_Char.forcedClassicRole[tg])
Aptechka:OnRoleChanged()
end,
["createpets"] = function()
Expand Down
15 changes: 11 additions & 4 deletions Options/ProfileSelection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,15 @@ function ns.MakeProfileSelection()
},
}

if Aptechka.util.GetAPILevel() <= 2 then
if Aptechka.util.GetAPILevel() <= 3 then
local GetActiveTalentGroup = GetActiveTalentGroup
if Aptechka.util.GetAPILevel() <= 2 then
GetActiveTalentGroup = function() return 1 end
end

opt.args.manualRoleSelection = {
type = "group",
name = L"Manual Role selection for current character",
name = L"Manual Role selection for current talent group",
width = "double",
disabled = function() return not Aptechka.db.global.enableProfileSwitching end,
guiInline = true,
Expand All @@ -261,7 +266,8 @@ function ns.MakeProfileSelection()
type = "toggle",
get = function(info) return AptechkaDB_Char.forcedClassicRole == "HEALER" end,
set = function(info, v)
AptechkaDB_Char.forcedClassicRole = "HEALER"
local tg = GetActiveTalentGroup()
AptechkaDB_Char.forcedClassicRole[tg] = "HEALER"
Aptechka:OnRoleChanged()
end,
order = 1,
Expand All @@ -271,7 +277,8 @@ function ns.MakeProfileSelection()
type = "toggle",
get = function(info) return AptechkaDB_Char.forcedClassicRole == "DAMAGER" end,
set = function(info, v)
AptechkaDB_Char.forcedClassicRole = "DAMAGER"
local tg = GetActiveTalentGroup()
AptechkaDB_Char.forcedClassicRole[tg] = "DAMAGER"
Aptechka:OnRoleChanged()
end,
order = 2,
Expand Down

0 comments on commit de2ff1e

Please sign in to comment.