From 3cf0fb6391424f03d52b27f79771390d4c3e664e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 12 Oct 2024 13:27:59 +0200 Subject: [PATCH] extended interface for text buffer drawing functions (not used yet) --- src/editor.c | 2 +- src/init.c | 4 ++-- src/libgame/gadgets.c | 2 +- src/libgame/text.c | 11 +++++++++++ src/libgame/text.h | 10 +++++----- src/network.c | 2 +- src/screens.c | 16 ++++++++-------- src/tools.c | 4 ++-- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/editor.c b/src/editor.c index f24f27c0..332abb54 100644 --- a/src/editor.c +++ b/src/editor.c @@ -11678,7 +11678,7 @@ static int PrintTextFromBuffer(char *text_buffer, int font_nr, int xpos, int ypo int max_lines_drawable = (SYSIZE - ypos) / font_height - 1; return DrawTextBuffer(SX + xpos, SY + ypos, text_buffer, font_nr, - max_chars_per_line, -1, max_lines_drawable, 0, -1, + max_chars_per_line, -1, max_lines_drawable, -1, -1, -1, 0, -1, TRUE, FALSE, FALSE); } diff --git a/src/init.c b/src/init.c index 956a5d01..7bbacd6e 100644 --- a/src/init.c +++ b/src/init.c @@ -6608,7 +6608,7 @@ void DisplayExitMessage(char *format, va_list ap) num_lines_printed = DrawTextBufferVA(sx, sy, format, ap, font_2, - line_length, line_length, max_lines, + line_length, line_length, max_lines, -1, -1, -1, 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); sy += (num_lines_printed + 3) * font_height; @@ -6617,7 +6617,7 @@ void DisplayExitMessage(char *format, va_list ap) num_lines_printed = DrawTextBuffer(sx, sy, program.log_filename, font_2, - line_length, line_length, max_lines, + line_length, line_length, max_lines, -1, -1, -1, 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); DrawTextSCentered(SYSIZE - 20, font_3, "Press any key or button to exit"); diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 8d23fe80..9cf2f6f0 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -954,7 +954,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) // gadget text value DrawTextArea(x + border_x, y + border_y, gi->textarea.value, - font_nr, xsize, -1, ysize, 0, + font_nr, xsize, -1, ysize, -1, -1, -1, 0, BLIT_ON_BACKGROUND, FALSE, FALSE, FALSE); cursor_letter = gi->textarea.value[gi->textarea.cursor_position]; diff --git a/src/libgame/text.c b/src/libgame/text.c index 25233f94..4d647466 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -549,6 +549,7 @@ static void DrawTextBuffer_Flush(int x, int y, char *buffer, int base_font_nr, static int DrawTextBufferExt(int x, int y, char *text_buffer, int base_font_nr, int line_length, int cut_length, int max_lines, + int line_width_unused, int cut_width_unused, int max_height_unused, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments, boolean is_text_area) @@ -708,39 +709,46 @@ static int DrawTextBufferExt(int x, int y, char *text_buffer, int base_font_nr, int DrawTextArea(int x, int y, char *text_buffer, int font_nr, int line_length, int cut_length, int max_lines, + int line_width, int cut_width, int max_height, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments) { return DrawTextBufferExt(x, y, text_buffer, font_nr, line_length, cut_length, max_lines, + line_width, cut_width, max_height, line_spacing, mask_mode, autowrap, centered, parse_comments, TRUE); } int DrawTextBuffer(int x, int y, char *text_buffer, int font_nr, int line_length, int cut_length, int max_lines, + int line_width, int cut_width, int max_height, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments) { return DrawTextBufferExt(x, y, text_buffer, font_nr, line_length, cut_length, max_lines, + line_width, cut_width, max_height, line_spacing, mask_mode, autowrap, centered, parse_comments, FALSE); } int DrawTextBufferS(int x, int y, char *text_buffer, int font_nr, int line_length, int cut_length, int max_lines, + int line_width, int cut_width, int max_height, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments) { return DrawTextBuffer(gfx.sx + x, gfx.sy + y, text_buffer, font_nr, line_length, cut_length, max_lines, + line_width, cut_width, max_height, line_spacing, mask_mode, autowrap, centered, parse_comments); } int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr, int line_length, int cut_length, int max_lines, + int line_width, int cut_width, int max_height, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments) { @@ -752,6 +760,7 @@ int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr, int num_lines_printed = DrawTextBuffer(x, y, text_buffer, font_nr, line_length, cut_length, max_lines, + line_width, cut_width, max_height, line_spacing, mask_mode, autowrap, centered, parse_comments); return num_lines_printed; @@ -759,12 +768,14 @@ int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr, int DrawTextFile(int x, int y, char *filename, int font_nr, int line_length, int cut_length, int max_lines, + int line_width, int cut_width, int max_height, int line_spacing, int mask_mode, boolean autowrap, boolean centered, boolean parse_comments) { char *text_buffer = GetTextBufferFromFile(filename, MAX_OUTPUT_LINESIZE); int num_lines_printed = DrawTextBuffer(x, y, text_buffer, font_nr, line_length, cut_length, max_lines, + line_width, cut_width, max_height, line_spacing, mask_mode, autowrap, centered, parse_comments); checked_free(text_buffer); diff --git a/src/libgame/text.h b/src/libgame/text.h index 9295a037..57eb5764 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -126,15 +126,15 @@ void DrawText(int, int, char *, int); void DrawTextExt(DrawBuffer *, int, int, char *, int, int); char *GetTextBufferFromFile(char *, int); -int DrawTextArea(int, int, char *, int, int, int, int, int, int, +int DrawTextArea(int, int, char *, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); -int DrawTextBuffer(int, int, char *, int, int, int, int, int, int, +int DrawTextBuffer(int, int, char *, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); -int DrawTextBufferS(int, int, char *, int, int, int, int, int, int, +int DrawTextBufferS(int, int, char *, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); -int DrawTextBufferVA(int, int, char *, va_list, int, int, int, int, int, int, +int DrawTextBufferVA(int, int, char *, va_list, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); -int DrawTextFile(int, int, char *, int, int, int, int, int, int, +int DrawTextFile(int, int, char *, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); #endif // TEXT_H diff --git a/src/network.c b/src/network.c index 3461572d..8a638728 100644 --- a/src/network.c +++ b/src/network.c @@ -99,7 +99,7 @@ static void DrawNetworkTextExt(char *message, int font_nr, boolean initialize) int num_lines_spacing = (font_nr == FC_YELLOW ? 1 : 3); int num_lines_printed = DrawTextBuffer(xpos, ypos, message, font_nr, max_chars_per_line, -1, - max_lines_per_text, 0, -1, + max_lines_per_text, -1, -1, -1, 0, -1, TRUE, TRUE, FALSE); ypos += (num_lines_printed + num_lines_spacing) * font_height; diff --git a/src/screens.c b/src/screens.c index b902af3f..4ee7366e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1840,7 +1840,7 @@ static void DrawTitleScreenMessage(int nr, boolean initial) ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi), - filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1, + filename, tmi->font, tmi->chars, -1, tmi->lines, -1, -1, -1, 0, -1, tmi->autowrap, tmi->centered, tmi->parse_comments); ResetFontStatus(); @@ -3464,7 +3464,7 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) // first get number of text lines to calculate offset for centering text int num_lines_printed = DrawTextBuffer(0, 0, text, font_nr, - max_chars_per_line, -1, max_lines_per_text, line_spacing, -1, + max_chars_per_line, -1, max_lines_per_text, -1, -1, -1, line_spacing, -1, autowrap, centered, parse_comments); EnableDrawingText(); @@ -3473,7 +3473,7 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) int yoffset = (row_height - size_lines_printed) / 2; DrawTextBuffer(xstart, ystart + ypos * ystep + yoffset, text, font_nr, - max_chars_per_line, -1, max_lines_per_text, line_spacing, -1, + max_chars_per_line, -1, max_lines_per_text, -1, -1, -1, line_spacing, -1, autowrap, centered, parse_comments); } @@ -4111,7 +4111,7 @@ static void DrawInfoScreen_GenericScreen(int screen_nr, int num_screens, boolean parse_comments = TRUE; DrawTextFile(xstart, ystart, - filename, font_text, chars, -1, lines, line_spacing, -1, + filename, font_text, chars, -1, lines, -1, -1, -1, line_spacing, -1, autowrap, centered, parse_comments); } else if (info_mode == INFO_MODE_LEVELSET || @@ -4150,7 +4150,7 @@ static void DrawInfoScreen_GenericScreen(int screen_nr, int num_screens, tmi->height = tmi->lines * getFontHeight(tmi->font); DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi), - filename, font, tmi->chars, -1, tmi->lines, 0, -1, + filename, font, tmi->chars, -1, tmi->lines, -1, -1, -1, 0, -1, tmi->autowrap, tmi->centered, tmi->parse_comments); } @@ -5851,13 +5851,13 @@ static void DrawScoreInfo_Content(int entry_nr) DrawTextF(xstart1, ystart, font_head, "Level Set"); lines = DrawTextBufferS(xstart2, ystart, leveldir_current->name, font_text, - max_chars_per_line, -1, max_lines_per_text, 0, -1, + max_chars_per_line, -1, max_lines_per_text, -1, -1, -1, 0, -1, TRUE, FALSE, FALSE); ystart += ystep_line + (lines > 0 ? lines - 1 : 0) * font_height; DrawTextF(xstart1, ystart, font_head, "Level"); lines = DrawTextBufferS(xstart2, ystart, level.name, font_text, - max_chars_per_line, -1, max_lines_per_text, 0, -1, + max_chars_per_line, -1, max_lines_per_text, -1, -1, -1, 0, -1, TRUE, FALSE, FALSE); ystart += ystep_para + (lines > 0 ? lines - 1 : 0) * font_height; @@ -5911,7 +5911,7 @@ static void DrawScoreInfo_Content(int entry_nr) DrawTextF(xstart1, ystart, font_head, "Country"); lines = DrawTextBufferS(xstart2, ystart, entry->country_name, font_text, - max_chars_per_line, -1, max_lines_per_text, 0, -1, + max_chars_per_line, -1, max_lines_per_text, -1, -1, -1, 0, -1, TRUE, FALSE, FALSE); ystart += ystep_line; diff --git a/src/tools.c b/src/tools.c index bf6192dd..a6d5aa47 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2970,7 +2970,7 @@ static void AnimateEnvelope(int envelope_nr, int anim_mode, int action) DrawTextArea(sx + font_width, sy + font_height, level.envelope[envelope_nr].text, font_nr, max_xsize, - xsize - 2, ysize - 2, 0, mask_mode, + xsize - 2, ysize - 2, -1, -1, -1, 0, mask_mode, level.envelope[envelope_nr].autowrap, level.envelope[envelope_nr].centered, FALSE); @@ -3228,7 +3228,7 @@ static void DrawEnvelopeRequestText(int sx, int sy, char *text) } DrawTextBuffer(sx + sx_offset, sy + sy_offset, text_final, font_nr, - line_length, -1, max_lines, line_spacing, mask_mode, + line_length, -1, max_lines, -1, -1, -1, line_spacing, mask_mode, request.autowrap, request.centered, FALSE); if (text_door_style) -- 2.34.1