From c72619cbb297e6b3648fb1207103aa23aac0f867 Mon Sep 17 00:00:00 2001 From: Lance Ewing Date: Mon, 26 Feb 2024 21:11:23 +0000 Subject: [PATCH] Added three variations of behaviour for game import. --- .../java/com/agifans/agile/HomeScreen.java | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/com/agifans/agile/HomeScreen.java b/core/src/main/java/com/agifans/agile/HomeScreen.java index 9d27800..249685a 100644 --- a/core/src/main/java/com/agifans/agile/HomeScreen.java +++ b/core/src/main/java/com/agifans/agile/HomeScreen.java @@ -728,32 +728,47 @@ public void openFileResult(boolean success, String filePath, String gameName, St agile.getPreferences().flush(); } final String appConfigFilePath = filePath; - dialogHandler.promptForTextInput("Confirm name of AGI game", gameName, - new TextInputResponseHandler() { - @Override - public void inputTextResult(boolean success, String text) { - if (success) { - AppConfigItem appConfigItem = new AppConfigItem(); - appConfigItem.setGameId(gameId); - appConfigItem.setName(text); - appConfigItem.setFilePath(appConfigFilePath); - if (Gdx.app.getType().equals(ApplicationType.WebGL)) { - appConfigItem.setFileType("GAMEFILES.DAT"); - } else { - if (appConfigFilePath.toLowerCase().endsWith(".zip")) { - appConfigItem.setFileType("ZIP"); - } - else { - appConfigItem.setFileType("DIR"); - } + final TextInputResponseHandler textInputResponseHandler = new TextInputResponseHandler() { + @Override + public void inputTextResult(boolean success, String text) { + if (success) { + AppConfigItem appConfigItem = new AppConfigItem(); + appConfigItem.setGameId(gameId); + appConfigItem.setName(text); + appConfigItem.setFilePath(appConfigFilePath); + if (Gdx.app.getType().equals(ApplicationType.WebGL)) { + appConfigItem.setFileType("GAMEFILES.DAT"); + } else { + if (appConfigFilePath.toLowerCase().endsWith(".zip")) { + appConfigItem.setFileType("ZIP"); + } + else { + appConfigItem.setFileType("DIR"); } - appConfigMap.put(appConfigItem.getName(), appConfigItem); - disposeCachedIcon(appConfigItem); - updateHomeScreenButtonStages(); - showGamePage(appConfigItem); } + appConfigMap.put(appConfigItem.getName(), appConfigItem); + disposeCachedIcon(appConfigItem); + updateHomeScreenButtonStages(); + showGamePage(appConfigItem); } - }); + } + }; + if (appConfigItem != null) { + if (appConfigItem.getGameId().equals(gameId)) { + // Imported Sierra game matches, so add without any prompt. + textInputResponseHandler.inputTextResult(true, gameName); + } else { + // Imported game does not match what was clicked. + dialogHandler.showMessageDialog( + "The selected AGI game does not appear to match '" + + appConfigItem.getName() + "'."); + textInputResponseHandler.inputTextResult(false, null); + } + } else { + // Normal 'Add Game', i.e. add new game, not import Sierra game. + dialogHandler.promptForTextInput("Confirm name of AGI game", + gameName, textInputResponseHandler); + } } } });