impr: Various small fixes and improvements

This commit is contained in:
WerWolv
2025-01-31 19:43:39 +01:00
parent e603c75bd3
commit e6ab2c3b7e
30 changed files with 132 additions and 83 deletions

View File

@@ -362,7 +362,7 @@ namespace hex {
* @brief Returns all registered achievements
* @return All achievements
*/
static const std::unordered_map<std::string, std::unordered_map<std::string, std::unique_ptr<Achievement>>>& getAchievements();
static const std::unordered_map<UnlocalizedString, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>>& getAchievements();
/**
* @brief Returns all achievement start nodes
@@ -370,14 +370,14 @@ namespace hex {
* @param rebuild Whether to rebuild the list of start nodes
* @return All achievement start nodes
*/
static const std::unordered_map<std::string, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true);
static const std::unordered_map<UnlocalizedString, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true);
/**
* @brief Returns all achievement nodes
* @param rebuild Whether to rebuild the list of nodes
* @return All achievement nodes
*/
static const std::unordered_map<std::string, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true);
static const std::unordered_map<UnlocalizedString, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true);
/**
* @brief Loads the progress of all achievements from the achievements save file

View File

@@ -101,10 +101,9 @@ namespace hex {
public:
UnlocalizedString() = default;
template<typename T>
UnlocalizedString(T &&arg) : m_unlocalizedString(std::forward<T>(arg)) {
static_assert(!std::same_as<std::remove_cvref_t<T>, Lang>, "Expected a unlocalized name, got a localized one!");
}
UnlocalizedString(const std::string &string) : m_unlocalizedString(string) { }
UnlocalizedString(const char *string) : m_unlocalizedString(string) { }
UnlocalizedString(const Lang& arg) = delete;
[[nodiscard]] operator std::string() const {
return m_unlocalizedString;
@@ -149,3 +148,10 @@ namespace hex {
}
}
template<>
struct std::hash<hex::UnlocalizedString> {
std::size_t operator()(const hex::UnlocalizedString &string) const noexcept {
return std::hash<std::string>{}(string.get());
}
};

View File

@@ -2,6 +2,7 @@
#include <hex/helpers/fs.hpp>
#include <array>
#include <vector>
namespace hex::paths {

View File

@@ -9,6 +9,7 @@
#include <map>
#include <span>
#include <string>
#include <numbers>
#include <opengl_support.h>
#include <GLFW/glfw3.h>
@@ -219,11 +220,11 @@ namespace hex::gl {
this->mat[row*Columns + col] = value;
}
T &operator()( const int &row,const int &col) {
T &operator()( const unsigned&row, const unsigned&col) {
return this->mat[row*Columns + col];
}
const T &operator()(const unsigned& row,const unsigned& col ) const {
const T &operator()(const unsigned& row, const unsigned& col) const {
return this->mat[row*Columns + col];
}
@@ -401,7 +402,7 @@ namespace hex::gl {
T Sx, Cx, Sy, Cy, Sz, Cz;
Vector<T,3> angles = ypr;
if(!radians)
angles *= M_PI/180;
angles *= std::numbers::pi / 180;
Sx = -sin(angles[0]); Cx = cos(angles[0]);
Sy = -sin(angles[1]); Cy = cos(angles[1]);
@@ -524,7 +525,7 @@ namespace hex::gl {
Vector<T,3> rotationVector3 = {{rotationVector[0], rotationVector[1], rotationVector[2]}};
T theta = rotationVector3.magnitude();
if (!radians)
theta *= M_PI / 180;
theta *= std::numbers::pi / 180;
Vector<T,3> axis = rotationVector3;
if (theta != 0)
axis = axis.normalize();

View File

@@ -37,7 +37,7 @@ namespace hex {
template<typename T>
[[nodiscard]] std::vector<std::vector<T>> sampleChannels(const std::vector<T> &data, size_t count, size_t channels) {
if (channels == 0) return {};
size_t signalLength = std::max(1.0, double(data.size()) / channels);
size_t signalLength = std::max<double>(1.0, double(data.size()) / channels);
size_t stride = std::max(1.0, double(signalLength) / count);