geode/loader/include/Geode/utils/operators.hpp

170 lines
5 KiB
C++
Raw Normal View History

2022-07-30 12:24:03 -04:00
#pragma once
2022-10-13 05:56:23 -04:00
#include <cocos2d.h>
2022-07-30 12:24:03 -04:00
namespace geode {
2022-10-30 14:59:20 -04:00
static cocos2d::CCPoint& operator*=(cocos2d::CCPoint& pos, float mul) {
2022-07-30 12:24:03 -04:00
pos.x *= mul;
pos.y *= mul;
return pos;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize& operator*=(cocos2d::CCSize& size, float mul) {
size.width *= mul;
2022-07-30 12:24:03 -04:00
size.height *= mul;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator*(cocos2d::CCSize const& size, cocos2d::CCPoint const& point) {
2022-07-30 12:24:03 -04:00
return {
size.width * point.x,
size.height * point.y,
};
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator*=(cocos2d::CCRect& rect, float mul) {
2022-07-30 12:24:03 -04:00
rect.origin *= mul;
2022-10-30 14:59:20 -04:00
rect.size *= mul;
2022-07-30 12:24:03 -04:00
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator*(cocos2d::CCRect const& rect, float mul) {
return {
rect.origin.x * mul,
rect.origin.y * mul,
rect.size.width * mul,
rect.size.height * mul,
};
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCPoint operator/=(cocos2d::CCPoint& pos, float div) {
2022-07-30 12:24:03 -04:00
pos.x /= div;
pos.y /= div;
return pos;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator/=(cocos2d::CCSize& size, float div) {
size.width /= div;
2022-07-30 12:24:03 -04:00
size.height /= div;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator/=(cocos2d::CCRect& rect, float div) {
2022-07-30 12:24:03 -04:00
rect.origin /= div;
2022-10-30 14:59:20 -04:00
rect.size /= div;
2022-07-30 12:24:03 -04:00
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCPoint operator+=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
2022-07-30 12:24:03 -04:00
pos.x += add.x;
pos.y += add.y;
return pos;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
size.width += add.x;
2022-07-30 12:24:03 -04:00
size.height += add.y;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
size.width += add.width;
2022-07-30 12:24:03 -04:00
size.height += add.height;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
2022-07-30 12:24:03 -04:00
rect.origin += add;
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
2022-07-30 12:24:03 -04:00
rect.size += add;
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
2022-07-30 12:24:03 -04:00
rect.origin += add.origin;
2022-10-30 14:59:20 -04:00
rect.size += add.size;
2022-07-30 12:24:03 -04:00
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCPoint operator-=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
pos.x -= add.x;
pos.y -= add.y;
return pos;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
size.width -= add.x;
size.height -= add.y;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
size.width -= add.width;
size.height -= add.height;
return size;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
rect.origin -= add;
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
rect.size -= add;
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
rect.origin -= add.origin;
2022-10-30 14:59:20 -04:00
rect.size -= add.size;
return rect;
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator-(cocos2d::CCSize const& size, float f) {
2022-07-30 12:24:03 -04:00
return { size.width - f, size.height - f };
}
2022-10-30 14:59:20 -04:00
static cocos2d::CCSize operator-(cocos2d::CCSize const& size) {
2022-07-30 12:24:03 -04:00
return { -size.width, -size.height };
}
2022-10-30 14:59:20 -04:00
static bool operator==(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
return p1.x == p2.x && p1.y == p2.y;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
static bool operator!=(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
return p1.x != p2.x || p1.y != p2.y;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
static bool operator==(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
return s1.width == s2.width && s1.height == s2.height;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
static bool operator!=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
return s1.width != s2.width || s1.height != s2.height;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
static bool operator==(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
return r1.origin == r2.origin && r1.size == r2.size;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
static bool operator!=(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
return r1.origin != r2.origin || r1.size != r2.size;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
2022-07-30 12:24:03 -04:00
static bool operator==(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
2022-10-30 14:59:20 -04:00
return c1.r == c2.r && c1.g == c2.g && c1.b == c2.b && c1.a == c2.a;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
2022-07-30 12:24:03 -04:00
static bool operator!=(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
2022-10-30 14:59:20 -04:00
return c1.r != c2.r || c1.g != c2.g || c1.b != c2.b || c1.a != c2.a;
2022-07-30 12:24:03 -04:00
}
2022-10-30 14:59:20 -04:00
2022-07-30 12:24:03 -04:00
static bool operator!=(cocos2d::ccColor3B const& c1, cocos2d::ccColor3B const& c2) {
2022-10-30 14:59:20 -04:00
return c1.r != c2.r || c1.g != c2.g || c1.b != c2.b;
2022-07-30 12:24:03 -04:00
}
}