Skip to content

Bags: add optional Sort to Bottom - #1192

Merged
EllesmereGaming merged 2 commits into
EllesmereGaming:mainfrom
Kirihasio2:feature/bags-sort-to-bottom
Aug 5, 2026
Merged

Bags: add optional Sort to Bottom#1192
EllesmereGaming merged 2 commits into
EllesmereGaming:mainfrom
Kirihasio2:feature/bags-sort-to-bottom

Conversation

@Kirihasio2

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a new option to sort to the bottom instead of top for onebag

How was it tested?

8.7.5 live

Screenshots

image
Recording.2026-08-04.125551.mp4

Checklist

  • [✔️] New settings default OFF (no behavior change without opt-in)
  • [✔️] Zero cost while disabled: no events registered, no polling, no hooks doing work, no frames built
  • [✔️] Cheap while enabled: event-driven (no polling, no timer-based logic, no per-frame allocations)
  • [✔️] No writes onto Blizzard-owned frames (weak-table pattern used); HookScript/hooksecurefunc only, never SetScript on Blizzard frames
  • [✔️] Tested in-game, works on live retail; no load errors on the 12.1 PTR client

Kirihasio2 and others added 2 commits August 4, 2026 12:50
Sorting packs items into the first free slots, so a half-empty bag reads
as a block of items at the top and a run of empty slots below it. Some
players want the opposite: items settled at the bottom, free space at the
top, so the gap sits next to nothing and new loot does not shift the
block they just organised.

New "Sort to Bottom" toggle in a cog popup on the Show Sort Icon row
(Bags -> EXTRAS), defaulting off. The item order inside the block never
changes; only where the block starts does.

Three sort paths back the one button and each needed its own handling:

- OneBag runs the module's own physical sort. Sorted item i targeted slot
  i; it now targets slot i + offset, where offset is the free-slot count
  when the option is on and 0 otherwise, so the default path is unchanged.
  The walk direction has to follow: forwards when packing to the top,
  backwards when packing to the bottom, so that the item displaced by a
  swap always lands in a slot the pass has yet to visit and gets placed in
  the same pass. Keeping the forward walk while packing to the bottom is
  still correct but strands every displaced item behind the cursor, one
  BAG_UPDATE retry each -- a half-full bag went from 2 passes to 12+ and
  blew the 15-retry cap, leaving bags visibly half-sorted.

- MultiBag and the bank defer to Blizzard (SortBags / SortBank), which
  fills by its own right-to-left direction: right-to-left starts at the
  backpack, which sits at the right end of the default bag bar and is the
  top of our views, so packing to the bottom means clearing it. That is a
  real game setting shared with Blizzard's Clean Up button, so it is only
  ever written while the option is on -- an untouched setup keeps whatever
  direction the player chose. Turning the option on stashes their value
  and turning it off restores it, and each sort re-asserts ours in case a
  profile switch or the Blizzard settings panel moved it in between.

- Category views need nothing: they pack their own grid with no gaps.

The move loop is pure index arithmetic, so it was extracted and run
standalone over 6000 randomised bag states (1-120 slots, 0-100% full,
unique through heavy duplicate stacks, both directions), asserting the
block lands contiguous, in order, at the right end, with no items lost.
Worst case is 4 retry passes against the cap of 15.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The committed list was 8 keys stale: it still carried the profile-import
Window Skins / overrides strings whose L() calls are gone from the source.
Pre-existing on main, not from this branch -- running the extractor on a
clean upstream/main checkout produces the same 658 keys against the 666
committed, so the locale-check job fails on any PR touching Lua until this
lands. Regenerated with .tools/extract-locale-keys.sh, no hand edits.

The Sort to Bottom strings add nothing here: like every options row label
they reach L() as a variable, so the static extractor cannot see them and
translators pick them up from the in-game /euiloc harvester instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@EllesmereGaming
EllesmereGaming merged commit 6e0df9d into EllesmereGaming:main Aug 5, 2026
1 check passed
EllesmereGaming pushed a commit that referenced this pull request Aug 7, 2026
The Bags "Sort to Bottom" cog from #1192 and the gold DataBar's rebuilt
tooltip, whose new section checklist shipped with 8.7.6 itself.

Sort stays 排序 to match the Show Sort Icon row that owns the cog
(顯示排序圖示). The long explanation reuses the file's own 單一背包 and
多重背包 for the two bag views, 格線 for the item grid, and the client's
整理背包 for the Blizzard cleanup direction the option flips. On the
DataBars side the gold block is 金錢 and its tooltip parts are 區段, the
same word L["Section"] already uses, so they do not read as the DataBar
blocks (區塊); 工作階段 (Session) and 魔獸代幣 (WoW Token) were already
translated, so Characters joins them as 角色.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants