Skip to content

Commit

Permalink
Change display names to be max two lines, with ... if it goes beyond …
Browse files Browse the repository at this point in the history
…that.
  • Loading branch information
lanceewing committed Mar 29, 2024
1 parent 3ceb850 commit a89d2e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
22 changes: 11 additions & 11 deletions assets/data/games.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
{
"gameId": "BORMN2",
"name": "Boring Man 2 - Ho Man! This Game Sucks!",
"displayName": "Boring Man 2 - Ho\nMan! This Game\nSucks!",
"displayName": "Boring Man 2 - Ho\nMan! This Game...",
"filePath": "/games/bormn2.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -297,7 +297,7 @@
{
"gameId": "DOGSQ",
"name": "Dogs Quest - The Quest for the Golden Bone",
"displayName": "Dogs Quest - The\nQuest for the\nGolden Bone",
"displayName": "Dogs Quest - The\nQuest for the...",
"filePath": "/games/dogsq.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -374,7 +374,7 @@
{
"gameId": "GTAMP1",
"name": "Gennadi Tahab Autot - Mission Pack 1 - Kuressaare",
"displayName": "Gennadi Tahab Autot\n- Mission Pack 1 -\nKuressaare",
"displayName": "Gennadi Tahab Autot\n- Mission Pack 1...",
"filePath": "/games/gtamp1.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -486,7 +486,7 @@
{
"gameId": "JOEMCM",
"name": "Joe McMuffin In \"What's Cooking, Doc\"",
"displayName": "Joe McMuffin In\n\"What's Cooking,\nDoc\"",
"displayName": "Joe McMuffin In\n\"What's Cooking,...",
"filePath": "/games/joemcm.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -675,14 +675,14 @@
{
"gameId": "NATU2E",
"name": "Naturette 2 - Daughter of the Moon",
"displayName": "Naturette 2 -\nDaughter of the\nMoon",
"displayName": "Naturette 2 -\nDaughter of the Moon",
"filePath": "/games/natu2e.zip",
"fileType": "ZIP"
},
{
"gameId": "NATU3E",
"name": "Naturette 3 - Adventure in Treeworld",
"displayName": "Naturette 3 -\nAdventure in\nTreeworld",
"displayName": "Naturette 3 -\nAdventure in Treeworld",
"filePath": "/games/natu3e.zip",
"fileType": "ZIP"
},
Expand All @@ -703,7 +703,7 @@
{
"gameId": "NICKQ",
"name": "Nick's Quest - In Pursuit of QuakeMovie",
"displayName": "Nick's Quest - In\nPursuit of\nQuakeMovie",
"displayName": "Nick's Quest - In\nPursuit of...",
"filePath": "/games/nickq.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -983,7 +983,7 @@
{
"gameId": "TEXM1",
"name": "Tex McPhilip 1 - Quest For The Papacy",
"displayName": "Tex McPhilip 1 -\nQuest For The\nPapacy",
"displayName": "Tex McPhilip 1 -\nQuest For The Papacy",
"filePath": "/games/texm1.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -1025,7 +1025,7 @@
{
"gameId": "LSHAYL",
"name": "The Legend of Shay-Larah 1 - The Lost Prince",
"displayName": "The Legend of\nShay-Larah 1 - The\nLost Prince",
"displayName": "The Legend of\nShay-Larah 1 - The...",
"filePath": "/games/lshayl.zip",
"fileType": "ZIP"
},
Expand All @@ -1039,7 +1039,7 @@
{
"gameId": "LHDUDE",
"name": "The Long Haired Dude: Encounter of the 18-th Kind",
"displayName": "The Long Haired\nDude: Encounter of\nthe 18-th Kind",
"displayName": "The Long Haired\nDude: Encounter of...",
"filePath": "/games/lhdude.zip",
"fileType": "ZIP"
},
Expand Down Expand Up @@ -1088,7 +1088,7 @@
{
"gameId": "TTSCB",
"name": "Tonight The Shrieking Corpses Bleed",
"displayName": "Tonight The\nShrieking Corpses\nBleed",
"displayName": "Tonight The\nShrieking Corpses...",
"filePath": "/games/ttscb.zip",
"fileType": "ZIP"
},
Expand Down
16 changes: 12 additions & 4 deletions core/src/main/java/com/agifans/agile/config/AppConfigItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,30 @@ public void setName(String name) {
* @return the displayName
*/
public String getDisplayName() {
if ((displayName == null) && (name != null)) {
if (/*(displayName == null) && */(name != null)) {
// Word wrap default to 20 chars.
StringBuilder displayNameBuilder = new StringBuilder();
StringBuilder currentLine = new StringBuilder();
String[] words = name.split(" ");
int lineCount = 1;
for (String word : words) {
if ((currentLine.length() + word.length() + 1) < 20) {
if ((currentLine.length() + word.length() + 1) <= 20) {
if (currentLine.length() > 0) {
currentLine.append(" ");
}
currentLine.append(word);
} else {
// New line. Check for max 2 lines.
displayNameBuilder.append(currentLine.toString());
displayNameBuilder.append("\n");
currentLine.setLength(0);
currentLine.append(word);
if (lineCount == 2) {
displayNameBuilder.append("...");
break;
} else {
lineCount++;
displayNameBuilder.append("\n");
currentLine.append(word);
}
}
}
if (currentLine.length() > 0) {
Expand Down

0 comments on commit a89d2e3

Please sign in to comment.