This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
smutbook:classes:inventory:inventoryui [2023/08/08 18:11] – lee | smutbook:classes:inventory:inventoryui [2023/08/09 17:20] (current) – lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== InventoryUI ====== | ====== InventoryUI ====== | ||
- | + | **Type:** Const Container Object | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
InventoryUI is a static container holding functions to render the inventory UI, as well as the object details UI (FIXME). | InventoryUI is a static container holding functions to render the inventory UI, as well as the object details UI (FIXME). | ||
Line 26: | Line 7: | ||
FIXME mention the CSS yadda yadda. | FIXME mention the CSS yadda yadda. | ||
- | ==== InventoryUI.render( config ) ==== | + | FIXME talk about how the default implementations function. |
+ | ===== InventoryUI.render( config ) ===== | ||
Given a configuration object, this function renders the inventory UI into a DOM container (which is passed as part of the config object). | Given a configuration object, this function renders the inventory UI into a DOM container (which is passed as part of the config object). | ||
This function is called by the InventoryUI macro (see the [[Macro]] documentation for more details). | This function is called by the InventoryUI macro (see the [[Macro]] documentation for more details). | ||
- | ==== The Configuration Object ==== | + | * **Type:** Function |
+ | * **Arguments: | ||
+ | * //config//: The configuration object, which controls how the UI is rendered. | ||
+ | * **Returns: | ||
+ | * **Throws:** Nothing | ||
+ | |||
+ | ===== The Configuration Object | ||
- | The configuration object can contain a number of fields. | + | **Type:** Plain Old Javascript Object (acting |
- | For more information, | + | The configuration object is just a plain old javascript object containing a number of configuration fields and their values. |
- | === parentElement === | + | ==== parentElement |
The parent element to render the UI into. | The parent element to render the UI into. | ||
- | * Type: jQuery DOM Element | + | |
- | * Default: DEFAULT | + | * **Required** |
- | | + | |
- | === leftInventory === | + | ==== leftInventory |
- | The GeneralInventory (or subclass) or Person that appears on the left side of the inventory UI. This is conventionally the inventory of the person who is picking things up, or the inventory that things are being picked up and put into, but it can actually be any inventory or person. | + | The GeneralInventory (or subclass) or Person that appears on the left side of the inventory UI. This is conventionally the inventory of the person who is picking things up, or the inventory that things are being picked up and put into, but it can actually be any inventory or person. FIXME It doesn' |
- | * Type: GeneralInventory or Person | + | |
- | * Default: None | + | * **Required** |
- | | + | |
- | === rightInventory === | + | ==== rightInventory |
- | The GeneralInventory (or subclass) or Person that appears on the right side of the inventory UI. This is conventionally the inventory from which things are being taken, but it can actually be any inventory or person. | + | The GeneralInventory (or subclass) or Person that appears on the right side of the inventory UI. This is conventionally the inventory from which things are being taken, but it can actually be any inventory or person. FIXME It doesn' |
- | * Type: GeneralInventory or Person | + | |
- | * Default: None | + | * **Required** |
- | | + | |
- | === onClose( config ) === | + | ==== onClose( config ) ==== |
Function to be called when inventory UI is closed. | Function to be called when inventory UI is closed. | ||
- | * Type: Function | + | |
- | * Returns: Void | + | * **Arguments:** |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryIU.render(). |
- | * Default: undefined | + | * **Returns:** void |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default Value:** undefined | ||
- | === allowClose( config ) === | + | ==== allowClose( config ) ==== |
If this function returns a String, that value will be printed in place of the " | If this function returns a String, that value will be printed in place of the " | ||
- | * Type: Function | + | |
- | * Returns: String | + | |
- | * Default: undefined | + | * //config//: The config object that was passed to InventoryIU.render(). |
- | * Optional | + | * **Returns:** String |
+ | * **Throws:** Nothing | ||
+ | * **Default Value:** undefined | ||
- | === actor === | + | ==== actor ==== |
The Person interacting with the inventory. | The Person interacting with the inventory. | ||
- | * Type: Person | + | |
- | * Default: | + | |
- | | + | |
- | === leftAction === | + | ==== leftAction |
The action label for moving item from left inventory. | The action label for moving item from left inventory. | ||
- | * Type: String | + | |
- | * Default: " | + | |
- | * Optional | + | |
- | === leftActioned === | + | ==== leftActioned |
The left action success word. " | The left action success word. " | ||
- | * Type: String | + | |
- | * Default: " | + | |
- | * Optional | + | |
- | === rightAction === | + | ==== rightAction |
The action label for moving item from right inventory. | The action label for moving item from right inventory. | ||
- | * Type: String | + | |
- | * Default: " | + | |
- | * Optional | + | |
- | === rightActioned === | + | ==== rightActioned |
The left action success word. " | The left action success word. " | ||
- | * Type: String | + | |
- | * Default: " | + | |
- | * Optional | + | |
- | === canShowOnLeft( item, config ) === | + | ==== canShowOnLeft( item, config ) ==== |
Called to check if the object will be displayed in left inventory at all. | Called to check if the object will be displayed in left inventory at all. | ||
- | * Type: Function | + | |
- | * Returns: Boolean | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item which we are checking whether or not we should show. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: true | + | * **Returns:** Boolean |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default Value:** true | ||
- | === canShowOnRight( item, config ) === | + | ==== canShowOnRight( item, config ) ==== |
Called to check if the object will be displayed in right inventory at all. | Called to check if the object will be displayed in right inventory at all. | ||
- | * Type: Function | + | |
- | * Returns: Boolean | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item which we are checking whether or not we should show. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: true | + | * **Returns:** Boolean |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default Value:** true | ||
- | === canMoveFromLeft( item, config ) === | + | ==== canMoveFromLeft( item, config ) ==== |
The item will be shown in the left inventory, but will we show the control to move it to the right inventory? | The item will be shown in the left inventory, but will we show the control to move it to the right inventory? | ||
- | * Type: Function | + | |
- | * Returns: Boolean | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item which we are checking whether or not we can move. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: true | + | * **Returns:** Boolean |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default Value:** true | ||
- | === canMoveFromRight( item, config ) === | + | ==== canMoveFromRight( item, config ) ==== |
The item will be shown in the right inventory, but will we show the control to move it to the right inventory? | The item will be shown in the right inventory, but will we show the control to move it to the right inventory? | ||
- | * Type: Function | + | |
- | * Returns: Boolean | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item which we are checking whether or not we can move. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: true | + | * **Returns:** Boolean |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default Value:** true | ||
- | === getSortCategory( item, inventory, config ) === | + | ==== getSortCategory( item, inventory, config ) ==== |
Return object category for the sort selector. | Return object category for the sort selector. | ||
- | * Type: Function | + | |
- | * Returns: String | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item we are getting the sort category for. |
- | * // | + | * // |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: item.inventoryCategory | + | |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default | ||
- | === canShowLeftSelector === | + | ==== canShowLeftSelector |
Will the left selector be shown? | Will the left selector be shown? | ||
- | * Type: Boolean | + | |
- | * Default: | + | |
- | | + | |
- | === canShowRightSelector === | + | ==== canShowRightSelector |
Will the right selector be shown? | Will the right selector be shown? | ||
- | * Type: Boolean | + | |
- | * Default: | + | |
- | | + | |
- | === moveFromLeft( item, config ) === | + | ==== moveFromLeft( item, config ) ==== |
Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used. | Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used. | ||
- | * Type: Function | + | |
- | * Returns: Void | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item we are moving to the right-hand inventory. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: the builtin implementation | + | |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default | ||
- | === moveFromRight( item, config ) === | + | ==== moveFromRight( item, config ) ==== |
Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used. | Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used. | ||
- | * Type: Function | + | |
- | * Returns: Void | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item we are moving to the left-hand inventory. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: the builtin implementation | + | |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default | ||
- | === leftTitle === | + | ==== leftTitle |
Override the left title. | Override the left title. | ||
- | * Type: String | + | |
- | * Default: if the left inventory is a Person then " | + | |
- | * Optional | + | |
- | === rightTitle === | + | ==== rightTitle |
Override the right title. | Override the right title. | ||
- | * Type: String | + | |
- | * Default: if the right inventory is a Person then " | + | |
- | * Optional | + | |
- | === leftName( item, config ) === | + | ==== leftName( item, config ) ==== |
Override the left label for item. | Override the left label for item. | ||
- | * Type: Function | + | |
- | * Returns: String | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item we want the label for. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: the item' | + | |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default | ||
- | === rightName( item, config ) === | + | ==== rightName( item, config ) ==== |
Override the right label for item. | Override the right label for item. | ||
- | * Type: Function | + | |
- | * Returns: String | + | * **Arguments:** |
- | * //item//: The item which we are checking whether or not we should show. | + | * //item//: The item we want the label for. |
- | * //config//: The config object that was passed to InventoryIU.render(). | + | * //config//: The config object that was passed to InventoryUI.render(). |
- | * Default: the item' | + | |
- | * Optional | + | * **Throws:** Nothing |
+ | * **Default | ||
- | === outerTpl === | + | ==== outerTpl |
Override the builtin outer HTML template. | Override the builtin outer HTML template. | ||
- | * Type: String | + | |
- | * Default: | + | |
- | | + | |
- | === listitemTplLeft === | + | ==== listitemTplLeft |
Override the builtin left list item HTML template. | Override the builtin left list item HTML template. | ||
- | * Type: String | + | |
- | * Default: | + | |
- | | + | |
- | === listitemTplRight === | + | ==== listitemTplRight |
Override the builtin right list item HTML template. | Override the builtin right list item HTML template. | ||
- | * Type: String | Function(config) returning String | + | |
- | * Default: | + | |
- | | + | |
- | === detailsTpl === | + | ==== detailsTpl |
Override the builtin item details HTML template. | Override the builtin item details HTML template. | ||
- | * Type: String | Function(config) returning String | + | |
- | * Default: | + | |
- | | + | |