MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / TextGroupWidget_DrawAdvanced

Function TextGroupWidget_DrawAdvanced

src/Widgets.c:2359–2398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2357}
2358
2359static void TextGroupWidget_DrawAdvanced(struct TextGroupWidget* w, struct Texture* tex, struct DrawTextArgs* args, int index, const cc_string* text) {
2360 char chars[GUI_MAX_CHATLINES * TEXTGROUPWIDGET_LEN];
2361 struct Portion portions[2 * (TEXTGROUPWIDGET_LEN / TEXTGROUPWIDGET_HTTP_LEN)];
2362 struct Portion bit;
2363 int width, height;
2364 int partWidths[Array_Elems(portions)];
2365 struct Context2D ctx;
2366 int portionsCount;
2367 int i, x, ul;
2368
2369 width = 0;
2370 height = Drawer2D_TextHeight(args);
2371 portionsCount = TextGroupWidget_Reduce(w, chars, index, portions);
2372
2373 for (i = 0; i < portionsCount; i++) {
2374 bit = portions[i];
2375 args->text = String_UNSAFE_Substring(text, bit.LineBeg, bit.LineLen);
2376
2377 partWidths[i] = Drawer2D_TextWidth(args);
2378 width += partWidths[i];
2379 }
2380
2381 Context2D_Alloc(&ctx, width, height);
2382 {
2383 x = 0;
2384 for (i = 0; i < portionsCount; i++) {
2385 bit = portions[i];
2386 ul = (bit.Len & TEXTGROUPWIDGET_URL);
2387 args->text = String_UNSAFE_Substring(text, bit.LineBeg, bit.LineLen);
2388
2389 if (ul) args->font->flags |= FONT_FLAGS_UNDERLINE;
2390 Context2D_DrawText(&ctx, args, x, 0);
2391 if (ul) args->font->flags &= ~FONT_FLAGS_UNDERLINE;
2392
2393 x += partWidths[i];
2394 }
2395 Context2D_MakeTexture(tex, &ctx);
2396 }
2397 Context2D_Free(&ctx);
2398}
2399
2400void TextGroupWidget_RedrawAll(struct TextGroupWidget* w) {
2401 int i;

Callers 1

TextGroupWidget_RedrawFunction · 0.85

Calls 8

Drawer2D_TextHeightFunction · 0.85
TextGroupWidget_ReduceFunction · 0.85
String_UNSAFE_SubstringFunction · 0.85
Drawer2D_TextWidthFunction · 0.85
Context2D_AllocFunction · 0.85
Context2D_DrawTextFunction · 0.85
Context2D_MakeTextureFunction · 0.85
Context2D_FreeFunction · 0.85

Tested by

no test coverage detected