From 33a2bc2439d6770b47e395d84ca67eeef18d02d4 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 27 Jun 2018 21:16:37 +0200 Subject: [PATCH] changed drawing to playfield when changing network mode setup options --- src/init.c | 2 -- src/network.c | 33 +++++++++++++++++++++++++++------ src/screens.c | 10 +--------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/init.c b/src/init.c index db1070e4..dd7e5a17 100644 --- a/src/init.c +++ b/src/init.c @@ -5621,8 +5621,6 @@ void InitNetworkServer() LimitScreenUpdates(FALSE); - ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); - if (!ConnectToServer(network.server_host, network.server_port)) { network.enabled = FALSE; diff --git a/src/network.c b/src/network.c index cabcfd30..fcd757d4 100644 --- a/src/network.c +++ b/src/network.c @@ -52,24 +52,45 @@ static boolean stop_network_game = FALSE; static void DrawNetworkTextExt(char *message, int font_nr, boolean initialize) { static int xpos = 0, ypos = 0; + static int max_line_width = 0; int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); + int ypos_1 = 120; + int ypos_2 = 150; if (initialize) { - xpos = (WIN_XSIZE - getTextWidth(message, font_nr)) / 2; - ypos = 120; + if (game_status == GAME_MODE_LOADING) + { + max_line_width = WIN_XSIZE; + + xpos = (max_line_width - getTextWidth(message, font_nr)) / 2; + ypos = ypos_1; - DrawText(xpos, ypos, message, font_nr); + DrawText(xpos, ypos, message, font_nr); - xpos = 0; - ypos = 150; + xpos = 0; + ypos = ypos_2; + } + else + { + max_line_width = SXSIZE; + + DrawTextSCentered(ypos_1, font_nr, message); + + /* calculate offset to x position caused by rounding */ + int max_chars_per_line = max_line_width / font_width; + int xoffset = (max_line_width - max_chars_per_line * font_width) / 2; + + xpos = SX + xoffset; + ypos = SY + ypos_2; + } Error(ERR_DEBUG, "========== %s ==========", message); } else { - int max_chars_per_line = WIN_XSIZE / font_width; + int max_chars_per_line = max_line_width / font_width; int max_lines_per_text = 10; int num_lines_spacing = (font_nr == FC_YELLOW ? 1 : 3); int num_lines_printed = DrawTextBuffer(xpos, ypos, message, font_nr, diff --git a/src/screens.c b/src/screens.c index 3ffcb484..3eab4a73 100644 --- a/src/screens.c +++ b/src/screens.c @@ -6449,12 +6449,9 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) { network.enabled = setup.network_mode; - SetGameStatus(GAME_MODE_LOADING); - SetDrawBackgroundMask(REDRAW_NONE); - FadeOut(REDRAW_ALL); - ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); + ClearField(); FadeIn(REDRAW_ALL); @@ -6463,11 +6460,6 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) else DisconnectFromNetworkServer(); - SetGameStatus(GAME_MODE_SETUP); - SetDrawBackgroundMask(REDRAW_FIELD); - - redraw_mask = REDRAW_ALL; - DrawSetupScreen(); } } -- 2.34.1