More stuff, fix saved games

This commit is contained in:
elasota
2020-01-05 02:33:03 -05:00
parent a4b8db1065
commit aca18df74b
58 changed files with 1075 additions and 454 deletions

View File

@@ -27,11 +27,17 @@ struct Rect
int16_t right;
bool IsValid() const;
Rect Intersect(const Rect &rect) const;
Rect MakeValid() const;
Rect Intersect(const Rect &rect) const;
Rect Inset(int16_t h, int16_t v) const;
Rect operator-(const Point &point) const;
Rect operator+(const Point &point) const;
Rect &operator-=(const Point &point);
Rect &operator+=(const Point &point);
uint16_t Height() const;
uint16_t Width() const;
@@ -164,6 +170,11 @@ inline Rect Rect::Intersect(const Rect &other) const
return result;
}
inline Rect Rect::Inset(int16_t h, int16_t v) const
{
return Rect::Create(top + v, left + h, bottom - v, right - h);
}
inline Rect Rect::MakeValid() const
{
Rect result = *this;
@@ -186,6 +197,28 @@ inline Rect Rect::operator+(const Point &point) const
return Rect::Create(this->top + point.v, this->left + point.h, this->bottom + point.v, this->right + point.h);
}
inline Rect &Rect::operator-=(const Point &point)
{
this->top -= point.v;
this->bottom -= point.v;
this->left -= point.h;
this->right -= point.h;
return *this;
}
inline Rect &Rect::operator+=(const Point &point)
{
this->top += point.v;
this->bottom += point.v;
this->left += point.h;
this->right += point.h;
return *this;
}
inline uint16_t Rect::Height() const
{
return static_cast<uint16_t>(static_cast<int32_t>(this->bottom) - static_cast<int32_t>(this->top));