sisby-folk / inventory-tabs

A minecraft mod that allows swapping to other in-world screens (blocks, entities, etc) via tabs. A fourth-generation rewrite of CakeWhip's InventoryTabs.
https://modrinth.com/mod/inventory-tabs
GNU Lesser General Public License v3.0
6 stars 3 forks source link

Transactional Tab Swapping #6

Closed sisby-folk closed 8 months ago

sisby-folk commented 9 months ago

Right now, if anything goes wrong when opening a tab, it can leave restore logic held in place until the next screen opens, which is likely to cause visual slot desync.

This happens rarely in vanilla, but frequently in testing, with modded content in the config, or while developing addons.

To resolve this, the act of swapping from one tab to another needs to be transactional - When clicking a tab, the state should be stored and the UI should lock up until the HandledScreen changes - if it changes, it should restore state, and if not, it should roll back and unlock.

The visual "current tab" and the actual current tab should be seperated, so clicking a tab can feel responsive - and clearly indicated when a swap has "timed out".

Using this system, tabs should be able to run code in each stage - for example, ItemTab needs to be able to perform a slot swap before a tab switch is attempted, and needs to redo the slot swap when the new screen is opened - these should be overrideable methods (like module swapping in switchy, really)