From: Holger Schemel Date: Sat, 12 May 2018 00:21:18 +0000 (+0200) Subject: added updating virtual buttons setup screen depending on screen orientation X-Git-Tag: 4.1.1.0~158 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=6dd55346a5d7a35592294313893c14e0641e15ae;p=rocksndiamonds.git added updating virtual buttons setup screen depending on screen orientation --- diff --git a/src/events.c b/src/events.c index 21209318..9aad2bca 100644 --- a/src/events.c +++ b/src/events.c @@ -649,12 +649,7 @@ void HandleWindowEvent(WindowEvent *event) int x, y; if (game_status == GAME_MODE_SETUP) - { - // save active virtual buttons (in case of just configuring them) - 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]; - } + RedrawSetupScreenAfterScreenRotation(nr); nr = GRID_ACTIVE_NR(); diff --git a/src/screens.c b/src/screens.c index 88c92a13..6f6e7a13 100644 --- a/src/screens.c +++ b/src/screens.c @@ -82,8 +82,9 @@ #define SETUP_MODE_CHOOSE_GRID_YSIZE_0 33 #define SETUP_MODE_CHOOSE_GRID_XSIZE_1 34 #define SETUP_MODE_CHOOSE_GRID_YSIZE_1 35 +#define SETUP_MODE_CONFIG_VIRT_BUTTONS 36 -#define MAX_SETUP_MODES 36 +#define MAX_SETUP_MODES 37 #define MAX_MENU_MODES MAX(MAX_INFO_MODES, MAX_SETUP_MODES) @@ -5389,8 +5390,12 @@ static void execSetupChooseGridYSize_1() static void execSetupConfigureVirtualButtons() { + setup_mode = SETUP_MODE_CONFIG_VIRT_BUTTONS; + ConfigureVirtualButtons(); + setup_mode = SETUP_MODE_TOUCH; + DrawSetupScreen(); } @@ -6012,7 +6017,7 @@ static struct TokenInfo setup_info_touch[] = { 0, NULL, NULL } }; -static struct TokenInfo setup_info_touch_virtual_buttons[] = +static struct TokenInfo setup_info_touch_virtual_buttons_0[] = { { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" }, { TYPE_STRING, &touch_controls_text, "" }, @@ -6031,6 +6036,31 @@ static struct TokenInfo setup_info_touch_virtual_buttons[] = { 0, NULL, NULL } }; +static struct TokenInfo setup_info_touch_virtual_buttons_1[] = +{ + { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" }, + { TYPE_STRING, &touch_controls_text, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_ENTER_LIST, execSetupChooseGridXSize_1, "Horizontal Buttons (Portrait):" }, + { TYPE_STRING, &grid_size_text[1][0], "" }, + { TYPE_ENTER_LIST, execSetupChooseGridYSize_1, "Vertical Buttons (Portrait):" }, + { TYPE_STRING, &grid_size_text[1][1], "" }, + { TYPE_ENTER_LIST, execSetupChooseTransparency, "Transparency:" }, + { TYPE_STRING, &transparency_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_virtual_buttons[] = +{ + setup_info_touch_virtual_buttons_0, + setup_info_touch_virtual_buttons_1 +}; + static struct TokenInfo setup_info_touch_wipe_gestures[] = { { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" }, @@ -6465,7 +6495,7 @@ static void DrawSetupScreen_Generic() title_string = STR_SETUP_TOUCH; if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) - setup_info = setup_info_touch_virtual_buttons; + setup_info = setup_info_touch_virtual_buttons[GRID_ACTIVE_NR()]; else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES)) setup_info = setup_info_touch_wipe_gestures; } @@ -7763,6 +7793,24 @@ void RedrawSetupScreenAfterFullscreenToggle() } } +void RedrawSetupScreenAfterScreenRotation(int nr) +{ + int x, y; + + if (setup_mode == SETUP_MODE_TOUCH) + { + // update virtual button settings (depending on screen orientation) + DrawSetupScreen(); + } + else if (setup_mode == SETUP_MODE_CONFIG_VIRT_BUTTONS) + { + // save already configured virtual buttons + 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]; + } +} + void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { if (setup_mode == SETUP_MODE_INPUT) diff --git a/src/screens.h b/src/screens.h index 7af2a008..418c41f4 100644 --- a/src/screens.h +++ b/src/screens.h @@ -25,6 +25,7 @@ void DrawMainMenu(void); void DrawHallOfFame(int); void RedrawSetupScreenAfterFullscreenToggle(); +void RedrawSetupScreenAfterScreenRotation(int); void HandleTitleScreen(int, int, int, int, int); void HandleMainMenu(int, int, int, int, int);