static void HandleSetupScreen_Input(int, int, int, int, int);
static void CustomizeKeyboard(int);
static void ConfigureJoystick(int);
+static void ConfigureVirtualButtons();
static void execSetupGame(void);
static void execSetupGraphics(void);
static void execSetupSound(void);
DrawSetupScreen();
}
+static void execSetupConfigureVirtualButtons()
+{
+ ConfigureVirtualButtons();
+
+ DrawSetupScreen();
+}
+
static void execSetupTouch()
{
if (touch_controls == NULL)
{ 0, NULL, NULL }
};
+static struct TokenInfo setup_info_touch_virtual_buttons[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
static struct TokenInfo setup_info_touch_wipe_gestures[] =
{
{ TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
setup_info = setup_info_touch;
title_string = STR_SETUP_TOUCH;
- if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
+ if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
+ setup_info = setup_info_touch_virtual_buttons;
+ else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
setup_info = setup_info_touch_wipe_gestures;
}
else if (setup_mode == SETUP_MODE_SHORTCUTS)
controller->width, controller->height,
controller_x, controller_y);
+ SDL_SetSurfaceBlendMode(marker->surface_masked, SDL_BLENDMODE_BLEND);
SDL_SetSurfaceAlphaMod(marker->surface_masked, alpha);
BlitBitmapMasked(marker, drawto, 0, 0,
DrawSetupScreen_Input();
}
+boolean ConfigureVirtualButtonsMain()
+{
+ static char *customize_step_text[] =
+ {
+ "Move Left",
+ "Move Right",
+ "Move Up",
+ "Move Down",
+ "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;
+ int ypos2 = SYSIZE / 2 - font_height * 1;
+ 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);
+
+ ClearField();
+
+ DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Virtual Buttons");
+ DrawTextSCentered(ypos1, font_nr, "Select tiles to");
+ DrawTextSCentered(ypos2, font_nr, customize_step_text[step_nr]);
+
+ FadeIn(REDRAW_FIELD);
+
+ SetOverlayShowGrid(TRUE);
+
+ while (!finished)
+ {
+ Event event;
+
+ while (NextValidEvent(&event))
+ {
+ switch (event.type)
+ {
+ case EVENT_KEYPRESS:
+ {
+ Key key = GetEventKey((KeyEvent *)&event, FALSE);
+
+ /* 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;
+
+ break;
+ }
+
+ /* press 'Enter' to keep the existing key binding */
+ if (key == KSYM_Return ||
+ key == KSYM_Menu ||
+ key == KSYM_space)
+ {
+ step_nr++;
+ }
+ else if (key == KSYM_BackSpace ||
+ key == KSYM_Back)
+ {
+ if (step_nr == 0)
+ {
+ FadeSkipNextFadeIn();
+
+ finished = TRUE;
+
+ break;
+ }
+
+ step_nr--;
+ }
+ else
+ {
+ break;
+ }
+
+ /* all virtual buttons configured */
+ if (step_nr == 6)
+ {
+ finished = TRUE;
+ success = TRUE;
+
+ 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();
+
+ DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Virtual Buttons");
+ DrawTextSCentered(ypos1, font_nr, "Select tiles to");
+ DrawTextSCentered(ypos2, font_nr, customize_step_text[step_nr]);
+ }
+ break;
+
+ case EVENT_KEYRELEASE:
+ 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;
+
+#if defined(TARGET_SDL2)
+ case SDL_WINDOWEVENT:
+ HandleWindowEvent((WindowEvent *) &event);
+
+ // check if device has been rotated
+ if (nr != GRID_ACTIVE_NR())
+ {
+ nr = GRID_ACTIVE_NR();
+
+ 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];
+ }
+
+ break;
+
+ case SDL_APP_WILLENTERBACKGROUND:
+ case SDL_APP_DIDENTERBACKGROUND:
+ case SDL_APP_WILLENTERFOREGROUND:
+ case SDL_APP_DIDENTERFOREGROUND:
+ HandlePauseResumeEvent((PauseResumeEvent *) &event);
+ break;
+#endif
+
+ 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++)
+ setup.touch.grid_button[nr][x][y] = overlay.grid_button[x][y];
+
+ overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;
+
+ SetOverlayShowGrid(FALSE);
+
+ return success;
+}
+
+void ConfigureVirtualButtons()
+{
+ boolean success = ConfigureVirtualButtonsMain();
+
+ if (success)
+ {
+ int font_nr = FONT_TITLE_1;
+ int font_height = getFontHeight(font_nr);
+ int ypos1 = SYSIZE / 2 - font_height * 2;
+ int ypos2 = SYSIZE / 2 - font_height * 1;
+ unsigned int wait_frame_delay = 0;
+ unsigned int wait_frame_delay_value = 2000;
+
+ ResetDelayCounter(&wait_frame_delay);
+
+ ClearField();
+
+ DrawTextSCentered(ypos1, font_nr, "Virtual buttons");
+ DrawTextSCentered(ypos2, font_nr, "configured!");
+
+ while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
+ BackToFront();
+
+ ClearEventQueue();
+ }
+}
+
void DrawSetupScreen()
{
if (setup_mode == SETUP_MODE_INPUT)