From b9b623698129c414c22c1152994c69f96800a0df Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Fri, 24 Nov 2023 22:13:53 -0600 Subject: [PATCH] Singe Toolbar for ZB is working! --- src/main.c | 1 + src/singe.c | 13 ++++++++++--- thirdparty/lua/src/loslib.c | 8 +++++++- zbstudio/packages/singetoolbar.lua | 21 ++++++++++++++------- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index b87e61811..3d19f91e5 100644 --- a/src/main.c +++ b/src/main.c @@ -891,6 +891,7 @@ void unpackGames(void) { packageType = x; break; } + x++; } if (packageType >= 0) { showHeader(); diff --git a/src/singe.c b/src/singe.c index 2d31280bf..114d8efb4 100644 --- a/src/singe.c +++ b/src/singe.c @@ -4621,7 +4621,8 @@ void startControllers(void) { void startLuaContext(lua_State *L) { - size_t length; + size_t length; + int i; // What to do when bad things happen lua_atpanic(L, luaError); @@ -4639,9 +4640,15 @@ void startLuaContext(lua_State *L) { lua_getfield(L, -1, "searchers"); // Get the number of existing searchers in the table length = lua_rawlen(L, -1); - // Add our own searcher to the list + // Shift existing elements to make room for ours + for (i=length+1; i>1; i--) { + lua_rawgeti(L, -2, i - 1); + lua_rawseti(L, -2, i); + } + // Add our own searcher to the front of the list lua_pushcfunction(L, luaSearcher); - lua_rawseti(L, -2, length + 1); + //lua_rawseti(L, -2, length + 1); + lua_rawseti(L, -2, 1); // Remove the seachers and the package tables from the stack lua_pop(L, 2); } diff --git a/thirdparty/lua/src/loslib.c b/thirdparty/lua/src/loslib.c index ad5a92768..6c02f2eda 100644 --- a/thirdparty/lua/src/loslib.c +++ b/thirdparty/lua/src/loslib.c @@ -166,10 +166,16 @@ static int os_rename (lua_State *L) { } +#include static int os_tmpname (lua_State *L) { char buff[LUA_TMPNAMBUFSIZE]; int err; - lua_tmpnam(buff, err); + + //lua_tmpnam(buff, err); + int fd = mkstemp(buff); // With this… + if (fd >= 0) + close(fd); + if (l_unlikely(err)) return luaL_error(L, "unable to generate a unique filename"); lua_pushstring(L, buff); diff --git a/zbstudio/packages/singetoolbar.lua b/zbstudio/packages/singetoolbar.lua index eea403d91..ddb481bca 100644 --- a/zbstudio/packages/singetoolbar.lua +++ b/zbstudio/packages/singetoolbar.lua @@ -25,6 +25,7 @@ local configId = ID("singemenu.singemenu") local id = ID("singetoolbar.singemenu") local tool local settings +local line = "-------------------------------------------------------------------------------" local function utilDump(o) @@ -142,9 +143,13 @@ local function configureSinge(self) end +local function singeEnd() + ide:Print("\n"..line) +end + + local function singeOutput(s) - --ide:GetOutput():Write(s) - ide:Print("[] " .. s) + ide:GetOutput():Write(s) end @@ -153,6 +158,8 @@ local function startSinge(self) local cdir = wx.wxFileName.GetCwd() local wdir local launch + local env + local ok if settings then if not settings.singe then message = "You must specify the Singe executable in the Singe configuration." end @@ -171,13 +178,13 @@ local function startSinge(self) launch = settings.singe .. ' ' .. settings.options .. ' -v ' .. settings.video .. ' ' .. settings.script launch = launch:gsub(wdir, "./", 1):gsub(wdir, "") wdir = wx.wxFileName.DirName(wdir):GetFullPath() + ide:Print(line) ide:Print(launch) - ide:ExecuteCommand(launch, wdir, singeOutput) - - --wx.wxFileName.SetCwd(wdir) - --wx.wxExecute(launch) - --wx.wxFileName.SetCwd(cdir) + ok, env = wx.wxGetEnv('LUA_CPATH') + wx.wxUnsetEnv('LUA_CPATH') + ide:ExecuteCommand(launch, wdir, singeOutput, singeEnd) + wx.wxSetEnv('LUA_CPATH', env) end