Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


smutbook:classes:inventory: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).

FIXME mention the CSS yadda yadda.

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).

This function is called by the InventoryUI macro (see the Macro documentation for more details). You probably don't want to use this function directly unless you are extending LibEcho itself.

  • Type: Function
  • Arguments:
    • config: The configuration object, which controls how the UI is rendered. See below.
  • Returns: void
  • Throws: Nothing

The Configuration Object

Type: Plain Old Javascript Object (acting as an associative array)

The configuration object is just a plain old javascript object containing a number of configuration fields and their values. For more information, see the InventoryUI Macro source code.

parentElement

The parent element to render the UI into.

  • Type: jQuery DOM Element
  • Required

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. FIXME It doesn't work on Person at the moment.

  • Type: GeneralInventory or Person
  • Required

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. FIXME It doesn't work on Person at the moment.

  • Type: GeneralInventory or Person
  • Required

onClose( config )

Function to be called when inventory UI is closed. The InventoryUI macro uses this to evaluate the tweecode in the contents of the macro body when the InventoryUI dialog is closed.

  • Type: Function
  • Arguments:
    • config: The config object that was passed to InventoryIU.render().
  • Returns: void
  • Throws: Nothing
  • Default Value: undefined

allowClose( config )

If this function returns a String, that value will be printed in place of the “Done” link at the bottom of the inventory modal (preventing the modal from being closed). This can be used to prevent the inventory from being able to be closed until certain items have been taken or dropped, for example. If the return value is a falsy value, the regular “Done” link will be displayed, allowing the modal to be closed.

  • Type: Function
  • Arguments:
    • config: The config object that was passed to InventoryIU.render().
  • Returns: String
  • Throws: Nothing
  • Default Value: undefined

actor

The Person interacting with the inventory.

  • Type: Person or Function(config) returning Person
  • Default Value: undefined

leftAction

The action label for moving item from left inventory.

  • Type: String or Function(config) returning String
  • Default Value: “Drop”

leftActioned

The left action success word. “ObjectName: dropped.”

  • Type: String or Function(config) returning String
  • Default Value: “dropped”

rightAction

The action label for moving item from right inventory.

  • Type: String or Function(config) returning String
  • Default Value: “Take”

rightActioned

The left action success word. “ObjectName: taken.”

  • Type: String or Function(config) returning String
  • Default Value: “taken”

canShowOnLeft( item, config )

Called to check if the object will be displayed in left inventory at all.

  • Type: Function
  • Arguments:
    • item: The item which we are checking whether or not we should show.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: Boolean
  • Throws: Nothing
  • Default Value: true

canShowOnRight( item, config )

Called to check if the object will be displayed in right inventory at all.

  • Type: Function
  • Arguments:
    • item: The item which we are checking whether or not we should show.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: Boolean
  • Throws: Nothing
  • Default Value: true

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?

  • Type: Function
  • Arguments:
    • item: The item which we are checking whether or not we can move.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: Boolean
  • Throws: Nothing
  • Default Value: true

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?

  • Type: Function
  • Arguments:
    • item: The item which we are checking whether or not we can move.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: Boolean
  • Throws: Nothing
  • Default Value: true

getSortCategory( item, inventory, config )

Return object category for the sort selector.

  • Type: Function
  • Arguments:
    • item: The item we are getting the sort category for.
    • inventory: The inventory we are checking in.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: String
  • Throws: Nothing
  • Default Value: item.inventoryCategory or “Other” (if the item has no inventoryCategory).

canShowLeftSelector

Will the left selector be shown?

  • Type: Boolean or Function(config) returning Boolean
  • Default Value: true

canShowRightSelector

Will the right selector be shown?

  • Type: Boolean or Function(config) returning Boolean
  • Default Value: true

moveFromLeft( item, config )

Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used.

  • Type: Function
  • Arguments:
    • item: The item we are moving to the right-hand inventory.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: void
  • Throws: Nothing
  • Default Value: the builtin implementation, defined in InventoryUI.js

moveFromRight( item, config )

Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used.

  • Type: Function
  • Arguments:
    • item: The item we are moving to the left-hand inventory.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: void
  • Throws: Nothing
  • Default Value: the builtin implementation, defined in InventoryUI.js

leftTitle

Override the left title.

  • Type: String or Function(config) returning String
  • Default Value: if the left inventory is a Person then “Soandso (Inventory)”, otherwise leftInventory.AName().

rightTitle

Override the right title.

  • Type: String or Function(config) returning String
  • Default Value: if the right inventory is a Person then “Soandso (Inventory)”, otherwise rightInventory.AName().

leftName( item, config )

Override the left label for item.

  • Type: Function
  • Arguments:
    • item: The item we want the label for.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: String
  • Throws: Nothing
  • Default Value: the item.AName()

rightName( item, config )

Override the right label for item.

  • Type: Function
  • Arguments:
    • item: The item we want the label for.
    • config: The config object that was passed to InventoryUI.render().
  • Returns: String
  • Throws: Nothing
  • Default Value: the item.AName()

outerTpl

Override the builtin outer HTML template.

  • Type: String or Function(config) returning String
  • Default Value: undefined

listitemTplLeft

Override the builtin left list item HTML template.

  • Type: String or Function(config) returning String
  • Default Value: undefined

listitemTplRight

Override the builtin right list item HTML template.

  • Type: String | Function(config) returning String
  • Default Value: undefined

detailsTpl

Override the builtin item details HTML template.

  • Type: String | Function(config) returning String
  • Default Value: undefined

smutbook/classes/inventory/inventoryui.txt · Last modified: 2023/08/09 17:20 by lee