General Question simple vc help

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Thanks
Code:
void ClassicMfd::DefineMfds()
{
	DefineMfd(PILOT_MFD_LEFT, GRP_TALON_VCNEW_PILOT_MFD_LEFT_SCREEN);
	DefineMfd(PILOT_MFD_CENTER, GRP_TALON_VCNEW_PILOT_MFD_CENTER_SCREEN);
//	DefineMfd(PILOT_MFD_CENTER, GRP_TALON_VCNEW_PILOT_MFD_CENTER_SCREEN);
	

}
this?
Code:
#define PILOT_MFD_LEFT (MFD_LEFT)
//#define PILOT_MFD_RIGHT (MFD_RIGHT)
#define PILOT_MFD_CENTER (MFD_RIGHT)
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Code:
#define PILOT_MFD_LEFT (MFD_LEFT)
//#define PILOT_MFD_RIGHT (MFD_RIGHT)
#define PILOT_MFD_CENTER (MFD_RIGHT)


That can't be the only definition - according to this you should get a compiler error when using PILOT_MFD_RIGHT.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Well this was for only 2 mfd. I can go back to 3 and send what I have

---------- Post added at 05:10 PM ---------- Previous post was at 05:08 AM ----------

OK So I went back to 3 mfd. If I go with original code:
Code:
	RECT const draw_area = _R(0, 0, buttonFnRect[mfd].right - buttonFnRect[mfd].left, buttonFnRect[mfd].bottom - buttonFnRect[mfd].top);

all labels work
but the center upper mfd buttons don't function. Whats odd is look at the Select screen one the right is different than the center.
C5U09AX.jpg

Code:
#define PILOT_MFD_LEFT (MFD_LEFT)
#define PILOT_MFD_RIGHT (MFD_USER1)
#define PILOT_MFD_CENTER (MFD_RIGHT)

Code:
#pragma once

#define AID_FIRST_ID 0

#define AID_PILOT_MFD_LEFT_BTNS_FN 1
#define AID_PILOT_MFD_LEFT_BTNS_SYS 2
#define AID_PILOT_MFD_CENTER_BTNS_FN 3
#define AID_PILOT_MFD_CENTER_BTNS_SYS 4
#define AID_PILOT_MFD_RIGHT_BTNS_FN 5
#define AID_PILOT_MFD_RIGHT_BTNS_SYS 6
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Whats odd is look at the Select screen one the right is different than the center.

Makes absolutely sense to me. The USER1 MFD is neither left or right MFD to Orbiter, so it can't have a left shift or right shift keybinding. Orbiter is smart enough to notice it.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Oh. Then I guess I need to see why the center SYS button are not working. Or it is not detecting.
I guess the debugger is in order?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Oh. Then I guess I need to see why the center SYS button are not working. Or it is not detecting.
I guess the debugger is in order?

Debugger should do what you tell him to do.

You could place a breakpoint at the beginning of ProcessMfdSysButton and look at the value of p. Or a breakpoint at each oapi calls in this function.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
did this:
QFiXD4f.jpg


I place a break on the mfd right and left and it broke but not on the Center

Code:
bool ClassicMfd::HandleMouseEvent(int const aid, int const event, VECTOR3 const &p)
{
	switch (aid) {
	case AID_PILOT_MFD_LEFT_BTNS_FN:
		return ProcessMfdFnButton(PILOT_MFD_LEFT, event, p);
	case AID_PILOT_MFD_LEFT_BTNS_SYS:
		return ProcessMfdSysButton(PILOT_MFD_LEFT, event, p);

	case AID_PILOT_MFD_CENTER_BTNS_FN:
		return ProcessMfdFnButton(PILOT_MFD_CENTER, event, p);
	case AID_PILOT_MFD_CENTER_BTNS_SYS:
		return ProcessMfdSysButton(PILOT_MFD_CENTER, event, p);

	case AID_PILOT_MFD_RIGHT_BTNS_FN:
		return ProcessMfdFnButton(PILOT_MFD_RIGHT, event, p);
	case AID_PILOT_MFD_RIGHT_BTNS_SYS:
		return ProcessMfdSysButton(PILOT_MFD_RIGHT, event, p);

	

	}

	return false;
}

bool ClassicMfd::ProcessMfdFnButton(int const mfd, int const event, VECTOR3 const &p)
{
	if (p.x > 0.07 && p.x < 0.93) return false;
	int index = (int)(p.y * 11);
	if (index == 0 || index / 2 != (index - 1) / 2) {
		index /= 2;
		if (p.x > 0.5) index += 6;
		oapiProcessMFDButton(mfd, index, event);
		return true;
	}

	return false;
}
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
And this means? ;)

How does the function "void ClassicMfd::DefineMfdsButtons()" look like in your case?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
center-sys
- p {data=0x00a7fe18 {0.029262820458040295, 0.54513952071380345, 0.00000000000000000} x=0.029262820458040295 ...} const VECTOR3 &

right fn:- p {data=0x00a7fe18 {0.041359094658296347, 0.95806050273387910, 0.00000000000000000} x=0.041359094658296347 ...} const VECTOR3 &


I guess the P is the mouse position?

