SDK Question VESSEL3::clbkDrawHUD

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,555
Reaction score
4,378
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'
 
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);
 
Thanks. Yes it is
Code:
	VESSEL3::clbkDrawHUD (mode, hps, skp);
 
Could you post the header with the declarations of your class and its functions?
 
Thanks for the help. I didn't see the Vessel3 part .My was a vessel2. Now a vessel 3:cheers:
 
No duck-typing in C++ :lol:
 
Back
Top