Sound enum refactoring
* rename Sound -> SoundType * add parsing string to SoundTypemaster
parent
c84ce92a86
commit
9b232ee3f5
|
@ -195,6 +195,7 @@ set(BASE_SOURCES
|
||||||
script/script.cpp
|
script/script.cpp
|
||||||
script/scriptfunc.cpp
|
script/scriptfunc.cpp
|
||||||
sound/sound.cpp
|
sound/sound.cpp
|
||||||
|
sound/sound_type.cpp
|
||||||
ui/button.cpp
|
ui/button.cpp
|
||||||
ui/check.cpp
|
ui/check.cpp
|
||||||
ui/color.cpp
|
ui/color.cpp
|
||||||
|
|
|
@ -3814,7 +3814,7 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
|
void CParticle::Play(SoundType sound, Math::Vector pos, float amplitude)
|
||||||
{
|
{
|
||||||
if (m_sound == nullptr)
|
if (m_sound == nullptr)
|
||||||
m_sound = CApplication::GetInstancePointer()->GetSound();
|
m_sound = CApplication::GetInstancePointer()->GetSound();
|
||||||
|
|
|
@ -365,7 +365,7 @@ protected:
|
||||||
//! Seeks if an object collided with a ray
|
//! Seeks if an object collided with a ray
|
||||||
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father);
|
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father);
|
||||||
//! Sounded one
|
//! Sounded one
|
||||||
void Play(Sound sound, Math::Vector pos, float amplitude);
|
void Play(SoundType sound, Math::Vector pos, float amplitude);
|
||||||
//! Moves a drag; returns true if the drag is finished
|
//! Moves a drag; returns true if the drag is finished
|
||||||
bool TrackMove(int i, Math::Vector pos, float progress);
|
bool TrackMove(int i, Math::Vector pos, float progress);
|
||||||
//! Draws a drag
|
//! Draws a drag
|
||||||
|
|
|
@ -192,7 +192,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
||||||
type == PT_EXPLOT ||
|
type == PT_EXPLOT ||
|
||||||
type == PT_EXPLOW )
|
type == PT_EXPLOW )
|
||||||
{
|
{
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
if ( m_power )
|
if ( m_power )
|
||||||
{
|
{
|
||||||
sound = SOUND_EXPLOp;
|
sound = SOUND_EXPLOp;
|
||||||
|
|
|
@ -1615,7 +1615,7 @@ bool CMotionHuman::EventFrame(const Event &event)
|
||||||
if ( legAction == MH_MARCH ||
|
if ( legAction == MH_MARCH ||
|
||||||
legAction == MH_MARCHTAKE )
|
legAction == MH_MARCHTAKE )
|
||||||
{
|
{
|
||||||
Sound sound[2];
|
SoundType sound[2];
|
||||||
float synchro, volume[2], freq[2], hard;
|
float synchro, volume[2], freq[2], hard;
|
||||||
|
|
||||||
float speedX = m_physics->GetLinMotionX(MO_REASPEED);
|
float speedX = m_physics->GetLinMotionX(MO_REASPEED);
|
||||||
|
|
|
@ -824,7 +824,7 @@ bool CMotionToto::EventFrame(const Event &event)
|
||||||
|
|
||||||
Error CMotionToto::SetAction(int action, float time)
|
Error CMotionToto::SetAction(int action, float time)
|
||||||
{
|
{
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
|
|
||||||
CMotion::SetAction(action, time);
|
CMotion::SetAction(action, time);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "object/object_interface_type.h"
|
#include "object/object_interface_type.h"
|
||||||
#include "object/old_object_interface.h"
|
#include "object/old_object_interface.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CObject
|
* \class CObject
|
||||||
* \brief Base class for all 3D in-game objects
|
* \brief Base class for all 3D in-game objects
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
//! Reads object properties from line in level file
|
//! Reads object properties from line in level file
|
||||||
virtual void Read(CLevelParserLine* line) = 0;
|
virtual void Read(CLevelParserLine* line) = 0;
|
||||||
|
|
||||||
|
|
||||||
//! Check if object implements the given type of interface
|
//! Check if object implements the given type of interface
|
||||||
inline bool Implements(ObjectInterfaceType type) const
|
inline bool Implements(ObjectInterfaceType type) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ void COldObject::FlushCrashShere()
|
||||||
|
|
||||||
// Adds a new sphere.
|
// Adds a new sphere.
|
||||||
|
|
||||||
int COldObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound,
|
int COldObject::CreateCrashSphere(Math::Vector pos, float radius, SoundType sound,
|
||||||
float hardness)
|
float hardness)
|
||||||
{
|
{
|
||||||
float zoom;
|
float zoom;
|
||||||
|
@ -1132,7 +1132,7 @@ bool COldObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
|
||||||
|
|
||||||
// Returns the hardness of a sphere.
|
// Returns the hardness of a sphere.
|
||||||
|
|
||||||
Sound COldObject::GetCrashSphereSound(int rank)
|
SoundType COldObject::GetCrashSphereSound(int rank)
|
||||||
{
|
{
|
||||||
return m_crashSphereSound[rank];
|
return m_crashSphereSound[rank];
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,11 +103,11 @@ public:
|
||||||
int GetEffectLight() override;
|
int GetEffectLight() override;
|
||||||
|
|
||||||
void FlushCrashShere() override;
|
void FlushCrashShere() override;
|
||||||
int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f) override;
|
int CreateCrashSphere(Math::Vector pos, float radius, SoundType sound, float hardness=0.45f) override;
|
||||||
int GetCrashSphereTotal() override;
|
int GetCrashSphereTotal() override;
|
||||||
bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) override;
|
bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) override;
|
||||||
float GetCrashSphereHardness(int rank) override;
|
float GetCrashSphereHardness(int rank) override;
|
||||||
Sound GetCrashSphereSound(int rank) override;
|
SoundType GetCrashSphereSound(int rank) override;
|
||||||
void SetGlobalSphere(Math::Vector pos, float radius) override;
|
void SetGlobalSphere(Math::Vector pos, float radius) override;
|
||||||
void GetGlobalSphere(Math::Vector &pos, float &radius) override;
|
void GetGlobalSphere(Math::Vector &pos, float &radius) override;
|
||||||
void GetJostlingSphere(Math::Vector &pos, float &radius) override;
|
void GetJostlingSphere(Math::Vector &pos, float &radius) override;
|
||||||
|
@ -395,7 +395,7 @@ protected:
|
||||||
Math::Vector m_crashSpherePos[MAXCRASHSPHERE];
|
Math::Vector m_crashSpherePos[MAXCRASHSPHERE];
|
||||||
float m_crashSphereRadius[MAXCRASHSPHERE];
|
float m_crashSphereRadius[MAXCRASHSPHERE];
|
||||||
float m_crashSphereHardness[MAXCRASHSPHERE];
|
float m_crashSphereHardness[MAXCRASHSPHERE];
|
||||||
Sound m_crashSphereSound[MAXCRASHSPHERE];
|
SoundType m_crashSphereSound[MAXCRASHSPHERE];
|
||||||
Math::Vector m_globalSpherePos;
|
Math::Vector m_globalSpherePos;
|
||||||
float m_globalSphereRadius;
|
float m_globalSphereRadius;
|
||||||
Math::Vector m_jostlingSpherePos;
|
Math::Vector m_jostlingSpherePos;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include "object/object_type.h"
|
#include "object/object_type.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
#include "sound/sound_type.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -99,11 +99,11 @@ public:
|
||||||
virtual int GetEffectLight() = 0;
|
virtual int GetEffectLight() = 0;
|
||||||
|
|
||||||
virtual void FlushCrashShere() = 0;
|
virtual void FlushCrashShere() = 0;
|
||||||
virtual int CreateCrashSphere(Math::Vector pos, float radius, Sound sound, float hardness=0.45f) = 0;
|
virtual int CreateCrashSphere(Math::Vector pos, float radius, SoundType sound, float hardness=0.45f) = 0;
|
||||||
virtual int GetCrashSphereTotal() = 0;
|
virtual int GetCrashSphereTotal() = 0;
|
||||||
virtual bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) = 0;
|
virtual bool GetCrashSphere(int rank, Math::Vector &pos, float &radius) = 0;
|
||||||
virtual float GetCrashSphereHardness(int rank) = 0;
|
virtual float GetCrashSphereHardness(int rank) = 0;
|
||||||
virtual Sound GetCrashSphereSound(int rank) = 0;
|
virtual SoundType GetCrashSphereSound(int rank) = 0;
|
||||||
virtual void SetGlobalSphere(Math::Vector pos, float radius) = 0;
|
virtual void SetGlobalSphere(Math::Vector pos, float radius) = 0;
|
||||||
virtual void GetGlobalSphere(Math::Vector &pos, float &radius) = 0;
|
virtual void GetGlobalSphere(Math::Vector &pos, float &radius) = 0;
|
||||||
virtual void GetJostlingSphere(Math::Vector &pos, float &radius) = 0;
|
virtual void GetJostlingSphere(Math::Vector &pos, float &radius) = 0;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
|
||||||
|
#include "sound/sound.h"
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
|
@ -1862,7 +1862,7 @@ void CPhysics::WaterFrame(float aTime, float rTime)
|
||||||
|
|
||||||
void CPhysics::SoundMotorFull(float rTime, ObjectType type)
|
void CPhysics::SoundMotorFull(float rTime, ObjectType type)
|
||||||
{
|
{
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
float amplitude, time, freq;
|
float amplitude, time, freq;
|
||||||
|
|
||||||
if ( type == OBJECT_MOBILEia ||
|
if ( type == OBJECT_MOBILEia ||
|
||||||
|
@ -1976,7 +1976,7 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector pos, speed;
|
Math::Vector pos, speed;
|
||||||
Math::Point dim;
|
Math::Point dim;
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
float amplitude;
|
float amplitude;
|
||||||
int i, max;
|
int i, max;
|
||||||
|
|
||||||
|
@ -2129,7 +2129,7 @@ void CPhysics::SoundMotorStop(float rTime, ObjectType type)
|
||||||
|
|
||||||
void CPhysics::SoundReactorFull(float rTime, ObjectType type)
|
void CPhysics::SoundReactorFull(float rTime, ObjectType type)
|
||||||
{
|
{
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector pos, speed;
|
Math::Vector pos, speed;
|
||||||
Math::Point dim;
|
Math::Point dim;
|
||||||
|
@ -2512,7 +2512,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
CPhysics* ph;
|
CPhysics* ph;
|
||||||
Math::Matrix matRotate;
|
Math::Matrix matRotate;
|
||||||
Math::Vector iPos, oPos, iiPos, oAngle, oSpeed;
|
Math::Vector iPos, oPos, iiPos, oAngle, oSpeed;
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
float iRad, oRad, distance, force, volume;
|
float iRad, oRad, distance, force, volume;
|
||||||
int j, colType;
|
int j, colType;
|
||||||
ObjectType iType, oType;
|
ObjectType iType, oType;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
#include "common/logger.h"
|
||||||
#include "common/pathman.h"
|
#include "common/pathman.h"
|
||||||
#include "common/resources/inputstream.h"
|
#include "common/resources/inputstream.h"
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
|
@ -156,7 +156,7 @@ int ALSound::GetMusicVolume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::Cache(Sound sound, const std::string &filename)
|
bool ALSound::Cache(SoundType sound, const std::string &filename)
|
||||||
{
|
{
|
||||||
Buffer *buffer = new Buffer();
|
Buffer *buffer = new Buffer();
|
||||||
if (buffer->LoadFromFile(filename, sound))
|
if (buffer->LoadFromFile(filename, sound))
|
||||||
|
@ -172,7 +172,7 @@ bool ALSound::CacheMusic(const std::string &filename)
|
||||||
if (m_music.find("music/"+filename) == m_music.end())
|
if (m_music.find("music/"+filename) == m_music.end())
|
||||||
{
|
{
|
||||||
Buffer *buffer = new Buffer();
|
Buffer *buffer = new Buffer();
|
||||||
if (buffer->LoadFromFile("music/"+filename, static_cast<Sound>(-1)))
|
if (buffer->LoadFromFile("music/"+filename, static_cast<SoundType>(-1)))
|
||||||
{
|
{
|
||||||
m_music["music/"+filename] = buffer;
|
m_music["music/"+filename] = buffer;
|
||||||
return true;
|
return true;
|
||||||
|
@ -181,7 +181,7 @@ bool ALSound::CacheMusic(const std::string &filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ALSound::IsCached(Sound sound)
|
bool ALSound::IsCached(SoundType sound)
|
||||||
{
|
{
|
||||||
return m_sounds.find(sound) != m_sounds.end();
|
return m_sounds.find(sound) != m_sounds.end();
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ bool ALSound::IsCachedMusic(const std::string &filename)
|
||||||
return m_music.find("music/"+filename) != m_music.end();
|
return m_music.find("music/"+filename) != m_music.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALSound::GetPriority(Sound sound)
|
int ALSound::GetPriority(SoundType sound)
|
||||||
{
|
{
|
||||||
if ( sound == SOUND_FLYh ||
|
if ( sound == SOUND_FLYh ||
|
||||||
sound == SOUND_FLY ||
|
sound == SOUND_FLY ||
|
||||||
|
@ -240,7 +240,7 @@ int ALSound::GetPriority(Sound sound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded)
|
||||||
{
|
{
|
||||||
int priority = GetPriority(sound);
|
int priority = GetPriority(sound);
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||||
it.second->SetPriority(priority);
|
it.second->SetPriority(priority);
|
||||||
it.second->Reset();
|
it.second->Reset();
|
||||||
channel = it.first;
|
channel = it.first;
|
||||||
bAlreadyLoaded = it.second->IsLoaded();
|
alreadyLoaded = it.second->IsLoaded();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||||
chn->Reset();
|
chn->Reset();
|
||||||
m_channels[1] = chn;
|
m_channels[1] = chn;
|
||||||
channel = 1;
|
channel = 1;
|
||||||
bAlreadyLoaded = false;
|
alreadyLoaded = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delete chn;
|
delete chn;
|
||||||
|
@ -300,7 +300,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||||
chn->Reset();
|
chn->Reset();
|
||||||
m_channels[++i] = chn;
|
m_channels[++i] = chn;
|
||||||
channel = i;
|
channel = i;
|
||||||
bAlreadyLoaded = false;
|
alreadyLoaded = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delete chn;
|
delete chn;
|
||||||
|
@ -337,13 +337,13 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ALSound::Play(Sound sound, float amplitude, float frequency, bool bLoop)
|
int ALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
||||||
{
|
{
|
||||||
return Play(sound, m_eye, amplitude, frequency, bLoop);
|
return Play(sound, m_eye, amplitude, frequency, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ALSound::Play(Sound sound, const Math::Vector &pos, float amplitude, float frequency, bool bLoop)
|
int ALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -356,13 +356,13 @@ int ALSound::Play(Sound sound, const Math::Vector &pos, float amplitude, float f
|
||||||
}
|
}
|
||||||
|
|
||||||
int channel;
|
int channel;
|
||||||
bool bAlreadyLoaded = false;
|
bool alreadyLoaded = false;
|
||||||
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
|
if (!SearchFreeBuffer(sound, channel, alreadyLoaded))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bAlreadyLoaded)
|
if (!alreadyLoaded)
|
||||||
{
|
{
|
||||||
if (!m_channels[channel]->SetBuffer(m_sounds[sound]))
|
if (!m_channels[channel]->SetBuffer(m_sounds[sound]))
|
||||||
{
|
{
|
||||||
|
@ -381,7 +381,7 @@ int ALSound::Play(Sound sound, const Math::Vector &pos, float amplitude, float f
|
||||||
m_channels[channel]->ResetOper();
|
m_channels[channel]->ResetOper();
|
||||||
m_channels[channel]->SetFrequency(frequency);
|
m_channels[channel]->SetFrequency(frequency);
|
||||||
m_channels[channel]->SetVolume(powf(amplitude * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume);
|
m_channels[channel]->SetVolume(powf(amplitude * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume);
|
||||||
m_channels[channel]->SetLoop(bLoop);
|
m_channels[channel]->SetLoop(loop);
|
||||||
|
|
||||||
if (!m_channels[channel]->Play())
|
if (!m_channels[channel]->Play())
|
||||||
{
|
{
|
||||||
|
@ -485,7 +485,7 @@ bool ALSound::StopAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::MuteAll(bool bMute)
|
bool ALSound::MuteAll(bool mute)
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -496,7 +496,7 @@ bool ALSound::MuteAll(bool bMute)
|
||||||
{
|
{
|
||||||
if (it.second->IsPlaying())
|
if (it.second->IsPlaying())
|
||||||
{
|
{
|
||||||
it.second->Mute(bMute);
|
it.second->Mute(mute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,9 +566,9 @@ void ALSound::FrameMove(float delta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<OldMusic> toRemove;
|
std::list<OldMusic> toRemove;
|
||||||
|
|
||||||
for (auto& it : m_oldMusic)
|
for (auto& it : m_oldMusic)
|
||||||
{
|
{
|
||||||
if (it.currentTime >= it.fadeTime)
|
if (it.currentTime >= it.fadeTime)
|
||||||
|
@ -582,7 +582,7 @@ void ALSound::FrameMove(float delta)
|
||||||
it.music->SetVolume(((it.fadeTime-it.currentTime) / it.fadeTime) * m_musicVolume);
|
it.music->SetVolume(((it.fadeTime-it.currentTime) / it.fadeTime) * m_musicVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_previousMusic.fadeTime > 0.0f) {
|
if (m_previousMusic.fadeTime > 0.0f) {
|
||||||
if (m_previousMusic.currentTime >= m_previousMusic.fadeTime)
|
if (m_previousMusic.currentTime >= m_previousMusic.fadeTime)
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@ void ALSound::FrameMove(float delta)
|
||||||
m_previousMusic.music->SetVolume(((m_previousMusic.fadeTime-m_previousMusic.currentTime) / m_previousMusic.fadeTime) * m_musicVolume);
|
m_previousMusic.music->SetVolume(((m_previousMusic.fadeTime-m_previousMusic.currentTime) / m_previousMusic.fadeTime) * m_musicVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it : toRemove)
|
for (auto it : toRemove)
|
||||||
m_oldMusic.remove(it);
|
m_oldMusic.remove(it);
|
||||||
}
|
}
|
||||||
|
@ -613,11 +613,11 @@ void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::PlayMusic(int rank, bool bRepeat, float fadeTime)
|
bool ALSound::PlayMusic(int rank, bool repeat, float fadeTime)
|
||||||
{
|
{
|
||||||
std::stringstream filename;
|
std::stringstream filename;
|
||||||
filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg";
|
filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg";
|
||||||
return PlayMusic(filename.str(), bRepeat, fadeTime);
|
return PlayMusic(filename.str(), repeat, fadeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ bool operator==(const OldMusic & l, const OldMusic & r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTime)
|
bool ALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime)
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -653,7 +653,7 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
|
||||||
} */
|
} */
|
||||||
|
|
||||||
buffer = new Buffer();
|
buffer = new Buffer();
|
||||||
if (!buffer->LoadFromFile("music/"+filename, static_cast<Sound>(-1)))
|
if (!buffer->LoadFromFile("music/"+filename, static_cast<SoundType>(-1)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,7 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
|
||||||
m_currentMusic = new Channel();
|
m_currentMusic = new Channel();
|
||||||
m_currentMusic->SetBuffer(buffer);
|
m_currentMusic->SetBuffer(buffer);
|
||||||
m_currentMusic->SetVolume(m_musicVolume);
|
m_currentMusic->SetVolume(m_musicVolume);
|
||||||
m_currentMusic->SetLoop(bRepeat);
|
m_currentMusic->SetLoop(repeat);
|
||||||
m_currentMusic->Play();
|
m_currentMusic->Play();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -688,15 +688,15 @@ bool ALSound::PlayPauseMusic(const std::string &filename, bool repeat)
|
||||||
{
|
{
|
||||||
if (m_previousMusic.fadeTime > 0.0f)
|
if (m_previousMusic.fadeTime > 0.0f)
|
||||||
{
|
{
|
||||||
if(m_currentMusic)
|
if (m_currentMusic)
|
||||||
{
|
{
|
||||||
OldMusic old;
|
OldMusic old;
|
||||||
old.music = m_currentMusic;
|
old.music = m_currentMusic;
|
||||||
old.fadeTime = 2.0f;
|
old.fadeTime = 2.0f;
|
||||||
old.currentTime = 0.0f;
|
old.currentTime = 0.0f;
|
||||||
m_oldMusic.push_back(old);
|
m_oldMusic.push_back(old);
|
||||||
m_currentMusic = nullptr;
|
m_currentMusic = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -720,10 +720,10 @@ void ALSound::StopPauseMusic()
|
||||||
|
|
||||||
m_currentMusic = m_previousMusic.music;
|
m_currentMusic = m_previousMusic.music;
|
||||||
m_previousMusic.music = nullptr;
|
m_previousMusic.music = nullptr;
|
||||||
if(m_currentMusic != nullptr)
|
if (m_currentMusic != nullptr)
|
||||||
{
|
{
|
||||||
m_currentMusic->SetVolume(m_musicVolume);
|
m_currentMusic->SetVolume(m_musicVolume);
|
||||||
if(m_previousMusic.currentTime >= m_previousMusic.fadeTime)
|
if (m_previousMusic.currentTime >= m_previousMusic.fadeTime)
|
||||||
{
|
{
|
||||||
m_currentMusic->Play();
|
m_currentMusic->Play();
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ void ALSound::StopMusic(float fadeTime)
|
||||||
old.fadeTime = fadeTime;
|
old.fadeTime = fadeTime;
|
||||||
old.currentTime = 0.0f;
|
old.currentTime = 0.0f;
|
||||||
m_oldMusic.push_back(old);
|
m_oldMusic.push_back(old);
|
||||||
|
|
||||||
m_currentMusic = nullptr;
|
m_currentMusic = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
#include <al.h>
|
#include <al.h>
|
||||||
|
|
||||||
|
|
||||||
struct OldMusic {
|
struct OldMusic
|
||||||
|
{
|
||||||
Channel* music;
|
Channel* music;
|
||||||
float fadeTime;
|
float fadeTime;
|
||||||
float currentTime;
|
float currentTime;
|
||||||
|
@ -51,9 +52,9 @@ public:
|
||||||
~ALSound();
|
~ALSound();
|
||||||
|
|
||||||
bool Create() override;
|
bool Create() override;
|
||||||
bool Cache(Sound, const std::string &) override;
|
bool Cache(SoundType, const std::string &) override;
|
||||||
bool CacheMusic(const std::string &) override;
|
bool CacheMusic(const std::string &) override;
|
||||||
bool IsCached(Sound) override;
|
bool IsCached(SoundType) override;
|
||||||
bool IsCachedMusic(const std::string &) override;
|
bool IsCachedMusic(const std::string &) override;
|
||||||
|
|
||||||
bool GetEnable() override;
|
bool GetEnable() override;
|
||||||
|
@ -66,18 +67,18 @@ public:
|
||||||
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) override;
|
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) override;
|
||||||
void FrameMove(float rTime) override;
|
void FrameMove(float rTime) override;
|
||||||
|
|
||||||
int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) override;
|
int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
|
||||||
int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) override;
|
int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
|
||||||
bool FlushEnvelope(int channel) override;
|
bool FlushEnvelope(int channel) override;
|
||||||
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override;
|
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override;
|
||||||
bool Position(int channel, const Math::Vector &pos) override;
|
bool Position(int channel, const Math::Vector &pos) override;
|
||||||
bool Frequency(int channel, float frequency) override;
|
bool Frequency(int channel, float frequency) override;
|
||||||
bool Stop(int channel) override;
|
bool Stop(int channel) override;
|
||||||
bool StopAll() override;
|
bool StopAll() override;
|
||||||
bool MuteAll(bool bMute) override;
|
bool MuteAll(bool mute) override;
|
||||||
|
|
||||||
bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f) override;
|
bool PlayMusic(int rank, bool repeat, float fadeTime=2.0f) override;
|
||||||
bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f) override;
|
bool PlayMusic(const std::string &filename, bool repeat, float fadeTime=2.0f) override;
|
||||||
bool RestartMusic() override;
|
bool RestartMusic() override;
|
||||||
void SuspendMusic() override;
|
void SuspendMusic() override;
|
||||||
void StopMusic(float fadeTime=2.0f) override;
|
void StopMusic(float fadeTime=2.0f) override;
|
||||||
|
@ -87,8 +88,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
int GetPriority(Sound);
|
int GetPriority(SoundType);
|
||||||
bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded);
|
bool SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded);
|
||||||
bool CheckChannel(int &channel);
|
bool CheckChannel(int &channel);
|
||||||
|
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
|
@ -97,7 +98,7 @@ private:
|
||||||
unsigned int m_channels_limit;
|
unsigned int m_channels_limit;
|
||||||
ALCdevice* m_device;
|
ALCdevice* m_device;
|
||||||
ALCcontext* m_context;
|
ALCcontext* m_context;
|
||||||
std::map<Sound, Buffer*> m_sounds;
|
std::map<SoundType, Buffer*> m_sounds;
|
||||||
std::map<std::string, Buffer*> m_music;
|
std::map<std::string, Buffer*> m_music;
|
||||||
std::map<int, Channel*> m_channels;
|
std::map<int, Channel*> m_channels;
|
||||||
Channel *m_currentMusic;
|
Channel *m_currentMusic;
|
||||||
|
|
|
@ -43,7 +43,7 @@ Buffer::~Buffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Buffer::LoadFromFile(std::string filename, Sound sound)
|
bool Buffer::LoadFromFile(std::string filename, SoundType sound)
|
||||||
{
|
{
|
||||||
m_sound = sound;
|
m_sound = sound;
|
||||||
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
||||||
|
@ -88,7 +88,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Sound Buffer::GetSoundType()
|
SoundType Buffer::GetSoundType()
|
||||||
{
|
{
|
||||||
return m_sound;
|
return m_sound;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,16 +42,16 @@ public:
|
||||||
Buffer();
|
Buffer();
|
||||||
~Buffer();
|
~Buffer();
|
||||||
|
|
||||||
bool LoadFromFile(std::string, Sound);
|
bool LoadFromFile(std::string, SoundType);
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
|
||||||
Sound GetSoundType();
|
SoundType GetSoundType();
|
||||||
ALuint GetBuffer();
|
ALuint GetBuffer();
|
||||||
float GetDuration();
|
float GetDuration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ALuint m_buffer;
|
ALuint m_buffer;
|
||||||
Sound m_sound;
|
SoundType m_sound;
|
||||||
bool m_loaded;
|
bool m_loaded;
|
||||||
float m_duration;
|
float m_duration;
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,7 +84,7 @@ bool Channel::Pause()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
alSourcePause(m_source);
|
alSourcePause(m_source);
|
||||||
if (alCheck())
|
if (alCheck())
|
||||||
{
|
{
|
||||||
|
@ -262,7 +262,7 @@ void Channel::ResetOper()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Sound Channel::GetSoundType()
|
SoundType Channel::GetSoundType()
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
|
|
||||||
void AddOper(SoundOper);
|
void AddOper(SoundOper);
|
||||||
void ResetOper();
|
void ResetOper();
|
||||||
Sound GetSoundType();
|
SoundType GetSoundType();
|
||||||
void SetLoop(bool);
|
void SetLoop(bool);
|
||||||
void Mute(bool);
|
void Mute(bool);
|
||||||
bool IsMuted();
|
bool IsMuted();
|
||||||
|
|
|
@ -49,7 +49,7 @@ void CSoundInterface::CacheAll()
|
||||||
{
|
{
|
||||||
std::stringstream filename;
|
std::stringstream filename;
|
||||||
filename << "sounds/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
|
filename << "sounds/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
|
||||||
if ( !Cache(static_cast<Sound>(i), filename.str()) )
|
if ( !Cache(static_cast<SoundType>(i), filename.str()) )
|
||||||
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
|
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,22 +62,22 @@ void CSoundInterface::AddMusicFiles()
|
||||||
CacheMusic("music011.ogg");
|
CacheMusic("music011.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::Cache(Sound bSound, const std::string &bFile)
|
bool CSoundInterface::Cache(SoundType sound, const std::string &file)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::CacheMusic(const std::string &bFile)
|
bool CSoundInterface::CacheMusic(const std::string &file)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::IsCached(Sound bSound)
|
bool CSoundInterface::IsCached(SoundType sound)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::IsCachedMusic(const std::string& bFile)
|
bool CSoundInterface::IsCachedMusic(const std::string& file)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -113,12 +113,12 @@ void CSoundInterface::FrameMove(float rTime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSoundInterface::Play(Sound sound, float amplitude, float frequency, bool bLoop)
|
int CSoundInterface::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSoundInterface::Play(Sound sound, const Math::Vector &pos, float amplitude, float frequency, bool bLoop)
|
int CSoundInterface::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -158,12 +158,12 @@ bool CSoundInterface::MuteAll(bool bMute)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::PlayMusic(int rank, bool bRepeat, float fadeTime)
|
bool CSoundInterface::PlayMusic(int rank, bool repeat, float fadeTime)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::PlayMusic(const std::string &filename, bool bRepeat, float fadeTime)
|
bool CSoundInterface::PlayMusic(const std::string &filename, bool repeat, float fadeTime)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "math/vector.h"
|
#include "math/vector.h"
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "sound/sound_type.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -36,100 +36,6 @@
|
||||||
const float MAXVOLUME = 100.0f;
|
const float MAXVOLUME = 100.0f;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \public
|
|
||||||
* \enum Sound sound/sound.h
|
|
||||||
* \brief Sound enum representing sound file
|
|
||||||
**/
|
|
||||||
enum Sound
|
|
||||||
{
|
|
||||||
SOUND_NONE = -1,
|
|
||||||
SOUND_CLICK = 0,
|
|
||||||
SOUND_BOUM = 1,
|
|
||||||
SOUND_EXPLO = 2,
|
|
||||||
SOUND_FLYh = 3, /*!< human */
|
|
||||||
SOUND_FLY = 4,
|
|
||||||
SOUND_STEPs = 5, /*!< smooth */
|
|
||||||
SOUND_MOTORw = 6, /*!< wheel */
|
|
||||||
SOUND_MOTORt = 7, /*!< tank */
|
|
||||||
SOUND_MOTORr = 8, /*!< roller */
|
|
||||||
SOUND_ERROR = 9,
|
|
||||||
SOUND_CONVERT = 10,
|
|
||||||
SOUND_ENERGY = 11,
|
|
||||||
SOUND_PLOUF = 12,
|
|
||||||
SOUND_BLUP = 13,
|
|
||||||
SOUND_WARNING = 14,
|
|
||||||
SOUND_DERRICK = 15,
|
|
||||||
SOUND_LABO = 16,
|
|
||||||
SOUND_STATION = 17,
|
|
||||||
SOUND_REPAIR = 18,
|
|
||||||
SOUND_RESEARCH = 19,
|
|
||||||
SOUND_INSECTs = 20, /*!< spider */
|
|
||||||
SOUND_BURN = 21,
|
|
||||||
SOUND_TZOING = 22,
|
|
||||||
SOUND_GGG = 23,
|
|
||||||
SOUND_MANIP = 24,
|
|
||||||
SOUND_FIRE = 25, /*!< shooting with fireball */
|
|
||||||
SOUND_HUMAN1 = 26, /*!< breathing */
|
|
||||||
SOUND_STEPw = 27, /*!< water */
|
|
||||||
SOUND_SWIM = 28,
|
|
||||||
SOUND_RADAR = 29,
|
|
||||||
SOUND_BUILD = 30,
|
|
||||||
SOUND_ALARM = 31, /*!< energy alarm */
|
|
||||||
SOUND_SLIDE = 32,
|
|
||||||
SOUND_EXPLOi = 33, /*!< insect */
|
|
||||||
SOUND_INSECTa = 34, /*!< ant */
|
|
||||||
SOUND_INSECTb = 35, /*!< bee */
|
|
||||||
SOUND_INSECTw = 36, /*!< worm */
|
|
||||||
SOUND_INSECTm = 37, /*!< mother */
|
|
||||||
SOUND_TREMBLE = 38,
|
|
||||||
SOUND_PSHHH = 39,
|
|
||||||
SOUND_NUCLEAR = 40,
|
|
||||||
SOUND_INFO = 41,
|
|
||||||
SOUND_OPEN = 42,
|
|
||||||
SOUND_CLOSE = 43,
|
|
||||||
SOUND_FACTORY = 44,
|
|
||||||
SOUND_EGG = 45,
|
|
||||||
SOUND_MOTORs = 46, /*!< submarine */
|
|
||||||
SOUND_MOTORi = 47, /*!< insect (legs) */
|
|
||||||
SOUND_SHIELD = 48,
|
|
||||||
SOUND_FIREi = 49, /*!< shooting with orgaball (insect) */
|
|
||||||
SOUND_GUNDEL = 50,
|
|
||||||
SOUND_PSHHH2 = 51, /*!< shield */
|
|
||||||
SOUND_MESSAGE = 52,
|
|
||||||
SOUND_BOUMm = 53, /*!< metal */
|
|
||||||
SOUND_BOUMv = 54, /*!< plant */
|
|
||||||
SOUND_BOUMs = 55, /*!< smooth */
|
|
||||||
SOUND_EXPLOl = 56, /*!< little */
|
|
||||||
SOUND_EXPLOlp = 57, /*!< little power */
|
|
||||||
SOUND_EXPLOp = 58, /*!< power */
|
|
||||||
SOUND_STEPh = 59, /*!< hard */
|
|
||||||
SOUND_STEPm = 60, /*!< metal */
|
|
||||||
SOUND_POWERON = 61,
|
|
||||||
SOUND_POWEROFF = 62,
|
|
||||||
SOUND_AIE = 63,
|
|
||||||
SOUND_WAYPOINT = 64,
|
|
||||||
SOUND_RECOVER = 65,
|
|
||||||
SOUND_DEADi = 66,
|
|
||||||
SOUND_JOSTLE = 67,
|
|
||||||
SOUND_GFLAT = 68,
|
|
||||||
SOUND_DEADg = 69, /*!< shooting death */
|
|
||||||
SOUND_DEADw = 70, /*!< drowning */
|
|
||||||
SOUND_FLYf = 71, /*!< reactor fail */
|
|
||||||
SOUND_ALARMt = 72, /*!< temperature alarm */
|
|
||||||
SOUND_FINDING = 73, /*!< finds a cache object */
|
|
||||||
SOUND_THUMP = 74,
|
|
||||||
SOUND_TOUCH = 75,
|
|
||||||
SOUND_BLITZ = 76,
|
|
||||||
SOUND_MUSHROOM = 77,
|
|
||||||
SOUND_FIREp = 78, /*!< shooting with phazer */
|
|
||||||
SOUND_EXPLOg1 = 79, /*!< impact gun 1 */
|
|
||||||
SOUND_EXPLOg2 = 80, /*!< impact gun 2 */
|
|
||||||
// SOUND_MOTORd = 81, /*!< engine friction */
|
|
||||||
SOUND_MAX /** number of items in enum */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \enum SoundNext
|
* \enum SoundNext
|
||||||
* \brief Enum representing operation that will be performend on a sound at given time
|
* \brief Enum representing operation that will be performend on a sound at given time
|
||||||
|
@ -168,30 +74,30 @@ public:
|
||||||
|
|
||||||
/** Function called to cache sound effect file.
|
/** Function called to cache sound effect file.
|
||||||
* This function is called by plugin interface for each file.
|
* This function is called by plugin interface for each file.
|
||||||
* \param bSound - id of a file, will be used to identify sound files
|
* \param sound - id of a file, will be used to identify sound files
|
||||||
* \param bFile - file to load
|
* \param file - file to load
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool Cache(Sound bSound, const std::string &bFile);
|
virtual bool Cache(SoundType sound, const std::string &file);
|
||||||
|
|
||||||
/** Function called to cache music file.
|
/** Function called to cache music file.
|
||||||
* This function is called by CRobotMain for each file used in the mission.
|
* This function is called by CRobotMain for each file used in the mission.
|
||||||
* \param bFile - file to load
|
* \param file - file to load
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool CacheMusic(const std::string &bFile);
|
virtual bool CacheMusic(const std::string &file);
|
||||||
|
|
||||||
/** Function to check if sound effect file was cached.
|
/** Function to check if sound effect file was cached.
|
||||||
* \param bSound - id of a sound effect file
|
* \param sound - id of a sound effect file
|
||||||
* \return return true if the file was cached
|
* \return return true if the file was cached
|
||||||
*/
|
*/
|
||||||
virtual bool IsCached(Sound bSound);
|
virtual bool IsCached(SoundType sound);
|
||||||
|
|
||||||
/** Function called to check if music file was cached.
|
/** Function called to check if music file was cached.
|
||||||
* \param bFile - file to check
|
* \param file - file to check
|
||||||
* \return return true if the file was cached
|
* \return return true if the file was cached
|
||||||
*/
|
*/
|
||||||
virtual bool IsCachedMusic(const std::string &bFile);
|
virtual bool IsCachedMusic(const std::string &file);
|
||||||
|
|
||||||
/** Return if plugin is enabled
|
/** Return if plugin is enabled
|
||||||
* \return return true if plugin is enabled
|
* \return return true if plugin is enabled
|
||||||
|
@ -233,20 +139,20 @@ public:
|
||||||
* \param sound - sound to play
|
* \param sound - sound to play
|
||||||
* \param amplitude - change amplitude of sound before playing
|
* \param amplitude - change amplitude of sound before playing
|
||||||
* \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
|
* \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
|
||||||
* \param bLoop - loop sound
|
* \param loop - loop sound
|
||||||
* \return identifier of channel that sound will be played on
|
* \return identifier of channel that sound will be played on
|
||||||
*/
|
*/
|
||||||
virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
|
virtual int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
|
||||||
|
|
||||||
/** Play specific sound
|
/** Play specific sound
|
||||||
* \param sound - sound to play
|
* \param sound - sound to play
|
||||||
* \param pos - position of sound in space
|
* \param pos - position of sound in space
|
||||||
* \param amplitude - change amplitude of sound before playing
|
* \param amplitude - change amplitude of sound before playing
|
||||||
* \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
|
* \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
|
||||||
* \param bLoop - loop sound
|
* \param loop - loop sound
|
||||||
* \return identifier of channel that sound will be played on
|
* \return identifier of channel that sound will be played on
|
||||||
*/
|
*/
|
||||||
virtual int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
|
virtual int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
|
||||||
|
|
||||||
/** Remove all operations that would be made on sound in channel.
|
/** Remove all operations that would be made on sound in channel.
|
||||||
* \param channel - channel to work on
|
* \param channel - channel to work on
|
||||||
|
@ -290,26 +196,26 @@ public:
|
||||||
virtual bool StopAll();
|
virtual bool StopAll();
|
||||||
|
|
||||||
/** Mute/unmute all sounds
|
/** Mute/unmute all sounds
|
||||||
* \param bMute
|
* \param mute
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool MuteAll(bool bMute);
|
virtual bool MuteAll(bool mute);
|
||||||
|
|
||||||
/** Start playing music
|
/** Start playing music
|
||||||
* \param rank - track number
|
* \param rank - track number
|
||||||
* \param bRepeat - repeat playing
|
* \param repeat - repeat playing
|
||||||
* \param fadeTime - time of transition between music
|
* \param fadeTime - time of transition between music
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f);
|
virtual bool PlayMusic(int rank, bool repeat, float fadeTime=2.0f);
|
||||||
|
|
||||||
/** Start playing music
|
/** Start playing music
|
||||||
* \param filename - name of file to play
|
* \param filename - name of file to play
|
||||||
* \param bRepeat - repeat playing
|
* \param repeat - repeat playing
|
||||||
* \param fadeTime - time of transition between music
|
* \param fadeTime - time of transition between music
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f);
|
virtual bool PlayMusic(const std::string &filename, bool repeat, float fadeTime=2.0f);
|
||||||
|
|
||||||
/** Restart music
|
/** Restart music
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
|
@ -330,13 +236,13 @@ public:
|
||||||
* \return return true if music is playing
|
* \return return true if music is playing
|
||||||
*/
|
*/
|
||||||
virtual bool IsPlayingMusic();
|
virtual bool IsPlayingMusic();
|
||||||
|
|
||||||
/** Start playing pause music
|
/** Start playing pause music
|
||||||
* \param filename - name of file to play
|
* \param filename - name of file to play
|
||||||
* \return return true on success
|
* \return return true on success
|
||||||
*/
|
*/
|
||||||
virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
|
virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
|
||||||
|
|
||||||
/** Stop playing pause music and return to the mission music
|
/** Stop playing pause music and return to the mission music
|
||||||
* \return nothing
|
* \return nothing
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
|
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sound/sound_type.h"
|
||||||
|
|
||||||
|
#include "common/logger.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, SoundType> SOUND_STRINGS =
|
||||||
|
{
|
||||||
|
{"none", SOUND_NONE},
|
||||||
|
{"click", SOUND_CLICK},
|
||||||
|
{"boum", SOUND_BOUM},
|
||||||
|
{"explo", SOUND_EXPLO},
|
||||||
|
{"flyh", SOUND_FLYh},
|
||||||
|
{"fly", SOUND_FLY},
|
||||||
|
{"steps", SOUND_STEPs},
|
||||||
|
{"motorw", SOUND_MOTORw},
|
||||||
|
{"motort", SOUND_MOTORt},
|
||||||
|
{"motorr", SOUND_MOTORr},
|
||||||
|
{"error", SOUND_ERROR},
|
||||||
|
{"convert", SOUND_CONVERT},
|
||||||
|
{"energy", SOUND_ENERGY},
|
||||||
|
{"plouf", SOUND_PLOUF},
|
||||||
|
{"blup", SOUND_BLUP},
|
||||||
|
{"warning", SOUND_WARNING},
|
||||||
|
{"derrick", SOUND_DERRICK},
|
||||||
|
{"labo", SOUND_LABO},
|
||||||
|
{"station", SOUND_STATION},
|
||||||
|
{"repair", SOUND_REPAIR},
|
||||||
|
{"research", SOUND_RESEARCH},
|
||||||
|
{"insects", SOUND_INSECTs},
|
||||||
|
{"burn", SOUND_BURN},
|
||||||
|
{"tzoing", SOUND_TZOING},
|
||||||
|
{"ggg", SOUND_GGG},
|
||||||
|
{"manip", SOUND_MANIP},
|
||||||
|
{"fire", SOUND_FIRE},
|
||||||
|
{"human1", SOUND_HUMAN1},
|
||||||
|
{"stepw", SOUND_STEPw},
|
||||||
|
{"swim", SOUND_SWIM},
|
||||||
|
{"radar", SOUND_RADAR},
|
||||||
|
{"build", SOUND_BUILD},
|
||||||
|
{"alarm", SOUND_ALARM},
|
||||||
|
{"slide", SOUND_SLIDE},
|
||||||
|
{"exploi", SOUND_EXPLOi},
|
||||||
|
{"insecta", SOUND_INSECTa},
|
||||||
|
{"insectb", SOUND_INSECTb},
|
||||||
|
{"insectw", SOUND_INSECTw},
|
||||||
|
{"insectm", SOUND_INSECTm},
|
||||||
|
{"tremble", SOUND_TREMBLE},
|
||||||
|
{"pshhh", SOUND_PSHHH},
|
||||||
|
{"nuclear", SOUND_NUCLEAR},
|
||||||
|
{"info", SOUND_INFO},
|
||||||
|
{"open", SOUND_OPEN},
|
||||||
|
{"close", SOUND_CLOSE},
|
||||||
|
{"factory", SOUND_FACTORY},
|
||||||
|
{"egg", SOUND_EGG},
|
||||||
|
{"motors", SOUND_MOTORs},
|
||||||
|
{"motori", SOUND_MOTORi},
|
||||||
|
{"shield", SOUND_SHIELD},
|
||||||
|
{"firei", SOUND_FIREi},
|
||||||
|
{"gundel", SOUND_GUNDEL},
|
||||||
|
{"pshhh2", SOUND_PSHHH2},
|
||||||
|
{"message", SOUND_MESSAGE},
|
||||||
|
{"boumm", SOUND_BOUMm},
|
||||||
|
{"boumv", SOUND_BOUMv},
|
||||||
|
{"boums", SOUND_BOUMs},
|
||||||
|
{"explol", SOUND_EXPLOl},
|
||||||
|
{"explolp", SOUND_EXPLOlp},
|
||||||
|
{"explop", SOUND_EXPLOp},
|
||||||
|
{"steph", SOUND_STEPh},
|
||||||
|
{"stepm", SOUND_STEPm},
|
||||||
|
{"poweron", SOUND_POWERON},
|
||||||
|
{"poweroff", SOUND_POWEROFF},
|
||||||
|
{"aie", SOUND_AIE},
|
||||||
|
{"waypoint", SOUND_WAYPOINT},
|
||||||
|
{"recover", SOUND_RECOVER},
|
||||||
|
{"deadi", SOUND_DEADi},
|
||||||
|
{"jostle", SOUND_JOSTLE},
|
||||||
|
{"gflat", SOUND_GFLAT},
|
||||||
|
{"deadg", SOUND_DEADg},
|
||||||
|
{"deadw", SOUND_DEADw},
|
||||||
|
{"flyf", SOUND_FLYf},
|
||||||
|
{"alarmt", SOUND_ALARMt},
|
||||||
|
{"finding", SOUND_FINDING},
|
||||||
|
{"thump", SOUND_THUMP},
|
||||||
|
{"touch", SOUND_TOUCH},
|
||||||
|
{"blitz", SOUND_BLITZ},
|
||||||
|
{"mushroom", SOUND_MUSHROOM},
|
||||||
|
{"firep", SOUND_FIREp},
|
||||||
|
{"explog1", SOUND_EXPLOg1},
|
||||||
|
{"explog2", SOUND_EXPLOg2}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
SoundType StringToSound(const std::string& str)
|
||||||
|
{
|
||||||
|
auto it = SOUND_STRINGS.find(str);
|
||||||
|
if (it == SOUND_STRINGS.end())
|
||||||
|
{
|
||||||
|
GetLogger()->Error("Could not parse sound string: %s\n", str.c_str());
|
||||||
|
return SOUND_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
|
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
|
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \public
|
||||||
|
* \enum SoundType
|
||||||
|
* \brief Enum representing sound file
|
||||||
|
**/
|
||||||
|
enum SoundType
|
||||||
|
{
|
||||||
|
SOUND_NONE = -1,
|
||||||
|
SOUND_CLICK = 0,
|
||||||
|
SOUND_BOUM = 1,
|
||||||
|
SOUND_EXPLO = 2,
|
||||||
|
SOUND_FLYh = 3, /*!< human */
|
||||||
|
SOUND_FLY = 4,
|
||||||
|
SOUND_STEPs = 5, /*!< smooth */
|
||||||
|
SOUND_MOTORw = 6, /*!< wheel */
|
||||||
|
SOUND_MOTORt = 7, /*!< tank */
|
||||||
|
SOUND_MOTORr = 8, /*!< roller */
|
||||||
|
SOUND_ERROR = 9,
|
||||||
|
SOUND_CONVERT = 10,
|
||||||
|
SOUND_ENERGY = 11,
|
||||||
|
SOUND_PLOUF = 12,
|
||||||
|
SOUND_BLUP = 13,
|
||||||
|
SOUND_WARNING = 14,
|
||||||
|
SOUND_DERRICK = 15,
|
||||||
|
SOUND_LABO = 16,
|
||||||
|
SOUND_STATION = 17,
|
||||||
|
SOUND_REPAIR = 18,
|
||||||
|
SOUND_RESEARCH = 19,
|
||||||
|
SOUND_INSECTs = 20, /*!< spider */
|
||||||
|
SOUND_BURN = 21,
|
||||||
|
SOUND_TZOING = 22,
|
||||||
|
SOUND_GGG = 23,
|
||||||
|
SOUND_MANIP = 24,
|
||||||
|
SOUND_FIRE = 25, /*!< shooting with fireball */
|
||||||
|
SOUND_HUMAN1 = 26, /*!< breathing */
|
||||||
|
SOUND_STEPw = 27, /*!< water */
|
||||||
|
SOUND_SWIM = 28,
|
||||||
|
SOUND_RADAR = 29,
|
||||||
|
SOUND_BUILD = 30,
|
||||||
|
SOUND_ALARM = 31, /*!< energy alarm */
|
||||||
|
SOUND_SLIDE = 32,
|
||||||
|
SOUND_EXPLOi = 33, /*!< insect */
|
||||||
|
SOUND_INSECTa = 34, /*!< ant */
|
||||||
|
SOUND_INSECTb = 35, /*!< bee */
|
||||||
|
SOUND_INSECTw = 36, /*!< worm */
|
||||||
|
SOUND_INSECTm = 37, /*!< mother */
|
||||||
|
SOUND_TREMBLE = 38,
|
||||||
|
SOUND_PSHHH = 39,
|
||||||
|
SOUND_NUCLEAR = 40,
|
||||||
|
SOUND_INFO = 41,
|
||||||
|
SOUND_OPEN = 42,
|
||||||
|
SOUND_CLOSE = 43,
|
||||||
|
SOUND_FACTORY = 44,
|
||||||
|
SOUND_EGG = 45,
|
||||||
|
SOUND_MOTORs = 46, /*!< submarine */
|
||||||
|
SOUND_MOTORi = 47, /*!< insect (legs) */
|
||||||
|
SOUND_SHIELD = 48,
|
||||||
|
SOUND_FIREi = 49, /*!< shooting with orgaball (insect) */
|
||||||
|
SOUND_GUNDEL = 50,
|
||||||
|
SOUND_PSHHH2 = 51, /*!< shield */
|
||||||
|
SOUND_MESSAGE = 52,
|
||||||
|
SOUND_BOUMm = 53, /*!< metal */
|
||||||
|
SOUND_BOUMv = 54, /*!< plant */
|
||||||
|
SOUND_BOUMs = 55, /*!< smooth */
|
||||||
|
SOUND_EXPLOl = 56, /*!< little */
|
||||||
|
SOUND_EXPLOlp = 57, /*!< little power */
|
||||||
|
SOUND_EXPLOp = 58, /*!< power */
|
||||||
|
SOUND_STEPh = 59, /*!< hard */
|
||||||
|
SOUND_STEPm = 60, /*!< metal */
|
||||||
|
SOUND_POWERON = 61,
|
||||||
|
SOUND_POWEROFF = 62,
|
||||||
|
SOUND_AIE = 63,
|
||||||
|
SOUND_WAYPOINT = 64,
|
||||||
|
SOUND_RECOVER = 65,
|
||||||
|
SOUND_DEADi = 66,
|
||||||
|
SOUND_JOSTLE = 67,
|
||||||
|
SOUND_GFLAT = 68,
|
||||||
|
SOUND_DEADg = 69, /*!< shooting death */
|
||||||
|
SOUND_DEADw = 70, /*!< drowning */
|
||||||
|
SOUND_FLYf = 71, /*!< reactor fail */
|
||||||
|
SOUND_ALARMt = 72, /*!< temperature alarm */
|
||||||
|
SOUND_FINDING = 73, /*!< finds a cache object */
|
||||||
|
SOUND_THUMP = 74,
|
||||||
|
SOUND_TOUCH = 75,
|
||||||
|
SOUND_BLITZ = 76,
|
||||||
|
SOUND_MUSHROOM = 77,
|
||||||
|
SOUND_FIREp = 78, /*!< shooting with phazer */
|
||||||
|
SOUND_EXPLOg1 = 79, /*!< impact gun 1 */
|
||||||
|
SOUND_EXPLOg2 = 80, /*!< impact gun 2 */
|
||||||
|
// SOUND_MOTORd = 81, /*!< engine friction */
|
||||||
|
SOUND_MAX /** number of items in enum */
|
||||||
|
};
|
||||||
|
|
||||||
|
SoundType ParseSoundType(const std::string& str);
|
|
@ -196,7 +196,7 @@ void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height
|
||||||
Ui::CGroup* group;
|
Ui::CGroup* group;
|
||||||
Ui::CLabel* label;
|
Ui::CLabel* label;
|
||||||
Math::Point pos, ppos, dim;
|
Math::Point pos, ppos, dim;
|
||||||
Sound sound;
|
SoundType sound;
|
||||||
float hLine, hBox;
|
float hLine, hBox;
|
||||||
int nLine, icon, i;
|
int nLine, icon, i;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "clipboard/clipboard.h"
|
#include "clipboard/clipboard.h"
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
#include "common/logger.h"
|
||||||
#include "common/pathman.h"
|
#include "common/pathman.h"
|
||||||
#include "common/resources/inputstream.h"
|
#include "common/resources/inputstream.h"
|
||||||
#include "common/resources/outputstream.h"
|
#include "common/resources/outputstream.h"
|
||||||
|
@ -1458,10 +1459,10 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
bool bInSoluce, bBOL;
|
bool bInSoluce, bBOL;
|
||||||
|
|
||||||
if ( filename == "" ) return false;
|
if ( filename == "" ) return false;
|
||||||
|
|
||||||
CInputStream stream;
|
CInputStream stream;
|
||||||
stream.open(filename);
|
stream.open(filename);
|
||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
{
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Failed to load text file %s\n", filename.c_str());
|
CLogger::GetInstancePointer()->Error("Failed to load text file %s\n", filename.c_str());
|
||||||
|
@ -1644,7 +1645,8 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
// A part of image per line of text.
|
// A part of image per line of text.
|
||||||
for ( iCount=0 ; iCount<iLines ; iCount++ )
|
for ( iCount=0 ; iCount<iLines ; iCount++ )
|
||||||
{
|
{
|
||||||
if(iIndex >= EDITIMAGEMAX) {
|
if (iIndex >= EDITIMAGEMAX)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Warn("Too many images, current limit is %d image lines. This limit will be removed in the future.\n", EDITIMAGEMAX);
|
CLogger::GetInstancePointer()->Warn("Too many images, current limit is %d image lines. This limit will be removed in the future.\n", EDITIMAGEMAX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1792,7 +1794,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
buffer[i+4] == ' ' )
|
buffer[i+4] == ' ' )
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
for(count = 0; buffer[i+5+count] != ';'; count++);
|
for (count = 0; buffer[i+5+count] != ';'; count++);
|
||||||
if ( m_bSoluce || !bInSoluce ) //TODO: ???
|
if ( m_bSoluce || !bInSoluce ) //TODO: ???
|
||||||
{
|
{
|
||||||
CInput* input = CInput::GetInstancePointer();
|
CInput* input = CInput::GetInstancePointer();
|
||||||
|
@ -1814,7 +1816,9 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
m_text[j] = ' ';
|
m_text[j] = ' ';
|
||||||
m_format[j] = font;
|
m_format[j] = font;
|
||||||
j ++;
|
j ++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_text[j] = '?';
|
m_text[j] = '?';
|
||||||
m_format[j] = font;
|
m_format[j] = font;
|
||||||
j ++;
|
j ++;
|
||||||
|
@ -1860,10 +1864,10 @@ bool CEdit::WriteText(std::string filename)
|
||||||
float iDim = 0.0f;
|
float iDim = 0.0f;
|
||||||
|
|
||||||
if ( filename[0] == 0 ) return false;
|
if ( filename[0] == 0 ) return false;
|
||||||
|
|
||||||
COutputStream stream;
|
COutputStream stream;
|
||||||
stream.open(filename);
|
stream.open(filename);
|
||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
|
#include "common/logger.h"
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
|
@ -646,12 +647,12 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
|
||||||
button = pw->CreateButton(pos, dim, 64+29, EVENT_STUDIO_STEP);
|
button = pw->CreateButton(pos, dim, 64+29, EVENT_STUDIO_STEP);
|
||||||
button->SetState(STATE_SHADOW);
|
button->SetState(STATE_SHADOW);
|
||||||
|
|
||||||
if(!m_program->runnable)
|
if (!m_program->runnable)
|
||||||
{
|
{
|
||||||
GetResource(RES_TEXT, RT_PROGRAM_EXAMPLE, res);
|
GetResource(RES_TEXT, RT_PROGRAM_EXAMPLE, res);
|
||||||
SetInfoText(res, false);
|
SetInfoText(res, false);
|
||||||
}
|
}
|
||||||
else if(m_program->readOnly)
|
else if (m_program->readOnly)
|
||||||
{
|
{
|
||||||
GetResource(RES_TEXT, RT_PROGRAM_READONLY, res);
|
GetResource(RES_TEXT, RT_PROGRAM_READONLY, res);
|
||||||
SetInfoText(res, false);
|
SetInfoText(res, false);
|
||||||
|
@ -1159,7 +1160,7 @@ void CStudio::StartDialog(StudioDialog type)
|
||||||
UpdateDialogList();
|
UpdateDialogList();
|
||||||
UpdateDialogPublic();
|
UpdateDialogPublic();
|
||||||
UpdateDialogAction();
|
UpdateDialogAction();
|
||||||
|
|
||||||
if ( m_dialog == SD_SAVE )
|
if ( m_dialog == SD_SAVE )
|
||||||
{
|
{
|
||||||
SetFilenameField(pe, m_script->GetFilename());
|
SetFilenameField(pe, m_script->GetFilename());
|
||||||
|
@ -1437,10 +1438,12 @@ void CStudio::UpdateChangeList()
|
||||||
void CStudio::SetFilenameField(CEdit* edit, const std::string& filename)
|
void CStudio::SetFilenameField(CEdit* edit, const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string name = filename;
|
std::string name = filename;
|
||||||
if(name.length() > static_cast<unsigned int>(edit->GetMaxChar())) {
|
if (name.length() > static_cast<unsigned int>(edit->GetMaxChar()))
|
||||||
if(name.substr(name.length()-4) == ".txt")
|
{
|
||||||
|
if (name.substr(name.length()-4) == ".txt")
|
||||||
name = name.substr(0, name.length()-4);
|
name = name.substr(0, name.length()-4);
|
||||||
if(name.length() > static_cast<unsigned int>(edit->GetMaxChar())) {
|
if (name.length() > static_cast<unsigned int>(edit->GetMaxChar()))
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Warn("Tried to load too long filename!\n");
|
CLogger::GetInstancePointer()->Warn("Tried to load too long filename!\n");
|
||||||
name = name.substr(0, edit->GetMaxChar()); // truncates according to max length
|
name = name.substr(0, edit->GetMaxChar()); // truncates according to max length
|
||||||
}
|
}
|
||||||
|
@ -1555,11 +1558,12 @@ void CStudio::UpdateDialogList()
|
||||||
if ( pl == nullptr ) return;
|
if ( pl == nullptr ) return;
|
||||||
pl->Flush();
|
pl->Flush();
|
||||||
|
|
||||||
if(!CResourceManager::DirectoryExists(SearchDirectory(false)))
|
if (!CResourceManager::DirectoryExists(SearchDirectory(false)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<std::string> programs = CResourceManager::ListFiles(SearchDirectory(false));
|
std::vector<std::string> programs = CResourceManager::ListFiles(SearchDirectory(false));
|
||||||
for(auto& prog : programs) {
|
for (auto& prog : programs)
|
||||||
|
{
|
||||||
std::ostringstream temp;
|
std::ostringstream temp;
|
||||||
TimeToAscii(CResourceManager::GetLastModificationTime(SearchDirectory(false) + prog), time);
|
TimeToAscii(CResourceManager::GetLastModificationTime(SearchDirectory(false) + prog), time);
|
||||||
temp << prog << '\t' << CResourceManager::GetFileSize(SearchDirectory(false) + prog) << " \t" << time;
|
temp << prog << '\t' << CResourceManager::GetFileSize(SearchDirectory(false) + prog) << " \t" << time;
|
||||||
|
@ -1583,7 +1587,7 @@ std::string CStudio::SearchDirectory(bool bCreate)
|
||||||
|
|
||||||
if ( bCreate )
|
if ( bCreate )
|
||||||
{
|
{
|
||||||
if(!CResourceManager::DirectoryExists(dir))
|
if (!CResourceManager::DirectoryExists(dir))
|
||||||
CResourceManager::CreateDirectory(dir);
|
CResourceManager::CreateDirectory(dir);
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
|
@ -1657,7 +1661,7 @@ bool CStudio::WriteProgram()
|
||||||
if ( pw == nullptr ) return false;
|
if ( pw == nullptr ) return false;
|
||||||
pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
|
pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
|
||||||
if ( pe == nullptr ) return false;
|
if ( pe == nullptr ) return false;
|
||||||
|
|
||||||
if ( !pe->WriteText(std::string(dir)) ) return false;
|
if ( !pe->WriteText(std::string(dir)) ) return false;
|
||||||
|
|
||||||
m_script->SetFilename(filename);
|
m_script->SetFilename(filename);
|
||||||
|
|
Loading…
Reference in New Issue