Adventure Creator 1.84.3
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2024
Loading...
Searching...
No Matches
AC.MenuDrag Class Reference
Inheritance diagram for AC.MenuDrag:
AC.MenuElement AC.ITranslatable

Public Member Functions

override void Declare ()
override MenuElement DuplicateSelf (bool fromEditor, bool ignoreUnityUI)
 Creates and returns a new MenuElement that has the same values as itself.
override void ShowGUI (Menu menu, System.Action< ActionListAsset > showALAEditor)
override void DrawOutline (bool isSelected, AC.Menu _menu)
 Draws an outline around the element.
override void PreDisplay (int _slot, int languageNumber, bool isActive)
 Performs all calculations necessary to display the element.
override void Display (GUIStyle _style, int _slot, float zoom, bool isActive)
 Draws the element using OnGUI.
override string GetLabel (int slot, int languageNumber)
 Gets the display text of the element, or a slot within it.
bool DoDrag (Vector2 _dragVector)
 Performs the drag.
bool CheckStop (Vector2 mousePosition)
 Checks if the dragging should be cancelled.
override bool ProcessClick (AC.Menu _menu, int _slot, MouseState _mouseState)
 Performs what should happen when the element is clicked on.
string GetTranslatableString (int index)
 Gets the text to be translated, given its index.
int GetTranslationID (int index)
 Gets the translation ID of a given text index.
void UpdateTranslatableString (int index, string updatedText)
int GetNumTranslatables ()
 Gets the maximum number of possible translatable texts.
bool HasExistingTranslation (int index)
 Checks if a given text index has already been assigned a unique translation ID.
void SetTranslationID (int index, int _lineID)
 Sets the translation ID of a given text index.
string GetOwner (int index)
 Gets the name of the translatable text's owner. In the case of speech text, it is the name of the character. In the case of menu element text, it is the name of the menu element.
bool OwnerIsPlayer (int index)
 Checks if the translatable text's owner is a Player. This is necessary for speech lines, since multiple player prefabs can feasibly share the same line.
AC_TextType GetTranslationType (int index)
 Gets the translation type of a given text index.
bool CanTranslate (int index)
 Checks if a given text index can and should be translated.
Public Member Functions inherited from AC.MenuElement
virtual void Copy (MenuElement _element)
 Copies the values of another MenuElement onto itself.
virtual void Initialise (AC.Menu _menu)
 Performs any initialisation that can only be done once the element has been instantiated at runtime.
virtual void LoadUnityUI (AC.Menu _menu, Canvas canvas, bool addEventListeners=true)
 Initialises the linked Unity UI GameObject.
virtual bool ProcessContinuousClick (AC.Menu _menu, MouseState _mouseState)
 Performs what should happen when the element is clicked on continuously.
virtual GameObject GetObjectToSelect (int slotIndex=0)
 Gets the linked Unity UI GameObject associated with this element.
virtual RectTransform GetRectTransform (int _slot)
 Gets the boundary of the element, or a slot within it.
virtual void SetSpeech (Speech _speech)
 Assigns the element to a specific Speech line.
virtual void ClearSpeech ()
void UpdateID (int[] idArray)
 Updates the ID number to something unique.
virtual void OverrideLabel (string newLabel, int _lineID=-1)
void UpdateLabel (int languageNumber)
virtual bool IsSelectedByEventSystem (int slotIndex)
 Checks if the element is selected by Unity UI's EventSystem (if the Menu is Unity UI-based).
virtual bool IsSelectableInteractable (int slotIndex)
 Checks if the element's linked Selectable is currently Interactable (if the Menu is Unity UI-based).
void ShowGUIStart (Menu menu, System.Action< ActionListAsset > showALAEditor)
virtual bool CheckConvertGlobalVariableToLocal (int oldGlobalID, int newLocalID)
 Checks if the Element makes references from a given global variable to a given local variable.
virtual int GetVariableReferences (int varID)
 Gets the number of references the MenuElement makes to a global variable.
virtual int UpdateVariableReferences (int oldVarID, int newVarID)
 Updates references the MenuElement makes to a global variable.
virtual bool ReferencesAsset (ActionListAsset actionListAsset)
 Checks if the Menu makes reference to a particular ActionList asset.
virtual bool ReferencesObjectOrID (GameObject gameObject, int id)
 Checks if the Element makes reference to a particular GameObject.
