1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-24 16:55:15 +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 "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());
}
}