Exemplo n.º 1
0
static void OnStartPointListInfo(WindowControl * Sender,
                                 WndListFrame::ListInfo_t *ListInfo) {
    (void)Sender;
    if (ListInfo->DrawIndex == -1) {
        ListInfo->ItemCount = 0;
        while(ValidStartPoint(ListInfo->ItemCount++)) { }
    } else {
        DrawListIndex = ListInfo->DrawIndex+ListInfo->ScrollIndex;
        ItemIndex = ListInfo->ItemIndex+ListInfo->ScrollIndex;
    }
}
Exemplo n.º 2
0
bool CTaskFileHelper::LoadStartPointList(XMLNode node) {
    if (node) {
        int i = 0;
        XMLNode nodePoint = node.getChildNode(_T("point"), &i);
        while (nodePoint) {
            if (!LoadStartPoint(nodePoint)) {
                return false;
            }
            nodePoint = node.getChildNode(_T("point"), &i);
        }
        EnableMultipleStartPoints = ValidStartPoint(0);
    }
    return true;
}
Exemplo n.º 3
0
bool CTaskFileHelper::SaveStartPointList(XMLNode node) {
    if (!node) {
        return false;
    }
    for (unsigned long i = 0; ValidStartPoint(i); ++i) {
        XMLNode PointNode = node.AddChild(ToString(_T("point")), false);
        if (!PointNode) {
            return false;
        }

        SetAttribute(PointNode, _T("idx"), i);

        RenameIfVirtual(i); // TODO: check code is unique ?

        if (!SaveStartPoint(PointNode, StartPoints[i])) {
            return false;
        }
    }
    return true;
}
Exemplo n.º 4
0
static void OnStartPointListEnter(WindowControl * Sender,
                                  WndListFrame::ListInfo_t *ListInfo) {
    (void)Sender;
    ItemIndex = ListInfo->ItemIndex + ListInfo->ScrollIndex;
    if (ItemIndex>=MAXSTARTPOINTS) {
        ItemIndex = -1;
        while(ValidStartPoint(ItemIndex++)) { }
    }
    if (ItemIndex>=0) {
        int res;
        res = dlgWayPointSelect();
        if (res>=0) {
            // TODO bug: don't add it if it's already present!
            LockTaskData();
            StartPoints[ItemIndex].Index = res;
            StartPoints[ItemIndex].Active = true;
            UnlockTaskData();
            changed = true;
            UpdateList();
        }
    }
}
Exemplo n.º 5
0
bool CTaskFileHelper::Save(const TCHAR* szFileName) {
    if (!WayPointList) return false; // this should never happen, but just to be safe...

    CScopeLock LockTask(LockTaskData, UnlockTaskData);
    StartupStore(_T(". SaveTask : saving <%s>%s"), szFileName, NEWLINE);

    ///////////////////////////////////////////////////////////////
    // TODO : this code is temporary before rewriting task system
    if (AATEnabled || DoOptimizeRoute()) {
        for (unsigned i = 0; ValidTaskPoint(i); ++i) {
            int type = -1;
            if (i == 0) { // Start
                Task[0].AATCircleRadius = StartRadius;
                Task[0].AATSectorRadius = StartRadius;
                Task[0].OutCircle = !PGStartOut;
                type = StartLine;
            } else if (!ValidTaskPoint(i + 1)) { //Finish
                Task[i].AATCircleRadius = FinishRadius;
                Task[i].AATSectorRadius = FinishRadius;
                type = FinishLine;
            }
            if (type != -1) {
                switch (type) {
                    case 0: //circle
                        Task[i].AATType = CIRCLE;
                        break;
                    case 1: //line
                        Task[i].AATType = LINE;
                        break;
                    case 2: //sector
                        Task[i].AATType = SECTOR;
                        break;
                }
            }
        }
    }
    ///////////////////////////////////////////////////////////////


    XMLNode topNode = XMLNode::createXMLTopNode();
    XMLNode rootNode = topNode.AddChild(ToString(_T("lk-task")), false);

    if (!SaveOption(rootNode)) {
        return false;
    }

    if (!SaveTaskPointList(rootNode.AddChild(ToString(_T("taskpoints")), false))) {
        return false;
    }
    if (EnableMultipleStartPoints && ValidStartPoint(0)) {
        if (!SaveStartPointList(rootNode.AddChild(ToString(_T("startpoints")), false))) {
            return false;
        }
    }
    if (!SaveWayPointList(rootNode.AddChild(ToString(_T("waypoints")), false))) {
        return false;
    }

    int ContentSize = 0;
    LPCTSTR szContent = topNode.createXMLString(1, &ContentSize);
    Utf8File file;
    if (!file.Open(szFileName, Utf8File::io_create)) {
        return false;
    }

    file.WriteLn(szContent);
    file.Close();

    return true;
}