I think we've hit the spot when patching up the cWindow and the jewelry around it is no longer feasible. It's time for refactoring this part of the code. Currently (rev 850-ish), chests aren't working and some windows are near impossible to implement (doublechest).
I propose a change like this:
A window is made up of several "areas". These areas each correspond to slots with a similar purpose. For example, the inventory area, or the crafting grid area, or chest storage area. Each area knows its items, the number of slots and whether it's per-player (inventory), global (chest) or temporary (crafting grid). A common ancestor for the area classes knows how to handle clicks within that area.
A window, then, is a collection of these areas, with slot numbers assigned ascending for each area. The window object is then just a simple container class that redirects click events to the individual areas and receives update commands from areas (furnace smelting etc.) A Window can be bound to a block (chest) or to an entity (player, storage minecart). A single window object can be shared among multiple players.
As for shift-clicks, they are moving stuff between areas automagically, so we need a way for an area to call out to other areas and ask them, "Do you want this stack? And how much of it?" This should be easy to route through the parent window. If not for any reason, then the parent window could be subclassed for the wanted functionality.
Comments, ideas?
I propose a change like this:
A window is made up of several "areas". These areas each correspond to slots with a similar purpose. For example, the inventory area, or the crafting grid area, or chest storage area. Each area knows its items, the number of slots and whether it's per-player (inventory), global (chest) or temporary (crafting grid). A common ancestor for the area classes knows how to handle clicks within that area.
A window, then, is a collection of these areas, with slot numbers assigned ascending for each area. The window object is then just a simple container class that redirects click events to the individual areas and receives update commands from areas (furnace smelting etc.) A Window can be bound to a block (chest) or to an entity (player, storage minecart). A single window object can be shared among multiple players.
As for shift-clicks, they are moving stuff between areas automagically, so we need a way for an area to call out to other areas and ask them, "Do you want this stack? And how much of it?" This should be easy to route through the parent window. If not for any reason, then the parent window could be subclassed for the wanted functionality.
Comments, ideas?