Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Container

Travis edited this page Jul 13, 2018 · 11 revisions

The Container mixin is the user-facing part of Categories, and it mostly serves as a anchor point for all the Slots of a given Category.

Performance and efficiency are top priorities for this mixin, as it needs to resize and position itself, as well as all the Slots that are anchored to it. As such, it's only updated when there's been a Slot change.

  • Callbacks:
    • On Container:
      • PreUpdateSize(Container) - Fires before a container size is changed.
      • PostUpdateSize(Container) - Fires after a container size is changed.
      • PreUpdateSlotPositions(Container) - Fires before a container's slots are positioned.
      • PostUpdateSlotPositions(Container) - Fires after a container's slots are positioned.
    • On Parent:
      • PreUpdateContainerPositions(Parent) - Fires before all visible containers are positioned.
      • PostUpdateContainerPositions(Parent) - Fires after all visible containers are positioned.
      • PostCreateContainer(Container) - Fires after a container is created.

Container:AddSlot(Slot)

Adds a Slot to the container and marks the container as "dirty".

  • Slot - Slot object to add to the container (Slot)

Container:RemoveSlot(Slot)

Removes a Slot from the container and marks the container as "dirty".

  • Slot - Slot object to add to the container (Slot)

Container:GetSlots()

Returns a table of all slots associated witht he container's category.


Container:SetDirty(flag)

Sets the container as "dirty", which means it will be updated in the next update cycle.

  • flag - true/false if the container should be marked as "dirty" (boolean)

Container:IsDirty()

Returns true/false if the Container is "dirty" or not.


Container:UpdateSize()

Updates the size of the Container based on the number of Slots it has attached to itself.


Container:UpdateSlotPositions()

Updates the positions of the Slots the Container has attached to itself.


Container:SetMaxColumns(numColumns)

Sets the maximum amount of columns the Container should display before wrapping to a new row.

  • numColumns - number of columns (integer, default = 8)

Container:GetMaxColumns()

Returns the number of columns the Container should display before wrapping to a new row.


Container:SetRelPoint(relPoint)

Sets relative point where the Container should anchor to the Parent.

  • relPoint - relative point (string, default = 'BOTTOMRIGHT')

Container:GetRelPoint()

Returns the relative point where the Container should anchor to the Parent.


Container:SetGrowDirection(x, y)

Sets the horizontal and vertical directions the containers should grow.

  • x - horizontal grow direction (string|integer, default = -1|'LEFT')
  • y - vertical grow direction (string|integer, default = 1|'UP')

Container:GetGrowDirection()

Returns the horizontal and vertical integers for the directions the container should grow.


Container:SetSpacing(x[, y])

Sets the horizontal and vertical spacing between containers.

  • x - horizontal spacing (integer, default = 2)
  • y - vertical spacing (integer, default = x|2)

Container:GetSpacing()

Returns the horizontal and vertical integers for the spacing between containers.


Container:SetPadding(left[, right][, top][, bottom])

Sets the horizontal and vertical padding within containers.

  • left - horizontal padding (integer, default = 5)
  • right - horizontal padding (integer, default = left)
  • top - vertical padding (integer, default = left)
  • bottom - vertical padding (integer, default = top)

Container:GetPadding()

Returns the horizontal and vertical integers for the four padding sides within containers.
Order: Left, Right, Up, Down


Container:GetName()

Returns the name for the Category the container represents.


Container:GetLocalizedName()

Returns the localized name for the Category the container represents.


Container:SetSlotSize(width[, height])

Sets the width and height of the Slots in the container.
It's adviced to set both the size for the Slot on the Slot and with this method.

  • width - width of the slot (integer, default = 37)
  • height - height of the slot (integer, default = width|37)

Container:GetSlotSize()

Returns the width and height of the Slots in the container.


Container:SetSlotRelPoint(relPoint)

Sets relative point where the Slot should anchor to the container.

  • relPoint - relative point (string, default = 'TOPLEFT')

Container:GetSlotRelPoint()

Returns the relative point where the Slot should anchor to the container.


Container:SetSlotSpacing(x[, y])

Sets the horizontal and vertical spacing between Slots.

  • x - horizontal spacing (integer, default = 4)
  • y - vertical spacing (integer, default = x|4)

Container:GetSlotSpacing()

Returns the horizontal and vertical integers for the spacing between Slots.


Container:SetSlotPadding(x[, y])

Sets the horizontal and vertical padding for Slots within the container.

  • x - horizontal padding (integer, default = 10)
  • y - vertical padding (integer, default = x|10)

Container:GetSlotPadding()

Returns the horizontal and vertical padding for Slots within the container.


Container:SetSlotGrowDirection(x, y)

Sets the horizontal and vertical directions the Slots should grow.

  • x - horizontal grow direction (string|integer, default = 1|'RIGHT')
  • y - vertical grow direction (string|integer, default = -1|'DOWN')

Container:GetSlotGrowDirection()

Returns the horizontal and vertical integers for the directions the Slots should grow.


Container:SetMaxHeight(amount)

Sets the maximum height the rows of containers can grow.

If the amount is between 0 and 1, it'll be a percentage of the screen height.
E.g:
If the amount is 0.3 the containers can grow up to 30% of the screen height.
If the amount is 500 the contaiers can grow up to 500 pixels.

  • amount - amount of pixels or percentage decimal (number, default = 1)

Container:GetMaxHeight()

Gets the maximum height the rows of containers can grow.


Container:GetID()

Returns the category index for the container.


Container:AddWidget(name)

Creates and returns a new object for the widget with the given name.

  • name - name of the widget (string)

Container:EnableWidget(name)

Enables the widget by name.

  • name - name of widget (string)

Container:DisableWidget(name)

Disables the widget by name.

  • name - name of widget (string)

Container:UpdateWidget(name)

Updates the widget by name.

  • name - name of widget (string)
Clone this wiki locally