API Question HUD_Text

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,538
Reaction score
4,370
Points
203
Location
Dallas, TX
I have a vessel2 vessel that is converted to Vessel3. But this doesn't work anymore. The info is not shown on the HUD. Didn't find anything in the API reference

h:
Code:
    void HUD_Text(const HUDPAINTSPEC* pHPS, HDC hdc);
cpp:
Code:
void xyz::HUD_Text(const HUDPAINTSPEC* pHPS, HDC hdc)

{



    char cbuf[128];
    //  char cbuf2[128];
    int  tx, ty, ty2, yoff, ty3, ty4, ty5;
    //double apd;
    GetTextMetrics(hdc, &tm);
    yoff = tm.tmHeight;
    tx = tm.tmAveCharWidth;
    ty4 = 15 * yoff;
    ty3 = 13 * yoff;
    ty = 15 * yoff;
    ty2 = 11 * yoff;
    ty5 = 12 * yoff;
    //Rectangle (hdc, tx-2, ty-1, tx+120,ty+(yoff*7));
    SetTextColor(hdc, colRed);


    sprintf(cbuf, "PAD A: ");
    TextOut(hdc, (tx), (ty2 + (yoff * 1)) + 3, cbuf, strlen(cbuf));
    if (GetAttachmentStatus(PaD1)){
        oapiGetObjectName(GetAttachmentStatus(PaD1), cbuf, 100);
    }
    else{
        sprintf(cbuf, " -----");
    }

    TextOut(hdc, (tx + 65), (ty2 + (yoff * 1)) + 3, cbuf, strlen(cbuf));
    sprintf(cbuf, "PAD B: ");
    TextOut(hdc, (tx), (ty2 + (yoff * 2)) + 3, cbuf, strlen(cbuf));
    if (GetAttachmentStatus(PaD2)){
        oapiGetObjectName(GetAttachmentStatus(PaD2), cbuf, 100);
    }
    else{
        sprintf(cbuf, " -----");
    }
    TextOut(hdc, (tx + 65), (ty2 + (yoff * 2)) + 3, cbuf, strlen(cbuf));

    sprintf(cbuf, "PAD C: ");
    TextOut(hdc, (tx), (ty2 + (yoff * 3)) + 3, cbuf, strlen(cbuf));

    if (GetAttachmentStatus(PaD3)){
        oapiGetObjectName(GetAttachmentStatus(PaD3), cbuf, 100);
    }
    else{
        sprintf(cbuf, " -----");
    }
    TextOut(hdc, (tx + 65), (ty2 + (yoff * 3)) + 3, cbuf, strlen(cbuf));




}
 
Last edited:
What are you trying to do?

What is the purpose of "HUD_Text ()" and where is it getting called?

What is "HDC" in this context?

Have you even overloaded the standard HUD call back functions?
 
Thanks.
HUD_TEXT writes to the HUD. In this case it displays "PAD A:" and the name of a vessel if attached. Similar to the Moonbase Alpha
 
Vessel3 does not longer use a HDC ("handle to drawing context"), but instead it calls the versions of the drawing call-backs with the Sketchpad parameter. So, you better change the signature there.

All the other functions for rendering are inactive now.
 
Last edited:
Yes. I know but wasn't sure how to carry convert that part for Vessel3.
 
Yes. I know but wasn't sure how to carry convert that part for Vessel3.

Simply replace all GDI drawing functions of windows by their SketchPad equivalents. Its a very repetitive but easy job.
 
Thanks. Is that in the SDK as far as SketchPad function?

I just switched to vessel2. But It might be nice to help others
 
Thanks. Is that in the SDK as far as SketchPad function?

I just switched to vessel2. But It might be nice to help others

Yes, of course. It is no function, sketchpad is what we call a "façade" here. It hides the drawing functions of the Orbiter Client from the spacecraft simulation, so that all spacecraft can use the same OS independent rendering functions.
 
I will take a look. I was able to get the screen prompts for UCGO and UMMU. But not to display to the HUD. change the color,....
 
Back
Top