MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / init_textbox

Function init_textbox

src/SB/Game/zTextBox.cpp:91–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 }
90
91 void init_textbox(ztextbox& e)
92 {
93 static const U32 xjlookup[] = { 0x0, 0x2, 0x1 };
94
95 ztextbox::asset_type& a = *e.asset;
96
97 e.tb.flags = 0;
98 e.tb.font.id = a.font;
99 e.tb.font.width = a.size.width;
100 e.tb.font.height = a.size.height;
101 e.tb.font.space = a.space.x;
102 e.tb.line_space = a.space.y;
103 e.tb.font.color = convert(a.color);
104 e.tb.bounds.x = a.bounds.x + a.inset.left;
105 e.tb.bounds.y = a.bounds.y + a.inset.top;
106 e.tb.bounds.w = a.bounds.w - a.inset.left - a.inset.right;
107 e.tb.bounds.h = a.bounds.h - a.inset.top - a.inset.bottom;
108 e.tb.flags |= (a.xjustify >= 3) ? xjlookup[0] : xjlookup[a.xjustify];
109 e.tb.set_text(e.segments, e.segments_size);
110
111 if (a.expand < ztextbox::asset_type::MAX_EX && a.max_height > a.bounds.h)
112 {
113 S32 lines;
114 F32 minh = e.tb.bounds.h;
115 F32 maxh = a.max_height - a.inset.top - a.inset.bottom;
116
117 e.tb.bounds.h = maxh;
118 e.tb.bounds.h = e.tb.yextent(maxh, lines, true);
119
120 if (e.tb.bounds.h > minh)
121 {
122 F32 hmore = e.tb.bounds.h - minh;
123
124 if (a.expand == ztextbox::asset_type::EX_CENTER)
125 {
126 e.tb.bounds.y -= _761_1 * hmore;
127 }
128 else if (a.expand == ztextbox::asset_type::EX_UP)
129 {
130 e.tb.bounds.y -= hmore;
131 }
132 }
133 else
134 {
135 e.tb.bounds.h = minh;
136 }
137 }
138
139 e.tb.font.clip.x = e.tb.bounds.x - a.inset.left;
140 e.tb.font.clip.y = e.tb.bounds.y - a.inset.top;
141 e.tb.font.clip.w = e.tb.bounds.w + a.inset.left + a.inset.right;
142 e.tb.font.clip.h = e.tb.bounds.h + a.inset.top + a.inset.bottom;
143 }
144
145 void parse_tag_blahblah(xtextbox::jot&, const xtextbox&, const xtextbox&,
146 const xtextbox::split_tag&)

Callers 2

renderMethod · 0.70
refreshMethod · 0.70

Calls 3

convertFunction · 0.85
set_textMethod · 0.45
yextentMethod · 0.45

Tested by

no test coverage detected