1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-02 19:13:31 +02:00

Modify a few menus

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

View File

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

View File

@ -6565,6 +6565,8 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
int maxspacing = 30; // maximum value for menuspacing, can only become lower. int maxspacing = 30; // maximum value for menuspacing, can only become lower.
bool auto_buttons = true; bool auto_buttons = true;
bool auto_center = true; bool auto_center = true;
int button_height = 26;
int button_spacing = 6;
menucountdown = 0; menucountdown = 0;
menuoptions.clear(); menuoptions.clear();
touch::remove_dynamic_buttons(); touch::remove_dynamic_buttons();
@ -6756,11 +6758,14 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
menuyoff = -20; menuyoff = -20;
break; break;
case Menu::gameplayoptions: case Menu::gameplayoptions:
{
#if !defined(MAKEANDPLAY) #if !defined(MAKEANDPLAY)
int offset = 0;
if (ingame_titlemode && unlock[Unlock_FLIPMODE]) if (ingame_titlemode && unlock[Unlock_FLIPMODE])
#endif #endif
{ {
option(loc::gettext("flip mode")); option(loc::gettext("flip mode"));
offset++;
} }
option(loc::gettext("toggle fps")); option(loc::gettext("toggle fps"));
option(loc::gettext("speedrun options")); option(loc::gettext("speedrun options"));
@ -6770,18 +6775,29 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option(loc::gettext("return")); option(loc::gettext("return"));
menuyoff = -10; menuyoff = -10;
maxspacing = 15; 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; break;
}
case Menu::graphicoptions: case Menu::graphicoptions:
{
int optionid = 4;
if (!gameScreen.isForcedFullscreen()) if (!gameScreen.isForcedFullscreen())
{ {
option(loc::gettext("toggle fullscreen")); option(loc::gettext("toggle fullscreen"));
optionid++;
} }
option(loc::gettext("scaling mode")); option(loc::gettext("scaling mode"));
if (!gameScreen.isForcedFullscreen()) if (!gameScreen.isForcedFullscreen())
{ {
option(loc::gettext("resize to nearest"), gameScreen.isWindowed); option(loc::gettext("resize to nearest"), gameScreen.isWindowed);
optionid++;
} }
option(loc::gettext("toggle filter")); option(loc::gettext("toggle filter"));
option(loc::gettext("toggle analogue")); option(loc::gettext("toggle analogue"));
@ -6789,9 +6805,18 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option(loc::gettext("return")); option(loc::gettext("return"));
menuyoff = -10; menuyoff = -10;
maxspacing = 15; 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; break;
}
case Menu::ed_settings: case Menu::ed_settings:
option(loc::gettext("change description")); option(loc::gettext("change description"));
option(loc::gettext("edit scripts")); option(loc::gettext("edit scripts"));
@ -7440,7 +7465,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; int offset = 0;
@ -7450,9 +7475,9 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
{ {
touch::create_menu_button( touch::create_menu_button(
(320 - 160) / 2, (320 - 160) / 2,
base_y + offset * 32, base_y + offset * (button_height + button_spacing),
160, 160,
26, button_height,
menuoptions[i].text, menuoptions[i].text,
i, i,
menuoptions[i].active menuoptions[i].active
@ -7461,6 +7486,8 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
} }
} }
} }
touch::on_menu_create();
} }
bool Game::can_unlock_ndm(void) bool Game::can_unlock_ndm(void)

View File

@ -454,7 +454,14 @@ void menuactionpress(void)
case 2: case 2:
//Options //Options
music.playef(Sound_VIRIDIAN); music.playef(Sound_VIRIDIAN);
if (key.using_touch)
{
game.createmenu(Menu::gameplayoptions);
}
else
{
game.createmenu(Menu::options); game.createmenu(Menu::options);
}
map.nexttowercolour(); map.nexttowercolour();
break; break;
case 3: case 3:
@ -708,6 +715,22 @@ void menuactionpress(void)
gameScreen.toggleVSync(); gameScreen.toggleVSync();
game.savestatsandsettings_menu(); 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) if (!processed)
{ {
//back //back
@ -1026,6 +1049,21 @@ void menuactionpress(void)
map.nexttowercolour(); 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; break;
} }
case Menu::options: case Menu::options:
@ -3363,7 +3401,14 @@ static void mapmenuactionpress(const bool version2_2)
// Set this before we create the menu // Set this before we create the menu
game.kludge_ingametemp = game.currentmenuname; game.kludge_ingametemp = game.currentmenuname;
if (key.using_touch)
{
game.createmenu(Menu::gameplayoptions);
}
else
{
game.createmenu(Menu::options); game.createmenu(Menu::options);
}
map.nexttowercolour(); map.nexttowercolour();
break; break;
case 32: 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); font::print_wrap(PR_CEN, -1, 65, loc::gettext("ERROR: This level has no start point!"), tr, tg, tb);
break; break;
case Menu::gameplayoptions: 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; int gameplayoptionsoffset = 0;
#if !defined(MAKEANDPLAY) #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(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); font::print_wrap(PR_CEN, -1, 65, loc::gettext("Delete your custom level save data and completion stars."), tr, tg, tb);
} }
}
break; break;
} }
@ -405,6 +413,13 @@ static void menurender(void)
} }
break; break;
case Menu::graphicoptions: 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; int offset = 0;
if (game.currentmenuoption == offset + 0 && !gameScreen.isForcedFullscreen()) 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); font::print_wrap(PR_CEN, -1, next_y, loc::gettext("Current mode: VSYNC ON"), tr, tg, tb);
} }
} }
}
break; break;
} }
case Menu::audiooptions: case Menu::audiooptions:

