How to make a drag and drop operation with custom destination location

@Viir

Today I back for you with a new question :smiley:

I try to explain what Im doing, to “finish” all functions for my A-Bot for Capitals and Mothership I have to made a function can refill the fighters into squadron if they die

So atm in-game it’s possible do it ONLY from the fighter bay, the fighter bay widow is splitted in 2 section, fighter bay inventory and launch tubes (look the screenshot)

image

I made already the code to drag the fighters from fighter bay inventory to launch tube part, BUT the IUElement I take in consideration like destination is the “Ready” Text

So this is the movement my function do (look the screenshot)

image

Here the problem… the “Ready” pixels are not considerate part of “Tube’s Button” this mean my code drag the fighters from the inventory to “Ready” text and when he release them the tube not load them

So my solution was load the real “Ready” text region in a variable, modify them for position this region a little bit more down so the bot will not drag them on the string pixels (look the screenshot)

image

Here the test code I made:

var squad1_tube = _memoryMeasurement?.WindowInventory.FirstOrDefault().LabelText?.ElementAt(10);
var Squad1 = _memoryMeasurement.ShipUi.SquadronsUI.SetSquadron.FirstOrDefault().Squadron.Health;
squad1_tube = squad1_tube.WithRegion(new Bib3.Geometrik.RectInt(squad1_tube.Region.Min0 - 400, squad1_tube.Region.Min1 - 400, squad1_tube.Region.Max0 - 400, squad1_tube.Region.Max1 - 400));

if (Squad1.SquadronSizeCurrent < Squad1.SquadronSizeMax)
			{
				var fighterToDrag = _memoryMeasurement?.WindowInventory.FirstOrDefault().SelectedRightInventory?.ListView?.Entry.FirstOrDefault()?.SetSprite?.ElementAt(1);
				yield return fighterToDrag.MouseDragAndDropOn(squad1_tube, MouseButtonIdEnum.Left);
			}

Not look the fact I go to decrease “400” from every point, this was just a test…

Now I show you all this in execution:

Original Region Loaded from Memory:

Region Changed by My code and applied to the squad1_tube:

So… to here everything ok… buw then I go to execute:
yield return fighterToDrag.MouseDragAndDropOn(squad1_tube, MouseButtonIdEnum.Left);

the code go to release always on the original region…

Can you help me please?

To let the mouse button release on another region, you can replace the call to MouseDragAndDropOn with a version adjusted to your need.
The function MouseDragAndDropOn is just a shortcut to compile a MotionParam, you don’t need it to model a drag and drop operation.
So let’s look at the definition of MouseDragAndDropOn:
I found it at

That code creates a list of two MotionParamMouseRegion, to model the path for the mouse.

To replace the destination region, create your own MotionParamMouseRegion (Sanderling/src/Sanderling/Sanderling/Motor/Motion.cs at 3e04af29eeacd1bd32ab69cb11adca8ef911c204 · Arcitectus/Sanderling · GitHub) and set its property RegionReplacement to specify the region to move the mouse to.

1 Like

To help people better find this, I moved these posts to a topic with a more suitable title.