Add missing nostalgia directory level in src tree
This commit is contained in:
17
src/nostalgia/common/CMakeLists.txt
Normal file
17
src/nostalgia/common/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
add_library(
|
||||
NostalgiaCommon
|
||||
bounds.cpp
|
||||
point.cpp
|
||||
)
|
||||
|
||||
#install(TARGETS NostalgiaCommon DESTINATION lib)
|
||||
install(
|
||||
FILES
|
||||
bounds.hpp
|
||||
common.hpp
|
||||
point.hpp
|
||||
DESTINATION
|
||||
include/wombat/common
|
||||
)
|
41
src/nostalgia/common/bounds.cpp
Normal file
41
src/nostalgia/common/bounds.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "bounds.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace common {
|
||||
|
||||
Bounds::Bounds() {
|
||||
}
|
||||
|
||||
bool Bounds::intersects(Bounds o) const {
|
||||
return o.x2() >= X && x2() >= o.X && o.y2() >= Y && y2() >= o.Y;
|
||||
}
|
||||
|
||||
bool Bounds::contains(int x, int y) const {
|
||||
return x >= X && y >= Y && x <= x2() && y <= y2();
|
||||
}
|
||||
|
||||
int Bounds::x2() const {
|
||||
return X + Width;
|
||||
}
|
||||
|
||||
int Bounds::y2() const {
|
||||
return Y + Height;
|
||||
}
|
||||
|
||||
Point Bounds::pt1() {
|
||||
return Point(X, Y);
|
||||
}
|
||||
|
||||
Point Bounds::pt2() {
|
||||
return Point(x2(), y2());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
41
src/nostalgia/common/bounds.hpp
Normal file
41
src/nostalgia/common/bounds.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "point.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace common {
|
||||
|
||||
class Bounds {
|
||||
public:
|
||||
int X = 0;
|
||||
int Y = 0;
|
||||
int Width = 0;
|
||||
int Height = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Bounds();
|
||||
|
||||
bool intersects(Bounds other) const;
|
||||
|
||||
bool contains(int x, int y) const;
|
||||
|
||||
int x2() const;
|
||||
|
||||
int y2() const;
|
||||
|
||||
Point pt1();
|
||||
|
||||
Point pt2();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
14
src/nostalgia/common/common.hpp
Normal file
14
src/nostalgia/common/common.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#ifndef NOSTALGIA_COMMON_COMMON_HPP
|
||||
#define NOSTALGIA_COMMON_COMMON_HPP
|
||||
|
||||
#include "bounds.hpp"
|
||||
#include "point.hpp"
|
||||
|
||||
#endif
|
125
src/nostalgia/common/point.cpp
Normal file
125
src/nostalgia/common/point.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "point.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace common {
|
||||
|
||||
Point::Point() {
|
||||
}
|
||||
|
||||
Point::Point(int x, int y) {
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
Point Point::operator+(common::Point p) const {
|
||||
p.X += X;
|
||||
p.Y += Y;
|
||||
return p;
|
||||
}
|
||||
|
||||
Point Point::operator-(common::Point p) const {
|
||||
auto out = *this;
|
||||
out.X -= p.X;
|
||||
out.Y -= p.Y;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator*(common::Point p) const {
|
||||
p.X *= X;
|
||||
p.Y *= Y;
|
||||
return p;
|
||||
}
|
||||
|
||||
Point Point::operator/(common::Point p) const {
|
||||
auto out = *this;
|
||||
out.X /= p.X;
|
||||
out.Y /= p.Y;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator+=(common::Point p) {
|
||||
X += p.X;
|
||||
Y += p.Y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator-=(common::Point p) {
|
||||
X -= p.X;
|
||||
Y -= p.Y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator*=(common::Point p) {
|
||||
X *= p.X;
|
||||
Y *= p.Y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator/=(common::Point p) {
|
||||
X /= p.X;
|
||||
Y /= p.Y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Point Point::operator+(int i) const {
|
||||
auto out = *this;
|
||||
out.X += i;
|
||||
out.Y += i;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator-(int i) const {
|
||||
auto out = *this;
|
||||
out.X -= i;
|
||||
out.Y -= i;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator*(int i) const {
|
||||
auto out = *this;
|
||||
out.X *= i;
|
||||
out.Y *= i;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator/(int i) const {
|
||||
auto out = *this;
|
||||
out.X /= i;
|
||||
out.Y /= i;
|
||||
return out;
|
||||
}
|
||||
|
||||
Point Point::operator+=(int i) {
|
||||
X += i;
|
||||
Y += i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator-=(int i) {
|
||||
X -= i;
|
||||
Y -= i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator*=(int i) {
|
||||
X *= i;
|
||||
Y *= i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point Point::operator/=(int i) {
|
||||
X /= i;
|
||||
Y /= i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
59
src/nostalgia/common/point.hpp
Normal file
59
src/nostalgia/common/point.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2016-2017 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace nostalgia {
|
||||
namespace common {
|
||||
|
||||
class Point {
|
||||
public:
|
||||
int X = 0;
|
||||
int Y = 0;
|
||||
|
||||
Point();
|
||||
|
||||
Point(int x, int y);
|
||||
|
||||
Point operator+(common::Point p) const;
|
||||
|
||||
Point operator-(common::Point p) const;
|
||||
|
||||
Point operator*(common::Point p) const;
|
||||
|
||||
Point operator/(common::Point p) const;
|
||||
|
||||
|
||||
Point operator+=(common::Point p);
|
||||
|
||||
Point operator-=(common::Point p);
|
||||
|
||||
Point operator*=(common::Point p);
|
||||
|
||||
Point operator/=(common::Point p);
|
||||
|
||||
|
||||
Point operator+(int i) const;
|
||||
|
||||
Point operator-(int i) const;
|
||||
|
||||
Point operator*(int i) const;
|
||||
|
||||
Point operator/(int i) const;
|
||||
|
||||
|
||||
Point operator+=(int i);
|
||||
|
||||
Point operator-=(int i);
|
||||
|
||||
Point operator*=(int i);
|
||||
|
||||
Point operator/=(int i);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user