Skip to content

Commit

Permalink
update lua bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Jun 28, 2024
1 parent 5b29261 commit 11a8cdb
Show file tree
Hide file tree
Showing 36 changed files with 297 additions and 170 deletions.
3 changes: 2 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"diagnostics.disable": ["redundant-return-value", "lowercase-global"],
"workspace.library": ["addons"]
"workspace.library": ["addons"],
"workspace.ignoreSubmodules": false
}
15 changes: 0 additions & 15 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,5 @@
]
]
},
{
"type": "LuaHelper-Debug",
"request": "launch",
"name": "LuaPanda",
"description": "通用模式,通常调试项目请选择此模式",
"cwd": "${workspaceFolder}/assets",
"luaFileExtension": "",
"connectionPort": 8818,
"stopOnEntry": true,
"useCHook": true,
"args": ["--workdir", "${workspaceFolder}/assets", "--lua-debug", "luapanda"],
"windows": {"program": "${workspaceFolder}/build/vs-build/bin/cocoslua/Debug/cocoslua.exe"},
"osx": {"program": "${workspaceFolder}/build/mac-build/bin/cocoslua/Debug/cocoslua.app/Contents/MacOS/cocoslua"},
"autoPathMode": true
}
]
}
7 changes: 4 additions & 3 deletions assets/src/cclua/ui/dataloader.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local font = require "cclua.font"
local Align = require "cclua.ui.Align"
local TouchStyle = require "cclua.ui.TouchStyle"
local olua = require "olua.c"
local font = require "cclua.font"
local Align = require "cclua.ui.Align"
local TouchStyle = require "cclua.ui.TouchStyle"

local assert = assert

Expand Down
2 changes: 1 addition & 1 deletion assets/src/test/SpineTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local SkeletonAnimation = require "spine.SkeletonAnimation"
local SkeletonData = require "spine.SkeletonData"

function SpineTest:ctor()
local data = SkeletonData.new("res/spine/raptor-pro.skel", "res/spine/raptor-pro.atlas", 0.4)
local data = SkeletonData.create("res/spine/raptor-pro.skel", "res/spine/raptor-pro.atlas", 0.4)
local animation = SkeletonAnimation.createWithData(data)
animation.x = 500
animation.y = 100
Expand Down
13 changes: 13 additions & 0 deletions frameworks/cclua/src/cclua/cclua-extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ olua_Return cocos2d::RectExtend::__call(lua_State *L)
return 1;
}

void cocos2d::RenderTextureExtend::beginVisit(cocos2d::RenderTexture *rt) {
rt->begin();
}

void cocos2d::RenderTextureExtend::endVisit(cocos2d::RenderTexture *rt) {
rt->end();
}

#ifdef CCLUA_BUILD_SPINE
using namespace spine;

Expand Down Expand Up @@ -551,6 +559,11 @@ olua_Return SkeletonDataExtend::__gc(lua_State *L)
return 0;
}

olua_Return SkeletonDataExtend::dispose(lua_State *L)
{
return SkeletonDataExtend::__gc(L);
}

