static int l_anims_set_marker(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    lua_pushboolean(L, pAnims->setFrameMarker(luaL_checkinteger(L, 2),
        static_cast<int>(luaL_checkinteger(L, 3)), static_cast<int>(luaL_checkinteger(L, 4))) ? 1 : 0);
    return 1;
}
Beispiel #2
0
static int l_anims_set_secondary_marker(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    lua_pushboolean(L, pAnims->setFrameSecondaryMarker((unsigned int)luaL_checkinteger(L, 2),
        luaL_checkint(L, 3), luaL_checkint(L, 4)) ? 1 : 0);
    return 1;
}
Beispiel #3
0
static int l_anims_getnext(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    int iFrame = luaL_checkint(L, 2);

    lua_pushinteger(L, pAnims->getNextFrame((unsigned int)iFrame));
    return 1;
}
static int l_anims_getfirst(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    int iAnim = static_cast<int>(luaL_checkinteger(L, 2));

    lua_pushinteger(L, pAnims->getFirstFrame(iAnim));
    return 1;
}
Beispiel #5
0
static int l_anims_set_spritesheet(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    THSpriteSheet* pSheet = luaT_testuserdata<THSpriteSheet>(L, 2);
    lua_settop(L, 2);

    pAnims->setSpriteSheet(pSheet);
    luaT_setenvfield(L, 1, "sprites");
    return 1;
}
/*!
    setCanvas(<video-surface>)
 */
static int l_anims_set_canvas(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    THRenderTarget* pCanvas = luaT_testuserdata<THRenderTarget>(L, 2);
    lua_settop(L, 2);

    pAnims->setCanvas(pCanvas);
    luaT_setenvfield(L, 1, "target");
    return 1;
}
/*!
    getAnimations(<tile-size>, <animation-name>) -> (<anim-north>, <anim-east>,  <anim-south>, <anim-west>)
 */
static int l_anims_getanims(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    int iTileSize = static_cast<int>(luaL_checkinteger(L, 2));
    const char *pName = luaL_checkstring(L, 3);

    const AnimationStartFrames &oFrames = pAnims->getNamedAnimations(pName, iTileSize);
    if (oFrames.iNorth < 0) { lua_pushnil(L); } else { lua_pushnumber(L, static_cast<double>(oFrames.iNorth)); }
    if (oFrames.iEast  < 0) { lua_pushnil(L); } else { lua_pushnumber(L, static_cast<double>(oFrames.iEast));  }
    if (oFrames.iSouth < 0) { lua_pushnil(L); } else { lua_pushnumber(L, static_cast<double>(oFrames.iSouth)); }
    if (oFrames.iWest  < 0) { lua_pushnil(L); } else { lua_pushnumber(L, static_cast<double>(oFrames.iWest));  }
    return 4;
}
Beispiel #8
0
static int l_anims_draw(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    THRenderTarget* pCanvas = luaT_testuserdata<THRenderTarget>(L, 2);
    int iFrame = luaL_checkint(L, 3);
    THLayers_t* pLayers = luaT_testuserdata<THLayers_t>(L, 4, luaT_upvalueindex(2));
    int iX = luaL_checkint(L, 5);
    int iY = luaL_checkint(L, 6);
    int iFlags = luaL_optint(L, 7, 0);

    pAnims->drawFrame(pCanvas, (unsigned int)iFrame, *pLayers, iX, iY, iFlags);

    lua_settop(L, 1);
    return 1;
}
/*!
    loadCustom(<data-of-an-animation-file>) -> true/false
 */
static int l_anims_loadcustom(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    size_t iDataLength;
    const uint8_t* pData = luaT_checkfile(L, 2, &iDataLength);

    if (pAnims->loadCustomAnimations(pData, iDataLength))
    {
        lua_pushboolean(L, 1);
    }
    else
    {
        lua_pushboolean(L, 0);
    }

    return 1;
}
Beispiel #10
0
static int l_anims_set_alt_pal(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    unsigned int iAnimation = luaL_checkint(L, 2);
    size_t iPalLen;
    const unsigned char *pPal = luaT_checkfile(L, 3, &iPalLen);
    if(iPalLen != 256)
        return luaL_typerror(L, 3, "GhostPalette string");

    pAnims->setAnimationAltPaletteMap(iAnimation, pPal);

    lua_getfenv(L, 1);
    lua_insert(L, 2);
    lua_settop(L, 4);
    lua_settable(L, 2);
    lua_settop(L, 1);
    return 1;
}
Beispiel #11
0
static int l_anims_load(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    size_t iStartDataLength, iFrameDataLength, iListDataLength, iElementDataLength;
    const unsigned char* pStartData = luaT_checkfile(L, 2, &iStartDataLength);
    const unsigned char* pFrameData = luaT_checkfile(L, 3, &iFrameDataLength);
    const unsigned char* pListData = luaT_checkfile(L, 4, &iListDataLength);
    const unsigned char* pElementData = luaT_checkfile(L, 5, &iElementDataLength);

    if(pAnims->loadFromTHFile(pStartData, iStartDataLength, pFrameData, iFrameDataLength,
        pListData, iListDataLength, pElementData, iElementDataLength))
    {
        lua_pushboolean(L, 1);
    }
    else
    {
        lua_pushboolean(L, 0);
    }

    return 1;
}
Beispiel #12
0
static int l_anim_set_anim(lua_State *L)
{
    THAnimation* pAnimation = luaT_testuserdata<THAnimation>(L);
    THAnimationManager* pManager = luaT_testuserdata<THAnimationManager>(L, 2);
    int iAnim = luaL_checkint(L, 3);
    if(iAnim < 0 || (unsigned int)iAnim >= pManager->getAnimationCount())
        luaL_argerror(L, 3, "Animation index out of bounds");

    if(lua_isnoneornil(L, 4))
        pAnimation->setFlags(0);
    else
        pAnimation->setFlags(luaL_checkint(L, 4));

    pAnimation->setAnimation(pManager, iAnim);
    lua_settop(L, 2);
    luaT_setenvfield(L, 1, "animator");
    lua_pushnil(L);
    luaT_setenvfield(L, 1, "morph_target");

    return 1;
}
static int l_anims_set_alt_pal(lua_State *L)
{
    THAnimationManager* pAnims = luaT_testuserdata<THAnimationManager>(L);
    size_t iAnimation = luaL_checkinteger(L, 2);
    size_t iPalLen;
    const uint8_t *pPal = luaT_checkfile(L, 3, &iPalLen);
    if(iPalLen != 256)
    {
        return luaL_argerror(L, 3, "GhostPalette string is not a valid palette");
    }
    uint32_t iAlt32 = static_cast<uint32_t>(luaL_checkinteger(L, 4));

    pAnims->setAnimationAltPaletteMap(iAnimation, pPal, iAlt32);

    lua_getfenv(L, 1);
    lua_insert(L, 2);
    lua_settop(L, 4);
    lua_settable(L, 2);
    lua_settop(L, 1);
    return 1;
}