Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message display #80

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions XPanel.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@
<ClCompile Include="src\core\ConfigParser.cpp" />
<ClCompile Include="src\core\Logger.cpp" />
<ClCompile Include="src\devices\saitek-multi\SaitekMultiPanel.cpp" />
<ClCompile Include="src\config-ui\MessageWindow.cpp" />
<ClCompile Include="src\devices\trc-1000\TRC1000.cpp" />
<ClCompile Include="src\devices\saitek-switch\SaitekSwitchPanel.cpp" />
<ClCompile Include="src\core\XPanel.cpp" />
<ClCompile Include="src\core\UsbHidDevice.cpp" />
<ClCompile Include="src\core\Trigger.cpp" />
<ClCompile Include="src\devices\trc-1000\TRC1000PFD.cpp" />
<ClCompile Include="src\devices\trc-1000\TRC1000Audio.cpp" />
<ClCompile Include="src\log-message-window\MessageWindow.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\core\AgeingCounter.h" />
Expand All @@ -209,7 +209,6 @@
<ClInclude Include="src\core\IniFileParser.h" />
<ClInclude Include="src\devices\saitek-radio\SaitekRadioPanel.h" />
<ClInclude Include="src\core\LuaHelper.h" />
<ClInclude Include="src\config-ui\MessageWindow.h" />
<ClInclude Include="src\core\MultiPurposeDisplay.h" />
<ClInclude Include="src\core\Logger.h" />
<ClInclude Include="src\devices\arduino-homecockpit\ArduinoHomeCockpit.h" />
Expand All @@ -224,6 +223,7 @@
<ClInclude Include="src\devices\trc-1000\TRC1000PFD.h" />
<ClInclude Include="src\devices\trc-1000\TRC1000.h" />
<ClInclude Include="src\devices\trc-1000\TRC1000Audio.h" />
<ClInclude Include="src\log-message-window\MessageWindow.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
4 changes: 2 additions & 2 deletions XPanel.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<ClCompile Include="src\core\XPanel.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="src\config-ui\MessageWindow.cpp">
<ClCompile Include="src\log-message-window\MessageWindow.cpp">
<Filter>config-ui</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -174,7 +174,7 @@
<ClInclude Include="src\core\MultiPurposeDisplay.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="src\config-ui\MessageWindow.h">
<ClInclude Include="src\log-message-window\MessageWindow.h">
<Filter>config-ui</Filter>
</ClInclude>
</ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ Set the log level of the plugin. The log lines are written to X-Plane's default
```ini
log_level="ERROR"
```

### Error messages
The ERROR and WARNING level messages are also routed to a window in XPlane simulator. There you can see error messages and don't need to open the XPlane log files.
![Error Window](error-window.png)

### Aircraft ACF file

The ACF file is the main file for an X-Plane aircraft. The plugin gets the ACF file name parameter from the X-Plane system. The reason to put the ACF file name into the configuration is only for safety. During parse, we can check if accidentally a wrong configuration file (created for another aircraft) has been loaded.
Expand Down
Binary file added doc/error-window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(xpanel SHARED
core/UsbHidDevice.cpp
core/XPanel.cpp
core/GenericScreen.cpp
config-ui/MessageWindow.cpp
log-message-window/MessageWindow.cpp
devices/arduino-homecockpit/ArduinoHomeCockpit.cpp
devices/saitek-multi/SaitekMultiPanel.cpp
devices/saitek-radio/SaitekRadioPanel.cpp
Expand Down
126 changes: 0 additions & 126 deletions src/config-ui/MessageWindow.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions src/config-ui/MessageWindow.h

This file was deleted.

17 changes: 14 additions & 3 deletions src/core/XPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "trc-1000/TRC1000PFD.h"
#include "trc-1000/TRC1000Audio.h"
#include "core/LuaHelper.h"
#include "config-ui/MessageWindow.h"
#include "log-message-window/MessageWindow.h"
#include "core/Logger.h"

#if IBM
Expand Down Expand Up @@ -71,6 +71,7 @@ const float ERROR_DISPLAY_TIME_PERIOD = 2.0f;
int g_menu_container_idx;
XPLMMenuID g_menu_id;
void menu_handler(void*, void*);
MessageWindow* msg_window = NULL;

typedef enum {
MENU_ITEM_RELOAD = 0
Expand All @@ -86,6 +87,9 @@ PLUGIN_API int XPluginStart(
Logger::set_log_level(TLogLevel::logINFO);
Logger(TLogLevel::logINFO) << "plugin start" << std::endl;

//XPLMEnableFeature("XPLM_USE_NATIVE_PATHS", 1);
//XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1);

snprintf(outName, 256, "XPanel ver %s", PLUGIN_VERSION);
snprintf(outSig, 256, "%s", PLUGIN_SIGNATURE);
snprintf(outDesc, 256, "A plugin to handle control devices using hidapi interface");
Expand Down Expand Up @@ -166,7 +170,10 @@ float error_display_callback(float, float, int, void*)
return ERROR_DISPLAY_TIME_PERIOD;

std::list<std::string> error_msgs = Logger::get_and_clear_stored_messages();
new MessageWindow(std::string("Xpanel: Errors and Warnings"), error_msgs, true);
if (!msg_window)
msg_window = new MessageWindow(std::string("Xpanel: Errors and Warnings"));
msg_window->append_multi_lines(error_msgs);
msg_window->show();

return ERROR_DISPLAY_TIME_PERIOD;
}
Expand All @@ -188,6 +195,10 @@ void stop_and_clear_xpanel_plugin()
config.clear();
ActionQueue::get_instance()->clear_all_actions();
plugin_already_initialized = false;

if (msg_window)
delete msg_window;
msg_window = NULL;
}

std::filesystem::path absolute_path(std::string aircraft_path, std::string file_name)
Expand Down Expand Up @@ -370,7 +381,7 @@ PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFrom, int inMsg, void*)
{
switch (inMsg) {
case XPLM_MSG_AIRPORT_LOADED:
Logger(TLogLevel::logTRACE) << "XPLM_MSG_AIRPORT_LOADED message received" << std::endl;
Logger(TLogLevel::logTRACE) << "XPLM_MSG_AIRPORT_LOADED: message received" << std::endl;

if (plugin_already_initialized)
stop_and_clear_xpanel_plugin();
Expand Down
Loading
Loading