mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Minesweeper: Paint a grid pattern below the mines.
This commit is contained in:
parent
bc5148354f
commit
791e8f5bb0
2 changed files with 24 additions and 1 deletions
|
@ -1,8 +1,9 @@
|
|||
#include "Field.h"
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibCore/CConfigFile.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -180,6 +181,26 @@ void Field::flood_fill(Square& square)
|
|||
});
|
||||
}
|
||||
|
||||
void Field::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GFrame::paint_event(event);
|
||||
GPainter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
auto inner_rect = frame_inner_rect();
|
||||
|
||||
for (int y = inner_rect.top() - 1; y <= inner_rect.bottom(); y += square_size()) {
|
||||
Point a { inner_rect.left(), y };
|
||||
Point b { inner_rect.right(), y };
|
||||
painter.draw_line(a, b, Color::MidGray);
|
||||
}
|
||||
for (int x = frame_inner_rect().left() - 1; x <= frame_inner_rect().right(); x += square_size()) {
|
||||
Point a { x, inner_rect.top() };
|
||||
Point b { x, inner_rect.bottom() };
|
||||
painter.draw_line(a, b, Color::MidGray);
|
||||
}
|
||||
}
|
||||
|
||||
void Field::on_square_clicked(Square& square)
|
||||
{
|
||||
if (square.is_swept)
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
|
||||
void on_square_clicked(Square&);
|
||||
void on_square_right_clicked(Square&);
|
||||
void game_over();
|
||||
|
|
Loading…
Add table
Reference in a new issue