Example #1
0
void plAnimEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb)
{
    HWND hList = GetDlgItem(hWnd, IDC_EVENT_LIST);
    ListBox_ResetContent(hList);

    plAnimComponentBase* comp;
    plMaxNode* node;

    //
    // If we don't have a valid comp and node, we should be disabled
    //
    if (!GetCompAndNode(pb, (plComponentBase*&)comp, node))
    {
        EnableWindow(hList, FALSE);
        return;
    }
    else
        EnableWindow(hList, TRUE);

    //
    // Load the events
    //
    int idx;

    idx = ListBox_AddStringData(hList, "(Begin)", kAnimEventBegin);
    if (pb->GetInt(kAnimBegin))
        ListBox_SetSel(hList, TRUE, idx);

    idx = ListBox_AddStringData(hList, "(End)", kAnimEventEnd);
    if (pb->GetInt(kAnimEnd))
        ListBox_SetSel(hList, TRUE, idx);

    if (comp)
    {
        // Get the shared animations for all the nodes this component is applied to
        plNotetrackAnim anim(comp, nil);
        plAnimInfo info = anim.GetAnimInfo(comp->GetAnimName());

        RemoveDeadMarkers(pb, kAnimMarkers, info);

        // Get all the markers in this animation
        ST::string marker;
        while (!(marker = info.GetNextMarkerName()).is_empty())
        {
            idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker);

            if (IsMarkerSelected(pb, kAnimMarkers, marker))
                ListBox_SetSel(hList, TRUE, idx);
        }
    }
}
Example #2
0
plMessage* plResponderCmdAnim::ICreateSndMsg(plMaxNode* node, plErrorMsg *pErrMsg, IParamBlock2 *pb)
{
    plComponentBase *comp;
    plMaxNode *targNode;
    if (!GetCompAndNode(pb, node, comp, targNode))
        throw "A valid sound component and node were not found";

    int type = pb->GetInt(kRespAnimType);
    switch (type)
    {
        case kRespondPlaySound:
        case kRespondStopSound:
        case kRespondToggleSound:
        case kRespondRewindSound:
        case kRespondSyncedPlaySound:
        {
            if (!targNode->GetSceneObject())
                throw "Sound emitter didn't export";

            int soundIdx = plAudioComp::GetSoundModIdx(comp, targNode);

            // Changed 8.26.2001 mcn - The audioInterface should be the message receiver,
            // not the audible itself.
            const plAudioInterface *ai = targNode->GetSceneObject()->GetAudioInterface();
            plKey key = ai->GetKey();

            plSoundMsg* msg = new plSoundMsg;
            msg->AddReceiver(key);
            msg->fIndex = soundIdx;

            if (type == kRespondPlaySound)
                msg->SetCmd(plSoundMsg::kPlay);
            else if (type == kRespondStopSound)
                msg->SetCmd(plSoundMsg::kStop);
            else if (type == kRespondToggleSound)
                msg->SetCmd(plSoundMsg::kToggleState);
            else if (type == kRespondRewindSound)
            {
                msg->fTime = 0;
                msg->SetCmd(plSoundMsg::kGoToTime);
            }
            else if(type == kRespondSyncedPlaySound)
                msg->SetCmd(plSoundMsg::kSynchedPlay);

            if( plAudioComp::IsLocalOnly( comp ) )
                msg->SetCmd( plSoundMsg::kIsLocalOnly );

            return msg;
        }

        case kRespondPlayRndSound:
        case kRespondStopRndSound:
        case kRespondToggleRndSound:
        {
            plKey key = plAudioComp::GetRandomSoundKey(comp, targNode);
            if (key)
            {
                plAnimCmdMsg *msg = new plAnimCmdMsg;
                msg->AddReceiver(key);

                if (type == kRespondPlayRndSound)
                    msg->SetCmd(plAnimCmdMsg::kContinue);
                else if (type == kRespondStopRndSound)
                    msg->SetCmd(plAnimCmdMsg::kStop);
                else if (type == kRespondToggleRndSound)
                    msg->SetCmd(plAnimCmdMsg::kToggleState);

                return msg;
            }
        }
    }

    throw "Unknown sound command";
}
Example #3
0
plMessage *plResponderCmdAnim::ICreateAnimMsg(plMaxNode* node, plErrorMsg *pErrMsg, IParamBlock2 *pb)
{
    plAnimComponentBase *comp = nil;
    plMaxNode *targNode = nil;
    if (!GetCompAndNode(pb, node, (plComponentBase*&)comp, targNode))
        throw "A valid animation component and node were not found";

    // Get the anim modifier keys for all nodes this comp is attached to
    plKey animKey = comp->GetModKey(targNode);
    if (!animKey)
        throw "Animation component didn't convert";

    plAnimCmdMsg *msg = new plAnimCmdMsg;
    msg->AddReceiver(animKey);

    plString tempAnimName = comp->GetAnimName();
    msg->SetAnimName(tempAnimName);

    // Create and initialize a message for the command
    switch (pb->GetInt(kRespAnimType))
    {
    case kRespondPlayAnim:
        msg->SetCmd(plAnimCmdMsg::kContinue);
        break;
    case kRespondStopAnim:
        msg->SetCmd(plAnimCmdMsg::kStop);
        break;
    case kRespondToggleAnim:
        msg->SetCmd(plAnimCmdMsg::kToggleState);
        break;
    case kRespondSetForeAnim:
        msg->SetCmd(plAnimCmdMsg::kSetForewards);
        break;
    case kRespondSetBackAnim:
        msg->SetCmd(plAnimCmdMsg::kSetBackwards);
        break;
    case kRespondLoopAnimOn:
        {
            msg->SetCmd(plAnimCmdMsg::kSetLooping);
            // KLUDGE - We send the loop to play by name here, so anim grouped components
            // could have loops with different begin and end points.  However, apparently
            // that functionality was never implemented, whoops.  So, we'll take out the
            // stuff that actually tries to set the begin and end points for now, so that
            // anims with a loop set in advance will actually work with this. -Colin
//          msg->SetCmd(plAnimCmdMsg::kSetLoopBegin);
//          msg->SetCmd(plAnimCmdMsg::kSetLoopEnd);
            plString loopName = plString::FromUtf8(pb->GetStr(kAnimLoop));
            msg->SetLoopName(loopName);
        }
        break;
    case kRespondLoopAnimOff:
        msg->SetCmd(plAnimCmdMsg::kUnSetLooping);
        break;

    case kRespondRewindAnim:
        msg->SetCmd(plAnimCmdMsg::kGoToBegin);
        break;
    case kRespondFastForwardAnim:
        msg->SetCmd(plAnimCmdMsg::kGoToEnd);
        break;
    }

    return msg;
}