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

Modify a few menus

This commit is contained in:
NyakoFox 2024-04-09 12:56:38 -03:00
parent eea8741689
commit 59a97d2404
6 changed files with 272 additions and 135 deletions

View file

@ -2652,9 +2652,16 @@ void editorclass::tool_place()
}
static void creategameoptions(void)
{
if (key.using_touch)
{
game.createmenu(Menu::gameplayoptions);
}
else
{
game.createmenu(Menu::options);
}
}
static void nextbgcolor(void)
{

View file

@ -6608,6 +6608,8 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
int maxspacing = 30; // maximum value for menuspacing, can only become lower.
bool auto_buttons = true;
bool auto_center = true;
int button_height = 26;
int button_spacing = 6;
menucountdown = 0;
menuoptions.clear();
touch::remove_dynamic_buttons();
@ -6799,11 +6801,14 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
menuyoff = -20;
break;
case Menu::gameplayoptions:
{
#if !defined(MAKEANDPLAY)
int offset = 0;
if (ingame_titlemode && unlock[Unlock_FLIPMODE])
#endif
{
option(loc::gettext("flip mode"));
offset++;
}
option(loc::gettext("toggle fps"));
option(loc::gettext("speedrun options"));
@ -6813,18 +6818,29 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option(loc::gettext("return"));
menuyoff = -10;
maxspacing = 15;
auto_buttons = false;
buttonscentered = true;
touch::create_toggle_button((320 - 160) / 2, 120 - 32, 160, 12, loc::gettext("limit to 30 fps"), offset, !over30mode);
touch::create_toggle_button((320 - 160) / 2, 120 - 32 + 16, 160, 12, loc::gettext("translucent room name bg"), offset, graphics.translucentroomname);
touch::create_menu_button(46 - 16, 200, 76, 26, loc::gettext("previous"), -2);
touch::create_menu_button(122, 200, 76, 26, loc::gettext("return"), offset + 5);
touch::create_menu_button(198 + 16, 200, 76, 26, loc::gettext("next"), -1);
break;
}
case Menu::graphicoptions:
{
int optionid = 4;
if (!gameScreen.isForcedFullscreen())
{
option(loc::gettext("toggle fullscreen"));
optionid++;
}
option(loc::gettext("scaling mode"));
if (!gameScreen.isForcedFullscreen())
{
option(loc::gettext("resize to nearest"), gameScreen.isWindowed);
optionid++;
}
option(loc::gettext("toggle filter"));
option(loc::gettext("toggle analogue"));
@ -6832,9 +6848,18 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option(loc::gettext("return"));
menuyoff = -10;
maxspacing = 15;
auto_buttons = false;
buttonscentered = true;
touch::create_menu_button((320 - 160) / 2, 120 - 32, 160, button_height, loc::gettext("scaling mode"), 1);
touch::create_toggle_button((320 - 160) / 2, 120 + 16, 160, 12, loc::gettext("filtered screen"), 3, gameScreen.isFiltered);
touch::create_toggle_button((320 - 160) / 2, 120 + 32, 160, 12, loc::gettext("analogue mode"), 4, gameScreen.badSignalEffect);
touch::create_toggle_button((320 - 160) / 2, 120 + 48, 160, 12, loc::gettext("vsync"), 5, gameScreen.vsync);
touch::create_menu_button(46 - 16, 200, 76, 26, loc::gettext("previous"), -2);
touch::create_menu_button(122, 200, 76, 26, loc::gettext("return"), optionid);
touch::create_menu_button(198 + 16, 200, 76, 26, loc::gettext("next"), -1);
break;
}
case Menu::ed_settings:
option(loc::gettext("change description"));
option(loc::gettext("edit scripts"));
@ -7484,7 +7509,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
}
}
base_y = (240 - count * 32) / 2;
base_y = (240 - count * (button_height + button_spacing)) / 2;
}
int offset = 0;
@ -7494,9 +7519,9 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
{
touch::create_menu_button(
(320 - 160) / 2,
base_y + offset * 32,
base_y + offset * (button_height + button_spacing),
160,
26,
button_height,
menuoptions[i].text,
i,
menuoptions[i].active
@ -7505,6 +7530,8 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
}
}
}
touch::on_menu_create();
}
bool Game::can_unlock_ndm(void)

