New Icon and Thumbnails for wads

This commit is contained in:
Simon 2016-03-05 11:34:12 +00:00
parent ca1d92e24c
commit 21cc2a3a67
14 changed files with 90 additions and 43 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

@ -24,9 +24,13 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
public boolean please_abort = false;
private String url = "https://www.dropbox.com/s/whngowjwpkwjht2/freedoom.zip?dl=1";
private String freedoomZip = DoomTools.GetDVRFolder() + "/freedoom.zip";
private String wadfile = DoomTools.GetDVRFolder() + "/freedoom.wad";
private String url = "https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip";
private String freedoomZip = DoomTools.GetDVRFolder() + "/freedoom-0.10.1.zip";
//OLD Freedom
//private String url = "https://www.dropbox.com/s/whngowjwpkwjht2/freedoom.zip?dl=1";
//private String freedoomZip = DoomTools.GetDVRFolder() + "/freedoom.zip";
//private String wadfile = DoomTools.GetDVRFolder() + "/freedoom.wad";
public DownloadTask set_context(Context context){
this.context = context;
@ -147,7 +151,7 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
.renameTo(new File(freedoomZip));
// done
publishProgress("download done" );
publishProgress("download done");
SystemClock.sleep(2000);
@ -157,7 +161,11 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
Log.i("DownloadTask.java", "extracting WAD data");
ZipFile file = new ZipFile (freedoomZip);
extract_file( file, "freedoom.wad", wadfile);
//extract_file( file, "freedoom-0.10.1\\COPYING", DoomTools.GetDVRFolder() + File.separator + "COPYING.txt");
//extract_file( file, "freedoom-0.10.1\\CREDITS", DoomTools.GetDVRFolder() + File.separator + "CREDITS.txt");
extract_file( file, "freedoom-0.10.1/README.html", DoomTools.GetDVRFolder() + File.separator + "README.html");
extract_file( file, "freedoom-0.10.1/freedoom1.wad", DoomTools.GetDVRFolder() + File.separator + "freedoom1.wad");
extract_file( file, "freedoom-0.10.1/freedoom2.wad", DoomTools.GetDVRFolder() + File.separator + "freedoom2.wad");
file.close();
@ -167,7 +175,7 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
pd.getButton(ProgressDialog.BUTTON_POSITIVE).setText("Done");
SystemClock.sleep(1000);
}
private void extract_file( ZipFile file, String entry_name, String output_name ) throws Exception{
@ -175,51 +183,52 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
Log.i( "DownloadTask.java", "extracting " + entry_name + " to " + output_name);
String short_name = new File(output_name).getName();
// create output directory
publishProgress("Extracting Freedoom Zip" );
new File(output_name).getParentFile().mkdirs();
ZipEntry entry = file.getEntry(entry_name);
if ( entry.isDirectory() ){
if ( entry.isDirectory() ){
Log.i( "DownloadTask.java", entry_name + " is a directory");
new File(output_name).mkdir();
return;
}
InputStream is = null;
FileOutputStream fos = null;
is = file.getInputStream(entry);
fos = new FileOutputStream ( output_name+".part" );
byte[] buffer = new byte [4096];
int totalcount =0;
long tprint = SystemClock.uptimeMillis();
while(true){
if (please_abort)
throw new Exception("aborting") ;
throw new Exception("aborting") ;
int count = is.read (buffer);
//Log.i( "DownloadTask.java", "extracted " + count + " bytes");
if ( count<=0 ) break;
fos.write (buffer, 0, count);
totalcount += count;
long tnow = SystemClock.uptimeMillis();
if ( (tnow-tprint)> 1000) {
float size_MB = totalcount * (1.0f/(1<<20));
publishProgress( String.format("%s : extracted %.1f MB",
short_name, size_MB));
@ -229,17 +238,17 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
is.close();
fos.close();
/// rename part file
new File(output_name+".part" )
.renameTo(new File(output_name));
// done
publishProgress( String.format("%s : done.",
short_name));
}
@Override
protected Void doInBackground(Void... unused) {

View file

@ -205,7 +205,7 @@ public class MainActivity
// set dialog message
alertDialogBuilder
.setMessage("Would you like to download the free FREEDOOM WAD (8MB)?\n\nIf you own or purchase the full game of Doom/Doom2 (or any other wad)you can click \'Cancel\' and copy the WAD file to the folder:\n\n{phonememory}/DVR")
.setMessage("Would you like to download the free Freedoom WADs (17.5MB)?\n\nIf you own or purchase the full game of Doom/Doom2 (or any other wad)you can click \'Cancel\' and copy the WAD file to the folder:\n\n{phonememory}/DVR")
.setCancelable(false)
.setPositiveButton("Download", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
@ -275,6 +275,8 @@ public class MainActivity
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, splashTexture[0]);
openGL.CopyBitmapToTexture(bmp, splashTexture[0]);
bmp.recycle();
}
@Override
@ -322,7 +324,7 @@ public class MainActivity
public void onDrawEye(Eye eye) {
if (!mShowingSpashScreen && mWADChooser.choosingWAD())
{
mWADChooser.onDrawEye(eye);
mWADChooser.onDrawEye(eye, this);
}
else if (mDVRInitialised || mShowingSpashScreen) {
@ -483,6 +485,8 @@ public class MainActivity
mPlayer.stop();
mPlayer.release();
mShowingSpashScreen = false;
mWADChooser.Initialise();
}
}

View file

@ -1,17 +1,25 @@
package com.drbeef.dvr;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.util.Pair;
import com.google.vrtoolkit.cardboard.Eye;
import java.io.File;
import java.io.InputStream;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import doom.util.DoomTools;
import doom.util.Natives;
@ -22,12 +30,22 @@ import doom.util.Natives;
public class WADChooser {
OpenGL openGL = null;
List<String> wads = new ArrayList<String>();
Map<String, String> wadThumbnails = new HashMap<String, String>();
private int selectedWAD = 0;
WADChooser(OpenGL openGL) {
this.openGL = openGL;
}
public void Initialise()
{
wadThumbnails.put(new String("doom.wad"), new String("d1.png"));
wadThumbnails.put(new String("doom2.wad"), new String("d2.png"));
wadThumbnails.put(new String("freedoom.wad"), new String("fd.png"));
wadThumbnails.put(new String("freedoom1.wad"), new String("fd1.png"));
wadThumbnails.put(new String("freedoom2.wad"), new String("fd2.png"));
File[] files = new File(DoomTools.GetDVRFolder()).listFiles();
@ -71,14 +89,32 @@ public class WADChooser {
selectedWAD = wads.size()-1;
}
void DrawWADName()
void DrawWADName(Context ctx)
{
// Create an empty, mutable bitmap
Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444);
// get a canvas to paint over the bitmap
Canvas canvas = new Canvas(bitmap);
bitmap.eraseColor(0);
Paint paint = new Paint();
if (wadThumbnails.containsKey(GetChosenWAD().toLowerCase())) {
try {
AssetManager assets = ctx.getAssets();
InputStream in = assets.open("thumbnails/" + wadThumbnails.get(GetChosenWAD().toLowerCase()));
Bitmap thumbnail = BitmapFactory.decodeStream(in);
in.close();
canvas.drawBitmap(thumbnail, null, new Rect(0, 0, 256, 200), paint);
} catch (Exception e) {
e.printStackTrace();
}
}
// get a background image from resources
// note the image format must match the bitmap format
// Drawable background = context.getResources().getDrawable(R.drawable.background);
@ -86,21 +122,19 @@ public class WADChooser {
// background.draw(canvas); // draw the background to our bitmap
// Draw the text
Paint textPaint = new Paint();
textPaint.setTextSize(20);
paint.setTextSize(20);
textPaint.setAntiAlias(true);
textPaint.setARGB(0xff, 0xff, 0x20, 0x00);
paint.setAntiAlias(true);
paint.setARGB(0xff, 0xff, 0x20, 0x00);
// draw the text centered
canvas.drawText("Choose WAD:", 16, 60, textPaint);
canvas.drawText("<- " + GetChosenWAD() + " ->", 16, 112, textPaint);
canvas.drawText("<- " + GetChosenWAD() + " ->", 16, 220, paint);
openGL.CopyBitmapToTexture(bitmap, openGL.fbo.ColorTexture[0]);
}
public void onDrawEye(Eye eye) {
public void onDrawEye(Eye eye, Context ctx) {
DrawWADName();
DrawWADName(ctx);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(eye.getViewport().x, eye.getViewport().y,

View file

@ -35,7 +35,7 @@ public class DoomTools {
// Game files we can handle
public static final String[] DOOM_WADS =
{"freedoom.wad", "freedm.wad", "doom.wad", "doom2.wad"};
{"freedoom.wad", "freedoom1.wad", "freedoom2.wad", "freedm.wad", "doom.wad", "doom2.wad"};
// These are required for the game to run
public static final String REQUIRED_DOOM_WAD = "prboom.wad";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 17 KiB