bool SDLEntity2D::LoadFrame ( std::string Name, std::string TexName, std::string MaskName, int FrameDelay, int x, int y, SGZCOLOUR ColourKey ) { /// Load up a Texture into an Animation SListIterator<SGZAnimGroup2D*> AnimListITR = AnimList.GetIterator(); for( AnimListITR.Start(); AnimListITR.Valid(); AnimListITR.Forth() ) if((AnimListITR.Item()->AnimName.compare(Name))==0) { SGZAnimFrame2D *Frame = new SGZAnimFrame2D; Frame->TextureName = TexName; Frame->MaskName = "none"; Frame->delay = FrameDelay; Frame->u = x; Frame->v = y; Frame->colkey = ColourKey; AnimListITR.Item()->FrameList.Append(Frame); AnimListITR.Item()->AnimNum++; AnimListITR.Item()->FrameITR = AnimListITR.Item()->FrameList.GetIterator(); if(!SGZInterpret.accessServer()->World()->accessTextureManager()->CheckExist(TexName)) SGZLogger.warn("Texture %s has not been loaded yet.. make sure it is before calling this frame!", TexName.c_str()); return true; } SGZLogger.warn("Animation \"%s\" does not exist!\n",Name.c_str()); return false; }
bool SDLAudio::DestroyInterface(void) { /** Destroy a client interface */ SListIterator<SGZMusic*> MusicListITR = MusicList.GetIterator(); MusicListITR.Start(); while (MusicListITR.Valid()) { Mix_FreeMusic(MusicListITR.Item()->Data); MusicList.Remove(MusicListITR); MusicListITR.Forth(); } SListIterator<SGZSound*> SFXListITR = SFXList.GetIterator(); SFXListITR.Start(); while (SFXListITR.Valid()) { Mix_FreeChunk(SFXListITR.Item()->Data); SFXList.Remove(SFXListITR); SFXListITR.Forth(); } Mix_CloseAudio(); return true; }
std::string MEntity::CheckVar ( std::string Name, std::string VarName ) { SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) return EntityListITR.Item()->CheckVar(VarName); SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return "none"; }
void CInterpret::NextEvent( void ) { SListIterator<IEvent*> EventListITR = EventList.GetIterator(); for( EventListITR.Start(); EventListITR.Valid(); EventListITR.Forth() ) { if(EventListITR.Item()->doEvent()) EventListITR.Item()->handled(true); } CleanEvents(); }
std::string SDLEntity2D::CheckVar( std::string Name ) { SListIterator<SGZVarGroup*> VarITR = VarList.GetIterator(); for( VarITR.Start(); VarITR.Valid(); VarITR.Forth() ) if((VarITR.Item()->Name.compare(Name))==0) return VarITR.Item()->Variable; return "none"; }
std::string MEntity::GetAnimation( std::string Name ) { /** Return the current X Position */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) return EntityListITR.Item()->GetAnimation(); SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return "none"; }
SGZSCALER MEntity::GetDepth ( std::string Name ) { /** Return the current width */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) return EntityListITR.Item()->GetDepth(); SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return 0; }
bool MEntity::DeleteAnimation( std::string Name, std::string AnimName ) { SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->DeleteAnimation( AnimName ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::MoveTo ( std::string Name, SGZVECTOR vector ) { /** Move to direct co-ordinates */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->MoveTo( vector ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::ChangeVar ( std::string Name, std::string VarName, std::string Value ) { SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->ChangeVar(VarName, Value); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::SetDepth ( std::string Name, SGZSCALER value ) { SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->SetDepth( value ); return false; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::MoveDeltaZ ( std::string Name, SGZVECTORVAL amount ) { SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->MoveDeltaZ( amount ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
int SDLAudio::FadeInSFX( std::string SFXName, int time, int loops, int channel) { /** Play SFX */ SListIterator<SGZSound*> SFXListITR = SFXList.GetIterator(); for( SFXListITR.Start(); SFXListITR.Valid(); SFXListITR.Forth() ) if((SFXListITR.Item()->Name.compare(SFXName))==0) { return Mix_FadeInChannel(channel, SFXListITR.Item()->Data, loops, time); } SGZLogger.warn("AudioMAN: Can't find SFX \"%s\" to Fade In!\n", SFXName.c_str()); return -1; }
bool MEntity::LoadFrame ( std::string Name, std::string AnimName, std::string TexName, std::string MaskName, int FrameDelay, int u, int v, SGZCOLOUR ColourKey ) { /** Load up a Texture into an Animation*/ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->LoadFrame( AnimName, TexName, MaskName, FrameDelay, u, v, ColourKey ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::SetCollisionGeom ( std::string Name, int type ) { /** Set the collision type */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->SetCollisionGeom( type ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::Stop ( std::string Name ) { /** Stop moving/rotating/scaling immediately */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->Stop( ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
bool MEntity::LookTo ( std::string Name, SGZVECTOR vector ) { /** Direction to look at ( move towards ) */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) { EntityListITR.Item()->LookTo( vector ); return true; } SGZLogger.warn("Entity %s does not exist!\n", Name.c_str()); return false; }
int SDLAudio::NewestGROUP(std::string name) { /** Check to see if we've created it */ SListIterator<SGZChanGroup*> GroupListITR = GroupList.GetIterator(); for( GroupListITR.Start(); GroupListITR.Valid(); GroupListITR.Forth() ) if((GroupListITR.Item()->Name.compare(name))==0) { return Mix_GroupNewer(GroupListITR.Item()->groupNum); } SGZLogger.warn("AudioMAN: Group \"%s\" doesn't exist!\n", name.c_str()); return 0; }
bool SDLAudio::FadeInMUS( std::string MUSName, int time, int loops) { /** Play Music */ SListIterator<SGZMusic*> MusicListITR = MusicList.GetIterator(); for( MusicListITR.Start(); MusicListITR.Valid(); MusicListITR.Forth() ) if((MusicListITR.Item()->Name.compare(MUSName))==0) { Mix_FadeInMusic(MusicListITR.Item()->Data, loops, time); return true; } SGZLogger.warn("AudioMAN: Can't find MUS \"%s\" to Fade In!\n", MUSName.c_str()); return false; }
bool SDLAudio::FadeGROUP(std::string name, int time) { /** Check to see if we've created it */ SListIterator<SGZChanGroup*> GroupListITR = GroupList.GetIterator(); for( GroupListITR.Start(); GroupListITR.Valid(); GroupListITR.Forth() ) if((GroupListITR.Item()->Name.compare(name))==0) { Mix_FadeOutGroup(GroupListITR.Item()->groupNum, time); return true; } SGZLogger.warn("AudioMAN: Group \"%s\" doesn't exist!\n", name.c_str()); return false; }
bool SDLAudio::GroupCHANS(int from, int to, std::string name) { /** Check to see if we've created it */ SListIterator<SGZChanGroup*> GroupListITR = GroupList.GetIterator(); for( GroupListITR.Start(); GroupListITR.Valid(); GroupListITR.Forth() ) if((GroupListITR.Item()->Name.compare(name))==0) { Mix_GroupChannels(from, to, GroupListITR.Item()->groupNum); return true; } SGZLogger.warn("AudioMAN: Group \"%s\" doesn't exist!\n", name.c_str()); return false; }
bool SDLEntity2D::ChangeVar ( std::string Name, std::string Value ) { /** Load up a Texture into an Animation*/ SListIterator<SGZVarGroup*> VarITR = VarList.GetIterator(); for( VarITR.Start(); VarITR.Valid(); VarITR.Forth() ) if((VarITR.Item()->Name.compare(Name))==0) { VarITR.Item()->Variable = Value; return true; } SGZLogger.warn("Variable \"%s\" does not exist!\n",Name.c_str()); return false; }
bool SDLAudio::PlayMUS( std::string MUSName, int loops ) { /** Play Music */ SListIterator<SGZMusic*> MusicListITR = MusicList.GetIterator(); for( MusicListITR.Start(); MusicListITR.Valid(); MusicListITR.Forth() ) if((MusicListITR.Item()->Name.compare(MUSName))==0) { Mix_PlayMusic(MusicListITR.Item()->Data, loops); SGZLogger.debug("AudioMAN: Playing %s, %d times\n", MUSName.c_str(), loops); return true; } SGZLogger.warn("AudioMAN: Can't find MUS \"%s\" to play! Is it loaded?\n", MUSName.c_str()); return false; }
bool SDLAudio::LoadSFXFile( std::string Filename, std::string SFXName ) { /** Check to see if we've already loaded it */ SListIterator<SGZSound*> SFXListITR = SFXList.GetIterator(); for( SFXListITR.Start(); SFXListITR.Valid(); SFXListITR.Forth() ) if((SFXListITR.Item()->Name.compare(SFXName))==0) { SGZLogger.debug("AudioMAN: SFX \"%s\" already loaded!\n", SFXName.c_str()); return false; } /** Load a sound effect to play */ SGZLogger.debug("AudioMAN: Loading SFX \"%s\" as %s\n", Filename.c_str(), SFXName.c_str()); SGZSound *Effect; Effect = new SGZSound; Effect->Name = SFXName; Effect->Data = Mix_LoadWAV(Filename.c_str()); if(Effect->Data == NULL) { SGZLogger.warn("AudioMAN: Failed to load SFX: %s\n", Filename.c_str()); delete Effect; return false; } else SFXList.Append(Effect); return true; }
bool SDLAudio::LoadMUSFile( std::string Filename, std::string MUSName ) { /** Check to see if we've already loaded it */ SListIterator<SGZMusic*> MusicListITR = MusicList.GetIterator(); for( MusicListITR.Start(); MusicListITR.Valid(); MusicListITR.Forth() ) if((MusicListITR.Item()->Name.compare(MUSName))==0) { SGZLogger.debug("AudioMAN: SFX: %s already loaded!\n", MUSName.c_str()); return false; } /** Load a music to play */ SGZLogger.debug("AudioMAN: Loading MUS: %s as %s\n", Filename.c_str(), MUSName.c_str()); SGZMusic *Music; Music = new SGZMusic; Music->Name = MUSName; Music->Data = Mix_LoadMUS(Filename.c_str()); if(Music->Data == NULL) { SGZLogger.warn("AudioMAN: Failed to load MUS: %s\n", Filename.c_str()); delete Music; return false; } else MusicList.Append(Music); return true; }
bool SDLAudio::RemoveSFX( std::string SFXName ) { /** Remove sound effect */ SListIterator<SGZSound*> SFXListITR = SFXList.GetIterator(); for( SFXListITR.Start(); SFXListITR.Valid(); SFXListITR.Forth() ) if((SFXListITR.Item()->Name.compare(SFXName))==0) { Mix_FreeChunk(SFXListITR.Item()->Data); SFXList.Remove(SFXListITR); return true; } SGZLogger.warn("AudioMAN: Can't find SFX \"%s\" to unload!\n", SFXName.c_str()); return false; }
bool SDLAudio::RemoveMUS( std::string MUSName ) { /** Remove Music */ SGZLogger.debug("AudioMAN: Removing %s\n", MUSName.c_str()); SListIterator<SGZMusic*> MusicListITR = MusicList.GetIterator(); for( MusicListITR.Start(); MusicListITR.Valid(); MusicListITR.Forth() ) if((MusicListITR.Item()->Name.compare(MUSName))==0) { Mix_FreeMusic(MusicListITR.Item()->Data); MusicList.Remove(MusicListITR); return true; } SGZLogger.warn("AudioMAN: Can't find MUS \"%s\" to unload!\n", MUSName.c_str()); return false; }
bool MEntity::UpdateEntities( void ) { /** Update Entities */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) EntityListITR.Item()->Update(); return true; }
void CInterpret::CleanEvents( void ) { SListIterator<IEvent*> EventListITR = EventList.GetIterator(); for( EventListITR.Start(); EventListITR.Valid(); EventListITR.Forth() ) { if(EventListITR.Item()->handled(false)) EventList.Remove(EventListITR); } }
bool MEntity::CheckExist(std::string Name) { /** Check an Entity */ SListIterator<IEntity*> EntityListITR = EntityList.GetIterator(); for( EntityListITR.Start(); EntityListITR.Valid(); EntityListITR.Forth() ) if(EntityListITR.Item()->GetName().compare(Name)==0) return true; return false; }