Skip to content

Commit

Permalink
Remove some unsignedness from ints.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 13, 2024
1 parent 94541db commit 3b9cf2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ unsigned int Menu::getLocationOfFirstItem() const
static_cast<unsigned int>(items_.size()) * getItemHeight() / 2;
}

unsigned int Menu::getItemWidth() const
int Menu::getItemWidth() const
{
return std::max(screen_.getWidth() / 3,
screen_.getBitmapWidth(ResourceType::MENU_ITEM));
}

unsigned int Menu::getItemHeight() const
int Menu::getItemHeight() const
{
return std::max(screen_.getHeight() / 10,
screen_.getBitmapHeight(ResourceType::MENU_ITEM));
Expand Down
4 changes: 2 additions & 2 deletions src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Menu final

unsigned int getLocationOfFirstItem() const;

unsigned int getItemWidth() const;
int getItemWidth() const;

unsigned int getItemHeight() const;
int getItemHeight() const;

UserChoice getUserChoice();

Expand Down
20 changes: 8 additions & 12 deletions src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,28 @@ void Screen::clearScreenWithBlack()

void Screen::updateSize()
{
width_ = static_cast<unsigned int>(
::al_get_display_width(::al_get_current_display()));
height_ = static_cast<unsigned int>(
::al_get_display_height(::al_get_current_display()));
width_ = ::al_get_display_width(::al_get_current_display());
height_ = ::al_get_display_height(::al_get_current_display());

Config::getInstance().screenSizeChanged(getWidth(), getHeight());
}

unsigned int Screen::getWidth() const { return width_; }
int Screen::getWidth() const { return width_; }

unsigned int Screen::getHeight() const { return height_; }
int Screen::getHeight() const { return height_; }

unsigned int Screen::getCenterX() const { return width_ / 2; }

unsigned int Screen::getCenterY() const { return height_ / 2; }

unsigned int Screen::getBitmapWidth(ResourceType resourceType) const
int Screen::getBitmapWidth(ResourceType resourceType) const
{
return static_cast<unsigned int>(
::al_get_bitmap_width(resources_.getBitmap(resourceType)));
return ::al_get_bitmap_width(resources_.getBitmap(resourceType));
}

unsigned int Screen::getBitmapHeight(ResourceType resourceType) const
int Screen::getBitmapHeight(ResourceType resourceType) const
{
return static_cast<unsigned int>(
::al_get_bitmap_height(resources_.getBitmap(resourceType)));
return ::al_get_bitmap_height(resources_.getBitmap(resourceType));
}

void Screen::refresh() { ::al_flip_display(); }
Expand Down
12 changes: 6 additions & 6 deletions src/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class Screen

unsigned int getCenterY() const;

unsigned int getBitmapWidth(ResourceType resourceType) const;
int getBitmapWidth(ResourceType resourceType) const;

unsigned int getBitmapHeight(ResourceType resourceType) const;
int getBitmapHeight(ResourceType resourceType) const;

static void refresh();

Expand All @@ -60,16 +60,16 @@ class Screen

void useWindowedMode();

unsigned int getWidth() const;
int getWidth() const;

unsigned int getHeight() const;
int getHeight() const;

private:
void updateSize();

Resources resources_;

unsigned int width_;
unsigned int height_;
int width_;
int height_;
ALLEGRO_FONT* font_;
};

0 comments on commit 3b9cf2a

Please sign in to comment.