Skip to content

Commit

Permalink
Move definitions to Display.cpp from Display.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 14, 2024
1 parent b7bb0fc commit ecd0980
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set(${PROJECT_NAME}_SOURCES
src/MenuItem.cpp
src/UserChoice.h
src/Display.h
src/Display.cpp
src/map/Water.cpp
src/map/Water.h
src/map/Steel.cpp
Expand Down
18 changes: 18 additions & 0 deletions src/Display.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "Display.h"

#include "Config.h"

Display::Display()
: width_(Config::getInstance().getBoardWidth() +
Config::getInstance().getSatusWidth()),
height_(Config::getInstance().getBoardHeight())
{
}

int Display::getCenterX() const { return width_ / 2; }
int Display::getCenterY() const { return height_ / 2; }

int Display::getWidth() const { return width_; }
void Display::setWidth(int width) { width_ = width; }
int Display::getHeight() const { return height_; }
void Display::setHeight(int height) { height_ = height; }
21 changes: 7 additions & 14 deletions src/Display.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
#pragma once

#include "Config.h"

class Display
{
public:
Display()
: width_(Config::getInstance().getBoardWidth() +
Config::getInstance().getSatusWidth()),
height_(Config::getInstance().getBoardHeight())
{
}
Display();

virtual ~Display() = default;

int getCenterX() const { return width_ / 2; }
int getCenterY() const { return height_ / 2; }
int getCenterX() const;
int getCenterY() const;

int getWidth() const { return width_; }
void setWidth(int width) { width_ = width; }
int getHeight() const { return height_; }
void setHeight(int height) { height_ = height; }
int getWidth() const;
void setWidth(int width);
int getHeight() const;
void setHeight(int height);

private:
int width_;
Expand Down

0 comments on commit ecd0980

Please sign in to comment.