diff options
Diffstat (limited to 'Userland/Games')
-rw-r--r-- | Userland/Games/Minesweeper/Field.cpp | 11 | ||||
-rw-r--r-- | Userland/Games/Minesweeper/Field.h | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/Userland/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index e1eb43732e..6269447435 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -28,6 +28,7 @@ #include <AK/HashTable.h> #include <AK/Queue.h> #include <LibCore/ConfigFile.h> +#include <LibGUI/Application.h> #include <LibGUI/Button.h> #include <LibGUI/Label.h> #include <LibGUI/Painter.h> @@ -124,7 +125,8 @@ private: }; Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed) - : m_face_button(face_button) + : m_mine_palette(GUI::Application::the()->palette().impl().clone()) + , m_face_button(face_button) , m_flag_label(flag_label) , m_time_label(time_label) , m_on_size_changed(move(on_size_changed)) @@ -145,6 +147,8 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b m_bad_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-bad.png"); for (int i = 0; i < 8; ++i) m_number_bitmap[i] = Gfx::Bitmap::load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)); + // Square with mine will be filled with background color later, i.e. red + m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); set_fill_with_background_color(true); reset(); @@ -254,10 +258,7 @@ void Field::reset() square.is_swept = false; if (!square.label) { square.label = add<SquareLabel>(square); - // Square with mine will be filled with background color later, i.e. red - auto palette = square.label->palette(); - palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); - square.label->set_palette(palette); + square.label->set_palette(m_mine_palette); square.label->set_background_role(Gfx::ColorRole::Base); } square.label->set_fill_with_background_color(false); diff --git a/Userland/Games/Minesweeper/Field.h b/Userland/Games/Minesweeper/Field.h index 0ab7e0f300..6afada88b5 100644 --- a/Userland/Games/Minesweeper/Field.h +++ b/Userland/Games/Minesweeper/Field.h @@ -29,6 +29,7 @@ #include <AK/Noncopyable.h> #include <LibCore/Timer.h> #include <LibGUI/Frame.h> +#include <LibGfx/Palette.h> class Field; class SquareButton; @@ -118,6 +119,7 @@ private: RefPtr<Gfx::Bitmap> m_good_face_bitmap; RefPtr<Gfx::Bitmap> m_bad_face_bitmap; RefPtr<Gfx::Bitmap> m_number_bitmap[8]; + Gfx::Palette m_mine_palette; GUI::Button& m_face_button; GUI::Label& m_flag_label; GUI::Label& m_time_label; |