mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2025-04-12 04:00:48 +00:00
java: added check for game files
This commit is contained in:
parent
3cb419f9c0
commit
2ad621568c
1 changed files with 64 additions and 2 deletions
|
@ -1,28 +1,90 @@
|
|||
package org.etlegacy.app;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.erz.joysticklibrary.JoyStick;
|
||||
import com.erz.joysticklibrary.JoyStick.JoyStickListener;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ETLActivity extends SDLActivity implements JoyStickListener
|
||||
{
|
||||
private Bitmap getBitmapFromAsset(String strName)
|
||||
{
|
||||
private String dir_etl;
|
||||
|
||||
private boolean checkGameFiles() {
|
||||
|
||||
ContextWrapper c = new ContextWrapper(this);
|
||||
dir_etl = c.getFilesDir().getPath();
|
||||
//Toast.makeText(this, c.getFilesDir().getPath(), Toast.LENGTH_LONG).show();
|
||||
|
||||
File etmain_dir = new File(dir_etl.concat("etmain"));
|
||||
if(etmain_dir.exists() == false)
|
||||
{
|
||||
Log.e("SDL","Creating" + etmain_dir + "etmain");
|
||||
etmain_dir.mkdir();
|
||||
}
|
||||
|
||||
File legacy_dir = new File(dir_etl.concat("legacy"));
|
||||
if(legacy_dir.exists() == false)
|
||||
{
|
||||
Log.e("SDL", "Creating" + legacy_dir + "legacy");
|
||||
legacy_dir.mkdir();
|
||||
}
|
||||
|
||||
/* Draw Dialog Box */
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getApplicationContext());
|
||||
alertDialogBuilder.setTitle("ET Legacy");
|
||||
alertDialogBuilder.setMessage("Do you want to download files required by game to run ?")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO:Implement DownloadManager here.
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// if clicked no finish activity and close app
|
||||
ETLActivity.this.finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
/* Check if pak0.pk3-pak2.pk3 are around */
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
String pak_filename = "pak" + i + ".pk3";
|
||||
File etl_pak_file = new File(dir_etl.concat("etmain").concat("/") + pak_filename);
|
||||
if(etl_pak_file.exists() == false)
|
||||
{
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Bitmap getBitmapFromAsset(String strName) {
|
||||
AssetManager assetManager = getAssets();
|
||||
InputStream istr = null;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue