X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=ab6c4efa28f32b808b095e4955afc0966798750a;hp=b0773082c16981783208ab5c7c815a2b2790ea6e;hb=ba20bcc8b425b7addb2bd1bfc4ef3661e56ccd43;hpb=dad6457f2f778d11ad84e90d328981532d0ba0ea diff --git a/src/tools.c b/src/tools.c index b0773082..ab6c4efa 100644 --- a/src/tools.c +++ b/src/tools.c @@ -981,6 +981,8 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type) draw_border_function); redraw_mask &= ~fade_mask; + + ClearEventQueue(); } static void SetScreenStates_BeforeFadingIn() @@ -2800,6 +2802,8 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame); } + + ClearEventQueue(); } void ShowEnvelope(int envelope_nr) @@ -3083,6 +3087,8 @@ void AnimateEnvelopeRequest(int anim_mode, int action) SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame); } + + ClearEventQueue(); } void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) @@ -3504,9 +3510,85 @@ static void DrawPreviewLevelExt(boolean restart) } } +void DrawPreviewPlayers() +{ + if (game_status != GAME_MODE_MAIN) + return; + + if (!network.enabled && !setup.team_mode) + return; + + boolean player_found[MAX_PLAYERS]; + int num_players = 0; + int i, x, y; + + for (i = 0; i < MAX_PLAYERS; i++) + player_found[i] = FALSE; + + /* check which players can be found in the level (simple approach) */ + for (x = 0; x < lev_fieldx; x++) + { + for (y = 0; y < lev_fieldy; y++) + { + int element = level.field[x][y]; + + if (ELEM_IS_PLAYER(element)) + { + int player_nr = GET_PLAYER_NR(element); + + player_nr = MIN(MAX(0, player_nr), MAX_PLAYERS - 1); + + if (!player_found[player_nr]) + num_players++; + + player_found[player_nr] = TRUE; + } + } + } + + struct TextPosInfo *pos = &menu.main.preview_players; + int tile_size = pos->tile_size; + int border_size = pos->border_size; + int player_xoffset_raw = (pos->vertical ? 0 : tile_size + border_size); + int player_yoffset_raw = (pos->vertical ? tile_size + border_size : 0); + int player_xoffset = (pos->xoffset != -1 ? pos->xoffset : player_xoffset_raw); + int player_yoffset = (pos->yoffset != -1 ? pos->yoffset : player_yoffset_raw); + int max_players_width = (MAX_PLAYERS - 1) * player_xoffset + tile_size; + int max_players_height = (MAX_PLAYERS - 1) * player_yoffset + tile_size; + int all_players_width = (num_players - 1) * player_xoffset + tile_size; + int all_players_height = (num_players - 1) * player_yoffset + tile_size; + int max_xpos = SX + ALIGNED_XPOS(pos->x, max_players_width, pos->align); + int max_ypos = SY + ALIGNED_YPOS(pos->y, max_players_height, pos->valign); + int xpos = SX + ALIGNED_XPOS(pos->x, all_players_width, pos->align); + int ypos = SY + ALIGNED_YPOS(pos->y, all_players_height, pos->valign); + + /* clear area in which the players will be drawn */ + ClearRectangleOnBackground(drawto, max_xpos, max_ypos, + max_players_width, max_players_height); + + /* only draw players if level is suited for team mode */ + if (num_players < 2) + return; + + /* draw all players that were found in the level */ + for (i = 0; i < MAX_PLAYERS; i++) + { + if (player_found[i]) + { + int graphic = el2img(EL_PLAYER_1 + i); + + DrawSizedGraphicThruMaskExt(drawto, xpos, ypos, graphic, 0, tile_size); + + xpos += player_xoffset; + ypos += player_yoffset; + } + } +} + void DrawPreviewLevelInitial() { DrawPreviewLevelExt(TRUE); + DrawPreviewPlayers(); } void DrawPreviewLevelAnimation() @@ -3530,9 +3612,12 @@ static void DrawNetworkPlayer(int x, int y, int player_nr, int tile_size, DrawText(x + xoffset_text, y + yoffset_text, player_name, font_nr); } -void DrawNetworkPlayers() +void DrawNetworkPlayersExt(boolean force) { - if (!network.enabled || !network.connected) + if (game_status != GAME_MODE_MAIN) + return; + + if (!network.connected && !force) return; int num_players = 0; @@ -3544,7 +3629,7 @@ void DrawNetworkPlayers() struct TextPosInfo *pos = &menu.main.network_players; int tile_size = pos->tile_size; - int border_size = 2; + int border_size = pos->border_size; int xoffset_text = tile_size + border_size; int font_nr = pos->font; int font_width = getFontWidth(font_nr); @@ -3564,7 +3649,8 @@ void DrawNetworkPlayers() /* first draw local network player ... */ for (i = 0; i < MAX_PLAYERS; i++) { - if (stored_player[i].connected_locally) + if (stored_player[i].connected_network && + stored_player[i].connected_locally) { char *player_name = getNetworkPlayerName(i + 1); int player_width = xoffset_text + getTextWidth(player_name, font_nr); @@ -3593,6 +3679,16 @@ void DrawNetworkPlayers() } } +void DrawNetworkPlayers() +{ + DrawNetworkPlayersExt(FALSE); +} + +void ClearNetworkPlayers() +{ + DrawNetworkPlayersExt(TRUE); +} + inline static void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, int sync_frame, int mask_mode) @@ -5329,6 +5425,8 @@ unsigned int MoveDoor(unsigned int door_state) DrawMaskedBorder(REDRAW_DOOR_1); DrawMaskedBorder(REDRAW_DOOR_2); + ClearEventQueue(); + return (door1 | door2); }