summaryrefslogtreecommitdiff
path: root/Userland/Games/Snake
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-06 14:17:01 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 23:46:35 +0100
commit8a48246ed1a93983668a25f5b9b0af0e745e3f04 (patch)
treedd98425d119f79e0160bf19951f96a4a30276cbb /Userland/Games/Snake
parent104be6c8ace8d56f66a89b570cdd615e74d22aa8 (diff)
downloadserenity-8a48246ed1a93983668a25f5b9b0af0e745e3f04.zip
Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
Diffstat (limited to 'Userland/Games/Snake')
-rw-r--r--Userland/Games/Snake/Game.cpp6
-rw-r--r--Userland/Games/Snake/Game.h4
2 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Games/Snake/Game.cpp b/Userland/Games/Snake/Game.cpp
index f7fc81900b..782b371983 100644
--- a/Userland/Games/Snake/Game.cpp
+++ b/Userland/Games/Snake/Game.cpp
@@ -53,7 +53,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
"/res/emoji/U+1FAB1.png"sv,
};
- NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps;
+ Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps;
TRY(food_bitmaps.try_ensure_capacity(food_bitmaps_files.size()));
for (auto file : food_bitmaps_files) {
@@ -69,7 +69,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps)));
}
-Game::Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps)
+Game::Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps)
: m_food_bitmaps(move(food_bitmaps))
{
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
@@ -263,7 +263,7 @@ void Game::paint_event(GUI::PaintEvent& event)
painter.fill_rect(bottom_side, m_snake_base_color.darkened(0.55));
}
- painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type].rect());
+ painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type]->rect());
}
void Game::game_over()
diff --git a/Userland/Games/Snake/Game.h b/Userland/Games/Snake/Game.h
index 5244fadc7c..0e4b91c065 100644
--- a/Userland/Games/Snake/Game.h
+++ b/Userland/Games/Snake/Game.h
@@ -30,7 +30,7 @@ public:
Function<bool(u32)> on_score_update;
private:
- explicit Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps);
+ explicit Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps);
virtual void paint_event(GUI::PaintEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
@@ -76,7 +76,7 @@ private:
unsigned m_score { 0 };
bool m_is_new_high_score { false };
- NonnullRefPtrVector<Gfx::Bitmap> m_food_bitmaps;
+ Vector<NonnullRefPtr<Gfx::Bitmap>> m_food_bitmaps;
Gfx::Color m_snake_base_color { Color::Yellow };
};