mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Shorten the version display on the main screen
This commit is contained in:
parent
26de955c77
commit
a859b2223a
@ -100,6 +100,16 @@ bool containsNoCase(std::string_view haystack, std::string_view needle) {
|
||||
return found != haystack.end();
|
||||
}
|
||||
|
||||
int countChar(std::string_view haystack, char needle) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < haystack.size(); i++) {
|
||||
if (haystack[i] == needle) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args)
|
||||
{
|
||||
int writtenCount = vsnprintf(out, outsize, format, args);
|
||||
|
@ -85,6 +85,8 @@ std::string_view StripQuotes(std::string_view s);
|
||||
|
||||
std::string_view StripPrefix(std::string_view prefix, std::string_view s);
|
||||
|
||||
int countChar(std::string_view haystack, char needle);
|
||||
|
||||
// NOTE: str must live at least as long as all uses of output.
|
||||
void SplitString(std::string_view str, const char delim, std::vector<std::string_view> &output);
|
||||
// Try to avoid this when possible, in favor of the string_view version.
|
||||
|
@ -1251,8 +1251,19 @@ void MainScreen::CreateViews() {
|
||||
rightColumnItems->SetSpacing(0.0f);
|
||||
rightColumn->Add(rightColumnItems);
|
||||
|
||||
char versionString[256];
|
||||
snprintf(versionString, sizeof(versionString), "%s", PPSSPP_GIT_VERSION);
|
||||
std::string versionString = PPSSPP_GIT_VERSION;
|
||||
// Strip the 'v' from the displayed version, and shorten the commit hash.
|
||||
if (versionString.size() > 2) {
|
||||
if (versionString[0] == 'v' && isdigit(versionString[1])) {
|
||||
versionString = versionString.substr(1);
|
||||
}
|
||||
if (countChar(versionString, '-') == 2) {
|
||||
// Shorten the commit hash.
|
||||
size_t cutPos = versionString.find_last_of('-') + 8;
|
||||
versionString = versionString.substr(0, std::min(cutPos, versionString.size()));
|
||||
}
|
||||
}
|
||||
|
||||
rightColumnItems->SetSpacing(0.0f);
|
||||
AnchorLayout *logos = new AnchorLayout(new AnchorLayoutParams(FILL_PARENT, 60.0f, false));
|
||||
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
|
||||
|
Loading…
Reference in New Issue
Block a user