Skip to content

Commit

Permalink
Added new option to disable info window
Browse files Browse the repository at this point in the history
  • Loading branch information
mauer committed May 30, 2022
1 parent 64144ac commit 8971b8d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

-----------------------------------------------------------------------------------------------------------------------

## VERSION 1.01

+ Fixed segmentation fault in Linux systems
+ Added option to disable the info window globally
+ Adjusted size of profile window

-----------------------------------------------------------------------------------------------------------------------

## VERSION 1.00

+ Some minor logging improvements
Expand Down
1 change: 1 addition & 0 deletions src/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const char *const CFG_KEY_VELOCITY = "velocity";
const char *const CFG_KEY_VELOCITY_ON = "velocity_on";
const char *const CFG_KEY_VELOCITY_OFF = "velocity_off";
const char *const CFG_KEY_VERSION = "version";
const char *const CFG_KEY_INFO_DISABLED = "info_disabled";
const char *const CFG_KEY_INFO_OFFSET_X = "info_offset_x";
const char *const CFG_KEY_INFO_OFFSET_Y = "info_offset_y";
const char *const CFG_KEY_INFO_POSITION = "info_position";
Expand Down
10 changes: 8 additions & 2 deletions src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,13 @@ void plugin::close_profile()
*/
void plugin::show_profile_message()
{
/*if (m_profile->loaded())
if (m_settings->info_disabled())
return;

if (m_profile->loaded())
show_info_message(XMIDICTRL_NAME, XMIDICTRL_FULL_NAME " --> Profile '" + m_profile->title() + "' loaded", 10);
else
show_info_message(XMIDICTRL_NAME, XMIDICTRL_FULL_NAME " --> No profile loaded", 10);*/
show_info_message(XMIDICTRL_NAME, XMIDICTRL_FULL_NAME " --> No profile loaded", 10);
}


Expand All @@ -274,6 +277,9 @@ void plugin::show_profile_message()
*/
void plugin::show_info_message(std::string_view in_id, std::string_view in_msg, int in_seconds)
{
if (m_settings->info_disabled())
return;

std::shared_ptr<info_msg> msg;

if (in_seconds == -1)
Expand Down
20 changes: 20 additions & 0 deletions src/plugin/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ settings::settings(text_logger &in_text_log, xplane &in_xp)

m_use_common_profile = toml::find_or<bool>(m_config, CFG_KEY_COMMON_PROFILE, true);

m_info_disabled = toml::find_or<bool>(m_config, CFG_KEY_INFO_DISABLED, false);
m_info_position = static_cast<window_position>(toml::find_or<int>(m_config, CFG_KEY_INFO_POSITION, 1));
m_info_offset_x = toml::find_or<int>(m_config, CFG_KEY_INFO_OFFSET_X, 50);
m_info_offset_y = toml::find_or<int>(m_config, CFG_KEY_INFO_OFFSET_Y, 50);
Expand Down Expand Up @@ -241,6 +242,24 @@ bool settings::use_common_profile() const
}


/**
* Set if the info window is disabled
*/
void settings::set_info_disabled(bool in_disabled)
{
m_info_disabled = in_disabled;
}


/**
* Return if the info window is disabled
*/
bool settings::info_disabled() const
{
return m_info_disabled;
}


/**
* Set the position of the info window
*/
Expand Down Expand Up @@ -332,6 +351,7 @@ void settings::save_settings()

m_config[CFG_KEY_COMMON_PROFILE] = m_use_common_profile;

m_config[CFG_KEY_INFO_DISABLED] = m_info_disabled;
m_config[CFG_KEY_INFO_POSITION] = static_cast<int>(m_info_position);
m_config[CFG_KEY_INFO_OFFSET_X] = m_info_offset_x;
m_config[CFG_KEY_INFO_OFFSET_Y] = m_info_offset_y;
Expand Down
5 changes: 5 additions & 0 deletions src/plugin/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class settings : public config {
void set_use_common_profile(bool in_enabled);
[[nodiscard]] bool use_common_profile() const;

void set_info_disabled(bool in_disabled);
[[nodiscard]] bool info_disabled() const;

void set_info_position(window_position in_position);
[[nodiscard]] window_position info_position() const;

Expand Down Expand Up @@ -95,6 +98,8 @@ class settings : public config {

bool m_use_common_profile {true};

bool m_info_disabled {false};

window_position m_info_position {window_position::bottom_left};
int m_info_offset_x {50};
int m_info_offset_y {50};
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/ui/profile_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace xmidictrl {
* Constructor
*/
profile_window::profile_window(text_logger &in_log, xplane &in_xp, profile &in_profile)
: imgui_window(in_log, in_xp, 1200, 800),
: imgui_window(in_log, in_xp, 1200, 750),
m_profile(in_profile)
{
set_title(std::string(XMIDICTRL_NAME) + " - Aircraft Profile");
Expand Down
11 changes: 9 additions & 2 deletions src/plugin/ui/settings_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace xmidictrl {
* Constructor
*/
settings_window::settings_window(text_logger &in_log, xplane &in_xp, settings &in_settings)
: imgui_window(in_log, in_xp, 1000, 500),
: imgui_window(in_log, in_xp, 1000, 550),
m_settings(in_settings)
{
m_debug_mode = m_settings.debug_mode();
Expand All @@ -54,6 +54,7 @@ settings_window::settings_window(text_logger &in_log, xplane &in_xp, settings &i

m_use_common_profile = m_settings.use_common_profile();

m_info_disabled = m_settings.info_disabled();
m_info_position = m_settings.info_position();
m_info_offset_x = m_settings.info_offset_x();
m_info_offset_y = m_settings.info_offset_y();
Expand Down Expand Up @@ -118,6 +119,9 @@ void settings_window::create_tab_general()
ImGui::Separator();
ImGui::NewLine();

ImGui::Checkbox("Disable info window", &m_info_disabled);
ImGui::NewLine();

ImGui::TextUnformatted("Window Position:");
ImGui::SameLine(250);
ImGui::PushItemWidth(200);
Expand Down Expand Up @@ -215,7 +219,7 @@ void settings_window::create_tab_general()


/**
* Create tab for loggings settings
* Create tab for logging settings
*/
void settings_window::create_tab_logging()
{
Expand Down Expand Up @@ -287,6 +291,8 @@ void settings_window::create_tab_logging()
ImGui::SameLine();
ImGui::RadioButton("Flat names (e.g. Eb)", &m_note_name, 1);

ImGui::NewLine();
ImGui::NewLine();
ImGui::NewLine();
ImGui::NewLine();

Expand Down Expand Up @@ -382,6 +388,7 @@ void settings_window::save_settings()

m_settings.set_use_common_profile(m_use_common_profile);

m_settings.set_info_disabled(m_info_disabled);
m_settings.set_info_position(m_info_position);
m_settings.set_info_offset_x(m_info_offset_x);
m_settings.set_info_offset_y(m_info_offset_y);
Expand Down
1 change: 1 addition & 0 deletions src/plugin/ui/settings_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class settings_window : public imgui_window {

bool m_use_common_profile;

bool m_info_disabled;
window_position m_info_position;
int m_info_offset_x;
int m_info_offset_y;
Expand Down

0 comments on commit 8971b8d

Please sign in to comment.