virtual int GetSlotIndex (GameObject gameObject)
 Gets the slot index that reference a particular GameObject.
virtual void HideAllUISlots ()
virtual string GetHotspotLabelOverride (int _slot, int _language)
 Gets a string that overrides the default 'hotspot label'.
Vector2[] GetSlotCentres (AC.Menu _menu)
 Gets the element's slot centres, as an array of Vector2s. This is used when keyboard-navigating menus.
virtual void Shift (AC_ShiftInventory shiftType, int amount)
 Shifts which slots are on display, if the number of slots the element has exceeds the number of slots it can show at once.
virtual bool CanBeShifted (AC_ShiftInventory shiftType)
 Checks if the element's slots can be shifted in a particular direction.
Vector2 GetSize ()
 Gets the size of the whole element.
Vector2 GetSizeFromCorner ()
 Gets the Vector2 from the top-left corner of the parent Menu to the bottom-right corner of the element.
void SetSize (Vector2 _size)
 Sets the size of an individual slot.
int GetNumSlots ()
 Gets the number of display slots the element has. This is not the maximum number of slots that can be shown by shifting - it is the number of slots that are shown at any one time.
Rect GetSlotRectRelative (int _slot)
 Gets the boundary of a slot, as a proportion of the screen size.
virtual void RecalculateSize (MenuSource source)
 Recalculates the element's size. This should be called whenever a Menu's shape is changed.
int GetFontSize ()
 Gets the size of the font.
void SetPosition (Vector2 _position)
 Sets the element's position.
void SetRelativePosition (Vector2 _size)
void ResetDragOffset ()
void SetDragOffset (Vector2 pos, Rect dragRect)
 Offsets an OnGUI MenuElement's position when dragged by a MenuDrag element.
Vector2 GetDragStart ()
 Gets the drag offset.
void AutoSetVisibility ()
virtual void SetUIInteractableState (bool state)
 Sets the interactive state of any linked Unity UI gameobjects.
virtual AudioClip GetHoverSound (int slot)
 Gets the hover sound for the element slot.
int GetOffset ()
 Gets the amount by which the slots have been offset, if the number that can be shown exceeds the number that can be display at once.
void SetOffset (int value)
 Sets the amount by which the slots have been offset, if the number that can be shown exceeds the number that can be display at once.
virtual void OnMenuTurnOn (Menu menu)
 Called whenever the Menu this is attached to is turned on.
virtual bool SupportsRightClicks ()
string GetVisibilitySaveData ()
override string ToString ()

Public Attributes

string label = "Element"
TextAnchor anchor
TextEffects textEffects
Rect dragRect
DragElementType dragType = DragElementType.EntireMenu
string elementName
Public Attributes inherited from AC.MenuElement
int ID
string title = "Element"
Vector2 slotSize
AC_SizeType sizeType
AC_PositionType2 positionType
float slotSpacing = 0f
int lineID = -1
string alternativeInputButton = ""
Font font
float fontScaleFactor = 60f
Color fontColor = Color.white
Color fontHighlightColor = Color.white
bool isClickable
ElementOrientation orientation = ElementOrientation.Vertical
int gridWidth = 3
Texture2D backgroundTexture
bool singleSlotBackgrounds = false
Texture2D highlightTexture
AudioClip hoverSound
AudioClip clickSound
bool changeCursor = false
int cursorID = 0
int linkedUiID
float maxAutoWidthFactor = 0.5f

Protected Member Functions

