Skip to content

DragDropCommon module API

ivan-mogilko edited this page Jan 31, 2024 · 4 revisions

DragDropCommon functions and properties

See also: Drag & Drop module overview

Setting up

This is how you configure the module up.

static bool DragDropCommon.ModeEnabled[]
this indexed (array) attribute is used to get or set which types of game objects are enabled for auto-dragging. These modes are described by a enum DragDropCommonMode:

  • eDragDropCharacter
  • eDragDropGUI
  • eDragDropGUIControl
  • eDragDropRoomObject
  • eDragDropInvItem

For example: DragDropCommon.ModeEnabled[eDragDropCharacter] = true; enables automatic hookup and dragging of Characters. You may enable multiple modes at once. If you don't enable any, there's still a way to hook up an object manually using one of the "TryHook..." functions (see below).

static void DragDropCommon.DisableAllModes()
disables everything at once. This is simply a convenience function.

static bool DragDropCommon.PixelPerfect
gets/sets whether click on AGS object should be tested using pixel-perfect detection; otherwise uses a simple bounding rectangle test. NOTE: currently only works for Characters and Room Objects.

static bool DragDropCommon.TestClickable
gets/sets whether only clickable objects should be dragged.

static DragDropCommonMove DragDropCommon.DragMove
gets/sets the dragging representation mode. These modes are described by a enum DragDropCommonMove:

Mode Description
eDDCmnMoveSelf Drag actual object itself (position updates real-time); NOTE: cannot be used with inventory items.
eDDCmnMoveGhostOverlay Create and drag overlay with object's image, while object stays in place until drag ends; NOTE: works for Characters, Room Objects and Inventory Items.
eDDCmnMoveGhostGUI Drag GUI with object's image, you must provide the GUI yourself; NOTE: works for Characters, Room Objects and Inventory Items.

static GUI* DragDropCommon.GhostGUI
gets/sets the GUI for eDDCmnMoveGhostGUI mode. You must set this if you're using eDDCmnMoveGhostGUI mode, otherwise the module will crash with "null pointer" error.

static int DragDropCommon.GhostZOrder
gets/sets the ZOrder of a "ghost overlay" or "ghost GUI" representation (default = 1000). IMPORTANT: only applies for overlays in AGS 3.6.0 and higher.

static bool DragDropCommon.GhostAlpha
gets/sets whether the "ghost" representation should keep sprite's alpha channel (default = true).

static int DragDropCommon.GhostTransparency
gets/sets the transparency of a "ghost overlay" or "ghost GUI" representation (default = 33).

State control

Following attributes and functions tell and control the dragging state:

static readonly Character* DragDropCommon._Character
returns the currently hooked Character, or null if none is hooked.

static readonly GUI* DragDropCommon._GUI
returns the currently hooked GUI, or null if none is hooked.

static readonly GUIControl* DragDropCommon._GUIControl
returns the currently hooked GUI control, or null if none is hooked.

static readonly Object* DragDropCommon._RoomObject
returns the currently hooked Room Object, or null if none is hooked.

static readonly InventoryItem* DragDropCommon._InvItem
returns the currently hooked Inventory Item, or null if none is hooked.

static readonly int DragDropCommon.ObjectWidth
returns the hooked object's width, or the width of its representation.

static readonly int DragDropCommon.ObjectHeight
returns the hooked object's height, or the width of its representation.

static readonly int DragDropCommon.GhostOverlay
returns the dragged object's representing Overlay, if the "ghost overlay" mode is used.

static readonly int DragDropCommon.UsedGhostGraphic
returns the dragged object's representation graphic, if one of the "ghost" modes are used.

static bool DragDropCommon.TryHookCharacter()
when DragDrop is in "Hooking object" state, this will try to hook up a Character under the mouse cursor.

static bool DragDropCommon.TryHookGUI()
when DragDrop is in "Hooking object" state, this will try to hook up a GUI under the mouse cursor.

static bool DragDropCommon.TryHookGUIControl()
when DragDrop is in "Hooking object" state, this will try to hook up a GUI control under the mouse cursor.

static bool DragDropCommon.TryHookRoomObject()
when DragDrop is in "Hooking object" state, this will try to hook up a Room Object under the mouse cursor.

static bool DragDropCommon.TryHookInventoryItem()
when DragDrop is in "Hooking object" state, this will try to hook up a Inventory Item under the mouse cursor.

static bool DragDropCommon.TryHookDraggableObject()
when DragDrop is in "Hooking object" state, this will try to hook up any suitable object under the mouse cursor, depending on which types are enabled using DragDropCommon.ModeEnabled[].