mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Added Source:getType, removed Source:isStatic (resolves issue #776)
--HG-- branch : minor
This commit is contained in:
@@ -34,6 +34,11 @@ Source::~Source()
|
||||
{
|
||||
}
|
||||
|
||||
Source::Type Source::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
bool Source::getConstant(const char *in, Type &out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
|
||||
@@ -88,7 +88,6 @@ public:
|
||||
|
||||
virtual void setLooping(bool looping) = 0;
|
||||
virtual bool isLooping() const = 0;
|
||||
virtual bool isStatic() const = 0;
|
||||
|
||||
virtual void setMinVolume(float volume) = 0;
|
||||
virtual float getMinVolume() const = 0;
|
||||
@@ -103,6 +102,7 @@ public:
|
||||
virtual float getMaxDistance() const = 0;
|
||||
|
||||
virtual int getChannels() const = 0;
|
||||
virtual Type getType() const;
|
||||
|
||||
static bool getConstant(const char *in, Type &out);
|
||||
static bool getConstant(Type in, const char *&out);
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
static bool getConstant(Unit in, const char *&out);
|
||||
|
||||
protected:
|
||||
|
||||
Type type;
|
||||
|
||||
private:
|
||||
|
||||
@@ -169,11 +169,6 @@ bool Source::isLooping() const
|
||||
return looping;
|
||||
}
|
||||
|
||||
bool Source::isStatic() const
|
||||
{
|
||||
return (type == TYPE_STATIC);
|
||||
}
|
||||
|
||||
void Source::setMinVolume(float volume)
|
||||
{
|
||||
this->minVolume = volume;
|
||||
|
||||
@@ -66,7 +66,6 @@ public:
|
||||
virtual bool isRelative() const;
|
||||
void setLooping(bool looping);
|
||||
bool isLooping() const;
|
||||
bool isStatic() const;
|
||||
virtual void setMinVolume(float volume);
|
||||
virtual float getMinVolume() const;
|
||||
virtual void setMaxVolume(float volume);
|
||||
|
||||
@@ -631,7 +631,7 @@ void Source::reset()
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, referenceDistance);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, rolloffFactor);
|
||||
alSourcef(source, AL_MAX_DISTANCE, maxDistance);
|
||||
alSourcei(source, AL_LOOPING, isStatic() && isLooping() ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_LOOPING, (type == TYPE_STATIC) && isLooping() ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_CONE_INNER_ANGLE, cone.innerAngle);
|
||||
alSourcei(source, AL_CONE_OUTER_ANGLE, cone.outerAngle);
|
||||
@@ -693,11 +693,6 @@ int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
|
||||
return decoded;
|
||||
}
|
||||
|
||||
bool Source::isStatic() const
|
||||
{
|
||||
return (type == TYPE_STATIC);
|
||||
}
|
||||
|
||||
void Source::setMinVolume(float volume)
|
||||
{
|
||||
if (valid)
|
||||
|
||||
@@ -105,7 +105,6 @@ public:
|
||||
virtual bool isRelative() const;
|
||||
void setLooping(bool looping);
|
||||
bool isLooping() const;
|
||||
bool isStatic() const;
|
||||
virtual void setMinVolume(float volume);
|
||||
virtual float getMinVolume() const;
|
||||
virtual void setMaxVolume(float volume);
|
||||
|
||||
@@ -275,13 +275,6 @@ int w_Source_isPlaying(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_isStatic(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
luax_pushboolean(L, t->isStatic());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_setVolumeLimits(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
@@ -346,6 +339,19 @@ int w_Source_getChannels(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_getType(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
Source::Type type = t->getType();
|
||||
const char *str = nullptr;
|
||||
|
||||
if (!Source::getConstant(type, str))
|
||||
return luaL_error(L, "Unknown Source type.");
|
||||
|
||||
lua_pushstring(L, str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] =
|
||||
{
|
||||
{ "clone", w_Source_clone },
|
||||
@@ -379,7 +385,6 @@ static const luaL_Reg functions[] =
|
||||
{ "isStopped", w_Source_isStopped },
|
||||
{ "isPaused", w_Source_isPaused },
|
||||
{ "isPlaying", w_Source_isPlaying },
|
||||
{ "isStatic", w_Source_isStatic },
|
||||
|
||||
{ "setVolumeLimits", w_Source_setVolumeLimits },
|
||||
{ "getVolumeLimits", w_Source_getVolumeLimits },
|
||||
@@ -389,6 +394,7 @@ static const luaL_Reg functions[] =
|
||||
{ "getRolloff", w_Source_getRolloff},
|
||||
|
||||
{ "getChannels", w_Source_getChannels },
|
||||
{ "getType", w_Source_getType },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@@ -57,7 +57,6 @@ int w_Source_isLooping(lua_State *L);
|
||||
int w_Source_isStopped(lua_State *L);
|
||||
int w_Source_isPaused(lua_State *L);
|
||||
int w_Source_isPlaying(lua_State *L);
|
||||
int w_Source_isStatic(lua_State *L);
|
||||
int w_Source_setVolumeLimits(lua_State *L);
|
||||
int w_Source_getVolumeLimits(lua_State *L);
|
||||
int w_Source_setAttenuationDistances(lua_State *L);
|
||||
@@ -65,6 +64,7 @@ int w_Source_getAttenuationDistances(lua_State *L);
|
||||
int w_Source_setRolloff(lua_State *L);
|
||||
int w_Source_getRolloff(lua_State *L);
|
||||
int w_Source_getChannels(lua_State *L);
|
||||
int w_Source_getType(lua_State *L);
|
||||
extern "C" int luaopen_source(lua_State *L);
|
||||
|
||||
} // audio
|
||||
|
||||
Reference in New Issue
Block a user