XPMP2-Remote/XPMP2-Remote.cpp
void MenuUpdateSenders ()
{
    // Simple case first: There is no sender
    if (rcGlob.gmapSender.empty()) {
        // If we show anything we must remove it
        if (numSendersInMenu > 0) {
            XPLMClearAllMenuItems(hSenders);
            XPLMAppendMenuItem(hSenders, "(none)", (void*)MENU_SENDER, 0);
            numSendersInMenu = 0;
        }
        return;
    }
    
    // There are senders, fill in their details
    if (numSendersInMenu == 0)      // physically there's always one menu item that we can re-use
        numSendersInMenu++;
    
    // Cycle over senders and update textual information
    int idx = 0;
    for (const mapSenderTy::value_type& p: rcGlob.gmapSender)
    {
        const SenderTy& snd = p.second;
        
        // Put together plugin name, IP address, number of aircraft
        std::string s (STR_N(snd.settings.name));
        if (!snd.bLocal) {
            s += " @ ";
            s += snd.sFrom;
        }
        s += ": ";
        s += std::to_string(snd.mapAc.size());
        s += " aircraft";
        
        // Do we need a new menu item or can we update an existing one?
        if (idx < numSendersInMenu)
            XPLMSetMenuItemName(hSenders, idx, s.c_str(), 0);
        else {
            XPLMAppendMenuItem(hSenders, s.c_str(), (void*)MENU_SENDER, 0);
            numSendersInMenu++;
        }
        idx++;
    }
    
    // Remove left-over menu items
    while (idx < numSendersInMenu)
        XPLMRemoveMenuItem(hSenders, --numSendersInMenu);
}
/// (Re)Create the submenu listing information about connected senders

(Re)Create the submenu listing information about connected senders
( Re ) Create the submenu listing information about connected senders
void MenuUpdateSenders ()
{
    if (rcGlob.gmapSender.empty()) {
        if (numSendersInMenu > 0) {
            XPLMClearAllMenuItems(hSenders);
            XPLMAppendMenuItem(hSenders, "(none)", (void*)MENU_SENDER, 0);
            numSendersInMenu = 0;
        }
        return;
    }
    if (numSendersInMenu == 0)      
        numSendersInMenu++;
    int idx = 0;
    for (const mapSenderTy::value_type& p: rcGlob.gmapSender)
    {
        const SenderTy& snd = p.second;
        std::string s (STR_N(snd.settings.name));
        if (!snd.bLocal) {
            s += " @ ";
            s += snd.sFrom;
        }
        s += ": ";
        s += std::to_string(snd.mapAc.size());
        s += " aircraft";
        if (idx < numSendersInMenu)
            XPLMSetMenuItemName(hSenders, idx, s.c_str(), 0);
        else {
            XPLMAppendMenuItem(hSenders, s.c_str(), (void*)MENU_SENDER, 0);
            numSendersInMenu++;
        }
        idx++;
    }
    while (idx < numSendersInMenu)
        XPLMRemoveMenuItem(hSenders, --numSendersInMenu);
}
void MenuUpdateSenders ( ) { if ( rcGlob . gmapSender . empty ( ) ) { if ( numSendersInMenu > 0 ) { XPLMClearAllMenuItems ( hSenders ) ; XPLMAppendMenuItem ( hSenders , " " , ( void * ) MENU_SENDER , 0 ) ; numSendersInMenu = 0 ; } return ; } if ( numSendersInMenu == 0 ) numSendersInMenu ++ ; int idx = 0 ; for ( const mapSenderTy :: value_type & p : rcGlob . gmapSender ) { const SenderTy & snd = p . second ; std :: string s ( STR_N ( snd . settings . name ) ) ; if ( ! snd . bLocal ) { s += " " ; s += snd . sFrom ; } s += " " ; s += std :: to_string ( snd . mapAc . size ( ) ) ; s += " " ; if ( idx < numSendersInMenu ) XPLMSetMenuItemName ( hSenders , idx , s . c_str ( ) , 0 ) ; else { XPLMAppendMenuItem ( hSenders , s . c_str ( ) , ( void * ) MENU_SENDER , 0 ) ; numSendersInMenu ++ ; } idx ++ ; } while ( idx < numSendersInMenu ) XPLMRemoveMenuItem ( hSenders , -- numSendersInMenu ) ; }
(Re)Create the submenu listing information about connected senders
( Re ) Create the submenu listing information about connected senders
// Simple case first: There is no sender
 // If we show anything we must remove it
 // There are senders, fill in their details
 // physically there's always one menu item that we can re-use
 // Cycle over senders and update textual information
 // Put together plugin name, IP address, number of aircraft
 // Do we need a new menu item or can we update an existing one?
 // Remove left-over menu items
