@@ -8,9 +8,10 @@ struct DragDropSettings
88 bool PixelPerfect; // pixel-perfect hit mode for AGS objects
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
11- int GhostTransparency; // transparency value of the overlay
12- bool GhostAlpha; // keep alpha channel when creating translucent overlays
1311 GUI* GhostGUI; // GUI to use for dragged object representation
12+ int GhostZOrder; // ZOrder to use for ghost representation
13+ int GhostTransparency; // transparency value of the ghost representation
14+ bool GhostAlpha; // keep alpha channel when creating translucent overlays
1415};
1516
1617DragDropSettings DDSet;
@@ -53,9 +54,10 @@ void Reset(this DragDropSettings*)
5354 this .PixelPerfect = false ;
5455 this .TestClickable = false ;
5556 this .Move = eDDCmnMoveSelf;
57+ this .GhostGUI = null;
58+ this .GhostZOrder = 1000 ; // max GUI zorder in 3.2.1, according to the manual
5659 this .GhostTransparency = 33 ;
5760 this .GhostAlpha = true ;
58- this .GhostGUI = null;
5961}
6062
6163// ===========================================================================
@@ -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
@@ -390,47 +402,62 @@ void set_DragMove(this DragDropCommon*, DragDropCommonMove value)
390402
391403// ===========================================================================
392404//
393- // DragDropCommon::GhostTransparency property
405+ // DragDropCommon::GhostGUI property
394406//
395407// ===========================================================================
396- int get_GhostTransparency (this DragDropCommon*)
408+ GUI* get_GhostGUI (this DragDropCommon*)
397409{
398- return DDSet.GhostTransparency ;
410+ return DDSet.GhostGUI ;
399411}
400412
401- void set_GhostTransparency (this DragDropCommon*, int value)
413+ void set_GhostGUI (this DragDropCommon*, GUI* value)
402414{
403- DDSet.GhostTransparency = value;
415+ DDSet.GhostGUI = value;
404416}
405417
406418// ===========================================================================
407419//
408- // DragDropCommon::GhostAlpha property
420+ // DragDropCommon::GhostZOrder property
409421//
410422// ===========================================================================
411- bool get_GhostAlpha (this DragDropCommon*)
423+ int get_GhostZOrder (this DragDropCommon*)
412424{
413- return DDSet.GhostAlpha ;
425+ return DDSet.GhostZOrder ;
414426}
415427
416- void set_GhostAlpha (this DragDropCommon*, bool value)
428+ void set_GhostZOrder (this DragDropCommon*, int value)
417429{
418- DDSet.GhostAlpha = value;
430+ DDSet.GhostZOrder = value;
419431}
420432
421433// ===========================================================================
422434//
423- // DragDropCommon::GhostGUI property
435+ // DragDropCommon::GhostTransparency property
424436//
425437// ===========================================================================
426- GUI* get_GhostGUI (this DragDropCommon*)
438+ int get_GhostTransparency (this DragDropCommon*)
427439{
428- return DDSet.GhostGUI ;
440+ return DDSet.GhostTransparency ;
429441}
430442
431- void set_GhostGUI (this DragDropCommon*, GUI* value)
443+ void set_GhostTransparency (this DragDropCommon*, int value)
432444{
433- DDSet.GhostGUI = value;
445+ DDSet.GhostTransparency = value;
446+ }
447+
448+ // ===========================================================================
449+ //
450+ // DragDropCommon::GhostAlpha property
451+ //
452+ // ===========================================================================
453+ bool get_GhostAlpha (this DragDropCommon*)
454+ {
455+ return DDSet.GhostAlpha ;
456+ }
457+
458+ void set_GhostAlpha (this DragDropCommon*, bool value)
459+ {
460+ DDSet.GhostAlpha = value;
434461}
435462
436463// ===========================================================================
@@ -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