From 09365347b6d9417712a520497ae290326f7bd9a6 Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Sat, 18 Mar 2023 22:32:26 +0100 Subject: [PATCH] Replace ACTION in texts by {button} placeholders Gamepads and the Steam Deck need "ACTION" to be replaced by a controller glyph, so that's now possible. --- desktop_version/lang/en/strings.xml | 19 +++++--- desktop_version/src/ActionSets.h | 10 ++++- desktop_version/src/ButtonGlyphs.cpp | 10 +++++ desktop_version/src/Game.cpp | 19 +++++++- desktop_version/src/Graphics.cpp | 2 + desktop_version/src/Render.cpp | 66 +++++++++++++++++++++------- 6 files changed, 101 insertions(+), 25 deletions(-) diff --git a/desktop_version/lang/en/strings.xml b/desktop_version/lang/en/strings.xml index dac6ce01..f2fdb5da 100644 --- a/desktop_version/lang/en/strings.xml +++ b/desktop_version/lang/en/strings.xml @@ -213,6 +213,7 @@ + @@ -418,12 +419,15 @@ - + + - - + + + + @@ -449,7 +453,8 @@ - + + @@ -463,7 +468,8 @@ - + + @@ -655,7 +661,8 @@ - + + diff --git a/desktop_version/src/ActionSets.h b/desktop_version/src/ActionSets.h index b522c1fa..ad445ea3 100644 --- a/desktop_version/src/ActionSets.h +++ b/desktop_version/src/ActionSets.h @@ -24,7 +24,7 @@ extern "C" typedef enum { //ActionSet_Global, - //ActionSet_Menu, + ActionSet_Menu, ActionSet_InGame //ActionSet_Editor } @@ -45,6 +45,13 @@ Action_Global; typedef enum { + Action_Menu_Accept +} +Action_Menu; + +typedef enum +{ + Action_InGame_ACTION, Action_InGame_Interact, Action_InGame_Map } @@ -67,6 +74,7 @@ typedef union { int intval; //Action_Global Global; + Action_Menu Menu; Action_InGame InGame; //Action_Editor Editor; } diff --git a/desktop_version/src/ButtonGlyphs.cpp b/desktop_version/src/ButtonGlyphs.cpp index b032c74c..f4126dbf 100644 --- a/desktop_version/src/ButtonGlyphs.cpp +++ b/desktop_version/src/ButtonGlyphs.cpp @@ -109,9 +109,19 @@ const char* BUTTONGLYPHS_get_button(const ActionSet actionset, const Action acti * to fill into strings like "Press {button} to activate terminal". */ switch (actionset) { + case ActionSet_Menu: + switch (action.Menu) + { + case Action_Menu_Accept: + return loc::gettext("ACTION"); + } + break; case ActionSet_InGame: switch (action.InGame) { + case Action_InGame_ACTION: + return loc::gettext("ACTION"); + case Action_InGame_Interact: if (game.separate_interact) { diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 9a85483f..199936a1 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -715,7 +715,14 @@ void Game::remaining_textbox(void) void Game::actionprompt_textbox(void) { - graphics.createtextboxflipme(loc::gettext("Press ACTION to continue"), -1, 196, 164, 164, 255); + char buffer[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("Press {button} to continue"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + graphics.createtextboxflipme(buffer, -1, 196, 164, 164, 255); graphics.textboxprintflags(PR_FONT_INTERFACE); graphics.textboxpad(1, 1); graphics.textboxcenterx(); @@ -1114,7 +1121,15 @@ void Game::updatestate(void) graphics.textboxremovefast(); obj.flags[3] = true; setstate(0); - graphics.createtextbox(loc::gettext("Press ACTION to flip"), -1, 25, 174, 174, 174); + + char buffer[SCREEN_WIDTH_CHARS*3 + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("Press {button} to flip"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + graphics.createtextbox(buffer, -1, 25, 174, 174, 174); graphics.textboxprintflags(PR_FONT_INTERFACE); graphics.textboxwrap(4); graphics.textboxcentertext(); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 7a817326..c0c9c4bc 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -768,8 +768,10 @@ static void fill_buttons(char* buffer, const size_t buffer_len, const char* line { vformat_buf(buffer, buffer_len, line, + "b_act:but," "b_int:but," "b_map:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION), vformat_button(ActionSet_InGame, Action_InGame_Interact), vformat_button(ActionSet_InGame, Action_InGame_Map) ); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 8391d024..5879c88a 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1,6 +1,7 @@ #include #include "ActionSets.h" +#include "ButtonGlyphs.h" #include "Constants.h" #include "Credits.h" #include "CustomLevels.h" @@ -1623,8 +1624,18 @@ void titlerender(void) font::print(PR_RIGHT, 264, temp+35, loc::gettext("MAKE AND PLAY EDITION"), tr, tg, tb); #endif - font::print_wrap(PR_CEN, -1, 175, loc::gettext("[ Press ACTION to Start ]"), tr, tg, tb); - font::print_wrap(PR_CEN, -1, 195, loc::gettext("ACTION = Space, Z, or V"), int(tr*0.5f), int(tg*0.5f), int(tb*0.5f)); + char buffer[SCREEN_WIDTH_CHARS*2 + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("[ Press {button} to Start ]"), + "button:but", + vformat_button(ActionSet_Menu, Action_Menu_Accept) + ); + font::print_wrap(PR_CEN, -1, 175, buffer, tr, tg, tb); + if (BUTTONGLYPHS_keyboard_is_active()) + { + font::print_wrap(PR_CEN, -1, 195, loc::gettext("ACTION = Space, Z, or V"), int(tr*0.5f), int(tg*0.5f), int(tb*0.5f)); + } } else { @@ -1975,13 +1986,17 @@ void gamerender(void) graphics.copy_texture(graphics.gameplayTexture, NULL, NULL); - if (graphics.flipmode) + if (game.advancetext) { - if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - } - else - { - if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); + char buffer_adv[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer_adv, sizeof(buffer_adv), + loc::gettext("- Press {button} to advance text -"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + + font::print(PR_CEN | PR_BOR, -1, graphics.flipmode ? 228 : 5, buffer_adv, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); } if (game.readytotele > 100 || game.oldreadytotele > 100) @@ -2593,7 +2608,14 @@ void maprender(void) } else if (obj.flags[67] && !map.custommode) { - font::print_wrap(PR_CEN, -1, 105, loc::gettext("Press ACTION to warp to the ship."), 196, 196, 255 - help.glow); + char buffer[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("Press {button} to warp to the ship."), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + font::print_wrap(PR_CEN, -1, 105, buffer, 196, 196, 255 - help.glow); } #if !defined(NO_CUSTOM_LEVELS) else if(map.custommode){ @@ -2755,7 +2777,15 @@ void maprender(void) if (!game.gamesaved) { - font::print(PR_CEN, -1, 80, loc::gettext("[Press ACTION to save your game]"), 255 - help.glow*2, 255 - help.glow*2, 255 - help.glow); + char buffer[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("[Press {button} to save your game]"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + + font::print(PR_CEN, -1, 80, buffer, 255 - help.glow*2, 255 - help.glow*2, 255 - help.glow); if (map.custommode || game.quicksummary == "") { @@ -2991,13 +3021,17 @@ void teleporterrender(void) graphics.drawgui(); - if (graphics.flipmode) + if (game.advancetext) { - if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - } - else - { - if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); + char buffer_adv[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer_adv, sizeof(buffer_adv), + loc::gettext("- Press {button} to advance text -"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_ACTION) + ); + + font::print(PR_CEN | PR_BOR, -1, graphics.flipmode ? 228 : 5, buffer_adv, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); } graphics.set_render_target(graphics.gameTexture);