Skip to content

SelectTool

Extends: Tool < Object

Description

The tool used to select objects. Inherits from Tool.

Accessed by Global.Editor.Tools["SelectTool"].

Properties

Selectable highlighted
Node2D[] Selected
Dictionary Selectables
Selectable[] RawSelectables
Vector2 boxBegin
Vector2 boxEnd
bool isDrawing
bool isMakingPrefab
int transformMode
int transformCorner
Dictionary initialRelativeTransforms
Transform2D preDragTransform
Vector2 transformPreDragBoxSize
Vector2 transformPreDragMousePosition
float transformPreDragMouseRotation
int manualAction
Node2D[] movableThings
Vector2[] preMovePositions
Vector2 moveDelta
bool justManualMoved
Portal movedPortal
Sprite portalAfterimage
Wall movedPortalWall
Light2D attenuatedLight
float instantDragTimer
int[] transformsIDs
Transform2D[] transformsBefore
Transform2D[] transformsAfter
bool hasDetectedMouseMotionThisFrame
Dictionary Filter
Dictionary LayerFilter
OptionButton LayerMenu
bool AreDeletable
bool HasCopyable
bool HasPrefab
bool HasPastable

Methods

void OnFinishSelection ( )
void HandleUndoOrRedo ( )
bool IsSelectableLocked ( Selectable s )
void CheckForInstantDrag ( Selectable s )
void Delete ( )
void PreviousTool ( )
void HighlightThingAtPoint ( )
void DehighlightSelected ( )
void Highlight ( Selectable s, bool value )
void SelectThingsInsideBox ( Rect2 box, bool value )
bool IsDeletable ( Selectable s )
void DeselectAll ( )
void DeselectAllEx ( )
void Select ( Selectable s, bool value )
Selectable SelectThing ( Node2D thing, bool value )
Selectable[] GetGrouped ( Selectable s )
int GetSelectableType ( Node node )
Selectable GetSelectable ( Node2D thing )
void EnableTransformBox ( bool value )
void ClearTransformSelection ( )
Rect2 GetSelectionRect ( )
int GetTransformMode ( )
void ApplyTransforms ( Transform2D t )
void RotateTransformBox ( float rotation )
void MirrorTransformBox ( )
void SavePreTransforms ( )
void RecordTransforms ( )
void PreviewPortalMove ( )
void ApplyPortalMove ( )
void Copy ( )
String Serialize ( bool clipboard )
void Lock ( )
bool IsSelectionLocked ( )
void MakePrefab ( )
void Separate ( )
void Paste ( )
void MergeWalls ( )
bool IsObjectLayerFiltered ( Node2D object )
void SetLayer ( int index )
void ChangeTexture ( Texture texture, String name )
void ChangeColor ( Color color, String name )
Color GetWallColor ( Texture texture = null )
void SetWallColor ( Color color )
void SetPatternColor ( Color color )
void SetPortalClosed ( bool value )
void SetShadow ( bool value )
void SetBlockLight ( bool value )
void SetPathwayTexture ( Texture texture )
void BringToFront ( )
void SendToBack ( )