I set a break at the start of the :
bool ClassicMfd::HandleMouseEvent(int const aid, int const event, VECTOR3 const &p)
{
switch (aid) {

and no break on the Center FN area.

Code:
void ClassicMfd::DefineMfdsButtons()
{
	// Pilot Left
	DefineMfdButtons(
		TEX_TALON_VCNEW_MFD_DYNAMIC_05,
		AID_PILOT_MFD_LEFT_BTNS_FN, GRP_TALON_VCNEW_PILOT_MFD_LEFT_BTNS_FN, buttonFnRect[PILOT_MFD_LEFT],
		AID_PILOT_MFD_LEFT_BTNS_SYS, GRP_TALON_VCNEW_PILOT_MFD_LEFT_BTNS_SYS
		);

	// Pilot Right
	DefineMfdButtons(
		TEX_TALON_VCNEW_MFD_DYNAMIC_05,
		AID_PILOT_MFD_CENTER_BTNS_FN, GRP_TALON_VCNEW_PILOT_CENTER_MFD_BTNS_FN, buttonFnRect[PILOT_MFD_CENTER],
		AID_PILOT_MFD_CENTER_BTNS_SYS, GRP_TALON_VCNEW_PILOT_CENTER_MFD_BTNS_SYS
		);

	DefineMfdButtons(
		TEX_TALON_VCNEW_MFD_DYNAMIC_05,
		AID_PILOT_MFD_RIGHT_BTNS_FN, GRP_TALON_VCNEW_PILOT_MFD_RIGHT_BTNS_FN, buttonFnRect[PILOT_MFD_RIGHT],
		AID_PILOT_MFD_RIGHT_BTNS_SYS, GRP_TALON_VCNEW_PILOT_MFD_RIGHT_BTNS_SYS
		);

void ClassicMfd::DefineMfdButtons(
	UINT const texId,
	UINT const fuctionAreaId, UINT const functionGroupId, RECT const functionRect,
	UINT const sysAreaId, UINT const sysGroupId
	)
{
	SURFHANDLE const texDyn = oapiGetTextureHandle(meshhg_VC, texId);
	oapiVCRegisterArea(fuctionAreaId, functionRect, PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_NONE, texDyn);
	DefineStaticClickArea(oapiMeshGroup(meshhg_VC, functionGroupId), fuctionAreaId, true);

	oapiVCRegisterArea(sysAreaId, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
	DefineStaticClickArea(oapiMeshGroup(meshhg_VC, sysGroupId), sysAreaId, true);
}
}


Code:
bool ClassicMfd::ProcessMfdFnButton(int const mfd, int const event, VECTOR3 const &p)
{
	if (p.x > 0.07 && p.x < 0.93) return false;
	int index = (int)(p.y * 11);
	if (index == 0 || index / 2 != (index - 1) / 2) {
		index /= 2;
		if (p.x > 0.5) index += 6;
		oapiProcessMFDButton(mfd, index, event);
		return true;
	}

	return false;
}
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
So, in both cases, the p.x coordinate meant the event was not supposed to be handled.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Odd. Yes i see the range of p.x is supposed to be
Code:
(p.x > 0.07 && p.x < 0.93)

But then why did it work for the right sys and FN and center sys?

Not sure if I can place a break somewhere to see what the p.x value is?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Oh. I could see where if the p.x is not >.07 and <.93 then return false.

Then I need to figure why it is not showing any mouse click in that area. From the left side I can click on the right and center SYS and right Fn. So it isn't a distance thing.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
The code looks like the entire surface of the MFD is covered by an active area, and the check for the p.x value then just cuts away clicks on the display area, to leave only clicks on the buttons at the left and right edges. Is that correct?

Did you write the code yourself, or copy-paste it from somewhere else? Either way, do you understand how it is supposed to work? Debugging should allow you to pinpoint the problem, but only if you know how it is supposed to work.

For example, are you sure that the large active area for the function buttons isn't also covering the system buttons and masking them?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
The code looks like the entire surface of the MFD is covered by an active area, and the check for the p.x value then just cuts away clicks on the display area, to leave only clicks on the buttons at the left and right edges. Is that correct?
I believe so.
Did you write the code yourself, or copy-paste it from somewhere else? Either way, do you understand how it is supposed to work? Debugging should allow you to pinpoint the problem, but only if you know how it is supposed to work.

Lisias original wrote this code for the Interstellar ships.

From looking at the code. The FN buttons area is defined by the texture mapped.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
No it's not. Urwumpe is right most of the time ;) but not here. Think for yourself before agreeing :cheers:

Argh, damn, thats what you get for quickly answering before getting to the next appointment. :lol: The "return false" went missing somewhere. One more for "goto should be considered harmful".
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
I am confused.
Code:
if (p.x > 0.07 && p.x < 0.93) return false;
so if the mouse is detected and p.x is >.07 and p.x < .93 return false
for the center mfd sys I get x=0.029262820458040295 so it is good.

I need to figure why I get no break at all when I press the mouse in the center FN area.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
How does the function for the Sys buttons look like?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,708
Reaction score
2,683
Points
203
Location
Dallas, TX
Code:
bool ClassicMfd::ProcessMfdSysButton(int const mfd, int const event, VECTOR3 const &p)
{
	if (event & PANEL_MOUSE_LBDOWN) {
		if (p.x < 0.1) {
			oapiToggleMFD_on(mfd);
			return true;
		}
		else if (p.x > 0.9) {
			oapiSendMFDKey(mfd, OAPI_KEY_GRAVE);
			return true;
		}
		else if (p.x > 0.8) {
			oapiSendMFDKey(mfd, OAPI_KEY_F1);
			return true;
		}
	}

	return false;
}
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
OK, and did you place a breakpoint there? at the first if to check?
 
Top