summaryrefslogtreecommitdiff
path: root/src/d/lyt/msg_window/d_lyt_msg_window_common.cpp
blob: 109ad21c3f0c4cb6860717a9c2f4ddce08cc0d91 (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
147
148
149
150
151
152
153
#include "d/lyt/msg_window/d_lyt_msg_window_common.h"

#include "common.h"
#include "d/d_tag_processor.h"
#include "d/lyt/d2d.h"
#include "m/m_vec.h"
#include "nw4r/math/math_types.h"

bool dLytMsgWindowSubtype::build(d2d::ResAccIf_c *, d2d::ResAccIf_c *, dTagProcessor_c *) {
    return true;
}

bool dLytMsgWindowSubtype::remove() {
    return true;
}

bool dLytMsgWindowSubtype::execute() {
    return true;
}

void dLytMsgWindowSubtype::open(dAcObjBase_c *obj, u32 param) {}

bool dLytMsgWindowSubtype::isDoneOpening() const {
    return true;
}

void dLytMsgWindowSubtype::close() {}

bool dLytMsgWindowSubtype::isDoneClosing() const {
    return true;
}

bool dLytMsgWindowSubtype::setText(const wchar_t *text) {
    return true;
}

static const char *sSwordPane = "RootPane";
static const char *sSwordTextBoxes[] = {
    "T_font_00",
    "T_fontS_00",
    "T_fontS_01",
};

bool dLytTextSword::build(d2d::ResAccIf_c *resAcc, ESwordType type) {
    mType = type;
    mLyt.setResAcc(resAcc);
    if (mType == GHIRAHIM) {
        mLyt.build("textGirahim00.brlyt", nullptr);
    } else if (mType == LASTBOSS) {
        mLyt.build("textLastBoss_00.brlyt", nullptr);
    } else {
        mLyt.build("textSword_00.brlyt", nullptr);
    }

    mLyt.setPriority(0x8A);

    if (mType == GHIRAHIM) {
        mAnm.init("textGirahim00_in.brlan", resAcc, mLyt.getLayout(), "G_inOut_00");
    } else if (mType == LASTBOSS) {
        mAnm.init("textLastBoss_00_in.brlan", resAcc, mLyt.getLayout(), "G_inOut_00");
    } else {
        mAnm.init("textSword_00_in.brlan", resAcc, mLyt.getLayout(), "G_inOut_00");
    }

    mAnm.bind(false);
    mAnm.setAnimEnable(true);

    mpPane = mLyt.findPane(sSwordPane);

    for (int i = 0; i < 3; i++) {
        mpTexts[i] = mLyt.getTextBox(sSwordTextBoxes[i]);
    }

    return true;
}

bool dLytTextSword::remove() {
    mAnm.remove();
    return true;
}

void dLytTextSword::draw(const wchar_t *str, s8 timer, mVec3_c pos, f32 fScale) {
    for (int i = 0; i < 3; i++) {
        mpTexts[i]->setTextWithGlobalTextProcessor(str, nullptr);
    }

    f32 f = fScale / dTagProcessor_c::fn_800B8040(0, 0);
    nw4r::math::VEC2 scale = nw4r::math::VEC2(f, f);

    mAnm.setFrame(timer);
    mpPane->SetLocationAdjust(true);
    mpPane->SetTranslate(pos);
    mpPane->SetScale(scale);
    mLyt.calc();
    mpPane->CalculateMtx(mLyt.getDrawInfo());
    mpPane->Draw(mLyt.getDrawInfo());
}

f32 dLytTextSword::getAnimDuration() const {
    return mAnm.getAnimDuration();
}

static const char *sLightPane = "RootPane";

bool dLytTextLight::build(d2d::ResAccIf_c *resAcc, ETextType type) {
    mType = type;
    mLyt.setResAcc(resAcc);

    if (type == DEMO) {
        mLyt.build("textLightDemo_00.brlyt", nullptr);
    } else {
        mLyt.build("textLight_00.brlyt", nullptr);
    }

    mLyt.setPriority(0x8A);

    if (mType == DEMO) {
        mAnm.init("textLightDemo_00_loop.brlan", resAcc, mLyt.getLayout(), "G_loop_00");
    } else {
        mAnm.init("textLight_00_loop.brlan", resAcc, mLyt.getLayout(), "G_loop_00");
    }

    mAnm.bind(false);
    mAnm.setAnimEnable(true);

    mpPane = mLyt.findPane(sLightPane);

    return true;
}

bool dLytTextLight::remove() {
    mAnm.remove();
    return true;
}

void dLytTextLight::draw(s8 frame, mVec3_c pos, u8 alpha, f32 fScale) {
    f32 f = fScale / dTagProcessor_c::fn_800B8040(0, 0);
    nw4r::math::VEC2 scale = nw4r::math::VEC2(f, f);

    mAnm.setFrame(frame);
    mpPane->SetLocationAdjust(true);
    mpPane->SetInfluencedAlpha(true);
    mpPane->SetAlpha(alpha);
    mpPane->SetTranslate(pos);
    mpPane->SetScale(scale);
    mLyt.calc();
    mpPane->CalculateMtx(mLyt.getDrawInfo());
    mpPane->Draw(mLyt.getDrawInfo());
}

f32 dLytTextLight::getAnimDuration() const {
    return mAnm.getAnimDuration();
}