Krealle / Cell-Snippets

7 stars 2 forks source link

Conditional sorting based on raid type #5

Open spamwax opened 1 month ago

spamwax commented 1 month ago

can you add an option to on run the RaidSortOptions snippet if the raid is not outdoors (in Layout Auto Switch)?

Krealle commented 1 month ago

I've added ONLY_SORT_IN_RAID option for that, but I won't be injecting options into Cell UI.

spamwax commented 1 month ago

Thanks for the update. What I meant was to have an option to not run the snippet when I am in an outside raid, like the world bosses where players can get added to the raid during combat lock-down. My understanding is that if the snippet is active, new players added during combat will not show up, which is not ideal because I won't see them to heal. I am guessing that the new option (ONLY_SORT_IN_RAID) and select(2, IsInInstance()) == "raid" will take care of outside raids.

I also see that you have some WIP options to set a fixed index for the player similar to PartySortOptions.lua. When this gets implemented, it would ideal for me so I can always place myself in a specific spot (like top-right corner) when doing mythic raids.

Krealle commented 1 month ago

What I meant was to have an option to not run the snippet when I am in an outside raid, like the world bosses where players can get added to the raid during combat lock-down. I am guessing that the new option (ONLY_SORT_IN_RAID) and select(2, IsInInstance()) == "raid" will take care of outside raids.

With ONLY_SORT_IN_RAID set to true it will no longer sort when you are outside of a raid instance, yea.

My understanding is that if the snippet is active, new players added during combat will not show up, which is not ideal because I won't see them to heal.

This is only if you have USE_NAME_FILTER set to true. This option just uses a method to prevent blizzards default sorts to happen during combat. Downside being that new players won't show up until after combat.

If you don't have it enabled the frames will still be sorted in combat(with blizzards method, not ours) and show new players.

I also see that you have some WIP options to set a fixed index for the player similar to PartySortOptions.lua. When this gets implemented, it would ideal for me so I can always place myself in a specific spot (like top-right corner) when doing mythic raids.

I'll look into it at some point before TWW raids is all I'm gonna promise for now x)

In the meantime, this is potentially something you could achieve with FrameSort addon.

spamwax commented 3 weeks ago

Krealle, I know you mentioned you will add the fixed index option for TWW raids, but I was messing around with the snippet and added the following to updateRaidFrames function (at the top of function after InCombatLockdown check) to temporarily get it working. I am trying to put myself at spot 16 (with Combine Raid Group options selected):

        local playerIndex
    for _, players in pairs(SORTED_RAID_GROUPS) do
        for i = 1, #players do
            if playerName == players[i].name then
                playerIndex = i
                break
            end
        end
    end
    if playerIndex and SORTED_RAID_GROUPS[0] and #SORTED_RAID_GROUPS[0] >= 16 then
        SORTED_RAID_GROUPS[0][playerIndex], SORTED_RAID_GROUPS[0][16] =
            SORTED_RAID_GROUPS[0][16], SORTED_RAID_GROUPS[0][playerIndex]
    end

do you think it will work?

Krealle commented 3 weeks ago

Could just pop the player and insert it at the appropriate position.

local playerEntry = table.remove(SORTED_RAID_GROUPS[0], playerIndex)

-- Either floor it to end of array or playerIndex, w/e makes most sense, this is just end of array
local pos = math.min(FIXED_INDEX, (#SORTED_RAID_GROUPS[0] + 1)) 

table.insert(SORTED_RAID_GROUPS[0], pos, playerEntry)

And you can prolly just use ipairs for this

local playerIndex
for idx, player in ipairs(SORTED_RAID_GROUPS[0]) do
  if playerName == player.name then
    playerIndex = idx
    break
  end
end