Tiles Module
Generic tile processing framework for grid selectors - provides path routing, grouping, clustering, and special group handling.
Generic tile processing framework for grid selectors - provides path routing, grouping, clustering, and special group handling.
Overview
tilesModule is a configurable tile processing factory used by grid selector backends. It provides a framework for path-based navigation, context creation with utility functions, and hooks for extensibility.
Module path: lua/ge/extensions/ui/gridSelectorUtils/tilesModule.lua (loaded via require)
Exports (M)
| Function | Signature | Description |
|---|---|---|
create | (config) | Creates a tiles processing instance. |
Config Options
| Key | Type | Description |
|---|---|---|
itemToTileConverter | function | Converts raw items to tile format. |
pathHandlers | table | Map of path type → handler function. |
clusteringFunction | function | Groups items into clusters. |
groupingModule | module | Provides group mode functions. |
sortingModule | module | Provides sort functions. |
getDataFunction | function | Returns current UI data. |
filterFunction | function | Tests if items pass filters. |
backendName | string | Backend identifier. |
Instance Methods
| Method | Signature | Description |
|---|---|---|
getTiles | (path, pathChanged?, overrideDefault?, tileFuncs?) | Main entry - routes to path handler. |
createContext | (data, overrideDefault?, tileFuncs?) | Creates a context object with utilities. |
Internals
Context Object
The context bundles configuration and utility functions for path handlers:
local context = {
itemToTileConverter = ...,
filterFunction = ...,
sortingModule = ...,
groupingModule = ...,
-- Utility functions
finalizeGroups = function(groups, favGroup, recentGroup) ... end,
setDefaultSelection = function(group, model) ... end,
matchesGroup = function(config, groupMode, groupName) ... end,
processClusteredItems = function(clustered, group, clusterMode) ... end,
handleSpecialGroups = function(tile, favGroup, recentGroup) ... end,
profiler = p,
data = data,
}Finalize Groups
Limits recent group to 15 tiles, filters empty groups, and sorts groups by order then name.
Default Selection
Finds the default-selected tile in a group. Priority:
- Content-specific default (e.g.,
model.default_pc) - Override tile (e.g., from navigation context)
- Fallback to last tile in the group
Special Group Handling
Duplicates tiles into Favourites/Recent groups based on display mode:
if data.displayData.showFavouritesMode == 'completeClusters' and tile.favouriteIdx > 0 then
local favouriteTile = deepcopy(tile)
favouriteTile.key = favouriteTile.key .. "_" .. tile.favouriteIdx
table.insert(favouriteGroup.tiles, favouriteTile)
endPath Dispatch
local handler = pathHandlers[pathType]
if handler then
local result = handler(path, data, context)
if pathChanged then
extensions.hook("onGridSelectorGetTiles", backendName, pathType)
end
return result
endHow It Works
- Backend creates instance with
tilesModule.create({pathHandlers = {...}, ...}) - UI calls
instance.getTiles(path)with a navigation path - A context is created with all utilities and current data
- Path type dispatches to the registered handler
- Handler uses context utilities for filtering, grouping, sorting
- Result is a list of groups with tiles for the grid UI
Additional Exports
The following exports are available but not yet documented in detail:
M.create