예제 #1
0
파일: FlarmTools.cpp 프로젝트: braun/LK8000
bool AddFlarmLookupItem(int id, TCHAR *name, bool saveFile)
{
  int index = LookupSecondaryFLARMId(id);

  #ifdef DEBUG_LKT
  StartupStore(_T("... LookupSecondary id=%d result index=%d\n"),id,index);
  #endif
  if (index == -1)
    {
      if (NumberOfFLARMNames < MAXFLARMLOCALS)  // 100322 
	{
	  // create new record
	  FLARM_Names[NumberOfFLARMNames].ID = id;
	  _tcsncpy(FLARM_Names[NumberOfFLARMNames].Name, name,MAXFLARMNAME); // was 20 100322
	  FLARM_Names[NumberOfFLARMNames].Name[MAXFLARMNAME]=0; // was 20
	  NumberOfFLARMNames++;
	  SaveFLARMDetails();
	  return true;
	}
    }
  else
    {
      // modify existing record
      FLARM_Names[index].ID = id;
      _tcsncpy(FLARM_Names[index].Name, name,MAXFLARMNAME);
      FLARM_Names[index].Name[MAXFLARMNAME]=0;	
      if (saveFile)
	{
	  SaveFLARMDetails();
	}
      return true;
    }
  return false;
}
예제 #2
0
/**
 * Adds a FLARM details couple (callsign + FLARM id)
 * to the FLARM details array and saves it to the
 * user file (if necessary)
 * @param id FLARM id
 * @param name Callsign
 * @param saveFile True = FLARM details file is saved after update
 * @return True if successfully added, False otherwise
 */
bool AddFlarmLookupItem(int id, const TCHAR *name, bool saveFile) {
  int index = LookupSecondaryFLARMId(id);

  if (index == -1) {
    if (NumberOfFLARMNames < MAXFLARMNAMES - 1) {
      // create new record
      FLARM_Names[NumberOfFLARMNames].ID = id;
      _tcsncpy(FLARM_Names[NumberOfFLARMNames].Name, name, 20);
      FLARM_Names[NumberOfFLARMNames].Name[20] = 0;
      NumberOfFLARMNames++;
      SaveFLARMDetails();
      return true;
    }
  } else {
    // modify existing record
    FLARM_Names[index].ID = id;
    _tcsncpy(FLARM_Names[index].Name, name, 20);
    FLARM_Names[index].Name[20] = 0;
    if (saveFile) {
      SaveFLARMDetails();
    }
    return true;
  }
  return false;
}
예제 #3
0
bool AddFlarmLookupItem(int id, TCHAR *name, bool saveFile) {
    bool bRet = false;
    int index = LookupSecondaryFLARMId(id);

#ifdef DEBUG_LKT
    StartupStore(_T("... LookupSecondary id=%d result index=%d\n"), id, index);
#endif
    if (index == -1) {
        if (NumberOfFLARMNames < MAXFLARMLOCALS) { // 100322
            // create new record
            index = NumberOfFLARMNames++;
        }
    }

    if(index != -1) {
        FLARM_Names[index].ID = id;
        LK_tcsncpy(FLARM_Names[index].Name, name, MAXFLARMNAME);
        bRet = true;
    }

    if (bRet && saveFile) {
        SaveFLARMDetails();
    }
    return bRet;
}
예제 #4
0
파일: FlarmTools.cpp 프로젝트: Mazuk/LK8000
// Used by TeamCode, to select a CN and get back the Id
int LookupFLARMDetails(TCHAR *cn) 
{
  // try to find flarm from userFile
  int index = LookupSecondaryFLARMId(cn);
  if (index != -1)
    {
      return FLARM_Names[index].ID;
    }
  
  // try to find flarm from FLARMNet.org File
  FlarmId* flarmId = file.GetFlarmIdItem(cn);
  if (flarmId != NULL)
    {
      return flarmId->GetId();
    }
  return 0;
}
예제 #5
0
파일: FlarmTools.cpp 프로젝트: Mazuk/LK8000
// returns Name or Cn to be used
TCHAR* LookupFLARMCn(long id) {
  
  // try to find flarm from userFile
  int index = LookupSecondaryFLARMId(id);
  if (index != -1)
    {
      return FLARM_Names[index].Name;
    }
  
  // try to find flarm from FLARMNet.org File
  FlarmId* flarmId = file.GetFlarmIdItem(id);
  if (flarmId != NULL)
    {
      return flarmId->cn;
    }
  return NULL;
}
예제 #6
0
static void OnDetailsListInfo(WindowControl * Sender, WndListFrame::ListInfo_t *ListInfo){
  (void)Sender;
  if (ListInfo->DrawIndex == -1){
    ListInfo->ItemCount = GetActiveFlarmTrafficCount();
  } else {
    DrawListIndex = ListInfo->DrawIndex+ListInfo->ScrollIndex;
    if (DrawListIndex != -1)
      {
	if (XCSoarInterface::Basic().FLARM_Traffic[DrawListIndex].ID != 0)
	  {
	    if (LookupFLARMDetails(XCSoarInterface::Basic().FLARM_Traffic[DrawListIndex].ID) == NULL)
	      {
		// not existing en primary or secondary flarm id list
		((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetCaption(TEXT("Set CN"));
		((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetVisible(true);
	      }
	    else
	      {
		// the id was found - is it from secondary list ?
		int index = LookupSecondaryFLARMId(XCSoarInterface::Basic().FLARM_Traffic[DrawListIndex].ID);

		if (index != -1)
		  {
		    ((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetCaption(TEXT("Edit CN"));
		    ((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetVisible(true);
		  }
		else
		  {
		    ((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetVisible(false);
		  }
	      }
	    ((WndButton *)wf->FindByName(TEXT("cmdTrack")))->SetVisible(true);
	  }
	else
	  {
	    ((WndButton *)wf->FindByName(TEXT("cmdTrack")))->SetVisible(false);
	    ((WndButton *)wf->FindByName(TEXT("cmdSetCN")))->SetVisible(false);
	  }
      }
  }
}