-
Notifications
You must be signed in to change notification settings - Fork 17
/
Preferences.h
58 lines (46 loc) · 1.51 KB
/
Preferences.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <stdint.h>
#include <string>
#include <jansson.h>
#include "Color.h"
#include "MathUtils.h"
using namespace std;
class Preferences
{
public:
static Preferences* Instance;
Preferences() : TotalFadeTimeMS(200),
BoundsTopLeft(0.2f, 0.2f), BoundsTopRight(0.8f, 0.2f), BoundsBottomRight(0.8f, 0.8f), BoundsBottomLeft(0.2f, 0.8f),
FixedColorEnabled(false), FixedColor(255, 0, 0),
CamSaturation(117), CamBrightness(30), CamContrast(74), CamGain(20)
{
Instance = this;
}
void Load();
json_t* JsonEncode() const;
void Save() const;
public:
// You know what, fuck getters and setters. What a waste of time
// Bounds coordinates in normalized coordinates ([0, 1], [0, 1])
Vector2 BoundsTopLeft;
Vector2 BoundsTopRight;
Vector2 BoundsBottomRight;
Vector2 BoundsBottomLeft;
// Fade time; makes color transitions smoother
int TotalFadeTimeMS;
// Fixed color settings
bool FixedColorEnabled;
Color FixedColor;
// Camera settings
uint8_t CamSaturation;
uint8_t CamBrightness;
uint8_t CamContrast;
uint8_t CamGain;
private:
void ReadVector2(const json_t *root, const char* propertyName, Vector2& dest);
void ReadColor(const json_t *root, const char* propertyName, Color& dest);
void ReadInt(const json_t *root, const char* propertyName, int& dest);
void ReadInt8(const json_t *root, const char* propertyName, uint8_t& dest);
void ReadFloat(const json_t *root, const char* propertyName, float& dest);
void ReadBool(const json_t *root, const char* propertyName, bool& dest);
};