summaryrefslogtreecommitdiff
path: root/include/JSystem/JUtility/TColor.h
blob: ba460306a2262a5e57f679c9bde7e60e645ccd79 (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
#ifndef TCOLOR_H
#define TCOLOR_H

#include "dolphin/gx/GXStruct.h"

namespace JUtility {
struct TColor : public GXColor {
    TColor(u8 r, u8 g, u8 b, u8 a) { set(r, g, b, a); }
    TColor() { set(0xffffffff); }
    TColor(u32 u32Color) { set(u32Color); }
    TColor(GXColor color) { set(color); }

    // TColor(const TColor& other) { set(other.toUInt32()); }
    TColor& operator=(const TColor& other) {
        GXColor::operator=(other);
        return *this;
    }

    operator u32() const { return toUInt32(); }
    u32 toUInt32() const { return *(u32*)&r; }

    void set(u8 cR, u8 cG, u8 cB, u8 cA) {
        r = cR;
        g = cG;
        b = cB;
        a = cA;
    }

    void set(u32 u32Color) { *(u32*)&r = u32Color; }
    void set(GXColor gxColor) {
        GXColor* temp = this;
        *temp = gxColor;
    }
};
}  // namespace JUtility

#endif