mirror of
https://github.com/love2d/love-android.git
synced 2026-08-16 08:11:44 +02:00
Added loading of games by opening the main.lua file
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user