From 93c8731e8f90c740a393896cdbff237068cd49a5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 19 Sep 2019 20:16:31 +0200 Subject: [PATCH] added overlay touch buttons for in-game "stop" and "pause" buttons --- src/conf_gfx.c | 19 +++++++++++++ src/game.c | 77 ++++++++++++++++++++++++++++++++------------------ src/game.h | 3 ++ src/init.c | 2 ++ 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 5bb2817f..1741f8a0 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6172,6 +6172,20 @@ struct ConfigInfo image_config[] = { "gfx.game.button.panel_sound_loops", UNDEFINED_FILENAME }, { "gfx.game.button.panel_sound_simple", UNDEFINED_FILENAME }, + { "gfx.game.button.touch_stop", "RocksTouch.png" }, + { "gfx.game.button.touch_stop.x", "210" }, + { "gfx.game.button.touch_stop.y", "120" }, + { "gfx.game.button.touch_stop.width", "60" }, + { "gfx.game.button.touch_stop.height", "60" }, + { "gfx.game.button.touch_stop.pressed_xoffset", "-200" }, + { "gfx.game.button.touch_pause", "RocksTouch.png" }, + { "gfx.game.button.touch_pause.x", "270" }, + { "gfx.game.button.touch_pause.y", "120" }, + { "gfx.game.button.touch_pause.width", "60" }, + { "gfx.game.button.touch_pause.height", "60" }, + { "gfx.game.button.touch_pause.pressed_xoffset", "-200" }, + { "gfx.game.button.touch_pause.active_yoffset", "60" }, + { "gfx.tape.button.eject", "RocksDoor.png" }, { "gfx.tape.button.eject.x", "305" }, { "gfx.tape.button.eject.y", "357" }, @@ -9137,6 +9151,11 @@ struct ConfigInfo image_config[] = { "game.button.panel_sound_simple.x", "-1" }, { "game.button.panel_sound_simple.y", "-1" }, + { "game.button.touch_stop.x", "0" }, + { "game.button.touch_stop.y", "0" }, + { "game.button.touch_pause.x", "-60" }, + { "game.button.touch_pause.y", "0" }, + { "tape.button.eject.x", "5" }, { "tape.button.eject.y", "77" }, { "tape.button.stop.x", "23" }, diff --git a/src/game.c b/src/game.c index 15cd4122..57771d75 100644 --- a/src/game.c +++ b/src/game.c @@ -1016,14 +1016,16 @@ static struct GamePanelControlInfo game_panel_controls[] = #define GAME_CTRL_ID_PANEL_STOP 8 #define GAME_CTRL_ID_PANEL_PAUSE 9 #define GAME_CTRL_ID_PANEL_PLAY 10 -#define SOUND_CTRL_ID_MUSIC 11 -#define SOUND_CTRL_ID_LOOPS 12 -#define SOUND_CTRL_ID_SIMPLE 13 -#define SOUND_CTRL_ID_PANEL_MUSIC 14 -#define SOUND_CTRL_ID_PANEL_LOOPS 15 -#define SOUND_CTRL_ID_PANEL_SIMPLE 16 +#define GAME_CTRL_ID_TOUCH_STOP 11 +#define GAME_CTRL_ID_TOUCH_PAUSE 12 +#define SOUND_CTRL_ID_MUSIC 13 +#define SOUND_CTRL_ID_LOOPS 14 +#define SOUND_CTRL_ID_SIMPLE 15 +#define SOUND_CTRL_ID_PANEL_MUSIC 16 +#define SOUND_CTRL_ID_PANEL_LOOPS 17 +#define SOUND_CTRL_ID_PANEL_SIMPLE 18 -#define NUM_GAME_BUTTONS 17 +#define NUM_GAME_BUTTONS 19 // forward declaration for internal use @@ -15476,93 +15478,104 @@ static struct int gadget_id; boolean *setup_value; boolean allowed_on_tape; + boolean is_touch_button; char *infotext; } gamebutton_info[NUM_GAME_BUTTONS] = { { IMG_GFX_GAME_BUTTON_STOP, &game.button.stop, GAME_CTRL_ID_STOP, NULL, - TRUE, "stop game" + TRUE, FALSE, "stop game" }, { IMG_GFX_GAME_BUTTON_PAUSE, &game.button.pause, GAME_CTRL_ID_PAUSE, NULL, - TRUE, "pause game" + TRUE, FALSE, "pause game" }, { IMG_GFX_GAME_BUTTON_PLAY, &game.button.play, GAME_CTRL_ID_PLAY, NULL, - TRUE, "play game" + TRUE, FALSE, "play game" }, { IMG_GFX_GAME_BUTTON_UNDO, &game.button.undo, GAME_CTRL_ID_UNDO, NULL, - TRUE, "undo step" + TRUE, FALSE, "undo step" }, { IMG_GFX_GAME_BUTTON_REDO, &game.button.redo, GAME_CTRL_ID_REDO, NULL, - TRUE, "redo step" + TRUE, FALSE, "redo step" }, { IMG_GFX_GAME_BUTTON_SAVE, &game.button.save, GAME_CTRL_ID_SAVE, NULL, - TRUE, "save game" + TRUE, FALSE, "save game" }, { IMG_GFX_GAME_BUTTON_PAUSE2, &game.button.pause2, GAME_CTRL_ID_PAUSE2, NULL, - TRUE, "pause game" + TRUE, FALSE, "pause game" }, { IMG_GFX_GAME_BUTTON_LOAD, &game.button.load, GAME_CTRL_ID_LOAD, NULL, - TRUE, "load game" + TRUE, FALSE, "load game" }, { IMG_GFX_GAME_BUTTON_PANEL_STOP, &game.button.panel_stop, GAME_CTRL_ID_PANEL_STOP, NULL, - FALSE, "stop game" + FALSE, FALSE, "stop game" }, { IMG_GFX_GAME_BUTTON_PANEL_PAUSE, &game.button.panel_pause, GAME_CTRL_ID_PANEL_PAUSE, NULL, - FALSE, "pause game" + FALSE, FALSE, "pause game" }, { IMG_GFX_GAME_BUTTON_PANEL_PLAY, &game.button.panel_play, GAME_CTRL_ID_PANEL_PLAY, NULL, - FALSE, "play game" + FALSE, FALSE, "play game" + }, + { + IMG_GFX_GAME_BUTTON_TOUCH_STOP, &game.button.touch_stop, + GAME_CTRL_ID_TOUCH_STOP, NULL, + FALSE, TRUE, "stop game" + }, + { + IMG_GFX_GAME_BUTTON_TOUCH_PAUSE, &game.button.touch_pause, + GAME_CTRL_ID_TOUCH_PAUSE, NULL, + FALSE, TRUE, "pause game" }, { IMG_GFX_GAME_BUTTON_SOUND_MUSIC, &game.button.sound_music, SOUND_CTRL_ID_MUSIC, &setup.sound_music, - TRUE, "background music on/off" + TRUE, FALSE, "background music on/off" }, { IMG_GFX_GAME_BUTTON_SOUND_LOOPS, &game.button.sound_loops, SOUND_CTRL_ID_LOOPS, &setup.sound_loops, - TRUE, "sound loops on/off" + TRUE, FALSE, "sound loops on/off" }, { IMG_GFX_GAME_BUTTON_SOUND_SIMPLE, &game.button.sound_simple, SOUND_CTRL_ID_SIMPLE, &setup.sound_simple, - TRUE, "normal sounds on/off" + TRUE, FALSE, "normal sounds on/off" }, { IMG_GFX_GAME_BUTTON_PANEL_SOUND_MUSIC, &game.button.panel_sound_music, SOUND_CTRL_ID_PANEL_MUSIC, &setup.sound_music, - FALSE, "background music on/off" + FALSE, FALSE, "background music on/off" }, { IMG_GFX_GAME_BUTTON_PANEL_SOUND_LOOPS, &game.button.panel_sound_loops, SOUND_CTRL_ID_PANEL_LOOPS, &setup.sound_loops, - FALSE, "sound loops on/off" + FALSE, FALSE, "sound loops on/off" }, { IMG_GFX_GAME_BUTTON_PANEL_SOUND_SIMPLE, &game.button.panel_sound_simple, SOUND_CTRL_ID_PANEL_SIMPLE, &setup.sound_simple, - FALSE, "normal sounds on/off" + FALSE, FALSE, "normal sounds on/off" } }; @@ -15579,10 +15592,11 @@ void CreateGameButtons(void) int button_type; boolean checked; unsigned int event_mask; + boolean is_touch_button = gamebutton_info[i].is_touch_button; boolean allowed_on_tape = gamebutton_info[i].allowed_on_tape; boolean on_tape = (tape.show_game_buttons && allowed_on_tape); - int base_x = (on_tape ? VX : DX); - int base_y = (on_tape ? VY : DY); + int base_x = (is_touch_button ? 0 : on_tape ? VX : DX); + int base_y = (is_touch_button ? 0 : on_tape ? VY : DY); int gd_x = gfx->src_x; int gd_y = gfx->src_y; int gd_xp = gfx->src_x + gfx->pressed_xoffset; @@ -15591,6 +15605,8 @@ void CreateGameButtons(void) int gd_ya = gfx->src_y + gfx->active_yoffset; int gd_xap = gfx->src_x + gfx->active_xoffset + gfx->pressed_xoffset; int gd_yap = gfx->src_y + gfx->active_yoffset + gfx->pressed_yoffset; + int x = (is_touch_button ? pos->x : GDI_ACTIVE_POS(pos->x)); + int y = (is_touch_button ? pos->y : GDI_ACTIVE_POS(pos->y)); int id = i; if (gfx->bitmap == NULL) @@ -15602,6 +15618,7 @@ void CreateGameButtons(void) if (id == GAME_CTRL_ID_STOP || id == GAME_CTRL_ID_PANEL_STOP || + id == GAME_CTRL_ID_TOUCH_STOP || id == GAME_CTRL_ID_PLAY || id == GAME_CTRL_ID_PANEL_PLAY || id == GAME_CTRL_ID_SAVE || @@ -15629,8 +15646,8 @@ void CreateGameButtons(void) gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, gamebutton_info[i].infotext, - GDI_X, base_x + GDI_ACTIVE_POS(pos->x), - GDI_Y, base_y + GDI_ACTIVE_POS(pos->y), + GDI_X, base_x + x, + GDI_Y, base_y + y, GDI_WIDTH, gfx->width, GDI_HEIGHT, gfx->height, GDI_TYPE, button_type, @@ -15641,6 +15658,7 @@ void CreateGameButtons(void) GDI_ALT_DESIGN_UNPRESSED, gfx->bitmap, gd_xa, gd_ya, GDI_ALT_DESIGN_PRESSED, gfx->bitmap, gd_xap, gd_yap, GDI_DIRECT_DRAW, FALSE, + GDI_OVERLAY_TOUCH_BUTTON, is_touch_button, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleGameButtons, GDI_END); @@ -15729,6 +15747,7 @@ void ModifyPauseButtons(void) GAME_CTRL_ID_PAUSE, GAME_CTRL_ID_PAUSE2, GAME_CTRL_ID_PANEL_PAUSE, + GAME_CTRL_ID_TOUCH_PAUSE, -1 }; int i; @@ -15874,6 +15893,7 @@ static void HandleGameButtonsExt(int id, int button) { case GAME_CTRL_ID_STOP: case GAME_CTRL_ID_PANEL_STOP: + case GAME_CTRL_ID_TOUCH_STOP: if (game_status == GAME_MODE_MAIN) break; @@ -15887,6 +15907,7 @@ static void HandleGameButtonsExt(int id, int button) case GAME_CTRL_ID_PAUSE: case GAME_CTRL_ID_PAUSE2: case GAME_CTRL_ID_PANEL_PAUSE: + case GAME_CTRL_ID_TOUCH_PAUSE: if (network.enabled && game_status == GAME_MODE_PLAYING) { if (tape.pausing) diff --git a/src/game.h b/src/game.h index 9bfa0cd5..224df856 100644 --- a/src/game.h +++ b/src/game.h @@ -129,6 +129,9 @@ struct GameButtonInfo struct XY panel_sound_music; struct XY panel_sound_loops; struct XY panel_sound_simple; + + struct XY touch_stop; + struct XY touch_pause; }; struct GameSnapshotInfo diff --git a/src/init.c b/src/init.c index 1e77ca47..a820bf62 100644 --- a/src/init.c +++ b/src/init.c @@ -280,6 +280,8 @@ void InitImageTextures(void) IMG_GFX_REQUEST_BUTTON_TOUCH_YES, IMG_GFX_REQUEST_BUTTON_TOUCH_NO, IMG_GFX_REQUEST_BUTTON_TOUCH_CONFIRM, + IMG_GFX_GAME_BUTTON_TOUCH_STOP, + IMG_GFX_GAME_BUTTON_TOUCH_PAUSE, -1 }; int i, j, k; -- 2.34.1