Skip to content

Commit

Permalink
Implemented cleared of the URL path and hash when a game import is no…
Browse files Browse the repository at this point in the history
…t successful.
  • Loading branch information
lanceewing committed Sep 18, 2024
1 parent 4744d23 commit 29b3f71
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/com/agifans/agile/AgileRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,6 @@ private void updateGameClock() {
public abstract boolean isMobile();

public abstract String slugify(String input);

public abstract void cancelImport();
}
4 changes: 4 additions & 0 deletions core/src/main/java/com/agifans/agile/HomeScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,8 @@ public void run() {
public void importTypeResult(boolean success, ImportType importType) {
if (success) {
importGameUsingOpenFileDialog(appConfigItem, importType);
} else {
agile.getAgileRunner().cancelImport();
}
}
});
Expand Down Expand Up @@ -961,6 +963,8 @@ public void inputTextResult(boolean success, String text) {
dialogHandler.promptForTextInput("Confirm name of AGI game",
gameName, textInputResponseHandler);
}
} else {
agile.getAgileRunner().cancelImport();
}
}
});
Expand Down
19 changes: 14 additions & 5 deletions html/src/main/java/com/agifans/agile/gwt/GwtAgileRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,21 @@ public void stop() {
stopped = true;
}

private void clearUrl() {
String newURL = Window.Location.createUrlBuilder()
.setPath("/")
.setHash(null)
.buildString();
updateURLWithoutReloading(newURL);
}

@Override
public void reset() {
// Resets to the original state, as if a game has not been previously run.
stopped = false;
worker = null;

String newURL = Window.Location.createUrlBuilder()
.setPath("/")
.setHash(null)
.buildString();
updateURLWithoutReloading(newURL);
clearUrl();
}

@Override
Expand Down Expand Up @@ -350,4 +354,9 @@ private native String slugifyHtml(String input) /*-{
return slug;
}-*/;

@Override
public void cancelImport() {
clearUrl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public void onFileResultsReady(GwtOpenFileResult[] openFileResultArray) {
// The game file map does not contain the minimum set of files.
openFileResponseHandler.openFileResult(false, null, null, null);
}
} else {
// No files selected.
openFileResponseHandler.openFileResult(false, null, null, null);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,9 @@ public String slugify(String input) {

return slug;
}

@Override
public void cancelImport() {
// Nothing to do for Desktop.
}
}

0 comments on commit 29b3f71

Please sign in to comment.