SDK Question VESSEL3::clbkDrawHUD

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,718
Reaction score
2,685
Points
203
Location
Dallas, TX
I am trying to add the 3 boxes to show landing gear. This is from the Delta Glider.
Code:
bool DeltaGlider::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
    if (oapiCockpitMode() != COCKPIT_VIRTUAL) return false;

    // draw the default HUD
    VESSEL3::clbkDrawHUD (mode, hps, skp);
    int cx = hps->CX, cy = hps->CY;

    // show gear deployment status
    if (gear_status == DOOR_OPEN || (gear_status >= DOOR_CLOSING && fmod (oapiGetSimTime(), 1.0) < 0.5)) {
        int d = hps->Markersize/2;
        if (cx >= -d*3 && cx < hps->W+d*3 && cy >= d && cy < hps->H+d*5) {
            skp->Rectangle (cx-d/2, cy-d*5, cx+d/2, cy-d*4);
            skp->Rectangle (cx-d*3, cy-d*2, cx-d*2, cy-d);
            skp->Rectangle (cx+d*2, cy-d*2, cx+d*3, cy-d);
        }
    }

But this is what I am using:
Code:
bool MYVESSEL::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
    if(dCargHudMessageDelay>0)
    {
        skp->Text(5,hps->H/60*15,cCargoHudDisplay,strlen(cCargoHudDisplay));
        dCargHudMessageDelay-=oapiGetSimStep();
        if(dCargHudMessageDelay<0)
            dCargHudMessageDelay=0;
    }
    if(dHudMessageDelay>0)
    {
        skp->Text(5,hps->H/60*15,cUmmuHudDisplay,strlen(cUmmuHudDisplay));
        dHudMessageDelay-=oapiGetSimStep();
        if(dHudMessageDelay<0)
            dHudMessageDelay=0;
    }
    return true;
    
    
    
    
    if (oapiCockpitMode() != COCKPIT_VIRTUAL) return false;

    // draw the default HUD
    VESSEL3::clbkDrawHUD (mode, hps, skp);
    int cx = hps->CX, cy = hps->CY;


    // show gear deployment status
    if (GEAR_status == GEAR_DOWN || (GEAR_status >= GEAR_LOWERING && fmod (oapiGetSimTime(), 1.0) < 0.5)) {
        int d = hps->Markersize/2;
        if (cx >= -d*3 && cx < hps->W+d*3 && cy >= d && cy < hps->H+d*5) {
            skp->Rectangle (cx-d/2, cy-d*5, cx+d/2, cy-d*4);
            skp->Rectangle (cx-d*3, cy-d*2, cx-d*2, cy-d);
            skp->Rectangle (cx+d*2, cy-d*2, cx+d*3, cy-d);
        }
    }

}
But I get this error:
.\MYVESSEL.CPP(2034) : error C2352: 'VESSEL3::clbkDrawHUD' : illegal call of non-static member function
c:\orbiter2010p1a\orbitersdk\include\VesselAPI.h(5915) : see declaration of 'VESSEL3::clbkDrawHUD'
 

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
Not what is causing the reported issue, but depending on intent, you can avoid it.
Code:
bool MYVESSEL::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
    if(dCargHudMessageDelay>0)
    {
        skp->Text(5,hps->H/60*15,cCargoHudDisplay,strlen(cCargoHudDisplay));
        dCargHudMessageDelay-=oapiGetSimStep();
        if(dCargHudMessageDelay<0)
            dCargHudMessageDelay=0;
    }
    if(dHudMessageDelay>0)
    {
        skp->Text(5,hps->H/60*15,cUmmuHudDisplay,strlen(cUmmuHudDisplay));
        dHudMessageDelay-=oapiGetSimStep();
        if(dHudMessageDelay<0)
            dHudMessageDelay=0;
    }
    [COLOR="Red"]return true;[/COLOR]
    
    
    
    
    if (oapiCockpitMode() != COCKPIT_VIRTUAL) return false;

    // draw the default HUD
    VESSEL3::clbkDrawHUD (mode, hps, skp);
    int cx = hps->CX, cy = hps->CY;


    // show gear deployment status
    if (GEAR_status == GEAR_DOWN || (GEAR_status >= GEAR_LOWERING && fmod (oapiGetSimTime(), 1.0) < 0.5)) {
        int d = hps->Markersize/2;
        if (cx >= -d*3 && cx < hps->W+d*3 && cy >= d && cy < hps->H+d*5) {
            skp->Rectangle (cx-d/2, cy-d*5, cx+d/2, cy-d*4);
            skp->Rectangle (cx-d*3, cy-d*2, cx-d*2, cy-d);
            skp->Rectangle (cx+d*2, cy-d*2, cx+d*3, cy-d);
        }
    }

}

Your clbkDrawHUD always returns true at the above point, so none of the code is ever executed below. If this is the intent, then you can just remove everything below the return true, avoiding the error.

---------- Post added at 10:47 PM ---------- Previous post was at 10:46 PM ----------

Sorry, of course that isn't your intent. You may just want to remove the return true entirely.

Not sure what is causing it, though. Is the error reported for the following line?
Code:
VESSEL3::clbkDrawHUD (mode, hps, skp);
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,718
Reaction score
2,685
Points
203
Location
Dallas, TX
Thanks. Yes it is
Code:
	VESSEL3::clbkDrawHUD (mode, hps, skp);
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,877
Reaction score
2,131
Points
203
Location
between the planets
Could you post the header with the declarations of your class and its functions?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,718
Reaction score
2,685
Points
203
Location
Dallas, TX
Thanks for the help. I didn't see the Vessel3 part .My was a vessel2. Now a vessel 3:cheers:
 

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 duck-typing in C++ :lol:
 
Top