forked from Mirrors/openclonk
Add drag_finished parameter to EditCursorMoved callback
parent
4a31ce0fd8
commit
6793455119
|
@ -1220,9 +1220,9 @@ void C4ControlJoinPlayer::CompileFunc(StdCompiler *pComp)
|
|||
// *** C4ControlEMMoveObject
|
||||
|
||||
C4ControlEMMoveObject::C4ControlEMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj,
|
||||
int32_t iObjectNum, int32_t *pObjects, const char *szScript)
|
||||
int32_t iObjectNum, int32_t *pObjects, const char *szScript, bool drag_finished)
|
||||
: eAction(eAction), tx(tx), ty(ty), iTargetObj(pTargetObj ? pTargetObj->Number : 0),
|
||||
iObjectNum(iObjectNum), pObjects(pObjects), StringParam(szScript, true)
|
||||
iObjectNum(iObjectNum), pObjects(pObjects), StringParam(szScript, true), drag_finished(drag_finished)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ void C4ControlEMMoveObject::MoveObject(C4Object *moved_object, bool move_forced)
|
|||
moved_object->ForcePosition(moved_object->fix_x + tx, moved_object->fix_y + ty);
|
||||
moved_object->xdir = moved_object->ydir = 0;
|
||||
moved_object->Mobile = false;
|
||||
C4AulParSet pars(C4VInt(old_x), C4VInt(old_y));
|
||||
C4AulParSet pars(C4VInt(old_x), C4VInt(old_y), C4VBool(drag_finished));
|
||||
if (moved_object->Call(PSF_EditCursorMoved, &pars))
|
||||
{
|
||||
::Console.EditCursor.InvalidateSelection();
|
||||
|
|
|
@ -460,9 +460,9 @@ enum C4ControlEMObjectAction
|
|||
class C4ControlEMMoveObject : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlEMMoveObject() : eAction(EMMO_Move), tx(Fix0), ty(Fix0), iTargetObj(0), iObjectNum(0), pObjects(nullptr) { }
|
||||
C4ControlEMMoveObject() : eAction(EMMO_Move), tx(Fix0), ty(Fix0), iTargetObj(0), iObjectNum(0), pObjects(nullptr), drag_finished(false) { }
|
||||
C4ControlEMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj,
|
||||
int32_t iObjectNum = 0, int32_t *pObjects = nullptr, const char *szScript = nullptr);
|
||||
int32_t iObjectNum = 0, int32_t *pObjects = nullptr, const char *szScript = nullptr, bool drag_finished = false);
|
||||
static C4ControlEMMoveObject *CreateObject(const C4ID &id, C4Real x, C4Real y, C4Object *container);
|
||||
~C4ControlEMMoveObject();
|
||||
protected:
|
||||
|
@ -472,6 +472,7 @@ protected:
|
|||
int32_t iObjectNum; // number of objects moved
|
||||
int32_t *pObjects; // pointer on array of objects moved
|
||||
StdStrBuf StringParam; // script to execute, or ID of object to create
|
||||
bool drag_finished; // Movement only: Set when mouse drag operation concluded (i.e. mouse up)
|
||||
private:
|
||||
void MoveObject(C4Object *moved_object, bool move_forced) const;
|
||||
public:
|
||||
|
|
|
@ -148,7 +148,7 @@ void C4EditCursor::Execute()
|
|||
case C4CNS_ModeEdit:
|
||||
// Hold selection
|
||||
if (Hold)
|
||||
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, Fix0, Fix0, nullptr, &selection);
|
||||
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, Fix0, Fix0, nullptr, &selection, false);
|
||||
break;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4CNS_ModeDraw:
|
||||
|
@ -249,7 +249,7 @@ bool C4EditCursor::Move(float iX, float iY, float iZoom, DWORD dwKeyState)
|
|||
// Hold
|
||||
if (!DragFrame && Hold && !DragShape && !DragTransform)
|
||||
{
|
||||
MoveSelection(ftofix(xoff),ftofix(yoff));
|
||||
MoveSelection(ftofix(xoff),ftofix(yoff), false);
|
||||
UpdateDropTarget(dwKeyState);
|
||||
}
|
||||
// Update target
|
||||
|
@ -488,6 +488,11 @@ bool C4EditCursor::LeftButtonUp(DWORD dwKeyState)
|
|||
{
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4CNS_ModeEdit:
|
||||
// Finish object drag
|
||||
if (!DragFrame && Hold && !DragShape && !DragTransform)
|
||||
{
|
||||
MoveSelection(Fix0, Fix0, true);
|
||||
}
|
||||
if (DragFrame) FrameSelection();
|
||||
if (DropTarget) PutContents();
|
||||
break;
|
||||
|
@ -934,9 +939,9 @@ void C4EditCursor::DrawSelectMark(C4Facet &cgo, FLOAT_RECT frame, float width, u
|
|||
}
|
||||
|
||||
|
||||
void C4EditCursor::MoveSelection(C4Real XOff, C4Real YOff)
|
||||
void C4EditCursor::MoveSelection(C4Real XOff, C4Real YOff, bool drag_finished)
|
||||
{
|
||||
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, XOff, YOff, nullptr, &selection);
|
||||
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, XOff, YOff, nullptr, &selection, nullptr, drag_finished);
|
||||
}
|
||||
|
||||
void C4EditCursor::FrameSelection()
|
||||
|
@ -1361,7 +1366,7 @@ void C4EditCursor::ApplyToolPicker()
|
|||
Hold=false;
|
||||
}
|
||||
|
||||
void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs, const char *szScript)
|
||||
void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs, const char *szScript, bool drag_finished)
|
||||
{
|
||||
// construct object list
|
||||
int32_t iObjCnt = 0; int32_t *pObjIDs = nullptr;
|
||||
|
@ -1382,7 +1387,7 @@ void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Re
|
|||
}
|
||||
|
||||
// execute control
|
||||
EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript));
|
||||
EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript, drag_finished));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -130,8 +130,8 @@ protected:
|
|||
void DrawSelectMark(C4Facet &cgo, FLOAT_RECT r, float width, uint32_t color = 0xffffffff);
|
||||
bool HasTransformMarker(float *x, float *y, float zoom) const;
|
||||
void FrameSelection();
|
||||
void MoveSelection(C4Real iXOff, C4Real iYOff);
|
||||
void EMMoveObject(enum C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs = nullptr, const char *szScript = nullptr);
|
||||
void MoveSelection(C4Real iXOff, C4Real iYOff, bool drag_finished);
|
||||
void EMMoveObject(enum C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs = nullptr, const char *szScript = nullptr, bool drag_finished = false);
|
||||
void DoContextObjCommand(C4Object *, const char *cmd);
|
||||
void ObjselectDelItems();
|
||||
|
||||
|
|
Loading…
Reference in New Issue