overwrite longer rom names on screen

This commit is contained in:
penfold42 2018-07-30 10:20:52 +10:00
parent d26147d93c
commit ba66f2f929
4 changed files with 20 additions and 1 deletions

View file

@ -1153,7 +1153,11 @@ void FileBrowser::ShowDeviceAndROM()
u32 x = 0; // 43 * 8
u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y) - 20;
snprintf(buffer, 256, "Device %2d %s\r\n", *deviceID, roms->ROMNames[roms->currentROMIndex]);
snprintf(buffer, 256, "Device %2d %*s\r\n"
, *deviceID
, roms->GetLongestRomNameLen()
, roms->ROMNames[roms->currentROMIndex]
);
screenMain->PrintText(false, x, y, buffer, textColour, bgColour);
}

View file

@ -43,3 +43,10 @@ void ROMs::SelectROM(const char* ROMName)
}
}
unsigned ROMs::UpdateLongestRomNameLen( unsigned maybeLongest )
{
if (maybeLongest > longestRomNameLen)
longestRomNameLen = maybeLongest;
return longestRomNameLen;
}

View file

@ -42,5 +42,12 @@ public:
unsigned currentROMIndex;
unsigned lastManualSelectedROMIndex;
unsigned GetLongestRomNameLen() { return longestRomNameLen; }
unsigned UpdateLongestRomNameLen( unsigned maybeLongest );
protected:
unsigned longestRomNameLen;
};
#endif

View file

@ -1240,6 +1240,7 @@ static void CheckOptions()
{
strncpy(roms.ROMNames[ROMIndex], ROMName, 255);
roms.ROMValid[ROMIndex] = true;
roms.UpdateLongestRomNameLen( strlen(roms.ROMNames[ROMIndex]) );
}
f_close(&fp);
//DEBUG_LOG("Read ROM %s from options\r\n", ROMName);