Skip to content

Commit

Permalink
Remove forced class/spec load option for talent load option
Browse files Browse the repository at this point in the history
  • Loading branch information
Snakybo committed Nov 28, 2022
1 parent 698170a commit ad6df5f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 47 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
* The MINOR component is used whenever a version has backwards-compatible profile changes. This also indicates that the user can not switch back to a previous MINOR version without using a backup.
* The PATCH component is used for versions that do not contain profile format changes. Users can freely switch between PATCH versions without risk of data loss.

## [1.10.1] - 2022-11-28

### Added

* Removed forced class and specialization load option when the talent load option is enabled

## [1.10.0] - 2022-11-28

### Added
Expand Down Expand Up @@ -1025,7 +1031,8 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel

* Initial public release

[Unreleased]: https://github.com/Snakybo/Clicked/compare/1.10.0...master
[Unreleased]: https://github.com/Snakybo/Clicked/compare/1.10.1...master
[1.10.1]: https://github.com/Snakybo/Clicked/releases/tag/1.10.1
[1.10.0]: https://github.com/Snakybo/Clicked/releases/tag/1.10.0
[1.9.1]: https://github.com/Snakybo/Clicked/releases/tag/1.9.1
[1.9.0]: https://github.com/Snakybo/Clicked/releases/tag/1.9.0
Expand Down
45 changes: 11 additions & 34 deletions Clicked/Config/Bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2024,14 +2024,9 @@ end

--- @param container table
--- @param class Binding.TriStateLoadOption
--- @param forced boolean
local function DrawLoadClass(container, class, forced)
local function DrawLoadClass(container, class)
local items, order = Addon:GetLocalizedClasses()
local enabled = DrawTristateLoadOption(container, Addon.L["Class"], items, order, class)

if enabled ~= nil then
enabled:SetDisabled(forced)
end
DrawTristateLoadOption(container, Addon.L["Class"], items, order, class)
end

--- @param container table
Expand All @@ -2044,14 +2039,9 @@ end
--- @param container table
--- @param specialization Binding.TriStateLoadOption
--- @param classNames string[]
--- @param forced boolean
local function DrawLoadSpecialization(container, specialization, classNames, forced)
local function DrawLoadSpecialization(container, specialization, classNames)
local items, order = Addon:GetLocalizedSpecializations(classNames)
local enabled = DrawTristateLoadOption(container, Addon.L["Talent specialization"], items, order, specialization)

if enabled ~= nil then
enabled:SetDisabled(forced)
end
DrawTristateLoadOption(container, Addon.L["Talent specialization"], items, order, specialization)
end

--- @param container table
Expand All @@ -2072,20 +2062,10 @@ end

--- @param container table
--- @param talent Binding.MutliFieldLoadOption
--- @param specId integer
local function DrawLoadTalent(container, talent, specId)
local function OnPostValueChanged(_, value)
if value then
local binding = GetCurrentBinding()
binding.load.class.selected = 1
binding.load.specialization.selected = 1
end
end

local items = Addon:GetLocalizedTalents(specId)
local enabled = DrawTalentSelectOption(container, Addon.L["Talent selected"], items, talent)

Addon:GUI_SetPostValueChanged(enabled, OnPostValueChanged)
--- @param specializations integer[]
local function DrawLoadTalent(container, talent, specializations)
local items = Addon:GetLocalizedTalents(specializations)
DrawTalentSelectOption(container, Addon.L["Talent selected"], items, talent)
end

--- @param container table
Expand Down Expand Up @@ -2260,21 +2240,18 @@ end
local function DrawBindingLoadConditionsPage(container, binding)
local load = binding.load

-- Due to class talents being in a different order for each spec on retail we must force this to be a binding per spec unfortunately
local classAndSpecForced = Addon:IsGameVersionAtleast("RETAIL") and load.talent.selected

DrawLoadNeverSelection(container, load)
DrawLoadPlayerNameRealm(container, load.playerNameRealm)
DrawLoadClass(container, load.class, classAndSpecForced)
DrawLoadClass(container, load.class)
DrawLoadRace(container, load.race)

if Addon:IsGameVersionAtleast("RETAIL") then
local classNames = GetTriStateLoadOptionValue(load.class)
local specIndices = GetTriStateLoadOptionValue(load.specialization)
local specializationIds = GetRelevantSpecializationIds(classNames, specIndices)

DrawLoadSpecialization(container, load.specialization, classNames, classAndSpecForced)
DrawLoadTalent(container, load.talent, specializationIds[1])
DrawLoadSpecialization(container, load.specialization, classNames)
DrawLoadTalent(container, load.talent, specializationIds)
DrawLoadPvPTalent(container, load.pvpTalent, specializationIds)
DrawLoadWarMode(container, load.warMode)
elseif Addon:IsGameVersionAtleast("WOTLK") then
Expand Down
32 changes: 20 additions & 12 deletions Clicked/Core/LocaleUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,24 +381,32 @@ if Addon:IsGameVersionAtleast("RETAIL") then
--- given specialization IDs. If the `specializations` parameter
--- is `nil` it will return results for the player's current specialization.
---
--- @param specialization integer
--- @param specializations integer[]
--- @return table
function Addon:GetLocalizedTalents(specialization)
function Addon:GetLocalizedTalents(specializations)
local result = {}
local found = {}

if specialization == nil then
specialization = GetSpecializationInfo(GetSpecialization())
if specializations == nil then
specializations = {}
specializations[1] = GetSpecializationInfo(GetSpecialization())
end

for i = 1, LibTalentInfo:GetNumTalents(specialization) do
local info = LibTalentInfo:GetTalentAt(specialization, i)
for _, specialization in ipairs(specializations) do
for i = 1, LibTalentInfo:GetNumTalents(specialization) do
local info = LibTalentInfo:GetTalentAt(specialization, i)

table.insert(result, {
entryId = info.entryID,
spellId = info.spellID,
text = info.name,
icon = info.icon
})
if found[info.name] ~= info.icon then
found[info.name] = info.icon

table.insert(result, {
entryId = info.entryID,
spellId = info.spellID,
text = info.name,
icon = info.icon
})
end
end
end

return result
Expand Down

0 comments on commit ad6df5f

Please sign in to comment.