1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 14:15:46 +00:00

Fix setGemPosition(), add more Lua functions:

- isShader()
- isParticleEffect()
- pe_start()
- pe_stop()
- pe_isRunning()
- isMiniMapCursorOkay()
This commit is contained in:
fgenesis 2013-10-25 01:47:24 +02:00
parent 69e25640fb
commit 3fe9ffc2cd
8 changed files with 65 additions and 13 deletions

View file

@ -4470,7 +4470,7 @@ void Avatar::action(int id, int state)
if (id == ACTION_PRIMARY && state)// !state
{
if (isMiniMapCursorOkay())
if (dsq->isMiniMapCursorOkay())
{
if (this->state.lockedToWall)
{
@ -5607,11 +5607,6 @@ Vector Avatar::getHeadPosition()
bool lastCursorKeyboard = false;
bool Avatar::isMiniMapCursorOkay()
{
return ((dsq->inputMode != INPUT_MOUSE) || (!dsq->game->miniMapRender || !dsq->game->miniMapRender->isCursorIn()));
}
void Avatar::onUpdate(float dt)
{
BBGE_PROF(Avatar_onUpdate);
@ -6427,7 +6422,7 @@ void Avatar::onUpdate(float dt)
float len = 0;
if (isMiniMapCursorOkay() && !isActing(ACTION_ROLL) &&
if (dsq->isMiniMapCursorOkay() && !isActing(ACTION_ROLL) &&
_isUnderWater && !riding && !boneLock.on &&
(movingOn || ((dsq->inputMode == INPUT_JOYSTICK || dsq->inputMode== INPUT_KEYBOARD) || (core->mouse.buttons.left || bursting))))
{

View file

@ -159,8 +159,6 @@ public:
bool zoomOverriden;
void clampPosition();
bool isMiniMapCursorOkay();
void splash(bool down);
InterpolatedVector myZoom;

View file

@ -5099,3 +5099,9 @@ void DSQ::resetLayerPasses()
renderObjectLayers[LR_ENTITIES].startPass = -2;
renderObjectLayers[LR_ENTITIES].endPass = 5;
}
bool DSQ::isMiniMapCursorOkay()
{
return ((inputMode != INPUT_MOUSE) || (!game->miniMapRender || !game->miniMapRender->isCursorIn()));
}

View file

@ -1572,6 +1572,7 @@ public:
virtual void onBackgroundUpdate();
void resetLayerPasses();
bool isMiniMapCursorOkay();
protected:

View file

@ -371,6 +371,7 @@ static void compile_time_assertions()
compile_assert(oo(Path) == oo(Avatar));
compile_assert(oo(Path) == oo(BaseText));
compile_assert(oo(Path) == oo(PauseQuad));
compile_assert(oo(Path) == oo(ParticleEffect));
#undef oo
}
#endif
@ -593,6 +594,16 @@ static SkeletalSprite *getSkeletalSprite(Entity *e)
return e ? &e->skeletalSprite : NULL;
}
static inline
ParticleEffect *getParticle(lua_State *L, int slot = 1)
{
ParticleEffect *q = (ParticleEffect*)lua_touserdata(L, slot);
ENSURE_TYPE(q, SCO_PARTICLE_EFFECT);
if (!q)
scriptDebug(L, "Invalid Particle Effect");
return q;
}
static bool looksLikeGlobal(const char *s)
{
for( ; *s; ++s)
@ -838,6 +849,8 @@ MakeTypeCheckFunc(isWeb, SCO_WEB)
MakeTypeCheckFunc(isIng, SCO_INGREDIENT)
MakeTypeCheckFunc(isBeam, SCO_BEAM)
MakeTypeCheckFunc(isText, SCO_TEXT)
MakeTypeCheckFunc(isShader, SCO_SHADER)
MakeTypeCheckFunc(isParticleEffect, SCO_PARTICLE_EFFECT)
#undef MakeTypeCheckFunc
@ -1794,7 +1807,8 @@ luaFunc(quad_getBorderAlpha)
MAKE_QUAD_FUNCS(beam, beam ) \
MAKE_ROBJ_FUNCS(getQuad, quad ) \
MAKE_ROBJ_FUNCS(getWeb, web ) \
MAKE_ROBJ_FUNCS(getText, text )
MAKE_ROBJ_FUNCS(getText, text ) \
MAKE_ROBJ_FUNCS(getParticle, pe )
// first time, create them. (There is a second use of this further down, with different MK_* macros)
EXPAND_FUNC_PROTOTYPES
@ -7979,8 +7993,9 @@ luaFunc(setGemPosition)
if(mapname.empty())
mapname = dsq->game->sceneName;
Vector pos(lua_tonumber(L, 2), lua_tonumber(L, 3));
bool result = false;
WorldMapTile *tile = dsq->continuity.worldMap.getWorldMapTile(getString(L, 1));
WorldMapTile *tile = dsq->continuity.worldMap.getWorldMapTile(mapname);
if(tile)
{
pos = dsq->game->worldMapRender->getWorldToTile(tile, pos, true, true);
@ -7991,6 +8006,7 @@ luaFunc(setGemPosition)
GemData& gem = *it;
gem.pos = pos;
gem.mapName = mapname;
result = true;
}
else
{
@ -8001,7 +8017,7 @@ luaFunc(setGemPosition)
{
debugLog("setGemPosition: Map tile does not exist: " + mapname);
}
luaReturnNil();
luaReturnBool(result);
}
luaFunc(removeGem)
@ -8336,6 +8352,11 @@ luaFunc(getScreenVirtualSize)
luaReturnVec2(core->getVirtualWidth(), core->getVirtualHeight());
}
luaFunc(isMiniMapCursorOkay)
{
luaReturnBool(dsq->isMiniMapCursorOkay());
}
luaFunc(inv_isFull)
{
IngredientData *data = dsq->continuity.getIngredientDataByName(getString(L, 1));
@ -8557,10 +8578,31 @@ luaFunc(shader_setFloat)
luaFunc(shader_delete)
{
if(core->afterEffectManager)
core->afterEffectManager->unloadShader(lua_tointeger(L, 1));
core->afterEffectManager->deleteShader(lua_tointeger(L, 1));
luaReturnNil();
}
luaFunc(pe_start)
{
ParticleEffect *pe = getParticle(L);
if (pe)
pe->start();
luaReturnNil();
}
luaFunc(pe_stop)
{
ParticleEffect *pe = getParticle(L);
if (pe)
pe->stop();
luaReturnNil();
}
luaFunc(pe_isRunning)
{
ParticleEffect *pe = getParticle(L);
luaReturnBool(pe && pe->isRunning());
}
//--------------------------------------------------------------------------------------------
@ -9483,6 +9525,7 @@ static const struct {
luaRegister(getScreenVirtualOff),
luaRegister(getScreenSize),
luaRegister(getScreenVirtualSize),
luaRegister(isMiniMapCursorOkay),
luaRegister(inv_isFull),
luaRegister(inv_getMaxAmount),
@ -9514,6 +9557,10 @@ static const struct {
luaRegister(shader_setInt),
luaRegister(shader_delete),
luaRegister(pe_start),
luaRegister(pe_stop),
luaRegister(pe_isRunning),
luaRegister(isQuad),
luaRegister(isNode),
luaRegister(isObject),
@ -9523,6 +9570,8 @@ static const struct {
luaRegister(isIng),
luaRegister(isBeam),
luaRegister(isText),
luaRegister(isShader),
luaRegister(isParticleEffect),
#undef MK_FUNC

View file

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ParticleEffect::ParticleEffect() : RenderObject()
{
addType(SCO_PARTICLE_EFFECT);
running = false;
waitForParticles = true;
effectLife = -1;

View file

@ -39,6 +39,7 @@ static const char *scriptObjTypeNames[] =
/* (1 <<11) */ "Text",
/* (1 <<12) */ "PauseQuad",
/* (1 <<13) */ "Shader",
/* (1 <<14) */ "ParticleEffect",
NULL
};

View file

@ -41,6 +41,7 @@ enum ScriptObjectType
SCO_TEXT = 0x0800,
SCO_PAUSEQUAD = 0x1000,
SCO_SHADER = 0x2000,
SCO_PARTICLE_EFFECT = 0x4000,
SCO_FORCE_32BIT = 0xFFFFFFFF
};