GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/dye/dyecolor.h Lines: 14 14 100.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2013-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef RESOURCES_DYE_DYECOLOR_H
22
#define RESOURCES_DYE_DYECOLOR_H
23
24
#include "utils/buildhex.h"
25
26
#include "localconsts.h"
27
28
struct DyeColor final
29
{
30
384
    DyeColor() noexcept2 :
31
        valueA(buildHex(0, 0, 0, 255)),
32
        valueS(buildHex(0, 0, 0, 0)),
33
384
        valueSOgl(buildHexOgl(0, 0, 0, 0))
34
    {
35
384
        value[3] = 255;
36
    }
37
38
    DyeColor(const uint8_t r,
39
             const uint8_t g,
40
             const uint8_t b) noexcept2 :
41
384
        valueA(buildHex(r, g, b, 255)),
42
        valueS(buildHex(r, g, b, 0)),
43
384
        valueSOgl(buildHexOgl(0, b, g, r))
44
    {
45
        value[0] = r;
46
        value[1] = g;
47
        value[2] = b;
48
        value[3] = 255;
49
    }
50
51
    DyeColor(const uint8_t r,
52
             const uint8_t g,
53
             const uint8_t b,
54
7866
             const uint8_t a) noexcept2 :
55
        valueA(buildHex(r, g, b, a)),
56
        valueS(buildHex(r, g, b, 0)),
57
7866
        valueSOgl(buildHexOgl(0, b, g, r))
58
    {
59
7866
        value[0] = r;
60
7866
        value[1] = g;
61
7866
        value[2] = b;
62
7866
        value[3] = a;
63
    }
64
65
    A_DEFAULT_COPY(DyeColor)
66
67
    void update()
68
    {
69
7866
        valueA = buildHex(value[0], value[1], value[2], value[3]);
70
7866
        valueS = buildHex(value[0], value[1], value[2], 0);
71
7866
        valueSOgl = buildHexOgl(0, value[2], value[1], value[0]);
72
    }
73
74
    union
75
    {
76
        uint8_t value[4];
77
        uint32_t valueAOgl;
78
    };
79
    uint32_t valueA;
80
    uint32_t valueS;
81
    uint32_t valueSOgl;
82
};
83
84
#endif  // RESOURCES_DYE_DYECOLOR_H