diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-05-13 13:10:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-13 16:27:43 +0200 |
commit | cdffe556c8fcca034b10cf91f0b05c17d835bc7b (patch) | |
tree | 189cbd59652eee1b2783a8323a7194100c78fd07 /Userland/Games | |
parent | 1f82beded3ae3664265f1ddf6075f64ca5a08cde (diff) | |
download | serenity-cdffe556c8fcca034b10cf91f0b05c17d835bc7b.zip |
LibGUI+Userland: Make Dialog::ExecResult an enum class
Diffstat (limited to 'Userland/Games')
-rw-r--r-- | Userland/Games/2048/GameSizeDialog.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/2048/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/Breakout/Game.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/Breakout/LevelSelectDialog.cpp | 6 | ||||
-rw-r--r-- | Userland/Games/Breakout/LevelSelectDialog.h | 2 | ||||
-rw-r--r-- | Userland/Games/Chess/ChessWidget.cpp | 8 | ||||
-rw-r--r-- | Userland/Games/Chess/PromotionDialog.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/Hearts/Game.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/Hearts/SettingsDialog.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/Hearts/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/MasterWord/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/Minesweeper/CustomGameDialog.cpp | 10 | ||||
-rw-r--r-- | Userland/Games/Minesweeper/CustomGameDialog.h | 2 | ||||
-rw-r--r-- | Userland/Games/Solitaire/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/Spider/main.cpp | 2 |
15 files changed, 28 insertions, 28 deletions
diff --git a/Userland/Games/2048/GameSizeDialog.cpp b/Userland/Games/2048/GameSizeDialog.cpp index 3f4ccd3a4e..0f925ccbab 100644 --- a/Userland/Games/2048/GameSizeDialog.cpp +++ b/Userland/Games/2048/GameSizeDialog.cpp @@ -74,10 +74,10 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent, size_t board_size, size_t ta button_layout.set_spacing(10); buttonbox.add<GUI::Button>("Cancel").on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; buttonbox.add<GUI::Button>("OK").on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; } diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 3a2d65a55a..e42066ceb3 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -99,7 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto change_settings = [&] { auto size_dialog = GameSizeDialog::construct(window, board_size, target_tile, evil_ai); - if (size_dialog->exec() || size_dialog->result() != GUI::Dialog::ExecOK) + if (size_dialog->exec() != GUI::Dialog::ExecResult::OK) return; board_size = size_dialog->board_size(); @@ -152,7 +152,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) "Congratulations!", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (want_to_continue == GUI::MessageBox::ExecYes) + if (want_to_continue == GUI::MessageBox::ExecResult::Yes) game.set_want_to_continue(); else start_a_new_game(); diff --git a/Userland/Games/Breakout/Game.cpp b/Userland/Games/Breakout/Game.cpp index bf38388717..134c7c979e 100644 --- a/Userland/Games/Breakout/Game.cpp +++ b/Userland/Games/Breakout/Game.cpp @@ -20,7 +20,7 @@ Game::Game() { set_override_cursor(Gfx::StandardCursor::Hidden); auto level_dialog = LevelSelectDialog::show(m_board, window()); - if (level_dialog != GUI::Dialog::ExecOK) + if (level_dialog != GUI::Dialog::ExecResult::OK) m_board = -1; set_paused(false); start_timer(16); diff --git a/Userland/Games/Breakout/LevelSelectDialog.cpp b/Userland/Games/Breakout/LevelSelectDialog.cpp index dfbc5c49d4..fb45e21adc 100644 --- a/Userland/Games/Breakout/LevelSelectDialog.cpp +++ b/Userland/Games/Breakout/LevelSelectDialog.cpp @@ -20,7 +20,7 @@ LevelSelectDialog::LevelSelectDialog(Window* parent_window) build(); } -int LevelSelectDialog::show(int& board_number, Window* parent_window) +GUI::Dialog::ExecResult LevelSelectDialog::show(int& board_number, Window* parent_window) { auto box = LevelSelectDialog::construct(parent_window); box->set_resizable(false); @@ -47,12 +47,12 @@ void LevelSelectDialog::build() level_list.add<GUI::Button>("Rainbow").on_click = [this](auto) { m_level = -1; - done(Dialog::ExecOK); + done(ExecResult::OK); }; level_list.add<GUI::Button>(":^)").on_click = [this](auto) { m_level = 0; - done(Dialog::ExecOK); + done(ExecResult::OK); }; } } diff --git a/Userland/Games/Breakout/LevelSelectDialog.h b/Userland/Games/Breakout/LevelSelectDialog.h index e3321936a8..89ccb40048 100644 --- a/Userland/Games/Breakout/LevelSelectDialog.h +++ b/Userland/Games/Breakout/LevelSelectDialog.h @@ -13,7 +13,7 @@ class LevelSelectDialog : public GUI::Dialog { C_OBJECT(LevelSelectDialog) public: virtual ~LevelSelectDialog() override = default; - static int show(int& board_number, Window* parent_window); + static ExecResult show(int& board_number, Window* parent_window); int level() const { return m_level; } private: diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 5e013e464e..8c4097b8a4 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -235,7 +235,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) Chess::Move move = { m_moving_square, target_square }; if (board().is_promotion_move(move)) { auto promotion_dialog = PromotionDialog::construct(*this); - if (promotion_dialog->exec() == PromotionDialog::ExecOK) + if (promotion_dialog->exec() == PromotionDialog::ExecResult::OK) move.promote_to = promotion_dialog->selected_piece(); } @@ -262,7 +262,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) update(); if (GUI::MessageBox::show(window(), "50 moves have elapsed without a capture. Claim Draw?", "Claim Draw?", GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) - == GUI::Dialog::ExecYes) { + == GUI::Dialog::ExecResult::Yes) { msg = "Draw by 50 move rule."; } else { over = false; @@ -275,7 +275,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) update(); if (GUI::MessageBox::show(window(), "The same board state has repeated three times. Claim Draw?", "Claim Draw?", GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) - == GUI::Dialog::ExecYes) { + == GUI::Dialog::ExecResult::Yes) { msg = "Draw by threefold repetition."; } else { over = false; @@ -691,7 +691,7 @@ int ChessWidget::resign() } auto result = GUI::MessageBox::show(window(), "Are you sure you wish to resign?", "Resign", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result != GUI::MessageBox::ExecYes) + if (result != GUI::MessageBox::ExecResult::Yes) return -1; board().set_resigned(m_board.turn()); diff --git a/Userland/Games/Chess/PromotionDialog.cpp b/Userland/Games/Chess/PromotionDialog.cpp index e89bd54d9e..f20ab09148 100644 --- a/Userland/Games/Chess/PromotionDialog.cpp +++ b/Userland/Games/Chess/PromotionDialog.cpp @@ -28,7 +28,7 @@ PromotionDialog::PromotionDialog(ChessWidget& chess_widget) button.set_icon(chess_widget.get_piece_graphic({ chess_widget.board().turn(), type })); button.on_click = [this, type](auto) { m_selected_piece = type; - done(ExecOK); + done(ExecResult::OK); }; } } diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index f59a612589..83986fe52a 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -137,7 +137,7 @@ void Game::show_score_card(bool game_over) auto& close_button = button_container.add<GUI::Button>("OK"); close_button.on_click = [&score_dialog](auto) { - score_dialog->done(GUI::Dialog::ExecOK); + score_dialog->done(GUI::Dialog::ExecResult::OK); }; close_button.set_min_width(70); close_button.resize(70, 30); diff --git a/Userland/Games/Hearts/SettingsDialog.cpp b/Userland/Games/Hearts/SettingsDialog.cpp index 2e027ad4f4..c9e185cded 100644 --- a/Userland/Games/Hearts/SettingsDialog.cpp +++ b/Userland/Games/Hearts/SettingsDialog.cpp @@ -43,10 +43,10 @@ SettingsDialog::SettingsDialog(GUI::Window* parent, String player_name) button_layout.set_spacing(10); button_box.add<GUI::Button>("Cancel").on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; button_box.add<GUI::Button>("OK").on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; } diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index 429779af2c..3ce2a8c0a4 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -75,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto change_settings = [&] { auto settings_dialog = SettingsDialog::construct(window, player_name); - if (settings_dialog->exec() || settings_dialog->result() != GUI::Dialog::ExecOK) + if (settings_dialog->exec() != GUI::Dialog::ExecResult::OK) return; player_name = settings_dialog->player_name(); diff --git a/Userland/Games/MasterWord/main.cpp b/Userland/Games/MasterWord/main.cpp index 2d17318e26..abdeee8ff7 100644 --- a/Userland/Games/MasterWord/main.cpp +++ b/Userland/Games/MasterWord/main.cpp @@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(game_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) { auto word_length = Config::read_i32("MasterWord", "", "word_length", 5); auto word_length_string = String::number(word_length); - if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecOK && !word_length_string.is_empty()) { + if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) { auto maybe_word_length = word_length_string.template to_uint(); if (!maybe_word_length.has_value() || maybe_word_length.value() < shortest_word || maybe_word_length.value() > longest_word) { GUI::MessageBox::show(window, String::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"); @@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(game_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) { auto max_guesses = Config::read_i32("MasterWord", "", "max_guesses", 5); auto max_guesses_string = String::number(max_guesses); - if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecOK && !max_guesses_string.is_empty()) { + if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) { auto maybe_max_guesses = max_guesses_string.template to_uint(); if (!maybe_max_guesses.has_value() || maybe_max_guesses.value() < 1 || maybe_max_guesses.value() > 20) { GUI::MessageBox::show(window, "Please enter a number between 1 and 20.", "MasterWord"); diff --git a/Userland/Games/Minesweeper/CustomGameDialog.cpp b/Userland/Games/Minesweeper/CustomGameDialog.cpp index 7cdafb2ed3..ce5194d767 100644 --- a/Userland/Games/Minesweeper/CustomGameDialog.cpp +++ b/Userland/Games/Minesweeper/CustomGameDialog.cpp @@ -9,7 +9,7 @@ #include "Field.h" #include <Games/Minesweeper/MinesweeperCustomGameWindowGML.h> -int CustomGameDialog::show(GUI::Window* parent_window, Field& field) +GUI::Dialog::ExecResult CustomGameDialog::show(GUI::Window* parent_window, Field& field) { auto dialog = CustomGameDialog::construct(parent_window); @@ -24,12 +24,12 @@ int CustomGameDialog::show(GUI::Window* parent_window, Field& field) auto result = dialog->exec(); - if (result != GUI::Dialog::ExecOK) + if (result != ExecResult::OK) return result; field.set_field_size(Field::Difficulty::Custom, dialog->m_rows_spinbox->value(), dialog->m_columns_spinbox->value(), dialog->m_mines_spinbox->value()); - return GUI::Dialog::ExecOK; + return ExecResult::OK; } void CustomGameDialog::set_max_mines() @@ -66,11 +66,11 @@ CustomGameDialog::CustomGameDialog(Window* parent_window) }; m_ok_button->on_click = [this](auto) { - done(ExecResult::ExecOK); + done(ExecResult::OK); }; m_cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; set_max_mines(); diff --git a/Userland/Games/Minesweeper/CustomGameDialog.h b/Userland/Games/Minesweeper/CustomGameDialog.h index 786a3252d3..42dd35625a 100644 --- a/Userland/Games/Minesweeper/CustomGameDialog.h +++ b/Userland/Games/Minesweeper/CustomGameDialog.h @@ -17,7 +17,7 @@ class CustomGameDialog : public GUI::Dialog { C_OBJECT(CustomGameDialog); public: - static int show(GUI::Window* parent_window, Field& field); + static ExecResult show(GUI::Window* parent_window, Field& field); private: CustomGameDialog(GUI::Window* parent_window); diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 2b70ce9e76..a900574f74 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -144,7 +144,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result == GUI::MessageBox::ExecYes) + if (result == GUI::MessageBox::ExecResult::Yes) return GUI::Window::CloseRequestDecision::Close; else return GUI::Window::CloseRequestDecision::StayOpen; diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index a4e2537979..db67616b80 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -201,7 +201,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result == GUI::MessageBox::ExecYes) + if (result == GUI::MessageBox::ExecResult::Yes) return GUI::Window::CloseRequestDecision::Close; else return GUI::Window::CloseRequestDecision::StayOpen; |