66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <JJX/JSON.hpp>
|
|
#include <Color4.hpp>
|
|
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
|
|
|
using namespace JJX;
|
|
|
|
struct RecentCameraState
|
|
{
|
|
Vector2 translation;
|
|
float rotation;
|
|
float scale;
|
|
|
|
json::value Serialize() const
|
|
{
|
|
json::object json;
|
|
json["tx"] = json::number(translation.x);
|
|
json["ty"] = translation.y;
|
|
json["rot"] = rotation;
|
|
json["scale"] = scale;
|
|
return json;
|
|
}
|
|
|
|
void Deserialize(const json::value& v)
|
|
{
|
|
translation.x = v["tx"].number.value_or(0.f);
|
|
translation.y = v["ty"].number.value_or(0.f);
|
|
rotation = v["rot"].number.value_or(0.f);
|
|
scale = v["scale"].number.value_or(1.f);
|
|
}
|
|
};
|
|
|
|
class Preferences {
|
|
public:
|
|
#pragma region Member Variables
|
|
RecentCameraState recent_camera_state;
|
|
#pragma endregion
|
|
public:
|
|
|
|
Preferences() : recent_camera_state()
|
|
{
|
|
|
|
}
|
|
|
|
explicit Preferences(const json::value& json)
|
|
{
|
|
Deserialize(json);
|
|
}
|
|
|
|
json::value Serialize() const
|
|
{
|
|
json::object json;
|
|
|
|
json["camerastate"] = recent_camera_state.Serialize();
|
|
|
|
return json;
|
|
}
|
|
|
|
void Deserialize(const json::value& json)
|
|
{
|
|
recent_camera_state.Deserialize(json["camerastate"]);
|
|
}
|
|
|
|
public:
|
|
}; |