summaryrefslogtreecommitdiff
path: root/include/JSystem/J2DGraph/J2DPicture.h
blob: dd55e7e883c446bee6bf2ca0bea563d89aeeb687 (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
138
139
140
141
142
143
144
145
146
#ifndef J2DPICTURE_H
#define J2DPICTURE_H

#include "JSystem/J2DGraph/J2DPane.h"
#include "JSystem/JUtility/JUTTexture.h"
#include "JSystem/JUtility/TColor.h"
#include "dolphin/gx/GX.h"

class JKRArchive;
class JUTTexture;
class JUTPalette;
struct ResTIMG;
struct ResTLUT;

enum J2DBinding {
    J2DBind_Bottom = (1 << 0),
    J2DBind_Top    = (1 << 1),
    J2DBind_Right  = (1 << 2),
    J2DBind_Left   = (1 << 3),
};

enum J2DMirror {
    J2DMirror_Y    = (1 << 0),
    J2DMirror_X    = (1 << 1),
};

class J2DPicture : public J2DPane {
public:
    struct TCornerColor {
        // TODO
    };

    J2DPicture();
    J2DPicture(J2DPane*, JSURandomInputStream*);
    J2DPicture(const ResTIMG*);
    J2DPicture(const char*);
    J2DPicture(u32, const JGeometry::TBox2<f32>&, const ResTIMG*, const ResTLUT*);
    virtual ~J2DPicture();
    virtual u16 getTypeID() { return 0x12; }
    virtual void drawSelf(f32 x, f32 y);
    virtual void drawSelf(f32 x, f32 y, Mtx* mtx);
    virtual void drawOut(f32 p1, f32 p2, f32 p3, f32 p4, f32 p5, f32 p6) {
        if (mpTexture[0]) {
            drawOut(JGeometry::TBox2<f32>(p1, p2, p1 + p3, p2 + p4), JGeometry::TBox2<f32>(p5, p6, p5 + mpTexture[0]->getWidth(), p6 + mpTexture[0]->getHeight()));
        }
    }
    virtual void drawOut(f32 p1, f32 p2, f32 p3, f32 p4, f32 p5, f32 p6, f32 p7, f32 p8) {
        drawOut(JGeometry::TBox2<f32>(p1, p2, p1 + p3, p2 + p4), JGeometry::TBox2<f32>(p5, p6, p5 + p7, p6 + p8));
    }
    JUTTexture * getTexture(u8 idx) const {
        return idx < mNumTexture ? mpTexture[idx] : NULL;
    }
    void initiate(const ResTIMG*, const ResTLUT*);
    void private_initiate(const ResTIMG*, const ResTLUT*);
    void initinfo();
    bool insert(const ResTIMG*, u8, f32);
    bool insert(const char*, u8, f32);
    bool append(const ResTIMG* timg, f32 param_1) { return insert(timg, mNumTexture, param_1); }
    bool append(const char* name, f32 param_1) { return insert(name, mNumTexture, param_1); }
    bool remove(u8);
    bool remove() { return remove(mNumTexture - 1); }
    const ResTIMG * changeTexture(const ResTIMG*, u8);
    const ResTIMG * changeTexture(const char*, u8);
    void drawFullSet(f32, f32, f32, f32, J2DBinding, J2DMirror, bool, Mtx*);
    void draw(f32, f32, f32, f32, bool, bool, bool);
    void draw(f32 x, f32 y, u8 i, bool mirrorX, bool mirrorY, bool tumble) {
        if (i < mNumTexture)
            draw(x, y, mpTexture[0]->getWidth(), mpTexture[0]->getHeight(), mirrorX, mirrorY, tumble);
    }
    void draw(f32 x, f32 y, bool mirrorX, bool mirrorY, bool tumble) {
        draw(x, y, 0, mirrorX, mirrorY, tumble);
    }
    void drawOut(const JGeometry::TBox2<f32>&, const JGeometry::TBox2<f32>&);
    void drawTexCoord(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, Mtx*);
    void setTevMode();
    void swap(f32&, f32&);
    void setBlendKonstColor();
    void setBlendKonstAlpha();
    void getNewColor(JUtility::TColor*);

    void setBlendColorRatio(f32 f1, f32 f2, f32 f3, f32 f4) {
        mBlendKonstColorF[0] = f1;
        mBlendKonstColorF[1] = f2;
        mBlendKonstColorF[2] = f3;
        mBlendKonstColorF[3] = f4;
        setBlendKonstColor();
    }
    void setBlendAlphaRatio(f32 f1, f32 f2, f32 f3, f32 f4) {
        mBlendKonstAlphaF[0] = f1;
        mBlendKonstAlphaF[1] = f2;
        mBlendKonstAlphaF[2] = f3;
        mBlendKonstAlphaF[3] = f4;
        setBlendKonstAlpha();
    }
    void setBlendRatio(f32 f1, f32 f2, f32 f3, f32 f4) {
        setBlendColorRatio(f1, f2, f3, f4);
        setBlendAlphaRatio(f1, f2, f3, f4);
    }
    const JUtility::TColor& getWhite() const { return mColorWhite; }
    bool setWhite(JUtility::TColor white) { mColorWhite = white; return true; }
    const JUtility::TColor& getBlack() const { return mColorBlack; }
    bool setBlack(JUtility::TColor black) { mColorBlack = black; return true; }
    bool setBlackWhite(JUtility::TColor black, JUtility::TColor white) {
        mColorBlack = black;
        mColorWhite = white;
        return true;
    }
    void setCornerColor(JUtility::TColor c0, JUtility::TColor c1, JUtility::TColor c2, JUtility::TColor c3) {
        mCornerColor[0] = c0;
        mCornerColor[1] = c1;
        mCornerColor[2] = c2;
        mCornerColor[3] = c3;
    }
    void setCornerColor(JUtility::TColor c) { setCornerColor(c, c, c, c); }

    void setBinding(J2DBinding v) { mBinding = v; }
    void setMirror(J2DMirror v) { mFlag = (mFlag & 0x04) | v; }
    J2DMirror getMirror() const { return J2DMirror(mFlag & 0x03); }

    void setTumble(bool v) {} // untested { mFlag = (mFlag & ~0x04) | (v << 2); }
    bool isTumble() const { return mFlag & 0x04; }

    void load(u8 i) { mpTexture[i]->load((GXTexMapID)i); }

    // TODO
    void getCornerColor(J2DPicture::TCornerColor&) const {}

protected:
    /* 0x0CC */ JUTTexture* mpTexture[4];
    /* 0x0DC */ u8 mNumTexture;
    /* 0x0DD */ u8 mValidTexture;
    /* 0x0DE */ u8 mBinding;
    /* 0x0DF */ u8 mFlag;
    /* 0x0E0 */ f32 mBlendKonstColorF[4];
    /* 0x0F0 */ f32 mBlendKonstAlphaF[4];
    /* 0x100 */ JUTPalette* mpPalette;
    /* 0x104 */ JUtility::TColor mColorWhite;
    /* 0x108 */ JUtility::TColor mColorBlack;
    /* 0x10C */ JUtility::TColor mCornerColor[4];
    /* 0x11C */ JUtility::TColor mBlendKonstColor;
    /* 0x120 */ JUtility::TColor mBlendKonstAlpha;
};  // Size: 0x124

STATIC_ASSERT(sizeof(J2DPicture) == 0x124);

#endif /* J2DPICTURE_H */