mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
CLuaInstCCText: Add various script functions
getLines()
getLines(test)
setDimensionsAll(x, y, w, h)
- Set Lua api version to 1.67
Origin commit data
------------------
Commit: 1576681543
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-12-01 (Thu, 01 Dec 2016)
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
* to luainstance.h changes
|
||||
*/
|
||||
#define LUA_API_VERSION_MAJOR 1
|
||||
#define LUA_API_VERSION_MINOR 66
|
||||
#define LUA_API_VERSION_MINOR 67
|
||||
|
@@ -54,14 +54,16 @@ CLuaCCText *CLuaInstCCText::CCTextCheck(lua_State *L, int n)
|
||||
void CLuaInstCCText::CCTextRegister(lua_State *L)
|
||||
{
|
||||
luaL_Reg meth[] = {
|
||||
{ "new", CLuaInstCCText::CCTextNew },
|
||||
{ "paint", CLuaInstCCText::CCTextPaint },
|
||||
{ "hide", CLuaInstCCText::CCTextHide },
|
||||
{ "setText", CLuaInstCCText::CCTextSetText },
|
||||
{ "scroll", CLuaInstCCText::CCTextScroll },
|
||||
{ "setCenterPos", CLuaInstCCText::CCTextSetCenterPos },
|
||||
{ "enableUTF8", CLuaInstCCText::CCTextEnableUTF8 },
|
||||
{ "__gc", CLuaInstCCText::CCTextDelete },
|
||||
{ "new", CLuaInstCCText::CCTextNew },
|
||||
{ "paint", CLuaInstCCText::CCTextPaint },
|
||||
{ "hide", CLuaInstCCText::CCTextHide },
|
||||
{ "setText", CLuaInstCCText::CCTextSetText },
|
||||
{ "getLines", CLuaInstCCText::CCTextGetLines },
|
||||
{ "scroll", CLuaInstCCText::CCTextScroll },
|
||||
{ "setCenterPos", CLuaInstCCText::CCTextSetCenterPos },
|
||||
{ "enableUTF8", CLuaInstCCText::CCTextEnableUTF8 },
|
||||
{ "setDimensionsAll", CLuaInstCCText::CCTextSetDimensionsAll },
|
||||
{ "__gc", CLuaInstCCText::CCTextDelete },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -214,6 +216,26 @@ int CLuaInstCCText::CCTextSetText(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstCCText::CCTextGetLines(lua_State *L)
|
||||
{
|
||||
CLuaCCText *D = CCTextCheck(L, 1);
|
||||
if (!D) return 0;
|
||||
|
||||
lua_Integer lines = 0;
|
||||
if (lua_gettop(L) == 2) {
|
||||
const char* Text = luaL_checkstring(L, 2);
|
||||
lines = (lua_Integer)CTextBox::getLines(Text);
|
||||
}
|
||||
else {
|
||||
CTextBox* ctb = D->ct->getCTextBoxObject();
|
||||
if (ctb)
|
||||
lines = (lua_Integer)ctb->getLines();
|
||||
}
|
||||
|
||||
lua_pushinteger(L, lines);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CLuaInstCCText::CCTextScroll(lua_State *L)
|
||||
{
|
||||
lua_assert(lua_istable(L,1));
|
||||
@@ -273,6 +295,28 @@ int CLuaInstCCText::CCTextEnableUTF8(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstCCText::CCTextSetDimensionsAll(lua_State *L)
|
||||
{
|
||||
CLuaCCText *D = CCTextCheck(L, 1);
|
||||
if (!D) return 0;
|
||||
lua_Integer x = luaL_checkint(L, 2);
|
||||
lua_Integer y = luaL_checkint(L, 3);
|
||||
lua_Integer w = luaL_checkint(L, 4);
|
||||
lua_Integer h = luaL_checkint(L, 5);
|
||||
if(x>-1 && y > -1 && w > 1 && h > 1){
|
||||
if (h > (lua_Integer)CFrameBuffer::getInstance()->getScreenHeight())
|
||||
h = (lua_Integer)CFrameBuffer::getInstance()->getScreenHeight();
|
||||
if (w > (lua_Integer)CFrameBuffer::getInstance()->getScreenWidth())
|
||||
w = (lua_Integer)CFrameBuffer::getInstance()->getScreenWidth();
|
||||
if(x > w)
|
||||
x = 0;
|
||||
if(y > h)
|
||||
y = 0;
|
||||
D->ct->setDimensionsAll(x,y,w,h);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstCCText::CCTextDelete(lua_State *L)
|
||||
{
|
||||
LUA_DEBUG("CLuaInstCCText::%s %d\n", __func__, lua_gettop(L));
|
||||
|
@@ -47,9 +47,11 @@ class CLuaInstCCText
|
||||
static int CCTextPaint(lua_State *L);
|
||||
static int CCTextHide(lua_State *L);
|
||||
static int CCTextSetText(lua_State *L);
|
||||
static int CCTextGetLines(lua_State *L);
|
||||
static int CCTextScroll(lua_State *L);
|
||||
static int CCTextSetCenterPos(lua_State *L);
|
||||
static int CCTextEnableUTF8(lua_State *L);
|
||||
static int CCTextSetDimensionsAll(lua_State *L);
|
||||
static int CCTextDelete(lua_State *L);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user