Ejemplo n.º 1
0
static void OnSelectClicked(WindowControl * Sender){
	(void)Sender;
  int res;
  res = dlgWayPointSelect();
  if (res != -1){
    SelectedWaypoint = res;    
    if (Task[twItemIndex].Index != res) {
      if (CheckDeclaration()) {
        LockTaskData();
        ResetTaskWaypoint(twItemIndex);
        Task[twItemIndex].Index = res;
        TaskModified = true;
        UnlockTaskData();
      }
    }
    UpdateCaption();
  };
}
Ejemplo n.º 2
0
static void OnSelectClicked(WndButton* pWnd){
  int res;
  res = dlgWayPointSelect();
  if (res != -1){
    SelectedWaypoint = res;    
    LKASSERT(twItemIndex>=0);
    if (Task[twItemIndex].Index != res) {
      if (CheckDeclaration()) {
        LockTaskData();
        ResetTaskWaypoint(twItemIndex);
        Task[twItemIndex].Index = res;
        Task[twItemIndex].PGConeBase = WayPointList[res].Altitude;
        TaskModified = true;
        UnlockTaskData();
      }
    }
    UpdateCaption();
  };
}
Ejemplo n.º 3
0
static void OnTaskListEnter(WindowControl * Sender,
		     WndListFrame::ListInfo_t *ListInfo) {
  (void)Sender;
  bool isfinish = false;

  ItemIndex = ListInfo->ItemIndex+ListInfo->ScrollIndex;

  // If we are clicking on Add Waypoint
  if ((ItemIndex>=0) && (ItemIndex == UpLimit) && (UpLimit<MAXTASKPOINTS)) {

	// add new waypoint
	if (CheckDeclaration()) {

		if (ItemIndex>0) {
#ifdef LAST_TASKPOINT_QUESTION
			if (MessageBoxX(
			// LKTOKEN  _@M817_ = "Will this be the finish?"
			MsgToken(817),
			// LKTOKEN  _@M54_ = "Add Waypoint"
			MsgToken(54),
			mbYesNo) == IdYes)
#else
		    if(0)
#endif
			{

				isfinish = true;

				// Set initial wp as the finish by default, or home if nonex
				LockTaskData();
                // ItemIndex is already checked for > 0 no need to test twice
				Task[ItemIndex].Index = Task[0].Index;
				UnlockTaskData();

			} else {
				isfinish = false;
			}
		}

		int res;
		res = dlgWayPointSelect();

		if (ValidWayPoint(res)){

			LockTaskData();
            ResetTaskWaypoint(ItemIndex);
			Task[ItemIndex].Index = res;
            Task[ItemIndex].PGConeBase = WayPointList[res].Altitude;

			UnlockTaskData();
			if (ItemIndex==0) {
				dlgTaskWaypointShowModal(ItemIndex, 0, true); // start waypoint
			} else if (isfinish) {
				dlgTaskWaypointShowModal(ItemIndex, 2, true); // finish waypoint
			} else {
				if (AATEnabled || DoOptimizeRoute()) {
					// only need to set properties for finish
					dlgTaskWaypointShowModal(ItemIndex, 1, true); // normal waypoint
				}
			}

		} // ValidWaypoint
		OverviewRefreshTask();

	} // CheckDeclaration

	return;

  } // Index==UpLimit, clicking on Add Waypoint

  if (ItemIndex<UpLimit) {

	if (ItemIndex==0) {
		dlgTaskWaypointShowModal(ItemIndex, 0); // start waypoint
	} else {
		if (ItemIndex==UpLimit-1) {
			dlgTaskWaypointShowModal(ItemIndex, 2); // finish waypoint
		} else {
			dlgTaskWaypointShowModal(ItemIndex, 1); // turnpoint
		}
	}
	  OverviewRefreshTask();
  }

} // OnTaskListEnter
Ejemplo n.º 4
0
// Inserts a waypoint into the task, in the
// position of the ActiveWaypoint.  If append=true, insert at end of the
// task.
void InsertWaypoint(int index, bool append) {
  if (!CheckDeclaration())
    return;

  int i;
  
  LockTaskData();
  TaskModified = true;
  TargetModified = true;

  if ((ActiveWayPoint<0) || !ValidTaskPoint(0)) {
    ActiveWayPoint = 0;
    ResetTaskWaypoint(ActiveWayPoint);
    Task[ActiveWayPoint].Index = index;

    UnlockTaskData();
    return;
  }
  
  if (ValidTaskPoint(MAXTASKPOINTS-1)) {
    // No room for any more task points!
    MessageBoxX(hWndMapWindow,
	// LKTOKEN  _@M727_ = "Too many waypoints in task!" 
      gettext(TEXT("_@M727_")),
	// LKTOKEN  _@M357_ = "Insert Waypoint" 
      gettext(TEXT("_@M357_")),
      MB_OK|MB_ICONEXCLAMATION);
    
    UnlockTaskData();
    return;
  }

  int indexInsert = max(ActiveWayPoint,0);
  if (append) {
	for (i=indexInsert; i<MAXTASKPOINTS-2; i++) {
		#if 100526
		if (Task[i+2].Index<0 && Task[i+1].Index>=0) {
			// i+1 is the last one, so we insert before the last one: shift i+1 to i+2, insert in i+1
			Task[i+2] = Task[i+1];
			ResetTaskWaypoint(i+1);
			Task[i+1].Index = index;
			break;
		}
		if (Task[i+1].Index<0) {
			// i+1 is empty, so the activewaypoint is the last one: we append after finish, because
			// pilot can use insert waypoint to make it BEFORE finish
			ResetTaskWaypoint(i+1);
			Task[i+1].Index = index;
			break;
		}
		#else
		if (Task[i+1].Index<0) {
			ResetTaskWaypoint(i+1);
			Task[i+1].Index = index;
			break;
		}
		#endif
	}  
  } else {
    // Shuffle ActiveWaypoint and all later task points
    // to the right by one position
    for (i=MAXTASKPOINTS-1; i>indexInsert; i--) {
      Task[i] = Task[i-1];
    }  
    // Insert new point and update task details
    ResetTaskWaypoint(indexInsert);
    Task[indexInsert].Index = index;
  }
  
  RefreshTask();
  UnlockTaskData();
  
}
Ejemplo n.º 5
0
// Inserts a waypoint into the task, in the
// position of the ActiveWaypoint.  If append=true, insert at end of the
// task.
void InsertWaypoint(int index, unsigned short append) {
  if (!CheckDeclaration())
    return;

  int i;

  LockTaskData();
  TaskModified = true;
  TargetModified = true;

  if ((ActiveTaskPoint<0) || !ValidTaskPoint(0)) {
    ActiveTaskPoint = 0;
    ResetTaskWaypoint(ActiveTaskPoint);
    Task[ActiveTaskPoint].Index = index;

    UnlockTaskData();
    return;
  }

  if (ValidTaskPoint(MAXTASKPOINTS-1)) {
    // No room for any more task points!
    MessageBoxX(
	// LKTOKEN  _@M727_ = "Too many waypoints in task!"
      MsgToken(727),
	// LKTOKEN  _@M357_ = "Insert Waypoint"
      MsgToken(357),
      mbOk);

    UnlockTaskData();
    return;
  }

  int indexInsert = max(ActiveTaskPoint,0);

  switch(append) {
	// append 0 = insert in current position
	case 0:
		// Shift ActiveWaypoint and all later task points
		// to the right by one position
		for (i=MAXTASKPOINTS-1; i>indexInsert; i--) {
			Task[i] = Task[i-1];
		}
		// Insert new point and update task details
		ResetTaskWaypoint(indexInsert);
		Task[indexInsert].Index = index;

		break;

	// append 1 = add before finish
	case 1:
		for (i=indexInsert; i<MAXTASKPOINTS-2; i++) {
			if (Task[i+2].Index<0 && Task[i+1].Index>=0) {
				// i+1 is the last one, so we insert before the last one: shift i+1 to i+2, insert in i+1
				Task[i+2] = Task[i+1];
				ResetTaskWaypoint(i+1);
				Task[i+1].Index = index;
				break;
			}
			// special case, we started already from the last point. We insert.
			if (Task[i+1].Index<0) {
				ResetTaskWaypoint(i+1);
				Task[i+1]=Task[i];
				Task[i].Index = index;
				break;
			}
		}
		break;

	// append 2 = add after finish
	case 2:
		for (i=indexInsert; i<MAXTASKPOINTS-2; i++) {
			if (Task[i+1].Index<0) {
				ResetTaskWaypoint(i+1);
				Task[i+1].Index = index;
				break;
			}
		}
		break;

	default:
		#if BUGSTOP
		LKASSERT(0);
		#endif
		break;
  }

  RefreshTask();
  UnlockTaskData();

}