1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

Android improvements and version update

This commit is contained in:
Zeno Rogue 2017-07-25 00:58:14 +02:00
parent f5e5977bbe
commit 3267c2dc23
4 changed files with 22 additions and 6 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.roguetemple.hyperroid" package="com.roguetemple.hyperroid"
android:versionCode="10003" android:versionName="10.0c" android:versionCode="10005" android:versionName="10.0e"
android:installLocation="auto"> android:installLocation="auto">
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> --> <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
<!-- <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" /> --> <!-- <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" /> -->

View File

@ -5,8 +5,11 @@ import javax.microedition.khronos.opengles.GL10;
// import android.graphics.Paint; // import android.graphics.Paint;
// import android.graphics.Path; // import android.graphics.Path;
import android.content.Context;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.PowerManager;
// bimport android.widget.Toast; // bimport android.widget.Toast;
import com.android.texample.GLText; import com.android.texample.GLText;
@ -25,7 +28,13 @@ public class HyperRenderer implements GLSurfaceView.Renderer {
public void onDrawFrame(GL10 gl) { public void onDrawFrame(GL10 gl) {
if(game.forceCanvas) return; if(game.forceCanvas) return;
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
PowerManager pm = (PowerManager) game.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? pm.isInteractive() : pm.isScreenOn();
if(!isScreenOn) return;
if(!game.activityVisible) return;
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
synchronized(game) { synchronized(game) {
game.hv.updateGame(); game.hv.updateGame();
game.draw(); game.draw();

View File

@ -339,10 +339,13 @@ public class HyperRogue extends Activity {
int lastland; int lastland;
int curpos[]; int curpos[];
float curvol; float curvol;
public static boolean activityVisible = true;
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
activityVisible = false;
boolean keep; boolean keep;
@ -392,6 +395,7 @@ public class HyperRogue extends Activity {
} }
protected void onResume() { protected void onResume() {
activityVisible = true;
super.onResume(); super.onResume();
if(backgroundmusic != null) { if(backgroundmusic != null) {
try {backgroundmusic.prepare(); } catch(Exception e) {} try {backgroundmusic.prepare(); } catch(Exception e) {}

View File

@ -1,5 +1,6 @@
package com.roguetemple.hyperroid; package com.roguetemple.hyperroid;
import android.app.KeyguardManager;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -8,6 +9,7 @@ import android.graphics.Path;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode; import android.graphics.PorterDuffXfermode;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.AttributeSet; import android.util.AttributeSet;
@ -169,7 +171,7 @@ public class HyperView extends View {
public void updateGame() { public void updateGame() {
lasttick = curtick; lasttick = curtick;
curtick = (int)SystemClock.elapsedRealtime(); curtick = (int)SystemClock.elapsedRealtime();
if(clickcnt > 0) clickcnt--; if(clickcnt > 0) clickcnt--;
game.update(width, height, curtick, mousex, mousey, clicked | ((clickcnt & 1) > 0)); game.update(width, height, curtick, mousex, mousey, clicked | ((clickcnt & 1) > 0));
@ -184,9 +186,10 @@ public class HyperView extends View {
super.onDraw(canvas); super.onDraw(canvas);
PowerManager pm = (PowerManager) game.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) game.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = pm.isScreenOn(); boolean isScreenOn = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? pm.isInteractive() : pm.isScreenOn();
if(!isScreenOn) return; if(!isScreenOn) return;
if(!game.activityVisible) return;
dc = canvas; dc = canvas;
width = getWidth(); width = getWidth();
height = getHeight(); height = getHeight();