C++ Question MFD Button Labels for USER MFD's

jimd

New member
Joined
Mar 30, 2009
Messages
25
Reaction score
0
Points
0
I have been an Orbiter fan for a long time and am working very seriously now on my own .dll based ship. I am working specifically on a very wide panel (1920 pixels) and have room for at least 3 or maybe even 4 MFD's while realizing that there may be frame rate problems. I have all the MFD buttons working fine but I cannot get the button labels working in the additional MFD.

I am sure that I must be missing something very simple but I am really stumped on this one. From what I can determine the maximum number of MFD's permitted is actually 10 - left, right and eight additional user defined called USER1 - USER8. However, when I try to setup an additional MFD based on this everything works fine except for the button menus. I don't get any text output anywhere for the additional MFD.

I know the code works because I get the button menus for the left and right MFD's. This code was borrowed from DG with only a few modifications


void Special::RedrawPanel_MFDButton (SURFHANDLE surf, int mfd, int side)
{
HDC hDC = oapiGetDC (surf);
SelectObject (hDC, g_Param.hFont[0]);
SetTextColor (hDC, RGB(196, 196, 196));
SetTextAlign (hDC, TA_CENTER);
SetBkMode (hDC, TRANSPARENT);
const char *label;
int x = 13;
int y = 3;

for (int bt = 0; bt < 6; bt++) {
if (label = oapiMFDButtonLabel (mfd, bt+side*6)) {
TextOut (hDC, x, y, label, strlen (label));
y += 41;
} else break;
}
oapiReleaseDC (surf, hDC);
}

And the associated calling functions


case AID_MFD3_LBUTTONS:
RedrawPanel_MFDButton (surf, MFD_USER1, 0);
return true;
case AID_MFD3_RBUTTONS:
RedrawPanel_MFDButton (surf, MFD_USER1, 1);
return true;

Any ideas? Do I need to do something special for a USER MFD?

Thanks to all in advance.
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
Firstly, welcome to the forum :hello:

The function RedrawPanel_MFDButton looks OK at first glance. Using the Visual Studio debugger, can you confirm that function actually gets called? If so, do you get expected values in "label"?

EDIT: For info on setting up the debugger for the Orbiter environment, see here: http://www.orbiterwiki.org/wiki/Free_Compiler_Setup#Debugging_the_addon
 

MeDiCS

Donator
Donator
Joined
Sep 22, 2008
Messages
602
Reaction score
2
Points
0
Just remember that not everyone's computer is able to display that panel comfortably.
 

jimd

New member
Joined
Mar 30, 2009
Messages
25
Reaction score
0
Points
0
tblaxland,

Thanks for the speedy reply. I have yet to setup the debugger. Is their a way to copy properties from the production setup? I am using VS 2008 Professional Version.

Thanks
 

jimd

New member
Joined
Mar 30, 2009
Messages
25
Reaction score
0
Points
0
I managed to get the debugger actually working - this is going to help a lot as I work on my panels. Thanks to computerex for this extremely helpful bit of information - [nomedia="http://www.youtube.com/watch?v=VBRLkN__YIo"]YouTube- Orbiter: Setting up the development environment[/nomedia]


It appears that there is some kind of problem with the MFD definition because although the MFD button routine is called the code jumps over the TextOut statement and it is never executed.


I set two breakpoints - one at the start of the function and a second at the TextOut. The output from the one at the start of the function is confusing

RedrawPanelMFDButton

void*surf = 0X067140d0
int mfd = 0X00000002
int side = 0X00000000

Anymore input would be appreciated.

PS - to those who have expressed concern about a 1920 pixel panel. My plan is to start with a full panel and then build smaller versions with reduced content like DG4/XR and others have done.

Thanks
 

SiameseCat

Addon Developer
Addon Developer
Joined
Feb 9, 2008
Messages
1,699
Reaction score
1
Points
0
Location
Ontario
What does oapiMFDButtonLabel return? If that's returning NULL, it probably means you're not creating the MFD properly. In that case, it might be helpful if you could post the MFD definition code here.
 

