Merge dev and dev-graphics
commit
5a6b3f005a
|
@ -48,7 +48,7 @@ endif()
|
||||||
|
|
||||||
# Global compile flags
|
# Global compile flags
|
||||||
# These are specific to GCC/MinGW; for other compilers, change as necessary
|
# These are specific to GCC/MinGW; for other compilers, change as necessary
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=c++11")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Global compile flags
|
# Global compile flags
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
|
|
|
@ -1520,7 +1520,16 @@ void CApplication::SetLanguage(Language language)
|
||||||
if (locale.empty())
|
if (locale.empty())
|
||||||
{
|
{
|
||||||
char *envLang = getenv("LANGUAGE");
|
char *envLang = getenv("LANGUAGE");
|
||||||
if (strncmp(envLang,"en",2) == 0)
|
if (envLang == NULL)
|
||||||
|
{
|
||||||
|
envLang = getenv("LANG");
|
||||||
|
}
|
||||||
|
if (envLang == NULL)
|
||||||
|
{
|
||||||
|
GetLogger()->Error("Failed to get language from environment, setting default language");
|
||||||
|
m_language = LANGUAGE_ENGLISH;
|
||||||
|
}
|
||||||
|
else if (strncmp(envLang,"en",2) == 0)
|
||||||
{
|
{
|
||||||
m_language = LANGUAGE_ENGLISH;
|
m_language = LANGUAGE_ENGLISH;
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1541,7 @@ void CApplication::SetLanguage(Language language)
|
||||||
{
|
{
|
||||||
m_language = LANGUAGE_FRENCH;
|
m_language = LANGUAGE_FRENCH;
|
||||||
}
|
}
|
||||||
else if (strncmp(envLang,"po",2) == 0)
|
else if (strncmp(envLang,"pl",2) == 0)
|
||||||
{
|
{
|
||||||
m_language = LANGUAGE_POLISH;
|
m_language = LANGUAGE_POLISH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
set(CMAKE_BUILD_TYPE debug)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
set(CMAKE_BUILD_TYPE debug)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
set(MODELFILE_TEST_SOURCES
|
set(MODELFILE_TEST_SOURCES
|
||||||
|
|
|
@ -8,7 +8,6 @@ find_package(PNG REQUIRED)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
set(CMAKE_BUILD_TYPE debug)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
set(ADD_LIBS "")
|
set(ADD_LIBS "")
|
||||||
|
|
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
set(CMAKE_BUILD_TYPE debug)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
|
@ -49,9 +49,14 @@ void ALSound::CleanUp()
|
||||||
if (mEnabled) {
|
if (mEnabled) {
|
||||||
GetLogger()->Info("Unloading files and closing device...\n");
|
GetLogger()->Info("Unloading files and closing device...\n");
|
||||||
StopAll();
|
StopAll();
|
||||||
|
|
||||||
|
for (auto channel : mChannels) {
|
||||||
|
delete channel.second;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto item : mSounds)
|
for (auto item : mSounds) {
|
||||||
delete item.second;
|
delete item.second;
|
||||||
|
}
|
||||||
|
|
||||||
mEnabled = false;
|
mEnabled = false;
|
||||||
alutExit();
|
alutExit();
|
||||||
|
@ -213,7 +218,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||||
|
|
||||||
it.second->SetPriority(priority);
|
it.second->SetPriority(priority);
|
||||||
channel = it.first;
|
channel = it.first;
|
||||||
bAlreadyLoaded = true;
|
bAlreadyLoaded = it.second->IsLoaded();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,15 +301,20 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
|
||||||
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
|
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency);
|
GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency);
|
||||||
|
|
||||||
int channel;
|
int channel;
|
||||||
bool bAlreadyLoaded;
|
bool bAlreadyLoaded;
|
||||||
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
|
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
|
||||||
return -1;
|
return -1;
|
||||||
if ( !bAlreadyLoaded ) {
|
|
||||||
mChannels[channel]->SetBuffer(mSounds[sound]);
|
bAlreadyLoaded = false;
|
||||||
|
if (!bAlreadyLoaded) {
|
||||||
|
if (!mChannels[channel]->SetBuffer(mSounds[sound])) {
|
||||||
|
GetLogger()->Trace("ALSound::Play SetBuffer failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Position(channel, pos);
|
Position(channel, pos);
|
||||||
|
|
|
@ -36,6 +36,7 @@ Channel::Channel() {
|
||||||
|
|
||||||
Channel::~Channel() {
|
Channel::~Channel() {
|
||||||
if (mReady) {
|
if (mReady) {
|
||||||
|
alSourceStop(mSource);
|
||||||
alSourcei(mSource, AL_BUFFER, 0);
|
alSourcei(mSource, AL_BUFFER, 0);
|
||||||
alDeleteSources(1, &mSource);
|
alDeleteSources(1, &mSource);
|
||||||
if (alCheck())
|
if (alCheck())
|
||||||
|
@ -45,7 +46,7 @@ Channel::~Channel() {
|
||||||
|
|
||||||
|
|
||||||
bool Channel::Play() {
|
bool Channel::Play() {
|
||||||
if (!mReady)
|
if (!mReady || mBuffer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
alSourcePlay(mSource);
|
alSourcePlay(mSource);
|
||||||
|
@ -56,7 +57,7 @@ bool Channel::Play() {
|
||||||
|
|
||||||
|
|
||||||
bool Channel::SetPosition(Math::Vector pos) {
|
bool Channel::SetPosition(Math::Vector pos) {
|
||||||
if (!mReady)
|
if (!mReady || mBuffer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z);
|
alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z);
|
||||||
|
@ -70,7 +71,7 @@ bool Channel::SetPosition(Math::Vector pos) {
|
||||||
|
|
||||||
bool Channel::SetFrequency(float freq)
|
bool Channel::SetFrequency(float freq)
|
||||||
{
|
{
|
||||||
if (!mReady)
|
if (!mReady || mBuffer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
alSourcef(mSource, AL_PITCH, freq);
|
alSourcef(mSource, AL_PITCH, freq);
|
||||||
|
@ -85,7 +86,7 @@ bool Channel::SetFrequency(float freq)
|
||||||
float Channel::GetFrequency()
|
float Channel::GetFrequency()
|
||||||
{
|
{
|
||||||
ALfloat freq;
|
ALfloat freq;
|
||||||
if (!mReady)
|
if (!mReady || mBuffer == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
alGetSourcef(mSource, AL_PITCH, &freq);
|
alGetSourcef(mSource, AL_PITCH, &freq);
|
||||||
|
@ -100,7 +101,7 @@ float Channel::GetFrequency()
|
||||||
|
|
||||||
bool Channel::SetVolume(float vol)
|
bool Channel::SetVolume(float vol)
|
||||||
{
|
{
|
||||||
if (!mReady || vol < 0)
|
if (!mReady || vol < 0 || mBuffer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
alSourcef(mSource, AL_GAIN, vol / MAXVOLUME);
|
alSourcef(mSource, AL_GAIN, vol / MAXVOLUME);
|
||||||
|
@ -115,7 +116,7 @@ bool Channel::SetVolume(float vol)
|
||||||
float Channel::GetVolume()
|
float Channel::GetVolume()
|
||||||
{
|
{
|
||||||
ALfloat vol;
|
ALfloat vol;
|
||||||
if (!mReady)
|
if (!mReady || mBuffer == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
alGetSourcef(mSource, AL_GAIN, &vol);
|
alGetSourcef(mSource, AL_GAIN, &vol);
|
||||||
|
@ -201,6 +202,9 @@ void Channel::ResetOper()
|
||||||
|
|
||||||
|
|
||||||
Sound Channel::GetSoundType() {
|
Sound Channel::GetSoundType() {
|
||||||
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return SOUND_NONE;
|
||||||
|
|
||||||
return mBuffer->GetSoundType();
|
return mBuffer->GetSoundType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +237,8 @@ void Channel::AdjustVolume(float volume) {
|
||||||
|
|
||||||
bool Channel::IsPlaying() {
|
bool Channel::IsPlaying() {
|
||||||
ALint status;
|
ALint status;
|
||||||
if (!mReady) return false;
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
alGetSourcei(mSource, AL_SOURCE_STATE, &status);
|
alGetSourcei(mSource, AL_SOURCE_STATE, &status);
|
||||||
if (alCheck()) {
|
if (alCheck()) {
|
||||||
|
@ -249,8 +254,15 @@ bool Channel::IsReady() {
|
||||||
return mReady;
|
return mReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Channel::IsLoaded() {
|
||||||
|
return mBuffer == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Channel::Stop() {
|
bool Channel::Stop() {
|
||||||
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
alSourceStop(mSource);
|
alSourceStop(mSource);
|
||||||
if (alCheck()) {
|
if (alCheck()) {
|
||||||
GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode());
|
GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode());
|
||||||
|
@ -262,6 +274,9 @@ bool Channel::Stop() {
|
||||||
|
|
||||||
float Channel::GetCurrentTime()
|
float Channel::GetCurrentTime()
|
||||||
{
|
{
|
||||||
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
ALfloat current;
|
ALfloat current;
|
||||||
alGetSourcef(mSource, AL_SEC_OFFSET, ¤t);
|
alGetSourcef(mSource, AL_SEC_OFFSET, ¤t);
|
||||||
if (alCheck()) {
|
if (alCheck()) {
|
||||||
|
@ -274,6 +289,9 @@ float Channel::GetCurrentTime()
|
||||||
|
|
||||||
void Channel::SetCurrentTime(float current)
|
void Channel::SetCurrentTime(float current)
|
||||||
{
|
{
|
||||||
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
alSourcef(mSource, AL_SEC_OFFSET, current);
|
alSourcef(mSource, AL_SEC_OFFSET, current);
|
||||||
if (alCheck())
|
if (alCheck())
|
||||||
GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode());
|
GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode());
|
||||||
|
@ -282,6 +300,9 @@ void Channel::SetCurrentTime(float current)
|
||||||
|
|
||||||
float Channel::GetDuration()
|
float Channel::GetDuration()
|
||||||
{
|
{
|
||||||
|
if (!mReady || mBuffer == nullptr)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
return mBuffer->GetDuration();
|
return mBuffer->GetDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ class Channel
|
||||||
float GetVolume();
|
float GetVolume();
|
||||||
bool IsPlaying();
|
bool IsPlaying();
|
||||||
bool IsReady();
|
bool IsReady();
|
||||||
|
bool IsLoaded();
|
||||||
|
|
||||||
bool SetBuffer(Buffer *);
|
bool SetBuffer(Buffer *);
|
||||||
bool HasEnvelope();
|
bool HasEnvelope();
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
**/
|
**/
|
||||||
enum Sound
|
enum Sound
|
||||||
{
|
{
|
||||||
|
SOUND_NONE = -1,
|
||||||
SOUND_CLICK = 0,
|
SOUND_CLICK = 0,
|
||||||
SOUND_BOUM = 1,
|
SOUND_BOUM = 1,
|
||||||
SOUND_EXPLO = 2,
|
SOUND_EXPLO = 2,
|
||||||
|
|
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
set(CMAKE_BUILD_TYPE debug)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
Loading…
Reference in New Issue