diff --git a/Release/com.ctytler.dcs.streamDeckPlugin b/Release/com.ctytler.dcs.streamDeckPlugin index f08df162..9bdad806 100644 Binary files a/Release/com.ctytler.dcs.streamDeckPlugin and b/Release/com.ctytler.dcs.streamDeckPlugin differ diff --git a/Sources/DcsInterface/DcsIdLookup.cpp b/Sources/DcsInterface/DcsIdLookup.cpp index cd8d28a0..1244c02f 100644 --- a/Sources/DcsInterface/DcsIdLookup.cpp +++ b/Sources/DcsInterface/DcsIdLookup.cpp @@ -27,7 +27,9 @@ json get_installed_modules(const std::string &dcs_install_path, const std::strin json get_clickabledata(const std::string &dcs_install_path, const std::string &module_name, const std::string &lua_script) { - json clickabledata_items; + json clickabledata_and_result; + clickabledata_and_result["clickabledata_items"] = json::array(); + clickabledata_and_result["result"] = ""; // create new Lua state lua_State *lua_state; @@ -47,22 +49,25 @@ json get_clickabledata(const std::string &dcs_install_path, const int file_status = luaL_loadfile(lua_state, lua_script.c_str()); if (file_status != 0) { lua_close(lua_state); - return clickabledata_items; + clickabledata_and_result["result"] = "Lua file load error: " + std::to_string(file_status); + return clickabledata_and_result; } const int script_status = lua_pcall(lua_state, 0, LUA_MULTRET, 0); if (script_status != 0) { lua_close(lua_state); - return clickabledata_items; + clickabledata_and_result["result"] = "Lua script runtime error: " + std::to_string(script_status); + return clickabledata_and_result; } // Handle each of the return values one at a time. while ((lua_gettop(lua_state) - lua_stack_size) > 0) { - clickabledata_items.push_back(lua_tostring(lua_state, lua_gettop(lua_state))); + clickabledata_and_result["result"] = "success"; + clickabledata_and_result["clickabledata_items"].push_back(lua_tostring(lua_state, lua_gettop(lua_state))); lua_pop(lua_state, 1); } // close the Lua state lua_close(lua_state); - return clickabledata_items; + return clickabledata_and_result; } diff --git a/Sources/MyStreamDeckPlugin.cpp b/Sources/MyStreamDeckPlugin.cpp index e792161c..0afcebd6 100644 --- a/Sources/MyStreamDeckPlugin.cpp +++ b/Sources/MyStreamDeckPlugin.cpp @@ -109,7 +109,7 @@ void MyStreamDeckPlugin::DidReceiveGlobalSettings(const json &inPayload) { try { dcs_interface_ = new DcsInterface(connection_settings); } catch (const std::exception &e) { - std::cerr << "Exception: " << e.what() << std::endl; + mConnectionManager->LogMessage("Caught Exception While Opening Connection: " + std::string(e.what())); } } } @@ -246,8 +246,14 @@ void MyStreamDeckPlugin::SendToPlugin(const std::string &inAction, if (event == "RequestIdLookup") { const std::string dcs_install_path = EPLJSONUtils::GetStringByName(inPayload, "dcs_install_path"); const std::string module = EPLJSONUtils::GetStringByName(inPayload, "module"); - json clickabledata = get_clickabledata(dcs_install_path, module, "extract_clickabledata.lua"); + json clickabledata_and_result = get_clickabledata(dcs_install_path, module, "extract_clickabledata.lua"); + const std::string lua_result = EPLJSONUtils::GetStringByName(clickabledata_and_result, "result"); + if (lua_result != "success") { + mConnectionManager->LogMessage(module + " Clickabledata Result: " + lua_result); + } mConnectionManager->SendToPropertyInspector( - inAction, inContext, json({{"event", "Clickabledata"}, {"clickabledata", clickabledata}})); + inAction, + inContext, + json({{"event", "Clickabledata"}, {"clickabledata", clickabledata_and_result["clickabledata_items"]}})); } } diff --git a/Sources/Test/DcsIdLookupTest.cpp b/Sources/Test/DcsIdLookupTest.cpp index 246336cf..2f11d631 100644 --- a/Sources/Test/DcsIdLookupTest.cpp +++ b/Sources/Test/DcsIdLookupTest.cpp @@ -2,6 +2,7 @@ #include "gtest/gtest.h" +#include "../Common/EPLJSONUtils.h" #include "../DcsInterface/DcsIdLookup.cpp" namespace test { @@ -17,7 +18,8 @@ TEST(DcsIdLookupTest, nonexistant_lua_file) { // Test that a bad path will return an empty json container. const std::string lua_script = "non-existant-file.lua"; json returned_values = get_clickabledata("path", "module", lua_script); - EXPECT_TRUE(returned_values.empty()); + EXPECT_EQ("Lua file load error: 6", EPLJSONUtils::GetStringByName(returned_values, "result")); + EXPECT_EQ(0, returned_values["clickabledata_items"].size()); } } // namespace test \ No newline at end of file diff --git a/Sources/com.ctytler.dcs.sdPlugin/dcs_interface.exe b/Sources/com.ctytler.dcs.sdPlugin/dcs_interface.exe index a6c3a5e3..01669a8b 100644 Binary files a/Sources/com.ctytler.dcs.sdPlugin/dcs_interface.exe and b/Sources/com.ctytler.dcs.sdPlugin/dcs_interface.exe differ