1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Buttonify map screen

This commit is contained in:
NyakoFox 2024-04-11 12:19:37 -03:00
parent 1ba14b037f
commit eef83a01a5
4 changed files with 294 additions and 52 deletions

View file

@ -1,3 +1,5 @@
#include <Input.h>
#include <tinyxml2.h> #include <tinyxml2.h>
#include <vector> #include <vector>
@ -3185,8 +3187,6 @@ void gameinput(void)
} }
} }
static void mapmenuactionpress(bool version2_2);
void mapinput(void) void mapinput(void)
{ {
const bool version2_2 = GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2); const bool version2_2 = GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2);
@ -3306,8 +3306,8 @@ void mapinput(void)
|| (game.menupage >= 20 && game.menupage <= 21) || (game.menupage >= 20 && game.menupage <= 21)
|| (game.menupage >= 30 && game.menupage <= 32)) || (game.menupage >= 30 && game.menupage <= 32))
{ {
if (key.isDown(KEYBOARD_ENTER) || key.isDown(game.controllerButton_map)) game.press_map = true; if (key.isDown(KEYBOARD_ENTER) || key.isDown(game.controllerButton_map) || touch::button_tapped(TOUCH_BUTTON_MAP_BACK)) game.press_map = true;
if ((key.isDown(27) || touch::button_tapped(TOUCH_BUTTON_CANCEL)) && !game.mapheld) if (key.isDown(27) && !game.mapheld)
{ {
touch::remove_dynamic_buttons(); touch::remove_dynamic_buttons();
game.mapheld = true; game.mapheld = true;
@ -3400,7 +3400,7 @@ void mapinput(void)
} }
} }
static void mapmenuactionpress(const bool version2_2) void mapmenuactionpress(const bool version2_2)
{ {
switch (game.menupage) switch (game.menupage)
{ {
@ -3563,7 +3563,13 @@ void teleporterinput(void)
if (!game.press_action && !game.press_left && !game.press_right && !game.press_interact) game.jumpheld = false; if (!game.press_action && !game.press_left && !game.press_right && !game.press_interact) game.jumpheld = false;
if (!game.press_map) game.mapheld = false; if (!game.press_map) game.mapheld = false;
if (key.isDown(27) || touch::button_tapped(TOUCH_BUTTON_CANCEL)) if (touch::button_tapped(TOUCH_BUTTON_MAP_BACK))
{
// Close teleporter menu
graphics.resumegamemode = true;
music.playef(Sound_VIRIDIAN);
}
else if (key.isDown(27))
{ {
if (!map.custommode || map.custommodeforreal) if (!map.custommode || map.custommodeforreal)
{ {

View file

@ -2,6 +2,7 @@
#define INPUT_H #define INPUT_H
void menuactionpress(void); void menuactionpress(void);
void mapmenuactionpress(const bool version2_2);
void titleinput(void); void titleinput(void);

View file

@ -3223,6 +3223,8 @@ void maprender(void)
} }
} }
else if (obj.flags[67] && !map.custommode) else if (obj.flags[67] && !map.custommode)
{
if (!key.using_touch)
{ {
char buffer[SCREEN_WIDTH_CHARS + 1]; char buffer[SCREEN_WIDTH_CHARS + 1];
vformat_buf( vformat_buf(
@ -3233,6 +3235,7 @@ void maprender(void)
); );
font::print_wrap(PR_CEN, -1, 105, buffer, 196, 196, 255 - help.glow); font::print_wrap(PR_CEN, -1, 105, buffer, 196, 196, 255 - help.glow);
} }
}
else if(map.custommode){ else if(map.custommode){
LevelMetaData& meta = cl.ListOfMetaData[game.playcustomlevel]; LevelMetaData& meta = cl.ListOfMetaData[game.playcustomlevel];
@ -3380,7 +3383,7 @@ void maprender(void)
/* We are not in a special case, so draw the save screen now... */ /* We are not in a special case, so draw the save screen now... */
if (!map.custommode) if (!map.custommode && ((!game.gamesaved && key.using_touch) || !key.using_touch))
{ {
/* FIXME: The text here should be automatically "balance-wrapped" instead of hardcoding the width. /* FIXME: The text here should be automatically "balance-wrapped" instead of hardcoding the width.
* In fact, maybe print_wrap should balance-wrap by default. */ * In fact, maybe print_wrap should balance-wrap by default. */
@ -3390,6 +3393,8 @@ void maprender(void)
if (!game.gamesaved) if (!game.gamesaved)
{ {
char buffer[SCREEN_WIDTH_CHARS + 1]; char buffer[SCREEN_WIDTH_CHARS + 1];
if (!key.using_touch)
{
vformat_buf( vformat_buf(
buffer, sizeof(buffer), buffer, sizeof(buffer),
loc::gettext("[Press {button} to save your game]"), loc::gettext("[Press {button} to save your game]"),
@ -3398,13 +3403,14 @@ void maprender(void)
); );
font::print(PR_CEN, -1, 80, buffer, 255 - help.glow * 2, 255 - help.glow * 2, 255 - help.glow); font::print(PR_CEN, -1, 80, buffer, 255 - help.glow * 2, 255 - help.glow * 2, 255 - help.glow);
}
if (map.custommode || !game.last_quicksave.exists) if (map.custommode || !game.last_quicksave.exists)
{ {
break; break;
} }
font::print(PR_CEN, -1, FLIP(100, 8), loc::gettext("Last Save:"), 164 - help.glow/4, 164 - help.glow/4, 164); font::print(PR_CEN, -1, FLIP((key.using_touch ? 40 : 100), 8), loc::gettext("Last Save:"), 164 - help.glow / 4, 164 - help.glow / 4, 164);
struct Game::Summary* last = &game.last_quicksave; struct Game::Summary* last = &game.last_quicksave;
vformat_buf( vformat_buf(
@ -3415,7 +3421,7 @@ void maprender(void)
game.giventimestring(last->hours, last->minutes, last->seconds).c_str() game.giventimestring(last->hours, last->minutes, last->seconds).c_str()
); );
font::print(PR_CEN, -1, FLIP(112, 8), buffer, 164 - help.glow/4, 164 - help.glow/4, 164); font::print(PR_CEN, -1, FLIP((key.using_touch ? 52 : 112), 8), buffer, 164 - help.glow/4, 164 - help.glow/4, 164);
break; break;
} }
@ -3480,9 +3486,12 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
} }
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80 - selection_offset, 88, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 - selection_offset, 88, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 76, loc::gettext("yes, quit to menu"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80 + 32, 76, loc::gettext("yes, quit to menu"), 96, 96, 96);
} }
}
else else
{ {
@ -3495,8 +3504,11 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
} }
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80 - selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 - selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, quit to menu"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, quit to menu"), 96, 96, 96);
}
} }
break; break;
@ -3514,9 +3526,12 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
} }
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80, 88, loc::gettext("no, keep playing"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80, 88, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 76, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 76, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
} }
}
else else
{ {
if (game.inspecial()) if (game.inspecial())
@ -3528,9 +3543,12 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
} }
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 142, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 142, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
} }
}
break; break;
case 20: case 20:
font::print(PR_CEN | PR_CJK_LOW, -1, 220, loc::gettext("[ GRAVITRON ]"), 196, 196, 255 - help.glow); font::print(PR_CEN | PR_CJK_LOW, -1, 220, loc::gettext("[ GRAVITRON ]"), 196, 196, 255 - help.glow);
@ -3538,15 +3556,21 @@ void maprender(void)
if (graphics.flipmode) if (graphics.flipmode)
{ {
font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80 - selection_offset, 142, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 - selection_offset, 142, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 130, loc::gettext("yes, return"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80 + 32, 130, loc::gettext("yes, return"), 96, 96, 96);
} }
}
else else
{ {
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80 - selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 - selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, return"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, return"), 96, 96, 96);
} }
}
break; break;
case 21: case 21:
@ -3555,18 +3579,26 @@ void maprender(void)
if (graphics.flipmode) if (graphics.flipmode)
{ {
font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80, 142, loc::gettext("no, keep playing"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80, 142, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 130, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 130, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
} }
}
else else
{ {
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12); font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
if (!key.using_touch)
{
font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96); font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 142, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow); font::print(PR_RTL_XFLIP, 80 + 32 - selection_offset, 142, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
} }
}
} }
touch::render_buttons();
graphics.set_render_target(graphics.gameTexture); graphics.set_render_target(graphics.gameTexture);
if (graphics.resumegamemode || graphics.menuoffset > 0 || graphics.oldmenuoffset > 0) if (graphics.resumegamemode || graphics.menuoffset > 0 || graphics.oldmenuoffset > 0)

