Skip to content

Commit

Permalink
Added three variations of behaviour for game import.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Feb 26, 2024
1 parent 1fbbfd3 commit c72619c
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions core/src/main/java/com/agifans/agile/HomeScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
});
Expand Down

0 comments on commit c72619c

Please sign in to comment.