View File

@ -33,6 +33,7 @@ namespace touch
bool use_buttons; bool use_buttons;
int scale; int scale;
bool textbox_style; bool textbox_style;
bool scroll;
void refresh_all_buttons(void) void refresh_all_buttons(void)
{ {
@ -52,7 +53,7 @@ namespace touch
int get_rect(TouchButton* button, SDL_Rect* rect) int get_rect(TouchButton* button, SDL_Rect* rect)
{ {
rect->x = button->x; rect->x = button->x;
rect->y = button->y; rect->y = button->y - scroll;
rect->w = button->width; rect->w = button->width;
rect->h = button->height; rect->h = button->height;
@ -124,6 +125,7 @@ namespace touch
button.type = TOUCH_BUTTON_TYPE_NONE; button.type = TOUCH_BUTTON_TYPE_NONE;
button.id = -1; button.id = -1;
button.disabled = false; button.disabled = false;
button.checked = false;
return button; return button;
} }
@ -148,6 +150,16 @@ namespace touch
register_button(button); 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) void register_button(TouchButton button)
{ {
dynamic_buttons.push_back(button); dynamic_buttons.push_back(button);
@ -166,6 +178,9 @@ namespace touch
bool version2_2 = GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2); bool version2_2 = GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2);
switch (button->type) switch (button->type)
{ {
case TOUCH_BUTTON_TYPE_MENU_TOGGLE:
button->checked = !button->checked;
SDL_FALLTHROUGH;
case TOUCH_BUTTON_TYPE_MENU: case TOUCH_BUTTON_TYPE_MENU:
game.currentmenuoption = button->id; game.currentmenuoption = button->id;
menuactionpress(); menuactionpress();
@ -303,13 +318,30 @@ namespace touch
inner_div = 6; 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 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 * 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); 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) void update_buttons(void)
{ {
if (!use_buttons || graphics.fademode != FADE_NONE) if (!use_buttons || graphics.fademode != FADE_NONE)

View File

@ -56,6 +56,7 @@ enum TouchButtonType
{ {
TOUCH_BUTTON_TYPE_NONE, TOUCH_BUTTON_TYPE_NONE,
TOUCH_BUTTON_TYPE_MENU, TOUCH_BUTTON_TYPE_MENU,
TOUCH_BUTTON_TYPE_MENU_TOGGLE,
TOUCH_BUTTON_TYPE_MAP TOUCH_BUTTON_TYPE_MAP
}; };
@ -72,6 +73,7 @@ struct TouchButton
bool ui; // Whether the button is on the UI layer or not bool ui; // Whether the button is on the UI layer or not
int id; // The ID for the button, mainly used for menu buttons 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 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 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_Texture* image; // The image that gets displayed on the button, can be NULL
SDL_FingerID fingerId; SDL_FingerID fingerId;
@ -85,9 +87,11 @@ namespace touch
extern std::vector<TouchButton> dynamic_buttons; extern std::vector<TouchButton> dynamic_buttons;
extern std::vector<TouchButton*> all_buttons; extern std::vector<TouchButton*> all_buttons;
extern int scale; extern int scale;
extern bool scroll;
void refresh_buttons(void); void refresh_buttons(void);
void reset(void); void reset(void);
void on_menu_create(void);
void update_buttons(void); void update_buttons(void);
TouchButton create_button(int x, int y, int width, int height, std::string text); 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);
void create_menu_button(int x, int y, int width, int height, std::string text, int id, bool disabled); 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); void remove_dynamic_buttons(void);