X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=aac531f02f3964afc8504d3cbbbe3372c67628b4;hb=534881ab3184952023d05c6aa739bc7fcf8da82a;hp=9e06ab4ad18d4b9b70ac3162f9d48562693cf939;hpb=d5aae18363bcd9867d27d8db5bdcf1d8579bb42c;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 9e06ab4a..aac531f0 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4215,7 +4215,42 @@ static int RequestHandleEvents(unsigned int req_state) } if (req_state & REQ_PLAYER) - result = 0; + { + int old_player_nr = setup.network_player_nr; + + if (result != -1) + result = old_player_nr + 1; + + switch (key) + { + case KSYM_space: + result = old_player_nr + 1; + break; + + case KSYM_Up: + case KSYM_1: + result = 1; + break; + + case KSYM_Right: + case KSYM_2: + result = 2; + break; + + case KSYM_Down: + case KSYM_3: + result = 3; + break; + + case KSYM_Left: + case KSYM_4: + result = 4; + break; + + default: + break; + } + } break; } @@ -4231,19 +4266,52 @@ static int RequestHandleEvents(unsigned int req_state) case SDL_CONTROLLER_BUTTON_A: case SDL_CONTROLLER_BUTTON_X: case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: + case SDL_CONTROLLER_BUTTON_LEFTSTICK: result = 1; break; case SDL_CONTROLLER_BUTTON_B: case SDL_CONTROLLER_BUTTON_Y: case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: + case SDL_CONTROLLER_BUTTON_RIGHTSTICK: case SDL_CONTROLLER_BUTTON_BACK: result = 0; break; } if (req_state & REQ_PLAYER) - result = 0; + { + int old_player_nr = setup.network_player_nr; + + if (result != -1) + result = old_player_nr + 1; + + switch (event.cbutton.button) + { + case SDL_CONTROLLER_BUTTON_DPAD_UP: + case SDL_CONTROLLER_BUTTON_Y: + result = 1; + break; + + case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: + case SDL_CONTROLLER_BUTTON_B: + result = 2; + break; + + case SDL_CONTROLLER_BUTTON_DPAD_DOWN: + case SDL_CONTROLLER_BUTTON_A: + result = 3; + break; + + case SDL_CONTROLLER_BUTTON_DPAD_LEFT: + case SDL_CONTROLLER_BUTTON_X: + result = 4; + break; + + default: + break; + } + } break; @@ -4268,6 +4336,22 @@ static int RequestHandleEvents(unsigned int req_state) else if (joy & JOY_BUTTON_2) result = 0; } + else if (AnyJoystick()) + { + int joy = AnyJoystick(); + + if (req_state & REQ_PLAYER) + { + if (joy & JOY_UP) + result = 1; + else if (joy & JOY_RIGHT) + result = 2; + else if (joy & JOY_DOWN) + result = 3; + else if (joy & JOY_LEFT) + result = 4; + } + } if (level_solved) { @@ -4308,13 +4392,11 @@ static boolean RequestDoor(char *text, unsigned int req_state) SetMouseCursor(CURSOR_DEFAULT); -#if defined(NETWORK_AVALIABLE) /* pause network game while waiting for request to answer */ - if (options.network && + if (network.enabled && game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR_INPUT) SendToServer_PausePlaying(); -#endif old_door_state = GetDoorState(); @@ -4450,13 +4532,11 @@ static boolean RequestDoor(char *text, unsigned int req_state) SetDrawBackgroundMask(REDRAW_FIELD); } -#if defined(NETWORK_AVALIABLE) /* continue network game after request */ - if (options.network && + if (network.enabled && game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR_INPUT) SendToServer_ContinuePlaying(); -#endif /* restore deactivated drawing when quick-loading level tape recording */ if (tape.playing && tape.deactivate_display) @@ -4478,13 +4558,11 @@ static boolean RequestEnvelope(char *text, unsigned int req_state) SetMouseCursor(CURSOR_DEFAULT); -#if defined(NETWORK_AVALIABLE) /* pause network game while waiting for request to answer */ - if (options.network && + if (network.enabled && game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR_INPUT) SendToServer_PausePlaying(); -#endif /* simulate releasing mouse button over last gadget, if still pressed */ if (button_status) @@ -4537,13 +4615,11 @@ static boolean RequestEnvelope(char *text, unsigned int req_state) SetDrawBackgroundMask(REDRAW_FIELD); } -#if defined(NETWORK_AVALIABLE) /* continue network game after request */ - if (options.network && + if (network.enabled && game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR_INPUT) SendToServer_ContinuePlaying(); -#endif /* restore deactivated drawing when quick-loading level tape recording */ if (tape.playing && tape.deactivate_display) @@ -5304,7 +5380,8 @@ void CreateToolButtons() for (i = 0; i < NUM_TOOL_BUTTONS; i++) { - struct GraphicInfo *gfx = &graphic_info[toolbutton_info[i].graphic]; + int graphic = toolbutton_info[i].graphic; + struct GraphicInfo *gfx = &graphic_info[graphic]; struct TextPosInfo *pos = toolbutton_info[i].pos; struct GadgetInfo *gi; Bitmap *deco_bitmap = None; @@ -5328,33 +5405,30 @@ void CreateToolButtons() if (x < 0 || x + gfx->width > request.width || y < 0 || y + gfx->height > request.height) { - // use left padding of "yes" button as default border padding - int padding = toolbutton_info[TOOL_CTRL_ID_YES].pos->x; - if (id == TOOL_CTRL_ID_YES) { - x = padding; - y = request.height - 2 * request.border_size - gfx->height - padding; + x = 0; + y = request.height - 2 * request.border_size - gfx->height; } else if (id == TOOL_CTRL_ID_NO) { - x = request.width - 2 * request.border_size - gfx->width - padding; - y = request.height - 2 * request.border_size - gfx->height - padding; + x = request.width - 2 * request.border_size - gfx->width; + y = request.height - 2 * request.border_size - gfx->height; } else if (id == TOOL_CTRL_ID_CONFIRM) { x = (request.width - 2 * request.border_size - gfx->width) / 2; - y = request.height - 2 * request.border_size - gfx->height - padding; + y = request.height - 2 * request.border_size - gfx->height; } else if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4) { int player_nr = id - TOOL_CTRL_ID_PLAYER_1; x = (request.width - 2 * request.border_size - gfx->width) / 2; - y = request.height - 2 * request.border_size - gfx->height - padding; + y = request.height - 2 * request.border_size - gfx->height * 2; - x += (player_nr % 2 ? +1 : -1) * gfx->width / 2; - y += (player_nr / 2 ? 0 : -1) * gfx->height; + x += (player_nr == 3 ? -1 : player_nr == 1 ? +1 : 0) * gfx->width; + y += (player_nr == 0 ? -1 : player_nr == 2 ? +1 : 0) * gfx->height; } } } @@ -5370,6 +5444,7 @@ void CreateToolButtons() } gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, toolbutton_info[i].infotext, GDI_X, dx + x, GDI_Y, dy + y,