@@ -9,7 +9,8 @@ struct DragDropSettings
99 bool TestClickable; // test Clickable property for AGS objects
1010 DragDropCommonMove Move; // whether object is dragged itself, or overlay with object's image on it
1111 GUI* GhostGUI; // GUI to use for dragged object representation
12- int GhostTransparency; // transparency value of the overlay
12+ int GhostZOrder; // ZOrder to use for ghost representation
13+ int GhostTransparency; // transparency value of the ghost representation
1314 bool GhostAlpha; // keep alpha channel when creating translucent overlays
1415};
1516
@@ -54,6 +55,7 @@ void Reset(this DragDropSettings*)
5455 this .TestClickable = false ;
5556 this .Move = eDDCmnMoveSelf;
5657 this .GhostGUI = null;
58+ this .GhostZOrder = 1000 ; // max GUI zorder in 3.2.1, according to the manual
5759 this .GhostTransparency = 33 ;
5860 this .GhostAlpha = true ;
5961}
@@ -65,9 +67,11 @@ void Reset(this DragDropSettings*)
6567//
6668// ===========================================================================
6769int CreateRepresentation (this DragDropState*, DragDropCommonMove move, int x, int y, int offx, int offy,
68- int slot, int trans, bool has_alpha)
70+ int slot, int trans, int zorder, bool has_alpha)
6971{
7072 this .GhostGraphic = slot;
73+ #ifndef SCRIPT_API_v360
74+ // NOTE: pre-3.6.0 did not support Overlay.Transparency
7175 if (move != eDDCmnMoveGhostGUI &&
7276 trans != 100 && trans != 0 )
7377 {
@@ -78,11 +82,16 @@ int CreateRepresentation(this DragDropState*, DragDropCommonMove move, int x, in
7882 this .GhostDspr = spr;
7983 slot = spr.Graphic ;
8084 }
85+ #endif
8186 this .OverlayOffX = offx;
8287 this .OverlayOffY = offy;
8388 if (move == eDDCmnMoveGhostOverlay)
8489 {
8590 this .GhostOverlay = Overlay.CreateGraphical (x + offx, y + offy, slot, true );
91+ #ifdef SCRIPT_API_v360
92+ this .GhostOverlay .Transparency = trans;
93+ this .GhostOverlay .ZOrder = zorder;
94+ #endif
8695 }
8796 else
8897 {
@@ -93,7 +102,7 @@ int CreateRepresentation(this DragDropState*, DragDropCommonMove move, int x, in
93102 this .GhostGUI .Y = y + offy;
94103 this .GhostGUI .Width = Game.SpriteWidth [slot];
95104 this .GhostGUI .Height = Game.SpriteHeight [slot];
96- this .GhostGUI .ZOrder = 1000 ; // max zorder, according to the manual
105+ this .GhostGUI .ZOrder = zorder;
97106 this .GhostGUI .Visible = true ;
98107 }
99108 this .Move = move;
@@ -168,7 +177,7 @@ static bool DragDropCommon::TryHookCharacter()
168177 if (vf != null)
169178 sprite = vf.Graphic ;
170179 DDState.CreateRepresentation (DDSet.Move , c.x , c.y , 0 , -Game.SpriteHeight [sprite], sprite,
171- DDSet.GhostTransparency , DDSet.GhostAlpha );
180+ DDSet.GhostTransparency , DDSet.GhostZOrder , DDSet. GhostAlpha );
172181 }
173182 return true ;
174183}
@@ -190,6 +199,7 @@ static bool DragDropCommon::TryHookGUI()
190199 return false ;
191200 DDState._GUI = g;
192201 DragDrop.HookObject (eDragDropGUI, g.X , g.Y );
202+ // NOTE: GUIs may be only dragged on their own
193203 return true ;
194204}
195205
@@ -211,6 +221,7 @@ static bool DragDropCommon::TryHookGUIControl()
211221 return false ;
212222 DDState._GUIControl = gc;
213223 DragDrop.HookObject (eDragDropGUIControl, gc.X , gc.Y );
224+ // NOTE: GUI Controls may be only dragged on their own
214225 return true ;
215226}
216227
@@ -247,7 +258,7 @@ static bool DragDropCommon::TryHookRoomObject()
247258 sprite = o.Graphic ;
248259 }
249260 DDState.CreateRepresentation (DDSet.Move , o.X , o.Y , 0 , -Game.SpriteHeight [sprite], sprite,
250- DDSet.GhostTransparency , DDSet.GhostAlpha );
261+ DDSet.GhostTransparency , DDSet.GhostZOrder , DDSet. GhostAlpha );
251262 }
252263 return true ;
253264}
@@ -271,9 +282,10 @@ static bool DragDropCommon::TryHookInventoryItem()
271282 int i_x = DragDrop.DragStartX - (DragDrop.DragStartX - wnd.OwningGUI .X - wnd.X ) % wnd.ItemWidth ;
272283 int i_y = DragDrop.DragStartY - (DragDrop.DragStartY - wnd.OwningGUI .Y - wnd.Y ) % wnd.ItemHeight ;
273284 DragDrop.HookObject (eDragDropInvItem, i_x, i_y);
285+ // NOTE: Inventory Items may be only dragged using representation
274286 int sprite = i.Graphic ;
275287 DDState.CreateRepresentation (DDSet.Move , i_x, i_y, 0 , 0 , sprite,
276- DDSet.GhostTransparency , DDSet.GhostAlpha );
288+ DDSet.GhostTransparency , DDSet.GhostZOrder , DDSet. GhostAlpha );
277289 return true ;
278290}
279291
@@ -403,6 +415,21 @@ void set_GhostGUI(this DragDropCommon*, GUI* value)
403415 DDSet.GhostGUI = value;
404416}
405417
418+ // ===========================================================================
419+ //
420+ // DragDropCommon::GhostZOrder property
421+ //
422+ // ===========================================================================
423+ int get_GhostZOrder (this DragDropCommon*)
424+ {
425+ return DDSet.GhostZOrder ;
426+ }
427+
428+ void set_GhostZOrder (this DragDropCommon*, int value)
429+ {
430+ DDSet.GhostZOrder = value;
431+ }
432+
406433// ===========================================================================
407434//
408435// DragDropCommon::GhostTransparency property
@@ -571,6 +598,16 @@ int get_ObjectHeight(this DragDropCommon*)
571598 return 0 ;
572599}
573600
601+ // ===========================================================================
602+ //
603+ // DragDropCommon::GhostOverlay property
604+ //
605+ // ===========================================================================
606+ Overlay* get_GhostOverlay (this DragDropCommon*)
607+ {
608+ return DDState.GhostOverlay ;
609+ }
610+
574611// ===========================================================================
575612//
576613// DragDropCommon::UsedGhostGraphic property
0 commit comments