summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-08-02 00:54:14 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-08-02 21:33:47 +0100
commit9a5eae7597bae8ceb8f033bcd44d39acd0ba63bc (patch)
tree2355c85956887a3eb5e34bff4445fe62d7e65e3e
parentc4ad8846190d6bdfb06e54548242c07713bc095d (diff)
Coerce all-uppercase titles to pseudo-titlecase
-rw-r--r--src/gameinfo.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gameinfo.c b/src/gameinfo.c
index 10959a6..3713d6c 100644
--- a/src/gameinfo.c
+++ b/src/gameinfo.c
@@ -82,6 +82,21 @@ bool gameinfo_init(void) {
#else
#error TODO(linux): grab window handle and title from SDL (a bit involved...)
#endif
+
+ // SUPER crude algorithm to force uppercase titles like HALF-LIFE 2 or
+ // PORTAL 2 to (almost-)titlecase. will refine later, as needed
+ bool hasupper = false, haslower = false;
+ for (char *p = title; *p && (!hasupper || !haslower); ++p) {
+ haslower |= *p >= 'a' && *p <= 'z';
+ hasupper |= *p >= 'A' && *p <= 'Z';
+ }
+ if (hasupper && !haslower) {
+ int casebit = 0;
+ for (char *p = title; *p; ++p) {
+ if (*p >= 'A' && *p <= 'Z') *p |= casebit;
+ casebit = (*p == ' ' || *p == '-') << 5; // ? 32 : 0
+ }
+ }
}
return true;
}