Corgi Engine  v8.8
MoreMountains.InventoryEngine.InventoryDisplay Class Reference

A component that handles the visual representation of an Inventory, allowing the user to interact with it More...

Inheritance diagram for MoreMountains.InventoryEngine.InventoryDisplay:
MoreMountains.Tools.MMEventListener< MMInventoryEvent > MoreMountains.InventoryEngine.InventoryHotbar

Classes

struct  ItemQuantity
 

Public Member Functions

virtual void SetupInventoryDisplay ()
 Creates and sets up the inventory display (usually called via the inspector's dedicated button) More...
 
virtual void Focus ()
 
Sets the focus on the first item of the inventory
More...
 
virtual InventorySlot CurrentlySelectedInventorySlot ()
 Returns the currently selected inventory slot More...
 
virtual void SetCurrentlySelectedSlot (InventorySlot slot)
 Sets the currently selected slot More...
 
virtual InventoryDisplay GoToInventory (int direction)
 Goes to the previous (-1) or next (1) inventory, based on the int direction passed in parameter. More...
 
virtual void SetReturnInventory (InventoryDisplay inventoryDisplay)
 Sets the return inventory display More...
 
virtual void ReturnInventoryFocus ()
 If possible, returns the focus to the current return inventory focus (after equipping an item, usually) More...
 
virtual void DisableAllBut (ItemClasses itemClass)
 Disables all the slots in the inventory display, except those from a certain class More...
 
virtual void ResetDisabledStates ()
 Enables back all slots (usually after having disabled some of them) More...
 
virtual void OnMMEvent (MMInventoryEvent inventoryEvent)
 Catches MMInventoryEvents and acts on them More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMInventoryEvent >
void OnMMEvent (T eventType)
 

Public Attributes

string TargetInventoryName = "MainInventory"
 the name of the inventory to display More...
 
string PlayerID = "Player1"
 
int NumberOfRows = 3
 the number of rows to display More...
 
int NumberOfColumns = 2
 the number of columns to display More...
 
InventoryDisplay TargetChoiceInventory
 
ItemClasses ItemClass
 
bool DrawEmptySlots =true
 if this is true, we'll draw slots even if they don't contain an object. Otherwise we don't draw them More...
 
bool AllowMovingObjectsToThisInventory = false
 if this is true, the Player will be allowed to move objects from another inventory to this one, using the Move button More...
 
int PaddingTop = 20
 The internal margin between the top of the inventory panel and the first slots. More...
 
int PaddingRight = 20
 The internal margin between the right of the inventory panel and the last slots. More...
 
int PaddingBottom = 20
 The internal margin between the bottom of the inventory panel and the last slots. More...
 
int PaddingLeft = 20
 The internal margin between the left of the inventory panel and the first slots. More...
 
InventorySlot SlotPrefab
 the game object to use as a Slot. If left empty, one will be automatically created at runtime
More...
 
Vector2 SlotSize = new Vector2(50,50)
 the horizontal and vertical size of the slots More...
 
Vector2 IconSize = new Vector2(30,30)
 the size of the icon in each slot More...
 
Vector2 SlotMargin = new Vector2(5,5)
 the horizontal and vertical margin to apply between slots rows and columns More...
 
Sprite EmptySlotImage
 The image to set as the background of each slot when the slot is empty. More...
 
Sprite FilledSlotImage
 The image to set as the background of each slot when the slot is not empty. More...
 
Sprite HighlightedSlotImage
 The image to set as the background of each slot when the slot is highlighted. More...
 
Sprite PressedSlotImage
 The image to set as the background of each slot when the slot is pressed. More...
 
Sprite DisabledSlotImage
 The image to set as the background of each slot when the slot is disabled. More...
 
Sprite MovedSlotImage
 The image to set as the background of each slot when the item in the slot is being moved around. More...
 
Image.Type SlotImageType
 The type of the image (sliced, normal, tiled...) More...
 
bool EnableNavigation = true
 if true, the engine will automatically create bindings to navigate through the different slots using keyboard or gamepad. More...
 
bool GetFocusOnStart = false
 if this is true, this inventory display will get the focus on start More...
 
bool DisplayTitle =true
 if true, will display the panel's title More...
 
string Title
 the title for the inventory that will be displayed More...
 
Font TitleFont
 the font used to display the quantity More...
 
int TitleFontSize =20
 the font size to use More...
 
Color TitleColor = Color.black
 the color to display the quantity in More...
 
Vector3 TitleOffset =Vector3.zero
 the padding (distance to the slot's edge) More...
 
TextAnchor TitleAlignment = TextAnchor.LowerRight
 where the quantity should be displayed More...
 
Font QtyFont
 the font used to display the quantity More...
 
int QtyFontSize =12
 the font size to use More...
 
Color QtyColor = Color.black
 the color to display the quantity in More...
 
float QtyPadding =10f
 the padding (distance to the slot's edge) More...
 
TextAnchor QtyAlignment = TextAnchor.LowerRight
 where the quantity should be displayed More...
 
InventoryDisplay PreviousInventory
 
InventoryDisplay NextInventory
 

Static Public Attributes

static InventoryDisplay CurrentlyBeingMovedFromInventoryDisplay
 the item currently being moved More...
 
static int CurrentlyBeingMovedItemIndex = -1
 

Protected Member Functions

virtual void Awake ()
 On Awake, initializes the various lists used to keep track of the content of the inventory More...
 
virtual void RedrawInventoryDisplay ()
 Redraws the inventory display's contents when needed (usually after a change in the target inventory) More...
 
virtual void InitializeSprites ()
 Initializes the sprites. More...
 
virtual void DrawInventoryTitle ()
 Adds and sets up the inventory title child object More...
 
virtual void AddGridLayoutGroup ()
 Adds a grid layout group if there ain't one already More...
 
virtual void ResizeInventoryDisplay ()
 Resizes the inventory panel, taking into account the number of rows/columns, the padding and margin More...
 
virtual void DrawInventoryContent ()
 Draws the content of the inventory (slots and icons) More...
 
virtual void ContentHasChanged ()
 If the content has changed, we draw our inventory panel again More...
 
virtual void FillLastUpdateContent ()
 Fills the last content of the update. More...
 
virtual void UpdateInventoryContent ()
 Draws the content of the inventory (slots and icons) More...
 
virtual void UpdateSlot (int i)
 Updates the slot's content and appearance More...
 
virtual void InitializeSlotPrefab ()
 Creates the slot prefab to use in all slot creations More...
 
virtual void DrawSlot (int i)
 Draws the slot and its content (icon, quantity...). More...
 
virtual void SetupSlotNavigation ()
 Setups the slot navigation using Unity's GUI built-in system, so that the user can move using the left/right/up/down arrows More...
 
virtual void OnEnable ()
 On Enable, we start listening for MMInventoryEvents More...
 
virtual void OnDisable ()
 On Disable, we stop listening for MMInventoryEvents More...
 

Static Protected Member Functions

static void InitializeStatics ()
 

Protected Attributes

Inventory _targetInventory = null
 
List< ItemQuantity_contentLastUpdate
 
List< int > _comparison
 
SpriteState _spriteState = new SpriteState()
 
InventorySlot _currentlySelectedSlot
 
InventorySlot _slotPrefab = null
 

Properties

Inventory TargetInventory [get]
 Grabs the target inventory based on its name More...
 
virtual int InventorySize [get, set]
 the total number of slots in this inventory More...
 
virtual GridLayoutGroup InventoryGrid [get, protected set]
 the grid layout used to display the inventory in rows and columns More...
 
virtual InventoryDisplayTitle InventoryTitle [get, protected set]
 the gameobject used to display the inventory's name More...
 
virtual RectTransform InventoryRectTransform [get]
 the main panel More...
 
virtual List< InventorySlotSlotContainer [get, protected set]
 an internal list of slots More...
 
virtual InventoryDisplay ReturnInventory [get, protected set]
 the inventory the focus should return to after an action More...
 
virtual bool IsOpen [get, protected set]
 whether this inventory display is open or not More...
 
virtual bool InEquipSelection [get, set]
 

Detailed Description

A component that handles the visual representation of an Inventory, allowing the user to interact with it

Member Function Documentation

◆ AddGridLayoutGroup()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.AddGridLayoutGroup ( )
protectedvirtual

Adds a grid layout group if there ain't one already

◆ Awake()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.Awake ( )
protectedvirtual

On Awake, initializes the various lists used to keep track of the content of the inventory

◆ ContentHasChanged()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.ContentHasChanged ( )
protectedvirtual

If the content has changed, we draw our inventory panel again

◆ CurrentlySelectedInventorySlot()

virtual InventorySlot MoreMountains.InventoryEngine.InventoryDisplay.CurrentlySelectedInventorySlot ( )
virtual

Returns the currently selected inventory slot

Returns
The selected inventory slot.

◆ DisableAllBut()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.DisableAllBut ( ItemClasses  itemClass)
virtual

Disables all the slots in the inventory display, except those from a certain class

Parameters
itemClassItem class.

◆ DrawInventoryContent()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.DrawInventoryContent ( )
protectedvirtual

Draws the content of the inventory (slots and icons)

◆ DrawInventoryTitle()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.DrawInventoryTitle ( )
protectedvirtual

Adds and sets up the inventory title child object

◆ DrawSlot()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.DrawSlot ( int  i)
protectedvirtual

Draws the slot and its content (icon, quantity...).

Parameters
iThe index.

◆ FillLastUpdateContent()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.FillLastUpdateContent ( )
protectedvirtual

Fills the last content of the update.

◆ Focus()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.Focus ( )
virtual


Sets the focus on the first item of the inventory


◆ GoToInventory()

virtual InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.GoToInventory ( int  direction)
virtual

Goes to the previous (-1) or next (1) inventory, based on the int direction passed in parameter.

Parameters
directionDirection.

◆ InitializeSlotPrefab()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.InitializeSlotPrefab ( )
protectedvirtual

Creates the slot prefab to use in all slot creations

◆ InitializeSprites()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.InitializeSprites ( )
protectedvirtual

Initializes the sprites.

◆ InitializeStatics()

static void MoreMountains.InventoryEngine.InventoryDisplay.InitializeStatics ( )
staticprotected

◆ OnDisable()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.OnDisable ( )
protectedvirtual

On Disable, we stop listening for MMInventoryEvents

Reimplemented in MoreMountains.InventoryEngine.InventoryHotbar.

◆ OnEnable()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.OnEnable ( )
protectedvirtual

On Enable, we start listening for MMInventoryEvents

Reimplemented in MoreMountains.InventoryEngine.InventoryHotbar.

◆ OnMMEvent()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.OnMMEvent ( MMInventoryEvent  inventoryEvent)
virtual

Catches MMInventoryEvents and acts on them

Parameters
inventoryEventInventory event.

◆ RedrawInventoryDisplay()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.RedrawInventoryDisplay ( )
protectedvirtual

Redraws the inventory display's contents when needed (usually after a change in the target inventory)

◆ ResetDisabledStates()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.ResetDisabledStates ( )
virtual

Enables back all slots (usually after having disabled some of them)

◆ ResizeInventoryDisplay()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.ResizeInventoryDisplay ( )
protectedvirtual

Resizes the inventory panel, taking into account the number of rows/columns, the padding and margin

◆ ReturnInventoryFocus()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.ReturnInventoryFocus ( )
virtual

If possible, returns the focus to the current return inventory focus (after equipping an item, usually)

◆ SetCurrentlySelectedSlot()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.SetCurrentlySelectedSlot ( InventorySlot  slot)
virtual

Sets the currently selected slot

Parameters
slotSlot.

◆ SetReturnInventory()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.SetReturnInventory ( InventoryDisplay  inventoryDisplay)
virtual

Sets the return inventory display

Parameters
inventoryDisplayInventory display.

◆ SetupInventoryDisplay()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.SetupInventoryDisplay ( )
virtual

Creates and sets up the inventory display (usually called via the inspector's dedicated button)

◆ SetupSlotNavigation()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.SetupSlotNavigation ( )
protectedvirtual

Setups the slot navigation using Unity's GUI built-in system, so that the user can move using the left/right/up/down arrows

◆ UpdateInventoryContent()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.UpdateInventoryContent ( )
protectedvirtual

Draws the content of the inventory (slots and icons)

◆ UpdateSlot()

virtual void MoreMountains.InventoryEngine.InventoryDisplay.UpdateSlot ( int  i)
protectedvirtual

Updates the slot's content and appearance

Parameters
iThe index.

Member Data Documentation

◆ _comparison

List<int> MoreMountains.InventoryEngine.InventoryDisplay._comparison
protected

◆ _contentLastUpdate

List<ItemQuantity> MoreMountains.InventoryEngine.InventoryDisplay._contentLastUpdate
protected

◆ _currentlySelectedSlot

InventorySlot MoreMountains.InventoryEngine.InventoryDisplay._currentlySelectedSlot
protected

◆ _slotPrefab

InventorySlot MoreMountains.InventoryEngine.InventoryDisplay._slotPrefab = null
protected

◆ _spriteState

SpriteState MoreMountains.InventoryEngine.InventoryDisplay._spriteState = new SpriteState()
protected

◆ _targetInventory

Inventory MoreMountains.InventoryEngine.InventoryDisplay._targetInventory = null
protected

◆ AllowMovingObjectsToThisInventory

bool MoreMountains.InventoryEngine.InventoryDisplay.AllowMovingObjectsToThisInventory = false

if this is true, the Player will be allowed to move objects from another inventory to this one, using the Move button

◆ CurrentlyBeingMovedFromInventoryDisplay

InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.CurrentlyBeingMovedFromInventoryDisplay
static

the item currently being moved

◆ CurrentlyBeingMovedItemIndex

int MoreMountains.InventoryEngine.InventoryDisplay.CurrentlyBeingMovedItemIndex = -1
static

◆ DisabledSlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.DisabledSlotImage

The image to set as the background of each slot when the slot is disabled.

◆ DisplayTitle

bool MoreMountains.InventoryEngine.InventoryDisplay.DisplayTitle =true

if true, will display the panel's title

◆ DrawEmptySlots

bool MoreMountains.InventoryEngine.InventoryDisplay.DrawEmptySlots =true

if this is true, we'll draw slots even if they don't contain an object. Otherwise we don't draw them

◆ EmptySlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.EmptySlotImage

The image to set as the background of each slot when the slot is empty.

◆ EnableNavigation

bool MoreMountains.InventoryEngine.InventoryDisplay.EnableNavigation = true

if true, the engine will automatically create bindings to navigate through the different slots using keyboard or gamepad.

◆ FilledSlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.FilledSlotImage

The image to set as the background of each slot when the slot is not empty.

◆ GetFocusOnStart

bool MoreMountains.InventoryEngine.InventoryDisplay.GetFocusOnStart = false

if this is true, this inventory display will get the focus on start

◆ HighlightedSlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.HighlightedSlotImage

The image to set as the background of each slot when the slot is highlighted.

◆ IconSize

Vector2 MoreMountains.InventoryEngine.InventoryDisplay.IconSize = new Vector2(30,30)

the size of the icon in each slot

◆ ItemClass

ItemClasses MoreMountains.InventoryEngine.InventoryDisplay.ItemClass

◆ MovedSlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.MovedSlotImage

The image to set as the background of each slot when the item in the slot is being moved around.

◆ NextInventory

InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.NextInventory

◆ NumberOfColumns

int MoreMountains.InventoryEngine.InventoryDisplay.NumberOfColumns = 2

the number of columns to display

◆ NumberOfRows

int MoreMountains.InventoryEngine.InventoryDisplay.NumberOfRows = 3

the number of rows to display

◆ PaddingBottom

int MoreMountains.InventoryEngine.InventoryDisplay.PaddingBottom = 20

The internal margin between the bottom of the inventory panel and the last slots.

◆ PaddingLeft

int MoreMountains.InventoryEngine.InventoryDisplay.PaddingLeft = 20

The internal margin between the left of the inventory panel and the first slots.

◆ PaddingRight

int MoreMountains.InventoryEngine.InventoryDisplay.PaddingRight = 20

The internal margin between the right of the inventory panel and the last slots.

◆ PaddingTop

int MoreMountains.InventoryEngine.InventoryDisplay.PaddingTop = 20

The internal margin between the top of the inventory panel and the first slots.

◆ PlayerID

string MoreMountains.InventoryEngine.InventoryDisplay.PlayerID = "Player1"

◆ PressedSlotImage

Sprite MoreMountains.InventoryEngine.InventoryDisplay.PressedSlotImage

The image to set as the background of each slot when the slot is pressed.

◆ PreviousInventory

InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.PreviousInventory

◆ QtyAlignment

TextAnchor MoreMountains.InventoryEngine.InventoryDisplay.QtyAlignment = TextAnchor.LowerRight

where the quantity should be displayed

◆ QtyColor

Color MoreMountains.InventoryEngine.InventoryDisplay.QtyColor = Color.black

the color to display the quantity in

◆ QtyFont

Font MoreMountains.InventoryEngine.InventoryDisplay.QtyFont

the font used to display the quantity

◆ QtyFontSize

int MoreMountains.InventoryEngine.InventoryDisplay.QtyFontSize =12

the font size to use

◆ QtyPadding

float MoreMountains.InventoryEngine.InventoryDisplay.QtyPadding =10f

the padding (distance to the slot's edge)

◆ SlotImageType

Image.Type MoreMountains.InventoryEngine.InventoryDisplay.SlotImageType

The type of the image (sliced, normal, tiled...)

◆ SlotMargin

Vector2 MoreMountains.InventoryEngine.InventoryDisplay.SlotMargin = new Vector2(5,5)

the horizontal and vertical margin to apply between slots rows and columns

◆ SlotPrefab

InventorySlot MoreMountains.InventoryEngine.InventoryDisplay.SlotPrefab

the game object to use as a Slot. If left empty, one will be automatically created at runtime

◆ SlotSize

Vector2 MoreMountains.InventoryEngine.InventoryDisplay.SlotSize = new Vector2(50,50)

the horizontal and vertical size of the slots

◆ TargetChoiceInventory

InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.TargetChoiceInventory

◆ TargetInventoryName

string MoreMountains.InventoryEngine.InventoryDisplay.TargetInventoryName = "MainInventory"

the name of the inventory to display

◆ Title

string MoreMountains.InventoryEngine.InventoryDisplay.Title

the title for the inventory that will be displayed

◆ TitleAlignment

TextAnchor MoreMountains.InventoryEngine.InventoryDisplay.TitleAlignment = TextAnchor.LowerRight

where the quantity should be displayed

◆ TitleColor

Color MoreMountains.InventoryEngine.InventoryDisplay.TitleColor = Color.black

the color to display the quantity in

◆ TitleFont

Font MoreMountains.InventoryEngine.InventoryDisplay.TitleFont

the font used to display the quantity

◆ TitleFontSize

int MoreMountains.InventoryEngine.InventoryDisplay.TitleFontSize =20

the font size to use

◆ TitleOffset

Vector3 MoreMountains.InventoryEngine.InventoryDisplay.TitleOffset =Vector3.zero

the padding (distance to the slot's edge)

Property Documentation

◆ InEquipSelection

virtual bool MoreMountains.InventoryEngine.InventoryDisplay.InEquipSelection
getset

◆ InventoryGrid

virtual GridLayoutGroup MoreMountains.InventoryEngine.InventoryDisplay.InventoryGrid
getprotected set

the grid layout used to display the inventory in rows and columns

◆ InventoryRectTransform

virtual RectTransform MoreMountains.InventoryEngine.InventoryDisplay.InventoryRectTransform
get

the main panel

◆ InventorySize

virtual int MoreMountains.InventoryEngine.InventoryDisplay.InventorySize
getset

the total number of slots in this inventory

◆ InventoryTitle

virtual InventoryDisplayTitle MoreMountains.InventoryEngine.InventoryDisplay.InventoryTitle
getprotected set

the gameobject used to display the inventory's name

◆ IsOpen

virtual bool MoreMountains.InventoryEngine.InventoryDisplay.IsOpen
getprotected set

whether this inventory display is open or not

◆ ReturnInventory

virtual InventoryDisplay MoreMountains.InventoryEngine.InventoryDisplay.ReturnInventory
getprotected set

the inventory the focus should return to after an action

◆ SlotContainer

virtual List<InventorySlot> MoreMountains.InventoryEngine.InventoryDisplay.SlotContainer
getprotected set

an internal list of slots

◆ TargetInventory

Inventory MoreMountains.InventoryEngine.InventoryDisplay.TargetInventory
get

Grabs the target inventory based on its name

The target inventory.


The documentation for this class was generated from the following file: