X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=3dd571fe857cb912493d9dc0105a0a559103d2fe;hb=6cf6b75d5b9c84476a121cfd2ff11a0351ecba47;hp=6d23dc804edd6e71a7133f436d212bc7bb277e75;hpb=6e07e52227e71a3c8fd8b6d63f48c68926ba79b6;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 6d23dc80..3dd571fe 100644 --- a/src/screens.c +++ b/src/screens.c @@ -7186,6 +7186,15 @@ boolean ConfigureVirtualButtonsMain() "Snap Field", "Drop Element" }; + char grid_button[] = + { + CHAR_GRID_BUTTON_LEFT, + CHAR_GRID_BUTTON_RIGHT, + CHAR_GRID_BUTTON_UP, + CHAR_GRID_BUTTON_DOWN, + CHAR_GRID_BUTTON_SNAP, + CHAR_GRID_BUTTON_DROP + }; int font_nr = FONT_INPUT_1_ACTIVE; int font_height = getFontHeight(font_nr); int ypos1 = SYSIZE / 2 - font_height * 2; @@ -7193,6 +7202,18 @@ boolean ConfigureVirtualButtonsMain() boolean success = FALSE; boolean finished = FALSE; int step_nr = 0; + char grid_button_draw = CHAR_GRID_BUTTON_NONE; + char grid_button_old[MAX_GRID_XSIZE][MAX_GRID_YSIZE]; + char grid_button_tmp[MAX_GRID_XSIZE][MAX_GRID_YSIZE]; + boolean set_grid_button = FALSE; + int nr = GRID_ACTIVE_NR(); + int x, y; + + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + grid_button_old[x][y] = grid_button_tmp[x][y] = overlay.grid_button[x][y]; + + overlay.grid_button_highlight = grid_button[step_nr]; FadeSetEnterMenu(); FadeOut(REDRAW_FIELD); @@ -7205,11 +7226,13 @@ boolean ConfigureVirtualButtonsMain() FadeIn(REDRAW_FIELD); + SetOverlayShowGrid(TRUE); + while (!finished) { Event event; - if (NextValidEvent(&event)) + while (NextValidEvent(&event)) { switch (event.type) { @@ -7220,6 +7243,10 @@ boolean ConfigureVirtualButtonsMain() /* press 'Escape' to abort and keep the old key bindings */ if (key == KSYM_Escape) { + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + overlay.grid_button[x][y] = grid_button_old[x][y]; + FadeSkipNextFadeIn(); finished = TRUE; @@ -7262,6 +7289,12 @@ boolean ConfigureVirtualButtonsMain() break; } + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + grid_button_tmp[x][y] = overlay.grid_button[x][y]; + + overlay.grid_button_highlight = grid_button[step_nr]; + /* query next virtual button */ ClearField(); @@ -7276,15 +7309,75 @@ boolean ConfigureVirtualButtonsMain() key_joystick_mapping = 0; break; + case EVENT_BUTTONPRESS: + case EVENT_BUTTONRELEASE: + { + ButtonEvent *button = (ButtonEvent *)&event; + + button->x += video.screen_xoffset; + button->y += video.screen_yoffset; + + x = button->x * overlay.grid_xsize / video.screen_width; + y = button->y * overlay.grid_ysize / video.screen_height; + + if (button->type == EVENT_BUTTONPRESS) + { + button_status = button->button; + + grid_button_draw = + (overlay.grid_button[x][y] != grid_button[step_nr] ? + grid_button[step_nr] : CHAR_GRID_BUTTON_NONE); + + set_grid_button = TRUE; + } + else + { + button_status = MB_RELEASED; + } + } + break; + + case EVENT_MOTIONNOTIFY: + { + MotionEvent *motion = (MotionEvent *)&event; + + motion->x += video.screen_xoffset; + motion->y += video.screen_yoffset; + + x = motion->x * overlay.grid_xsize / video.screen_width; + y = motion->y * overlay.grid_ysize / video.screen_height; + + set_grid_button = TRUE; + } + break; + default: HandleOtherEvents(&event); break; } + + if (set_grid_button) + { + overlay.grid_button[x][y] = + (grid_button_draw != CHAR_GRID_BUTTON_NONE ? grid_button_draw : + grid_button_tmp[x][y] == grid_button[step_nr] ? CHAR_GRID_BUTTON_NONE : + grid_button_tmp[x][y]); + + set_grid_button = FALSE; + } } BackToFront(); } + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + overlay.grid_button_all[nr][x][y] = overlay.grid_button[x][y]; + + overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE; + + SetOverlayShowGrid(FALSE); + return success; }