I have run into an odd issue. The max number of MFD is 12. the front of the shuttle has 9 then 1 aft and 2 CCTV. The aft side one can't be done has that would be 13.
So I have this:
here the 12 mfd are made.
static const int mfdgrp[12] = {
GRP_CDR1_VC, GRP_CDR2_VC, GRP_PLT1_VC, GRP_PLT2_VC,//0,1,2,3
GRP_MFD1_VC, GRP_MFD2_VC, GRP_MFD3_VC, GRP_MFD4_VC, GRP_MFD5_VC,//4,5,6,7,8
GRP_MFD_AFT_VC, GRP_CCTV1_VC,GRP_CCTV2_VC //9,10?,11
};...
if (ok) {
// register the HUDs (synced)
oapiVCRegisterHUD(&huds);
// register all MFD displays
for (int i = 0; i < 12; i++) {
mfds.ngroup = mfdgrp[i];
oapiRegisterMFD(MFD_LEFT + i, &mfds);
}
// update panel R13L
plop->UpdateVC();
}
return ok;
}
And here is where the mfd buttons get clicked. I have debug string to show which mfd is clicked. 0-8 are the front 9 the aft. but it shows 11 and 12 for the 2cctv not 10?
bool Atlantis::clbkVCMouseEvent(int id, int event, VECTOR3& p)
{
static bool counting = false;
static double t0 = 0.0;
switch (id) {
// handle MFD selection buttons
case AID_CDR1_BUTTONS:
case AID_CDR2_BUTTONS:
case AID_PLT1_BUTTONS:
case AID_PLT2_BUTTONS:
case AID_MFD1_BUTTONS:
case AID_MFD2_BUTTONS:
case AID_MFD3_BUTTONS:
case AID_MFD4_BUTTONS:
case AID_MFD5_BUTTONS:
case AID_MFDA_BUTTONS:
{
int mfd = id - AID_CDR1_BUTTONS + MFD_LEFT;
sprintf(oapiDebugString(), "%d ", mfd);
int bt = (int)(p.x * 5.99);
// sprintf(oapiDebugString(), "Mouse position: X %f Y %f Z %f bt%d", p.x, p.y, p.z, bt);
// oapiWriteLogV("Mouse position: X %f Y %f Z %f bt%d", p.x, p.y, p.z, bt);
if (bt < 5) oapiProcessMFDButton(mfd, bt, event);
else {
if (event & PANEL_MOUSE_LBDOWN) {
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting) {
oapiSendMFDKey(mfd, OAPI_KEY_F2);
counting = false;
}
else if ((event & PANEL_MOUSE_LBPRESSED) && counting && (oapiGetSysTime() - t0 >= 1.0)) {
oapiSendMFDKey(mfd, OAPI_KEY_F1);
counting = false;
}
}
} return true;
case AID_CCTV1_BUTTONS:
case AID_CCTV2_BUTTONS:
{
int mfd = id - AID_CDR1_BUTTONS + MFD_LEFT;
sprintf(oapiDebugString(), "%d ", mfd);
int bt = (int)(p.x * 5.99);
bt = (bt - 5) * -1;
// sprintf(oapiDebugString(), "Mouse position: X %f Y %f Z %f bt%d", p.x, p.y, p.z, bt);
// oapiWriteLogV("Mouse positionside: X %f Y %f Z %f bt%d", p.x, p.y, p.z, bt);
if (bt < 5) oapiProcessMFDButton(mfd, bt, event);
else {
if (event & PANEL_MOUSE_LBDOWN) {
t0 = oapiGetSysTime();
counting = true;
}
else if ((event & PANEL_MOUSE_LBUP) && counting) {
oapiSendMFDKey(mfd, OAPI_KEY_F2);
counting = false;
}
else if ((event & PANEL_MOUSE_LBPRESSED) && counting && (oapiGetSysTime() - t0 >= 1.0)) {
oapiSendMFDKey(mfd, OAPI_KEY_F1);
counting = false;
}
}
} return true;