bool ElevatorTrim::RedrawVC (DEVMESHHANDLE hMesh, SURFHANDLE surf) { double level = vessel->GetControlSurfaceLevel (AIRCTRL_ELEVATORTRIM); UINT pos = (UINT)((1.0+level)*23.0); if (pos != elevtrimpos) { int w = (oapiCockpitMode() == COCKPIT_VIRTUAL ? 2:15); oapiColourFill (surf, 0); oapiColourFill (surf, oapiGetColour (210,210,210), 1, pos, w, 6); elevtrimpos = pos; return true; } else return false; }
void BltStr (SURFHANDLE tgt, SURFHANDLE src, int x, int y, const char *newstr, char *oldstr, DWORD style) { if (newstr && oldstr && !strcmp (newstr, oldstr)) return; // nothing to do int w; bool align_right = ((style & ALIGN_RIGHT) > 0); if (oldstr) { // erase the old string w = 0; for (char *c = oldstr; *c; c++) w += small_font_width[*c]; if (w) oapiColourFill (tgt, 0, (align_right ? x-w:x), y, w, small_font_height); } if (newstr) { // write new string if (align_right) for (const char *c = newstr; *c; c++) x -= small_font_width[*c]; for (const char *c = newstr; *c; c++) { w = small_font_width[*c]; oapiBlt (tgt, src, x, y, small_font_xpos[*c], small_font_ypos[*c <= 90 ? 0:1], w, small_font_height); x += w; } } strcpy (oldstr, newstr); }
void ADICtrl::UpdateDisplay (SURFHANDLE surf, bool force) { static const int frm_tx_y0 = 53; static const int frm_tx_dy = 7; static const int frm_tx_x0[6] = {0, 404, 44, 17, 75, 98}; static const int frm_tx_dx[6] = {16, 16, 30, 26, 22, 23}; static const int nav_tx_x0[6] = {381, 122, 335, 231, 163, 141}; static const int nav_tx_dx[6] = {22, 17, 21, 36, 36, 20}; static const int tgt_tx_y0 = 46; static const int tgt_tx_x0[4] = {293, 315, 338, 371}; static const int tgt_tx_dx[4] = {22, 22, 33, 31}; static const int frm_bb_x0 = dsp_x0+22; static const int frm_bb_y0 = dsp_y0+ 1; static const int tgt_bb_x0 = dsp_x0+22; static const int tgt_bb_y0 = dsp_y0+25; VECTOR3 ofs; OBJHANDLE hRef = 0; NAVHANDLE hNav = 0; int i, len, c, mode, tgtmode, x0, dx; mode = sh->GetAttref()->GetMode(); tgtmode = sh->GetAttref()->GetTgtmode(); if (mode == 4) { DWORD navid = sh->GetAttref()->GetNavid(); hNav = sh->GetNavSource (navid); if (navid) mode = 5; } else if (mode >= 1 && mode <= 3) { if (mode == 3) hRef = sh->GetSurfaceRef(); else hRef = sh->GetGravityRef(); } if (mode != dispprm.frmmode || hRef != dispprm.frmref || (mode >= 4 && hNav != dispprm.navref)) { dispprm.frmmode = mode; dispprm.frmref = hRef; dispprm.navref = hNav; x0 = frm_bb_x0; dx = frm_tx_dx[mode]; oapiColourFill (surf, 0, x0, frm_bb_y0, dsp_x0+148-x0, frm_tx_dy); oapiBlt (surf, surf, x0, frm_bb_y0, frm_tx_x0[mode], frm_tx_y0, dx, frm_tx_dy); x0 += dx; if ((mode >= 1 && mode <= 3) && hRef) { char cbuf[256]; oapiGetObjectName (hRef, cbuf, 256); len = strlen(cbuf); x0 += 4; for (i = 0; i < len; i++) { c = toupper (cbuf[i]); dx = small_font_width[c]; oapiBlt (surf, surf, x0, frm_bb_y0, small_font_xpos[c], small_font_ypos[0], dx, frm_tx_dy); x0 += dx; } } if (mode >= 4) { x0 += 4; if ((i = (hNav ? oapiGetNavType (hNav) : 0)) < 6) { dx = nav_tx_dx[i]; oapiBlt (surf, surf, x0, frm_bb_y0, nav_tx_x0[i], frm_tx_y0, dx, frm_tx_dy); x0 += dx; } } } ofs = sh->GetAttref()->GetEulerOffset(); DispAngle (surf, ofs.x, 30, 8, dispprm.frmofs[0]); DispAngle (surf, ofs.y, 58, 8, dispprm.frmofs[1]); DispAngle (surf, ofs.z, 86, 8, dispprm.frmofs[2]); ofs = sh->GetAttref()->GetTgtOffset(); DispAngle (surf, ofs.y, 58, 32, dispprm.tgtofs[0]); DispAngle (surf, ofs.z, 86, 32, dispprm.tgtofs[1]); ofs = sh->GetAttref()->GetEulerAngles (); DispAngle (surf, ofs.x, 30, 15, dispprm.frmdev[0]); DispAngle (surf, ofs.y, 58, 15, dispprm.frmdev[1]); DispAngle (surf, ofs.z, 86, 15, dispprm.frmdev[2]); if (!sh->GetAttref()->GetTgtEulerAngles (ofs)) { tgtmode = 0; ofs = _V(0,0,0); } DispAngle (surf, ofs.y, 58, 39, dispprm.tgtdev[0]); DispAngle (surf, ofs.z, 86, 39, dispprm.tgtdev[1]); if (tgtmode != dispprm.tgtmode) { dispprm.tgtmode = tgtmode; x0 = frm_bb_x0; oapiColourFill (surf, 0, x0, tgt_bb_y0, dsp_x0+148-x0, frm_tx_dy); if (tgtmode >= 0 && tgtmode < 4) { dx = tgt_tx_dx[tgtmode]; oapiBlt (surf, surf, x0, tgt_bb_y0, tgt_tx_x0[tgtmode], tgt_tx_y0, dx, frm_tx_dy); x0 += dx; } } }