summaryrefslogtreecommitdiff
path: root/include/SSVOpenHexagon/Data/StyleData.hpp
blob: 52d0040a05c4be06abd8299214a6614229d8ba4b (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Copyright (c) 2013-2020 Vittorio Romeo
// License: Academic Free License ("AFL") v. 3.0
// AFL License page: https://opensource.org/licenses/AFL-3.0

#pragma once

#include "SSVOpenHexagon/Data/ColorData.hpp"
#include "SSVOpenHexagon/Data/CapColor.hpp"

#include <SSVUtils/Core/Common/Frametime.hpp>

#include <SFML/Graphics/Color.hpp>
#include <SFML/System/Vector2.hpp>

#include <vector>
#include <string>

namespace Json {

class Value;

}

namespace ssvuj {

using Obj = Json::Value;

}

namespace hg::Utils {

class FastVertexVectorTris;
class FastVertexVectorQuads;

} // namespace hg::Utils

namespace hg {

class StyleData
{
private:
    float currentHue{0};
    float currentSwapTime{0};
    float pulseFactor{0};
    sf::Color currentMainColor{sf::Color::Black};
    sf::Color currentPlayerColor{sf::Color::Black};
    sf::Color currentTextColor{sf::Color::Black};
    sf::Color currentWallColor{sf::Color::White};
    sf::Color current3DOverrideColor{sf::Color::Black};
    std::vector<sf::Color> currentColors;

    [[nodiscard]] static sf::Color calculateColor(const float mCurrentHue,
        const float mPulseFactor, const ColorData& mColorData);

    [[nodiscard]] static ColorData colorDataFromObjOrDefault(
        const ssvuj::Obj& mRoot, const std::string& mKey,
        const ColorData& mDefault);

    void drawBackgroundImpl(Utils::FastVertexVectorTris& vertices,
        const sf::Vector2f& mCenterPos, const unsigned int sides,
        const bool darkenUnevenBackgroundChunk, const bool blackAndWhite) const;

    void drawBackgroundMenuHexagonImpl(Utils::FastVertexVectorTris& vertices,
        const sf::Vector2f& mCenterPos, const unsigned int sides,
        const bool fourByThree, const bool blackAndWhite) const;

public:
    std::string id{};
    float hueMin{};
    float hueMax{};
    float hueIncrement{};
    bool huePingPong{};

    float pulseMin{};
    float pulseMax{};
    float pulseIncrement{};
    float maxSwapTime{};

    float _3dDepth{};
    float _3dSkew{};
    float _3dSpacing{};
    float _3dDarkenMult{};
    float _3dAlphaMult{};
    float _3dAlphaFalloff{};
    float _3dPulseMax{};
    float _3dPulseMin{};
    float _3dPulseSpeed{};
    float _3dPerspectiveMult{};

    float bgTileRadius{10000.f};
    unsigned int BGColorOffset{0};
    float BGRotOff{0}; // In degrees

private:
    sf::Color _3dOverrideColor;
    ColorData mainColorData;
    ColorData playerColor;
    ColorData textColor;
    ColorData wallColor;

    CapColor capColor;

    std::vector<ColorData> colorDatas;

public:
    explicit StyleData();
    explicit StyleData(const ssvuj::Obj& mRoot);

    void update(ssvu::FT mFT, float mMult = 1.f);

    void computeColors();

    void drawBackgroundMenu(Utils::FastVertexVectorTris& mTris,
        const sf::Vector2f& mCenterPos, const unsigned int sides,
        const bool darkenUnevenBackgroundChunk, const bool blackAndWhite,
        const bool fourByThree) const;

    void drawBackground(Utils::FastVertexVectorTris& mTris,
        const sf::Vector2f& mCenterPos, const unsigned int sides,
        const bool darkenUnevenBackgroundChunk, const bool blackAndWhite) const;

    void setCapColor(const CapColor& mCapColor);

    [[nodiscard]] const sf::Color& getMainColor() const noexcept;
    [[nodiscard]] const sf::Color& getPlayerColor() const noexcept;
    [[nodiscard]] const sf::Color& getTextColor() const noexcept;
    [[nodiscard]] const sf::Color& getWallColor() const noexcept;
    [[nodiscard]] const std::vector<sf::Color>& getColors() const noexcept;
    [[nodiscard]] const sf::Color& getColor(
        const std::size_t mIdx) const noexcept;
    [[nodiscard]] float getCurrentHue() const noexcept;
    [[nodiscard]] float getCurrentSwapTime() const noexcept;
    [[nodiscard]] const sf::Color& get3DOverrideColor() const noexcept;
    [[nodiscard]] sf::Color getCapColorResult() const noexcept;
};

} // namespace hg