コード例 #1
0
ファイル: animatecompile.cpp プロジェクト: calband/calchart
AnimateCommands
AnimateCompile::Compile(
    const Show& show, AnimationVariables& variablesStates,
    AnimationErrors& errors, Show::const_Sheet_iterator_t c_sheet,
    unsigned pt_num, SYMBOL_TYPE cont_symbol,
    std::list<std::unique_ptr<ContProcedure>> const& procs)
{
    AnimateState state{
        c_sheet->GetPosition(pt_num),
        c_sheet->GetBeats(),
        variablesStates,
        errors,
    };

    AnimateCompile ac(show, cont_symbol, pt_num, c_sheet, state);

    if (procs.empty()) {
        // no continuity was specified
        auto s = c_sheet + 1;
        for (; s != show.GetSheetEnd(); ++s) {
            if (s->IsInAnimation()) {
                // use EVEN REM NP
                ContProcEven defcont(new ContValueFloat(state.beats_rem),
                    new ContNextPoint());
                defcont.Compile(ac);
                break;
            }
        }
        if (s == show.GetSheetEnd()) {
            // use MTRM E
            ContProcMTRM defcont(new ContValueDefined(CC_E));
            defcont.Compile(ac);
        }
    }

    for (auto& proc : procs) {
        proc->Compile(ac);
    }

    if ((c_sheet + 1) != show.GetSheetEnd()) {
        auto next_point = (c_sheet + 1)->GetPosition(pt_num);
        if (state.pt != next_point) {
            auto c = next_point - state.pt;
            ac.RegisterError(ANIMERR_WRONGPLACE, NULL);
            ac.Append(std::make_shared<AnimateCommandMove>(state.beats_rem, c), NULL);
        }
    }
    if (state.beats_rem) {
        ac.RegisterError(ANIMERR_EXTRATIME, NULL);
        ac.Append(std::make_shared<AnimateCommandMT>(state.beats_rem, ANIMDIR_E), NULL);
    }
    return state.cmds;
}
コード例 #2
0
ファイル: animatecompile.cpp プロジェクト: calband/calchart
AnimatePoint AnimateCompile::GetEndingPosition(const ContToken* token) const
{
    auto sheet = curr_sheet + 1;

    while (1) {
        if (sheet == mShow.GetSheetEnd()) {
            RegisterError(ANIMERR_UNDEFINED, token);
            return GetPointPosition();
        }
        if (sheet->IsInAnimation()) {
            return sheet->GetPosition(GetCurrentPoint());
        }
        ++sheet;
    }
}
コード例 #3
0
ファイル: animate.cpp プロジェクト: superoven/calchart
Animation::Animation(const CC_show& show, NotifyStatus notifyStatus, NotifyErrorList notifyErrorList)
    : numpts(show.GetNumPoints()), pts(numpts), curr_cmds(numpts),
      curr_sheetnum(0),
      mCollisionAction(NULL)
{
    // the variables are persistant through the entire compile process.
    AnimationVariables variablesStates;

    for (auto curr_sheet = show.GetSheetBegin(); curr_sheet != show.GetSheetEnd(); ++curr_sheet)
    {
        if (!curr_sheet->IsInAnimation()) continue;

// Now parse continuity
        AnimateCompile comp(show, variablesStates);
        std::vector<std::vector<std::shared_ptr<AnimateCommand> > > theCommands(numpts);
        for (auto& current_symbol : k_symbols)
        {
            if (curr_sheet->ContinuityInUse(current_symbol))
            {
                auto& current_continuity = curr_sheet->GetContinuityBySymbol(current_symbol);
                std::string tmpBuffer(current_continuity.GetText());
                yyinputbuffer = tmpBuffer.c_str();
                if (notifyStatus)
                {
                    std::string message("Compiling \"");
                    message += curr_sheet->GetName().substr(0,32);
                    message += ("\" ");
                    message += GetNameForSymbol(current_symbol).substr(0,32);
                    message += ("...");
                    notifyStatus(message);
                }
                // parse out the error
                if (parsecontinuity() != 0)
                {
                    // Supply a generic parse error
                    ContToken dummy;
                    comp.RegisterError(ANIMERR_SYNTAX, &dummy);
                }
                for (unsigned j = 0; j < numpts; j++)
                {
                    if (curr_sheet->GetPoint(j).GetSymbol() == current_symbol)
                    {
                        theCommands[j] = comp.Compile(curr_sheet, j, current_symbol, ParsedContinuity);
                    }
                }
                while (ParsedContinuity)
                {
                    ContProcedure* curr_proc = ParsedContinuity->next;
                    delete ParsedContinuity;
                    ParsedContinuity = curr_proc;
                }
            }
        }
// Handle points that don't have continuity (shouldn't happen)
        if (notifyStatus)
        {
            std::string message("Compiling \"");
            message += curr_sheet->GetName().substr(0,32);
            message += ("\"...");
            notifyStatus(message);
        }
        for (unsigned j = 0; j < numpts; j++)
        {
            if (theCommands[j].empty())
            {
                theCommands[j] = comp.Compile(curr_sheet, j, MAX_NUM_SYMBOLS, NULL);
            }
        }
        if (!comp.Okay() && notifyErrorList)
        {
            std::string message("Errors for \"");
            message += curr_sheet->GetName().substr(0,32);
            message += ("\"");
            if (notifyErrorList(comp.GetErrorMarkers(), std::distance(show.GetSheetBegin(), curr_sheet), message))
            {
                break;
            }
        }
        std::vector<AnimatePoint> thePoints(numpts);
        for (unsigned i = 0; i < numpts; i++)
        {
            thePoints.at(i) = curr_sheet->GetPosition(i);
        }
        AnimateSheet new_sheet(thePoints, theCommands, curr_sheet->GetName(), curr_sheet->GetBeats());
        sheets.push_back(new_sheet);
    }
}