View file

@ -454,7 +454,14 @@ void menuactionpress(void)
case 2:
//Options
music.playef(Sound_VIRIDIAN);
if (key.using_touch)
{
game.createmenu(Menu::gameplayoptions);
}
else
{
game.createmenu(Menu::options);
}
map.nexttowercolour();
break;
case 3:
@ -708,6 +715,22 @@ void menuactionpress(void)
gameScreen.toggleVSync();
game.savestatsandsettings_menu();
}
if (game.currentmenuoption == -2)
{
// gameplay menu
music.playef(Sound_VIRIDIAN);
game.createmenu(Menu::gameplayoptions, true);
map.nexttowercolour();
processed = true;
}
if (game.currentmenuoption == -1)
{
// audio menu
music.playef(Sound_VIRIDIAN);
game.createmenu(Menu::audiooptions, true);
map.nexttowercolour();
processed = true;
}
if (!processed)
{
//back
@ -1032,6 +1055,21 @@ void menuactionpress(void)
map.nexttowercolour();
}
if (game.currentmenuoption == -2)
{
// language menu
music.playef(Sound_VIRIDIAN);
game.createmenu(Menu::language, true);
map.nexttowercolour();
}
if (game.currentmenuoption == -1)
{
// graphics menu
music.playef(Sound_VIRIDIAN);
game.createmenu(Menu::graphicoptions, true);
map.nexttowercolour();
}
break;
}
case Menu::options:
@ -3370,7 +3408,14 @@ static void mapmenuactionpress(const bool version2_2)
// Set this before we create the menu
game.kludge_ingametemp = game.currentmenuname;
if (key.using_touch)
{
game.createmenu(Menu::gameplayoptions);
}
else
{
game.createmenu(Menu::options);
}
map.nexttowercolour();
break;
case 32:

View file

@ -302,6 +302,13 @@ static void menurender(void)
font::print_wrap(PR_CEN, -1, 65, loc::gettext("ERROR: This level has no start point!"), tr, tg, tb);
break;
case Menu::gameplayoptions:
{
if (key.using_touch)
{
font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Gameplay Options"), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, loc::gettext("Adjust various gameplay settings."), tr, tg, tb);
}
else
{
int gameplayoptionsoffset = 0;
#if !defined(MAKEANDPLAY)
@ -362,6 +369,7 @@ static void menurender(void)
font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Clear Data"), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, loc::gettext("Delete your custom level save data and completion stars."), tr, tg, tb);
}
}
break;
}
@ -405,6 +413,13 @@ static void menurender(void)
}
break;
case Menu::graphicoptions:
{
if (key.using_touch)
{
font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Graphics Options"), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, loc::gettext("Adjust screen settings."), tr, tg, tb);
}
else
{
int offset = 0;
if (game.currentmenuoption == offset + 0 && !gameScreen.isForcedFullscreen())
@ -493,6 +508,7 @@ static void menurender(void)
font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Current mode: VSYNC ON"), tr, tg, tb);
}
}
}
break;
}
case Menu::audiooptions:

View file

