From 1d53647a7ea836e3d4934556fc9a28e13fabfc2e Mon Sep 17 00:00:00 2001 From: lantzelot-swe <75668734+lantzelot-swe@users.noreply.github.com> Date: Mon, 14 Aug 2023 22:16:52 +0200 Subject: [PATCH] fix: visual display of too many games/files for a game view The game- and file count for a gameview in the gamelist dropdown is shown in red color if it contain more than 255 games, which is the limit for games in the Carousel and in a folder in the file loader/media access. --- .../java/se/lantz/model/data/GameView.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/se/lantz/model/data/GameView.java b/src/main/java/se/lantz/model/data/GameView.java index 0aa4ae6..e14adad 100644 --- a/src/main/java/se/lantz/model/data/GameView.java +++ b/src/main/java/se/lantz/model/data/GameView.java @@ -10,6 +10,9 @@ import se.lantz.util.DbConstants; public class GameView implements Comparable { + private static final String fontRedStart = ""; + private static final String fontRedEnd = ""; + public static final String FAV_GAMEVIEW_NAME_PREF_KEY = "GameViewFavoritesName_"; public static final int ALL_GAMES_ID = -1; public static final int FAVORITES_ID = -2; @@ -30,7 +33,7 @@ public class GameView implements Comparable private int gameViewId; private int gameCount = -1; - + private int fileCount = -1; public GameView(int gameViewId) @@ -62,18 +65,28 @@ public class GameView implements Comparable @Override public String toString() { + String text = ""; if (gameCount > -1) { - if (gameViewId != -1 && gameCount < fileCount) + if (gameViewId != -1) { - return name + " (" + gameCount + "/" + fileCount + ")"; + String gameCountString = gameCount > 255 ? fontRedStart + gameCount + fontRedEnd : gameCount + ""; + String fileCountString = fileCount > 255 ? fontRedStart + fileCount + fontRedEnd : fileCount + ""; + if (gameCount < fileCount) + { + text = name + " (" + gameCountString + "/" + fileCountString + ")"; + } + else + { + text = name + " (" + gameCountString + ")"; + } } else { - return name + " (" + gameCount + ")"; + text = name + " (" + gameCount + ")"; } } - return name; + return "" + text + ""; } public List getViewFilters() @@ -295,7 +308,7 @@ public class GameView implements Comparable { this.gameViewId = gameViewId; } - + public int getGameCount() { return this.gameCount; @@ -315,7 +328,7 @@ public class GameView implements Comparable { this.fileCount = fileCount; } - + public String getFavNamePreferencesKey() { if (gameViewId < -1)