Skip to content

Commit

Permalink
Make Resources clas not movable.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 9, 2024
1 parent 73a543e commit 185458e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

#include <allegro5/allegro.h>

Resources::Resources()
{
for (const auto& [resourceType, path] : resourcePaths_)
bitmaps_[resourceType] = ::al_load_bitmap(path.c_str());
}

Resources::~Resources()
{
for (const auto& [_, bitmap] : bitmaps_)
Expand All @@ -20,6 +14,9 @@ Resources::~Resources()

ALLEGRO_BITMAP* Resources::getBitmap(ResourceType resourceType) const
{
if (bitmaps_.empty())
for (const auto& [resType, path] : resourcePaths_)
bitmaps_[resType] = ::al_load_bitmap(path.c_str());
return bitmaps_.at(resourceType);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ struct ALLEGRO_BITMAP;
class Resources
{
public:
Resources();
Resources() = default;
~Resources();

Resources& operator=(const Resources& other) = delete;
Resources(const Resources& other) = delete;

Resources& operator=(Resources&& other) = default;
Resources(Resources&& other) = default;
Resources& operator=(Resources&& other) = delete;
Resources(Resources&& other) = delete;

ALLEGRO_BITMAP* getBitmap(ResourceType resourceType) const;

Expand Down Expand Up @@ -50,5 +50,5 @@ class Resources
{ResourceType::ENEMY_TANK_TIER_3, "image/board/tank_tier3_enemy.tga"},
{ResourceType::ENEMY_TANK_TIER_4, "image/board/tank_tier4_enemy.tga"}};

std::unordered_map<ResourceType, ALLEGRO_BITMAP*> bitmaps_;
mutable std::unordered_map<ResourceType, ALLEGRO_BITMAP*> bitmaps_;
};
1 change: 0 additions & 1 deletion src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ bool Screen::init()

::al_set_window_title(::al_get_current_display(), "TankBle");

resources_ = {};
font_ = ::al_create_builtin_font();

return true;
Expand Down

0 comments on commit 185458e

Please sign in to comment.