MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / PostEffectApply

Method PostEffectApply

LuaSTGPlus/LuaWrapper.cpp:1477–1518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1475 return 0;
1476 }
1477 static int PostEffectApply(lua_State* L)LNOEXCEPT
1478 {
1479 const char* name = luaL_checkstring(L, 1);
1480 BlendMode blend = TranslateBlendMode(L, 2);
1481
1482 // 获取fx
1483 ResFX* p = LRES.FindFX(name);
1484 if (!p)
1485 return luaL_error(L, "PostEffectApply: can't find effect '%s'.", name);
1486 if (lua_istable(L, 3))
1487 {
1488 // 设置table上的参数到fx
1489 lua_pushnil(L); // s s t ... nil
1490 while (0 != lua_next(L, 3))
1491 {
1492 // s s t ... nil key value
1493 const char* key = luaL_checkstring(L, -2);
1494 if (lua_isnumber(L, -1))
1495 p->SetValue(key, (float)lua_tonumber(L, -1));
1496 else if (lua_isstring(L, -1))
1497 {
1498 ResTexture* pTex = LRES.FindTexture(lua_tostring(L, -1));
1499 if (!pTex)
1500 return luaL_error(L, "PostEffectApply: can't find texture '%s'.", lua_tostring(L, -1));
1501 p->SetValue(key, pTex->GetTexture());
1502 }
1503 else if (lua_isuserdata(L, -1))
1504 {
1505 fcyColor c = *static_cast<fcyColor*>(luaL_checkudata(L, -1, TYPENAME_COLOR));
1506 p->SetValue(key, c);
1507 }
1508 else
1509 return luaL_error(L, "PostEffectApply: invalid data type.");
1510
1511 lua_pop(L, 1); // s s t ... nil key
1512 }
1513 }
1514
1515 if (!LAPP.PostEffectApply(p, blend))
1516 return luaL_error(L, "PostEffectApply failed.");
1517 return 0;
1518 }
1519
1520 // 声音控制函数
1521 static int PlaySound(lua_State* L)LNOEXCEPT

Callers

nothing calls this directly

Calls 5

TranslateBlendModeFunction · 0.85
FindFXMethod · 0.80
SetValueMethod · 0.80
FindTextureMethod · 0.80
GetTextureMethod · 0.45

Tested by

no test coverage detected