View file

@ -90,6 +90,8 @@ namespace touch
buttons[i].type = TOUCH_BUTTON_TYPE_NONE; buttons[i].type = TOUCH_BUTTON_TYPE_NONE;
buttons[i].id = -1; buttons[i].id = -1;
buttons[i].disabled = false; buttons[i].disabled = false;
buttons[i].checked = false;
buttons[i].flags = 0;
} }
refresh_all_buttons(); refresh_all_buttons();
@ -198,6 +200,52 @@ namespace touch
game.currentmenuoption = button->id; game.currentmenuoption = button->id;
menuactionpress(); menuactionpress();
break; break;
case TOUCH_BUTTON_TYPE_MAP:
switch (button->id)
{
case 0:
case 1:
case 2:
case 3:
game.menupage = button->id;
music.playef(Sound_VIRIDIAN);
break;
case 4:
game.menupage = 1;
mapmenuactionpress(version2_2);
break;
case 5:
game.menupage = 3;
mapmenuactionpress(version2_2);
break;
case 6:
game.menupage = 3;
mapmenuactionpress(version2_2);
graphics.fademode = FADE_START_FADEOUT;
music.fadeout();
map.nexttowercolour();
if (!version2_2)
{
game.fadetomenu = true;
game.fadetomenudelay = 19;
}
break;
case 7:
music.playef(Sound_VIRIDIAN);
game.menupage = 10;
break;
case 8:
music.playef(Sound_VIRIDIAN);
game.menupage = 3;
break;
case 9:
game.menupage = 11;
mapmenuactionpress(version2_2);
break;
}
break;
case TOUCH_BUTTON_TYPE_NONE: case TOUCH_BUTTON_TYPE_NONE:
case TOUCH_BUTTON_TYPE_MENU_SLIDER: case TOUCH_BUTTON_TYPE_MENU_SLIDER:
default: default:
@ -206,6 +254,114 @@ namespace touch
refresh_buttons(); refresh_buttons();
} }
static void setup_map_buttons(void)
{
buttons[TOUCH_BUTTON_MAP_MAP].x = 16;
buttons[TOUCH_BUTTON_MAP_MAP].y = 211;
buttons[TOUCH_BUTTON_MAP_MAP].width = 56;
buttons[TOUCH_BUTTON_MAP_MAP].height = 26;
buttons[TOUCH_BUTTON_MAP_MAP].text = loc::gettext("MAP");
buttons[TOUCH_BUTTON_MAP_MAP].id = 0;
buttons[TOUCH_BUTTON_MAP_MAP].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_MAP].ui = false;
const char* tab_name;
if (game.insecretlab)
{
tab_name = loc::gettext("GRAV");
}
else if (obj.flags[67] && !map.custommode)
{
tab_name = loc::gettext("SHIP");
}
else
{
tab_name = loc::gettext("CREW");
}
buttons[TOUCH_BUTTON_MAP_CREW].x = 92;
buttons[TOUCH_BUTTON_MAP_CREW].y = 211;
buttons[TOUCH_BUTTON_MAP_CREW].width = 56;
buttons[TOUCH_BUTTON_MAP_CREW].height = 26;
buttons[TOUCH_BUTTON_MAP_CREW].text = tab_name;
buttons[TOUCH_BUTTON_MAP_CREW].id = 1;
buttons[TOUCH_BUTTON_MAP_CREW].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_CREW].ui = false;
buttons[TOUCH_BUTTON_MAP_STATS].x = 168;
buttons[TOUCH_BUTTON_MAP_STATS].y = 211;
buttons[TOUCH_BUTTON_MAP_STATS].width = 56;
buttons[TOUCH_BUTTON_MAP_STATS].height = 26;
buttons[TOUCH_BUTTON_MAP_STATS].text = loc::gettext("STATS");
buttons[TOUCH_BUTTON_MAP_STATS].id = 2;
buttons[TOUCH_BUTTON_MAP_STATS].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_STATS].ui = false;
buttons[TOUCH_BUTTON_MAP_QUIT].x = 244;
buttons[TOUCH_BUTTON_MAP_QUIT].y = 211;
buttons[TOUCH_BUTTON_MAP_QUIT].width = 56;
buttons[TOUCH_BUTTON_MAP_QUIT].height = 26;
buttons[TOUCH_BUTTON_MAP_QUIT].text = loc::gettext("QUIT");
buttons[TOUCH_BUTTON_MAP_QUIT].id = 3;
buttons[TOUCH_BUTTON_MAP_QUIT].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_QUIT].ui = false;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].x = 80;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].y = 120 - 16;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].width = 160;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].height = 30;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].text = loc::gettext("warp to ship");
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].id = 4;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].ui = false;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].x = 80;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].y = 96 + 8 - 16 - 16;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].width = 160;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].height = 26;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].text = loc::gettext("save");
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].id = 5;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].ui = false;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].x = 80;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].y = 96 + 32 + 8 - 16 - 16;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].width = 160;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].height = 26;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].text = loc::gettext("save and quit");
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].id = 6;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].ui = false;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].x = 80;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].y = 96 + 64 + 8 - 16 - 16;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].width = 160;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].height = 26;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].text = loc::gettext("quit");
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].id = 7;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].ui = false;
buttons[TOUCH_BUTTON_QUIT_NO].x = 80;
buttons[TOUCH_BUTTON_QUIT_NO].y = 96 + 16;
buttons[TOUCH_BUTTON_QUIT_NO].width = 160;
buttons[TOUCH_BUTTON_QUIT_NO].height = 26;
buttons[TOUCH_BUTTON_QUIT_NO].text = loc::gettext("no, keep playing");
buttons[TOUCH_BUTTON_QUIT_NO].id = 8;
buttons[TOUCH_BUTTON_QUIT_NO].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_QUIT_NO].ui = false;
buttons[TOUCH_BUTTON_QUIT_YES].x = 80;
buttons[TOUCH_BUTTON_QUIT_YES].y = 96 + 32 + 16;
buttons[TOUCH_BUTTON_QUIT_YES].width = 160;
buttons[TOUCH_BUTTON_QUIT_YES].height = 26;
buttons[TOUCH_BUTTON_QUIT_YES].text = loc::gettext("yes, quit to menu");
buttons[TOUCH_BUTTON_QUIT_YES].id = 9;
buttons[TOUCH_BUTTON_QUIT_YES].type = TOUCH_BUTTON_TYPE_MAP;
buttons[TOUCH_BUTTON_QUIT_YES].ui = false;
}
void refresh_buttons(void) void refresh_buttons(void)
{ {
int width; int width;
@ -244,6 +400,14 @@ namespace touch
buttons[TOUCH_BUTTON_CONFIRM].height = 40 * scale; buttons[TOUCH_BUTTON_CONFIRM].height = 40 * scale;
buttons[TOUCH_BUTTON_CONFIRM].image = graphics.grphx.im_button_right; buttons[TOUCH_BUTTON_CONFIRM].image = graphics.grphx.im_button_right;
buttons[TOUCH_BUTTON_MAP_BACK].x = width - ((double)(240 - (int) graphics.lerp(graphics.oldmenuoffset, graphics.menuoffset)) / 240.0) * (60 * scale);
buttons[TOUCH_BUTTON_MAP_BACK].y = 0;
buttons[TOUCH_BUTTON_MAP_BACK].width = 60 * scale;
buttons[TOUCH_BUTTON_MAP_BACK].height = 26 * scale;
buttons[TOUCH_BUTTON_MAP_BACK].text = loc::gettext("BACK");
setup_map_buttons();
// First, reset all buttons // First, reset all buttons
for (int i = 0; i < NUM_TOUCH_BUTTONS; i++) for (int i = 0; i < NUM_TOUCH_BUTTONS; i++)
{ {
@ -276,15 +440,60 @@ namespace touch
{ {
buttons[TOUCH_BUTTON_LEFT].active = true; buttons[TOUCH_BUTTON_LEFT].active = true;
buttons[TOUCH_BUTTON_RIGHT].active = true; buttons[TOUCH_BUTTON_RIGHT].active = true;
buttons[TOUCH_BUTTON_CANCEL].active = true;
buttons[TOUCH_BUTTON_CONFIRM].active = true; buttons[TOUCH_BUTTON_CONFIRM].active = true;
buttons[TOUCH_BUTTON_MAP_BACK].active = true;
} }
break; break;
case MAPMODE: case MAPMODE:
buttons[TOUCH_BUTTON_MAP_BACK].active = true;
if (game.menupage >= 0 && game.menupage < 4)
{
buttons[TOUCH_BUTTON_MAP_MAP].active = true;
buttons[TOUCH_BUTTON_MAP_CREW].active = true;
buttons[TOUCH_BUTTON_MAP_STATS].active = true;
buttons[TOUCH_BUTTON_MAP_QUIT].active = true;
}
if (graphics.menuoffset > 0)
{
buttons[TOUCH_BUTTON_MAP_BACK].down = true;
}
switch (game.menupage)
{
case 0:
case 2:
break;
case 1:
if (obj.flags[67] && !map.custommode)
{
buttons[TOUCH_BUTTON_MAP_SHIP_WARP].active = true;
}
break;
case 3:
if (!game.gamesaved && !game.gamesavefailed && !game.inspecial())
{
buttons[TOUCH_BUTTON_MAP_QUIT_SAVE].active = true;
buttons[TOUCH_BUTTON_MAP_QUIT_SAVEEXIT].active = true;
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].y = 96 + 64 + 8 - 16 - 16;
}
else
{
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].y = 96 + 32 + 8 - 16 + 48;
}
buttons[TOUCH_BUTTON_MAP_QUIT_EXIT].active = true;
break;
case 10:
case 11:
buttons[TOUCH_BUTTON_QUIT_NO].active = true;
buttons[TOUCH_BUTTON_QUIT_YES].active = true;
break;
default:
buttons[TOUCH_BUTTON_LEFT].active = true; buttons[TOUCH_BUTTON_LEFT].active = true;
buttons[TOUCH_BUTTON_RIGHT].active = true; buttons[TOUCH_BUTTON_RIGHT].active = true;
buttons[TOUCH_BUTTON_CANCEL].active = true; break;
buttons[TOUCH_BUTTON_CONFIRM].active = true; }
break; break;
case GAMECOMPLETE: case GAMECOMPLETE:
case GAMECOMPLETE2: case GAMECOMPLETE2:
@ -414,7 +623,7 @@ namespace touch
} }
else else
{ {
font::print(PR_CEN | PR_CJK_LOW | font_scale | button->flags, button->x + (button->width / 2) + offset * scale, button->y + ((button->height - height) / 2 + offset) * scale, button->text, 196, 196, 255 - help.glow); font::print(PR_CEN | PR_CJK_LOW | font_scale | button->flags, button->x + (button->width / 2) + offset * scale, button->y + ((button->height - height) / 2 + offset * scale), button->text, 196, 196, 255 - help.glow);
} }
break; break;
} }
@ -460,12 +669,6 @@ namespace touch
void reset(void) void reset(void)
{ {
for (int i = 0; i < NUM_TOUCH_BUTTONS; i++)
{
buttons[i].down = false;
buttons[i].fingerId = -1;
}
for (int i = 0; i < fingers.size(); i++) for (int i = 0; i < fingers.size(); i++)
{ {
fingers[i].pressed = false; fingers[i].pressed = false;