Property Descriptions

  • Node2D[] Selected:
    Gets an array of things selected by the user. A special function exposed a beautified version of the selection to mod scripts.

  • Dictionary Selectables:
    Gets a dictionary of things selected by the user of Node2D key - int value pairs. A special function exposed a beautified version of the selection to mod scripts. The key are the selected things and the int is the type of selected thing. Reference the following enum to identify a selected type. The enumeration is internal to Dungeondraft and becomes an int when it enters your script.
    enum SelectableTypes
    {
        Invalid = 0
        Wall = 1
        PortalFree = 2
        PortalWall = 3
        Object = 4
        Pathway = 5
        Light = 6
        PatternShape = 7
        Roof = 8
    }
    

  • Selectable[] RawSelectables:
    Gets an array of unbeautified Selectable. It is a sub-class which allows the SelectTool to safely select and manipulate asset instances. When a SelectTool modifies a selection, Selectable is the real class that is used. A Selectable has three properties:

  • Vector2 boxBegin:
    Gets the selection box start position.

  • Vector2 boxEnd:
    Gets the selection box end position.

  • bool isDrawing:
    Gets if the user is actively drawing.

  • bool isMakingPrefab:
    Gets if the user has the prefab window open and is trying to make a new prefab.

  • int transformMode:
    Gets the current mode of the transformation box. It is automatically adjusted based on the user's mouse cursor intention. gdscript enum TransformMode { None, Move, Rotate, Scale }

  • int transformCorner:
    Gets the corner id of the mouse corner on the selection box. The ids are in clockwise order starting from the top-left corner from 0 to 3. A -1 means that the cursor is not near a corner.

  • Dictionary initialRelativeTransforms:
    Gets a Dictionary of Selectable key - Transform2D value pairs that preserves the positional data of the selected objects before it was transformed by the user.

  • Transform2D preDragTransform:
    The transformation data of the selection box (not the objects) before the user moves it.

  • Vector2 transformPreDragBoxSize:
    The size of the selection box (not the objects) before the user moves it. Only accurate when the user is actively resizing.

  • Vector2 transformPreDragMousePosition:
    The position of the selection box (not the objects) before the user moves it. Only accurate when the user is actively moving.

  • float transformPreDragMouseRotation:
    The rotation of the selection box (not the objects) before the user moves it. Only accurate when the user is actively rotating.

  • int manualAction:
    Gets the manual action of a single selected object is applicable. public enum ManualAction { None, MoveThing, MovePortal, AttenuateLight }

  • Node2D[] movableThings:
    Gets the list of things in selection that are movable during instant drag.

  • Vector2[] preMovePositions:
    Gets the list of pre move positions of things in selection that are movable during instant drag.

  • Vector2 moveDelta:
    Gets the vector of the last manual move.

  • bool justManualMoved:
    Gets if the user just manually drag moved a selection.

  • Portal movedPortal:
    Gets the portal that was just moved.

  • Sprite portalAfterimage:
    Gets the ghost image of the portal in the original position during a user's dragging of a portal.

  • Wall movedPortalWall:
    Gets the wall the moved portal originated from.

  • Light2D attenuatedLight:
    Gets the light that was last instant edited.

  • float instantDragTimer:
    A short timer variable used to slightly delay an instant-drag for better feel.

  • int[] transformsIDs:
    Gets all the NodeIDs of selected objects being transformed.

  • Transform2D[] transformsBefore:
    Gets the transformation data of selected objects before a change. Used for undo history.

  • Transform2D[] transformsAfter:
    Gets the transformation data of selected objects after a change. Used for undo history.

  • bool hasDetectedMouseMotionThisFrame:
    Gets if mouse cursor movement was detected this engine frame.

  • Dictionary Filter:
    The lookup table of String key - bool value pair of whether or not a filter for the select tool is enabled. Used by the Type Filter menu in UI. Valid keys are: "Walls", "Portals", "Objects", "Paths", "Lights", "Patterns", and "Roofs".

  • Dictionary LayerFilter:
    The lookup table of int key - bool value pair of whether or not a layer for the select tool is enabled. Used by the Layer Filter menu in UI.

  • OptionButton LayerMenu:
    The reference to the layer menu in the Select Tool to change a selection to.

  • bool AreDeletable:
    Checks if the selection has deletable objects.

  • bool HasCopyable:
    Checks if the selection has any copyable objects.

  • bool HasPrefab:
    Gets if there are any prefabs selected.

  • bool HasPastable:
    Gets if there are anything to paste in the OS clipboard.

