forked from Mirrors/openclonk
+ MouseSelectionAlt: Callback for right-click on C4D_MouseSelect objects
parent
c32852379e
commit
21590e58c3
|
@ -318,8 +318,8 @@ void C4ControlScript::CompileFunc(StdCompiler *pComp)
|
|||
|
||||
// *** C4ControlPlayerSelect
|
||||
|
||||
C4ControlPlayerSelect::C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs)
|
||||
: iPlr(iPlr), iObjCnt(Objs.ObjectCount())
|
||||
C4ControlPlayerSelect::C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt)
|
||||
: iPlr(iPlr), iObjCnt(Objs.ObjectCount()), fIsAlt(fIsAlt)
|
||||
{
|
||||
pObjNrs = new int32_t[iObjCnt];
|
||||
int32_t i = 0;
|
||||
|
@ -344,22 +344,26 @@ void C4ControlPlayerSelect::Execute() const
|
|||
iControlChecksum += pObj->Number * (iControlChecksum+4787821);
|
||||
// user defined object selection: callback to object
|
||||
if (pObj->Category & C4D_MouseSelect)
|
||||
pObj->Call(PSF_MouseSelection, &C4AulParSet(C4VInt(iPlr)));
|
||||
if (fIsAlt)
|
||||
pObj->Call(PSF_MouseSelectionAlt, &C4AulParSet(C4VInt(iPlr)));
|
||||
else
|
||||
pObj->Call(PSF_MouseSelection, &C4AulParSet(C4VInt(iPlr)));
|
||||
// player crew selection (recheck status of pObj)
|
||||
if (pObj->Status && pPlr->ObjectInCrew(pObj))
|
||||
if (pObj->Status && pPlr->ObjectInCrew(pObj) && !fIsAlt)
|
||||
SelectObjs.Add(pObj, C4ObjectList::stNone);
|
||||
}
|
||||
// count
|
||||
pPlr->CountControl(C4Player::PCID_Command, iControlChecksum);
|
||||
|
||||
// any crew to be selected (or complete crew deselection)?
|
||||
if (!SelectObjs.IsClear() || !iObjCnt)
|
||||
if (!fIsAlt) if (!SelectObjs.IsClear() || !iObjCnt)
|
||||
pPlr->SelectCrew(SelectObjs);
|
||||
}
|
||||
|
||||
void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(iPlr, "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(fIsAlt, "IsAlt", false));
|
||||
pComp->Value(mkNamingAdapt(iObjCnt, "ObjCnt", 0));
|
||||
// Compile array
|
||||
if(pComp->isCompiler())
|
||||
|
|
|
@ -156,11 +156,12 @@ class C4ControlPlayerSelect : public C4ControlPacket // sync
|
|||
{
|
||||
public:
|
||||
C4ControlPlayerSelect()
|
||||
: iPlr(-1), iObjCnt(0), pObjNrs(NULL) { }
|
||||
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs);
|
||||
: iPlr(-1), iObjCnt(0), pObjNrs(NULL), fIsAlt(false) { }
|
||||
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt);
|
||||
~C4ControlPlayerSelect() { delete[] pObjNrs; }
|
||||
protected:
|
||||
int32_t iPlr;
|
||||
bool fIsAlt;
|
||||
int32_t iObjCnt;
|
||||
int32_t *pObjNrs;
|
||||
public:
|
||||
|
|
|
@ -136,6 +136,7 @@ void InitFunctionMap(C4AulScriptEngine *pEngine); // add functions to engine
|
|||
#define PSF_CalcBuyValue "~CalcBuyValue" // C4ID idItem, int iDefValue
|
||||
#define PSF_CalcSellValue "~CalcSellValue" // C4Object *pObj, int iObjValue
|
||||
#define PSF_MouseSelection "~MouseSelection" // int iByPlr
|
||||
#define PSF_MouseSelectionAlt "~MouseSelectionAlt" // int iByPlr
|
||||
#define PSF_OnOwnerChanged "~OnOwnerChanged" // iNewOwner, iOldOwner
|
||||
#define PSF_OnJoinCrew "~Recruitment" // int Player
|
||||
#define PSF_OnRemoveCrew "~DeRecruitment" // int Player
|
||||
|
|
|
@ -919,7 +919,7 @@ void C4MouseControl::LeftUpDragNone()
|
|||
// Selection
|
||||
case C4MC_Cursor_Select:
|
||||
// Object selection to control queue
|
||||
if (!IsPassive()) Game.Input.Add(CID_PlrSelect, new C4ControlPlayerSelect(Player,Selection));
|
||||
if (!IsPassive()) Game.Input.Add(CID_PlrSelect, new C4ControlPlayerSelect(Player,Selection,false));
|
||||
break;
|
||||
// Help
|
||||
case C4MC_Cursor_Help:
|
||||
|
@ -991,6 +991,10 @@ void C4MouseControl::RightUpDragNone()
|
|||
if (Cursor==C4MC_Cursor_Region)
|
||||
{ SendControl(DownRegion.RightCom); return; }
|
||||
|
||||
// Alternative object selection
|
||||
if (Cursor==C4MC_Cursor_Select && !IsPassive())
|
||||
{ Game.Input.Add(CID_PlrSelect, new C4ControlPlayerSelect(Player,Selection,true)); }
|
||||
|
||||
// Help: end
|
||||
if (Help)
|
||||
{ Help=false; KeepCaption=0; return; }
|
||||
|
|
Loading…
Reference in New Issue