mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Remove usage of std::string from MenuOption
Instead, the string in MenuOption is just a buffer of 161 chars, which is 40 chars (160 bytes if each were the largest possible UTF-8 character size) plus a null terminator. This is because the maximum length of a menu option that can be fit on the screen without going past is 40 chars.
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
|
||||
struct MenuOption
|
||||
{
|
||||
std::string text;
|
||||
char text[161]; // 40 chars (160 bytes) covers the entire screen, + 1 more for null terminator
|
||||
// WARNING: should match Game::menutextbytes below
|
||||
bool active;
|
||||
};
|
||||
|
||||
@@ -225,12 +226,13 @@ public:
|
||||
int current_credits_list_index;
|
||||
int menuxoff, menuyoff;
|
||||
int menuspacing;
|
||||
static const int menutextbytes = 161; // this is just sizeof(MenuOption::text), but doing that is non-standard
|
||||
std::vector<MenuStackFrame> menustack;
|
||||
|
||||
void inline option(std::string text, bool active = true)
|
||||
void inline option(const char* text, bool active = true)
|
||||
{
|
||||
MenuOption menuoption;
|
||||
menuoption.text = text;
|
||||
SDL_strlcpy(menuoption.text, text, sizeof(menuoption.text));
|
||||
menuoption.active = active;
|
||||
menuoptions.push_back(menuoption);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user