Files
DNF_DEV/source/Tool/Common.h

141 lines
3.0 KiB
C++

#pragma once
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstddef>
#include <SDL.h>
#ifdef __SWITCH__
#include <switch/types.h>
#else
#include <cmath>
#endif
#include "math/Math.h"
/// \~chinese
/// @brief 不可拷贝对象
class Noncopyable
{
protected:
Noncopyable() = default;
private:
Noncopyable(const Noncopyable &) = delete;
Noncopyable &operator=(const Noncopyable &) = delete;
};
// 尺寸向量
typedef struct VecSize
{
int width;
int height;
// 构造函数,方便初始化
VecSize(int width_ = 0, int height_ = 0) : width(width_), height(height_) {}
// 加法运算符重载:两个 VecSize 相加
VecSize operator+(const VecSize &other) const
{
return VecSize(width + other.width, height + other.height);
}
// 减法运算符重载:两个 VecSize 相减
VecSize operator-(const VecSize &other) const
{
return VecSize(width - other.width, height - other.height);
}
// 等于运算符重载:判断两个 VecSize 是否相等
bool operator==(const VecSize &other) const
{
return width == other.width && height == other.height;
}
// 复合赋值加法:当前对象加上另一个 VecSize
VecSize &operator+=(const VecSize &other)
{
width += other.width;
height += other.height;
return *this;
}
// 复合赋值减法:当前对象减去另一个 VecSize
VecSize &operator-=(const VecSize &other)
{
width -= other.width;
height -= other.height;
return *this;
}
// 乘法
VecSize operator*(float value) const
{
return VecSize(width * value, height * value);
}
} VecSize;
typedef struct VecPos3
{
int x;
int y;
int z;
VecPos3(int x_ = 0, int y_ = 0, int z_ = 0) : x(x_), y(y_), z(z_) {}
VecPos3 operator+(const VecPos3 &other) const
{
return VecPos3(x + other.x, y + other.y, z + other.z);
}
VecPos3 operator-(const VecPos3 &other) const
{
return VecPos3(x - other.x, y - other.y, z - other.z);
}
bool operator==(const VecPos3 &other) const
{
return x == other.x && y == other.y && z == other.z;
}
bool operator!=(const VecPos3 &other) const
{
return x != other.x || y != other.y || z != other.z;
}
} VecPos3;
typedef struct VecSpeed3
{
int x;
int y;
int z;
VecSpeed3(int x_ = 0, int y_ = 0, int z_ = 0) : x(x_), y(y_), z(z_) {}
VecSpeed3 operator+(const VecSpeed3 &other) const
{
return VecSpeed3(x + other.x, y + other.y, z + other.z);
}
VecSpeed3 operator-(const VecSpeed3 &other) const
{
return VecSpeed3(x - other.x, y - other.y, z - other.z);
}
bool operator==(const VecSpeed3 &other) const
{
return x == other.x && y == other.y && z == other.z;
}
} VecSpeed3;
enum LE_BlEND_MODE
{
NONE,
LINEARDODGE
};