void MapWindow::DrawWaypointsNew(HDC hdc, const RECT rc) { unsigned int i; int bestwp=-1; TCHAR Buffer[LKSIZEBUFFER]; TCHAR Buffer2[LKSIZEBUFFER]; TCHAR sAltUnit[LKSIZEBUFFERUNIT]; TextInBoxMode_t TextDisplayMode = {0}; static int resizer[10]={ 20,20,20,3,5,8,10,12,0 }; // if pan mode, show full names int pDisplayTextType = DisplayTextType; if (!WayPointList) return; _tcscpy(sAltUnit, Units::GetAltitudeName()); MapWaypointLabelListCount = 0; int arrivalcutoff=0, foundairport=0; bool isairport; bool islandpoint; // setting decluttericons will not paint outlanding, and use minrunway to declutter even more bool decluttericons=false; // inrange : max scale allowed to print non-landable waypoints bool inrange=true; // minimal size of a runway to paint it while decluttering int minrunway=0; // // RealScale // // 2km 1.42 // 3.5km 2.5 // 5km 3.57 // 7.5km 5.35 // 10km 7.14 // 15km 10.71 // 20km 14.28 // 25km 17.85 // 40km 28.57 // 50km 35.71 // 75km 53.57 switch(DeclutterMode) { case dmDisabled: //inrange=(MapWindow::zoom.RealScale() <=18 ? true:false); // 17.85, 25km scale inrange=(MapWindow::zoom.RealScale() <=15 ? true:false); // 14.28, 20km scale decluttericons=false; break; case dmLow: inrange=(MapWindow::zoom.RealScale() <=11 ? true:false); // 10.71, 15km scale decluttericons=(MapWindow::zoom.RealScale() >=14 ? true : false); minrunway=200; break; case dmMedium: inrange=(MapWindow::zoom.RealScale() <=10 ? true:false); decluttericons=(MapWindow::zoom.RealScale() >=10 ? true : false); minrunway=400; break; case dmHigh: inrange=(MapWindow::zoom.RealScale() <=10 ? true:false); decluttericons=(MapWindow::zoom.RealScale() >=10 ? true : false); minrunway=800; break; case dmVeryHigh: inrange=(MapWindow::zoom.RealScale() <=10 ? true:false); decluttericons=(MapWindow::zoom.RealScale() >=10 ? true : false); minrunway=1600; break; default: LKASSERT(0); break; } if (MapWindow::zoom.RealScale() <=20) for(i=0;i<NumberOfWayPoints;i++) { if (WayPointList[i].Visible != TRUE ) continue; // false may not be FALSE? if (WayPointCalc[i].IsAirport) { if (WayPointList[i].Reachable == FALSE) { SelectObject(hDCTemp,hBmpAirportUnReachable); } else { SelectObject(hDCTemp,hBmpAirportReachable); if ( arrivalcutoff < (int)(WayPointList[i].AltArivalAGL)) { arrivalcutoff = (int)(WayPointList[i].AltArivalAGL); bestwp=i; foundairport++; } } } else { if ( WayPointCalc[i].IsOutlanding ) { // outlanding if (WayPointList[i].Reachable == FALSE) SelectObject(hDCTemp,hBmpFieldUnReachable); else { SelectObject(hDCTemp,hBmpFieldReachable); // get the outlanding as bestwp only if no other choice if (foundairport == 0) { // do not set arrivalcutoff: any next reachable airport is better than an outlanding if ( arrivalcutoff < (int)(WayPointList[i].AltArivalAGL)) bestwp=i; } } } else continue; // do not draw icons for normal turnpoints here } if(Appearance.IndLandable == wpLandableDefault) { double fScaleFact =MapWindow::zoom.RealScale(); if(fScaleFact < 0.1) fScaleFact = 0.1; // prevent division by zero fScaleFact = zoom.DrawScale(); if(fScaleFact > 20000.0) fScaleFact = 20000.0; // limit to prevent huge airfiel symbols if(fScaleFact < 1600) fScaleFact = 1600; // limit to prevent tiny airfiel symbols if (decluttericons) { if (WayPointCalc[i].IsAirport && (WayPointList[i].RunwayLen>minrunway || WayPointList[i].RunwayLen==0)) { DrawRunway(hdc,&WayPointList[i],rc, fScaleFact); } } else DrawRunway(hdc,&WayPointList[i],rc, fScaleFact); } else { DrawBitmapX(hdc, WayPointList[i].Screen.x-10, WayPointList[i].Screen.y-10, 20,20, hDCTemp,0,0,SRCPAINT,false); DrawBitmapX(hdc, WayPointList[i].Screen.x-10, WayPointList[i].Screen.y-10, 20,20, hDCTemp,20,0,SRCAND,false); } } // for all waypoints if (foundairport==0 && bestwp>=0) arrivalcutoff = (int)WayPointList[bestwp].AltArivalAGL; for(i=0;i<NumberOfWayPoints;i++) { if(WayPointList[i].Visible ) { bool irange = false; bool intask = false; bool islandable; // isairport+islandpoint bool excluded=false; bool dowrite; intask = WaypointInTask(i); dowrite = intask; // initially set only for intask memset((void*)&TextDisplayMode, 0, sizeof(TextDisplayMode)); // airports are also landpoints. should be better handled isairport=((WayPointList[i].Flags & AIRPORT) == AIRPORT); islandpoint=((WayPointList[i].Flags & LANDPOINT) == LANDPOINT); islandable=WayPointCalc[i].IsLandable; // always in range if MapScale <=10 irange = inrange; if(MapWindow::zoom.RealScale() > 20) { SelectObject(hDCTemp,hInvSmall); irange=false; goto NiklausWirth; // with compliments } if (decluttericons) { if (! (WayPointCalc[i].IsAirport && (WayPointList[i].RunwayLen>minrunway || WayPointList[i].RunwayLen==0))) { SelectObject(hDCTemp,hInvSmall); irange=false; goto NiklausWirth; } } if( islandable ) { if(WayPointList[i].Reachable){ TextDisplayMode.Reachable = 1; if ( isairport ) SelectObject(hDCTemp,hBmpAirportReachable); else SelectObject(hDCTemp,hBmpFieldReachable); if ((GetMultimap_Labels()<MAPLABELS_ALLOFF)||intask) { dowrite = true; // exclude outlandings worst than visible airports, only when there are visible reachable airports! if ( isairport==false && islandpoint==true ) { if ( (int)WayPointList[i].AltArivalAGL >=2000 ) { // more filter excluded=true; } else { if ( (bestwp>=0) && (i==(unsigned)bestwp) && (foundairport==0) ) { // this outlanding is the best option isairport=true; islandpoint=false; // make it an airport TODO paint it as best } else { if ( foundairport >0 ) { if ( (int)WayPointList[i].AltArivalAGL <= arrivalcutoff ) { excluded=true; } } } } } else // do not display airport arrival if close to the best so far. // ex: best arrival is 1200m, include onlye below 1200/4 (prevent division by zero) // This way we only display far points, and skip closer points // WE NEED MORE INFO ABOUT LANDING POINTS: THE .CUP FORMAT WILL LET US KNOW WHAT IS // BEST TO SHOW AND WHAT IS NOT. Winpilot format is useless here. { dowrite=true;// TEST FIX not necessary probably // it's an airport if ( (bestwp>=0) && (i != (unsigned)bestwp) && (arrivalcutoff>600) ) { if ( (arrivalcutoff / ((int)WayPointList[i].AltArivalAGL+1))<4 ) { excluded=true; } } } } } else // landable waypoint is unreachable { dowrite=true; if ( isairport ) { SelectObject(hDCTemp,hBmpAirportUnReachable); } else { SelectObject(hDCTemp,hBmpFieldUnReachable); } } } else { // waypoint is an ordinary turnpoint if(MapWindow::zoom.RealScale() > 4) { if (BlackScreen) SelectObject(hDCTemp,hInvSmall); else SelectObject(hDCTemp,hSmall); } else { if (BlackScreen) SelectObject(hDCTemp,hInvTurnPoint); else SelectObject(hDCTemp,hTurnPoint); } } // end landable-not landable NiklausWirth: if (intask || (OutlinedTp==(OutlinedTp_t)otAll) ) { TextDisplayMode.WhiteBold = 1; TextDisplayMode.Color=RGB_WHITE; } // No matter of how we thought to draw it, let it up to the user.. switch(NewMapDeclutter) { case 0: excluded=false; // no decluttering: show all airports and outlandings break; case 1: if ( isairport ) excluded=false; // show all airports, declutter outlandings break; default: break; // else work normally } // here come both turnpoints and landables.. if( intask || irange || dowrite) { // irange always set when MapScale <=10 bool draw_alt = TextDisplayMode.Reachable && ((GetMultimap_Labels()<MAPLABELS_ONLYTOPO) || intask); // 100711 reachable landing point! if (excluded==true) draw_alt=false; // exclude close outlandings switch(pDisplayTextType) { case DISPLAYNAME: case DISPLAYFIRSTTHREE: case DISPLAYFIRSTFIVE: case DISPLAYFIRST8: case DISPLAYFIRST10: case DISPLAYFIRST12: dowrite = (GetMultimap_Labels()<MAPLABELS_ONLYTOPO) || intask || islandable; // 100711 if ( (islandable && !isairport) && MapWindow::zoom.RealScale() >=10 ) dowrite=0; // FIX then no need to go further // 101215 if (DisplayTextType == DISPLAYNAME) { _tcscpy(Buffer2,WayPointList[i].Name); } else { LK_tcsncpy(Buffer2, WayPointList[i].Name, resizer[DisplayTextType]); } // ConvToUpper(Buffer2); if (draw_alt) { if ( ArrivalValue == (ArrivalValue_t) avAltitude ) { if ( (MapBox == (MapBox_t)mbUnboxedNoUnit) || (MapBox == (MapBox_t)mbBoxedNoUnit) ) wsprintf(Buffer, TEXT("%s:%d"), Buffer2, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY)); else wsprintf(Buffer, TEXT("%s:%d%s"), Buffer2, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY), sAltUnit); } else wsprintf(Buffer, TEXT("%s:%d"), Buffer2, (int)WayPointCalc[i].GR); if ( (MapBox == (MapBox_t)mbBoxed) || (MapBox == (MapBox_t)mbBoxedNoUnit)) { TextDisplayMode.Border = 1; TextDisplayMode.WhiteBold = 0; } else TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } else { //wsprintf(Buffer, TEXT("%s"),Buffer2); _tcscpy(Buffer,Buffer2); if (islandable && isairport) { TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } } break; case DISPLAYNUMBER: dowrite = (GetMultimap_Labels()<MAPLABELS_ONLYTOPO) || intask || islandable; if ( (islandable && !isairport) && MapWindow::zoom.RealScale() >=10 ) dowrite=0; // FIX then no need to go further if (draw_alt) { if ( ArrivalValue == (ArrivalValue_t) avAltitude ) { if ( (MapBox == (MapBox_t)mbUnboxedNoUnit) || (MapBox == (MapBox_t)mbBoxedNoUnit) ) wsprintf(Buffer, TEXT("%d:%d"), WayPointList[i].Number, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY)); else wsprintf(Buffer, TEXT("%d:%d%s"), WayPointList[i].Number, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY), sAltUnit); } else wsprintf(Buffer, TEXT("%d:%d"), WayPointList[i].Number, (int)(WayPointCalc[i].GR)); if ( (MapBox == (MapBox_t)mbBoxed) || (MapBox == (MapBox_t)mbBoxedNoUnit)) { TextDisplayMode.Border = 1; TextDisplayMode.WhiteBold = 0; } else TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } else { wsprintf(Buffer, TEXT("%d"),WayPointList[i].Number); if (islandable && isairport) { TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } } break; case DISPLAYNAMEIFINTASK: dowrite = intask; if (intask) { if (draw_alt) { if ( ArrivalValue == (ArrivalValue_t) avAltitude ) { if ( (MapBox == (MapBox_t)mbUnboxedNoUnit) || (MapBox == (MapBox_t)mbBoxedNoUnit) ) wsprintf(Buffer, TEXT("%s:%d"), WayPointList[i].Name, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY)); else wsprintf(Buffer, TEXT("%s:%d%s"), WayPointList[i].Name, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY), sAltUnit); } else wsprintf(Buffer, TEXT("%s:%d"), WayPointList[i].Name, (int)(WayPointCalc[i].GR)); if ( (MapBox == (MapBox_t)mbBoxed) || (MapBox == (MapBox_t)mbBoxedNoUnit)) { TextDisplayMode.Border = 1; TextDisplayMode.WhiteBold = 0; } else TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } else { wsprintf(Buffer, TEXT("%s"),WayPointList[i].Name); // TODO CHECK THIS, UNTESTED.. if (islandable && isairport) { TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } } } else { wsprintf(Buffer, TEXT(" ")); dowrite=true; } break; case DISPLAYNONE: dowrite = (GetMultimap_Labels()<MAPLABELS_ONLYTOPO) || intask || islandable; if (draw_alt) { if ( ArrivalValue == (ArrivalValue_t) avAltitude ) { if ( (MapBox == (MapBox_t)mbUnboxedNoUnit) || (MapBox == (MapBox_t)mbBoxedNoUnit) ) wsprintf(Buffer, TEXT("%d"), (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY)); else wsprintf(Buffer, TEXT("%d%s"), (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY), sAltUnit); } else wsprintf(Buffer, TEXT("%d"), (int)(WayPointCalc[i].GR) ); if ( (MapBox == (MapBox_t)mbBoxed) || (MapBox == (MapBox_t)mbBoxedNoUnit)) { TextDisplayMode.Border = 1; TextDisplayMode.WhiteBold = 0; } else TextDisplayMode.WhiteBold = 1; // outlined TextDisplayMode.Color=RGB_WHITE; } else { wsprintf(Buffer, TEXT(" ")); } break; default: #if (WINDOWSPC<1) //ASSERT(0); #endif break; } // end intask/irange/dowrite if (MapWindow::zoom.RealScale()<20 && islandable && dowrite) { TextInBox(hdc, &rc, Buffer, WayPointList[i].Screen.x+5, WayPointList[i].Screen.y, 0, &TextDisplayMode, true); dowrite=false; // do not pass it along } // Do not show takeoff for gliders, check TakeOffWayPoint if (i==RESWP_TAKEOFF) { if (TakeOffWayPoint) { intask=false; // 091031 let TAKEOFF be decluttered WayPointList[i].Visible=TRUE; } else { WayPointList[i].Visible=FALSE; dowrite=false; } } if(i==RESWP_OPTIMIZED) { dowrite = DoOptimizeRoute(); } if (dowrite) { MapWaypointLabelAdd( Buffer, WayPointList[i].Screen.x+5, WayPointList[i].Screen.y, &TextDisplayMode, (int)(WayPointList[i].AltArivalAGL*ALTITUDEMODIFY), intask,islandable,isairport,excluded,i,WayPointList[i].Style); } } // end if intask { ; } } // if visible } // for all waypoints qsort(&MapWaypointLabelList, MapWaypointLabelListCount, sizeof(MapWaypointLabel_t), MapWaypointLabelListCompare); int j; // now draw task/landable waypoints in order of range (closest last) // writing unconditionally for (j=MapWaypointLabelListCount-1; j>=0; j--){ MapWaypointLabel_t *E = &MapWaypointLabelList[j]; // draws if they are in task unconditionally, // otherwise, does comparison if ( E->inTask || (E->isLandable && !E->isExcluded) ) { TextInBox(hdc, &rc, E->Name, E->Pos.x, E->Pos.y, 0, &(E->Mode), false); // At low zoom, dont print the bitmap because drawn task would make it look offsetted if(MapWindow::zoom.RealScale() > 2) continue; // If we are at low zoom, use a dot for icons, so we dont clutter the screen if(MapWindow::zoom.RealScale() > 1) { if (BlackScreen) SelectObject(hDCTemp,hInvSmall); else SelectObject(hDCTemp,hSmall); } else { if (BlackScreen) SelectObject(hDCTemp,hInvTurnPoint); else SelectObject(hDCTemp,hTurnPoint); } DrawBitmapX(hdc, E->Pos.x-10, E->Pos.y-10, 20,20, hDCTemp,0,0,SRCPAINT,false); DrawBitmapX(hdc, E->Pos.x-10, E->Pos.y-10, 20,20, hDCTemp,20,0,SRCAND,false); } // wp in task } // for all waypoint, searching for those in task // now draw normal waypoints in order of range (furthest away last) // without writing over each other (or the task ones) for (j=0; j<MapWaypointLabelListCount; j++) { MapWaypointLabel_t *E = &MapWaypointLabelList[j]; if (!E->inTask && !E->isLandable ) { if ( TextInBox(hdc, &rc, E->Name, E->Pos.x, E->Pos.y, 0, &(E->Mode), true) == true) { // If we are at low zoom, use a dot for icons, so we dont clutter the screen if(MapWindow::zoom.RealScale() > 4) { if (BlackScreen) SelectObject(hDCTemp,hInvSmall); else SelectObject(hDCTemp,hSmall); } else { // We switch all styles in the correct order, to force a jump table by the compiler // It would be much better to use an array of bitmaps, but no time to do it for 3.0 switch(E->style) { case STYLE_NORMAL: goto turnpoint; break; // These are not used here in fact case STYLE_AIRFIELDGRASS: case STYLE_OUTLANDING: case STYLE_GLIDERSITE: case STYLE_AIRFIELDSOLID: goto turnpoint; break; case STYLE_MTPASS: SelectObject(hDCTemp,hMountpass); break; case STYLE_MTTOP: SelectObject(hDCTemp,hMountop); break; case STYLE_SENDER: SelectObject(hDCTemp,hSender); break; case STYLE_VOR: goto turnpoint; break; case STYLE_NDB: SelectObject(hDCTemp,hNdb); break; case STYLE_COOLTOWER: goto turnpoint; break; case STYLE_DAM: SelectObject(hDCTemp,hDam); break; case STYLE_TUNNEL: goto turnpoint; break; case STYLE_BRIDGE: SelectObject(hDCTemp,hBridge); break; case STYLE_POWERPLANT: case STYLE_CASTLE: goto turnpoint; break; case STYLE_INTERSECTION: SelectObject(hDCTemp,hIntersect); break; case STYLE_TRAFFIC: goto turnpoint; break; case STYLE_THERMAL: SelectObject(hDCTemp,hLKThermal); break; case STYLE_MARKER: SelectObject(hDCTemp,hBmpMarker); break; default: turnpoint: if (BlackScreen) SelectObject(hDCTemp,hInvTurnPoint); else SelectObject(hDCTemp,hTurnPoint); break; } // switch estyle } // below zoom threshold // We dont do stretching here. We are using different bitmaps for hi res. // The 20x20 size is large enough to make much bigger icons than the old ones. DrawBitmapX(hdc, E->Pos.x-10, E->Pos.y-10, 20,20, hDCTemp,0,0,SRCPAINT,false); DrawBitmapX(hdc, E->Pos.x-10, E->Pos.y-10, 20,20, hDCTemp,20,0,SRCAND,false); } } } } // end DrawWaypoint
// // TODO CHECK BUFFER SIZE, which is 100 (set in Buttons). // bool ExpandMacros(const TCHAR *In, TCHAR *OutBuffer, size_t Size){ TCHAR *a; LK_tcsncpy(OutBuffer, In, Size - 1); if (_tcsstr(OutBuffer, TEXT("$(")) == NULL) { return false; } short items=1; bool invalid = false; // Accelerator for entire label replacement- only one macro per label accepted a =_tcsstr(OutBuffer, TEXT("$(AC")); if (a != NULL) { TCHAR tbuf[20]; short i; i= (*(a+4)-'0')*10; i+= *(a+5)-'0'; LKASSERT(i>=0 && i<41); switch(i) { case 0: // LOCKMODE _tcscpy(OutBuffer,_T("")); // default is button invisible if (LockMode(0)) { // query availability if (LockMode(1)) // query status _tcscpy(OutBuffer,MsgToken(965)); // UNLOCK\nSCREEN else _tcscpy(OutBuffer,MsgToken(966)); // LOCK\nSCREEN if (!LockMode(3)) invalid=true; // button not usable } break; case 1: // Pan Supertoggle PanModeStatus mode=pan location=8 if ( MapWindow::mode.AnyPan() ) _stprintf(OutBuffer, _T("%s%s"),MsgToken(2004),MsgToken(491)); // OFF else _stprintf(OutBuffer, _T("%s%s"),MsgToken(2004),MsgToken(894)); // ON break; case 2: // Pan Supertoggle PanModeStatus mode=ScreenMode location=8 if ( MapWindow::mode.AnyPan() ) _stprintf(OutBuffer, _T("%s\n%s"),MsgToken(2082),MsgToken(491)); // OFF else _stprintf(OutBuffer, _T("%s\n%s"),MsgToken(2082),MsgToken(894)); // ON break; case 3: // DISABLED _tcscpy(OutBuffer,MsgToken(2023)); // Reserved invalid=true; break; case 4: // MacCreadyValue + 2078 _stprintf(tbuf,_T("%2.1lf"), iround(LIFTMODIFY*MACCREADY*10)/10.0); _stprintf(OutBuffer, _T("%s\n%s"), MsgToken(2078), tbuf); break; case 5: if (CALCULATED_INFO.AutoMacCready) { switch(AutoMcMode) { case amcFinalGlide: _stprintf(tbuf,_T("%s"), MsgToken(1681)); break; case amcAverageClimb: _stprintf(tbuf,_T("%s"), MsgToken(1682)); break; case amcEquivalent: _stprintf(tbuf,_T("%s"), MsgToken(1683)); break; case amcFinalAndClimb: if (CALCULATED_INFO.FinalGlide) _stprintf(tbuf,_T("%s"), MsgToken(1681)); else _stprintf(tbuf,_T("%s"), MsgToken(1682)); break; default: // LKTOKEN _@M1202_ "Auto" _stprintf(tbuf,_T("%s"), MsgToken(1202)); break; } } else { // LKTOKEN _@M1201_ "Man" _stprintf(tbuf,_T("%s"), MsgToken(1201)); } _stprintf(OutBuffer,_T("Mc %s\n%2.1lf"), tbuf,iround(LIFTMODIFY*MACCREADY*10)/10.0); break; case 6: // WaypointNext invalid = !ValidTaskPoint(ActiveTaskPoint+1); if (!ValidTaskPoint(ActiveTaskPoint+2)) _tcscpy(OutBuffer,MsgToken(801)); // Waypoint Finish else _tcscpy(OutBuffer,MsgToken(802)); // Waypoint Next break; case 7: // WaypointPrevious if (ActiveTaskPoint==1) { invalid = !ValidTaskPoint(ActiveTaskPoint-1); _tcscpy(OutBuffer,MsgToken(804)); // Waypoint Start } else if (EnableMultipleStartPoints) { invalid = !ValidTaskPoint(0); if (ActiveTaskPoint==0) _tcscpy(OutBuffer,_T("StartPnt\nCycle")); else _tcscpy(OutBuffer,MsgToken(803)); // Waypoint Previous } else { invalid = (ActiveTaskPoint<=0); _tcscpy(OutBuffer,MsgToken(803)); // Waypoint Previous } break; case 8: // RealTask check for Task reset if (! (ValidTaskPoint(ActiveTaskPoint) && ValidTaskPoint(1))) { invalid=true; } _tcscpy(OutBuffer,MsgToken(2019)); // Task reset break; case 9: // TerrainVisible for ChangeBack topology color if (CALCULATED_INFO.TerrainValid && IsMultimapTerrain() && !LKVarioBar) { invalid = true; } _tcscpy(OutBuffer,MsgToken(2037)); // Change topo back break; case 10: // TOGGLEHBAR HBARAVAILABLE for Toggle HBAR button if (!GPS_INFO.BaroAltitudeAvailable) { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2045),MsgToken(1068)); // Nav by HBAR invalid=true; } else { if (EnableNavBaroAltitude) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2045),MsgToken(1174)); // Nav by HGPS else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2045),MsgToken(1068)); // Nav by HBAR } break; case 11: // SIM MENU SIMONLY if (SIMMODE) _tcscpy(OutBuffer,MsgToken(2074)); // SIM MENU else _tcscpy(OutBuffer,_T("")); break; case 12: // THIS MACRO IS AVAILABLE FOR USE break; case 13: if(UseTotalEnergy) { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2115),MsgToken(894)); // TE ON } else { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2115),MsgToken(491)); // TE OFF } break; case 14: if ( Shading ) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2080),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2080),MsgToken(894)); // ON break; case 15: if (EnableSoundModes) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2055),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2055),MsgToken(894)); // ON break; case 16: // ActiveMap no more used now Radio Button #ifdef RADIO_ACTIVE if (RadioPara.Enabled) { _stprintf(OutBuffer,_T("%s\n"),MsgToken(2306)); // TEXT invalid=false; } else { _stprintf(OutBuffer,_T("%s\n"),MsgToken(2306)); // TEXT invalid=true; } #else invalid=true; #endif break; case 17: // Order is: ALL ON, TEXT ONLY, GAUGES ONLY, ALL OFF if (!HaveGauges()) { if (!IsMultimapOverlaysText()) { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(2234)); // TEXT } else { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(491)); // OFF } break; } if (!IsMultimapOverlaysText()&&!IsMultimapOverlaysGauges()) { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(899)); // ALL ON } else { if (IsMultimapOverlaysAll()) { _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(2234)); // TEXT } else { if (IsMultimapOverlaysText()) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(2235)); // GAUGES else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2079),MsgToken(898)); // ALL OFF } } break; case 18: if (Orbiter) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2065),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2065),MsgToken(894)); // ON if (!EnableThermalLocator) invalid = true; break; case 19: if (IsMultimapAirspace()) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(894)); // ON break; case 20: if (MapWindow::zoom.AutoZoom() ) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2009),MsgToken(418)); else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2009),MsgToken(897)); break; case 21: if (IsMultimapTopology()) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2027),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2027),MsgToken(894)); // ON break; case 22: if (IsMultimapTerrain()) _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2028),MsgToken(491)); // OFF else _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2028),MsgToken(894)); // ON break; case 23: if (MapSpaceMode!=MSM_MAP) invalid=true; if (MapWindow::mode.UserForcedMode() == MapWindow::Mode::MODE_FLY_CIRCLING) _stprintf(OutBuffer,_T("DspMode\n_%s_"),MsgToken(2031)); else _stprintf(OutBuffer,_T("DspMode\n%s"),MsgToken(2031)); break; case 24: if (MapSpaceMode!=MSM_MAP) invalid=true; if (MapWindow::mode.UserForcedMode() == MapWindow::Mode::MODE_FLY_CRUISE) _stprintf(OutBuffer,_T("DspMode\n_%s_"),MsgToken(2032)); else _stprintf(OutBuffer,_T("DspMode\n%s"),MsgToken(2032)); break; case 25: if (MapSpaceMode!=MSM_MAP) invalid=true; if (MapWindow::mode.UserForcedMode() == MapWindow::Mode::MODE_FLY_NONE) _stprintf(OutBuffer,_T("DspMode\n_%s_"),MsgToken(2034)); else _stprintf(OutBuffer,_T("DspMode\n%s"),MsgToken(2034)); break; case 26: if (MapSpaceMode!=MSM_MAP) invalid=true; if (MapWindow::mode.UserForcedMode() == MapWindow::Mode::MODE_FLY_FINAL_GLIDE) _stprintf(OutBuffer,_T("DspMode\n_%s_"),MsgToken(2033)); else _stprintf(OutBuffer,_T("DspMode\n%s"),MsgToken(2033)); break; case 27: // amcIsBoth if (CALCULATED_INFO.AutoMacCready && AutoMcMode==amcFinalAndClimb) _stprintf(OutBuffer,_T("Auto\n_%s_"),MsgToken(2117)); else _stprintf(OutBuffer,_T("Auto\n%s"),MsgToken(2117)); break; case 28: // amcIsFinal if (CALCULATED_INFO.AutoMacCready && AutoMcMode==amcFinalGlide) _stprintf(OutBuffer,_T("Auto\n_%s_"),MsgToken(2033)); else _stprintf(OutBuffer,_T("Auto\n%s"),MsgToken(2033)); break; case 29: // amcIsClimb if (CALCULATED_INFO.AutoMacCready && AutoMcMode==amcAverageClimb) _stprintf(OutBuffer,_T("Auto\n_%s_"),MsgToken(2075)); else _stprintf(OutBuffer,_T("Auto\n%s"),MsgToken(2075)); break; case 30: // amcIsEquiv if (CALCULATED_INFO.AutoMacCready && AutoMcMode==amcEquivalent) _stprintf(OutBuffer,_T("Auto\n_%s_"),MsgToken(2076)); else _stprintf(OutBuffer,_T("Auto\n%s"),MsgToken(2076)); break; case 31: // CheckManMc if (CALCULATED_INFO.AutoMacCready) _stprintf(OutBuffer,_T("Mc\n%s"),MsgToken(2077)); else _stprintf(OutBuffer,_T("Mc\n_%s_"),MsgToken(2077)); break; case 32: // AirspaceMode switch(AltitudeMode) { case 0: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(184)); // Clip break; case 1: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(897)); // Auto break; case 2: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(139)); // Below break; case 3: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(359)); // Inside break; case 4: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(75)); // All Off break; case 5: default: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2029),MsgToken(76)); // All On break; } break; case 33: // SnailTrailToggleName if (MapSpaceMode!=MSM_MAP) invalid=true; // Since we show the next choice, but the order is not respected in 5.0: // the new order is artificially off-short-long-full, as in the inputevents button management switch(TrailActive) { case 0: // off to short _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2035),MsgToken(612)); // Short break; case 1: // long to full _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2035),MsgToken(312)); // Full break; case 2: // short to long _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2035),MsgToken(410)); // Long break; case 3: // full to off default: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2035),MsgToken(491)); // OFF break; } break; case 34: // MapLabelsToggleActionName switch(GetMultimap_Labels()) { case MAPLABELS_ALLON: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2026),MsgToken(1203)); // WPTS break; case MAPLABELS_ONLYWPS: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2026),MsgToken(1204)); // TOPO break; case MAPLABELS_ONLYTOPO: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2026),MsgToken(898)); break; case MAPLABELS_ALLOFF: default: _stprintf(OutBuffer,_T("%s\n%s"),MsgToken(2026),MsgToken(899)); break; } break; case 35: // SIM PAN MODE REPOSITION, PANREPOS if (SIMMODE) _tcscpy(OutBuffer,MsgToken(2133)); // Position else _tcscpy(OutBuffer,_T("")); break; case 36: // // Order is: ALL ON, TASK ONLY, FAI ONLY, ALL OFF if (Flags_DrawTask&&Flags_DrawFAI) { _tcscpy(OutBuffer,MsgToken(2238)); // Draw Task } else { if (Flags_DrawTask&&!Flags_DrawFAI) { _tcscpy(OutBuffer,MsgToken(2239)); // Draw FAI } else { if (!Flags_DrawTask&&Flags_DrawFAI) { _tcscpy(OutBuffer,MsgToken(2240)); // NoDraw TaskFAI } else { _tcscpy(OutBuffer,MsgToken(2241)); // Draw TaskFAI } } } break; case 37: // if (SonarWarning) _tcscpy(OutBuffer,MsgToken(2243)); // Sonar OFF else _tcscpy(OutBuffer,MsgToken(2242)); // Sonar ON break; case 38: // if (MapSpaceMode!=MSM_MAP) invalid=true; _tcscpy(OutBuffer,MsgToken(2081)); // Set Map break; case 39: if (! (ValidTaskPoint(ActiveTaskPoint) && ValidTaskPoint(1))) { invalid=true; } _tcscpy(OutBuffer,MsgToken(1850)); // Task reverse break; case 40: if(IsKobo()) { #ifdef KOBO if(IsKoboWifiOn()) { _tcscpy(OutBuffer,_T("Wifi\nOff")); } else { _tcscpy(OutBuffer,_T("Wifi\nOn")); } #endif } else { _tcscpy(OutBuffer,_T("")); } break; default: _stprintf(OutBuffer, _T("INVALID\n%d"),i); break; } goto label_ret; } // ACcelerator // No accelerator? First check if we have a second macro embedded in string a =_tcsstr(OutBuffer, TEXT("&(")); if (a != NULL) { *a=_T('$'); items=2; } // Then go for one-by-one match search, slow if (_tcsstr(OutBuffer, TEXT("$(AdvanceArmed)"))) { switch (AutoAdvance) { case 0: ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(892), Size); // (manual) invalid = true; break; case 1: ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(893), Size); // (auto) invalid = true; break; case 2: if (ActiveTaskPoint>0) { if (ValidTaskPoint(ActiveTaskPoint+1)) { CondReplaceInString(AdvanceArmed, OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(161), // Cancel MsgToken(678), Size); // TURN } else { ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(8), Size); // (finish) invalid = true; } } else { CondReplaceInString(AdvanceArmed, OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(161), // Cancel MsgToken(571), Size); // START } break; case 3: if (ActiveTaskPoint==0) { CondReplaceInString(AdvanceArmed, OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(161), // Cancel MsgToken(571), Size); // START } else if (ActiveTaskPoint==1) { CondReplaceInString(AdvanceArmed, OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(161), // Cancel MsgToken(539), Size); // RESTART } else { ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(893), Size); // (auto) invalid = true; } break; // TODO bug: no need to arm finish case 4: if (ActiveTaskPoint>0) { if (ValidTaskPoint(ActiveTaskPoint+1)) { CondReplaceInString(AdvanceArmed, OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(161), // Cancel MsgToken(678), Size); // TURN } else { ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(8), Size); // (finish) invalid = true; } } else { ReplaceInString(OutBuffer, TEXT("$(AdvanceArmed)"), MsgToken(893), Size); // (auto) invalid = true; } break; default: break; } if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckFlying)"))) { if (!CALCULATED_INFO.Flying) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckFlying)"), TEXT(""), Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(NotInReplay)"))) { if (ReplayLogger::IsEnabled()) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(NotInReplay)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckWaypointFile)"))) { if (!ValidWayPoint(NUMRESWP)) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckWaypointFile)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckSettingsLockout)"))) { if (LockSettingsInFlight && CALCULATED_INFO.Flying) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckSettingsLockout)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckTask)"))) { if (!ValidTaskPoint(ActiveTaskPoint)) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckTask)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckAirspace)"))) { if (!CAirspaceManager::Instance().ValidAirspaces()) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckAirspace)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(CheckFLARM)"))) { if (!GPS_INFO.FLARM_Available) { invalid = true; } ReplaceInString(OutBuffer, TEXT("$(CheckFLARM)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } // If it is not SIM mode, it is invalid if (_tcsstr(OutBuffer, TEXT("$(OnlyInSim)"))) { if (!SIMMODE) invalid = true; ReplaceInString(OutBuffer, TEXT("$(OnlyInSim)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(OnlyInFly)"))) { #if TESTBENCH invalid=false; #else if (SIMMODE) invalid = true; #endif ReplaceInString(OutBuffer, TEXT("$(OnlyInFly)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(WCSpeed)"))) { TCHAR tbuf[10]; _stprintf(tbuf,_T("%.0f%s"),SPEEDMODIFY*WindCalcSpeed,Units::GetUnitName(Units::GetUserHorizontalSpeedUnit()) ); ReplaceInString(OutBuffer, TEXT("$(WCSpeed)"), tbuf, Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(GS"))) { TCHAR tbuf[10]; _stprintf(tbuf,_T("%.0f%s"),SPEEDMODIFY*GPS_INFO.Speed,Units::GetUnitName(Units::GetUserHorizontalSpeedUnit()) ); ReplaceInString(OutBuffer, TEXT("$(GS)"), tbuf, Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(HGPS"))) { TCHAR tbuf[10]; _stprintf(tbuf,_T("%.0f%s"),ALTITUDEMODIFY*GPS_INFO.Altitude,Units::GetUnitName(Units::GetUserAltitudeUnit()) ); ReplaceInString(OutBuffer, TEXT("$(HGPS)"), tbuf, Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(TURN"))) { TCHAR tbuf[10]; _stprintf(tbuf,_T("%.0f"),SimTurn); ReplaceInString(OutBuffer, TEXT("$(TURN)"), tbuf, Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(NETTO"))) { TCHAR tbuf[10]; _stprintf(tbuf,_T("%.1f"),SimNettoVario); ReplaceInString(OutBuffer, TEXT("$(NETTO)"), tbuf, Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(LoggerActive)"))) { CondReplaceInString(LoggerActive, OutBuffer, TEXT("$(LoggerActive)"), MsgToken(670), MsgToken(657), Size); // Stop Start if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(NoSmart)"))) { if (DisplayOrientation == NORTHSMART) invalid = true; ReplaceInString(OutBuffer, TEXT("$(NoSmart)"), TEXT(""), Size); if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(FinalForceToggleActionName)"))) { CondReplaceInString(ForceFinalGlide, OutBuffer, TEXT("$(FinalForceToggleActionName)"), MsgToken(896), // Unforce MsgToken(895), // Force Size); if (AutoForceFinalGlide) { invalid = true; } if (--items<=0) goto label_ret; // 100517 } if (_tcsstr(OutBuffer, TEXT("$(PCONLY)"))) { if(IsEmbedded()) { _tcscpy(OutBuffer,_T("")); invalid = true; } else { ReplaceInString(OutBuffer, TEXT("$(PCONLY)"), TEXT(""), Size); } if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(NOTPC)"))) { if(IsEmbedded()) { ReplaceInString(OutBuffer, TEXT("$(NOTPC)"), TEXT(""), Size); } else { _tcscpy(OutBuffer,_T("")); invalid = true; } if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(ONLYMAP)"))) { if (MapSpaceMode!=MSM_MAP) invalid=true; ReplaceInString(OutBuffer, TEXT("$(ONLYMAP)"), TEXT(""), Size); if (--items<=0) goto label_ret; } if (_tcsstr(OutBuffer, TEXT("$(SCREENROTATE)"))) { if(CanRotateScreen()) { ReplaceInString(OutBuffer, TEXT("$(SCREENROTATE)"), TEXT(""), Size); } else { _tcscpy(OutBuffer,_T("")); invalid = true; } if (--items<=0) goto label_ret; } extern unsigned int CustomKeyLabel[]; // We dont replace macro, we do replace the entire label a =_tcsstr(OutBuffer, TEXT("$(MM")); if (a != NULL) { short i; i= *(a+4)-48; LKASSERT(i>=0 && i<11); // get the label for the custom menu item here // Decide if invalid=true or if no label at all, setting Replace to empty string unsigned int ckeymode; // test mode only switch(i) { case 1: ckeymode=CustomMenu1; break; case 2: ckeymode=CustomMenu2; break; case 3: ckeymode=CustomMenu3; break; case 4: ckeymode=CustomMenu4; break; case 5: ckeymode=CustomMenu5; break; case 6: ckeymode=CustomMenu6; break; case 7: ckeymode=CustomMenu7; break; case 8: ckeymode=CustomMenu8; break; case 9: ckeymode=CustomMenu9; break; case 0: ckeymode=CustomMenu10; break; default: ckeymode=0; break; } if (ckeymode==0 || ckeymode>=ckTOP) { invalid=true; // non selectable // _stprintf(OutBuffer,_T("Key\n%d"),i); _tcscpy(OutBuffer,_T("")); // make it invisible } else { _tcscpy(OutBuffer,MsgToken( CustomKeyLabel[ckeymode] )); } } // MM label_ret: return invalid; }