50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Color4.hpp>
|
|
#include <J3ML/LinearAlgebra.hpp>
|
|
#include <json.hpp>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
#include "Event.h"
|
|
#include "J3ML/LinearAlgebra/Vector2i.hpp"
|
|
|
|
#pragma once
|
|
|
|
|
|
inline int CellToIndex(Vector2i cell, int width)
|
|
{
|
|
return cell.y*width + cell.x;
|
|
}
|
|
|
|
namespace JsonConversions
|
|
{
|
|
Color4 parse_color(const json::value& v);
|
|
json::value deparse_color_to_hex(const Color4& color);
|
|
|
|
std::vector<std::string> parse_string_list(const json::value& v);
|
|
|
|
json::value deparse_string_list(const std::vector<std::string>& list);
|
|
} // namespace JsonConversions
|
|
|
|
template <typename T>
|
|
struct Lerped
|
|
{
|
|
T goal;
|
|
T current;
|
|
float rate;
|
|
|
|
void Step(float elapsed);
|
|
|
|
};
|
|
|
|
template <> inline void Lerped<float>::Step(float elapsed) { current = Math::Lerp(current, goal, rate*elapsed);}
|
|
template <> inline void Lerped<Vector2>::Step(float elapsed) { current = Vector2::Lerp(current, goal, rate*elapsed);}
|
|
|
|
|
|
std::string read_file_contents(const std::filesystem::path& file_path);
|
|
bool write_file_contents(const std::filesystem::path& file_path, const std::string& contents);
|
|
|
|
std::vector<std::string> split (const std::string &s, char delim);
|
|
|