v0.7.1c: removed android-specific code from several classes in core

This commit is contained in:
Evan Debenham 2019-01-10 20:30:13 -05:00
parent 18f72cd5ac
commit 7dffe6bf23
11 changed files with 38 additions and 33 deletions

View File

@ -104,6 +104,10 @@ public class SmartTexture extends Texture {
height = bitmap.getHeight();
}
public int getPixel( int x, int y ){
return bitmap.getPixel(x, y);
}
public void reload() {
id = -1;
generate();

View File

@ -21,7 +21,12 @@
package com.watabou.utils;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import com.watabou.noosa.Game;
public class DeviceCompat {
@ -40,5 +45,14 @@ public class DeviceCompat {
public static boolean usesISO_8859_1(){
return Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO;
}
public static void openURI( String URI ){
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( URI ) );
Game.instance.startActivity( intent );
}
public static void log( String tag, String message ){
Log.i( tag, message );
}
}

View File

@ -21,8 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.actors;
import android.util.SparseArray;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
@ -31,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.SparseArray;
import java.util.HashSet;

View File

@ -21,8 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.effects;
import android.annotation.SuppressLint;
import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Blending;
@ -51,7 +49,6 @@ public class Flare extends Visual {
private int nRays;
@SuppressLint("FloatMath")
public Flare( int nRays, float radius ) {
super( 0, 0, 0, 0 );

View File

@ -30,6 +30,7 @@ import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.noosa.Image;
//TODO externalize bitmap stuff to SPD-classes
public class Halo extends Image {
private static final Object CACHE_KEY = Halo.class;

View File

@ -21,9 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.effects;
import android.annotation.SuppressLint;
import android.util.SparseArray;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
@ -32,6 +29,7 @@ import com.watabou.noosa.particles.Emitter;
import com.watabou.utils.ColorMath;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
import com.watabou.utils.SparseArray;
public class Speck extends Image {
@ -79,7 +77,7 @@ public class Speck extends Image {
private static TextureFilm film;
private static SparseArray<Emitter.Factory> factories = new SparseArray<Emitter.Factory>();
private static SparseArray<Emitter.Factory> factories = new SparseArray<>();
public Speck() {
super();
@ -367,7 +365,6 @@ public class Speck extends Image {
left = lifespan;
}
@SuppressLint("FloatMath")
@Override
public void update() {
super.update();

View File

@ -21,9 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import android.content.Intent;
import android.net.Uri;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
@ -34,10 +31,10 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.input.Touchscreen.Touch;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.RenderedText;
import com.watabou.noosa.TouchArea;
import com.watabou.utils.DeviceCompat;
public class AboutScene extends PixelScene {
@ -98,8 +95,7 @@ public class AboutScene extends PixelScene {
TouchArea shpxhotArea = new TouchArea( shpxlink.left(), shpxlink.top(), shpxlink.width(), shpxlink.height() ) {
@Override
protected void onClick( Touch touch ) {
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://" + LNK_SHPX ) );
Game.instance.startActivity( intent );
DeviceCompat.openURI( "https://" + LNK_SHPX );
}
};
add( shpxhotArea );
@ -140,8 +136,7 @@ public class AboutScene extends PixelScene {
TouchArea hotArea = new TouchArea( wataLink.left(), wataLink.top(), wataLink.width(), wataLink.height() ) {
@Override
protected void onClick( Touch touch ) {
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://" + LNK_WATA ) );
Game.instance.startActivity( intent );
DeviceCompat.openURI( "https://" + LNK_WATA );
}
};
add( hotArea );

View File

@ -21,8 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.sprites;
import android.graphics.Bitmap;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
@ -33,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Matrix;
import com.watabou.glwrap.Vertexbuffer;
@ -328,11 +327,11 @@ public class ItemSprite extends MovieClip {
}
public static int pick( int index, int x, int y ) {
Bitmap bmp = TextureCache.get( Assets.ITEMS ).bitmap;
int rows = bmp.getWidth() / SIZE;
SmartTexture tx = TextureCache.get( Assets.ITEMS );
int rows = tx.width / SIZE;
int row = index / rows;
int col = index % rows;
return bmp.getPixel( col * SIZE + x, row * SIZE + y );
return tx.getPixel( col * SIZE + x, row * SIZE + y );
}
public static class Glowing {

View File

@ -21,10 +21,9 @@
package com.shatteredpixel.shatteredpixeldungeon.tiles;
import android.util.SparseIntArray;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.watabou.utils.Random;
import com.watabou.utils.SparseArray;
import java.util.Arrays;
import java.util.HashSet;
@ -115,7 +114,7 @@ public class DungeonTileSheet {
public static final int CHASM_WATER = CHASM+4;
//tiles that can stitch with chasms (from above), and which visual represents the stitching
public static SparseIntArray chasmStitcheable = new SparseIntArray(32);
public static SparseArray<Integer> chasmStitcheable = new SparseArray<>();
static {
//floor
chasmStitcheable.put( Terrain.EMPTY, CHASM_FLOOR );
@ -343,7 +342,7 @@ public class DungeonTileSheet {
**********************************************************************/
//These visuals always directly represent a game tile with no stitching required
public static SparseIntArray directVisuals = new SparseIntArray(32);
public static SparseArray<Integer> directVisuals = new SparseArray<>();
static {
directVisuals.put(Terrain.EMPTY, FLOOR);
directVisuals.put(Terrain.GRASS, GRASS);
@ -366,7 +365,7 @@ public class DungeonTileSheet {
}
//These visuals directly represent game tiles (no stitching) when terrain is being shown as flat
public static SparseIntArray directFlatVisuals = new SparseIntArray(32);
public static SparseArray<Integer> directFlatVisuals = new SparseArray<>();
static {
directFlatVisuals.put(Terrain.WALL, FLAT_WALL);
directFlatVisuals.put(Terrain.DOOR, FLAT_DOOR);
@ -401,7 +400,7 @@ public class DungeonTileSheet {
}
//These alt visuals will trigger 50% of the time (45% of the time if a rare alt is also present)
public static SparseIntArray commonAltVisuals = new SparseIntArray(32);
public static SparseArray<Integer> commonAltVisuals = new SparseArray<>();
static {
commonAltVisuals.put(FLOOR, FLOOR_ALT_1);
commonAltVisuals.put(GRASS, GRASS_ALT);
@ -426,7 +425,7 @@ public class DungeonTileSheet {
}
//These alt visuals trigger 5% of the time (and also override common alts when they show up)
public static SparseIntArray rareAltVisuals = new SparseIntArray(32);
public static SparseArray<Integer> rareAltVisuals = new SparseArray<>();
static {
rareAltVisuals.put(FLOOR, FLOOR_ALT_2);
}

View File

@ -21,9 +21,8 @@
package com.shatteredpixel.shatteredpixeldungeon.utils;
import android.util.Log;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.DeviceCompat;
import com.watabou.utils.Signal;
public class GLog {
@ -43,7 +42,7 @@ public class GLog {
text = Messages.format( text, args );
}
Log.i( TAG, text );
DeviceCompat.log( TAG, text );
update.dispatch( text );
}

View File

@ -44,6 +44,7 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.RenderedText;
//This class makes use of the android EditText component to handle text input
//TODO externalize android-specific code to SPD-classes
public class WndTextInput extends Window {
private EditText textInput;