@ -33,6 +33,7 @@ namespace touch
bool use_buttons;
int scale;
bool textbox_style;
bool scroll;
void refresh_all_buttons(void)
{
@ -52,7 +53,7 @@ namespace touch
int get_rect(TouchButton* button, SDL_Rect* rect)
{
rect->x = button->x;
rect->y = button->y;
rect->y = button->y - scroll;
rect->w = button->width;
rect->h = button->height;
@ -124,6 +125,7 @@ namespace touch
button.type = TOUCH_BUTTON_TYPE_NONE;
button.id = -1;
button.disabled = false;
button.checked = false;
return button;
}
@ -148,6 +150,16 @@ namespace touch
register_button(button);
}
void create_toggle_button(int x, int y, int width, int height, std::string text, int id, bool checked)
{
TouchButton button = create_button(x, y, width, height, text);
button.type = TOUCH_BUTTON_TYPE_MENU_TOGGLE;
button.id = id;
button.checked = checked;
register_button(button);
}
void register_button(TouchButton button)
{
dynamic_buttons.push_back(button);
@ -166,6 +178,9 @@ namespace touch
bool version2_2 = GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2);
switch (button->type)
{
case TOUCH_BUTTON_TYPE_MENU_TOGGLE:
button->checked = !button->checked;
SDL_FALLTHROUGH;
case TOUCH_BUTTON_TYPE_MENU:
game.currentmenuoption = button->id;
menuactionpress();
@ -303,13 +318,30 @@ namespace touch
inner_div = 6;
}
graphics.fill_rect(button->x + 4 * scale, button->y + 4 * scale, button->width, button->height, r / shadow_div, g / shadow_div, b / shadow_div);
int offset = (button->down) ? 1 : 0;
int font_scale = (SDL_min((scale - 1), 7) << 0);
int height = font::height(PR_CJK_LOW | font_scale);
switch (button->type)
{
case TOUCH_BUTTON_TYPE_MENU_TOGGLE:
graphics.draw_rect(button->x + offset * scale, button->y + offset * scale, 10, 10, use_r, use_g, use_b);
if (button->checked)
{
graphics.fill_rect(button->x + 2 * scale + offset * scale, button->y + 2 * scale + offset * scale, 6, 6, use_r, use_g, use_b);
}
font::print(PR_CJK_LOW | font_scale, button->x + 16 + offset * scale, button->y + ((button->height - height) / 2 + offset) * scale, button->text, use_r, use_g, use_b);
break;
default:
graphics.fill_rect(button->x + 4 * scale, button->y + 4 * scale, button->width, button->height, r / shadow_div, g / shadow_div, b / shadow_div);
graphics.fill_rect(button->x + offset * scale, button->y + offset * scale, button->width, button->height, use_r, use_g, use_b);
graphics.fill_rect(button->x + (offset + 2) * scale, button->y + (2 + offset) * scale, button->width - 4 * scale, button->height - 4 * scale, use_r / inner_div, use_g / inner_div, use_b / inner_div);
font::print(PR_CEN | (SDL_min((scale - 1), 7) << 0), button->x + (button->width / 2) + offset * scale, button->y + (button->height / 2) + (offset - 4) * scale, button->text, 196, 196, 255 - help.glow);
font::print(PR_CEN | PR_CJK_LOW | font_scale, button->x + (button->width / 2) + offset * scale, button->y + ((button->height - height) / 2 + offset) * scale, button->text, 196, 196, 255 - help.glow);
break;
}
}
}
}
@ -365,6 +397,11 @@ namespace touch
}
}
void on_menu_create(void)
{
scroll = 0;
}
void update_buttons(void)
{
if (!use_buttons || graphics.fademode != FADE_NONE)

View file

@ -56,6 +56,7 @@ enum TouchButtonType
{
TOUCH_BUTTON_TYPE_NONE,
TOUCH_BUTTON_TYPE_MENU,
TOUCH_BUTTON_TYPE_MENU_TOGGLE,
TOUCH_BUTTON_TYPE_MAP
};
@ -72,6 +73,7 @@ struct TouchButton
bool ui; // Whether the button is on the UI layer or not
int id; // The ID for the button, mainly used for menu buttons
bool disabled; // Whether the button is disabled or not (gray and can't use), different from active
bool checked; // If this is a checkbox, whether it's checked or not
std::string text; // The text for the button, if it doesn't have an image
SDL_Texture* image; // The image that gets displayed on the button, can be NULL
SDL_FingerID fingerId;
@ -85,9 +87,11 @@ namespace touch
extern std::vector<TouchButton> dynamic_buttons;
extern std::vector<TouchButton*> all_buttons;
extern int scale;
extern bool scroll;
void refresh_buttons(void);
void reset(void);
void on_menu_create(void);
void update_buttons(void);
TouchButton create_button(int x, int y, int width, int height, std::string text);
@ -95,6 +99,7 @@ namespace touch
void create_menu_button(int x, int y, int width, int height, std::string text, int id);
void create_menu_button(int x, int y, int width, int height, std::string text, int id, bool disabled);
void create_toggle_button(int x, int y, int width, int height, std::string text, int id, bool checked);
void remove_dynamic_buttons(void);