override string GetLabelToTranslate ()
override void AutoSize ()
Protected Member Functions inherited from AC.MenuElement
void CreateUIEvent (UnityEngine.UI.Button uiButton, AC.Menu _menu, UIPointerState uiPointerState=UIPointerState.PointerClick, int _slotIndex=0, bool liveState=true)
void CreateHoverSoundHandler (Selectable selectable, AC.Menu _menu, int _slotIndex=0)
virtual void ProcessClickUI (AC.Menu _menu, int _slot, MouseState _mouseState)
void ClearCache ()
string TranslateLabel (int languageNumber)
virtual void ShowTextGUI (string apiPrefix)
virtual void ShowTextureGUI (string apiPrefix)
void EndGUI (string apiPrefix)
void ShowClipHelp ()
LinkedUiGUI< T > (T field, string label, Menu menu, string tooltip="")
UISlot[] ResizeUISlots (UISlot[] uiSlots, int maxSlots)
void ChangeCursorGUI (Menu menu)
void LimitUISlotVisibility (UISlot[] uiSlots, int _numSlots, UIHideStyle uiHideStyle, Texture emptyTexture=null)
void LimitUISlotVisibility (UISlot[] uiSlots, int _numSlots, UISelectableHideStyle uiHideStyle)
Rect ZoomRect (Rect rect, float zoom)
void LimitOffset ()
void Shift (AC_ShiftInventory shiftType, int maxSlots, int arraySize, int amount, bool canBeLooped=false)
void SetAbsoluteSize (Vector2 _size)
void AutoSize (GUIContent content)
void LinkUIElement< T > (Canvas canvas, ref T existingField)
void UpdateUISelectable< T > (T field, UISelectableHideStyle uiSelectableHideStyle)
void UpdateUIElement< T > (T field, UIComponentHideStyle uiComponentHideStyle)
void ClearSpriteCache (UISlot[] uiSlots)
void SetUISlotsInteractableState (UISlot[] uiSlots, bool state)

Additional Inherited Members

Protected Attributes inherited from AC.MenuElement
bool isVisible = true
int offset = 0
Menu parentMenu
Rect relativeRect
Vector2 relativePosition
int numSlots
Properties inherited from AC.MenuElement
virtual bool IsVisible [get, set]
virtual int MaxSlotsForOffset [get]
Menu ParentMenu [get]

Detailed Description

A MenuElement that can be used to drag around another element, or its parent Menu. This element type cannot be used in Unity UI-based Menus, because Unity UI has its own classes that perform the same functionality.

Member Function Documentation

◆ AutoSize()

override void AC.MenuDrag.AutoSize ( )
protectedvirtual

Reimplemented from AC.MenuElement.

◆ CanTranslate()

bool AC.MenuDrag.CanTranslate ( int index)

Checks if a given text index can and should be translated.

Parameters
indexThe index of the translatable text
Returns
True if the text can and should be translated

Implements AC.ITranslatable.

◆ CheckStop()

bool AC.MenuDrag.CheckStop ( Vector2 mousePosition)

Checks if the dragging should be cancelled.

Parameters
mousePositionThe position of the mouse cursor
Returns
True if the dragging should be cancelled

◆ Declare()

override void AC.MenuDrag.Declare ( )
virtual

Initialises the MenuElement when it is created within MenuManager.

Reimplemented from AC.MenuElement.

◆ Display()

override void AC.MenuDrag.Display ( GUIStyle _style,
int _slot,
float zoom,
bool isActive )
virtual

Draws the element using OnGUI.

Parameters
_styleThe GUIStyle to draw with
_slotThe index number of the slot to display
zoomThe zoom factor
isActiveIf True, then the element will be drawn as though highlighted

Reimplemented from AC.MenuElement.

◆ DoDrag()

bool AC.MenuDrag.DoDrag ( Vector2 _dragVector)

Performs the drag.

Parameters
_dragVectorThe amount and direction to drag by
Returns
True if the drag effect was successful

◆ DrawOutline()

override void AC.MenuDrag.DrawOutline ( bool isSelected,
AC.Menu _menu )
virtual

Draws an outline around the element.

Parameters
isSelectedIf True, a different-coloured outline will be used to differentiate it from others
_menuThe element's parent Menu

Reimplemented from AC.MenuElement.

◆ DuplicateSelf()

override MenuElement AC.MenuDrag.DuplicateSelf ( bool fromEditor,
bool ignoreUnityUI )
virtual

Creates and returns a new MenuElement that has the same values as itself.

Parameters
fromEditorIf True, the duplication was done within the Menu Manager and not as part of the gameplay initialisation.
ignoreUnityUIIf True, variables associated with Unity UI will not be transferred
Returns
A new MenuElement with the same values as itself

Reimplemented from AC.MenuElement.

◆ GetLabel()

override string AC.MenuDrag.GetLabel ( int slot,
int languageNumber )
virtual

Gets the display text of the element, or a slot within it.

Parameters
slotThe index number of the slot to get text for
languageNumberThe index number of the language number to get the text in
Returns
The display text of the element's slot, or the whole element if it only has one slot

Reimplemented from AC.MenuElement.

