mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01:00
De-duplicate number of menu text bytes
I've moved this to a define that gets declared in Game.h. I could've made it a const int, but that's only legal in C++ mode.
This commit is contained in:
parent
40c6a01917
commit
22d71affba
3 changed files with 7 additions and 6 deletions
|
@ -6327,7 +6327,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
|
|||
static const char tmp[] = " ";
|
||||
prefix = tmp;
|
||||
}
|
||||
char text[menutextbytes];
|
||||
char text[MENU_TEXT_BYTES];
|
||||
SDL_snprintf(text, sizeof(text), "%s%s", prefix, ed.ListOfMetaData[i].title.c_str());
|
||||
for (size_t ii = 0; text[ii] != '\0'; ++ii)
|
||||
{
|
||||
|
|
|
@ -14,10 +14,12 @@ namespace tinyxml2
|
|||
class XMLElement;
|
||||
}
|
||||
|
||||
/* 40 chars (160 bytes) covers the entire screen, + 1 more for null terminator */
|
||||
#define MENU_TEXT_BYTES 161
|
||||
|
||||
struct MenuOption
|
||||
{
|
||||
char text[161]; // 40 chars (160 bytes) covers the entire screen, + 1 more for null terminator
|
||||
// WARNING: should match Game::menutextbytes below
|
||||
char text[MENU_TEXT_BYTES];
|
||||
bool active;
|
||||
};
|
||||
|
||||
|
@ -252,7 +254,6 @@ 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(const char* text, bool active = true)
|
||||
|
|
|
@ -1420,10 +1420,10 @@ void Graphics::drawmenu( int cr, int cg, int cb, bool levelmenu /*= false*/ )
|
|||
}
|
||||
}
|
||||
|
||||
char tempstring[Game::menutextbytes];
|
||||
char tempstring[MENU_TEXT_BYTES];
|
||||
SDL_strlcpy(tempstring, opt.text, sizeof(tempstring));
|
||||
|
||||
char buffer[Game::menutextbytes];
|
||||
char buffer[MENU_TEXT_BYTES];
|
||||
if ((int) i == game.currentmenuoption)
|
||||
{
|
||||
if (opt.active)
|
||||
|
|
Loading…
Reference in a new issue