Method Descriptions

  • void OnFinishSelection ( ):
    Called when a user lets go of a new drag box, and creates a visual selection box that allows transformations.

  • void HandleUndoOrRedo ( ):
    Called when an undo or redo is performed to clear existing selections.


  • void CheckForInstantDrag ( Selectable s ):
    Checks if the mouse-overed object is available for instant modification features. Will prepare the relevant properties if applicable like moveDelta and manualAction.

  • void Delete ( ):
    Deletes all selected things.

  • void PreviousTool ( ):
    Switches to the last used tool away from SelectTool.


  • void DehighlightSelected ( ):
    Removes highlighting of selected objects. (No need to highlight once selected).




  • void DeselectAll ( ):
    Removes all things from selection. Call ClearTransformSelection() instead if you want to also clear the selection box visuals.

  • void DeselectAllEx ( ):
    Same as deselect all, except used when the user holds Shift to keep certain objects selected.


  • Selectable SelectThing ( Node2D thing, bool value ):
    External version of Select to allow safe select and deselecting of things. Automatically creates an internal Selectable if it does not exist. You will want to call Global.Editor.Toolset.GetToolPanel("SelectTool").OnSelect(type) if you want the Select Tool panel to display the controls that allow the user to edit the selected type. Returns the existing Selectable or creates a new Selectable if it does not exist.



  • Selectable GetSelectable ( Node2D thing ):
    Gets the Selectable of a thing. Only works for things already inside the selection. Otherwise, use Select(Node2D thing).



  • Rect2 GetSelectionRect ( ):
    Returns a Rect2 that encloses all selected things. This is the function also called internally by SelectTool just after a user draws a box.

  • int GetTransformMode ( ):
    Checks the selection and updates to the proper transform mode and returns it as an int.
    public enum TransformMode
    {
        None,
        Move,
        Rotate,
        Scale
    }
    


  • void RotateTransformBox ( float rotation ):
    Rotates every thing that can be rotated in degrees by the center of the box.

  • void MirrorTransformBox ( ):
    Horizontally flip all transformable things along center of the box.

  • void SavePreTransforms ( ):
    Creates a snapshot of the transforms of the selection before a change. Saves to transformIDs and transformsBefore.

  • void RecordTransforms ( ):
    Records any changes for the redo history and uses the data from SavePreTransforms() to create the undo history.

  • void PreviewPortalMove ( ):
    Called when the user drags a Portal and creates a ghost in the old Portal location and moves the Portal to the closest logical place along a wall under the cursor.

  • void ApplyPortalMove ( ):
    Finalizes the previewed Portal move and deletes the previous Portal and its ghost image.

  • void Copy ( ):
    Copies the selection onto the OS clipboard as text serialized by Serialize().

  • String Serialize ( bool clipboard ):
    Serialize the selection into text. Set clipboard to true if using it to copy and to false if using it to make a prefab.

  • void Lock ( ):
    Toggles the lock on selected things. Use carefully, as the user may not realize you locked their asset instances.


  • void MakePrefab ( ):
    Prompts the user to make the current selection into a prefab.

  • void Separate ( ):
    Separate the current selected prefab instance into individual pieces and disassociating with the prefab.

  • void Paste ( ):
    Converts any text in the clipboard that is pastable into real objects and pastes it onto the map.

  • void MergeWalls ( ):
    Merges walls if there are more than one wall selected that can be merged. Incompatible with a selection of mixed types.


  • void ChangeTexture ( Texture texture, String name ):
    Change a texture of the selected items. Valid name options are: "WallTexture", "PortalTexture", "PatternTexture", and "LightTexture".

  • void ChangeColor ( Color color, String name ):
    Change a color of the selected items. Valid name options are: "WallColor", "CustomColor", "PatternColor", and "LightColor".





  • void SetShadow ( bool value ):
    Set selected items to draw a shadow underneath if applicable.

  • void SetBlockLight ( bool value ):
    Set selected items to block light if applicable.


  • void BringToFront ( ):
    Bring selected items to the foreground if applicable.

  • void SendToBack ( ):
    Send selected items to the background if applicable.