olua_Return SkeletonDataExtend::create(lua_State *L, const char *skel_path, const char *atlas_path, float scale)
{
auto texture_loader = new spine::Cocos2dTextureLoader();
Expand Down
7 changes: 7 additions & 0 deletions frameworks/cclua/src/cclua/cclua-extend.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ class RectExtend {
static olua_Return __call(lua_State *L);
};

class RenderTextureExtend {
public:
static void beginVisit(cocos2d::RenderTexture *rt);
static void endVisit(cocos2d::RenderTexture *rt);
};

NS_CC_END

#ifdef CCLUA_BUILD_SPINE
Expand All @@ -292,6 +298,7 @@ namespace spine {
class SkeletonDataExtend {
public:
static olua_Return __gc(lua_State *L);
static olua_Return dispose(lua_State *L);
static olua_Return create(lua_State *L, const char *skelPath, const char *atlasPath, float scale = 1.0f);
};

Expand Down
37 changes: 34 additions & 3 deletions frameworks/cclua/src/lua-bindings/lua_cocos2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,6 @@ OLUA_LIB int luaopen_cocos2d_Director(lua_State *L)
oluacls_func(L, "convertToUI", _cocos2d_Director_convertToUI);
oluacls_func(L, "drawScene", _cocos2d_Director_drawScene);
oluacls_func(L, "end", _cocos2d_Director_end);
oluacls_func(L, "exit", _cocos2d_Director_end);
oluacls_func(L, "getActionManager", _cocos2d_Director_getActionManager);
oluacls_func(L, "getAnimationInterval", _cocos2d_Director_getAnimationInterval);
oluacls_func(L, "getConsole", _cocos2d_Director_getConsole);
Expand Down Expand Up @@ -32164,6 +32163,22 @@ static int _cocos2d_RenderTexture_begin(lua_State *L)
return 0;
}

static int _cocos2d_RenderTexture_beginVisit(lua_State *L)
{
olua_startinvoke(L);

cocos2d::RenderTexture *arg1 = nullptr; /** rt */

olua_check_object(L, 1, &arg1, "cc.RenderTexture");

// @extend(cocos2d::RenderTextureExtend) static void beginVisit(cocos2d::RenderTexture *rt)
cocos2d::RenderTextureExtend::beginVisit(arg1);

olua_endinvoke(L);

return 0;
}

static int _cocos2d_RenderTexture_beginWithClear$1(lua_State *L)
{
olua_startinvoke(L);
Expand Down Expand Up @@ -32441,6 +32456,22 @@ static int _cocos2d_RenderTexture_end(lua_State *L)
return 0;
}

static int _cocos2d_RenderTexture_endVisit(lua_State *L)
{
olua_startinvoke(L);

cocos2d::RenderTexture *arg1 = nullptr; /** rt */

olua_check_object(L, 1, &arg1, "cc.RenderTexture");

// @extend(cocos2d::RenderTextureExtend) static void endVisit(cocos2d::RenderTexture *rt)
cocos2d::RenderTextureExtend::endVisit(arg1);

olua_endinvoke(L);

return 0;
}

static int _cocos2d_RenderTexture_getClearColor(lua_State *L)
{
olua_startinvoke(L);
Expand Down Expand Up @@ -33324,14 +33355,14 @@ OLUA_LIB int luaopen_cocos2d_RenderTexture(lua_State *L)
{
oluacls_class<cocos2d::RenderTexture, cocos2d::Node>(L, "cc.RenderTexture");
oluacls_func(L, "begin", _cocos2d_RenderTexture_begin);
oluacls_func(L, "beginVisit", _cocos2d_RenderTexture_begin);
oluacls_func(L, "beginVisit", _cocos2d_RenderTexture_beginVisit);
oluacls_func(L, "beginWithClear", _cocos2d_RenderTexture_beginWithClear);
oluacls_func(L, "clear", _cocos2d_RenderTexture_clear);
oluacls_func(L, "clearDepth", _cocos2d_RenderTexture_clearDepth);
oluacls_func(L, "clearStencil", _cocos2d_RenderTexture_clearStencil);
oluacls_func(L, "create", _cocos2d_RenderTexture_create);
oluacls_func(L, "end", _cocos2d_RenderTexture_end);
oluacls_func(L, "endVisit", _cocos2d_RenderTexture_end);
oluacls_func(L, "endVisit", _cocos2d_RenderTexture_endVisit);
oluacls_func(L, "getClearColor", _cocos2d_RenderTexture_getClearColor);
oluacls_func(L, "getClearDepth", _cocos2d_RenderTexture_getClearDepth);
oluacls_func(L, "getClearFlags", _cocos2d_RenderTexture_getClearFlags);
Expand Down
Loading

0 comments on commit 11a8cdb

Please sign in to comment.