From b79c459b8c05e2a3e847c19b09639f7ddfb4b38b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 29 May 2021 23:02:05 +0200 Subject: [PATCH] Fix fetching LUA tool name Resolves #60 --- radio/src/gui/colorlcd/radio_tools.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 811450484..02a900bba 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -25,6 +25,7 @@ #include "opentx.h" #include "libopenui.h" #include "lua/lua_api.h" +#include "standalone_lua.h" extern uint8_t g_moduleIdx; @@ -106,7 +107,7 @@ void RadioToolsPage::rebuild(FormWindow * window) char toolName[TOOL_NAME_MAXLEN + 1]; const char * label; char * ext = (char *)getFileExtension(path); - if (readToolName(path, toolName)) { + if (readToolName(toolName, path)) { label = toolName; } else { @@ -114,11 +115,18 @@ void RadioToolsPage::rebuild(FormWindow * window) label = getBasename(path); } new StaticText(window, grid.getLabelSlot(), "lua", BUTTON_BACKGROUND, CENTERED); - new TextButton(window, grid.getFieldSlot(1), label, [=]() -> uint8_t { - f_chdir("/SCRIPTS/TOOLS/"); - //luaExec(path); - return 0; - }, 0); + + std::string path_str(path); + new TextButton( + window, grid.getFieldSlot(1), label, + [window, path_str]() -> uint8_t { + f_chdir("/SCRIPTS/TOOLS/"); + luaExec(path_str.c_str()); + // TODO: check 'luaState' + new StandaloneLuaWindow(window); + return 0; + }, + 0); grid.nextLine(); } } @@ -187,4 +195,4 @@ void RadioToolsPage::rebuild(FormWindow * window) #endif window->setInnerHeight(grid.getWindowHeight()); -} \ No newline at end of file +}