Added loading of games by opening the main.lua file

This commit is contained in:
fysx
2014-10-22 11:54:04 +02:00
parent b20f7e7302
commit 72b2fcd4eb
2 changed files with 18 additions and 6 deletions
+11 -3
View File
@@ -2,6 +2,7 @@ package org.love2d.android;
import org.libsdl.app.SDLActivity;
import java.util.List;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
@@ -45,11 +46,18 @@ public class GameActivity extends SDLActivity {
Uri game = this.getIntent().getData();
if (game != null) {
if (game.getScheme().equals ("file")) {
gamePath = game.getPath();
// If we were given the path of a main.lua then use its
// directory. Otherwise use full path.
List<String> path_segments = game.getPathSegments();
if (path_segments.get(path_segments.size() - 1).equals("main.lua")) {
gamePath = game.getPath().substring(0, game.getPath().length() - "main.lua".length());
} else {
gamePath = game.getPath();
}
} else {
copyGameToCache (game);
}
Log.d("GameActivity", "Selected the file: " + getGamePath());
Log.d("GameActivity", "Opening game from: " + getGamePath());
}
super.onCreate(savedInstanceState);
@@ -72,7 +80,7 @@ public class GameActivity extends SDLActivity {
public static String getGamePath() {
Log.d ("GameActivity", "called getGamePath(), game path = " + gamePath);
return gamePath;
return gamePath;
}
public static DisplayMetrics getMetrics() {