jimd

New member
Joined
Mar 30, 2009
Messages
25
Reaction score
0
Points
0
There does appear to be a problem with OapiMFDButtonLabel with the added MFD - label = 0xcccccccc



Here is the construction of the MFD's -


bool Special::clbkLoadPanel (int id)
{
int xofs, yofs;
ReleaseSurfaces();

HBITMAP hBmp = LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (IDB_PANEL1+id));
MFDSPEC mfds_left = {{ 224, 86, 514, 376}, 6, 6, 47, 41};
MFDSPEC mfds_right = {{1403, 86, 1693, 376}, 6, 6, 47, 41};
MFDSPEC mfds_user1 = {{ 813, 86, 1103, 376}, 6, 6, 47, 41};

switch (id) {
case 0: // main panel
oapiRegisterPanelBackground (hBmp, PANEL_ATTACH_BOTTOM|PANEL_MOVEOUT_BOTTOM, 0xffffff);
oapiSetPanelNeighbours (-1,-1,1,-1);
oapiRegisterMFD (MFD_LEFT, mfds_left);
oapiRegisterMFD (MFD_RIGHT, mfds_right);
oapiRegisterMFD (MFD_USER1, mfds_user1);



xofs = 182; // left MFD
yofs = 25; // left MFD
oapiRegisterPanelArea (AID_MFD1_BBUTTONS, _R( 55+xofs,359+yofs,325+xofs, 377+yofs), PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); // bottom button row
oapiRegisterPanelArea (AID_MFD1_LBUTTONS, _R( xofs,100+yofs, 25+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // left button column
oapiRegisterPanelArea (AID_MFD1_RBUTTONS, _R(353+xofs,100+yofs,378+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // right button column

xofs = 770; // center MFD
yofs = 25; // center MFD
oapiRegisterPanelArea (AID_MFD3_BBUTTONS, _R( 55+xofs,359+yofs,325+xofs, 377+yofs), PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); // bottom button row
oapiRegisterPanelArea (AID_MFD3_LBUTTONS, _R( xofs,100+yofs, 25+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // left button column
oapiRegisterPanelArea (AID_MFD3_RBUTTONS, _R(353+xofs,100+yofs,378+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // right button column

xofs = 1361; // right MFD
yofs = 25; // right MFD
oapiRegisterPanelArea (AID_MFD2_BBUTTONS, _R( 55+xofs,359+yofs,325+xofs, 377+yofs), PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); // bottom button row
oapiRegisterPanelArea (AID_MFD2_LBUTTONS, _R( xofs,100+yofs, 25+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // left button column
oapiRegisterPanelArea (AID_MFD2_RBUTTONS, _R(353+xofs,100+yofs,378+xofs, 323+yofs), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND); // right button column
break;


Any insights would obviously be appreciated.
 

jimd

New member
Joined
Mar 30, 2009
Messages
25
Reaction score
0
Points
0
After some digging I finally figured out what was wrong. Using the debugger I was able to see that the program was not processing the USER1 MFD the same as the RIGHT and LEFT.

I needed to add the additional MFD to the MFD Mode routine

void Special::clbkMFDMode (int mfd, int mode)
{
switch (mfd) {
case MFD_LEFT:
oapiTriggerPanelRedrawArea (0, AID_MFD1_LBUTTONS);
oapiTriggerPanelRedrawArea (0, AID_MFD1_RBUTTONS);
break;
case MFD_RIGHT:
oapiTriggerPanelRedrawArea (0, AID_MFD2_LBUTTONS);
oapiTriggerPanelRedrawArea (0, AID_MFD2_RBUTTONS);
break;
case MFD_USER1:
oapiTriggerPanelRedrawArea (0, AID_MFD3_LBUTTONS);
oapiTriggerPanelRedrawArea (0, AID_MFD3_RBUTTONS);
break;
}
}

I appreciate the input that everyone provided which eventually got me to the solution. I will be making a post shortly describing my vehicle and the progress made to date.
 
Top