1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-26 17:55:12 +03:00

Fix fetching LUA tool name

Resolves #60
This commit is contained in:
Raphael Coeffic 2021-05-29 23:02:05 +02:00
parent 4c4764d828
commit b79c459b8c

View file

@ -25,6 +25,7 @@
#include "opentx.h" #include "opentx.h"
#include "libopenui.h" #include "libopenui.h"
#include "lua/lua_api.h" #include "lua/lua_api.h"
#include "standalone_lua.h"
extern uint8_t g_moduleIdx; extern uint8_t g_moduleIdx;
@ -106,7 +107,7 @@ void RadioToolsPage::rebuild(FormWindow * window)
char toolName[TOOL_NAME_MAXLEN + 1]; char toolName[TOOL_NAME_MAXLEN + 1];
const char * label; const char * label;
char * ext = (char *)getFileExtension(path); char * ext = (char *)getFileExtension(path);
if (readToolName(path, toolName)) { if (readToolName(toolName, path)) {
label = toolName; label = toolName;
} }
else { else {
@ -114,11 +115,18 @@ void RadioToolsPage::rebuild(FormWindow * window)
label = getBasename(path); label = getBasename(path);
} }
new StaticText(window, grid.getLabelSlot(), "lua", BUTTON_BACKGROUND, CENTERED); new StaticText(window, grid.getLabelSlot(), "lua", BUTTON_BACKGROUND, CENTERED);
new TextButton(window, grid.getFieldSlot(1), label, [=]() -> uint8_t {
f_chdir("/SCRIPTS/TOOLS/"); std::string path_str(path);
//luaExec(path); new TextButton(
return 0; window, grid.getFieldSlot(1), label,
}, 0); [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(); grid.nextLine();
} }
} }
@ -187,4 +195,4 @@ void RadioToolsPage::rebuild(FormWindow * window)
#endif #endif
window->setInnerHeight(grid.getWindowHeight()); window->setInnerHeight(grid.getWindowHeight());
} }