Add missing nostalgia directory level in src tree

This commit is contained in:
2017-05-12 17:55:18 -05:00
parent 1b9f8f40f4
commit bfc87b50b1
43 changed files with 22 additions and 19 deletions

View 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
)

View 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());
}
}
}

View 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();
};
}
}

View 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

View 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;
}
}
}

View 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);
};
}
}