summaryrefslogtreecommitdiff
path: root/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp
diff options
context:
space:
mode:
authorTim Ledbetter <timledbetter@gmail.com>2023-05-09 20:01:47 +0100
committerSam Atkins <atkinssj@gmail.com>2023-05-10 12:13:35 +0100
commitcf4a43e4c083591480ac78172324ce0fa4a3e1ae (patch)
tree299b317762cef94509c68f229cf8abd0c0f6be65 /Userland/Applications/GamesSettings/ChessSettingsWidget.cpp
parent0c26717ba3317e769f64c605668603a79e909518 (diff)
downloadserenity-cf4a43e4c083591480ac78172324ce0fa4a3e1ae.zip
Chess+GameSettings: Optionally highlight the king when in check
When either king is in check, its square is now highlighted with a red background. This behavior can be toggled in GameSettings.
Diffstat (limited to 'Userland/Applications/GamesSettings/ChessSettingsWidget.cpp')
-rw-r--r--Userland/Applications/GamesSettings/ChessSettingsWidget.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp
index 81d4c836e3..74d9d86fed 100644
--- a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp
+++ b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp
@@ -276,6 +276,12 @@ ErrorOr<void> ChessSettingsWidget::initialize()
m_preview->set_show_coordinates(checked);
};
+ m_highlight_checks_checkbox = find_descendant_of_type_named<GUI::CheckBox>("highlight_checks");
+ m_highlight_checks_checkbox->set_checked(show_coordinates, GUI::AllowCallback::No);
+ m_highlight_checks_checkbox->on_checked = [&](bool) {
+ set_modified(true);
+ };
+
TRY(m_preview->set_piece_set_name(piece_set_name));
m_preview->set_dark_square_color(board_theme.dark_square_color);
m_preview->set_light_square_color(board_theme.light_square_color);
@@ -289,6 +295,7 @@ void ChessSettingsWidget::apply_settings()
Config::write_string("Games"sv, "Chess"sv, "PieceSet"sv, m_piece_set_combobox->text());
Config::write_string("Games"sv, "Chess"sv, "BoardTheme"sv, m_board_theme_combobox->text());
Config::write_bool("Games"sv, "Chess"sv, "ShowCoordinates"sv, m_show_coordinates_checkbox->is_checked());
+ Config::write_bool("Games"sv, "Chess"sv, "HighlightChecks"sv, m_highlight_checks_checkbox->is_checked());
}
void ChessSettingsWidget::reset_default_values()
@@ -302,6 +309,7 @@ void ChessSettingsWidget::reset_default_values()
m_preview->set_dark_square_color(board_theme.dark_square_color);
m_preview->set_light_square_color(board_theme.light_square_color);
m_show_coordinates_checkbox->set_checked(true);
+ m_highlight_checks_checkbox->set_checked(true);
}
}