bool AndroidAnimation::checkIterationsAndProgress(double time, float* finalProgress)
{
    float progress = currentProgress(time);

    int currentIteration = static_cast<int>(progress);
    if (currentIteration != m_currentIteration)
        if (m_direction == Animation::AnimationDirectionAlternate)
            swapDirection();

    m_currentIteration = currentIteration;
    progress -= m_currentIteration;

    if ((m_currentIteration >= m_iterationCount)
          && (m_iterationCount != Animation::IterationCountInfinite))
        return false;

    if (m_timingFunction.type() != LinearTimingFunction) {
        UnitBezier bezier(m_timingFunction.x1(),
                          m_timingFunction.y1(),
                          m_timingFunction.x2(),
                          m_timingFunction.y2());
        if (m_duration > 0)
            progress = bezier.solve(progress, 1.0f / (200.0f * m_duration));
    }

    *finalProgress = progress;
    return true;
}
Example #2
0
float Con_GetProgress(void)
{
    float prog;

    if(!progressMax) return 1.0f;

    lockProgress(true);
    prog = currentProgress();
    lockProgress(false);

    prog /= (float) progressMax;

    // Scale to the progress range.
    return progressStart + prog * (progressEnd - progressStart);
}
Example #3
0
void Con_SetProgress(int progress)
{
    timespan_t nowTime;

    lockProgress(true);

    // Continue animation from the current value.
    nowTime = Timer_RealSeconds();
    last.value = currentProgress();
    last.time = nowTime;

    target.value = progress;
    target.time = nowTime + (progress < progressMax? PROGRESS_DELTA_TIME : PROGRESS_DELTA_TIME/2);

    lockProgress(false);
}
Example #4
0
void BlinkParser::parseXml()
{
    while (!m_reader->atEnd()) {
        switch(m_reader->readNext()) {
        case QXmlStreamReader::StartElement:
            if (m_reader->name().endsWith(QStringLiteral("db_id"))) {
                state = State::ID;
            } else if (m_reader->name() == QStringLiteral("series_image")) {
                state = State::ImgLink;
            } else if (m_reader->name() == QStringLiteral("myinfo")) {
                m_atUserInfo = true;
            } else if (m_atUserInfo) {
                // here we rip off the total progress that we need
                if (m_reader->name() == QStringLiteral("user_watching")
                        || m_reader->name() == QStringLiteral("user_reading")
                        || m_reader->name() == QStringLiteral("user_completed")
                        || m_reader->name() == QStringLiteral("user_onhold")
                        || m_reader->name() == QStringLiteral("user_dropped")
                        || m_reader->name() == QStringLiteral("user_plantowatch")
                        || m_reader->name() == QStringLiteral("user_plantoread")) {
                    m_total += m_reader->readElementText().toInt();
                }
            } else if (m_reader->name() == "error") {
                emit writingError(m_reader->readElementText());
                return;
            }
            break;
        case QXmlStreamReader::Characters:
            if (state == State::ID) {
                m_currentId += m_reader->text();
            } else if (state == State::ImgLink) {
                m_currentImgLink += m_reader->text();
            }
        case QXmlStreamReader::EndElement:
            if (m_reader->name().endsWith(QStringLiteral("db_id"))
                || m_reader->name() == QStringLiteral("series_image")) {
                state = State::Nothing;
            }
            if (m_reader->name() == QStringLiteral("anime")
                || m_reader->name() == QStringLiteral("manga")) {
                emit write(m_currentId, m_currentImgLink);
                emit currentProgress(++m_current);
                m_currentId.clear();
                m_currentImgLink.clear();
            }
            if (m_reader->name() == QStringLiteral("myinfo")) {
                m_atUserInfo = false;
                emit totalCount(m_total);
            }
            break;
        case QXmlStreamReader::EndDocument:
            m_reply->deleteLater();
            m_reply = nullptr;
            emit writingFinished();
        default:
            break;
        }
    }
    if (Q_UNLIKELY(m_reader->hasError()
                   && m_reader->error()
                    != QXmlStreamReader::PrematureEndOfDocumentError)) {
        emit writingError(m_reader->errorString());
        m_reply->abort();
        m_reply->deleteLater();
        m_reply = nullptr;
    }
}