◆ GetLabelToTranslate()

override string AC.MenuDrag.GetLabelToTranslate ( )
protectedvirtual

Reimplemented from AC.MenuElement.

◆ GetNumTranslatables()

int AC.MenuDrag.GetNumTranslatables ( )

Gets the maximum number of possible translatable texts.

Returns
The maximum number of possible translatable texts.

Implements AC.ITranslatable.

◆ GetOwner()

string AC.MenuDrag.GetOwner ( int index)

Gets the name of the translatable text's owner. In the case of speech text, it is the name of the character. In the case of menu element text, it is the name of the menu element.

Parameters
indexThe index of the translatable text
Returns
The name of the translatable text's owner.

Implements AC.ITranslatable.

◆ GetTranslatableString()

string AC.MenuDrag.GetTranslatableString ( int index)

Gets the text to be translated, given its index.

Parameters
indexThe index of the translatable text
Returns
The text to be translated

Implements AC.ITranslatable.

◆ GetTranslationID()

int AC.MenuDrag.GetTranslationID ( int index)

Gets the translation ID of a given text index.

Parameters
indexThe index of the translatable text
Returns
The translation ID of the text

Implements AC.ITranslatable.

◆ GetTranslationType()

AC_TextType AC.MenuDrag.GetTranslationType ( int index)

Gets the translation type of a given text index.

Parameters
indexThe index of the translatable text
Returns
The translation type of a given text index.

Implements AC.ITranslatable.

◆ HasExistingTranslation()

bool AC.MenuDrag.HasExistingTranslation ( int index)

Checks if a given text index has already been assigned a unique translation ID.

Parameters
indexThe index of the translatable text
Returns
True if the text has been assigned a unique translation ID

Implements AC.ITranslatable.

◆ OwnerIsPlayer()

bool AC.MenuDrag.OwnerIsPlayer ( int index)

Checks if the translatable text's owner is a Player. This is necessary for speech lines, since multiple player prefabs can feasibly share the same line.

Parameters
indexThe index of the translatable text
Returns
True if the translatable text's owner is a Player.

Implements AC.ITranslatable.

◆ PreDisplay()

override void AC.MenuDrag.PreDisplay ( int _slot,
int languageNumber,
bool isActive )
virtual

Performs all calculations necessary to display the element.

Parameters
_slotThe index number of the slot to display
languageNumberThe index number of the language to display text in
isActiveIf True, then the element will be drawn as though highlighted

Reimplemented from AC.MenuElement.

◆ ProcessClick()

override bool AC.MenuDrag.ProcessClick ( AC.Menu _menu,
int _slot,
MouseState _mouseState )
virtual

Performs what should happen when the element is clicked on.

Parameters
_menuThe element's parent Menu
_slotThe index number of the slot that was clicked on
_mouseStateThe state of the mouse button
Returns
True if the click had an effect, and so should be consumed

Reimplemented from AC.MenuElement.

◆ SetTranslationID()

void AC.MenuDrag.SetTranslationID ( int index,
int lineID )

Sets the translation ID of a given text index.

Parameters
indexThe index of the translatable text
lineIDThe new translation ID to assign the translatable text

Implements AC.ITranslatable.

◆ ShowGUI()

override void AC.MenuDrag.ShowGUI ( Menu menu,
System.Action< ActionListAsset > showALAEditor )
virtual

Reimplemented from AC.MenuElement.

◆ UpdateTranslatableString()

void AC.MenuDrag.UpdateTranslatableString ( int index,
string updatedText )

Implements AC.ITranslatable.

Member Data Documentation

◆ anchor

TextAnchor AC.MenuDrag.anchor

The text alignment

◆ dragRect

Rect AC.MenuDrag.dragRect

The boundary that the draggable Menu or MenuElement can be moved within

◆ dragType

DragElementType AC.MenuDrag.dragType = DragElementType.EntireMenu

What the MenuDrag can be used to move (EntireMenu, SingleElement)

◆ elementName

string AC.MenuDrag.elementName

The name of the MenuElement that can be dragged, if dragType = DragElementType.SingleElement

◆ label

string AC.MenuDrag.label = "Element"

The text that's displayed on-screen

◆ textEffects

TextEffects AC.MenuDrag.textEffects

The special FX applied to the text (None, Outline, Shadow, OutlineAndShadow)