Ejemplo n.º 1
0
void FfbHandle_EffectOperation(USB_FFBReport_EffectOperation_Output_Data_t* data)
{
	if (data->operation == 1)
	{   // Start
		if(data->loopCount > 0) gEffectStates[data->effectBlockIndex].duration *= data->loopCount;
		if(data->loopCount==0xFF) gEffectStates[data->effectBlockIndex].duration = USB_DURATION_INFINITE;
		StartEffect(data->effectBlockIndex);
	}
	else if (data->operation == 2)
	{   // StartSolo

		// Stop all first
		StopAllEffects();

		// Then start the given effect
		StartEffect(data->effectBlockIndex);

	}
	else if (data->operation == 3)
	{   // Stop

		StopEffect(data->effectBlockIndex);
	}
	else
	{
	}
}
Ejemplo n.º 2
0
END_CLASS_STATES

/*
================
rvMonsterConvoyGround::State_Fall
================
*/
stateResult_t rvMonsterConvoyGround::State_Fall ( const stateParms_t& parms ) {
	enum {
		STAGE_INIT,			// Initialize fall stage
		STAGE_WAITIMPACT,	// Wait for the drop turret to hit the ground
		STAGE_IMPACT,		// Handle drop turret impact, switch to combat state
		STAGE_WAITDONE,
		STAGE_DONE
	};
	switch ( parms.stage ) {
		case STAGE_INIT:
			StopMove ( MOVE_STATUS_DONE );
			StopAnimState ( ANIMCHANNEL_LEGS );
			StopAnimState ( ANIMCHANNEL_TORSO );
			StartSound ( "snd_falling", SND_CHANNEL_VOICE, 0, false, NULL );
			PlayEffect ( "fx_droptrail", animator.GetJointHandle ( "origin" ), true );
			DisableAnimState ( ANIMCHANNEL_LEGS );
			PlayCycle ( ANIMCHANNEL_TORSO, "idle", 0 );
			oldOrigin = physicsObj.GetOrigin ( );
			return SRESULT_STAGE(STAGE_WAITIMPACT);
			
		case STAGE_WAITIMPACT:
			if ( physicsObj.HasGroundContacts ( ) ) {
				return SRESULT_STAGE(STAGE_IMPACT);
			}
			return SRESULT_WAIT;
			
		case STAGE_IMPACT:
			StopSound ( SND_CHANNEL_VOICE, false );
			StopEffect ( "fx_droptrail" );
			PlayEffect ( "fx_landing", GetPhysics()->GetOrigin(), (-GetPhysics()->GetGravityNormal()).ToMat3() );
			
			if ( (physicsObj.GetOrigin ( ) - oldOrigin).LengthSqr() > Square(128.0f) ) {
				PlayAnim ( ANIMCHANNEL_TORSO, "land", 0 );
				return SRESULT_STAGE ( STAGE_WAITDONE );
			}
			return SRESULT_STAGE ( STAGE_DONE );
			
		case STAGE_WAITDONE:
			if ( AnimDone ( ANIMCHANNEL_TORSO, 4 ) ) {
				return SRESULT_STAGE ( STAGE_DONE );
			}
			return SRESULT_WAIT;
		
		case STAGE_DONE:
			onGround = true;
			SetAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle" );
			SetAnimState ( ANIMCHANNEL_TORSO, "Torso_Idle" );
			return SRESULT_DONE;
	}
	return SRESULT_ERROR;
}
Ejemplo n.º 3
0
void ForceFeedbackDevice::TypedForce<P>::UpdateEffect(int magnitude)
{
  if (UpdateParameters(magnitude))
  {
    if (magnitude)
      PlayEffect();
    else
      StopEffect();
  }
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------------
// CUISiegeWarfareDoc::
// Explain:  
// Date : 2005-07-13,Author: Lee Ki-hwan
//------------------------------------------------------------------------------
void CUISiegeWarfareDoc::RestartEffect(int nZoneIndex)
{
	StopEffect( -1, TRUE );

	bool bJoinFlag = false;
	SBYTE sbJoinFlag = _pNetwork->MyCharacterInfo.sbJoinFlagMerac;

	if (nZoneIndex == 4)
	{
		bJoinFlag = true;
		sbJoinFlag = _pNetwork->MyCharacterInfo.sbJoinFlagDratan;
	}

	// Start Effect My Character
	StartEffect ( _pNetwork->MyCharacterInfo.index, CEntity::GetPlayerEntity(0), sbJoinFlag, _pNetwork->MyCharacterInfo.lGuildIndex );
	
	// Start My Guild, Enemy Guild Effect Start
	ACTORMGR()->RefreshSiegeWarfareEffect(bJoinFlag);
}
Ejemplo n.º 5
0
void InitRestartData(void)
{
	int			i;

	my_delete(lpMovie);
	lpSoundDS->FadeOut(voiceHandle);	
	selectWnd.selectEnd();
	msgWnd.MsgCLS();
	backColorBuf.clearColorBuf();
	bgInf.colorBuf.clearColorBuf();
	toneConvert.ClearTable();
	for(i=0;i<STCHAR_MAX;i++){
		charInf[i].Release();
	}
	for(i=0;i<STBMP_MAX;i++){
		setBmpInf[i].Release();
	}
	for(i=0;i<hEvtSndMax;i++) StopEffect(evtHandle[i]);
	cl_free(LangData.LangBuf);
	saveInf.Reset();
	SaveStruct.Reset();
	backLog.ClearLog();
}
Ejemplo n.º 6
0
void RPG_DestructibleEntity::SetDestroyed()
{
  m_isDestroyed = true;

  // remove the attackable component
  RPG_AttackableComponent* attackableComponent = static_cast<RPG_AttackableComponent*>(Components().GetComponentOfType(V_RUNTIME_CLASS(RPG_AttackableComponent)));
  if (attackableComponent)
  {
    RemoveComponent(attackableComponent);
  }

  vHavokRigidBody* rigidBodyComponent = static_cast<vHavokRigidBody*>(Components().GetComponentOfType(V_RUNTIME_CLASS(vHavokRigidBody)));
  if (rigidBodyComponent)
  {
    RemoveComponent(rigidBodyComponent);
  }

  // stop the ambient effect
  StopEffect(DEFX_Ambient);
  CreateEffect(DEFX_Destroy, GetPosition(), GetOrientation());

  // remove collision if so instructed
  //if (m_removeCollisionAfterDestruction)
  {
    RemoveObstacle();
  }

  if(!m_postDestructionMeshFilename.IsEmpty())
  {
    // swap the mesh
    SetMesh(m_postDestructionMeshFilename);
  }
  else
  {
    DisposeObject();
  }
}
Ejemplo n.º 7
0
/*
================
idExplodingBarrel::ExplodingEffects
================
*/
void idExplodingBarrel::ExplodingEffects( void ) {
	const char *temp;

	StartSound( "snd_explode", SND_CHANNEL_ANY, 0, false, NULL );

	temp = spawnArgs.GetString( "model_damage", "" );
	if ( temp && *temp ) {
		SetModel( temp );
		Show();
	}

// RAVEN BEGIN
// bdube: replaced with playing an effect
/*
	temp = spawnArgs.GetString( "mtr_lightexplode", "" );
	if ( temp && *temp ) {
		AddLight( temp, false );
	}
*/
	StopEffect ( "fx_burn" );
	gameLocal.PlayEffect ( gameLocal.GetEffect(spawnArgs, "fx_explode"), GetPhysics()->GetOrigin(), (-GetPhysics()->GetGravityNormal()).ToMat3(), false, vec3_origin, true );

	gameLocal.ProjectDecal( GetPhysics()->GetOrigin(), GetPhysics()->GetGravity(), 128.0f, true, 96.0f, "textures/decals/genericdamage" );
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_EntityFlame::ClientThink( void )
{
	StopEffect();
	Release();
}
Ejemplo n.º 9
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_EntityFlame::UpdateOnRemove( void )
{
	StopEffect();
	BaseClass::UpdateOnRemove();
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
C_EntityFlame::~C_EntityFlame( void )
{
	StopEffect();
}
Ejemplo n.º 11
0
/*
================
rvMonsterBerserker::State_Killed
================
*/
stateResult_t rvMonsterBerserker::State_Killed	( const stateParms_t& parms ) {
	StopEffect ( "fx_charge_up" );
	StopEffect ( "fx_ambient_electricity" );
	StopEffect ( "fx_ambient_electricity_mace" );
	return idAI::State_Killed ( parms );
}
Ejemplo n.º 12
0
/*
================
rvMonsterSlimyTransfer::OnDeath
================
*/
void rvMonsterSlimyTransfer::OnDeath ( void ) {
	StopEffect ( "fx_vomit_muzzle" );
	idAI::OnDeath ( );
}
Ejemplo n.º 13
0
/*
================
rvEffect::Think
================
*/
void rvEffect::Stop( bool destroyParticles ) {
    StopEffect ( effect, destroyParticles );
}
/*
================
rvMonsterStreamProtector::State_Torso_FinishPlasmaAttack
================
*/
stateResult_t rvMonsterStreamProtector::State_Torso_FinishPlasmaAttack ( const stateParms_t& parms ) {	
	StopEffect ( "fx_plasma_muzzle" );
	return SRESULT_DONE;
}
Ejemplo n.º 15
0
//---------------------------------------------------------
//---------------------------------------------------------
void CRumbleEffects::StartEffect( unsigned char effectIndex, unsigned char rumbleData, unsigned char rumbleFlags )
{
	if( effectIndex == RUMBLE_STOP_ALL )
	{
		StopAllEffects();
		return;
	}

	if( rumbleFlags & RUMBLE_FLAG_STOP )
	{
		StopEffect( effectIndex );
		return;
	}

	int priority = 1;
	RumbleChannel_t *pChannel = NULL;

	if( (rumbleFlags & RUMBLE_FLAG_RESTART) )
	{
		// Try to find any active instance of this effect and replace it.
		pChannel = FindExistingChannel( effectIndex );
	}

	if( (rumbleFlags & RUMBLE_FLAG_ONLYONE) )
	{
		pChannel = FindExistingChannel( effectIndex );

		if( pChannel )
		{
			// Bail out. An instance of this effect is already playing.
			return;
		}
	}

	if( (rumbleFlags & RUMBLE_FLAG_UPDATE_SCALE) )
	{
		pChannel = FindExistingChannel( effectIndex );
		if( pChannel )
		{
			pChannel->scale = ((float)rumbleData) / 100.0f;
		}

		// It's possible to return without finding a rumble to update.
		// This means you tried to update a rumble you never started.
		return;
	}

	if( !pChannel )
	{
		pChannel = FindAvailableChannel( priority );
	}

	if( pChannel )
	{
		pChannel->waveformIndex = effectIndex;
		pChannel->priority = 1;
		pChannel->starttime = gpGlobals->curtime;
		pChannel->in_use = true;
		pChannel->rumbleFlags = rumbleFlags;

		if( rumbleFlags & RUMBLE_FLAG_INITIAL_SCALE )
		{
			pChannel->scale = ((float)rumbleData) / 100.0f;
		}
		else
		{
			pChannel->scale = 1.0f;
		}
	}

	if( (rumbleFlags & RUMBLE_FLAG_RANDOM_AMPLITUDE) )
	{
		pChannel->scale = random->RandomFloat( 0.1f, 1.0f );
	}
}
Ejemplo n.º 16
0
Archivo: command.c Proyecto: ihbar/fpp
char *ProcessCommand(char *command, char *response)
{
    char *s;
    char *s2;
    char *s3;
    char *s4;
    char *response2 = NULL;
    int i;
    char NextPlaylist[128] = "No playlist scheduled.";
    char NextScheduleStartText[64] = "";
    char CommandStr[64];
    LogExcess(VB_COMMAND, "CMD: %s\n", command);
    s = strtok(command,",");
    strcpy(CommandStr, s);
    if (!strcmp(CommandStr, "s")) {
        scheduler->GetNextScheduleStartText(NextScheduleStartText);
        scheduler->GetNextPlaylistText(NextPlaylist);
        if(FPPstatus==FPP_STATUS_IDLE) {
            if (getFPPmode() == REMOTE_MODE) {
                int secsElapsed = 0;
                int secsRemaining = 0;
                char seqFilename[1024];
                char mediaFilename[1024];

                if (sequence->IsSequenceRunning()) {
                    strcpy(seqFilename, sequence->m_seqFilename);
                    secsElapsed = sequence->m_seqSecondsElapsed;
                    secsRemaining = sequence->m_seqSecondsRemaining;
                } else {
                    strcpy(seqFilename, "");
                }

                if (mediaOutput) {
                    strcpy(mediaFilename, mediaOutput->m_mediaFilename.c_str());
                    secsElapsed = mediaOutputStatus.secondsElapsed;
                    secsRemaining = mediaOutputStatus.secondsRemaining;
                } else {
                    strcpy(mediaFilename, "");
                }

                sprintf(response,"%d,%d,%d,%s,%s,%d,%d\n",
                        getFPPmode(), 0, getVolume(), seqFilename,
                        mediaFilename, secsElapsed, secsRemaining);
            } else if (sequence->IsSequenceRunning()) {
                sprintf(response,"%d,%d,%d,,,%s,,0,0,%d,%d,%s,%s,0\n",
                        getFPPmode(),
                        1,
                        getVolume(),
                        sequence->m_seqFilename,
                        sequence->m_seqSecondsElapsed,
                        sequence->m_seqSecondsRemaining,
                        NextPlaylist,
                        NextScheduleStartText);
            } else {
                sprintf(response,"%d,%d,%d,%s,%s\n",getFPPmode(),0,getVolume(),NextPlaylist,NextScheduleStartText);
            }
        } else {
            Json::Value pl = playlist->GetInfo();
            if (pl["currentEntry"].isMember("dynamic"))
                pl["currentEntry"] = pl["currentEntry"]["dynamic"];

            if ((pl["currentEntry"]["type"] == "both") ||
                (pl["currentEntry"]["type"] == "media")) {
                //printf(" %s\n", pl.toStyledString().c_str());
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    pl["currentEntry"]["type"].asString() == "both" ? pl["currentEntry"]["sequence"]["sequenceName"].asString().c_str() : "",
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["mediaFilename"].asString().c_str()
                        : pl["currentEntry"]["mediaFilename"].asString().c_str() ,
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["secondsElapsed"].asInt()
                        : pl["currentEntry"]["secondsElapsed"].asInt(),
                    pl["currentEntry"]["type"].asString() == "both"
                        ? pl["currentEntry"]["media"]["secondsRemaining"].asInt()
                        : pl["currentEntry"]["secondsRemaining"].asInt(),
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            } else if (pl["currentEntry"]["type"] == "sequence") {
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    pl["currentEntry"]["sequenceName"].asString().c_str(),
                    "",
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    sequence->m_seqSecondsElapsed,
                    sequence->m_seqSecondsRemaining,
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            } else {
                sprintf(response,"%d,%d,%d,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
                    getFPPmode(),
                    FPPstatus,
                    getVolume(),
                    pl["name"].asString().c_str(),
                    pl["currentEntry"]["type"].asString().c_str(),
                    "",
                    "",
//							pl["currentEntry"]["entryID"].asInt() + 1,
                    playlist->GetPosition(),
                    pl["size"].asInt(),
                    pl["currentEntry"]["type"].asString() == "pause" ? pl["currentEntry"]["duration"].asInt() - pl["currentEntry"]["remaining"].asInt() : 0,
                    pl["currentEntry"]["type"].asString() == "pause" ? pl["currentEntry"]["remaining"].asInt() : 0,
                    NextPlaylist,
                    NextScheduleStartText,
                    pl["repeat"].asInt());
            }
        }
    } else if ((!strcmp(CommandStr, "P")) || (!strcmp(CommandStr, "p"))) {
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");

        int entry = 0;
        if (s2 && s2[0])
            entry = atoi(s2);

        if (s)
        {
            int repeat = strcmp(CommandStr, "p") ? 0 : 1;
            int scheduledRepeat = 0;
            std::string playlistName = scheduler->GetPlaylistThatShouldBePlaying(scheduledRepeat);

            if ((playlistName == s) && (repeat == scheduledRepeat)) {
                // Use CheckIfShouldBePlayingNow() so the scheduler knows when
                // to stop the playlist
                scheduler->CheckIfShouldBePlayingNow(1);
                sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
            } else if (playlist->Play(s, entry, repeat, 0)) {
                FPPstatus = FPP_STATUS_PLAYLIST_PLAYING;
                sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		    } else {
                sprintf(response,"%d,%d,Error Starting Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
            }
        } else {
            sprintf(response,"%d,%d,Unknown Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if ((!strcmp(CommandStr, "S")) ||
               (!strcmp(CommandStr, "StopGracefully"))) {
        if (FPPstatus==FPP_STATUS_PLAYLIST_PLAYING) {
            playlist->StopGracefully(1);
            scheduler->ReLoadCurrentScheduleInfo();
            sprintf(response,"%d,%d,Playlist Stopping Gracefully,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,Not playing,,,,,,,,,,,\n",COMMAND_FAILED);
        }
    } else if ((!strcmp(CommandStr, "d")) ||
               (!strcmp(CommandStr, "StopNow"))) {
        if (FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY) {
            playlist->StopNow(1);
            scheduler->ReLoadCurrentScheduleInfo();
            sprintf(response,"%d,%d,Playlist Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else if ((FPPstatus == FPP_STATUS_IDLE) &&
                   (sequence->IsSequenceRunning())) {
            sequence->CloseSequenceFile();
            sprintf(response,"%d,%d,Sequence Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,%d,Not playing,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "R")) {
        scheduler->ReLoadNextScheduleInfo();
        if (FPPstatus==FPP_STATUS_IDLE) {
            scheduler->ReLoadCurrentScheduleInfo();
            scheduler->CheckIfShouldBePlayingNow();
        }
        sprintf(response,"%d,%d,Reloading Schedule,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
    } else if (!strcmp(CommandStr, "v")) {
        s = strtok(NULL,",");
        if (s) {
            setVolume(atoi(s));
            sprintf(response,"%d,%d,Setting Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
        } else {
            sprintf(response,"%d,%d,Invalid Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "q")) {
        // Quit/Shutdown fppd
        if ((FPPstatus == FPP_STATUS_PLAYLIST_PLAYING) ||
            (FPPstatus == FPP_STATUS_STOPPING_GRACEFULLY)) {
            playlist->StopNow(1);
            sleep(2);
        }

        ShutdownFPPD();

        sleep(1);
    } else if (!strcmp(CommandStr, "e")) {
        // Start an Effect
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        s3 = strtok(NULL,",");
        if (s && s2) {
            i = StartEffect(s, atoi(s2), atoi(s3));
            if (i >= 0)
                sprintf(response,"%d,%d,Starting Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
            else
                sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        } else
            sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "t")) {
        // Trigger an event
        s = strtok(NULL,",");
        pluginCallbackManager.eventCallback(s, "command");
        i = TriggerEventByID(s);
        if (i >= 0)
            sprintf(response,"%d,%d,Event Triggered,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
        else
            sprintf(response,"%d,%d,Event Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "GetTestMode")) {
        strcpy(response, channelTester->GetConfig().c_str());
        strcat(response, "\n");
    } else if (!strcmp(CommandStr, "SetTestMode")) {
        if (channelTester->SetupTest(std::string(s + strlen(s) + 1)))
        {
            sprintf(response, "0,%d,Test Mode Activated,,,,,,,,,\n",
                COMMAND_SUCCESS);
        } else {
            sprintf(response, "0,%d,Test Mode Deactivated,,,,,,,,,\n",
                COMMAND_SUCCESS);
        }
    } else if (!strcmp(CommandStr, "LogLevel")) {
        s = strtok(NULL,",");

        if (SetLogLevel(s)) {
            sprintf(response,"%d,%d,Log Level Updated,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
        } else {
            sprintf(response,"%d,%d,Error Updating Log Level,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_FAILED,logLevel,logMask);
        }
    } else if (!strcmp(CommandStr, "LogMask")) {
        s = strtok(NULL,",");

        if ((s && SetLogMask(s)) || SetLogMask("")) {
            sprintf(response,"%d,%d,Log Mask Updated,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
        } else {
            sprintf(response,"%d,%d,Error Updating Log Mask,%d,%d,,,,,,,,,\n",
                getFPPmode(),COMMAND_FAILED,logLevel,logMask);
        }
    } else if (!strcmp(CommandStr, "SetSetting")) {
        char name[128];

        s = strtok(NULL,",");
        if (s) {
            strcpy(name, s);
            s = strtok(NULL,",");
            if (s)
                parseSetting(name, s);
        }
    } else if (!strcmp(CommandStr, "StopAllEffects")) {
        StopAllEffects();
        sprintf(response,"%d,%d,All Effects Stopped,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
    } else if (!strcmp(CommandStr, "StopEffectByName")) {
        s = strtok(NULL,",");
        if (strlen(s)) {
            if (StopEffect(s))
                sprintf(response,"%d,%d,Stopping Effect,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,s);
            else
                sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
        }
    } else if (!strcmp(CommandStr, "StopEffect")) {
        s = strtok(NULL,",");
        i = atoi(s);
        if (StopEffect(i))
            sprintf(response,"%d,%d,Stopping Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
        else
            sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
    } else if (!strcmp(CommandStr, "GetRunningEffects")) {
        sprintf(response,"%d,%d,Running Effects",getFPPmode(),COMMAND_SUCCESS);
        GetRunningEffects(response, &response2);
    } else if (!strcmp(CommandStr, "GetFPPDUptime")) {
        sprintf(response,"%d,%d,FPPD Uptime,%ld,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS, time(NULL) - fppdStartTime);
    } else if (!strcmp(CommandStr, "StartSequence")) {
        if ((FPPstatus == FPP_STATUS_IDLE) &&
            (!sequence->IsSequenceRunning())) {
            s = strtok(NULL,",");
            s2 = strtok(NULL,",");
            if (s && s2) {
                i = atoi(s2);
                sequence->OpenSequenceFile(s, 0, i);
            } else {
                LogDebug(VB_COMMAND, "Invalid command: %s\n", command);
            }
        } else {
            LogErr(VB_COMMAND, "Tried to start a sequence when a playlist or "
                    "sequence is already running\n");
        }
    } else if (!strcmp(CommandStr, "StopSequence")) {
        if ((FPPstatus == FPP_STATUS_IDLE) &&
            (sequence->IsSequenceRunning())) {
            sequence->CloseSequenceFile();
        } else {
            LogDebug(VB_COMMAND,
                "Tried to stop a sequence when no sequence is running\n");
        }
    } else if (!strcmp(CommandStr, "ToggleSequencePause")) {
        if ((sequence->IsSequenceRunning()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->ToggleSequencePause();
        }
    } else if (!strcmp(CommandStr, "SingleStepSequence")) {
        if ((sequence->IsSequenceRunning()) &&
            (sequence->SequenceIsPaused()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->SingleStepSequence();
        }
    } else if (!strcmp(CommandStr, "SingleStepSequenceBack")) {
        if ((sequence->IsSequenceRunning()) &&
            (sequence->SequenceIsPaused()) &&
            ((FPPstatus == FPP_STATUS_IDLE) ||
             ((FPPstatus != FPP_STATUS_IDLE) &&
              (playlist->GetInfo()["currentEntry"]["type"] == "sequence")))) {
            sequence->SingleStepSequenceBack();
        }
    } else if (!strcmp(CommandStr, "NextPlaylistItem")) {
        switch (FPPstatus)
        {
            case FPP_STATUS_IDLE:
                sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
                break;
            case FPP_STATUS_PLAYLIST_PLAYING:
                sprintf(response,"%d,%d,Skipping to next playlist item\n",getFPPmode(),COMMAND_SUCCESS);
                playlist->NextItem();
                break;
            case FPP_STATUS_STOPPING_GRACEFULLY:
                sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
                break;
        }
    } else if (!strcmp(CommandStr, "PrevPlaylistItem")) {
        switch (FPPstatus) {
            case FPP_STATUS_IDLE:
                sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
                break;
            case FPP_STATUS_PLAYLIST_PLAYING:
                sprintf(response,"%d,%d,Skipping to previous playlist item\n",getFPPmode(),COMMAND_SUCCESS);
                playlist->PrevItem();
                break;
            case FPP_STATUS_STOPPING_GRACEFULLY:
                sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
                break;
        }
    } else if (!strcmp(CommandStr, "SetupExtGPIO")) {
        // Configure the given GPIO to the given mode
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        if (s && s2)
        {
            
            if (!SetupExtGPIO(atoi(s), s2))
            {
                sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2);
            } else {
                sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2);
            }
        }
    } else if (!strcmp(CommandStr, "ExtGPIO")) {
        s = strtok(NULL,",");
        s2 = strtok(NULL,",");
        s3 = strtok(NULL,",");
        if (s && s2 && s3)
        {
            i = ExtGPIO(atoi(s), s2, atoi(s3));
            if (i >= 0)
            {
                sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,%d,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2,atoi(s3),i);
            } else {
                sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2,atoi(s3));
            }
        }
    } else {
        sprintf(response,"Invalid command: '%s'\n", CommandStr);
    }

    return response2;
}
Ejemplo n.º 17
0
/*
================
rvMonsterSlimyTransfer::State_Frame_StopVomit
================
*/
stateResult_t rvMonsterSlimyTransfer::State_Frame_StopVomit ( const stateParms_t& parms ) {	
	StopEffect ( "fx_vomit_muzzle" );
	vomitNextAttackTime = 0;
	return SRESULT_DONE;
}
/*
================
rvMonsterStreamProtector::State_Torso_PlasmaAttack
================
*/
stateResult_t rvMonsterStreamProtector::State_Torso_PlasmaAttack ( const stateParms_t& parms ) {	
	enum {
		STAGE_START,
		STAGE_START_WAIT,
		STAGE_FIRE,
		STAGE_INITIALFIRE_WAIT,
		STAGE_FIRE_WAIT,
		STAGE_END,
		STAGE_END_WAIT,
	};	
	switch ( parms.stage ) {
		case STAGE_START:
			DisableAnimState ( ANIMCHANNEL_LEGS );

			// Loop the flame animation
			PlayAnim( ANIMCHANNEL_TORSO, "range_plasma_start", parms.blendFrames );

			// Make sure we clean up some things when this state is finished (effects for one)			
			PostAnimState ( ANIMCHANNEL_TORSO, "Torso_FinishPlasmaAttack", 0, 0, SFLAG_ONCLEAR );
			
			return SRESULT_STAGE ( STAGE_START_WAIT );
		
		case STAGE_START_WAIT:
			if ( AnimDone ( ANIMCHANNEL_TORSO, 0 ) ) {
				return SRESULT_STAGE ( STAGE_FIRE );
			}
			return SRESULT_WAIT;

		case STAGE_FIRE:
			attackEndTime = gameLocal.time + 500;
			attackNextTime = gameLocal.time;
			
			// Flame effect
			PlayEffect ( "fx_plasma_muzzle", jointPlasmaMuzzle, true );
			
			PlayCycle ( ANIMCHANNEL_TORSO, "range_plasma_fire", 0 );
			
			return SRESULT_STAGE ( STAGE_INITIALFIRE_WAIT );

		case STAGE_INITIALFIRE_WAIT:
			if ( gameLocal.time > attackEndTime ) {
				attackEndTime = gameLocal.time + SEC2MS ( 1.0f + gameLocal.random.RandomFloat ( ) * 4.0f );
				return SRESULT_STAGE ( STAGE_FIRE_WAIT );
			}
			// Launch another attack?
			if ( gameLocal.time >= attackNextTime ) {
				Attack ( "plasma", jointPlasmaMuzzle, enemy.ent );
				attackNextTime = gameLocal.time + plasmaAttackRate;
			}
			return SRESULT_WAIT;
			
		case STAGE_FIRE_WAIT:
			// If we have been using plasma too long or havent seen our enemy for at least half a second then
			// stop now.
			if ( gameLocal.time > attackEndTime || gameLocal.time - enemy.lastVisibleTime > 500 || (IsEnemyVisible() && !enemy.fl.inFov) ) {
				StopEffect ( "fx_plasma_muzzle" );
				return SRESULT_STAGE ( STAGE_END );
			}
			// Launch another attack?
			if ( gameLocal.time >= attackNextTime  ) {
				Attack ( "plasma", jointPlasmaMuzzle, enemy.ent );
				attackNextTime = gameLocal.time + plasmaAttackRate;
			}
			return SRESULT_WAIT;
				
		case STAGE_END:
			// End animations
			PlayAnim( ANIMCHANNEL_TORSO, "range_plasma_end", parms.blendFrames );			
			return SRESULT_STAGE ( STAGE_END_WAIT );
		
		case STAGE_END_WAIT:
			if ( AnimDone ( ANIMCHANNEL_TORSO, 0 ) ) {
				return SRESULT_DONE;
			}
			return SRESULT_WAIT;						
	}

	return SRESULT_ERROR;
}
Ejemplo n.º 19
0
Archivo: command.c Proyecto: dkulp/fpp
  void ProcessCommand(char *command)
  {
    char *s;
    char *s2;
    char *s3;
    char *s4;
    char *response2 = NULL;
    int i;
		char NextPlaylist[128] = "No playlist scheduled.";
		char NextScheduleStartText[64] = "";
		char CommandStr[64];
		LogExcess(VB_COMMAND, "CMD: %s\n", command);
		s = strtok(command,",");
		strcpy(CommandStr, s);
		if (!strcmp(CommandStr, "s"))
		{
				Json::Value info = player->GetCurrentPlaylistInfo();
				char currentEntryType = 'u'; // Unknown
				const char *currentSequenceName = NULL;
				const char *currentMediaName = NULL;

				if (info["currentEntry"].isMember("sequenceName"))
					currentSequenceName = info["currentEntry"]["sequenceName"].asString().c_str();

				if (info["currentEntry"].isMember("mediaFilename"))
					currentMediaName = info["currentEntry"]["mediaFilename"].asString().c_str();

				if (info["currentEntry"].isMember("type"))
				{
					std::string type = info["currentEntry"]["type"].asString();
					if (type == "both")
						currentEntryType = 'b';
					else if (type == "event")
						currentEntryType = 'e';
					else if (type == "media")
						currentEntryType = 'm';
					else if (type == "pause")
						currentEntryType = 'p';
					else if (type == "plugin")
						currentEntryType = 'P';
					else if (type == "sequence")
						currentEntryType = 's';
				}

				player->GetNextScheduleStartText(NextScheduleStartText);
				player->GetNextPlaylistText(NextPlaylist);
				if(FPPstatus==FPP_STATUS_IDLE)
				{
					if (getFPPmode() == REMOTE_MODE)
					{
						sprintf(response,"%d,%d,%d,%s,%s,%d,%d\n",
							getFPPmode(), 0, getVolume(),
							currentSequenceName,
							currentMediaName,
							player->GetPlaybackSecondsElapsed(),
							player->GetPlaybackSecondsRemaining());
					}
					else
					{
						sprintf(response,"%d,%d,%d,%s,%s\n",
							getFPPmode(),0,getVolume(),
							NextPlaylist,NextScheduleStartText);
					}
				}
				else
				{
					sprintf(response,"%d,%d,%d,%s,%c,%s,%s,%d,%d,%d,%d,%s,%s,%d\n",
							getFPPmode(),FPPstatus,getVolume(),
							info["name"].asString().c_str(),
							currentEntryType,
							currentSequenceName,
							currentMediaName,
							info["currentPosition"].asInt() + 1,
							info["size"].asInt(),
							info["currentEntry"]["secondsElapsed"].asInt(),
							info["currentEntry"]["secondsRemaining"].asInt(),
							NextPlaylist,NextScheduleStartText,
							info["repeat"].asInt());
				}
		}
		else if ((!strcmp(CommandStr, "p")) ||
				 (!strcmp(CommandStr, "P")))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY)
				{
					player->PlaylistStopNow();
					sleep(1);
				}
	
				s = strtok(NULL,",");
				if (s)
				{
					std::string playlistName(s);
					int repeat = !strcmp(CommandStr, "p") ? 1 : 0;
					int position = 0;

					s = strtok(NULL,",");
					if (s)
						position = atoi(s);

					if (player->PlaylistStart(playlistName, position, repeat))
					{
						sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
					}
					else
					{
						sprintf(response,"%d,%d,Playlist Start Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
					}
				}
				else
				{
					sprintf(response,"%d,%d,Unknown Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "S"))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING)
				{
					player->PlaylistStopGracefully();
					player->ReLoadCurrentScheduleInfo();
					sprintf(response,"%d,%d,Playlist Stopping Gracefully,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,Not playing,,,,,,,,,,,\n",COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "d"))
		{
				if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY)
				{
					player->PlaylistStopNow();
					player->ReLoadCurrentScheduleInfo();
					sprintf(response,"%d,%d,Playlist Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,%d,Not playing,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "R"))
		{
				if(FPPstatus==FPP_STATUS_IDLE)
				{
					player->ReLoadCurrentScheduleInfo();
				}
				player->ReLoadNextScheduleInfo();
				
				
				sprintf(response,"%d,%d,Reloading Schedule,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		}
		else if (!strcmp(CommandStr, "v"))
		{
				s = strtok(NULL,",");
				if (s)
				{
					setVolume(atoi(s));
					sprintf(response,"%d,%d,Setting Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
				}
				else
				{
					sprintf(response,"%d,%d,Invalid Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
				}
		}
		else if (!strcmp(CommandStr, "w"))
		{
				LogInfo(VB_SETTING, "Sending Falcon hardware config\n");
				if (!DetectFalconHardware(1))
					SendFPDConfig();
		}
		else if (!strcmp(CommandStr, "r"))
		{
				WriteBytesReceivedFile();
				sprintf(response,"true\n");
		}
		else if (!strcmp(CommandStr, "q"))
		{
			// Quit/Shutdown fppd
			ShutdownFPPD();
		}
		else if (!strcmp(CommandStr, "e"))
		{
			// Start an Effect
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			s3 = strtok(NULL,",");
			if (s && s2)
			{
				i = StartEffect(s, atoi(s2), atoi(s3));
				if (i >= 0)
					sprintf(response,"%d,%d,Starting Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
				else
					sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
			else
				sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "t"))
		{
			// Trigger an event
			s = strtok(NULL,",");
			pluginCallbackManager.eventCallback(s, "command");
			i = TriggerEventByID(s);
			if (i >= 0)
				sprintf(response,"%d,%d,Event Triggered,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
			else
				sprintf(response,"%d,%d,Event Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "GetTestMode"))
		{
			strcpy(response, channelTester->GetConfig().c_str());
			strcat(response, "\n");
		}
		else if (!strcmp(CommandStr, "SetTestMode"))
		{
			if (channelTester->SetupTest(std::string(s + strlen(s) + 1)))
			{
				sprintf(response, "0,%d,Test Mode Activated,,,,,,,,,\n",
					COMMAND_SUCCESS);
			}
			else
			{
				sprintf(response, "0,%d,Test Mode Deactivated,,,,,,,,,\n",
					COMMAND_SUCCESS);
			}
		}
		else if (!strcmp(CommandStr, "LogLevel"))
		{
			s = strtok(NULL,",");

			if (SetLogLevel(s)) {
				sprintf(response,"%d,%d,Log Level Updated,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
			} else {
				sprintf(response,"%d,%d,Error Updating Log Level,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_FAILED,logLevel,logMask);
			}
		}
		else if (!strcmp(CommandStr, "LogMask"))
		{
			s = strtok(NULL,",");

			if ((s && SetLogMask(s)) || SetLogMask("")) {
				sprintf(response,"%d,%d,Log Mask Updated,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_SUCCESS,logLevel,logMask);
			} else {
				sprintf(response,"%d,%d,Error Updating Log Mask,%d,%d,,,,,,,,,\n",
					getFPPmode(),COMMAND_FAILED,logLevel,logMask);
			}
		}
		else if (!strcmp(CommandStr, "SetSetting"))
		{
			char name[128];

			s = strtok(NULL,",");
			if (s)
			{
				strcpy(name, s);
				s = strtok(NULL,",");
				if (s)
					parseSetting(name, s);
			}
		}
		else if (!strcmp(CommandStr, "StopAllEffects"))
		{
			StopAllEffects();
			sprintf(response,"%d,%d,All Effects Stopped,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
		}
		else if (!strcmp(CommandStr, "StopEffectByName"))
		{
			s = strtok(NULL,",");
			if (strlen(s))
			{
				if (StopEffect(s))
						sprintf(response,"%d,%d,Stopping Effect,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,s);
				else
						sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "StopEffect"))
		{
			s = strtok(NULL,",");
			i = atoi(s);
			if (StopEffect(i))
					sprintf(response,"%d,%d,Stopping Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i);
			else
					sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
		}
		else if (!strcmp(CommandStr, "GetRunningEffects"))
		{
			sprintf(response,"%d,%d,Running Effects",getFPPmode(),COMMAND_SUCCESS);
			GetRunningEffects(response, &response2);
		}
		else if (!strcmp(CommandStr, "ReloadChannelRemapData"))
		{
			if ((FPPstatus==FPP_STATUS_IDLE) &&
				(LoadChannelRemapData())) {
				sprintf(response,"%d,%d,Channel Remap Data Reloaded,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS);
			} else {
				sprintf(response,"%d,%d,Failed to reload Channel Remap Data,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "GetFPPDUptime"))
		{
			sprintf(response,"%d,%d,FPPD Uptime,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS, time(NULL) - fppdStartTime);
		}
		else if (!strcmp(CommandStr, "StartSequence"))
		{
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			if (s && s2)
			{
				i = atoi(s2);
				player->StartSequence(s, 0, i);
				sprintf(response,"%d,%d,Sequence Started,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_SUCCESS);
			}
			else
			{
				LogErr(VB_COMMAND, "Tried to start a sequence when a playlist or "
						"sequence is already running\n");
				sprintf(response,"%d,%d,Sequence Failed,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "StopSequence"))
		{
			s = strtok(NULL,",");
			if (s)
			{
				player->StopSequence(s);
				sprintf(response,"%d,%d,Sequence Stopped,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_SUCCESS);
			}
			else
			{
				LogDebug(VB_COMMAND, "Invalid command: %s\n", command);
				sprintf(response,"%d,%d,Sequence Name Missing,,,,,,,,,,,,\n",
					getFPPmode(), COMMAND_FAILED);
			}
		}
		else if (!strcmp(CommandStr, "ToggleSequencePause"))
		{
			if ((player->SequencesRunning()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 (FPPstatus != FPP_STATUS_IDLE)))
			{
				player->ToggleSequencePause();
			}
		}
		else if (!strcmp(CommandStr, "SingleStepSequence"))
		{
			if ((player->SequencesRunning()) &&
				(player->SequencesArePaused()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 ((FPPstatus != FPP_STATUS_IDLE))))
			{
				player->SingleStepSequences();
			}
		}
		else if (!strcmp(CommandStr, "SingleStepSequenceBack"))
		{
			if ((player->SequencesRunning()) &&
				(player->SequencesArePaused()) &&
				((FPPstatus == FPP_STATUS_IDLE) ||
				 ((FPPstatus != FPP_STATUS_IDLE))))
			{
				player->SingleStepSequencesBack();
			}
		}
		else if (!strcmp(CommandStr, "NextPlaylistItem"))
		{
			switch (FPPstatus)
			{
				case FPP_STATUS_IDLE:
					sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
					break;
				case FPP_STATUS_PLAYLIST_PLAYING:
					sprintf(response,"%d,%d,Skipping to next playlist item\n",getFPPmode(),COMMAND_SUCCESS);
					player->NextPlaylistItem();
					break;
				case FPP_STATUS_STOPPING_GRACEFULLY:
					sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
					break;
			}
		}
		else if (!strcmp(CommandStr, "PrevPlaylistItem"))
		{
			switch (FPPstatus)
			{
				case FPP_STATUS_IDLE:
					sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED);
					break;
				case FPP_STATUS_PLAYLIST_PLAYING:
					sprintf(response,"%d,%d,Skipping to previous playlist item\n",getFPPmode(),COMMAND_SUCCESS);
					player->PrevPlaylistItem();
					break;
				case FPP_STATUS_STOPPING_GRACEFULLY:
					sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED);
					break;
			}
		}
		else if (!strcmp(CommandStr, "SetupExtGPIO"))
		{
			// Configure the given GPIO to the given mode
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			if (s && s2)
			{
				
				if (!SetupExtGPIO(atoi(s), s2))
				{
					sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2);
				}
				else
				{
					sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2);
				}
			}
		}
		else if (!strcmp(CommandStr, "ExtGPIO"))
		{
			s = strtok(NULL,",");
			s2 = strtok(NULL,",");
			s3 = strtok(NULL,",");
			if (s && s2 && s3)
			{
				i = ExtGPIO(atoi(s), s2, atoi(s3));
				if (i >= 0) 
				{
					sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,%d,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2,atoi(s3),i);
				}
				else
				{
					sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2,atoi(s3));
				}
			}
		}
		else
		{
			sprintf(response,"Invalid command: '%s'\n", CommandStr);
		}

		if (response2)
		{
			bytes_sent = sendto(socket_fd, response2, strlen(response2), 0,
                          (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un));
			LogDebug(VB_COMMAND, "%s %s", CommandStr, response2);
			free(response2);
			response2 = NULL;
		}
		else
		{
			bytes_sent = sendto(socket_fd, response, strlen(response), 0,
                          (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un));
			LogDebug(VB_COMMAND, "%s %s", CommandStr, response);
		}
  }
Ejemplo n.º 20
0
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void ManagerImplemented::GCDrawSet( bool isRemovingManager )
{
	// インスタンスグループ自体の削除処理
	{
		std::map<Handle,DrawSet>::iterator it = m_RemovingDrawSets[1].begin();
		while( it != m_RemovingDrawSets[1].end() )
		{
			DrawSet& drawset = (*it).second;

			// 全破棄処理
			drawset.InstanceContainerPointer->RemoveForcibly( true );
			drawset.InstanceContainerPointer->~InstanceContainer();
			InstanceContainer::operator delete( drawset.InstanceContainerPointer, this );
			ES_SAFE_RELEASE( drawset.ParameterPointer );
			ES_SAFE_DELETE( drawset.GlobalPointer );

			if(m_cullingWorld != NULL)
			{
				m_cullingWorld->RemoveObject(drawset.CullingObjectPointer);
				Culling3D::SafeRelease(drawset.CullingObjectPointer);
			}

			m_RemovingDrawSets[1].erase( it++ );
		}
		m_RemovingDrawSets[1].clear();
	}

	{
		std::map<Handle,DrawSet>::iterator it = m_RemovingDrawSets[0].begin();
		while( it != m_RemovingDrawSets[0].end() )
		{
			DrawSet& drawset = (*it).second;
			m_RemovingDrawSets[1][ (*it).first ] = (*it).second;
			m_RemovingDrawSets[0].erase( it++ );
		}
		m_RemovingDrawSets[0].clear();
	}

	{
		std::map<Handle,DrawSet>::iterator it = m_DrawSets.begin();
		while( it != m_DrawSets.end() )
		{
			DrawSet& draw_set = (*it).second;

			// 削除フラグが立っている時
			bool isRemoving = draw_set.IsRemoving;

			// 何も存在しない時
			if( !isRemoving && draw_set.GlobalPointer->GetInstanceCount() == 0 )
			{
				isRemoving = true;
			}

			// ルートのみ存在し、既に新しく生成する見込みがないとき
			if( !isRemoving && draw_set.GlobalPointer->GetInstanceCount() == 1 )
			{
				InstanceContainer* pRootContainer = draw_set.InstanceContainerPointer;
				InstanceGroup* group = pRootContainer->GetFirstGroup();

				if( group )
				{
					Instance* pRootInstance = group->GetFirst();

					if( pRootInstance && pRootInstance->GetState() == INSTANCE_STATE_ACTIVE )
					{
						int maxcreate_count = 0;
						for( int i = 0; i < Min(pRootInstance->m_pEffectNode->GetChildrenCount(), Instance::ChildrenMax); i++ )
						{
							auto child = (EffectNodeImplemented*) pRootInstance->m_pEffectNode->GetChild(i);

							float last_generation_time = 
								child->CommonValues.GenerationTime.max *
								(child->CommonValues.MaxGeneration - 1) +
								child->CommonValues.GenerationTimeOffset.max +
								1.0f;

							if( pRootInstance->m_LivingTime >= last_generation_time )
							{
								maxcreate_count++;
							}
							else
							{
								break;
							}
						}
					
						if( maxcreate_count == pRootInstance->m_pEffectNode->GetChildrenCount() )
						{
							// 音が再生中でないとき
							if (!GetSoundPlayer() || !GetSoundPlayer()->CheckPlayingTag(draw_set.GlobalPointer))
							{
								isRemoving = true;
							}
						}
					}
				}
			}

			if( isRemoving )
			{
				// 消去処理
				StopEffect( (*it).first );

				if( (*it).second.RemovingCallback != NULL )
				{
					(*it).second.RemovingCallback( this, (*it).first, isRemovingManager );
				}

				m_RemovingDrawSets[0][ (*it).first ] = (*it).second;
				m_DrawSets.erase( it++ );
			}
			else
			{
				++it;
			}			
		}
	}
}
Ejemplo n.º 21
0
int Title()
{
	#define WORD_SIZE 20
    #define CMOVE 40
	#define TITLE_TIP 350
    #define TITLE_END TITLE_TIP + CMOVE * 2
    
    int TitleGraph; //タイトルグラフィックハンドル
    int CursorGraph; //カーソルグラフィックハンドル
    
    int TutorialGraph[9];
       
    int Color;
    
    //キー関係-------
    int Key;
    int BeforeInput;
    int UpInput;
    int DownInput;
    //--------------
    
    int CursorX; 
    int CursorY;
    
	TitleMusic = LoadSoundMem("sound/Title.ogg");//タイトルBGM
	LevelSelectMusic = LoadSoundMem("sound/levelselect.ogg");
	
	EnterSound = LoadSoundMem("sound/decide.wav");
    SelectSound = LoadSoundMem("sound/select.wav");
    CancelSound = LoadSoundMem("sound/cancel.wav");
    
    TitleGraph = LoadGraph("graphic/Title.png");
    CursorGraph = LoadGraph("graphic/handicon.png");
    
    LoadDivGraph("graphic/chip.png", 10, 2, 5, 32, 32, TutorialGraph); 
    
    Color = GetColor(0, 0, 0);
    
    SetFontSize(WORD_SIZE);
    
    //カーソル位置の初期化
    CursorX = 165;
    CursorY = TITLE_TIP;
    
    SetDrawScreen(DX_SCREEN_BACK);
    
    	    PlayEffectLoop(TitleMusic);

    
    

    while(ProcessMessage()==0 && CheckHitKey(KEY_INPUT_ESCAPE) ==0)
    {
	    ClsDrawScreen();
	    
	     
	    BeforeInput = Key;
	    
	    Key = GetJoypadInputState(DX_INPUT_KEY_PAD1);
	    
	    UpInput = ~Key & BeforeInput;
	    DownInput = Key & ~BeforeInput;
	    
	    if(DownInput & PAD_INPUT_UP)
	    {
	       CursorY -= CMOVE;
	       
	       PlayEffect(SelectSound);
	    }
	 
	    if(DownInput & PAD_INPUT_DOWN)
	    {
	       CursorY += CMOVE;
	       PlayEffect(SelectSound);
	    }
	 
	    if(CursorY<=TITLE_TIP) 
	    {
	       CursorY = TITLE_TIP;
	       
	         if(DownInput & PAD_INPUT_A)
	         {
	             StopEffect(TitleMusic);
	             
	             PlayEffect(EnterSound);
	             
	             PlayEffectLoop(LevelSelectMusic);
	                          
	             LevelSelect();
	             
	             return 0;
	             
	         } 
    
	    }
	    
	    if(CursorY == TITLE_TIP + CMOVE)
	    {
	        if(DownInput & PAD_INPUT_A)
	        {
	        	PlayEffect(EnterSound);
	        	
	        	return Tutorial();
	        }
	    }
	    
	 
	    if(CursorY>=TITLE_END)
	    {
	        CursorY = TITLE_END;
	    
	          if(DownInput & PAD_INPUT_A)
	          {
	             StopEffect(TitleMusic);
	             
	             exit(0);
	          }
	    }
	    
         DrawGraph(0, 0, TitleGraph, TRUE);
         
         DrawGraph(CursorX, CursorY, CursorGraph, TRUE);
             
         //画面の表示
         ScreenFlip();
         
    }
}    
Ejemplo n.º 22
0
int LevelSelect()
{
	#define CMOVE 214
	#define LEVEL_TIP  3
	#define LEVEL_END  431
		
	#define MENU_X 2	
	#define MENU_Y 380
	
	int Color;
	
	int SelectGraph;
	
	int CursorGraph;
	
	int CursorX;
	int CursorY;
	
	Color = GetColor(0,0,0);
	
	CursorGraph = LoadGraph("graphic/LevelSelect_C.png");
	SelectGraph = LoadGraph("graphic/LevelSelect.png");
	
	CursorX = MENU_X;
	CursorY = 61;
	
	SetDrawScreen(DX_SCREEN_BACK);
	
	while(ProcessMessage()==0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0)
    {
    	int Key;
    	int BeforeInput;
    	int UpInput;
    	int DownInput;
    	
    	BeforeInput = Key;
    	
    	Key = GetJoypadInputState(DX_INPUT_KEY_PAD1); 
    	
    	UpInput = ~Key & BeforeInput;
    	DownInput = Key & ~BeforeInput;
    	
    	ClsDrawScreen();
    	
    	DrawGraph(0, 0, SelectGraph, TRUE);
    	
    	DrawGraph(CursorX, CursorY, CursorGraph, TRUE);	
    	
    	if(DownInput & PAD_INPUT_B)
    	{
    		PlayEffect(CancelSound);
    		StopEffect(LevelSelectMusic);
    		 Title();
    	}
    	
    	if(DownInput & PAD_INPUT_LEFT)
    	{
    		CursorX -= CMOVE;
    		PlayEffect(SelectSound);
    	}
    	
    	if(DownInput & PAD_INPUT_RIGHT)
    	{
    		CursorX += CMOVE;
    		PlayEffect(SelectSound);
    	} 
    	
    	if(CursorX == LEVEL_TIP)
    	{
    		if(DownInput & PAD_INPUT_A)
    		{	             
    			PlayEffect(EnterSound);
    			
    			StopEffect(LevelSelectMusic);
    			
    			LevelEasy();
    			
    			ActMain();
    			
    			return 0;
    		}
    	}
    	
    	if(CursorX == LEVEL_TIP + CMOVE)
    	{
	             
    		if(DownInput & PAD_INPUT_A)
    		{
    			PlayEffect(EnterSound);
    			
    			StopEffect(LevelSelectMusic);
    			
    			LevelNormal();
    			
    			ActMain();
    			
    			return 0;
    		}
    	}
    	
    	if(CursorX == LEVEL_TIP + CMOVE*2)
    	{
    		
    		if(DownInput & PAD_INPUT_A)
    		{
    		 	PlayEffect(EnterSound);

	    		StopEffect(LevelSelectMusic);

    			LevelHard();
    			
    			ActMain();
    			
    			return 0;
    		}
    	}
    	
    	if(CursorX < LEVEL_TIP)
    	{
    		CursorX = LEVEL_TIP;
    	}
    	
    	if(CursorX > LEVEL_END)
    	{
    		CursorX = LEVEL_END;
    	}

    	ScreenFlip();
    }
}
Ejemplo n.º 23
0
int Tutorial(void)
{
    int Color;
    int MovingGraph;//操作方法グラフィック
    int PItemExplainGraph;//プラスアイテム説明グラフィック
    int MItemExplainGraph;//マイナスアイテム説明グラフィック
    int GameGraph;//ゲーム画面説明グラフィック
    int WordBeforeGameGraph;//ゲーム画面前文字グラフィック
    int GameRuleGraph;//ゲームグラフィック説明グラフィック
    int ScoreExGraph; //スコア計算方法説明グラフィック
    
    int PageUpSound; //ページ進み音
    int PageDownSound; //ページ戻り音
    
     //キー関係-------
    int Key;
    int BeforeInput;
    int UpInput;
    int DownInput;
    //--------------
    
    int tutorialcounter;//ゲーム画面の出す順
    
    Color = GetColor(255,255,255);
    
    MovingGraph = LoadGraph("graphic/moving.png");
    PItemExplainGraph = LoadGraph("graphic/ItemExplain(Plus).png");
    MItemExplainGraph = LoadGraph("graphic/ItemExplain(Minus).png");
    GameGraph = LoadGraph("graphic/GameScreen.png");
    WordBeforeGameGraph = LoadGraph("graphic/GameExplain(Word).png");
    GameRuleGraph = LoadGraph("graphic/GameRule.png");
    ScoreExGraph = LoadGraph("graphic/Score.png");
    
    PageUpSound = LoadSoundMem("sound/pageup.wav");
    PageDownSound = LoadSoundMem("sound/pagedown.wav");
    
    tutorialcounter = 0;
    
    SetDrawScreen(DX_SCREEN_BACK);
    
    while(ProcessMessage()==0 && CheckHitKey(KEY_INPUT_ESCAPE)==0)
    {
       BeforeInput = Key;
    	
       Key = GetJoypadInputState(DX_INPUT_KEY_PAD1); 
    	
       UpInput = ~Key & BeforeInput;
       DownInput = Key & ~BeforeInput;
       
       ClsDrawScreen();

       if(DownInput & PAD_INPUT_A)
       {
        	tutorialcounter++; 
        	PlayEffect(PageUpSound);
        	WaitTimer(50);
       }
       
       if(DownInput & PAD_INPUT_B)
       {
           tutorialcounter--;
           PlayEffect(PageDownSound);
           WaitTimer(50);
       }
       
       if(tutorialcounter < 0)
       {
          PlayEffect(CancelSound);
          
          StopEffect(TitleMusic);

           Title();
       }
       
       if(tutorialcounter > 6)
       {
       		StopEffect(TitleMusic);

       		Title();
       }
       
       switch(tutorialcounter)
       {
       		case 0:
       		{
       		   DrawGraph(0, 0, MovingGraph, TRUE);
       		   break;
       		}
       		
       		case 1:
       		{
       		   DrawGraph(0, 0, WordBeforeGameGraph, TRUE);
       		    break;
       		}
       		
       		case 2:
       		{
       		   DrawGraph(0, 0,GameGraph, TRUE);
       		    break;
       		}
       		
       		case 3:
       		{
       			DrawGraph(0, 0,ScoreExGraph, TRUE);
       			break;
       		}
       		
       		case 4:
       		{
       		    DrawGraph(0, 0,PItemExplainGraph, TRUE);   
       		     break;
       		}
       		
       		case 5:
       		{
       		    DrawGraph(0, 0,MItemExplainGraph, TRUE);
       		     break;

       		}
       		
       		case 6:
       		{
       		    DrawGraph(0, 0,GameRuleGraph, TRUE);
       		    break;

       		}
       		
       }
       
       ScreenFlip();
       
    }
}
Ejemplo n.º 24
0
void StopAllEffects(void)
{
	for (uint8_t id = 0; id <= MAX_EFFECTS; id++)
	StopEffect(id);
}
Ejemplo n.º 25
0
/*
================
rvMonsterBerserker::State_Torso_Pain
================
*/
stateResult_t rvMonsterBerserker::State_Torso_Pain ( const stateParms_t& parms ) {
	StopEffect ( "fx_charge_up" );
	return idAI::State_Torso_Pain ( parms );
}